Пример #1
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()
Пример #2
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()
Пример #3
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()
Пример #4
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})
Пример #5
0
def _generate_so_ninja():
    n = ninja_generator.SharedObjectNinjaGenerator(
        'gralloc.arc',
        install_path='/lib/hw',
        force_compiler='clang',
        enable_cxx11=True,
        base_path='graphics_translation/gralloc')

    # gralloc_main.cpp uses gcc-style struct initialization "member: value"
    # which clang warns by default. We cannot switch to the C++11 style
    # ".member = value" yet as some of our compilers do not support it.
    # TODO(crbug.com/365178): Switch to ".member = value" style and remove
    # -Wno-gnu-designator.
    n.add_compiler_flags('-Werror', '-Wno-gnu-designator')

    n.add_notice_sources(['mods/graphics_translation/NOTICE'])
    n.emit_framework_common_flags()
    n.add_include_paths('mods')
    sources = ['graphics_translation/gralloc/gralloc_main.cpp']
    n.build_default(sources, base_path='mods')
    n.link()
Пример #6
0
def _generate_libposix_translation():
  compiler_flags = [
      '-Werror', '-fvisibility=hidden', '-fvisibility-inlines-hidden']

  n = ninja_generator.ArchiveNinjaGenerator(
      'libposix_translation_static',
      # libart-gtest and libposix_translation need this
      force_compiler='clang',
      enable_cxx11=True)
  n.add_compiler_flags(*compiler_flags)
  if OPTIONS.is_posix_translation_debug():
    n.add_defines('DEBUG_POSIX_TRANSLATION')
  if OPTIONS.use_verbose_memory_viewer():
    n.add_defines('USE_VERBOSE_MEMORY_VIEWER')
  # For functions in chromium_org/base/ and private headers in ppapi/.
  # TODO(crbug.com/234789): Use public API so that we can depend on
  # nacl_pepper_path instead.
  n.add_ppapi_compile_flags()
  n.add_libchromium_base_compile_flags()
  all_files = build_common.find_all_files(['src/posix_translation'],
                                          ['.cc'])
  n.build_default(all_files).archive()

  n = ninja_generator.SharedObjectNinjaGenerator(
      'libposix_translation',
      is_system_library=True,
      force_compiler='clang',
      enable_cxx11=True)
  n.add_library_deps('libc.so', 'libm.so', 'libdl.so', 'libstlport.so')
  n.add_whole_archive_deps('libposix_translation_static.a')
  # Statically link libchromium_base.a so that we can use unwrapped version of
  # the library.
  # TODO(crbug.com/423063, crbug.com/336316): Statically link libcommon.a into
  # the DSO too for more safety.
  n.add_library_deps('libchromium_base.a')
  n.add_compiler_flags(*compiler_flags)
  n.add_ppapi_link_flags()
  n.build_default([]).link()
Пример #7
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)
Пример #8
0
def generate_ninjas():
    n = ninja_generator.SharedObjectNinjaGenerator(
        'hwcomposer.default',
        install_path='/lib/hw',
        force_compiler='clang',
        enable_cxx11=True,
        base_path='android/hardware/arc/hwcomposer')

    # hwcomposer.cpp uses gcc-style struct initialization "member: value"
    # which clang warns by default. We cannot switch to the C++11 style
    # ".member = value" yet as some of our compilers do not support it.
    # TODO(crbug.com/365178): Switch to ".member = value" style and remove
    # -Wno-gnu-designator.
    n.add_compiler_flags('-Werror', '-Wno-gnu-designator')
    n.emit_framework_common_flags()
    n.add_compiler_flags('-Wno-unused-variable', '-Wno-unused-function',
                         '-Werror')
    n.add_notice_sources(['mods/graphics_translation/NOTICE'])
    n.add_include_paths('mods/graphics_translation')
    sources = ['graphics_translation/hwcomposer/hwcomposer.cpp']
    n.build_default(sources, base_path='mods')
    n.add_library_deps('libcutils.so')
    n.link()
Пример #9
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()
Пример #10
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)