Beispiel #1
0
def _generate_test_framework_ninjas():
  # Build two versions of libgtest and libgmock that are built and linked with
  # STLport or libc++. It is used to build tests that depends on each library.
  _generate_gtest_ninja('libgtest', enable_libcxx=False)

  if not OPTIONS.run_tests():
    gtest_libcxx_instances = 0
  else:
    # libart-gtest.so, libarttest.so, and libnativebridgetest.so uses
    # libgtest_libc++.a. But when --disable-debug-code is specified,
    # libart-gtest.so is not built.
    if OPTIONS.is_debug_code_enabled():
      gtest_libcxx_instances = 3
    else:
      gtest_libcxx_instances = 2
  _generate_gtest_ninja('libgtest_libc++',
                        instances=gtest_libcxx_instances, enable_libcxx=True)

  # libartd.so for host uses libgtest_host.a. Although it is built with
  # libc++, it is not named libgtest_libc++_host.a by Android.mk.
  if OPTIONS.is_debug_code_enabled():
    _generate_gtest_ninja('libgtest_host', host=True, enable_libcxx=True)

  _generate_gmock_ninja('libgmock', enable_libcxx=False)
  _generate_gmock_ninja('libgmock_libc++', enable_libcxx=True)
Beispiel #2
0
def _generate_test_framework_ninjas():
    # Build two versions of libgtest and libgmock that are built and linked with
    # STLport or libc++. It is used to build tests that depends on each library.
    _generate_gtest_ninja('libgtest', enable_libcxx=False)

    if not OPTIONS.run_tests():
        gtest_libcxx_instances = 0
    else:
        # libart-gtest.so, libarttest.so, and libnativebridgetest.so uses
        # libgtest_libc++.a. But when --disable-debug-code is specified,
        # libart-gtest.so is not built.
        if OPTIONS.is_debug_code_enabled():
            gtest_libcxx_instances = 3
        else:
            gtest_libcxx_instances = 2
    _generate_gtest_ninja('libgtest_libc++',
                          instances=gtest_libcxx_instances,
                          enable_libcxx=True)

    # libartd.so for host uses libgtest_host.a. Although it is built with
    # libc++, it is not named libgtest_libc++_host.a by Android.mk.
    if OPTIONS.is_debug_code_enabled():
        _generate_gtest_ninja('libgtest_host', host=True, enable_libcxx=True)

    _generate_gmock_ninja('libgmock', enable_libcxx=False)
    _generate_gmock_ninja('libgmock_libc++', enable_libcxx=True)
Beispiel #3
0
def _convert_launch_chrome_options_to_external_metadata(parsed_args):
  metadata = parsed_args.additional_metadata

  for definition in manager.get_metadata_definitions():
    value = getattr(parsed_args, definition.python_name, None)
    if value is not None:
      metadata[definition.name] = value

  if bool(parsed_args.jdb_port or parsed_args.gdb):
    metadata['disableChildPluginRetry'] = True
    metadata['disableHeartbeat'] = True
    metadata['sleepOnBlur'] = False

  if (parsed_args.mode == 'atftest' or parsed_args.mode == 'system' or
      OPTIONS.get_system_packages()):
    # An app may briefly go through empty stack while running
    # addAccounts() in account manager service.
    # TODO(igorc): Find a more precise detection mechanism to support GSF,
    # implement empty stack timeout, or add a flag if this case is more common.
    metadata['allowEmptyActivityStack'] = True

  command = _generate_shell_command(parsed_args)
  if command:
    metadata['shell'] = command

  metadata['isDebugCodeEnabled'] = OPTIONS.is_debug_code_enabled()

  return metadata
Beispiel #4
0
def get_build_type():
    # Android has three build types, 'user', 'userdebug', and 'eng'.
    # 'user' is a build with limited access permissions for production.
    # 'eng' is a development configuration with debugging code. See,
    # https://source.android.com/source/building-running.html#choose-a-target.
    # ARC uses 'user' only when debug code is disabled.
    if OPTIONS.is_debug_code_enabled():
        return "eng"
    return "user"
Beispiel #5
0
def get_build_type():
    # Android has three build types, 'user', 'userdebug', and 'eng'.
    # 'user' is a build with limited access permissions for production.
    # 'eng' is a development configuration with debugging code. See,
    # https://source.android.com/source/building-running.html#choose-a-target.
    # ARC uses 'user' only when debug code is disabled.
    if OPTIONS.is_debug_code_enabled():
        return 'eng'
    return 'user'
    def build_gms_core_or_use_prebuilt(self):
        if OPTIONS.enable_art_aot():
            # Rule for pre-optimizing gms-core apk.
            boot_image_dir = os.path.join(build_common.get_android_fs_root(),
                                          'system/framework',
                                          build_common.get_art_isa())
            self.rule(
                'gms_core_apk_preoptimize',
                'src/build/gms_core_apk_preoptimize.py --input $in --output $out',
                description='Preoptimizing gmscore sub apks contained in $in')
            self.build(GmsCoreNinjaGenerator._APK_PATH,
                       'gms_core_apk_preoptimize',
                       GmsCoreNinjaGenerator._ORIGINAL_APK_PATH,
                       implicit=[
                           toolchain.get_tool('java', 'dex2oat'),
                           os.path.join(boot_image_dir, 'boot.art'),
                           os.path.join(boot_image_dir, 'boot.oat')
                       ])

        if not OPTIONS.internal_apks_source_is_internal():
            return

        flags = '--eng' if OPTIONS.is_debug_code_enabled() else ''
        build_log = os.path.join('out/gms-core-build/build.log')
        command = ('internal/build/build.py gms-core %s > %s 2>&1 || '
                   '(cat %s; exit 1)') % (flags, build_log, build_log)

        if OPTIONS.internal_apks_source() == 'internal-dev':
            # Only for local development.  play-services.apk dependes on jars below to
            # build, just to use ARC specific feature like ArcMessageBridge and
            # Tracing.  This dependency is a must-have for a clean build.  But this
            # dependency can cause unrelated framework change to trigger rebuild of
            # play-services.apk, which is very slow.  With this option, eng will self
            # manages the dependency, which is almost always satisfied.
            jars = []
        else:
            # Simply make these jars the dependencies of gms-core-build, which
            # references ArcMessage and ArcMessageBridge in the jar.  Note that these
            # jars changes often and is like to cause unnecessary rebuild of gms-core,
            # which is very slow.  We may think about a way to minimize the
            # dependency.
            #
            # See also: internal/mods/gms-core/vendor/unbundled_google/packages/ \
            #     OneUp/package/Android.mk
            #     OneUp/package/generate_package.mk
            jars = [
                build_common.get_build_path_for_jar('arc-services-framework',
                                                    subpath='classes.jar'),
                build_common.get_build_path_for_jar('framework',
                                                    subpath='classes.jar'),
            ]

        self.build(GmsCoreNinjaGenerator._ALL_OUTPUTS,
                   'run_shell_command',
                   implicit=['src/build/DEPS.arc-int'] + jars,
                   variables={'command': command})
