Beispiel #1
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)])
Beispiel #2
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)])
Beispiel #3
0
    def _filter(vars):
        if OPTIONS.is_nacl_build():
            # The flag is valid only for C/ObjC but not for C++ on NaCl gcc.
            vars.remove_c_or_cxxflag('-Wno-int-to-pointer-cast')
        # TODO(crbug.com/327496): Move this to generic functionality of
        # make_to_ninja.
        intermediates_dir = (make_to_ninja.MakefileNinjaTranslator.
                             get_intermediate_headers_dir())
        vars.get_includes().append(intermediates_dir)
        # TODO(crbug.com/414569): L-rebase: These include directories do not seem to
        # be being added. Fix that.
        vars.get_includes().append(
            'android/frameworks/av/media/img_utils/include')
        vars.get_includes().append('android/external/skia/include/pathops')
        vars.get_includes().append(
            'android/system/core/libprocessgroup/include')
        vars.get_implicit_deps().extend([
            intermediates_dir + '/' + i for i in [
                'libsonivox/eas.h', 'libsonivox/eas_types.h',
                'libsonivox/eas_reverb.h', 'libsonivox/jet.h'
            ]
        ])
        # Exclude ZygoteInit for which we have stubbed out jni registrations.
        vars.get_sources().remove('android/frameworks/base/core/jni/'
                                  'com_android_internal_os_ZygoteInit.cpp')
        # Exclude GLES31+ functionality since we do not currently support it.
        vars.get_sources().remove('android/frameworks/base/core/jni/'
                                  'android_opengl_GLES31.cpp')
        vars.get_sources().remove('android/frameworks/base/core/jni/'
                                  'android_opengl_GLES31Ext.cpp')
        # Add ARC specific JNIs.
        vars.get_sources().extend([
            'android/frameworks/base/core/jni/org_chromium_arc_internal_Tracing.cpp',  # NOQA
            'android/frameworks/base/core/jni/org_chromium_arc_ArcProxySelector.cpp',  # NOQA
        ])

        if OPTIONS.disable_hwui():
            # Defining this enables support for hardware accelerated rendering in the
            # user interface code, such as when an application uses a TextureView. The
            # primary effect is to use libhwui.  It is enabled by default in the
            # Android.mk file, we disable it here when not enabling hwui.
            vars.get_cflags().remove('-DUSE_OPENGL_RENDERER')
        if build_common.use_ndk_direct_execution():
            vars.get_cflags().append('-DUSE_NDK_DIRECT_EXECUTION')
        deps = vars.get_shared_deps()
        excluded_libs = (
            'libprocessgroup',  # Not built
            'libhardware_legacy',  # Not built
            'libnetutils',  # Not built
            'libselinux',  # Not built
            'libusbhost',  # Not built (only for MTP)
            'libwpa_client')  # Not built
        deps[:] = [x for x in deps if x not in excluded_libs]
        return True
Beispiel #4
0
def generate_test_ninjas():
    n = ninja_generator.TestNinjaGenerator('libcommon_test',
                                           force_compiler='clang',
                                           enable_cxx11=True,
                                           base_path='src/common')
    n.build_default_all_test_sources()
    if build_common.use_ndk_direct_execution():
        n.add_compiler_flags('-DUSE_NDK_DIRECT_EXECUTION')
    n.add_compiler_flags('-Werror')
    n.add_library_deps('libgccdemangle_static.a')
    _add_compile_flags(n)
    n.run(n.link())
Beispiel #5
0
def generate_test_ninjas():
  n = ninja_generator.TestNinjaGenerator('libcommon_test',
                                         force_compiler='clang',
                                         enable_cxx11=True,
                                         base_path='src/common')
  n.build_default_all_test_sources()
  if build_common.use_ndk_direct_execution():
    n.add_compiler_flags('-DUSE_NDK_DIRECT_EXECUTION')
  n.add_compiler_flags('-Werror')
  n.add_library_deps('libgccdemangle_static.a')
  _add_compile_flags(n)
  n.run(n.link())
