Example #1
0
def _generate_image_generator_ninja():
  n = ninja_generator.ExecNinjaGenerator(
      build_common.get_graphics_translation_image_generator_name(), host=True,
      base_path='mods/graphics_translation/tests')
  _add_compile_flags(n)
  n.add_defines('HAVE_PTHREADS')
  n.add_include_paths(
      staging.as_staging('android/external/chromium_org/testing/gtest/include'),
      staging.as_staging('android/external/chromium_org/testing/gtest/'))
  sources = build_common.find_all_files(
      ['mods/graphics_translation/tests'],
      suffixes='.cpp',
      include_tests=True,
      use_staging=False)
  sources.extend(
      ['mods/graphics_translation/gles/debug.cpp',
       'mods/graphics_translation/gles/texture_codecs.cpp',
       'src/common/vector.cc',
       'src/common/matrix.cc',
       staging.as_staging(
           'android/external/chromium_org/testing/gtest/src/gtest-all.cc')])
  sources = [x for x in sources if x.find('apk') < 0]
  n.build_default(sources, base_path=None)
  variables = {'my_static_libs': '-lX11 -lGL'}
  n.link(variables=variables)
Example #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)])
Example #3
0
def _generate_image_generator_ninja():
    n = ninja_generator.ExecNinjaGenerator(
        build_common.get_graphics_translation_image_generator_name(),
        host=True,
        base_path='mods/graphics_translation/tests')
    _add_compile_flags(n)
    n.add_defines('HAVE_PTHREADS')
    n.add_include_paths(
        staging.as_staging(
            'android/external/chromium_org/testing/gtest/include'),
        staging.as_staging('android/external/chromium_org/testing/gtest/'))
    sources = build_common.find_all_files(['mods/graphics_translation/tests'],
                                          suffixes='.cpp',
                                          include_tests=True,
                                          use_staging=False)
    sources.extend([
        'mods/graphics_translation/gles/debug.cpp',
        'mods/graphics_translation/gles/texture_codecs.cpp',
        'src/common/vector.cc', 'src/common/matrix.cc',
        staging.as_staging(
            'android/external/chromium_org/testing/gtest/src/gtest-all.cc')
    ])
    sources = [x for x in sources if x.find('apk') < 0]
    n.build_default(sources, base_path=None)
    variables = {'my_static_libs': '-lX11 -lGL'}
    n.link(variables=variables)
Example #4
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)])
Example #5
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
Example #6
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
Example #7
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
Example #8
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
Example #9
0
def _generate_libppapi_mocks():
  ppapi_dir = staging.as_staging('chromium-ppapi/ppapi')
  api_dir = os.path.join(ppapi_dir, 'api')
  out_dir = os.path.join(
      ninja_generator.PpapiTestNinjaGenerator.get_ppapi_mocks_generated_dir(),
      'ppapi_mocks')
  stamp_file = os.path.join(out_dir, 'STAMP')

  # Generate PPAPI mock sources from IDL files.
  rule_name = 'gen_ppapi_mock'
  n = ninja_generator.PythonNinjaGenerator(rule_name)
  script_path = os.path.join(_MY_DIR, 'gen_ppapi_mock.py')
  args = ['--wnone',  # Suppress all warnings.
          '--range=start,end',  # Generate code for all revisions.
          '--ppapicgen',  # Generate PpapiMock source files.
          '--ppapihgen',  # Generate PpapiMock header files.
          '--srcroot', api_dir,
          '--dstroot', out_dir]
  n.emit_python_rule(
      rule_name, script_path, args, extra_command='&& touch $stamp')

  generated_files = []
  idl_list = n.find_all_files('chromium-ppapi/ppapi/api', '.idl')
  for idl_path in idl_list:
    if 'finish_writing_these' in idl_path:
      # Files under ppapi/api/private/finish_writing_these/ directory are not
      # found by the parser of the idl generator library.
      continue
    path_stem = os.path.splitext(os.path.basename(idl_path))[0]
    # We are interested in only PPB files.
    if not path_stem.startswith('ppb_'):
      continue
    generated_files.append(os.path.join(out_dir, path_stem + '.cc'))
    generated_files.append(os.path.join(out_dir, path_stem + '.h'))

  n.run_python(generated_files + [stamp_file], rule_name,
               variables={'stamp': pipes.quote(stamp_file)},
               implicit=map(staging.as_staging, idl_list))

  # Build libppapi_mocks. libart-gtest depends on libppapi_mocks.
  n = ninja_generator.ArchiveNinjaGenerator('libppapi_mocks',
                                            instances=0,
                                            force_compiler='clang',
                                            enable_cxx11=True)
  n.add_ppapi_compile_flags()
  n.add_libchromium_base_compile_flags()
  n.add_include_paths(
      staging.as_staging('testing/gmock/include'),
      _MY_DIR,
      ninja_generator.PpapiTestNinjaGenerator.get_ppapi_mocks_generated_dir())

  n.build_default(
      [path for path in generated_files if path.endswith('.cc')] +
      n.find_all_files([_MY_DIR], '.cc', include_tests=True),
      implicit=[stamp_file])
  n.archive()
Example #10
0
def _generate_gmock_ninja(name, enable_libcxx=False):
  n = ninja_generator.ArchiveNinjaGenerator(
      name, base_path='testing/gmock/src',
      instances=0,  # Not used by shared objects
      force_compiler='clang',
      enable_cxx11=True,
      enable_libcxx=enable_libcxx)
  n.add_include_paths(staging.as_staging('testing/gmock'),
                      staging.as_staging('testing/gmock/include'))
  n.build_default(['gmock-all.cc']).archive()
Example #11
0
def _generate_gmock_ninja(name, enable_libcxx=False):
    n = ninja_generator.ArchiveNinjaGenerator(
        name,
        base_path='testing/gmock/src',
        instances=0,  # Not used by shared objects
        force_compiler='clang',
        enable_cxx11=True,
        enable_libcxx=enable_libcxx)
    n.add_include_paths(staging.as_staging('testing/gmock'),
                        staging.as_staging('testing/gmock/include'))
    n.build_default(['gmock-all.cc']).archive()
def main(args):
  script = staging.as_staging(
      'android/external/chromium_org/tools/linux/dump-static-initializers.py')
  failure = 0
  arch = 'bare_metal_i686_opt'
  for library in build_common.CHECKED_LIBRARIES:
    temp = 'src/build/dump-static-initializers-%s-expected-temp.txt' % library
    out = 'src/build/dump-static-initializers-%s-expected.txt' % library
    lib = 'out/target/%s/lib/%s' % (arch, library)
    ret = subprocess.call(
        'python src/build/run_python %s -d %s > %s' % (script, lib, temp),
        shell=True)
    if ret:
      failure = 1
    else:
      # Remove the 'Found XXX static initializers' line. Also remove results
      # for .cpp (i.e. Android) files.
      subprocess.call(('egrep -ve \'^# (.*\.cpp |Found )\' < %s |' +
                       'sed -e \'s/ T\.[0-9]*/ T.XXXXX/\' > %s') %
                      (temp, out), shell=True)
    if os.path.exists(temp):
      os.remove(temp)

  if failure:
    print '\n\nError: Failed to update all expectations!\n\n'
  return failure