Beispiel #7
0
def _filter_cflags_for_chromium_org(vars):
  append_cflags = []
  # TODO(http://crbug.com/509945): Use Gold once it's ready.
  strip_flags = ['-fuse-ld=gold', '-march=pentium4', '-finline-limit=64']
  if OPTIONS.is_arm():
    # ARM clang does not support these flags.
    strip_flags.extend(['-fno-partial-inlining', '-fno-early-inlining',
                        '-fno-tree-copy-prop', '-fno-tree-loop-optimize',
                        '-fno-move-loop-invariants',
                        '-Wa,-mimplicit-it=always'])
  if not OPTIONS.is_bare_metal_build():
    # nacl-clang supports -Oz, which is more aggressive than -Os.
    strip_flags.append('-Os')
  # TODO(crbug.com/346783): Remove this once we NaCl'ize PageAllocator.cpp.
  # It is only necessary for NaCl, but we do this for linux as well
  # to minimize platform differences.
  append_cflags.append('-DMEMORY_TOOL_REPLACES_ALLOCATOR')
  _update_flags(vars, append_cflags, strip_flags)
  # -finline-limit=32 experimentally provides the smallest binary across
  # the ni and nx targets.  Also specify -finline-functions so all functions
  # are candidates for inlining.
  size_opts = ['-finline-limit=32', '-finline-functions']
  if not OPTIONS.is_bare_metal_build():
    # -Oz is not valid for asmflags, so just add it for C and C++.
    vars.get_conlyflags().append('-Oz')
    vars.get_cxxflags().append('-Oz')
  # With these flags, compilers will not emit .eh_frame* sections and
  # the size of libwebviewchromium.so reduces from 84MB to 75MB on L.
  # As these options disables libgcc's _Unwind_Backtrace, we keep
  # using them for non-production build. Note GDB and breakpad can
  # produce backtraces without .eh_frame.
  #
  # It is intentional this condition is inconsistent with
  # ninja_generator.py and make_to_ninja.py. Removing .eh_frame from
  # production binary did not make a significant difference for file
  # size of L. We would rather prefer keeping .eh_frame for
  # _Unwind_Backtrace.
  if not OPTIONS.is_debug_code_enabled():
    size_opts += ['-fno-unwind-tables', '-fno-asynchronous-unwind-tables']
  vars.get_cflags()[:] = vars.get_cflags() + size_opts
  # dlopen fails for the following undefined reference without -mthumb
  # _ZN7WebCore26feLightingConstantsForNeonEv
  # TODO(crbug.com/358333): Investigate if this is actually needed.
  if OPTIONS.is_arm():
    vars.get_cflags().append('-mthumb')
  # OpenSSL makes wrong assumption that sizeof(long) == 8 under x86_64.
  # Remove the x86_64-specific include path to fall back to x86 config.
  # Note that this include path is set in many modules depending on OpenSSL,
  # not limited to third_party_openssl_openssl_gyp.a itself.
  if OPTIONS.is_nacl_x86_64():
    openssl_x64_include = (
        'android/external/chromium_org/third_party/openssl/config/x64')
    includes = vars.get_includes()
    if openssl_x64_include in includes:
      includes.remove(openssl_x64_include)
  def build_gms_core_or_use_prebuilt(self):
    if OPTIONS.enable_art_aot():
      # Rule for pre-optimizing gms-core apk.
      boot_image_dir = os.path.join(build_common.get_android_fs_root(),
                                    'system/framework',
                                    build_common.get_art_isa())
      self.rule(
          'gms_core_apk_preoptimize',
          'src/build/gms_core_apk_preoptimize.py --input $in --output $out',
          description='Preoptimizing gmscore sub apks contained in $in')
      self.build(GmsCoreNinjaGenerator._APK_PATH,
                 'gms_core_apk_preoptimize',
                 GmsCoreNinjaGenerator._ORIGINAL_APK_PATH,
                 implicit=[toolchain.get_tool('java', 'dex2oat'),
                           os.path.join(boot_image_dir, 'boot.art'),
                           os.path.join(boot_image_dir, 'boot.oat')])

    if not OPTIONS.internal_apks_source_is_internal():
      return

    flags = '--eng' if OPTIONS.is_debug_code_enabled() else ''
    build_log = os.path.join('out/gms-core-build/build.log')
    command = ('internal/build/build.py gms-core %s > %s 2>&1 || '
               '(cat %s; exit 1)') % (flags, build_log, build_log)

    if OPTIONS.internal_apks_source() == 'internal-dev':
      # Only for local development.  play-services.apk dependes on jars below to
      # build, just to use ARC specific feature like ArcMessageBridge and
      # Tracing.  This dependency is a must-have for a clean build.  But this
      # dependency can cause unrelated framework change to trigger rebuild of
      # play-services.apk, which is very slow.  With this option, eng will self
      # manages the dependency, which is almost always satisfied.
      jars = []
    else:
      # Simply make these jars the dependencies of gms-core-build, which
      # references ArcMessage and ArcMessageBridge in the jar.  Note that these
      # jars changes often and is like to cause unnecessary rebuild of gms-core,
      # which is very slow.  We may think about a way to minimize the
      # dependency.
      #
      # See also: internal/mods/gms-core/vendor/unbundled_google/packages/ \
      #     OneUp/package/Android.mk
      #     OneUp/package/generate_package.mk
      jars = [
          build_common.get_build_path_for_jar('arc-services-framework',
                                              subpath='classes.jar'),
          build_common.get_build_path_for_jar('framework',
                                              subpath='classes.jar'),
      ]

    self.build(GmsCoreNinjaGenerator._ALL_OUTPUTS,
               'run_shell_command',
               implicit=['src/build/DEPS.arc-int'] + jars,
               variables={'command': command})
