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

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

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

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

        return True

    make_to_ninja.MakefileNinjaTranslator('android/external/libcxx').generate(
        _filter)
Ejemplo n.º 2
0
def _generate_libcpufeatures_ninja():
  def _filter(vars):
    # -fstack-protector emits undefined symbols.
    if not OPTIONS.is_bare_metal_build():
      vars.get_cflags().append('-fno-stack-protector')
    return True
  path = 'android/ndk/sources/android/cpufeatures'
  make_to_ninja.MakefileNinjaTranslator(path).generate(_filter)
Ejemplo n.º 3
0
def generate_ninjas():
  def _filter(vars):
    if vars.get_module_name() not in ('libjpeg', 'libjpeg_static'):
      return False
    if OPTIONS.is_x86():
      # Adding this flag should be safe for all x86 Chromebooks.
      vars.get_cflags().append('-msse2')
    return True
  make_to_ninja.MakefileNinjaTranslator(
      'android/external/jpeg').generate(_filter)
Ejemplo n.º 4
0
def generate_ninjas():
    def _filter(vars):
        # -fexceptions and -frtti are defined in Android.mk, but automatically
        # removed by MakefileNinjaGenerator. Redefine them here.
        vars.get_cxxflags().extend(['-fexceptions', '-frtti'])
        # libc++ and libpdfium depend on libc++abi.
        vars.set_instances_count(2)
        return True

    make_to_ninja.MakefileNinjaTranslator(
        'android/external/libcxxabi').generate(_filter)
Ejemplo n.º 5
0
def generate_ninjas():
    gen_asm_ninja = _get_generate_libvpx_asm_ninja()

    def _filter(vars):
        if vars.get_module_name() not in ['libvpx', 'libwebm']:
            return False
        if vars.get_module_name() == 'libvpx':
            return _filter_libvpx(vars, gen_asm_ninja)
        return True

    make_to_ninja.MakefileNinjaTranslator('android/external/libvpx').generate(
        _filter)
Ejemplo n.º 6
0
def _generate_chromium_org_ninja(group):
  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)

  # Split Android.mk to multiple build groups since it takes 40 seconds to
  # run in a single step.
  # See mods/android/external/chromium_org/GypAndroid.linux-{arm|x86(_64)}.mk.
  make_to_ninja.MakefileNinjaTranslator(
      'android/external/chromium_org',
      extra_env_vars={'CHROMIUM_ORG_BUILD_GROUP': group}).generate(_filter)
Ejemplo n.º 7
0
def _generate_gcc_demangle_ninja():
  def _filter(vars):
    if vars.is_host():
      return False
    if vars.is_executable():
      return False
    # libgccdemangle_static is used in tests, libgccdemangle everyhwere else.
    if vars.get_module_name() == 'libgccdemangle' and vars.is_static():
      vars.set_module_name('libgccdemangle_static')
      # Only used in tests.
      vars.set_instances_count(0)
    return True
  make_to_ninja.MakefileNinjaTranslator(
      'android/external/gcc-demangle').generate(_filter)
Ejemplo n.º 8
0
def generate_ninjas():
    def _filter(vars):
        if vars.is_executable():
            return False
        if vars.get_module_name() == 'lib64cutils':
            assert vars.is_host()
            return False
        assert vars.get_module_name() == 'libcutils'

        if vars.is_host():
            # On host, we build libcutils.a only.
            assert vars.is_static()
        else:
            # On target, we build both libutils_static.a and libutils.so.
            # libutils_static.a is linked to unit tests.
            if vars.is_static():
                vars.set_module_name(vars.get_module_name() + '_static')

        if vars.is_target() and vars.is_shared():
            # libcutils.so links liblog.a because some legacy Android prebuilt
            # binaries expect liblog symbols in libcutils.so. It is not the case
            # with ARC, so do not static link liblog.a. See Android.mk for details.
            vars.get_whole_archive_deps().remove('liblog')

        # TODO(crbug.com/163446): Get the assembly working with nacl.
        src = vars.get_sources()
        # Not usable/compilable in ARC.
        if vars.is_shared():
            deps = vars.get_whole_archive_deps()
            deps.remove('libcutils')
            deps.append('libcutils_static')
        else:
            if not vars.is_host():
                src.remove('android/system/core/libcutils/android_reboot.c')
            src.remove('android/system/core/libcutils/iosched_policy.c')

        # TODO(crbug.com/462555): L-rebase: enable assembly implementation.
        # Use C implementation in memory.c for NaCl.
        if OPTIONS.is_nacl_build():
            vars.remove_c_or_cxxflag('-DHAVE_MEMSET16')
            vars.remove_c_or_cxxflag('-DHAVE_MEMSET32')
            src[:] = [x for x in src if not x.endswith('.S')]
        return True

    make_to_ninja.MakefileNinjaTranslator(
        'android/system/core/libcutils').generate(_filter)