Example #13
0
def _generate_checkdeps_ninjas():
    if open_source.is_open_source_repo():
        # Do not run checkdeps on the open source repo since some directories
        # checked are not included there.
        return
    n = ninja_generator.NinjaGenerator('checkdeps', target_groups=['lint'])
    checkdeps_script = staging.as_staging(
        'native_client/tools/checkdeps/checkdeps.py')
    n.rule('checkdeps',
           command=('%s -v --root=$root $in_dir > $out.tmp 2>&1 '
                    '&& mv $out.tmp $out '
                    '|| (cat $out.tmp; rm $out.tmp; exit 1)' %
                    checkdeps_script),
           description='checkdeps $in_dir')
    # Detect bad #include lines in src/.
    # TODO(crbug.com/323786): Check #include lines in mods/ too.
    src_dir = os.path.join(build_common.get_arc_root(), 'src')
    src_deps = os.path.join(src_dir, 'DEPS')
    for d in ['common', 'ndk_translation', 'posix_translation']:
        # TODO(crbug.com/323786): Check other directories in src/ too.
        implicit = build_common.find_all_files(
            os.path.join(src_dir, d),
            suffixes=['h', 'c', 'cc', 'cpp', 'java', 'DEPS'],
            include_tests=True,
            use_staging=False)
        implicit.extend([checkdeps_script, src_deps])
        out = os.path.join(build_common.OUT_DIR, 'checkdeps_%s.txt' % d)
        n.build(out,
                'checkdeps', [],
                variables={
                    'root': src_dir,
                    'in_dir': d
                },
                implicit=implicit)
Example #14
0
def _generate_pass_through_code(n):
  rule_name = 'pass_through_gen'

  api_dir = staging.as_staging('chromium-ppapi/ppapi/api')
  script_path = 'mods/graphics_translation/gles/pass_through_gen.py'

  gen_command = ['src/build/run_python', script_path,
                 '--wnone',
                 '--passthroughgen',
                 '--hpp=graphics_translation/gles/pass_through.h',
                 '--cpp=graphics_translation/gles/pass_through.cpp',
                 '--range=start,end',
                 '--srcroot', pipes.quote(api_dir),
                 '--dstroot', '$dstroot',
                 '>', '$logfile',
                 '|| (cat $logfile; rm $logfile; exit 1)']
  n.rule(rule_name,
         command=' '.join(gen_command),
         description='pass_through_gen')

  idls = n.find_all_files(api_dir, 'idl')
  n.build([_get_pass_through_h_path(), _get_pass_through_impl_path()],
          rule_name, idls, implicit=['src/build/run_python', script_path],
          variables={'logfile': os.path.join(_get_generated_sources_path(),
                                             'pass_through_gen.log'),
                     'dstroot': _get_generated_sources_path()})
Example #15
0
def _generate_integration_test_ninja():
    n = ninja_generator.ApkFromSdkNinjaGenerator(
        build_common.get_graphics_translation_test_name(),
        base_path='graphics_translation/tests/apk',
        use_ndk=True,
        use_gtest=True)
    sources = build_common.find_all_files(base_paths=[
        'graphics_translation/tests', 'graphics_translation/tests/util'
    ],
                                          suffixes=['.cpp', '.h'],
                                          include_tests=True,
                                          recursive=False)

    # Additional source code dependencies to outside of
    # graphics_translation/tests.
    implicit = [
        'android_libcommon/common/alog.h',
        'graphics_translation/gles/debug.cpp',
        'graphics_translation/gles/debug.h',
        'graphics_translation/gles/texture_codecs.cpp',
        'graphics_translation/gles/texture_codecs.h',
        'src/common/math_test_helpers.h',
        'src/common/matrix.cc',
        'src/common/matrix.h',
        'src/common/vector.cc',
        'src/common/vector.h',
    ]

    n.build_default_all_sources(
        implicit=[staging.as_staging(path) for path in (sources + implicit)])
    n.build_google_test_list(sources)
Example #16
0
def main(args):
    script = staging.as_staging(
        'android/external/chromium_org/tools/linux/dump-static-initializers.py'
    )
    failure = 0
    arch = 'bare_metal_i686_opt'
    for library in build_common.CHECKED_LIBRARIES:
        temp = 'src/build/dump-static-initializers-%s-expected-temp.txt' % library
        out = 'src/build/dump-static-initializers-%s-expected.txt' % library
        lib = 'out/target/%s/lib/%s' % (arch, library)
        ret = subprocess.call('python src/build/run_python %s -d %s > %s' %
                              (script, lib, temp),
                              shell=True)
        if ret:
            failure = 1
        else:
            # Remove the 'Found XXX static initializers' line. Also remove results
            # for .cpp (i.e. Android) files.
            subprocess.call(
                ('egrep -ve \'^# (.*\.cpp |Found )\' < %s |' +
                 'sed -e \'s/ T\.[0-9]*/ T.XXXXX/\' > %s') % (temp, out),
                shell=True)
        if os.path.exists(temp):
            os.remove(temp)

    if failure:
        print '\n\nError: Failed to update all expectations!\n\n'
    return failure
Example #17
0
def _generate_checkdeps_ninjas():
  if open_source.is_open_source_repo():
    # Do not run checkdeps on the open source repo since some directories
    # checked are not included there.
    return
  n = ninja_generator.NinjaGenerator('checkdeps', target_groups=['lint'])
  checkdeps_script = staging.as_staging(
      'native_client/tools/checkdeps/checkdeps.py')
  n.rule('checkdeps',
         command=('%s -v --root=$root $in_dir > $out.tmp 2>&1 '
                  '&& mv $out.tmp $out '
                  '|| (cat $out.tmp; rm $out.tmp; exit 1)' % checkdeps_script),
         description='checkdeps $in_dir')
  # Detect bad #include lines in src/.
  # TODO(crbug.com/323786): Check #include lines in mods/ too.
  src_dir = os.path.join(build_common.get_arc_root(), 'src')
  src_deps = os.path.join(src_dir, 'DEPS')
  for d in ['common', 'ndk_translation', 'posix_translation']:
    # TODO(crbug.com/323786): Check other directories in src/ too.
    implicit = build_common.find_all_files(
        os.path.join(src_dir, d),
        suffixes=['h', 'c', 'cc', 'cpp', 'java', 'DEPS'],
        include_tests=True, use_staging=False)
    implicit.extend([checkdeps_script, src_deps])
    out = os.path.join(build_common.OUT_DIR, 'checkdeps_%s.txt' % d)
    n.build(out, 'checkdeps', [],
            variables={'root': src_dir, 'in_dir': d},
            implicit=implicit)
Example #18
0
def _generate_integration_test_ninja():
  n = ninja_generator.ApkFromSdkNinjaGenerator(
      build_common.get_graphics_translation_test_name(),
      base_path='graphics_translation/tests/apk',
      use_ndk=True, use_gtest=True)
  sources = build_common.find_all_files(
      base_paths=['graphics_translation/tests',
                  'graphics_translation/tests/util'],
      suffixes=['.cpp', '.h'],
      include_tests=True,
      recursive=False)

  # Additional source code dependencies to outside of
  # graphics_translation/tests.
  implicit = [
      'android_libcommon/common/alog.h',
      'graphics_translation/gles/debug.cpp',
      'graphics_translation/gles/debug.h',
      'graphics_translation/gles/texture_codecs.cpp',
      'graphics_translation/gles/texture_codecs.h',
      'src/common/math_test_helpers.h',
      'src/common/matrix.cc',
      'src/common/matrix.h',
      'src/common/vector.cc',
      'src/common/vector.h',
  ]

  n.build_default_all_sources(
      implicit=[staging.as_staging(path) for path in (sources + implicit)])
  n.build_google_test_list(sources)