Beispiel #9
0
def generate_binaries_depending_ninjas(_):
    if (not OPTIONS.is_bare_metal_i686() or not OPTIONS.is_optimized_build() or
            # None of the targets analyzed are currently built in the open source
            # repository.
            open_source.is_open_source_repo() or
            # Run the checker only when --disable-debug-code is specified. Locations
            # of static initializers differ depending on the debug-code option.
            OPTIONS.is_debug_code_enabled() or
            # The checker only works with debug symbols.
            not OPTIONS.is_debug_info_enabled()):
        # The static analysis tool's output varies between debug and non-debug
        # builds, so we pick non-debug as the default.
        return
    n = ninja_generator.NinjaGenerator('analyze_static_initializers')
    script = staging.as_staging(
        'android/external/chromium_org/tools/linux/dump-static-initializers.py'
    )
    n.rule(
        'analyze_static_initializers',
        command=('python src/build/run_python %s -d $in | head --lines=-1 | '
                 'egrep -ve \'^# .*\.cpp \' |'
                 'sed -e \'s/ T\.[0-9]*/ T.XXXXX/\' |'
                 'diff -u $expect - && touch $out' % script),
        description='analyze_static_initializers $in')
    libraries = build_common.CHECKED_LIBRARIES
    libraries_fullpath = [
        os.path.join(build_common.get_load_library_path(), lib)
        for lib in libraries
    ]
    for library in zip(libraries, libraries_fullpath):
        # You can manually update the text files by running
        #   src/build/update_static_initializer_expectations.py.
        expect = 'src/build/dump-static-initializers-%s-expected.txt' % library[
            0]
        result_path = os.path.join(
            build_common.get_build_dir(), 'dump_static_initializers',
            'dump_static_initializers.%s.result' % library[0])
        n.build(
            result_path,
            'analyze_static_initializers',
            library[1],
            variables={
                'out': result_path,
                'expect': expect
            },
            # Add |libraries_fullpath| to implicit= not to run the analyzer
            # script until all libraries in |libraries_fullpath| become ready.
            # This makes it easy to use
            # update_static_initializer_expectations.py especially when you
            # remove global variables from two or more libraries at the same
            # time.
            implicit=[script, expect] + libraries_fullpath)
Beispiel #10
0
def generate_binaries_depending_ninjas(_):
  if (not OPTIONS.is_bare_metal_i686() or
      not OPTIONS.is_optimized_build() or
      # None of the targets analyzed are currently built in the open source
      # repository.
      open_source.is_open_source_repo() or
      # Run the checker only when --disable-debug-code is specified. Locations
      # of static initializers differ depending on the debug-code option.
      OPTIONS.is_debug_code_enabled() or
      # The checker only works with debug symbols.
      not OPTIONS.is_debug_info_enabled()):
    # The static analysis tool's output varies between debug and non-debug
    # builds, so we pick non-debug as the default.
    return
  n = ninja_generator.NinjaGenerator('analyze_static_initializers')
  script = staging.as_staging(
      'android/external/chromium_org/tools/linux/dump-static-initializers.py')
  n.rule('analyze_static_initializers',
         command=('python src/build/run_python %s -d $in | head --lines=-1 | '
                  'egrep -ve \'^# .*\.cpp \' |'
                  'sed -e \'s/ T\.[0-9]*/ T.XXXXX/\' |'
                  'diff -u $expect - && touch $out' %
                  script),
         description='analyze_static_initializers $in')
  libraries = build_common.CHECKED_LIBRARIES
  libraries_fullpath = [
      os.path.join(build_common.get_load_library_path(), lib)
      for lib in libraries]
  for library in zip(libraries, libraries_fullpath):
    # You can manually update the text files by running
    #   src/build/update_static_initializer_expectations.py.
    expect = 'src/build/dump-static-initializers-%s-expected.txt' % library[0]
    result_path = os.path.join(build_common.get_build_dir(),
                               'dump_static_initializers',
                               'dump_static_initializers.%s.result' %
                               library[0])
    n.build(result_path, 'analyze_static_initializers', library[1],
            variables={'out': result_path, 'expect': expect},
            # Add |libraries_fullpath| to implicit= not to run the analyzer
            # script until all libraries in |libraries_fullpath| become ready.
            # This makes it easy to use
            # update_static_initializer_expectations.py especially when you
            # remove global variables from two or more libraries at the same
            # time.
            implicit=[script, expect] + libraries_fullpath)
