author Robert Strong <>
Mon, 22 Aug 2016 12:48:16 -0700
changeset 347791 ddd7e7dd100e8f631696a0060f7ac5bcb2345d0b
parent 347611 c44ddf4b793791d33ebcacd5eff4a66fe15be3cc
child 347900 abe478444437c9d310eafec265d5f9441c5f13bf
child 350856 a88047e08c2f841bf29c64714cefbac7ac21e9c3
permissions -rw-r--r--
Bug 1287176 client code - Status file not written for staging errors. r=mhowell, a=rkothari

# -*- Mode: python; 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

# Profiling
# ==============================================================
# Some of the options here imply an option from js/moz.configure,
# so, need to be declared before the include.
option('--enable-systrace', env='MOZ_USE_SYSTRACE',
       help='Turn on systrace for the Gecko profiler on android/b2g')

@depends('--enable-systrace', target)
def systrace(value, target):
    if value and target.os != 'Android':
        die('--enable-systrace cannot be used when targeting %s',
    if value:
        return True

set_define('MOZ_USE_SYSTRACE', systrace)

option('--enable-jprof', env='MOZ_JPROF',
       help='Enable jprof profiling tool (needs mozilla/tools/jprof)')

def jprof(value):
    if value:
        return True

set_config('MOZ_JPROF', jprof)
set_define('MOZ_JPROF', jprof)
imply_option('--enable-profiling', jprof)

def sps_profiler(target):
    if target.os == 'Android':
        return target.cpu in ('arm', 'x86')
    elif target.kernel == 'Linux':
        return target.cpu in ('x86', 'x86_64')
    return target.os in ('OSX', 'WINNT')

def sps_profiler_define(value):
    if value:
        return True

set_config('MOZ_ENABLE_PROFILER_SPS', sps_profiler_define)
set_define('MOZ_ENABLE_PROFILER_SPS', sps_profiler_define)

option('--enable-dmd', env='MOZ_DMD',
       help='Enable Dark Matter Detector (heap profiler). '
            'Also enables jemalloc, replace-malloc and profiling')

def dmd(value):
    if value:
        return True

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

# JACK cubeb backend
# ==============================================================
option('--enable-jack', env='MOZ_JACK',
       help='Enable JACK audio backend.')

def jack(value):
    if value:
        return True

set_config('MOZ_JACK', jack)
set_define('MOZ_JACK', jack)

# Javascript engine
# ==============================================================

# L10N
# ==============================================================
option('--with-l10n-base', nargs=1, env='L10NBASEDIR',
       help='Path to l10n repositories')

def l10n_base(value):
    if value:
        path = value[0]
        if not os.path.isdir(path):
            die("Invalid value --with-l10n-base, %s doesn't exist", path)
        return os.path.realpath(os.path.abspath(path))

set_config('L10NBASEDIR', l10n_base)

# Default toolkit
# ==============================================================
# Normally, we'd want to use the `default` field on the option, but that
# requires --target to be resolved at --help time, which requires to run
# config.guess, which we want to avoid. Even better, we could actually set
# `choices` depending on the target, but that doesn't pan out for the same
# reason.
option('--enable-default-toolkit', nargs=1,
       choices=('cairo-windows', 'cairo-gtk2', 'cairo-gtk2-x11', 'cairo-gtk3',
                'cairo-cocoa', 'cairo-uikit', 'cairo-android',
       help='Select default toolkit')

@depends('--enable-default-toolkit', target)
def toolkit(value, target):
    # Define possible choices for each platform. The default is the first one
    # listed when there are several.
    os = target.os
    if target.os == 'WINNT':
        platform_choices = ('cairo-windows',)
    elif target.os == 'OSX':
        platform_choices = ('cairo-cocoa',)
    elif target.os == 'iOS':
        platform_choices = ('cairo-uikit',)
    elif target.os == 'Android':
        if value.origin == 'implied':
            # Trust values coming from imply_option() (used in
            # b2g/moz.configure).
            platform_choices = tuple(value)
            platform_choices = ('cairo-android',)
        platform_choices = ('cairo-gtk3', 'cairo-gtk2', 'cairo-gtk2-x11')

    if value:
        if value[0] not in platform_choices:
            die('`%s` is not a valid value for --enable-default-toolkit on %s\n'
                'Valid values: %s', value[0], os, ', '.join(platform_choices))
        return value[0]

    return platform_choices[0]

def toolkit(toolkit):
    if toolkit == 'cairo-gtk2-x11':
        widget_toolkit = 'gtk2'
        widget_toolkit = toolkit.replace('cairo-', '')
    return widget_toolkit

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

def toolkit_gtk(toolkit):
    if toolkit == 'gtk2':
        return '2'
    elif toolkit == 'gtk3':
        return '3'

set_define('MOZ_WIDGET_GTK', toolkit_gtk)

def toolkit_define(toolkit):
    if toolkit not in ('gtk2', 'gtk3', 'windows'):
        return 'MOZ_WIDGET_%s' % toolkit.upper()

set_define(toolkit_define, True)

option('--without-x', env='WITHOUT_X', help='Disable X11 support')

@depends('--without-x', toolkit)
def x11(value, toolkit):
    if not value:
        die('--without-x is not supported')

    x11_toolkits = ('gtk2', 'gtk3')
    if value and value.origin != 'default' and toolkit not in x11_toolkits:
        die('--with-x is only valid with --enable-default-toolkit={%s}',

    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
# ==============================================================
option('--with-gl-provider', nargs=1, help='Set GL provider backend type')

def gl_provider(value):
    if value:
        return value[0]

def gl_provider_define(provider):
    if provider:
        return 'GLContextProvider%s' % provider

set_define('MOZ_GL_PROVIDER', gl_provider_define)

@depends(gl_provider, x11)
def gl_default_provider(value, x11):
    if value:
        return value
    elif x11:
        return 'GLX'

set_config('MOZ_GL_PROVIDER', gl_provider)
set_config('MOZ_GL_DEFAULT_PROVIDER', gl_default_provider)

def gl_provider_define(provider):
    if provider:
        return 'GL_PROVIDER_%s' % provider

set_define(gl_provider_define, True)

# PDF printing
# ==============================================================
def pdf_printing(toolkit):
    if toolkit in ('windows', 'gtk2', 'gtk3', 'android', 'gonk'):
        return True

def pdf_surface_feature(pdf_printing):
    if pdf_printing:
        return '#define CAIRO_HAS_PDF_SURFACE 1'
        # CONFIGURE_SUBST_FILES need explicit empty values.
        return ''

set_config('MOZ_PDF_PRINTING', pdf_printing)
set_config('PDF_SURFACE_FEATURE', pdf_surface_feature)

# Event loop instrumentation
# ==============================================================
       help='Force-enable event loop instrumentation')

@depends('MOZ_INSTRUMENT_EVENT_LOOP', toolkit)
def instrument_event_loop(value, toolkit):
    if value or (toolkit in ('windows', 'gtk2', 'gtk3', 'cocoa', 'android',
                             'gonk') and value.origin == 'default'):
        return True

set_config('MOZ_INSTRUMENT_EVENT_LOOP', instrument_event_loop)
set_define('MOZ_INSTRUMENT_EVENT_LOOP', instrument_event_loop)

# Fontconfig Freetype
# ==============================================================
       help='Force-enable the use of fontconfig freetype')

@depends('USE_FC_FREETYPE', toolkit)
def fc_freetype(value, toolkit):
    if value or (toolkit in ('gtk2', 'gtk3') and
                 value.origin == 'default'):
        return True

add_old_configure_assignment('USE_FC_FREETYPE', fc_freetype)

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

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

# Windows Media Foundation support
# ==============================================================
       help='Disable support for Windows Media Foundation')