Example #19
0
def _generate_pass_through_code(n):
    rule_name = 'pass_through_gen'

    api_dir = staging.as_staging('chromium-ppapi/ppapi/api')
    script_path = 'mods/graphics_translation/gles/pass_through_gen.py'

    gen_command = [
        'src/build/run_python', script_path, '--wnone', '--passthroughgen',
        '--hpp=graphics_translation/gles/pass_through.h',
        '--cpp=graphics_translation/gles/pass_through.cpp',
        '--range=start,end', '--srcroot',
        pipes.quote(api_dir), '--dstroot', '$dstroot', '>', '$logfile',
        '|| (cat $logfile; rm $logfile; exit 1)'
    ]
    n.rule(rule_name,
           command=' '.join(gen_command),
           description='pass_through_gen')

    idls = n.find_all_files(api_dir, 'idl')
    n.build(
        [_get_pass_through_h_path(),
         _get_pass_through_impl_path()],
        rule_name,
        idls,
        implicit=['src/build/run_python', script_path],
        variables={
            'logfile':
            os.path.join(_get_generated_sources_path(),
                         'pass_through_gen.log'),
            'dstroot':
            _get_generated_sources_path()
        })
Example #20
0
def _generate_chromium_ppapi_ninja():
    base_path = 'chromium-ppapi/ppapi'
    n = ninja_generator.SharedObjectNinjaGenerator(
        'libchromium_ppapi',
        base_path=base_path,
        # The library does not require any __wrap_* function.
        is_system_library=True)
    _add_chromium_base_compiler_flags(n)
    n.add_include_paths('chromium-ppapi/ppapi')
    # native_client/src/include/portability.h expects bits/wordsize.h
    # exists in system header if __native_client__ is defined.
    # This is true for newlib and glibc,
    # but is false for bionic. So, we need an include path to
    # service_runtime's include path which is used in portability.h
    # when __native_client__ is not defined. As this directory has a
    # few more files which are incompatible with bionic, we put this
    # path as the last resort using unusual -idirafter option.
    #
    # TODO(crbug.com/243244): portability.h should check if __BIONIC__
    # is defined (or check __GLIBC__ and _NEWLIB_VERSION before we are
    # public).
    nacl_service_runtime_include_path = staging.as_staging(
        'native_client/src/trusted/service_runtime/include')
    n.add_compiler_flags('-idirafter', nacl_service_runtime_include_path)
    # With this, unistd.h will have environ global variable.
    n.add_defines('_GNU_SOURCE=1')
    if build_options.OPTIONS.is_bare_metal_build():
        # For bare metal build, we get Pepper stubs using NaCl IRT.
        n.add_defines('NACL_LINUX')
        n.add_defines('__native_client__')
        gcc_version = toolchain.get_gcc_version(build_options.OPTIONS.target())
        if build_options.OPTIONS.is_arm() and gcc_version >= [4, 8, 0]:
            # TODO(crbug.com/393385): ARM gcc 4.8 has a bug when doing tail call
            # optimization from softfp to hardfp code. Disable the optimization until
            # the bug is fixed.
            n.add_compiler_flags('-fno-optimize-sibling-calls')

    def relevant(f):
        assert f.startswith(base_path + os.path.sep)
        # internal_module.cc is for building NaCl service runtime etc. and is not
        # part of the PPAPI C++ library. See Chromium's src/ppapi/ppapi_cpp.gypi.
        if f in ['chromium-ppapi/ppapi/cpp/private/internal_module.cc']:
            return False
        ppapi_subdir = f.split(os.path.sep)[2]
        if ppapi_subdir in ['c', 'cpp', 'utility']:
            return True
        # This defines the entry point of nexe.
        return 'native_client/src/untrusted/irt_stub' in f

    build_files = filter(relevant, n.find_all_sources())
    if build_common.use_ppapi_fpabi_shim():
        build_files.append(
            os.path.join(build_common.get_ppapi_fpabi_shim_dir(),
                         'ppapi_fpabi_shim.c'))
        n.add_defines('USE_FPABI_SHIM')
    n.build_default(build_files, base_path=None)
    # Note: libstlport.so is not linked with --wrap at this point.
    n.add_library_deps('libc.so', 'libm.so', 'libdl.so', 'libstlport.so')
    n.link()
Example #21
0
def _generate_chromium_ppapi_ninja():
    base_path = "chromium-ppapi/ppapi"
    n = ninja_generator.SharedObjectNinjaGenerator(
        "libchromium_ppapi",
        base_path=base_path,
        # The library does not require any __wrap_* function.
        is_system_library=True,
    )
    _add_chromium_base_compiler_flags(n)
    n.add_include_paths("chromium-ppapi/ppapi")
    # native_client/src/include/portability.h expects bits/wordsize.h
    # exists in system header if __native_client__ is defined.
    # This is true for newlib and glibc,
    # but is false for bionic. So, we need an include path to
    # service_runtime's include path which is used in portability.h
    # when __native_client__ is not defined. As this directory has a
    # few more files which are incompatible with bionic, we put this
    # path as the last resort using unusual -idirafter option.
    #
    # TODO(crbug.com/243244): portability.h should check if __BIONIC__
    # is defined (or check __GLIBC__ and _NEWLIB_VERSION before we are
    # public).
    nacl_service_runtime_include_path = staging.as_staging("native_client/src/trusted/service_runtime/include")
    n.add_compiler_flags("-idirafter", nacl_service_runtime_include_path)
    # With this, unistd.h will have environ global variable.
    n.add_defines("_GNU_SOURCE=1")
    if build_options.OPTIONS.is_bare_metal_build():
        # For bare metal build, we get Pepper stubs using NaCl IRT.
        n.add_defines("NACL_LINUX")
        n.add_defines("__native_client__")
        gcc_version = toolchain.get_gcc_version(build_options.OPTIONS.target())
        if build_options.OPTIONS.is_arm() and gcc_version >= [4, 8, 0]:
            # TODO(crbug.com/393385): ARM gcc 4.8 has a bug when doing tail call
            # optimization from softfp to hardfp code. Disable the optimization until
            # the bug is fixed.
            n.add_compiler_flags("-fno-optimize-sibling-calls")

    def relevant(f):
        assert f.startswith(base_path + os.path.sep)
        # internal_module.cc is for building NaCl service runtime etc. and is not
        # part of the PPAPI C++ library. See Chromium's src/ppapi/ppapi_cpp.gypi.
        if f in ["chromium-ppapi/ppapi/cpp/private/internal_module.cc"]:
            return False
        ppapi_subdir = f.split(os.path.sep)[2]
        if ppapi_subdir in ["c", "cpp", "utility"]:
            return True
        # This defines the entry point of nexe.
        return "native_client/src/untrusted/irt_stub" in f

    build_files = filter(relevant, n.find_all_sources())
    if build_common.use_ppapi_fpabi_shim():
        build_files.append(os.path.join(build_common.get_ppapi_fpabi_shim_dir(), "ppapi_fpabi_shim.c"))
        n.add_defines("USE_FPABI_SHIM")
    n.build_default(build_files, base_path=None)
    # Note: libstlport.so is not linked with --wrap at this point.
    n.add_library_deps("libc.so", "libm.so", "libdl.so", "libstlport.so")
    n.link()