Beispiel #11
0
def _get_tool_map():
    android_build_tools_dir = _get_android_build_tools_dir()
    android_sdk_build_tools_dir = get_android_sdk_build_tools_dir()

    return {
        'host': {
            'cxx': os.getenv('HOSTCXX', 'g++'),
            'cc': os.getenv('HOSTCC', 'gcc'),
            'asm': os.getenv('HOSTCC', 'gcc'),
            'ld': os.getenv('HOSTLD', 'g++'),
            'ar': os.getenv('HOSTAR', 'ar'),
            'nm': os.getenv('HOSTNM', 'nm'),
            'objcopy': os.getenv('HOSTOBJCOPY', 'objcopy'),
            'objdump': os.getenv('HOSTOBJDUMP', 'objdump'),
            'addr2line': os.getenv('HOSTADDR2LINE', 'addr2line'),
            'strip': os.getenv('HOSTSTRIP', 'strip'),
            'runner': _get_native_runner('host'),
            'valgrind_runner': _get_valgrind_runner('host'),
            'gdb': 'gdb',
            'create_nmf': _get_create_nmf(),
            'deps': [],
            'adb': _get_adb_path_for_localhost(),
            'clangxx': os.path.join(_CLANG_BIN_DIR, 'clang++'),
            'clang': os.path.join(_CLANG_BIN_DIR, 'clang'),
        },
        'nacl_i686': {
            'cxx':
            (os.path.join(get_nacl_toolchain_path(), 'x86_64-nacl-g++') +
             ' -m32'),
            'cc': (os.path.join(get_nacl_toolchain_path(), 'x86_64-nacl-gcc') +
                   ' -m32'),
            'asm':
            os.path.join(_PNACL_BIN_PATH, 'i686-nacl-clang'),
            'ld':
            os.path.join(get_nacl_toolchain_path(), 'i686-nacl-g++'),
            'ar':
            os.path.join(_PNACL_BIN_PATH, 'i686-nacl-ar'),
            'nm':
            os.path.join(_PNACL_BIN_PATH, 'i686-nacl-nm'),
            'objcopy':
            os.path.join(_PNACL_BIN_PATH, 'i686-nacl-objcopy'),
            'objdump':
            os.path.join(_PNACL_BIN_PATH, 'i686-nacl-objdump'),
            'addr2line':
            os.path.join(_PNACL_BIN_PATH, 'i686-nacl-addr2line'),
            'strip':
            os.path.join(_PNACL_BIN_PATH, 'i686-nacl-strip'),
            'runner':
            ' '.join(get_nacl_runner(32)),
            'runner_without_test_library':
            ' '.join(get_nacl_runner(32, use_test_library=False)),
            # The target does not support Valgrind. Use nacl_runner.
            'valgrind_runner':
            ' '.join(get_nacl_runner(32)),
            'valgrind_runner_without_test_library':
            ' '.join(get_nacl_runner(32, use_test_library=False)),
            'ncval':
            os.path.join(_NACL_TOOLS_PATH, 'ncval'),
            'gdb':
            os.path.join(get_nacl_toolchain_path(), 'i686-nacl-gdb'),
            'irt':
            'nacl_irt_x86_32.nexe',
            'deps': [_NACL_DEPS_PATH],
            'llvm_tblgen':
            build_common.get_build_path_for_executable('llvm-tblgen',
                                                       is_host=True),
            'clangxx':
            os.path.join(_PNACL_BIN_PATH, 'i686-nacl-clang++'),
            'clang':
            os.path.join(_PNACL_BIN_PATH, 'i686-nacl-clang'),
        },
        'nacl_x86_64': {
            'cxx':
            os.path.join(get_nacl_toolchain_path(), 'x86_64-nacl-g++'),
            'cc':
            os.path.join(get_nacl_toolchain_path(), 'x86_64-nacl-gcc'),
            'ld':
            os.path.join(get_nacl_toolchain_path(), 'x86_64-nacl-g++'),
            'asm':
            os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-clang'),
            'ar':
            os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-ar'),
            'nm':
            os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-nm'),
            'objcopy':
            os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-objcopy'),
            'objdump':
            os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-objdump'),
            'addr2line':
            os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-addr2line'),
            'strip':
            os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-strip'),
            'runner':
            ' '.join(get_nacl_runner(64)),
            'runner_without_test_library':
            ' '.join(get_nacl_runner(64, use_test_library=False)),
            # The target does not support Valgrind. Use nacl_runner.
            'valgrind_runner':
            ' '.join(get_nacl_runner(64)),
            'valgrind_runner_without_test_library':
            ' '.join(get_nacl_runner(64, use_test_library=False)),
            'ncval':
            os.path.join(_NACL_TOOLS_PATH, 'ncval'),
            'gdb':
            os.path.join(get_nacl_toolchain_path(), 'x86_64-nacl-gdb'),
            'irt':
            'nacl_irt_x86_64.nexe',
            'deps': [_NACL_DEPS_PATH],
            'llvm_tblgen':
            build_common.get_build_path_for_executable('llvm-tblgen',
                                                       is_host=True),
            'clangxx':
            os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-clang++'),
            'clang':
            os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-clang'),
        },
        'bare_metal_i686': {
            'cxx':
            os.getenv('TARGETCXX', 'g++-4.8'),
            'cc':
            os.getenv('TARGETCC', 'gcc-4.8'),
            'asm':
            os.getenv('TARGETCC', 'gcc-4.8'),
            'clangxx':
            os.path.join(_CLANG_BIN_DIR, 'clang++'),
            'clang':
            os.path.join(_CLANG_BIN_DIR, 'clang'),
            'ld':
            os.getenv('TARGETLD', 'g++-4.8'),
            'ar':
            os.getenv('TARGETAR', 'ar'),
            'nm':
            os.getenv('TARGETNM', 'nm'),
            'objcopy':
            os.getenv('TARGETOBJCOPY', 'objcopy'),
            'objdump':
            os.getenv('TARGETOBJDUMP', 'objdump'),
            'addr2line':
            os.getenv('TARGETADDR2LINE', 'addr2line'),
            'strip':
            os.getenv('TARGETSTRIP', 'strip'),
            'runner':
            ' '.join(get_bare_metal_runner('x86_32')),
            'runner_without_test_library':
            ' '.join(get_bare_metal_runner('x86_32', use_test_library=False)),
            'valgrind_runner':
            _get_valgrind_runner('bare_metal_i686', nacl_arch='x86_32'),
            'valgrind_runner_without_test_library':
            _get_valgrind_runner('bare_metal_i686',
                                 use_test_library=False,
                                 nacl_arch='x86_32'),
            'gdb':
            'gdb',
            'deps': [],
            'llvm_tblgen':
            build_common.get_build_path_for_executable('llvm-tblgen',
                                                       is_host=True),
        },
        'bare_metal_arm': {
            'cxx':
            os.getenv('TARGETCXX', ' arm-linux-gnueabihf-g++'),
            'cc':
            os.getenv('TARGETCC', ' arm-linux-gnueabihf-gcc'),
            'asm':
            os.getenv('TARGETCC', ' arm-linux-gnueabihf-gcc'),
            'clangxx':
            os.path.join(_CLANG_BIN_DIR, 'clang++'),
            'clang':
            os.path.join(_CLANG_BIN_DIR, 'clang'),
            'clang.ld':
            os.path.join(_CLANG_BIN_DIR, 'clang'),
            'ld':
            os.getenv('TARGETLD', 'arm-linux-gnueabihf-g++'),
            'ar':
            os.getenv('TARGETAR', 'arm-linux-gnueabihf-ar'),
            'nm':
            os.getenv('TARGETNM', 'arm-linux-gnueabihf-nm'),
            'objcopy':
            os.getenv('TARGETOBJCOPY', 'arm-linux-gnueabihf-objcopy'),
            'objdump':
            os.getenv('TARGETOBJDUMP', 'arm-linux-gnueabihf-objdump'),
            'addr2line':
            os.getenv('TARGETADDR2LINE', 'arm-linux-gnueabihf-addr2line'),
            'strip':
            os.getenv('TARGETSTRIP', 'arm-linux-gnueabihf-strip'),
            'runner':
            ' '.join(get_bare_metal_runner('arm', use_qemu_arm=True)),
            'runner_without_test_library':
            ' '.join(
                get_bare_metal_runner('arm',
                                      use_qemu_arm=True,
                                      use_test_library=False)),
            # We do not support valgrind on Bare Metal ARM.
            'valgrind_runner':
            ' '.join(get_bare_metal_runner('arm', use_qemu_arm=True)),
            'valgrind_runner_without_test_library':
            ' '.join(
                get_bare_metal_runner(use_qemu_arm=True,
                                      use_test_library=False)),
            'gdb':
            build_common.get_gdb_multiarch_path(),
            'deps': [],
            'llvm_tblgen':
            build_common.get_build_path_for_executable('llvm-tblgen',
                                                       is_host=True),
        },
        'java': {
            'aapt':
            os.getenv('AAPT', os.path.join(android_sdk_build_tools_dir,
                                           'aapt')),
            'aidl':
            os.path.join(android_sdk_build_tools_dir, 'aidl'),
            'dx':
            os.getenv('DX', os.path.join(android_sdk_build_tools_dir, 'dx')),
            'deps': [],
            'dex2oat':
            build_common.get_build_path_for_executable(
                'dex2oatd' if OPTIONS.is_debug_code_enabled() else 'dex2oat',
                is_host=True),
            'dexdump':
            os.path.join(android_sdk_build_tools_dir, 'dexdump'),
            'java-event-log-tags':
            os.path.join(android_build_tools_dir, 'java-event-log-tags.py'),
            'jar':
            _get_java_command('jar'),
            'jarjar':
            os.getenv('JARJAR',
                      os.path.join(_DEXMAKER_PATH, 'lib', 'jarjar.jar')),
            'java':
            _get_java_command('java'),
            'javac':
            _get_java_command('javac'),
            'runner':
            _get_native_runner('java'),
            'zipalign':
            os.path.join(android_sdk_build_tools_dir, 'zipalign'),
        },
    }