Beispiel #6
0
  def _filter(vars):
    if OPTIONS.is_nacl_build():
      # The flag is valid only for C/ObjC but not for C++ on NaCl gcc.
      vars.remove_c_or_cxxflag('-Wno-int-to-pointer-cast')
    # TODO(crbug.com/327496): Move this to generic functionality of
    # make_to_ninja.
    intermediates_dir = (
        make_to_ninja.MakefileNinjaTranslator.get_intermediate_headers_dir())
    vars.get_includes().append(intermediates_dir)
    # TODO(crbug.com/414569): L-rebase: These include directories do not seem to
    # be being added. Fix that.
    vars.get_includes().append('android/frameworks/av/media/img_utils/include')
    vars.get_includes().append('android/external/skia/include/pathops')
    vars.get_includes().append('android/system/core/libprocessgroup/include')
    vars.get_implicit_deps().extend(
        [intermediates_dir + '/' + i for i in [
            'libsonivox/eas.h',
            'libsonivox/eas_types.h',
            'libsonivox/eas_reverb.h',
            'libsonivox/jet.h']])
    # Exclude ZygoteInit for which we have stubbed out jni registrations.
    vars.get_sources().remove('android/frameworks/base/core/jni/'
                              'com_android_internal_os_ZygoteInit.cpp')
    # Exclude GLES31+ functionality since we do not currently support it.
    vars.get_sources().remove('android/frameworks/base/core/jni/'
                              'android_opengl_GLES31.cpp')
    vars.get_sources().remove('android/frameworks/base/core/jni/'
                              'android_opengl_GLES31Ext.cpp')
    # Add ARC specific JNIs.
    vars.get_sources().extend([
        'android/frameworks/base/core/jni/org_chromium_arc_internal_Tracing.cpp',  # NOQA
        'android/frameworks/base/core/jni/org_chromium_arc_ArcProxySelector.cpp',  # NOQA
    ])

    if OPTIONS.disable_hwui():
      # Defining this enables support for hardware accelerated rendering in the
      # user interface code, such as when an application uses a TextureView. The
      # primary effect is to use libhwui.  It is enabled by default in the
      # Android.mk file, we disable it here when not enabling hwui.
      vars.get_cflags().remove('-DUSE_OPENGL_RENDERER')
    if build_common.use_ndk_direct_execution():
      vars.get_cflags().append('-DUSE_NDK_DIRECT_EXECUTION')
    deps = vars.get_shared_deps()
    excluded_libs = (
        'libprocessgroup',     # Not built
        'libhardware_legacy',  # Not built
        'libnetutils',         # Not built
        'libselinux',          # Not built
        'libusbhost',          # Not built (only for MTP)
        'libwpa_client')       # Not built
    deps[:] = [x for x in deps if x not in excluded_libs]
    return True
Beispiel #7
0
def _read_test_config(path, on_bot, use_gpu, remote_host_type):
  """Reads the file, and eval() it with the test config context."""
  if not os.path.exists(path):
    return {}

  with open(path) as stream:
    content = stream.read()
  test_context = {
      '__builtin__': None,  # Do not inherit the current context.

      # Expectation flags.
      'PASS': flags.FlagSet(flags.PASS),
      'FLAKY': flags.FlagSet(flags.FLAKY),
      'FAIL': flags.FlagSet(flags.FAIL),
      'TIMEOUT': flags.FlagSet(flags.TIMEOUT),
      'NOT_SUPPORTED': flags.FlagSet(flags.NOT_SUPPORTED),
      'LARGE': flags.FlagSet(flags.LARGE),

      # OPTIONS is commonly used for the conditions.
      'OPTIONS': OPTIONS,

      # Variables which can be used to check runtime configurations.
      'ON_BOT': on_bot,
      'USE_GPU': use_gpu,
      'USE_NDK_DIRECT_EXECUTION': build_common.use_ndk_direct_execution(),

      # Platform information of the machine on which the test runs for
      # remote execution. If it is not the remote execution, all variables
      # below will be False.
      'ON_CYGWIN': remote_host_type == 'cygwin',
      'ON_MAC': remote_host_type == 'mac',
      'ON_CHROMEOS': remote_host_type == 'chromeos',
  }

  try:
    raw_config = eval(content, test_context)
  except Exception as e:
    e.args = (e.args[0] + '\neval() failed: ' + path,) + e.args[1:]
    raise

  try:
    _validate(raw_config)
  except Exception as e:
    e.args = (e.args[0] + '\nValidation failed: ' + path,) + e.args[1:]
    raise
  return raw_config
Beispiel #8
0
def _read_test_config(path, on_bot, use_gpu, remote_host_type):
    """Reads the file, and eval() it with the test config context."""
    if not os.path.exists(path):
        return {}

    with open(path) as stream:
        content = stream.read()
    test_context = {
        '__builtin__': None,  # Do not inherit the current context.

        # Expectation flags.
        'PASS': flags.FlagSet(flags.PASS),
        'FLAKY': flags.FlagSet(flags.FLAKY),
        'FAIL': flags.FlagSet(flags.FAIL),
        'TIMEOUT': flags.FlagSet(flags.TIMEOUT),
        'NOT_SUPPORTED': flags.FlagSet(flags.NOT_SUPPORTED),
        'LARGE': flags.FlagSet(flags.LARGE),

        # OPTIONS is commonly used for the conditions.
        'OPTIONS': OPTIONS,

        # Variables which can be used to check runtime configurations.
        'ON_BOT': on_bot,
        'USE_GPU': use_gpu,
        'USE_NDK_DIRECT_EXECUTION': build_common.use_ndk_direct_execution(),

        # Platform information of the machine on which the test runs for
        # remote execution. If it is not the remote execution, all variables
        # below will be False.
        'ON_CYGWIN': remote_host_type == 'cygwin',
        'ON_MAC': remote_host_type == 'mac',
        'ON_CHROMEOS': remote_host_type == 'chromeos',
    }

    try:
        raw_config = eval(content, test_context)
    except Exception as e:
        e.args = (e.args[0] + '\neval() failed: ' + path, ) + e.args[1:]
        raise

    try:
        _validate(raw_config)
    except Exception as e:
        e.args = (e.args[0] + '\nValidation failed: ' + path, ) + e.args[1:]
        raise
    return raw_config