Example #22
0
    def _filter(vars):
        if vars.is_shared():
            return False
        module_name = vars.get_module_name()
        if module_name != 'libcompiler_rt':
            return False
        make_to_ninja.Filters.convert_to_shared_lib(vars)

        # compilerrt_abort_impl has unused parameters.
        vars.get_cflags().extend(['-Wno-unused-parameter', '-Werror'])

        # Android.mk assumes that .S files are built via clang as a front end,
        # but we just use gcc. Remove a clang specific flag here.
        # TODO(crbug.com/416353): We may be able to support this conversion inside
        # MakefileNinjaTranslator.
        vars.get_asmflags().remove('-integrated-as')

        if vars.is_target() and build_options.OPTIONS.is_nacl_i686():
            # Replace original assembly source files with NaClized source files.
            sources = vars.get_sources()
            asm_sources = [
                source for source in sources
                if os.path.splitext(source)[1] == '.S'
            ]
            for source in asm_sources:
                sources.remove(source)

            # Use C implementation instead of some assembly source files that
            # can not be converted easily.
            asm_sources = [
                source for source in asm_sources
                if os.path.basename(source) not in [
                    'floatdidf.S', 'floatdisf.S', 'floatdixf.S',
                    'floatundidf.S', 'floatundisf.S', 'floatundixf.S'
                ]
            ]
            sources.extend([
                'android/external/compiler-rt/lib/builtins/floatdidf.c',
                'android/external/compiler-rt/lib/builtins/floatdisf.c',
                'android/external/compiler-rt/lib/builtins/floatdixf.c',
                'android/external/compiler-rt/lib/builtins/floatundidf.c',
                'android/external/compiler-rt/lib/builtins/floatundisf.c',
                'android/external/compiler-rt/lib/builtins/floatundixf.c'
            ])

            # Assembly files need to include ../assembly.h that is relative path
            # from the original directory. Add the directory as an include path.
            asm_path = os.path.dirname(asm_sources[0])
            vars.get_asmflags().append('-I' + staging.as_staging(asm_path))

            n = ninja_generator.NaClizeNinjaGenerator('compier-rt')
            generated_file_list = n.generate(asm_sources)

            # Add generated files to the source file list.
            sources.extend(generated_file_list)

        return True
Example #23
0
  def _filter(vars):
    if vars.is_host():
      return False

    if vars.is_java_library():
      return False

    assert vars.is_target()

    vars.enable_clang()
    vars.enable_cxx11()
    vars.get_shared_deps().append('libcompiler_rt')

    # Force optimization since libwebviewchromium.so is too huge to fit in
    # memory space for NaCl debug build. See: http://crbug.com/475268
    if OPTIONS.is_nacl_build:
      vars.force_optimization()

    # Both stlport and Bionic libstdc++ are in the include path. We need to move
    # stlport to the very beginning of the list so it can have priority over
    # libstdc++.
    if _STLPORT_INCLUDE_PATH in vars.get_includes():
      vars.get_includes().remove(_STLPORT_INCLUDE_PATH)
      vars.get_sys_includes().insert(0,
                                     staging.as_staging(_STLPORT_INCLUDE_PATH))
    vars.get_cflags().extend([
        # Add a deref() function to ref-counted classes so they can be used with
        # the Chromium wrappers for ref-counted objects.
        '-DSK_REF_CNT_MIXIN_INCLUDE="SkRefCnt_android.h"',
        # Lower the priority of the external/skia includes so that the
        # chromium_org/third_party/skia includes are used.
        '-isystem',
        staging.as_staging('android/external/skia/include/core')])

    # Since all arch-specific .asm files are built as part of a previous
    # compilation step in Android, all the .o files they produce are listed as
    # source files in Android.mk. Some auto-generated .js files are also
    # included in this list. Remove them from the list of sources.
    def _exclude_js_and_o(filename):
      return os.path.splitext(filename)[1] not in ('.js', '.o')

    vars.get_sources()[:] = filter(_exclude_js_and_o, vars.get_sources())
    return _filter_target_modules(vars)
Example #24
0
def generate_ninjas():
  if open_source.is_open_source_repo():
    # Provide a stub.
    n = ninja_generator.SharedObjectNinjaGenerator('libjnigraphics')
    n.add_notice_sources([staging.as_staging('src/NOTICE')])
    n.link()
    return

  make_to_ninja.MakefileNinjaTranslator(
      'android/frameworks/base/native/graphics/jni').generate()
Example #25
0
def _generate_webview_package():
  # We modified package.mk to generate the intermediate .jar since it does not
  # use any of the normal mechanisms to produce the final package. We perform
  # those steps manually:
  resource_subdirectories = ['res']
  gen_resource_dirs = [
      ('android_gen_sources/GYP/shared_intermediates/'
       'android_webview_jarjar_content_resources/jarjar_res'),
      ('android_gen_sources/GYP/shared_intermediates/'
       'android_webview_jarjar_ui_resources/jarjar_res'),
      ('android_gen_sources/GYP/ui_strings_grd_intermediates/'
       'ui_strings_grd/res_grit'),
      ('android_gen_sources/GYP/content_strings_grd_intermediates/'
       'content_strings_grd/res_grit')
  ]
  for gen_resource_dir in gen_resource_dirs:
    resource_subdirectories.append(
        os.path.relpath(
            os.path.join(build_common.get_target_common_dir(),
                         gen_resource_dir),
            staging.as_staging('android/frameworks/webview/chromium')))
  n = ninja_generator.ApkNinjaGenerator(
      'webview',
      base_path='android/frameworks/webview/chromium',
      install_path='/system/framework',
      aapt_flags=[
          '--shared-lib',
          '--auto-add-overlay',
          '--extra-packages',
          'com.android.webview.chromium:org.chromium.content:org.chromium.ui'],
      resource_subdirectories=resource_subdirectories)
  # This package is about adding Android resources to the webview_library.
  # Since the resources are built from pre-generated soruce files, we need to
  # explicitly include the right NOTICE file.
  n.add_notice_sources([
      staging.as_staging('android/frameworks/webview/chromium/NOTICE')])

  n.add_extracted_jar_contents('webview_library')

  n.package()
  n.install()
Example #26
0
def _add_compile_flags(ninja):
  if OPTIONS.is_memory_usage_logging():
    ninja.add_defines('MEMORY_USAGE_LOGGING')
  if OPTIONS.log_thread_ids():
    ninja.add_defines('LOG_THREAD_IDS')
  if OPTIONS.log_timestamps():
    ninja.add_defines('LOG_TIMESTAMPS')

  ninja.add_ppapi_compile_flags()  # for mprotect_rwx.cc
  ninja.add_libchromium_base_compile_flags()
  ninja.add_cxx_flags('-isystem',
                      staging.as_staging('android/external/stlport/stlport'))