Beispiel #12
0
def _get_tool_map():
  android_build_tools_dir = _get_android_build_tools_dir()
  android_sdk_build_tools_dir = get_android_sdk_build_tools_dir()

  return {
      'host': {
          'cxx': os.getenv('HOSTCXX', 'g++'),
          'cc': os.getenv('HOSTCC', 'gcc'),
          'asm': os.getenv('HOSTCC', 'gcc'),
          'ld': os.getenv('HOSTLD', 'g++'),
          'ar': os.getenv('HOSTAR', 'ar'),
          'nm': os.getenv('HOSTNM', 'nm'),
          'objcopy': os.getenv('HOSTOBJCOPY', 'objcopy'),
          'objdump': os.getenv('HOSTOBJDUMP', 'objdump'),
          'addr2line': os.getenv('HOSTADDR2LINE', 'addr2line'),
          'strip': os.getenv('HOSTSTRIP', 'strip'),
          'runner': _get_native_runner('host'),
          'valgrind_runner': _get_valgrind_runner('host'),
          'gdb': 'gdb',
          'create_nmf': _get_create_nmf(),
          'deps': [],
          'adb': _get_adb_path_for_localhost(),
          'clangxx': os.path.join(_CLANG_BIN_DIR, 'clang++'),
          'clang': os.path.join(_CLANG_BIN_DIR, 'clang'),
      },
      'nacl_i686': {
          'cxx': (os.path.join(get_nacl_toolchain_path(), 'x86_64-nacl-g++') +
                  ' -m32'),
          'cc': (os.path.join(get_nacl_toolchain_path(), 'x86_64-nacl-gcc') +
                 ' -m32'),
          'asm': os.path.join(_PNACL_BIN_PATH, 'i686-nacl-clang'),
          'ld': os.path.join(get_nacl_toolchain_path(), 'i686-nacl-g++'),
          'ar': os.path.join(_PNACL_BIN_PATH, 'i686-nacl-ar'),
          'nm': os.path.join(_PNACL_BIN_PATH, 'i686-nacl-nm'),
          'objcopy': os.path.join(_PNACL_BIN_PATH, 'i686-nacl-objcopy'),
          'objdump': os.path.join(_PNACL_BIN_PATH, 'i686-nacl-objdump'),
          'addr2line': os.path.join(_PNACL_BIN_PATH, 'i686-nacl-addr2line'),
          'strip': os.path.join(_PNACL_BIN_PATH, 'i686-nacl-strip'),
          'runner': ' '.join(get_nacl_runner(32)),
          'runner_without_test_library': ' '.join(
              get_nacl_runner(32, use_test_library=False)),
          # The target does not support Valgrind. Use nacl_runner.
          'valgrind_runner': ' '.join(get_nacl_runner(32)),
          'valgrind_runner_without_test_library': ' '.join(
              get_nacl_runner(32, use_test_library=False)),
          'ncval': os.path.join(_NACL_TOOLS_PATH, 'ncval'),
          'gdb': os.path.join(get_nacl_toolchain_path(), 'i686-nacl-gdb'),
          'irt': 'nacl_irt_x86_32.nexe',
          'deps': [_NACL_DEPS_PATH],
          'llvm_tblgen': build_common.get_build_path_for_executable(
              'llvm-tblgen', is_host=True),
          'clangxx': os.path.join(_PNACL_BIN_PATH, 'i686-nacl-clang++'),
          'clang': os.path.join(_PNACL_BIN_PATH, 'i686-nacl-clang'),
      },
      'nacl_x86_64': {
          'cxx': os.path.join(get_nacl_toolchain_path(), 'x86_64-nacl-g++'),
          'cc': os.path.join(get_nacl_toolchain_path(), 'x86_64-nacl-gcc'),
          'ld': os.path.join(get_nacl_toolchain_path(), 'x86_64-nacl-g++'),
          'asm': os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-clang'),
          'ar': os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-ar'),
          'nm': os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-nm'),
          'objcopy': os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-objcopy'),
          'objdump': os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-objdump'),
          'addr2line': os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-addr2line'),
          'strip': os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-strip'),
          'runner': ' '.join(get_nacl_runner(64)),
          'runner_without_test_library': ' '.join(
              get_nacl_runner(64, use_test_library=False)),
          # The target does not support Valgrind. Use nacl_runner.
          'valgrind_runner': ' '.join(get_nacl_runner(64)),
          'valgrind_runner_without_test_library': ' '.join(
              get_nacl_runner(64, use_test_library=False)),
          'ncval': os.path.join(_NACL_TOOLS_PATH, 'ncval'),
          'gdb': os.path.join(get_nacl_toolchain_path(), 'x86_64-nacl-gdb'),
          'irt': 'nacl_irt_x86_64.nexe',
          'deps': [_NACL_DEPS_PATH],
          'llvm_tblgen': build_common.get_build_path_for_executable(
              'llvm-tblgen', is_host=True),
          'clangxx': os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-clang++'),
          'clang': os.path.join(_PNACL_BIN_PATH, 'x86_64-nacl-clang'),
      },
      'bare_metal_i686': {
          'cxx': os.getenv('TARGETCXX', 'g++-4.8'),
          'cc': os.getenv('TARGETCC', 'gcc-4.8'),
          'asm': os.getenv('TARGETCC', 'gcc-4.8'),
          'clangxx': os.path.join(_CLANG_BIN_DIR, 'clang++'),
          'clang': os.path.join(_CLANG_BIN_DIR, 'clang'),
          'ld': os.getenv('TARGETLD', 'g++-4.8'),
          'ar': os.getenv('TARGETAR', 'ar'),
          'nm': os.getenv('TARGETNM', 'nm'),
          'objcopy': os.getenv('TARGETOBJCOPY', 'objcopy'),
          'objdump': os.getenv('TARGETOBJDUMP', 'objdump'),
          'addr2line': os.getenv('TARGETADDR2LINE', 'addr2line'),
          'strip': os.getenv('TARGETSTRIP', 'strip'),
          'runner': ' '.join(get_bare_metal_runner('x86_32')),
          'runner_without_test_library': ' '.join(
              get_bare_metal_runner('x86_32', use_test_library=False)),
          'valgrind_runner': _get_valgrind_runner('bare_metal_i686',
                                                  nacl_arch='x86_32'),
          'valgrind_runner_without_test_library': _get_valgrind_runner(
              'bare_metal_i686', use_test_library=False, nacl_arch='x86_32'),
          'gdb': 'gdb',
          'deps': [],
          'llvm_tblgen': build_common.get_build_path_for_executable(
              'llvm-tblgen', is_host=True),
      },
      'bare_metal_arm': {
          'cxx': os.getenv('TARGETCXX', ' arm-linux-gnueabihf-g++'),
          'cc': os.getenv('TARGETCC', ' arm-linux-gnueabihf-gcc'),
          'asm': os.getenv('TARGETCC', ' arm-linux-gnueabihf-gcc'),
          'clangxx': os.path.join(_CLANG_BIN_DIR, 'clang++'),
          'clang': os.path.join(_CLANG_BIN_DIR, 'clang'),
          'clang.ld': os.path.join(_CLANG_BIN_DIR, 'clang'),
          'ld': os.getenv('TARGETLD', 'arm-linux-gnueabihf-g++'),
          'ar': os.getenv('TARGETAR', 'arm-linux-gnueabihf-ar'),
          'nm': os.getenv('TARGETNM', 'arm-linux-gnueabihf-nm'),
          'objcopy': os.getenv('TARGETOBJCOPY', 'arm-linux-gnueabihf-objcopy'),
          'objdump': os.getenv('TARGETOBJDUMP', 'arm-linux-gnueabihf-objdump'),
          'addr2line': os.getenv('TARGETADDR2LINE',
                                 'arm-linux-gnueabihf-addr2line'),
          'strip': os.getenv('TARGETSTRIP', 'arm-linux-gnueabihf-strip'),
          'runner': ' '.join(get_bare_metal_runner('arm', use_qemu_arm=True)),
          'runner_without_test_library': ' '.join(
              get_bare_metal_runner('arm', use_qemu_arm=True,
                                    use_test_library=False)),
          # We do not support valgrind on Bare Metal ARM.
          'valgrind_runner': ' '.join(get_bare_metal_runner(
              'arm', use_qemu_arm=True)),
          'valgrind_runner_without_test_library': ' '.join(
              get_bare_metal_runner(use_qemu_arm=True, use_test_library=False)),
          'gdb': build_common.get_gdb_multiarch_path(),
          'deps': [],
          'llvm_tblgen': build_common.get_build_path_for_executable(
              'llvm-tblgen', is_host=True),
      },
      'java': {
          'aapt': os.getenv(
              'AAPT', os.path.join(android_sdk_build_tools_dir, 'aapt')),
          'aidl': os.path.join(android_sdk_build_tools_dir, 'aidl'),
          'dx': os.getenv(
              'DX', os.path.join(android_sdk_build_tools_dir, 'dx')),
          'deps': [],
          'dex2oat': build_common.get_build_path_for_executable(
              'dex2oatd' if OPTIONS.is_debug_code_enabled() else 'dex2oat',
              is_host=True),
          'dexdump': os.path.join(android_sdk_build_tools_dir, 'dexdump'),
          'java-event-log-tags': os.path.join(android_build_tools_dir,
                                              'java-event-log-tags.py'),
          'jar': _get_java_command('jar'),
          'jarjar': os.getenv('JARJAR', os.path.join(
              _DEXMAKER_PATH, 'lib', 'jarjar.jar')),
          'java': _get_java_command('java'),
          'javac': _get_java_command('javac'),
          'runner': _get_native_runner('java'),
          'zipalign': os.path.join(android_sdk_build_tools_dir, 'zipalign'),
      },
  }
