Esempio n. 1
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)
Esempio n. 2
0
def _generate_jemalloc_unit_tests():
  paths = build_common.find_all_files(
      'android/external/jemalloc/test/unit', ['.c'], include_tests=True)

  # These tests need -DJEMALLOC_PROF which we do not enable.
  paths.remove('android/external/jemalloc/test/unit/prof_accum.c')
  paths.remove('android/external/jemalloc/test/unit/prof_accum_a.c')
  paths.remove('android/external/jemalloc/test/unit/prof_accum_b.c')
  paths.remove('android/external/jemalloc/test/unit/prof_gdump.c')
  paths.remove('android/external/jemalloc/test/unit/prof_idump.c')

  # Disable some multi-threaded tests flaky under ARM qemu.
  if OPTIONS.is_arm():
    paths.remove('android/external/jemalloc/test/unit/mq.c')
    paths.remove('android/external/jemalloc/test/unit/mtx.c')

  for path in paths:
    name = os.path.splitext(os.path.basename(path))[0]
    n = ninja_generator.TestNinjaGenerator('jemalloc_unit_test_' + name)
    n.add_include_paths(
        'android/external/jemalloc/include',
        'android/external/jemalloc/test/include')
    n.add_c_flags('-Werror')
    n.add_c_flags('-DJEMALLOC_UNIT_TEST')
    if OPTIONS.enable_jemalloc_debug():
      n.add_c_flags('-DJEMALLOC_DEBUG')
    # Needs C99 for "restrict" keyword.
    n.add_c_flags('-std=gnu99')
    n.add_library_deps('libjemalloc_jet.a')
    n.add_library_deps('libjemalloc_unittest.a')
    n.build_default([path])
    n.run(n.link(), enable_valgrind=OPTIONS.enable_valgrind(), rule='run_test')
Esempio n. 3
0
def _generate_check_symbols_ninja():
    # If we do not use NDK direct execution, the compatibility is less
    # important.
    if not build_common.use_ndk_direct_execution():
        return

    n = ninja_generator.NinjaGenerator('check_symbols')
    script = staging.as_staging('src/build/check_symbols.py')
    rule_name = 'check_symbols'
    n.rule(rule_name,
           command=('src/build/run_python %s $android_lib $in %s' %
                    (script, build_common.get_test_output_handler())),
           description=(rule_name + ' $in'))

    if OPTIONS.is_arm():
        arch_subdir = 'arch-arm'
    else:
        arch_subdir = 'arch-x86'
    lib_dir = os.path.join(_ANDROID_SYSTEM_IMAGE_DIR, arch_subdir, 'usr/lib')
    for so_file in build_common.find_all_files(lib_dir, suffixes='.so'):
        lib_name = os.path.basename(so_file)
        if lib_name not in ['libc.so', 'libdl.so', 'libm.so']:
            # For now, we only check Bionic.
            # TODO(crbug.com/408548): Extend this for other libraries.
            continue
        result_path = os.path.join(build_common.get_build_dir(),
                                   'check_symbols',
                                   'check_symbols.%s.result' % lib_name)
        n.build(result_path,
                rule_name,
                build_common.get_build_path_for_library(lib_name),
                variables={'android_lib': staging.as_staging(so_file)},
                implicit=[script, staging.as_staging(so_file)])
Esempio n. 4
0
def _generate_jemalloc_integration_tests():
  paths = build_common.find_all_files(
      'android/external/jemalloc/test/integration', ['.c'], include_tests=True)

  # Disable some multi-threaded tests flaky under ARM qemu.
  if OPTIONS.is_arm():
    paths.remove('android/external/jemalloc/test/integration/MALLOCX_ARENA.c')
    paths.remove('android/external/jemalloc/test/integration/thread_arena.c')

  for path in paths:
    name = os.path.splitext(os.path.basename(path))[0]
    n = ninja_generator.TestNinjaGenerator('jemalloc_integartion_test_' + name)
    n.add_include_paths(
        'android/external/jemalloc/include',
        'android/external/jemalloc/test/include')
    n.add_c_flags('-Werror')
    n.add_c_flags('-DJEMALLOC_INTEGRATION_TEST')
    if OPTIONS.enable_jemalloc_debug():
      n.add_c_flags('-DJEMALLOC_DEBUG')
    # Needs C99 for "restrict" keyword.
    n.add_c_flags('-std=gnu99')
    n.add_library_deps('libjemalloc.a')
    n.add_library_deps('libjemalloc_integrationtest.a')
    n.build_default([path])
    n.run(n.link(), enable_valgrind=OPTIONS.enable_valgrind(), rule='run_test')
Esempio n. 5
0
def main():
    # Disable line buffering
    sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)

    if not _configure_build_options():
        return -1

    _update_arc_version_file()

    _ensure_downloads_up_to_date()

    if not open_source.is_open_source_repo():
        import sync_chrome
        sync_chrome.run()

    adb_target = 'linux-arm' if OPTIONS.is_arm() else 'linux-x86_64'
    sync_adb.run(adb_target)

    _set_up_internal_repo()

    _gclient_sync_third_party()
    _check_javac_version()
    _cleanup_orphaned_pyc_files()

    _set_up_git_hooks()

    _set_up_chromium_org_submodules()

    # Make sure the staging directory is up to date whenever configure
    # runs to make it easy to generate rules by scanning directories.
    staging.create_staging()

    config_runner.generate_ninjas()

    return 0
