Skip to content

Commit

Permalink
Bug 1257823 - Move add_old_configure_assignment() to the global scope…
Browse files Browse the repository at this point in the history
…. r=nalexander

Similar to set_config, set_define and imply_option, but this is a
sandboxed function that stays sandboxed.
  • Loading branch information
glandium committed Mar 24, 2016
1 parent 4f41b6f commit 7b36063
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 38 deletions.
44 changes: 28 additions & 16 deletions build/moz.configure/init.configure
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,16 @@ def extra_old_configure_args(help):
return []

@template
def add_old_configure_assignment(var, value):
@depends(old_configure_assignments)
@advanced
def add_old_configure_assignment(var, value_func):
from mozbuild.configure import DummyFunction
assert isinstance(value_func, DummyFunction)

@depends(old_configure_assignments, value_func)
@advanced
def add_assignment(assignments):
def add_assignment(assignments, value):
if value is None:
return
if value is True:
assignments.append('%s=1' % var)
elif value is False:
Expand Down Expand Up @@ -222,10 +228,10 @@ def virtualenv_python(env_python, build_env, mozconfig):
if not distutils.sysconfig.get_python_lib():
error('Could not determine python site packages directory')

add_old_configure_assignment('PYTHON', python)
return python

set_config('PYTHON', virtualenv_python)
add_old_configure_assignment('PYTHON', virtualenv_python)

# Inject mozconfig options
# ==============================================================
Expand Down Expand Up @@ -505,16 +511,11 @@ def target_variables(target):
else:
os_target = target.os
os_arch = target.kernel
add_old_configure_assignment('OS_TARGET', os_target)
add_old_configure_assignment('OS_ARCH', os_arch)

if target.os == 'Darwin' and target.cpu == 'x86':
os_test = 'i386'
else:
os_test = target.raw_cpu
add_old_configure_assignment('OS_TEST', os_test)

add_old_configure_assignment('CPU_ARCH', target.cpu)

return namespace(
OS_TARGET=os_target,
Expand All @@ -524,9 +525,16 @@ def target_variables(target):
)

set_config('OS_TARGET', delayed_getattr(target_variables, 'OS_TARGET'))
add_old_configure_assignment('OS_TARGET',
delayed_getattr(target_variables, 'OS_TARGET'))
set_config('OS_ARCH', delayed_getattr(target_variables, 'OS_ARCH'))
add_old_configure_assignment('OS_ARCH',
delayed_getattr(target_variables, 'OS_ARCH'))
set_config('OS_TEST', delayed_getattr(target_variables, 'OS_TEST'))
add_old_configure_assignment('OS_TEST',
delayed_getattr(target_variables, 'OS_TEST'))
set_config('CPU_ARCH', delayed_getattr(target, 'cpu'))
add_old_configure_assignment('CPU_ARCH', delayed_getattr(target, 'cpu'))
set_config('INTEL_ARCHITECTURE', delayed_getattr(target_variables,
'INTEL_ARCHITECTURE'))
set_config('TARGET_CPU', delayed_getattr(target, 'raw_cpu'))
Expand All @@ -539,12 +547,13 @@ def host_variables(host):
os_arch = 'GNU_kFreeBSD'
else:
os_arch = host.kernel
add_old_configure_assignment('HOST_OS_ARCH', os_arch)
return namespace(
HOST_OS_ARCH=os_arch,
)

set_config('HOST_OS_ARCH', delayed_getattr(host_variables, 'HOST_OS_ARCH'))
add_old_configure_assignment('HOST_OS_ARCH',
delayed_getattr(host_variables, 'HOST_OS_ARCH'))

@depends(target)
def target_is_windows(target):
Expand Down Expand Up @@ -624,8 +633,6 @@ def include_project_configure(project, external_source_dir, build_env, help):

base_dir = build_env.topsrcdir
if external_source_dir:
add_old_configure_assignment('EXTERNAL_SOURCE_DIR',
external_source_dir[0])
base_dir = os.path.join(base_dir, external_source_dir[0])

path = os.path.join(base_dir, project[0], 'moz.configure')
Expand All @@ -639,17 +646,18 @@ def external_source_dir(value):
return value[0]

set_config('EXTERNAL_SOURCE_DIR', external_source_dir)
add_old_configure_assignment('EXTERNAL_SOURCE_DIR', external_source_dir)


@depends(include_project_configure, check_build_environment, '--help')
def build_project(include_project_configure, build_env, help):
ret = os.path.dirname(os.path.relpath(include_project_configure,
build_env.topsrcdir))
add_old_configure_assignment('MOZ_BUILD_APP', ret)
return ret

set_config('MOZ_BUILD_APP', build_project)
set_define('MOZ_BUILD_APP', build_project)
add_old_configure_assignment('MOZ_BUILD_APP', build_project)