Example #27
0
def _add_compile_flags(ninja):
    if OPTIONS.is_memory_usage_logging():
        ninja.add_defines('MEMORY_USAGE_LOGGING')
    if OPTIONS.log_thread_ids():
        ninja.add_defines('LOG_THREAD_IDS')
    if OPTIONS.log_timestamps():
        ninja.add_defines('LOG_TIMESTAMPS')

    ninja.add_ppapi_compile_flags()  # for mprotect_rwx.cc
    ninja.add_libchromium_base_compile_flags()
    ninja.add_cxx_flags('-isystem',
                        staging.as_staging('android/external/stlport/stlport'))
Example #28
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)
Example #29
0
def _generate_gtest_ninja(name, instances=0, enable_libcxx=False, host=False):
  n = ninja_generator.ArchiveNinjaGenerator(
      name, base_path='android/external/chromium_org/testing/gtest/src',
      instances=instances,
      force_compiler='clang',
      enable_cxx11=True,
      enable_libcxx=enable_libcxx,
      host=host)
  n.add_include_paths(staging.as_staging(
      'android/external/chromium_org/testing/gtest'))
  # To avoid "private field 'pretty_' is not used" on clang.
  n.add_compiler_flags('-Wno-unused-private-field')
  n.build_default(['gtest-all.cc']).archive()
Example #30
0
  def _filter(vars):
    if vars.is_shared():
      return False
    module_name = vars.get_module_name()
    if module_name != 'libcompiler_rt':
      return False
    make_to_ninja.Filters.convert_to_shared_lib(vars)

    # compilerrt_abort_impl has unused parameters.
    vars.get_cflags().extend(['-Wno-unused-parameter', '-Werror'])

    # Android.mk assumes that .S files are built via clang as a front end,
    # but we just use gcc. Remove a clang specific flag here.
    # TODO(crbug.com/416353): We may be able to support this conversion inside
    # MakefileNinjaTranslator.
    vars.get_asmflags().remove('-integrated-as')

    if vars.is_target() and build_options.OPTIONS.is_nacl_i686():
      # Replace original assembly source files with NaClized source files.
      sources = vars.get_sources()
      asm_sources = [source for source in sources
                     if os.path.splitext(source)[1] == '.S']
      for source in asm_sources:
        sources.remove(source)

      # Use C implementation instead of some assembly source files that
      # can not be converted easily.
      asm_sources = [source for source in asm_sources
                     if os.path.basename(source) not in [
                         'floatdidf.S', 'floatdisf.S', 'floatdixf.S',
                         'floatundidf.S', 'floatundisf.S', 'floatundixf.S']]
      sources.extend([
          'android/external/compiler-rt/lib/builtins/floatdidf.c',
          'android/external/compiler-rt/lib/builtins/floatdisf.c',
          'android/external/compiler-rt/lib/builtins/floatdixf.c',
          'android/external/compiler-rt/lib/builtins/floatundidf.c',
          'android/external/compiler-rt/lib/builtins/floatundisf.c',
          'android/external/compiler-rt/lib/builtins/floatundixf.c'])

      # Assembly files need to include ../assembly.h that is relative path
      # from the original directory. Add the directory as an include path.
      asm_path = os.path.dirname(asm_sources[0])
      vars.get_asmflags().append('-I' + staging.as_staging(asm_path))

      n = ninja_generator.NaClizeNinjaGenerator('compier-rt')
      generated_file_list = n.generate(asm_sources)

      # Add generated files to the source file list.
      sources.extend(generated_file_list)

    return True
Example #31
0
def _generate_gtest_ninja(name, instances=0, enable_libcxx=False, host=False):
    n = ninja_generator.ArchiveNinjaGenerator(
        name,
        base_path='android/external/chromium_org/testing/gtest/src',
        instances=instances,
        force_compiler='clang',
        enable_cxx11=True,
        enable_libcxx=enable_libcxx,
        host=host)
    n.add_include_paths(
        staging.as_staging('android/external/chromium_org/testing/gtest'))
    # To avoid "private field 'pretty_' is not used" on clang.
    n.add_compiler_flags('-Wno-unused-private-field')
    n.build_default(['gtest-all.cc']).archive()
Example #32
0
  def _filter(vars):
    module_name = vars.get_module_name()
    if module_name != 'webview_library':
      return False

    # LOCAL_JARJAR_RULES should be defined as $(LOCAL_PATH)/jarjar-rules.txt.
    # But, webviewchromium defines it as $(CHROMIUM_PATH) relative, and
    # $(CHROMIUM_PATH) is 'external/chromium_org'. As a result, ARC cannot
    # handle the file path for LOCAL_JARJAR_RULES correctly.
    # ARC manually fixes the path with 'android' prefix, and converts it to
    # a staging path.
    vars._jarjar_rules = staging.as_staging(
        os.path.join('android', vars._jarjar_rules))
    return True
Example #33
0
def generate_ninjas():
    if open_source.is_open_source_repo():
        # Provide a stub.
        n = ninja_generator.SharedObjectNinjaGenerator('libui')
        n.add_notice_sources([staging.as_staging('src/NOTICE')])
        n.link()
        return

    n = ninja_generator.SharedObjectNinjaGenerator(
        'libui', base_path='android/frameworks/native/libs/ui')
    n.add_include_paths('android/system/core/libsync/include')
    n.add_library_deps('libcutils.so', 'libhardware.so', 'liblog.so',
                       'libsync.so', 'libutils.so')
    n.build_default_all_sources()
    n.link()
Example #34
0
 def _start_emacsclient_jdb(self):
     source_paths = []
     for path in _JAVA_SOURCE_PATHS:
         source_paths.extend([
             staging.as_staging(path),
             # Add the real paths too to let emacs know these paths too are
             # candidates for setting breakpoints etc.
             os.path.join('./mods', path),
             os.path.join('./third_party', path),
         ])
     command = [
         'emacsclient', '-e',
         '(jdb "jdb -attach localhost:{port} -sourcepath{path}")'.format(
             port=self._jdb_port, path=':'.join(source_paths))
     ]
     subprocess.Popen(command)
Example #35
0
 def _start_emacsclient_jdb(self):
   source_paths = []
   for path in _JAVA_SOURCE_PATHS:
     source_paths.extend([
         staging.as_staging(path),
         # Add the real paths too to let emacs know these paths too are
         # candidates for setting breakpoints etc.
         os.path.join('./mods', path),
         os.path.join('./third_party', path),
     ])
   command = [
       'emacsclient', '-e',
       '(jdb "jdb -attach localhost:{port} -sourcepath{path}")'.format(
           port=self._jdb_port,
           path=':'.join(source_paths))]
   subprocess.Popen(command)
Example #36
0
 def _filter(vars):
   if vars.is_host() or vars.is_static():
     return False
   if vars.is_prebuilt():
     vars.set_prebuilt_install_to_root_dir(True)
     return not vars.is_prebuilt_for_host()
   # ICU uses RTTI. Note that we originally tried to handle this flag via
   # LOCAL_RTTI_FLAG in the constructor of MakeVars, but it turned out to be
   # difficult as -frtti is removed later in _remove_feature_flags().
   vars.get_cxxflags().append('-frtti')
   # In order to get RTTI working, the right typeinfo header must be included
   # to make gcc happy. Apparently, type_info definition in bionic libstdc++ is
   # not complete enough and it complains.
   vars.get_cxxflags().append(
       '-I' + staging.as_staging('android/abi/cpp/include'))
   return True