Esempio n. 6
0
def _generate_jemalloc_integration_tests():
    paths = build_common.find_all_files(
        'android/external/jemalloc/test/integration', ['.c'],
        include_tests=True)

    # Disable some multi-threaded tests flaky under ARM qemu.
    if OPTIONS.is_arm():
        paths.remove(
            'android/external/jemalloc/test/integration/MALLOCX_ARENA.c')
        paths.remove(
            'android/external/jemalloc/test/integration/thread_arena.c')

    for path in paths:
        name = os.path.splitext(os.path.basename(path))[0]
        n = ninja_generator.TestNinjaGenerator('jemalloc_integartion_test_' +
                                               name)
        n.add_include_paths('android/external/jemalloc/include',
                            'android/external/jemalloc/test/include')
        n.add_c_flags('-Werror')
        n.add_c_flags('-DJEMALLOC_INTEGRATION_TEST')
        if OPTIONS.enable_jemalloc_debug():
            n.add_c_flags('-DJEMALLOC_DEBUG')
        # Needs C99 for "restrict" keyword.
        n.add_c_flags('-std=gnu99')
        n.add_library_deps('libjemalloc.a')
        n.add_library_deps('libjemalloc_integrationtest.a')
        n.build_default([path])
        n.run(n.link(),
              enable_valgrind=OPTIONS.enable_valgrind(),
              rule='run_test')
Esempio n. 7
0
  def _filter(vars):
    if open_source.is_open_source_repo() and vars.is_host():
      return False
    # Shared object version just links the static library version. To avoid a
    # module name conflict, we just build static library version as a converted
    # shared object.
    if vars.is_shared():
      return False
    make_to_ninja.Filters.convert_to_shared_lib(vars)

    # Build libc++.so as a system library so that it does not link to
    # libstlport.so, and does not emit syscall wrappers.
    vars.get_generator_args()['is_system_library'] = True
    if vars.is_target():
      # A side-effect of |is_system_library| is that it also removes the
      # dependencies on libc, libm, and libdl. We still need them, so add them
      # back.
      vars.get_shared_deps().extend(['libc', 'libm', 'libdl'])

    # Install an additional ARM version of libc++.so for Renderscript.
    if (vars.is_target() and vars.get_module_name() == 'libc++' and
        not OPTIONS.is_arm()):
      vars.set_canned_arm(True)

    vars.get_whole_archive_deps().remove('libcompiler_rt')
    vars.get_shared_deps().append('libcompiler_rt')

    return True
Esempio n. 8
0
def _get_generate_libvpx_asm_ninja():
    if not OPTIONS.is_arm():
        return None

    gen_asm_ninja = ninja_generator.NinjaGenerator('libvpx_asm')
    # Translate RVCT format assembly code into GNU Assembler format.
    gen_asm_ninja.rule(_GEN_LIBVPX_ASM_RULE,
                       command=_ADS2GAS +
                       ' < $in > $out.tmp && (mv $out.tmp $out)')

    # Translate C source code into assembly code and run grep to
    # generate a list of constants. Assembly code generated by this rule
    # will be included from other assembly code. See
    # third_party/android/external/libvpx/libvpx.mk for corresponding
    # rules written in Makefile.
    asm_include_paths = [
        '-I' + staging.as_staging('android/external/libvpx/armv7a-neon'),
        '-I' + staging.as_staging('android/external/libvpx/libvpx')
    ]
    gen_asm_ninja.rule(_GEN_LIBVPX_OFFSETS_ASM_RULE,
                       command=('%s -DINLINE_ASM %s -S $in -o $out.s && '
                                'grep \'^[a-zA-Z0-9_]* EQU\' $out.s | '
                                'tr -d \'$$\\#\' | '
                                '%s > $out.tmp && (mv $out.tmp $out)' %
                                (toolchain.get_tool(OPTIONS.target(), 'cc'),
                                 ' '.join(asm_include_paths), _ADS2GAS)))

    return gen_asm_ninja
Esempio n. 9
0
def _generate_check_symbols_ninja():
  # If we do not use NDK direct execution, the compatibility is less
  # important.
  if not build_common.use_ndk_direct_execution():
    return

  n = ninja_generator.NinjaGenerator('check_symbols')
  script = staging.as_staging('src/build/check_symbols.py')
  rule_name = 'check_symbols'
  n.rule(rule_name,
         command=('src/build/run_python %s $android_lib $in %s' % (
             script, build_common.get_test_output_handler())),
         description=(rule_name + ' $in'))

  if OPTIONS.is_arm():
    arch_subdir = 'arch-arm'
  else:
    arch_subdir = 'arch-x86'
  lib_dir = os.path.join(_ANDROID_SYSTEM_IMAGE_DIR, arch_subdir, 'usr/lib')
  for so_file in build_common.find_all_files(lib_dir, suffixes='.so'):
    lib_name = os.path.basename(so_file)
    if lib_name not in ['libc.so', 'libdl.so', 'libm.so']:
      # For now, we only check Bionic.
      # TODO(crbug.com/408548): Extend this for other libraries.
      continue
    result_path = os.path.join(build_common.get_build_dir(),
                               'check_symbols',
                               'check_symbols.%s.result' % lib_name)
    n.build(result_path, rule_name,
            build_common.get_build_path_for_library(lib_name),
            variables={'android_lib': staging.as_staging(so_file)},
            implicit=[script, staging.as_staging(so_file)])