Ejemplo n.º 9
0
def generate_ninjas():
    def _filter(vars):
        if vars.is_static():
            if vars.is_host():
                return False
            vars.set_module_name(vars.get_module_name() + '_static')
            # The static version of libunwind is only used in tests.
            vars.set_instances_count(0)

        return {
            'libunwind': _filter_libunwind,
            'libunwind_static': _filter_libunwind,
            'libunwind-ptrace': _filter_libunwind_ptrace,
        }.get(vars.get_module_name(), lambda vars: False)(vars)

    make_to_ninja.MakefileNinjaTranslator(
        'android/external/libunwind').generate(_filter)
Ejemplo n.º 10
0
def generate_ninjas():
    def _filter(vars):
        if vars.get_module_name() != 'liblog':
            # Only build liblog
            return False

        # We cannot build both static and shared versions of a library with the
        # same name, so add the '_static' suffix to the static library.
        if vars.is_static():
            vars.set_module_name('liblog_static')
        else:
            vars.get_whole_archive_deps().remove('liblog')
            vars.get_whole_archive_deps().append('liblog_static')

        return True

    make_to_ninja.MakefileNinjaTranslator(
        'android/system/core/liblog').generate(_filter)
Ejemplo n.º 11
0
def _generate_webview_ninja():
  def _filter(vars):
    # TODO(crbug.com/390856): Build Java libraries from source.
    if vars.is_java_library() or vars.is_package():
      return False
    # WebViewShell is a simple APK that loads a webview, not needed for ARC.
    # UbWebViewJankTests is only a test, not needed for ARC.
    skip = ['WebViewShell', 'UbWebViewJankTests', 'webview-janktesthelper']
    if vars.get_module_name() in skip:
      return False
    vars.enable_clang()
    vars.enable_cxx11()
    return True

  env = {
      'res_overrides': '',
      'version_build_number': '',
      'R_file_stamp': ''}
  make_to_ninja.MakefileNinjaTranslator(
      'android/frameworks/webview', extra_env_vars=env).generate(_filter)
Ejemplo n.º 12
0
def generate_ninjas():
    def _filter(vars):
        assert vars.is_java_library()
        if vars.is_static_java_library() or vars.is_host():
            return False

        return {
            'core-junit': True,
            'junit-runner': False,
            # TODO(crbug.com/468670): L-rebase: junit-targetdex exercises our dexopt
            # compile paths, which are disabled until we find how to do dex2oat in
            # ninja time.
            'junit-targetdex': False,
        }[vars.get_module_name()]

    if open_source.is_open_source_repo():
        # We currently do not build Java code in open source.
        return
    make_to_ninja.MakefileNinjaTranslator('android/external/junit').generate(
        _filter)
Ejemplo n.º 13
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)
Ejemplo n.º 14
0
def generate_ninjas():
    def _filter(vars):
        # Android uses two different C++ libraries: bionic's libstdc++ (instead of
        # GCC's libstdc++) and clang's libc++ (only for ART and a few other
        # libraries). STLport does not have compiler dependent functions (functions
        # which are called from code generated by compiler), so use bionic's and
        # link it into libstlport.so for simplicity.
        vars.get_sources().extend([
            'android/bionic/libc/bionic/new.cpp',
            'android/bionic/libc/bionic/__cxa_guard.cpp',
            'android/bionic/libc/bionic/__cxa_pure_virtual.cpp',
            # Needed for __libc_fatal.
            'android/bionic/libc/bionic/libc_logging.cpp'
        ])
        vars.get_includes().append('android/bionic/libc')
        vars.get_includes().remove('android/bionic/libstdc++/include')
        vars.get_sys_includes().remove('android/bionic/libstdc++/include')
        # This is necessary to use atomic operations in bionic. 1 indicates
        # compilation for symmetric multi-processor (0 for uniprocessor).
        vars.get_cflags().append('-DANDROID_SMP=1')
        if vars.is_shared():
            # This is for not emitting syscall wrappers.
            vars.get_shared_deps().extend(['libc', 'libm'])
            # Note: libstlport.so must be a system library because other system
            # libraries such as libchromium_ppapi.so and libposix_translation.so
            # depend on it. We already have some ARC MODs against STLPort to make
            # it work without --wrap, and the cost of maintaining the MODs seems
            # very low because STLPort is not under active development anymore.
            vars.get_generator_args()['is_system_library'] = True
            # TODO(crbug.com/364344): Once Renderscript is built from source, this
            # canned install can be removed.
            if not OPTIONS.is_arm():
                vars.set_canned_arm(True)
        return True

    make_to_ninja.MakefileNinjaTranslator(_STLPORT_ROOT).generate(_filter)
Ejemplo n.º 15
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)
Ejemplo n.º 16
0
def generate_ninjas():
  def _filter(vars):
    return vars.is_shared()
  make_to_ninja.MakefileNinjaTranslator('android/abi/cpp').generate(_filter)