Example #37
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)
Example #38
0
def _generate_chromium_ppapi_fpabi_shim_ninja():
    if not build_common.use_ppapi_fpabi_shim():
        return
    ninja_name = "libppapi_fpabi_shim"
    n = ninja_generator.NinjaGenerator(ninja_name)
    rule_name = "gen_" + ninja_name

    ppapi_dir = staging.as_staging("chromium-ppapi/ppapi")
    script_path = os.path.join(ppapi_dir, "gen_ppapi_fpabi_shim.py")
    api_dir = os.path.join(ppapi_dir, "api")
    out_file = os.path.join(build_common.get_ppapi_fpabi_shim_dir(), "ppapi_fpabi_shim.c")
    gen_command = [
        "src/build/run_python",
        pipes.quote(script_path),
        "--wnone",
        "--fpabi",
        "--fpabishim",
        "$out.tmp",
        "--range=start,end",
        "--srcroot",
        pipes.quote(api_dir),
        ">",
        "$out.log",
        "|| (cat $out.log; rm $out.log; exit 1)",
    ]
    # On success, touch the output file. The generator does not update the file
    # if the output content is same. In such a case, without this touch, if the
    # script is updated (by such as repository sync), the script timestamp gets
    # newer than the generated code, so that ninja always re-runs the script
    # generation and later phases.
    n.rule(
        rule_name,
        command=(
            "("
            + " ".join(gen_command)
            + ")"
            + " && touch $out.tmp && mv $out.tmp $out"
            + ' && printf "%s: %s" $out "$in" > $out.d'
        ),
        depfile="$out.d",
        description=rule_name + " $out",
    )

    idls = n.find_all_files(api_dir, ".idl", use_staging=False)
    n.build(out_file, rule_name, idls, implicit=[script_path, "src/build/run_python"])
Example #39
0
def generate_ninjas():
  if open_source.is_open_source_repo():
    # Provide a stub.
    n = ninja_generator.SharedObjectNinjaGenerator('libui')
    n.add_notice_sources([staging.as_staging('src/NOTICE')])
    n.link()
    return

  n = ninja_generator.SharedObjectNinjaGenerator(
      'libui', base_path='android/frameworks/native/libs/ui')
  n.add_include_paths('android/system/core/libsync/include')
  n.add_library_deps(
      'libcutils.so',
      'libhardware.so',
      'liblog.so',
      'libsync.so',
      'libutils.so')
  n.build_default_all_sources()
  n.link()
Example #40
0
def _generate_libposix_translation_for_test():
  n = ninja_generator.SharedObjectNinjaGenerator(
      'libposix_translation_for_test',
      dt_soname='libposix_translation.so',
      is_system_library=True,
      is_for_test=True)
  # libposix_translation_for_test is built using generated code in the out/
  # directory. The logic we have to scan for NOTICES does not find one for this
  # generated code, and complains later. The libposix_translation.so code
  # normally inherits the project NOTICE from src/NOTICE, so we just explicitly
  # point to it here as the notice to use for this special version of the
  # library.
  n.add_notice_sources([staging.as_staging('src/NOTICE')])
  gen_rule_name = 'gen_wrap_syscall_aliases_s'
  gen_script_path = os.path.join('src/common', gen_rule_name + '.py')
  n.rule(gen_rule_name,
         command='%s > $out.tmp && mv $out.tmp $out' % gen_script_path,
         description=gen_rule_name + ' $in')
  gen_out_path = os.path.join(build_common.get_build_dir(),
                              'posix_translation_gen_sources',
                              'wrap_syscall_aliases.S')
  gen_implicit_deps = python_deps.find_deps(gen_script_path)
  n.build(gen_out_path, gen_rule_name, implicit=gen_implicit_deps)
  # Following deps order is important. art_libc_supplement_for_test.so should
  # be placed before libc.so.
  if not open_source.is_open_source_repo():
    # This is for ART unit tests which have not been opensourced. To not let
    # posix_translation depend on ART on arc_open, use is_open_source_repo().
    n.add_library_deps('art_libc_supplement_for_test.so')
  n.add_library_deps('libc.so', 'libdl.so')
  n.build_default([gen_out_path], base_path=None).link()

  # /test/libposix_translation.so should be a symbolic link to
  # ../lib/libposix_translation_for_test.so.
  n = ninja_generator.NinjaGenerator('test_libposix_translation')
  orig_so = os.path.join(
      build_common.get_load_library_path(), 'libposix_translation_for_test.so')
  link_so = os.path.join(
      build_common.get_load_library_path_for_test(), 'libposix_translation.so')
  command = 'ln -sf %s %s' % (
      os.path.join('../../lib/', os.path.basename(orig_so)), link_so)
  n.build(link_so, 'run_shell_command', implicit=orig_so,
          variables={'command': command})
Example #41
0
def generate_ninjas():
    if open_source.is_open_source_repo():
        # Provide a stub.
        n = ninja_generator.SharedObjectNinjaGenerator('libskia')
        n.add_notice_sources([staging.as_staging('src/NOTICE')])
        n.link()
        return

    def _filter(vars):
        if vars.is_executable():
            return False
        if vars.get_module_name() == 'libskia':
            if not OPTIONS.is_optimized_build():
                # Enable basic optimizations for SKIA as it otherwise fails as it
                # refers to unimplemented FT_Get_FSType_Flags. For some reason using
                # -ffunction-sections with --gc-sections did not solve the problem
                # here.
                vars.get_cflags().append('-O1')
            vars.get_shared_deps().append('libcompiler_rt')
        return True

    make_to_ninja.MakefileNinjaTranslator('android/external/skia').generate(
        _filter)
Example #42
0
def generate_ninjas():
  if open_source.is_open_source_repo():
    # Provide a stub.
    n = ninja_generator.SharedObjectNinjaGenerator('libskia')
    n.add_notice_sources([staging.as_staging('src/NOTICE')])
    n.link()
    return

  def _filter(vars):
    if vars.is_executable():
      return False
    if vars.get_module_name() == 'libskia':
      if not OPTIONS.is_optimized_build():
        # Enable basic optimizations for SKIA as it otherwise fails as it
        # refers to unimplemented FT_Get_FSType_Flags. For some reason using
        # -ffunction-sections with --gc-sections did not solve the problem
        # here.
        vars.get_cflags().append('-O1')
      vars.get_shared_deps().append('libcompiler_rt')
    return True

  make_to_ninja.MakefileNinjaTranslator(
      'android/external/skia').generate(_filter)
Example #43
0
def _generate_chromium_ppapi_fpabi_shim_ninja():
    if not build_common.use_ppapi_fpabi_shim():
        return
    ninja_name = 'libppapi_fpabi_shim'
    n = ninja_generator.NinjaGenerator(ninja_name)
    rule_name = 'gen_' + ninja_name

    ppapi_dir = staging.as_staging('chromium-ppapi/ppapi')
    script_path = os.path.join(ppapi_dir, 'gen_ppapi_fpabi_shim.py')
    api_dir = os.path.join(ppapi_dir, 'api')
    out_file = os.path.join(build_common.get_ppapi_fpabi_shim_dir(),
                            'ppapi_fpabi_shim.c')
    gen_command = [
        'src/build/run_python',
        pipes.quote(script_path), '--wnone', '--fpabi', '--fpabishim',
        '$out.tmp', '--range=start,end', '--srcroot',
        pipes.quote(api_dir), '>', '$out.log',
        '|| (cat $out.log; rm $out.log; exit 1)'
    ]
    # On success, touch the output file. The generator does not update the file
    # if the output content is same. In such a case, without this touch, if the
    # script is updated (by such as repository sync), the script timestamp gets
    # newer than the generated code, so that ninja always re-runs the script
    # generation and later phases.
    n.rule(rule_name,
           command=('(' + ' '.join(gen_command) + ')' +
                    ' && touch $out.tmp && mv $out.tmp $out' +
                    ' && printf "%s: %s" $out "$in" > $out.d'),
           depfile='$out.d',
           description=rule_name + ' $out')

    idls = n.find_all_files(api_dir, '.idl', use_staging=False)
    n.build(out_file,
            rule_name,
            idls,
            implicit=[script_path, 'src/build/run_python'])