Beispiel #13
0
# version_defaults.mk sets this if there is no BUILD_ID set.
_BUILD_NUMBER = build_common.get_build_version()

os.environ['BUILD_DISPLAY_ID'] = _BUILD_NUMBER

# Non-tagged builds generate fingerprints that are longer than the maximum
# number of characters allowed for system property values. Split the build ID
# in version and specific build to be within the limit.
if '-' in _BUILD_NUMBER:
    tokens = _BUILD_NUMBER.split('-')
    os.environ['BUILD_ID'] = tokens[0]
    os.environ['BUILD_NUMBER'] = '-'.join(tokens[1:])
else:
    os.environ['BUILD_ID'] = _BUILD_NUMBER
    os.environ['BUILD_NUMBER'] = _BUILD_NUMBER
if OPTIONS.is_debug_code_enabled():
    os.environ['BUILD_VERSION_TAGS'] = 'test-keys'
else:
    os.environ['BUILD_VERSION_TAGS'] = 'release-keys'

# "REL" means a release build (everything else is a dev build).
os.environ['PLATFORM_VERSION_CODENAME'] = 'REL'
os.environ['PLATFORM_VERSION_ALL_CODENAMES'] = 'REL'
os.environ['PLATFORM_VERSION'] = '5.0'
# SDK has to be pinned to correct level to avoid loading
# unsupported featured from app's APK file.
os.environ['PLATFORM_SDK_VERSION'] = str(toolchain.get_android_api_level())