Esempio n. 10
0
def main(args):
    OPTIONS.parse_configure_file()

    # TODO(crbug.com/378196): Make qemu-arm available in open source in order to
    # run any unit tests there.
    if open_source.is_open_source_repo() and OPTIONS.is_arm():
        return 0

    for test_name in args[1:]:
        pipe = subprocess.Popen(
            ['python', 'src/build/run_unittest.py', test_name],
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT)
        out = pipe.communicate()[0]
        sys.stdout.write(out)
        if pipe.returncode:
            sys.stdout.write('FAIL (exit=%d)\n' % pipe.returncode)
            sys.stdout.write(out + '\n')
            return 1
        elif out.find('PASS\n') < 0:
            sys.stdout.write('FAIL (no PASS)\n')
            sys.stdout.write(out + '\n')
            return 1
        else:
            sys.stdout.write('OK\n')

    return 0
Esempio n. 11
0
def _filter_params_for_v8(vars):
  # Switch V8 to always emit ARM code and use simulator to run that on
  # x86 NaCl.
  # Also disable snapshots as they are not working in ARC yet.
  if OPTIONS.is_nacl_build():
    if '-DV8_TARGET_ARCH_IA32' in vars.get_cflags():
      vars.get_cflags().remove('-DV8_TARGET_ARCH_IA32')
    if '-DV8_TARGET_ARCH_X64' in vars.get_cflags():
      vars.get_cflags().remove('-DV8_TARGET_ARCH_X64')
    vars.get_cflags().append('-DV8_TARGET_ARCH_ARM')
    vars.get_cflags().append('-D__ARM_ARCH_7__')
  sources = vars.get_sources()
  new_sources = []
  v8_src = 'android/external/chromium_org/v8/src/'
  for path in sources:
    if OPTIONS.is_nacl_build():
      if path.startswith(v8_src + 'x64/'):
        path = v8_src + 'arm/' + os.path.basename(path).replace('x64', 'arm')
      if path.startswith(v8_src + 'ia32/'):
        path = v8_src + 'arm/' + os.path.basename(path).replace('ia32', 'arm')
    if path.endswith('/snapshot.cc'):
      path = 'android/external/chromium_org/v8/src/snapshot-empty.cc'
    new_sources.append(path)
  if not OPTIONS.is_arm() and OPTIONS.is_nacl_build():
    new_sources.append(v8_src + 'arm/constants-arm.cc')
    new_sources.append(v8_src + 'arm/simulator-arm.cc')
  vars.get_sources()[:] = new_sources
Esempio n. 12
0
 def _filter(vars):
     # Android uses two different C++ libraries: bionic's libstdc++ (instead of
     # GCC's libstdc++) and clang's libc++ (only for ART and a few other
     # libraries). STLport does not have compiler dependent functions (functions
     # which are called from code generated by compiler), so use bionic's and
     # link it into libstlport.so for simplicity.
     vars.get_sources().extend([
         'android/bionic/libc/bionic/new.cpp',
         'android/bionic/libc/bionic/__cxa_guard.cpp',
         'android/bionic/libc/bionic/__cxa_pure_virtual.cpp',
         # Needed for __libc_fatal.
         'android/bionic/libc/bionic/libc_logging.cpp'
     ])
     vars.get_includes().append('android/bionic/libc')
     vars.get_includes().remove('android/bionic/libstdc++/include')
     vars.get_sys_includes().remove('android/bionic/libstdc++/include')
     # This is necessary to use atomic operations in bionic. 1 indicates
     # compilation for symmetric multi-processor (0 for uniprocessor).
     vars.get_cflags().append('-DANDROID_SMP=1')
     if vars.is_shared():
         # This is for not emitting syscall wrappers.
         vars.get_shared_deps().extend(['libc', 'libm'])
         # Note: libstlport.so must be a system library because other system
         # libraries such as libchromium_ppapi.so and libposix_translation.so
         # depend on it. We already have some ARC MODs against STLPort to make
         # it work without --wrap, and the cost of maintaining the MODs seems
         # very low because STLPort is not under active development anymore.
         vars.get_generator_args()['is_system_library'] = True
         # TODO(crbug.com/364344): Once Renderscript is built from source, this
         # canned install can be removed.
         if not OPTIONS.is_arm():
             vars.set_canned_arm(True)
     return True