Example #44
0
def _generate_libppapi_mocks():
    ppapi_dir = staging.as_staging('chromium-ppapi/ppapi')
    api_dir = os.path.join(ppapi_dir, 'api')
    out_dir = os.path.join(
        ninja_generator.PpapiTestNinjaGenerator.get_ppapi_mocks_generated_dir(
        ), 'ppapi_mocks')
    stamp_file = os.path.join(out_dir, 'STAMP')

    # Generate PPAPI mock sources from IDL files.
    rule_name = 'gen_ppapi_mock'
    n = ninja_generator.PythonNinjaGenerator(rule_name)
    script_path = os.path.join(_MY_DIR, 'gen_ppapi_mock.py')
    args = [
        '--wnone',  # Suppress all warnings.
        '--range=start,end',  # Generate code for all revisions.
        '--ppapicgen',  # Generate PpapiMock source files.
        '--ppapihgen',  # Generate PpapiMock header files.
        '--srcroot',
        api_dir,
        '--dstroot',
        out_dir
    ]
    n.emit_python_rule(rule_name,
                       script_path,
                       args,
                       extra_command='&& touch $stamp')

    generated_files = []
    idl_list = n.find_all_files('chromium-ppapi/ppapi/api', '.idl')
    for idl_path in idl_list:
        if 'finish_writing_these' in idl_path:
            # Files under ppapi/api/private/finish_writing_these/ directory are not
            # found by the parser of the idl generator library.
            continue
        path_stem = os.path.splitext(os.path.basename(idl_path))[0]
        # We are interested in only PPB files.
        if not path_stem.startswith('ppb_'):
            continue
        generated_files.append(os.path.join(out_dir, path_stem + '.cc'))
        generated_files.append(os.path.join(out_dir, path_stem + '.h'))

    n.run_python(generated_files + [stamp_file],
                 rule_name,
                 variables={'stamp': pipes.quote(stamp_file)},
                 implicit=map(staging.as_staging, idl_list))

    # Build libppapi_mocks. libart-gtest depends on libppapi_mocks.
    n = ninja_generator.ArchiveNinjaGenerator('libppapi_mocks',
                                              instances=0,
                                              force_compiler='clang',
                                              enable_cxx11=True)
    n.add_ppapi_compile_flags()
    n.add_libchromium_base_compile_flags()
    n.add_include_paths(
        staging.as_staging('testing/gmock/include'), _MY_DIR,
        ninja_generator.PpapiTestNinjaGenerator.get_ppapi_mocks_generated_dir(
        ))

    n.build_default([path
                     for path in generated_files if path.endswith('.cc')] +
                    n.find_all_files([_MY_DIR], '.cc', include_tests=True),
                    implicit=[stamp_file])
    n.archive()
Example #45
0
def generate_ninjas():
  if open_source.is_open_source_repo():
    # Provide a stub.
    n = ninja_generator.SharedObjectNinjaGenerator('libandroid_runtime')
    n.add_notice_sources([staging.as_staging('src/NOTICE')])
    n.link()
    return

  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
  path = 'android/frameworks/base/core/jni'
  make_to_ninja.MakefileNinjaTranslator(path).generate(_filter)
Example #46
0
def generate_ninjas():
    if open_source.is_open_source_repo():
        # Provide a stub.
        n = ninja_generator.SharedObjectNinjaGenerator('libandroid')
        n.add_notice_sources([staging.as_staging('src/NOTICE')])
        n.link()
Example #47
0
def generate_ninjas():
    if open_source.is_open_source_repo():
        # Provide a stub.
        n = ninja_generator.SharedObjectNinjaGenerator('libandroid_runtime')
        n.add_notice_sources([staging.as_staging('src/NOTICE')])
        n.link()
        return

    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

    path = 'android/frameworks/base/core/jni'
    make_to_ninja.MakefileNinjaTranslator(path).generate(_filter)
Example #48
0
 def test_as_staging(self):
   self.assertEquals('out/staging/android/frameworks/base',
                     staging.as_staging('android/frameworks/base'))
   self.assertEquals('out/staging/src/common',
                     staging.as_staging('src/common'))
Example #49
0
 def get_source_root():
   """Returns the root directory of ART test source files."""
   return staging.as_staging('android/art/test')
Example #50
0
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os

from src.build import make_to_ninja
from src.build import ninja_generator
from src.build import staging
from src.build import toolchain
from src.build.build_options import OPTIONS

_ADS2GAS = staging.as_staging(
    'android/external/libvpx/libvpx/build/make/ads2gas.pl')
_GEN_LIBVPX_ASM_RULE = 'gen_libvpx_asm'
_GEN_LIBVPX_OFFSETS_ASM_RULE = 'gen_libvpx_offsets_asm'


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
Example #51
0
 def test_as_staging(self):
     self.assertEquals('out/staging/android/frameworks/base',
                       staging.as_staging('android/frameworks/base'))
     self.assertEquals('out/staging/src/common',
                       staging.as_staging('src/common'))