# By convention, ro.product.brand, ro.product.manufacturer and ro.product.name
# are always in lowercase.
os.environ['PRODUCT_BRAND'] = 'chromium'
Beispiel #14
0
class GmsCoreNinjaGenerator(ninja_generator.ApkNinjaGenerator):
    if OPTIONS.internal_apks_source_is_internal():
        _DIST_DIR = 'out/gms-core-build/dist'
        _ORIGINAL_APK_PATH = 'out/gms-core-build/play_services.apk'
        _NOTICES_OUTPUT_PATH = 'out/gms-core-build/NOTICES.tar.gz'
    else:
        # Use archived build
        _DIST_DIR = 'out/internal-apks'
        _ORIGINAL_APK_PATH = 'out/internal-apks/play_services.apk'
        _NOTICES_OUTPUT_PATH = 'out/internal-apks/play_services_NOTICES.tar.gz'

    if OPTIONS.enable_art_aot():
        _APK_PATH = build_common.get_build_path_for_apk('play_services',
                                                        'optimized.apk',
                                                        is_target=True)
    else:
        _APK_PATH = _ORIGINAL_APK_PATH

    APITEST_APK_PATH = os.path.join(_DIST_DIR, 'GmsCoreApiTests.apk')
    APITEST_SETUP_APK_PATH = os.path.join(_DIST_DIR,
                                          'GmsCoreApiTestsSetup.apk')
    _PROGUARD_MAPPING = os.path.join(_DIST_DIR, 'GmsCore-proguard-mapping.txt')

    # Every build artifact of GMS Core for ninja to generate dependencies.
    _ALL_OUTPUTS = [
        _ORIGINAL_APK_PATH, _NOTICES_OUTPUT_PATH, APITEST_APK_PATH,
        APITEST_SETUP_APK_PATH
    ]
    if not OPTIONS.is_debug_code_enabled():
        _ALL_OUTPUTS.append(_PROGUARD_MAPPING)

    def __init__(self, extra_dex2oat_flags):
        super(GmsCoreNinjaGenerator, self).__init__(
            'play_services',
            install_path='/vendor/play_services',
            canned_classes_apk=GmsCoreNinjaGenerator._APK_PATH,
            extra_dex2oat_flags=extra_dex2oat_flags)

    def build_gms_core_or_use_prebuilt(self):
        if OPTIONS.enable_art_aot():
            # Rule for pre-optimizing gms-core apk.
            boot_image_dir = os.path.join(build_common.get_android_fs_root(),
                                          'system/framework',
                                          build_common.get_art_isa())
            self.rule(
                'gms_core_apk_preoptimize',
                'src/build/gms_core_apk_preoptimize.py --input $in --output $out',
                description='Preoptimizing gmscore sub apks contained in $in')
            self.build(GmsCoreNinjaGenerator._APK_PATH,
                       'gms_core_apk_preoptimize',
                       GmsCoreNinjaGenerator._ORIGINAL_APK_PATH,
                       implicit=[
                           toolchain.get_tool('java', 'dex2oat'),
                           os.path.join(boot_image_dir, 'boot.art'),
                           os.path.join(boot_image_dir, 'boot.oat')
                       ])

        if not OPTIONS.internal_apks_source_is_internal():
            return

        flags = '--eng' if OPTIONS.is_debug_code_enabled() else ''
        build_log = os.path.join('out/gms-core-build/build.log')
        command = ('internal/build/build.py gms-core %s > %s 2>&1 || '
                   '(cat %s; exit 1)') % (flags, build_log, build_log)

        if OPTIONS.internal_apks_source() == 'internal-dev':
            # Only for local development.  play-services.apk dependes on jars below to
            # build, just to use ARC specific feature like ArcMessageBridge and
            # Tracing.  This dependency is a must-have for a clean build.  But this
            # dependency can cause unrelated framework change to trigger rebuild of
            # play-services.apk, which is very slow.  With this option, eng will self
            # manages the dependency, which is almost always satisfied.
            jars = []
        else:
            # Simply make these jars the dependencies of gms-core-build, which
            # references ArcMessage and ArcMessageBridge in the jar.  Note that these
            # jars changes often and is like to cause unnecessary rebuild of gms-core,
            # which is very slow.  We may think about a way to minimize the
            # dependency.
            #
            # See also: internal/mods/gms-core/vendor/unbundled_google/packages/ \
            #     OneUp/package/Android.mk
            #     OneUp/package/generate_package.mk
            jars = [
                build_common.get_build_path_for_jar('arc-services-framework',
                                                    subpath='classes.jar'),
                build_common.get_build_path_for_jar('framework',
                                                    subpath='classes.jar'),
            ]

        self.build(GmsCoreNinjaGenerator._ALL_OUTPUTS,
                   'run_shell_command',
                   implicit=['src/build/DEPS.arc-int'] + jars,
                   variables={'command': command})

    def package_and_install(self):
        self.set_notice_archive(GmsCoreNinjaGenerator._NOTICES_OUTPUT_PATH)
        self.package()
        self.install()