Beispiel #9
0
def _generate_libcommon_ninja(module_name, instances, enable_libcxx,
                              extra_sources):
    n = ninja_generator.ArchiveNinjaGenerator(module_name,
                                              instances=instances,
                                              force_compiler='clang',
                                              enable_cxx11=True,
                                              enable_libcxx=enable_libcxx,
                                              base_path='src/common')
    n.add_compiler_flags('-Werror')
    if build_common.use_ndk_direct_execution():
        n.add_compiler_flags('-DUSE_NDK_DIRECT_EXECUTION')
    # Common code really should not reach out into external.
    n.add_include_paths('android_libcommon')
    _add_compile_flags(n)
    sources = n.find_all_sources()
    sources.remove('src/common/plugin_handle.cc')
    sources.extend(build_common.as_list(extra_sources))
    return n.build_default(sources, base_path=None).archive()
Beispiel #10
0
def _generate_libcommon_ninja(
    module_name, instances, enable_libcxx, extra_sources):
  n = ninja_generator.ArchiveNinjaGenerator(module_name,
                                            instances=instances,
                                            force_compiler='clang',
                                            enable_cxx11=True,
                                            enable_libcxx=enable_libcxx,
                                            base_path='src/common')
  n.add_compiler_flags('-Werror')
  if build_common.use_ndk_direct_execution():
    n.add_compiler_flags('-DUSE_NDK_DIRECT_EXECUTION')
  # Common code really should not reach out into external.
  n.add_include_paths('android_libcommon')
  _add_compile_flags(n)
  sources = n.find_all_sources()
  sources.remove('src/common/plugin_handle.cc')
  sources.extend(build_common.as_list(extra_sources))
  return n.build_default(sources, base_path=None).archive()
Beispiel #11
0
def generate_test_ninjas():
  n = ninja_generator.PpapiTestNinjaGenerator(
      'posix_translation_test',
      base_path='src/posix_translation',
      force_compiler='clang',
      enable_cxx11=True)
  # Build a rootfs image for tests.
  rule_name = 'gen_test_fs_image'
  script_path = 'src/posix_translation/scripts/create_test_fs_image.py'

  gen_prod_image = (
      build_common.get_posix_translation_readonly_fs_image_file_path())

  # This is a little odd, but we use the documented path to the production image
  # to also store a test image in the same location for simplicity.
  out_path = os.path.dirname(gen_prod_image)
  gen_test_image = os.path.join(out_path, 'test_readonly_fs_image.img')

  n.rule(rule_name,
         command=script_path + ' $out_path',
         description=rule_name + ' $in_real_path')
  n.add_ppapi_compile_flags()
  n.build([gen_test_image], rule_name,
          variables={'out_path': out_path},
          # The script calls create_readonly_fs_image.py.
          implicit=[script_path,
                    _CREATE_READONLY_FS_IMAGE_SCRIPT,
                    ])
  all_files = n.find_all_contained_test_sources()

  n.build_default(all_files, base_path=None)
  n.add_compiler_flags('-Werror')
  n.add_library_deps('libposix_translation_static.a',
                     'libchromium_base.a',
                     'libcommon.a',
                     'libgccdemangle_static.a')
  if build_common.use_ndk_direct_execution():
    n.add_defines('USE_NDK_DIRECT_EXECUTION')
  implicit = [gen_test_image]
  if open_source.is_open_source_repo():
    implicit.append(gen_prod_image)
    n.add_defines('PROD_READONLY_FS_IMAGE="%s"' % gen_prod_image)
  else:
    # Add runtime to implicit dependencies because ReadonlyFsReaderTest uses
    # the readonly FS image in runtime.
    implicit.append(build_common.get_runtime_build_stamp())
    n.add_defines('PROD_READONLY_FS_IMAGE="%s"' % os.path.join(
                  build_common.get_runtime_platform_specific_path(
                      build_common.get_runtime_out_dir(), OPTIONS.target()),
                  os.path.basename(gen_prod_image)))
    n.run(n.link(), implicit=implicit)

  # To be able to refer mock implementation from outside of posix_translation.
  # Setting instance count is zero because usage count verifier doesn't check
  # the reference from test executable. See verify_usage_counts in
  # ninja_generator.py
  n = ninja_generator.ArchiveNinjaGenerator(
      'mock_posix_translation',
      instances=0,
      force_compiler='clang',
      enable_cxx11=True)
  n.add_libchromium_base_compile_flags()
  n.add_compiler_flags('-Werror')
  all_files = ['src/posix_translation/test_util/mock_virtual_file_system.cc']
  n.build_default(all_files).archive()