@depends('--disable-wmf', target)
def wmf(value, target):
    enabled = bool(value)
    if value.origin == 'default':
        # Enable Windows Media Foundation support by default.
        # Note our minimum SDK version is Windows 7 SDK, so we are (currently)
        # guaranteed to have a recent-enough SDK to build WMF.
        enabled = target.os == 'WINNT'
    if enabled and target.os != 'WINNT':
        die('Cannot enable Windows Media Foundation support on %s', target.os)
    if enabled:
        return True

set_config('MOZ_WMF', wmf)
set_define('MOZ_WMF', wmf)

# FFmpeg H264/AAC Decoding Support
# ==============================================================
       help='Disable FFmpeg for fragmented H264/AAC decoding')

@depends('--disable-ffmpeg', target)
def ffmpeg(value, target):
    enabled = bool(value)
    if value.origin == 'default':
        enabled = target.os not in ('Android', 'WINNT')
    if enabled:
        return True

set_config('MOZ_FFMPEG', ffmpeg)
set_define('MOZ_FFMPEG', ffmpeg)
imply_option('--enable-fmp4', ffmpeg, '--enable-ffmpeg')

# Built-in fragmented MP4 support.
# ==============================================================
option('--disable-fmp4', env='MOZ_FMP4',
       help='Disable support for in built Fragmented MP4 parsing')

