author Mike Hommey <>
Tue, 22 Mar 2016 14:21:32 +0900
changeset 313930 9d2b6f4c3ee8366365c16cee6cbda90c4688c743
parent 310958 85ead00f0a39583ccb7fcce767017d1ec6877094
child 314706 89b86fc355d7611a3a43872ee047bd32d651ddd1
permissions -rw-r--r--
Bug 1257823 - Move set_config() to the global scope. r=nalexander The way set_config is set currently makes it difficult to introspect moz.configure files to know what configuration items are being set, because they're hidden in the control flow of functions. This makes some of the moz.configure more convoluted, but this is why there are templates, and we can improve the recurring cases afterwards.

# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at

# For more complex and repetitive things, we can create templates
def check_compiler_flag(flag):
    def check(value):
        if value:
            return [flag]
    set_config('CFLAGS', check)
    return check


# A template that doesn't return functions can be used in @depends functions.
def fortytwo():
    return 42

def twentyone():
    yield 21

def check(value):
    if value:
        return fortytwo()

set_config('TEMPLATE_VALUE', check)

def check(value):
    if value:
        for val in twentyone():
            return val

set_config('TEMPLATE_VALUE_2', check)

# Templates can use @advanced too to import modules and get the full set of
# builtins.
def platform():
    import sys
    return sys.platform

option('--enable-advanced-template', help='Advanced template')
def check(value):
    if value:
        return platform()

set_config('PLATFORM', check)