Beispiel #15
0
# version_defaults.mk sets this if there is no BUILD_ID set.
_BUILD_NUMBER = build_common.get_build_version()

os.environ['BUILD_DISPLAY_ID'] = _BUILD_NUMBER

# Non-tagged builds generate fingerprints that are longer than the maximum
# number of characters allowed for system property values. Split the build ID
# in version and specific build to be within the limit.
if '-' in _BUILD_NUMBER:
  tokens = _BUILD_NUMBER.split('-')
  os.environ['BUILD_ID'] = tokens[0]
  os.environ['BUILD_NUMBER'] = '-'.join(tokens[1:])
else:
  os.environ['BUILD_ID'] = _BUILD_NUMBER
  os.environ['BUILD_NUMBER'] = _BUILD_NUMBER
if OPTIONS.is_debug_code_enabled():
  os.environ['BUILD_VERSION_TAGS'] = 'test-keys'
else:
  os.environ['BUILD_VERSION_TAGS'] = 'release-keys'

# "REL" means a release build (everything else is a dev build).
os.environ['PLATFORM_VERSION_CODENAME'] = 'REL'
os.environ['PLATFORM_VERSION_ALL_CODENAMES'] = 'REL'
os.environ['PLATFORM_VERSION'] = '5.0'
# SDK has to be pinned to correct level to avoid loading
# unsupported featured from app's APK file.
os.environ['PLATFORM_SDK_VERSION'] = str(toolchain.get_android_api_level())

# By convention, ro.product.brand, ro.product.manufacturer and ro.product.name
# are always in lowercase.
os.environ['PRODUCT_BRAND'] = 'chromium'