Example #52
0
class Notices(object):
    """Class that keeps track of Android-style notice and license files.

  Notice files are named NOTICE and have the text of notices in them.  These
  notices are required to be shown in the final product for proper compliance.
  License files are named MODULE_LICENSE_* and their existence demarks a
  directory tree published under the given license."""
    _license_kinds = {}
    # Maps from (relative directory path, file spec) to path that contains
    # that file or None if no parent does.
    _parent_cache = {}

    KIND_PUBLIC_DOMAIN = 'public domain'
    KIND_NOTICE = 'notice'
    KIND_OPEN_SOURCE_REQUIRED = 'requires open source'
    KIND_LGPL_LIKE = 'lgpl-like'
    KIND_GPL_LIKE = 'gpl-like'
    KIND_TODO = 'todo'
    KIND_UNKNOWN = 'unknown'
    KIND_DEFAULT = KIND_NOTICE

    _PER_FILE_LICENSE_KINDS = dict([
        # This file has a modified GPL license header indicating it can be
        # part of a binary distribution without disclosing all sources..
        (staging.as_staging('android/external/gcc-demangle/cp-demangle.c'),
         KIND_NOTICE),
        # TODO(crbug.com/380032): Once we can add licensing information
        # directly in the directory itself, we can remove these per-file
        # license hacks.
        ('third_party/chromium-ppapi/base/atomicops_internals_gcc.h',
         KIND_PUBLIC_DOMAIN),
        # event-log-tags is generated by filtering a file created by an
        # Apache2-licensed script.
        ('canned/target/android/generated/event-log-tags', KIND_NOTICE)
    ])

    # Provide a partial ordering of all license kinds based on how
    # "restrictive" they are.  On one end a public domain (non-)license
    # indicates not even a notice of the software is required.  On the other
    # end, GPL licensing requires everything in the process to be open
    # sourced.
    _KIND_RESTRICTIVENESS = {
        KIND_UNKNOWN: 5,
        KIND_TODO: 5,
        KIND_GPL_LIKE: 4,
        KIND_LGPL_LIKE: 3,
        KIND_OPEN_SOURCE_REQUIRED: 2,
        KIND_NOTICE: 1,
        KIND_PUBLIC_DOMAIN: 0
    }

    def __init__(self):
        self._license_roots = set()
        # Map from a license root to an example file that required it.  This is
        # helpful for diagnosing licensing violation errors.
        self._license_roots_examples = {}
        self._notice_roots = set()

    def _find_parent_file(self, start_path, filespec):
        """Find a file in start_path or a parent matching filespec.

    This function is purposefully not staging aware.  It will only look in
    the actual file system path provided."""
        if start_path == '':
            return None
        if (start_path, filespec) in self._parent_cache:
            return self._parent_cache[start_path, filespec]
        if (('*' in filespec and glob.glob(os.path.join(start_path, filespec)))
                or os.path.exists(os.path.join(start_path, filespec))):
            self._parent_cache[start_path, filespec] = start_path
            return start_path
        parent_result = self._find_parent_file(os.path.dirname(start_path),
                                               filespec)
        self._parent_cache[start_path, filespec] = parent_result
        return parent_result

    def add_sources(self, files):
        for f in files:
            if os.path.isabs(f):
                f = os.path.relpath(f, build_common.get_arc_root())
            notice_root = self._find_parent_file(os.path.dirname(f), 'NOTICE')
            if notice_root:
                self._notice_roots.add(notice_root)
            if f in self._PER_FILE_LICENSE_KINDS:
                license_root = f
            else:
                license_root = self._find_parent_file(os.path.dirname(f),
                                                      'MODULE_LICENSE_*')
            if license_root:
                if license_root not in self._license_roots:
                    self._license_roots.add(license_root)
                    self._license_roots_examples[license_root] = f

    def has_proper_metadata(self):
        return bool(self._notice_roots) or bool(self._license_roots)

    @staticmethod
    def _get_license_kind_by_path(path):
        license_file = os.path.basename(path)
        if license_file.startswith('MODULE_LICENSE_'):
            license = '_'.join(license_file.split('_')[2:])
            if license in ['GPL']:
                return Notices.KIND_GPL_LIKE
            if license in ['LGPL']:
                return Notices.KIND_LGPL_LIKE
            if license in ['CCSA', 'CPL', 'FRAUNHOFER', 'MPL']:
                return Notices.KIND_OPEN_SOURCE_REQUIRED
            # If the author lets us choose between a notice and more restrictive
            # license, we pick notice.
            if license in [
                    'APACHE2', 'BSD', 'BSD_LIKE', 'BSD_OR_LGPL', 'MIT', 'W3C'
            ]:
                return Notices.KIND_NOTICE
            if license == 'TODO':
                return Notices.KIND_TODO
            if license == 'PUBLIC_DOMAIN':
                return Notices.KIND_PUBLIC_DOMAIN
        else:
            raise Exception('Wrong file passed: %s' % path)
        # If we do not recognize it, assume the worst.
        print 'WARNING: Unrecognized license: ' + path
        return Notices.KIND_UNKNOWN

    @staticmethod
    def is_more_restrictive(a, b):
        return Notices._KIND_RESTRICTIVENESS[
            a] > Notices._KIND_RESTRICTIVENESS[b]

    @staticmethod
    def get_license_kind(path):
        if path not in Notices._license_kinds:
            license_filenames = glob.glob(
                os.path.join(path, 'MODULE_LICENSE_*'))
            most_restrictive = None
            for license_filename in license_filenames:
                kind = Notices._get_license_kind_by_path(license_filename)
                if (not most_restrictive or Notices.is_more_restrictive(
                        kind, most_restrictive)):
                    most_restrictive = kind
            if path in Notices._PER_FILE_LICENSE_KINDS:
                Notices._license_kinds[path] = Notices._PER_FILE_LICENSE_KINDS[
                    path]
            elif most_restrictive is None:
                Notices._license_kinds[path] = Notices.KIND_DEFAULT
            else:
                Notices._license_kinds[path] = most_restrictive
        return Notices._license_kinds[path]

    def get_most_restrictive_license_kind(self):
        most_restrictive = Notices.KIND_PUBLIC_DOMAIN
        for p in self._license_roots:
            kind = self.get_license_kind(p)
            if Notices.is_more_restrictive(kind, most_restrictive):
                most_restrictive = kind
        return most_restrictive

    def has_lgpl_or_gpl(self):
        return Notices.is_more_restrictive(
            self.get_most_restrictive_license_kind(),
            Notices.KIND_OPEN_SOURCE_REQUIRED)

    def does_license_force_source_with_binary_distribution(self, path):
        return self.is_more_restrictive(self.get_license_kind(path),
                                        self.KIND_NOTICE)

    def get_gpl_roots(self):
        return [
            p for p in sorted(self._license_roots)
            if self.get_license_kind(p) == Notices.KIND_GPL_LIKE
        ]

    def get_source_required_roots(self):
        source_required_roots = set([
            p for p in sorted(self._license_roots)
            if self.does_license_force_source_with_binary_distribution(p)
        ])
        return source_required_roots

    def get_source_required_examples(self):
        return [
            self.get_license_root_example(r)
            for r in self.get_source_required_roots()
        ]

    def add_notices(self, notices):
        self._license_roots.update(notices._license_roots)
        self._license_roots_examples.update(notices._license_roots_examples)
        self._notice_roots.update(notices._notice_roots)

    def get_notice_roots(self):
        return self._notice_roots

    def get_license_roots(self):
        return self._license_roots

    def get_license_root_example(self, root):
        return self._license_roots_examples[root]

    def get_notice_files(self):
        notice_files = set()
        for p in self._notice_roots:
            notice_file = os.path.join(p, 'NOTICE')
            if os.path.exists(notice_file):
                notice_files.add(notice_file)
        return notice_files

    def __repr__(self):
        output = ['notice.Notices object:']
        output.append('  notices: ' + ', '.join(self.get_notice_files()))
        for r in self.get_license_roots():
            output.append('  License kind "%s" in %s: example file %s' %
                          (Notices.get_license_kind(r), r,
                           self.get_license_root_example(r)))
        return '\n'.join(output)
Example #53
0
def generate_ninjas():
  if open_source.is_open_source_repo():
    # Provide a stub.
    n = ninja_generator.SharedObjectNinjaGenerator('libandroid')
    n.add_notice_sources([staging.as_staging('src/NOTICE')])
    n.link()
Example #54
0
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os

from src.build import make_to_ninja
from src.build import ninja_generator
from src.build import staging
from src.build import toolchain
from src.build.build_options import OPTIONS

_ADS2GAS = staging.as_staging(
    'android/external/libvpx/libvpx/build/make/ads2gas.pl')
_GEN_LIBVPX_ASM_RULE = 'gen_libvpx_asm'
_GEN_LIBVPX_OFFSETS_ASM_RULE = 'gen_libvpx_offsets_asm'


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