Esempio n. 13
0
 def _filter(vars):
   # Android uses two different C++ libraries: bionic's libstdc++ (instead of
   # GCC's libstdc++) and clang's libc++ (only for ART and a few other
   # libraries). STLport does not have compiler dependent functions (functions
   # which are called from code generated by compiler), so use bionic's and
   # link it into libstlport.so for simplicity.
   vars.get_sources().extend([
       'android/bionic/libc/bionic/new.cpp',
       'android/bionic/libc/bionic/__cxa_guard.cpp',
       'android/bionic/libc/bionic/__cxa_pure_virtual.cpp',
       # Needed for __libc_fatal.
       'android/bionic/libc/bionic/libc_logging.cpp'])
   vars.get_includes().append('android/bionic/libc')
   vars.get_includes().remove('android/bionic/libstdc++/include')
   vars.get_sys_includes().remove('android/bionic/libstdc++/include')
   # This is necessary to use atomic operations in bionic. 1 indicates
   # compilation for symmetric multi-processor (0 for uniprocessor).
   vars.get_cflags().append('-DANDROID_SMP=1')
   if vars.is_shared():
     # This is for not emitting syscall wrappers.
     vars.get_shared_deps().extend(['libc', 'libm'])
     # Note: libstlport.so must be a system library because other system
     # libraries such as libchromium_ppapi.so and libposix_translation.so
     # depend on it. We already have some ARC MODs against STLPort to make
     # it work without --wrap, and the cost of maintaining the MODs seems
     # very low because STLPort is not under active development anymore.
     vars.get_generator_args()['is_system_library'] = True
     # TODO(crbug.com/364344): Once Renderscript is built from source, this
     # canned install can be removed.
     if not OPTIONS.is_arm():
       vars.set_canned_arm(True)
   return True
Esempio n. 14
0
def _get_generate_libvpx_asm_ninja():
    if not OPTIONS.is_arm():
        return None

    gen_asm_ninja = ninja_generator.NinjaGenerator('libvpx_asm')
    # Translate RVCT format assembly code into GNU Assembler format.
    gen_asm_ninja.rule(
        _GEN_LIBVPX_ASM_RULE,
        command=_ADS2GAS + ' < $in > $out.tmp && (mv $out.tmp $out)')

    # Translate C source code into assembly code and run grep to
    # generate a list of constants. Assembly code generated by this rule
    # will be included from other assembly code. See
    # third_party/android/external/libvpx/libvpx.mk for corresponding
    # rules written in Makefile.
    asm_include_paths = [
        '-I' + staging.as_staging('android/external/libvpx/armv7a-neon'),
        '-I' + staging.as_staging('android/external/libvpx/libvpx')
    ]
    gen_asm_ninja.rule(
        _GEN_LIBVPX_OFFSETS_ASM_RULE,
        command=('%s -DINLINE_ASM %s -S $in -o $out.s && '
                 'grep \'^[a-zA-Z0-9_]* EQU\' $out.s | '
                 'tr -d \'$$\\#\' | '
                 '%s > $out.tmp && (mv $out.tmp $out)' % (toolchain.get_tool(
                     OPTIONS.target(), 'cc'), ' '.join(asm_include_paths),
                                                          _ADS2GAS)))

    return gen_asm_ninja
Esempio n. 15
0
    def _filter(vars):
        if open_source.is_open_source_repo() and vars.is_host():
            return False
        # Shared object version just links the static library version. To avoid a
        # module name conflict, we just build static library version as a converted
        # shared object.
        if vars.is_shared():
            return False
        make_to_ninja.Filters.convert_to_shared_lib(vars)

        # Build libc++.so as a system library so that it does not link to
        # libstlport.so, and does not emit syscall wrappers.
        vars.get_generator_args()['is_system_library'] = True
        if vars.is_target():
            # A side-effect of |is_system_library| is that it also removes the
            # dependencies on libc, libm, and libdl. We still need them, so add them
            # back.
            vars.get_shared_deps().extend(['libc', 'libm', 'libdl'])

        # Install an additional ARM version of libc++.so for Renderscript.
        if (vars.is_target() and vars.get_module_name() == 'libc++'
                and not OPTIONS.is_arm()):
            vars.set_canned_arm(True)

        vars.get_whole_archive_deps().remove('libcompiler_rt')
        vars.get_shared_deps().append('libcompiler_rt')

        return True
Esempio n. 16
0
def _generate_jemalloc_unit_tests():
    paths = build_common.find_all_files('android/external/jemalloc/test/unit',
                                        ['.c'],
                                        include_tests=True)

    # These tests need -DJEMALLOC_PROF which we do not enable.
    paths.remove('android/external/jemalloc/test/unit/prof_accum.c')
    paths.remove('android/external/jemalloc/test/unit/prof_accum_a.c')
    paths.remove('android/external/jemalloc/test/unit/prof_accum_b.c')
    paths.remove('android/external/jemalloc/test/unit/prof_gdump.c')
    paths.remove('android/external/jemalloc/test/unit/prof_idump.c')

    # Disable some multi-threaded tests flaky under ARM qemu.
    if OPTIONS.is_arm():
        paths.remove('android/external/jemalloc/test/unit/mq.c')
        paths.remove('android/external/jemalloc/test/unit/mtx.c')

    for path in paths:
        name = os.path.splitext(os.path.basename(path))[0]
        n = ninja_generator.TestNinjaGenerator('jemalloc_unit_test_' + name)
        n.add_include_paths('android/external/jemalloc/include',
                            'android/external/jemalloc/test/include')
        n.add_c_flags('-Werror')
        n.add_c_flags('-DJEMALLOC_UNIT_TEST')
        if OPTIONS.enable_jemalloc_debug():
            n.add_c_flags('-DJEMALLOC_DEBUG')
        # Needs C99 for "restrict" keyword.
        n.add_c_flags('-std=gnu99')
        n.add_library_deps('libjemalloc_jet.a')
        n.add_library_deps('libjemalloc_unittest.a')
        n.build_default([path])
        n.run(n.link(),
              enable_valgrind=OPTIONS.enable_valgrind(),
              rule='run_test')