# set RELEASE_BUILD and NIGHTLY_BUILD variables depending on the cycle we're in
Expand All @@ -669,10 +677,8 @@ def milestone(build_env):
is_nightly = is_release = None

if 'a1' in milestone:
add_old_configure_assignment('NIGHTLY_BUILD', True)
is_nightly = True
elif 'a' not in milestone:
add_old_configure_assignment('RELEASE_BUILD', True)
is_release = True

return namespace(version=milestone,
Expand All @@ -682,8 +688,12 @@ def milestone(build_env):
set_config('GRE_MILESTONE', delayed_getattr(milestone, 'version'))
set_config('NIGHTLY_BUILD', delayed_getattr(milestone, 'is_nightly'))
set_define('NIGHTLY_BUILD', delayed_getattr(milestone, 'is_nightly'))
add_old_configure_assignment('NIGHTLY_BUILD',
delayed_getattr(milestone, 'is_nightly'))
set_config('RELEASE_BUILD', delayed_getattr(milestone, 'is_release'))
set_define('RELEASE_BUILD', delayed_getattr(milestone, 'is_release'))
add_old_configure_assignment('RELEASE_BUILD',
delayed_getattr(milestone, 'is_release'))


# This is temporary until js/src/configure and configure are merged.
Expand Down Expand Up @@ -714,4 +724,6 @@ include(include_project_configure)
@depends(gonkdir)
def gonkdir_for_old_configure(value):
if value:
add_old_configure_assignment('gonkdir', value)
return value

add_old_configure_assignment('gonkdir', gonkdir_for_old_configure)
9 changes: 5 additions & 4 deletions js/moz.configure
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ option(env='JS_STANDALONE', default=building_js,
@depends('JS_STANDALONE')
def js_standalone(value):
if value:
add_old_configure_assignment('JS_STANDALONE', True)
return True

set_config('JS_STANDALONE', js_standalone)
add_old_configure_assignment('JS_STANDALONE', js_standalone)

js_option('--disable-js-shell', default=building_js,
help='Do not build the JS shell')
Expand Down Expand Up @@ -62,10 +62,10 @@ def shared_js(shared_js, export_js):
if shared_js:
if not export_js:
error('Must export JS symbols when building a shared library.')
add_old_configure_assignment('JS_SHARED_LIBRARY', True)
return True

set_config('JS_SHARED_LIBRARY', shared_js)
add_old_configure_assignment('JS_SHARED_LIBRARY', shared_js)

@depends('--disable-shared-js', '--disable-export-js')
def exportable_js_api(shared_js, export_js):
Expand Down Expand Up @@ -122,11 +122,11 @@ def instruments(value, target):
error('--enable-instruments cannot be used when targeting %s'
% target.os)
if value:
add_old_configure_assignment('MOZ_INSTRUMENTS', True)
return True

set_config('MOZ_INSTRUMENTS', instruments)
set_define('MOZ_INSTRUMENTS', instruments)
add_old_configure_assignment('MOZ_INSTRUMENTS', instruments)
imply_option('--enable-profiling', instruments, reason='--enable-instruments')

js_option('--enable-callgrind', env='MOZ_CALLGRIND',
Expand All @@ -147,9 +147,10 @@ js_option('--enable-profiling', env='MOZ_PROFILING',
@depends('--enable-profiling')
def profiling(value):
if value:
add_old_configure_assignment('MOZ_PROFILING', True)
return True

add_old_configure_assignment('MOZ_PROFILING', profiling)

@depends(profiling, target)
def imply_vtune(value, target):
if value and (target.kernel == 'WINNT' or (target.kernel == 'Linux' and
Expand Down
25 changes: 16 additions & 9 deletions moz.configure
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ option('--disable-compile-environment',
@depends('--disable-compile-environment')
def compile_environment(value):
if value:
add_old_configure_assignment('COMPILE_ENVIRONMENT', True)
return True

set_config('COMPILE_ENVIRONMENT', compile_environment)
add_old_configure_assignment('COMPILE_ENVIRONMENT', compile_environment)


@depends('--help')
Expand Down Expand Up @@ -84,7 +84,9 @@ awk = check_prog('AWK', ('gawk', 'mawk', 'nawk', 'awk'))
# Until the AWK variable is not necessary in old-configure
@depends(awk)
def awk_for_old_configure(value):
add_old_configure_assignment('AWK', value)
return value

add_old_configure_assignment('AWK', awk_for_old_configure)


# Perl detection
Expand All @@ -94,7 +96,9 @@ perl = check_prog('PERL', ('perl5', 'perl'))
# Until the PERL variable is not necessary in old-configure
@depends(perl)
def perl_for_old_configure(value):
add_old_configure_assignment('PERL', value)
return value

add_old_configure_assignment('PERL', perl_for_old_configure)

@template
def perl_version_check(min_version):
Expand Down Expand Up @@ -145,14 +149,17 @@ def yasm_version(yasm):
version = Version(subprocess.check_output(
[yasm, '--version']
).splitlines()[0].split()[1])
# Until we move all the yasm consumers out of old-configure.
# bug 1257904
add_old_configure_assignment('_YASM_MAJOR_VERSION', version.major)
add_old_configure_assignment('_YASM_MINOR_VERSION', version.minor)
return version
except subprocess.CalledProcessError as e:
error('Failed to get yasm version: %s' % e.message)

# Until we move all the yasm consumers out of old-configure.
# bug 1257904
add_old_configure_assignment('_YASM_MAJOR_VERSION',
delayed_getattr(yasm_version, 'major'))
add_old_configure_assignment('_YASM_MINOR_VERSION',
delayed_getattr(yasm_version, 'minor'))

@depends(yasm, target)
def yasm_asflags(yasm, target):
if yasm:
Expand All @@ -171,8 +178,6 @@ def yasm_asflags(yasm, target):
asflags = '-f elf64'
if asflags:
asflags += ' -rnasm -pnasm'
# Until the YASM variable is not necessary in old-configure.
add_old_configure_assignment('YASM', True)
return asflags

set_config('YASM_ASFLAGS', yasm_asflags)
Expand All @@ -183,6 +188,8 @@ def have_yasm(value):
return True

set_config('HAVE_YASM', have_yasm)
# Until the YASM variable is not necessary in old-configure.
add_old_configure_assignment('YASM', have_yasm)


# Miscellaneous programs
Expand Down
17 changes: 8 additions & 9 deletions toolkit/moz.configure
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ option('--enable-dmd', env='MOZ_DMD',
@depends('--enable-dmd')
def dmd(value):
if value:
add_old_configure_assignment('MOZ_DMD', True)
return True

set_config('MOZ_DMD', dmd)
set_define('MOZ_DMD', dmd)
add_old_configure_assignment('MOZ_DMD', dmd)
imply_option('--enable-profiling', dmd)

# Javascript engine
Expand Down Expand Up @@ -138,11 +138,10 @@ def toolkit(toolkit):
widget_toolkit = 'gtk2'
else:
widget_toolkit = toolkit.replace('cairo-', '')
add_old_configure_assignment('MOZ_WIDGET_TOOLKIT', widget_toolkit)

return widget_toolkit

set_config('MOZ_WIDGET_TOOLKIT', toolkit)
add_old_configure_assignment('MOZ_WIDGET_TOOLKIT', toolkit)

@depends(toolkit)
def toolkit_gtk(toolkit):
Expand Down Expand Up @@ -173,15 +172,13 @@ def x11(value, toolkit):
error('--with-x is only valid with --enable-default-toolkit={%s}'
% ','.join(x11_toolkits))

if value and toolkit in x11_toolkits:
add_old_configure_assignment('MOZ_X11', True)

return True if value and toolkit in x11_toolkits else None

set_config('MOZ_ENABLE_XREMOTE', x11)
set_define('MOZ_ENABLE_XREMOTE', x11)
set_config('MOZ_X11', x11)
set_define('MOZ_X11', x11)
add_old_configure_assignment('MOZ_X11', x11)

# GL Provider
# ==============================================================
Expand Down Expand Up @@ -260,19 +257,21 @@ option(env='USE_FC_FREETYPE',
def fc_freetype(value, toolkit):
if value or (toolkit in ('gtk2', 'gtk3', 'qt') and
value.origin == 'default'):
add_old_configure_assignment('USE_FC_FREETYPE', True)
return True

add_old_configure_assignment('USE_FC_FREETYPE', fc_freetype)


# Apple platform decoder support
# ==============================================================
@depends(toolkit)
def applemedia(toolkit):
if toolkit in ('cocoa', 'uikit'):
add_old_configure_assignment('MOZ_APPLEMEDIA', True)
return True

set_config('MOZ_APPLEMEDIA', applemedia)
set_define('MOZ_APPLEMEDIA', applemedia)
add_old_configure_assignment('MOZ_APPLEMEDIA', applemedia)

# Windows Media Foundation support
# ==============================================================
Expand Down Expand Up @@ -325,11 +324,11 @@ def fmp4(value, target, wmf, applemedia):
# target.os == 'Android' includes all B2G versions
enabled = wmf or applemedia or target.os == 'Android'
if enabled:
add_old_configure_assignment('MOZ_FMP4', True)
return True

set_config('MOZ_FMP4', fmp4)
set_define('MOZ_FMP4', fmp4)
add_old_configure_assignment('MOZ_FMP4', fmp4)

# EME Support
# ==============================================================
Expand Down

0 comments on commit 7b36063

Please sign in to comment.