@depends('--disable-fmp4', target, wmf, applemedia)
def fmp4(value, target, wmf, applemedia):
    enabled = bool(value)
    if value.origin == 'default':
        # target.os == 'Android' includes all B2G versions
        enabled = wmf or applemedia or target.os == 'Android'
    if enabled:
        return True

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

# EME Support
# ==============================================================
# Widevine is enabled by default in desktop browser builds.
@depends(build_project, '--help')
def eme_default(build_project, help):
    if build_project == 'browser':
        return 'widevine'

       help='Enable support for Encrypted Media Extensions')

@depends('--enable-eme', fmp4)
def eme(value, fmp4):
    enabled = bool(value)
    if value.origin == 'default':
        enabled = enabled or fmp4
    if enabled and not fmp4:
        die('Encrypted Media Extension support requires '
            'Fragmented MP4 support')
    if enabled:
        return True

def eme_modules(value):
    # Theoretically, we could pass `value` directly when it is a
    # PositiveOptionValue, but somehow, the JSON serialization in
    # outputs inconsistent data in some cases when we do (a closing bracket
    # without an opening one).
    return list(value) if value else []

set_config('MOZ_EME', eme)
set_define('MOZ_EME', eme)
set_config('MOZ_EME_MODULES', eme_modules)

       help='Select FORMAT of chrome files during packaging.',
       choices=('omni', 'jar', 'flat'),

def packager_format(value):
    return value[0]

set_config('MOZ_PACKAGER_FORMAT', packager_format)

@depends(host, build_project)
def jar_maker_format(host, build_project):
    # Multilocales for mobile/android use the same mergedirs for all locales,
    # so we can't use symlinks for those builds.
    if host.os == 'WINNT' or build_project == 'mobile/android':
        return 'flat'
    return 'symlink'

set_config('MOZ_JAR_MAKER_FILE_FORMAT', jar_maker_format)

def omnijar_name(toolkit):
    # Fennec's static resources live in the assets/ folder of the
    # APK.  Adding a path to the name here works because we only
    # have one omnijar file in the final package (which is not the
    # case on desktop), and necessitates some contortions during
    # packaging so that the resources in the omnijar are considered
    # as rooted at / and not as rooted at assets/ (which again is
    # not the case on desktop: there are omnijars rooted at webrtc/,
    # etc). handles changing the rooting of the single
    # omnijar.
    return 'assets/omni.ja' if toolkit == 'android' else 'omni.ja'

set_config('OMNIJAR_NAME', omnijar_name)

             help='Build Places if required',

             help='Build SocialAPI if required',

             help='Build Firefox Health Reporter Service',

             help='Build Sync Services if required')

             help='Build Services/CloudSync if required')

             help='Enable Android History instead of Places',

def check_places_and_android_history(places, android_history):
    if places and android_history:
        die('Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.')

# gpsd support
# ==============================================================
option('--enable-gpsd', env='MOZ_GPSD',
       help='Enable gpsd support')

def gpsd(value):
    return bool(value)

system_gpsd = pkg_check_modules('MOZ_GPSD', 'libgps >= 3.11', gpsd)

set_config('MOZ_GPSD', system_gpsd)

# Miscellaneous programs
# ==============================================================

check_prog('TAR', ('gnutar', 'gtar', 'tar'))
check_prog('UNZIP', ('unzip',))
check_prog('ZIP', ('zip',))