Esempio n. 17
0
def main():
  # Disable line buffering
  sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)

  if not _configure_build_options():
    return -1

  _update_arc_version_file()

  _ensure_downloads_up_to_date()

  if not open_source.is_open_source_repo():
    import sync_chrome
    sync_chrome.run()

  adb_target = 'linux-arm' if OPTIONS.is_arm() else 'linux-x86_64'
  sync_adb.run(adb_target)

  _set_up_internal_repo()

  _gclient_sync_third_party()
  _check_javac_version()
  _cleanup_orphaned_pyc_files()

  _set_up_git_hooks()

  _set_up_chromium_org_submodules()

  # Make sure the staging directory is up to date whenever configure
  # runs to make it easy to generate rules by scanning directories.
  staging.create_staging()

  config_runner.generate_ninjas()

  return 0
Esempio n. 18
0
def main(args):
  OPTIONS.parse_configure_file()

  # TODO(crbug.com/378196): Make qemu-arm available in open source in order to
  # run any unit tests there.
  if open_source.is_open_source_repo() and OPTIONS.is_arm():
    return 0

  for test_name in args[1:]:
    pipe = subprocess.Popen(['python', 'src/build/run_unittest.py',
                             test_name],
                            stdout=subprocess.PIPE,
                            stderr=subprocess.STDOUT)
    out = pipe.communicate()[0]
    sys.stdout.write(out)
    if pipe.returncode:
      sys.stdout.write('FAIL (exit=%d)\n' % pipe.returncode)
      sys.stdout.write(out + '\n')
      return 1
    elif out.find('PASS\n') < 0:
      sys.stdout.write('FAIL (no PASS)\n')
      sys.stdout.write(out + '\n')
      return 1
    else:
      sys.stdout.write('OK\n')

  return 0
Esempio n. 19
0
def _filter_libvpx(vars, gen_asm_ninja):
    # They only have some definitions of constants, and are meant to be
    # included from other assembly code, so we do not need to compile
    # them.
    offset_asms = [
        'vp8/encoder/vp8_asm_enc_offsets.asm',
        'vpx_scale/vpx_scale_asm_offsets.asm'
    ]
    for remove in offset_asms:
        match = [m for m in vars.get_sources() if remove in m]
        for m in match:
            vars.get_sources().remove(m)

    if OPTIONS.is_arm():
        # Build the 'offsets' assembly files.
        generated_offset_asms = []
        for offset_asm in offset_asms:
            generated_offset_asm_dir = os.path.join(
                vars.get_android_gen_path(), os.path.dirname(offset_asm),
                'arm/neon')
            # The generated assembly code will be included from other
            # files. Here we pass the appropriate include path.
            vars.get_cflags().append('-Wa,-I' + generated_offset_asm_dir)
            generated_offset_asm = os.path.join(generated_offset_asm_dir,
                                                os.path.basename(offset_asm))
            gen_asm_ninja.build(generated_offset_asm,
                                _GEN_LIBVPX_OFFSETS_ASM_RULE,
                                staging.as_staging(
                                    os.path.join(
                                        'android/external/libvpx/libvpx',
                                        offset_asm.replace('.asm', '.c'))),
                                implicit=[_ADS2GAS])
            generated_offset_asms.append(generated_offset_asm)

        # Translate RVCT format to GNU Assembler format.
        for f in filter(lambda f: '/arm/' in f, vars.get_sources()):
            if f.endswith('.asm.s'):
                assert f.startswith(vars.get_android_gen_path())
                source = f.replace(
                    vars.get_android_gen_path(),
                    staging.as_staging('android/external/libvpx/libvpx'))
                source = source.replace('.asm.s', '.asm')
                # We manually set generated_offset_asms as their implicit
                # dependencies because our 'asm' compiler rule does not
                # support ninja's 'deps' attribute.
                gen_asm_ninja.build(f,
                                    _GEN_LIBVPX_ASM_RULE,
                                    source,
                                    implicit=[_ADS2GAS] +
                                    generated_offset_asms)
    else:
        # TODO(crbug.com/263712): Enable assembly code in libvpx for Bare
        # Metal i686.
        assert not gen_asm_ninja

    # libvpx is used by libstagefright, libstagefright_soft_vpxdec and
    # libwebviewchromium, hence 3 instances.
    vars.set_instances_count(3)
    return True
Esempio n. 20
0
def _filter_libvpx(vars, gen_asm_ninja):
    # They only have some definitions of constants, and are meant to be
    # included from other assembly code, so we do not need to compile
    # them.
    offset_asms = [
        'vp8/encoder/vp8_asm_enc_offsets.asm',
        'vpx_scale/vpx_scale_asm_offsets.asm'
    ]
    for remove in offset_asms:
        match = [m for m in vars.get_sources() if remove in m]
        for m in match:
            vars.get_sources().remove(m)

    if OPTIONS.is_arm():
        # Build the 'offsets' assembly files.
        generated_offset_asms = []
        for offset_asm in offset_asms:
            generated_offset_asm_dir = os.path.join(
                vars.get_android_gen_path(), os.path.dirname(offset_asm),
                'arm/neon')
            # The generated assembly code will be included from other
            # files. Here we pass the appropriate include path.
            vars.get_cflags().append('-Wa,-I' + generated_offset_asm_dir)
            generated_offset_asm = os.path.join(generated_offset_asm_dir,
                                                os.path.basename(offset_asm))
            gen_asm_ninja.build(
                generated_offset_asm,
                _GEN_LIBVPX_OFFSETS_ASM_RULE,
                staging.as_staging(
                    os.path.join('android/external/libvpx/libvpx',
                                 offset_asm.replace('.asm', '.c'))),
                implicit=[_ADS2GAS])
            generated_offset_asms.append(generated_offset_asm)

        # Translate RVCT format to GNU Assembler format.
        for f in filter(lambda f: '/arm/' in f, vars.get_sources()):
            if f.endswith('.asm.s'):
                assert f.startswith(vars.get_android_gen_path())
                source = f.replace(
                    vars.get_android_gen_path(),
                    staging.as_staging('android/external/libvpx/libvpx'))
                source = source.replace('.asm.s', '.asm')
                # We manually set generated_offset_asms as their implicit
                # dependencies because our 'asm' compiler rule does not
                # support ninja's 'deps' attribute.
                gen_asm_ninja.build(
                    f,
                    _GEN_LIBVPX_ASM_RULE,
                    source,
                    implicit=[_ADS2GAS] + generated_offset_asms)
    else:
        # TODO(crbug.com/263712): Enable assembly code in libvpx for Bare
        # Metal i686.
        assert not gen_asm_ninja

    # libvpx is used by libstagefright, libstagefright_soft_vpxdec and
    # libwebviewchromium, hence 3 instances.
    vars.set_instances_count(3)
    return True
Esempio n. 21
0
def get_android_config_header(is_host):
    if is_host:
        arch_subdir = "linux-x86"
    elif OPTIONS.is_arm():
        arch_subdir = "linux-arm"
    else:
        arch_subdir = "target_linux-x86"
    return os.path.join(get_staging_root(), "android/build/core/combo/include/arch", arch_subdir, "AndroidConfig.h")
Esempio n. 22
0
def get_art_isa():
    if OPTIONS.is_i686():
        return "x86"
    elif OPTIONS.is_x86_64():
        return "x86_64"
    elif OPTIONS.is_arm():
        return "arm"
    raise Exception("Unable to map target into an ART ISA: %s" % OPTIONS.target())
Esempio n. 23
0
def get_art_isa():
    if OPTIONS.is_i686():
        return 'x86'
    elif OPTIONS.is_x86_64():
        return 'x86_64'
    elif OPTIONS.is_arm():
        return 'arm'
    raise Exception('Unable to map target into an ART ISA: %s' %
                    OPTIONS.target())
Esempio n. 24
0
def get_android_config_header(is_host):
    if is_host:
        arch_subdir = 'linux-x86'
    elif OPTIONS.is_arm():
        arch_subdir = 'linux-arm'
    else:
        arch_subdir = 'target_linux-x86'
    return os.path.join(get_staging_root(),
                        'android/build/core/combo/include/arch', arch_subdir,
                        'AndroidConfig.h')
Esempio n. 25
0
def get_bionic_arch_name():
    """Returns Bionic's architecture name as used in sub directories.

  The architecture name is used in sub directories like
  android/bionic/libc/kernel/uapi/asm-arm.
  android/bionic/libc/arch-arm.
  """
    if OPTIONS.is_arm():
        return 'arm'
    else:
        return 'x86'
Esempio n. 26
0
def get_bionic_arch_name():
    """Returns Bionic's architecture name as used in sub directories.

  The architecture name is used in sub directories like
  android/bionic/libc/kernel/uapi/asm-arm.
  android/bionic/libc/arch-arm.
  """
    if OPTIONS.is_arm():
        return "arm"
    else:
        return "x86"
Esempio n. 27
0
def _filter_sources_for_opus(vars):
  # TODO(crbug.com/414569): L-Rebase: This ARM-specific assembly file can be
  # generated using a perl script, similar to how libvpx uses ads2gas.pl. For
  # now, the generated file will be added directly to the mods/ directory, but
  # we should centralize all gnu assembler-conversion somewhere.
  if OPTIONS.is_arm():
    sources = vars.get_sources()
    pitch_correction_asm = 'celt_pitch_xcorr_arm_gnu.S'
    sources.remove(os.path.join(vars.get_android_gen_path(),
                                pitch_correction_asm))
    sources.append(os.path.join(vars.get_path(), 'third_party', 'opus', 'src',
                                'celt', 'arm', pitch_correction_asm))
  # Opus complains when not building with optimization. Always enable them.
  vars.force_optimization()
Esempio n. 28
0
def _filter_all_make_to_ninja(vars):
  # All the following filters are only for the target.
  if vars.is_host():
    return True
  if vars.is_java_library() and open_source.is_open_source_repo():
    # We do not yet build all of the Java prerequisites in the open source
    # repository.
    return False
  if vars.is_c_library() or vars.is_executable():
    _filter_excluded_libs(vars)

    if not OPTIONS.is_arm():
      _filter_for_when_not_arm(vars)

  return True
Esempio n. 29
0
def get_adb_path_for_chromeos(relative=True):
    """Returns the directory that contains the adb executable for Chrome OS."""

    if platform_util.is_running_on_chromeos():
        # The adb binary is copied to a directory whose filesystem is mounted
        # without noexec mount options on Chrome OS.
        root = build_common.get_chromeos_arc_root_without_noexec()
    else:
        root = build_common.get_arc_root()

    # Chrome OS based on linux-i686 is not supported.
    target = 'linux-arm' if OPTIONS.is_arm() else 'linux-x86_64'
    path = os.path.join('out/adb', target, 'adb')
    if relative:
        return path
    return os.path.join(root, path)
Esempio n. 30
0
def get_adb_path_for_chromeos(relative=True):
  """Returns the directory that contains the adb executable for Chrome OS."""

  if platform_util.is_running_on_chromeos():
    # The adb binary is copied to a directory whose filesystem is mounted
    # without noexec mount options on Chrome OS.
    root = build_common.get_chromeos_arc_root_without_noexec()
  else:
    root = build_common.get_arc_root()

  # Chrome OS based on linux-i686 is not supported.
  target = 'linux-arm' if OPTIONS.is_arm() else 'linux-x86_64'
  path = os.path.join('out/adb', target, 'adb')
  if relative:
    return path
  return os.path.join(root, path)
Esempio n. 31
0
def get_dex2oat_target_dependent_flags_map():
    # New flags added here might need to be accounted for in
    # src/build/generate_build_prop.py for runtime dex2oat to work properly.
    flags = {}
    if not OPTIONS.is_debug_info_enabled():
        flags["no-include-debug-symbols"] = ""

    if OPTIONS.is_i686():
        flags["instruction-set-features"] = "default"
        flags["instruction-set"] = "x86"
        flags["compiler-filter"] = "speed"
    elif OPTIONS.is_x86_64():
        flags["instruction-set-features"] = "default"
        flags["instruction-set"] = "x86_64"
        flags["compiler-filter"] = "space"
        flags["small-method-max"] = "30"
        flags["tiny-method-max"] = "10"
    elif OPTIONS.is_arm():
        flags["instruction-set-features"] = "div"
        flags["instruction-set"] = "arm"
        flags["compiler-filter"] = "everything"
    return flags
Esempio n. 32
0
def get_dex2oat_target_dependent_flags_map():
    # New flags added here might need to be accounted for in
    # src/build/generate_build_prop.py for runtime dex2oat to work properly.
    flags = {}
    if not OPTIONS.is_debug_info_enabled():
        flags['no-include-debug-symbols'] = ''

    if OPTIONS.is_i686():
        flags['instruction-set-features'] = 'default'
        flags['instruction-set'] = 'x86'
        flags['compiler-filter'] = 'speed'
    elif OPTIONS.is_x86_64():
        flags['instruction-set-features'] = 'default'
        flags['instruction-set'] = 'x86_64'
        flags['compiler-filter'] = 'space'
        flags['small-method-max'] = '30'
        flags['tiny-method-max'] = '10'
    elif OPTIONS.is_arm():
        flags['instruction-set-features'] = 'div'
        flags['instruction-set'] = 'arm'
        flags['compiler-filter'] = 'everything'
    return flags
Esempio n. 33
0
def extend_chrome_params(parsed_args, params):
    # Do not show the New Tab Page because showing NTP during perftest makes the
    # benchmark score look unnecessarily bad especially on ARM Chromebooks where
    # CPU resource is very limited.
    # TODO(yusukes): Use this option on Windows/Mac/Linux too. We might need to
    # use --keep-alive-for-test then.
    params.append("--no-startup-window")

    if parsed_args.login_user:
        user = parsed_args.login_user
        params.append("--login-user=%s" % user)
        params.append("--login-profile=%s" % _get_user_hash(user))
    else:
        # Login as a fake test user when login_user is not specified.
        params.append("--login-user="******"atftest", "system"):
        # On ARM Chromebooks, there is a bug (crbug.com/270064) that causes X server
        # to hang when multiple ash host windows are displayed in the size of the
        # screen, which is the default ash host window size on Chrome OS. In order
        # to workaround this issue, show the ash host window in the size 1 pixel
        # wider than the original screen size.
        # Newer Chromebooks run without X and don't need this workaround.
        # TODO(crbug.com/314050): Remove the workaround once the upstream issue is
        # fixed, or all supported Chromebooks stop using X.

        try:
            output = subprocess.check_output(["xdpyinfo", "-display", ":0.0"])
            m = re.search(r"dimensions: +([0-9]+)x([0-9]+) pixels", output)
            if not m:
                raise Exception("Cannot get the screen size")
            width, height = int(m.group(1)) + 1, int(m.group(2))
            params.append("--ash-host-window-bounds=0+0-%dx%d" % (width, height))
        except OSError as e:
            # Ignore the error on missing xdpyinfo assuming the Chromebook runs
            # without X.
            if e.errno != errno.ENOENT:
                raise
        except subprocess.CalledProcessError:
            # Ignore the error on calling xdpyinfo assuming the Chromebook runs
            # without X.
            pass

    assert os.path.exists(_CHROME_COMMAND_LINE_FILE), "%s does not exist." % _CHROME_COMMAND_LINE_FILE
    with open(_CHROME_COMMAND_LINE_FILE) as f:
        chrome_command_line = f.read().rstrip()
    params_str = re.sub("^%s " % _REMOTE_CHROME_EXE_BINARY, "", chrome_command_line)
    # Use ' -' instead of ' ' to split the command line flags because the flag
    # values can contain spaces.
    new_params = params_str.split(" -")
    new_params[1:] = ["-" + param for param in new_params[1:]]

    # Check if _UNNEEDED_PARAM_PREFIXES is up to date.
    for unneeded_param in _UNNEEDED_PARAM_PREFIXES:
        if not any(p.startswith(unneeded_param) for p in new_params):
            print "WARNING: _UNNEEDED_PARAM_PREFIXES is outdated. Remove %s." % (unneeded_param)

    # Append the flags that are not set by our scripts.
    for new_param in new_params:
        if not _is_param_set(new_param, params) and _is_param_needed(new_param):
            params.append(new_param)
Esempio n. 34
0
def use_ppapi_fpabi_shim():
    return OPTIONS.is_arm()
Esempio n. 35
0
def use_ppapi_fpabi_shim():
    return OPTIONS.is_arm()
Esempio n. 36
0
def extend_chrome_params(parsed_args, params):
    # Do not show the New Tab Page because showing NTP during perftest makes the
    # benchmark score look unnecessarily bad especially on ARM Chromebooks where
    # CPU resource is very limited.
    # TODO(yusukes): Use this option on Windows/Mac/Linux too. We might need to
    # use --keep-alive-for-test then.
    params.append('--no-startup-window')

    if parsed_args.login_user:
        user = parsed_args.login_user
        params.append('--login-user=%s' % user)
        params.append('--login-profile=%s' % _get_user_hash(user))
    else:
        # Login as a fake test user when login_user is not specified.
        params.append('--login-user='******'atftest', 'system'):
        # On ARM Chromebooks, there is a bug (crbug.com/270064) that causes X server
        # to hang when multiple ash host windows are displayed in the size of the
        # screen, which is the default ash host window size on Chrome OS. In order
        # to workaround this issue, show the ash host window in the size 1 pixel
        # wider than the original screen size.
        # Newer Chromebooks run without X and don't need this workaround.
        # TODO(crbug.com/314050): Remove the workaround once the upstream issue is
        # fixed, or all supported Chromebooks stop using X.

        try:
            output = subprocess.check_output(['xdpyinfo', '-display', ':0.0'])
            m = re.search(r'dimensions: +([0-9]+)x([0-9]+) pixels', output)
            if not m:
                raise Exception('Cannot get the screen size')
            width, height = int(m.group(1)) + 1, int(m.group(2))
            params.append('--ash-host-window-bounds=0+0-%dx%d' %
                          (width, height))
        except OSError as e:
            # Ignore the error on missing xdpyinfo assuming the Chromebook runs
            # without X.
            if e.errno != errno.ENOENT:
                raise
        except subprocess.CalledProcessError:
            # Ignore the error on calling xdpyinfo assuming the Chromebook runs
            # without X.
            pass

    assert os.path.exists(_CHROME_COMMAND_LINE_FILE), (
        '%s does not exist.' % _CHROME_COMMAND_LINE_FILE)
    with open(_CHROME_COMMAND_LINE_FILE) as f:
        chrome_command_line = f.read().rstrip()
    params_str = re.sub('^%s ' % _REMOTE_CHROME_EXE_BINARY, '',
                        chrome_command_line)
    # Use ' -' instead of ' ' to split the command line flags because the flag
    # values can contain spaces.
    new_params = params_str.split(' -')
    new_params[1:] = ['-' + param for param in new_params[1:]]

    # Check if _UNNEEDED_PARAM_PREFIXES is up to date.
    for unneeded_param in _UNNEEDED_PARAM_PREFIXES:
        if not any(p.startswith(unneeded_param) for p in new_params):
            print 'WARNING: _UNNEEDED_PARAM_PREFIXES is outdated. Remove %s.' % (
                unneeded_param)

    # Append the flags that are not set by our scripts.
    for new_param in new_params:
        if not _is_param_set(new_param,
                             params) and _is_param_needed(new_param):
            params.append(new_param)
Esempio n. 37
0
def get_nonsfi_loader(nacl_arch=None):
    if nacl_arch is None:
        nacl_arch = 'arm' if OPTIONS.is_arm() else 'x86_32'
    return os.path.join(_NACL_TOOLS_PATH, 'nonsfi_loader_' + nacl_arch)
Esempio n. 38
0
def get_nonsfi_loader(nacl_arch=None):
  if nacl_arch is None:
    nacl_arch = 'arm' if OPTIONS.is_arm() else 'x86_32'
  return os.path.join(_NACL_TOOLS_PATH, 'nonsfi_loader_' + nacl_arch)