def _push_test_files(self, arc): """Pushes test files via ADB. This function mimics the test preparation task performed in android/art/test/etc/push-and-run-test-jar. Args: arc: SystemMode object. """ test_file = os.path.join(self._work_dir, '%s.jar' % self._suite_name) assert os.access(test_file, os.R_OK), ( 'can not read a test file %s' % test_file) arc.run_adb(['shell', 'mkdir', _TEST_FILES_LOCATION]) arc.run_adb(['push', test_file, _TEST_FILES_LOCATION]) test_ex_file = os.path.join(self._work_dir, '%s-ex.jar' % self._suite_name) if os.access(test_ex_file, os.R_OK): arc.run_adb(['push', test_ex_file, _TEST_FILES_LOCATION]) # Push shared libraries needed for ART integration tests but not installed # in the official runtime. We set LD_LIBRARY_PATH later to use them. arc.run_adb( ['push', build_common.get_build_path_for_library('libarttest.so'), _TEST_FILES_LOCATION]) arc.run_adb( ['push', build_common.get_build_path_for_library('libnativebridgetest.so'), _TEST_FILES_LOCATION])
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)])
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)])
def _generate_chromium_base_ninja_common(module_name, instances, enable_libcxx): base_path = 'android/external/chromium_org/base' # chromium_base is required by libart-gtest, libposix_translation, and the # plugin. n = ninja_generator.ArchiveNinjaGenerator( module_name, base_path=base_path, instances=instances, force_compiler='clang', enable_cxx11=True, enable_libcxx=enable_libcxx) n.add_compiler_flags('-fvisibility=hidden') # for libposix_translation.so _add_chromium_base_compiler_flags(n) def relevant(f): f = f.lstrip('android/external/chromium_org/') # Files with specific suffixes like '_linux' are usually excluded. # Here is the list of exceptions. whitelist = ['base/threading/platform_thread_linux.cc', 'base/threading/thread_local_android.cc', 'base/debug/stack_trace_android.cc', 'base/debug/trace_event_android.cc'] if f in whitelist: return True # Exclude cc files that do not compile with nacl-g++. Roughly speaking, # functions in the following categories do not compile/work: # - Functions that execute commands (e.g. *_xdg.cc). # - Functions that depends on file_util.h which is not (yet) available. excludes = [ 'base/allocator/generic_allocators.cc', 'base/async_socket_io_handler_posix.cc', 'base/base64.cc', 'base/base_paths.cc', 'base/base_paths_posix.cc', 'base/check_example.cc', 'base/cpu.cc', 'base/debug_message.cc', # This is excluded in the upstream, too. 'base/debug/stack_trace_posix.cc', 'base/debug/trace_event_system_stats_monitor.cc', # TODO(crbug.com/414569): L-rebase: Do I need it? 'base/memory/discardable_memory_ashmem.cc', 'base/memory/discardable_memory_ashmem_allocator.cc', 'base/files/file_enumerator_posix.cc', 'base/files/file_proxy.cc', 'base/files/file_path_watcher_fsevents.cc', # for Mac 'base/files/important_file_writer.cc', 'base/files/memory_mapped_file.cc', 'base/files/memory_mapped_file_posix.cc', 'base/files/scoped_temp_dir.cc', 'base/guid_posix.cc', 'base/json/json_file_value_serializer.cc', 'base/memory/discardable_memory.cc', 'base/memory/shared_memory_posix.cc', 'base/message_loop/message_pump_ozone.cc', 'base/message_loop/message_pump_x11.cc', 'base/nix/mime_util_xdg.cc', 'base/nix/xdg_util.cc', # This provides timegm implementation, but we use the one in bionic. 'base/os_compat_nacl.cc', 'base/path_service.cc', 'base/perftimer.cc', 'base/rand_util.cc', 'base/rand_util_nacl.cc', 'base/rand_util_posix.cc', 'base/sync_socket_posix.cc', 'base/third_party/dmg_fp/dtoa_wrapper.cc', 'base/threading/watchdog.cc', 'base/x11/edid_parser_x11.cc', 'base/x11/x11_error_tracker.cc'] if ((f in excludes) or # Exclude non-cc files. (not f.endswith('.cc') and not f.endswith('.c')) or # Exclude tests. re.search(r'test?\.cc|unittest|/test/', f) or # Exclude directories that are not compatible with nacl-g++. re.search(r'/(i18n|prefs|histogram|metrics|xdg_mime|process)/', f) or # Exclude files for other architectures. Also excludes files that # operates files. These files do not seem to support OS_NACL build. re.search(r'[/_](win|mac|linux|chromeos|android|ios|glib|gtk|' 'openbsd|freebsd|kqueue|libevent|aurax11|' # TODO(yusukes): Try to compile file_util*.cc with NaCl g++ # to minimize the |excludes| list above. 'sys_info|process_|shim|file_util)', f)): return False return True build_files = filter(relevant, n.find_all_sources()) n.build_default(build_files, base_path=None).archive() # Dump global symbols in libchromium_base. if not enable_libcxx: out_path = os.path.join(ninja_generator.CNinjaGenerator.get_symbols_path(), 'libchromium_base.a.defined') n.build([out_path], 'dump_defined_symbols', build_common.get_build_path_for_library('libchromium_base.a'), implicit='src/build/symbol_tool.py')
def _generate_chromium_base_ninja_common(module_name, instances, enable_libcxx): base_path = 'android/external/chromium_org/base' # chromium_base is required by libart-gtest, libposix_translation, and the # plugin. n = ninja_generator.ArchiveNinjaGenerator(module_name, base_path=base_path, instances=instances, force_compiler='clang', enable_cxx11=True, enable_libcxx=enable_libcxx) n.add_compiler_flags('-fvisibility=hidden') # for libposix_translation.so _add_chromium_base_compiler_flags(n) def relevant(f): f = f.lstrip('android/external/chromium_org/') # Files with specific suffixes like '_linux' are usually excluded. # Here is the list of exceptions. whitelist = [ 'base/threading/platform_thread_linux.cc', 'base/threading/thread_local_android.cc', 'base/debug/stack_trace_android.cc', 'base/debug/trace_event_android.cc' ] if f in whitelist: return True # Exclude cc files that do not compile with nacl-g++. Roughly speaking, # functions in the following categories do not compile/work: # - Functions that execute commands (e.g. *_xdg.cc). # - Functions that depends on file_util.h which is not (yet) available. excludes = [ 'base/allocator/generic_allocators.cc', 'base/async_socket_io_handler_posix.cc', 'base/base64.cc', 'base/base_paths.cc', 'base/base_paths_posix.cc', 'base/check_example.cc', 'base/cpu.cc', 'base/debug_message.cc', # This is excluded in the upstream, too. 'base/debug/stack_trace_posix.cc', 'base/debug/trace_event_system_stats_monitor.cc', # TODO(crbug.com/414569): L-rebase: Do I need it? 'base/memory/discardable_memory_ashmem.cc', 'base/memory/discardable_memory_ashmem_allocator.cc', 'base/files/file_enumerator_posix.cc', 'base/files/file_proxy.cc', 'base/files/file_path_watcher_fsevents.cc', # for Mac 'base/files/important_file_writer.cc', 'base/files/memory_mapped_file.cc', 'base/files/memory_mapped_file_posix.cc', 'base/files/scoped_temp_dir.cc', 'base/guid_posix.cc', 'base/json/json_file_value_serializer.cc', 'base/memory/discardable_memory.cc', 'base/memory/shared_memory_posix.cc', 'base/message_loop/message_pump_ozone.cc', 'base/message_loop/message_pump_x11.cc', 'base/nix/mime_util_xdg.cc', 'base/nix/xdg_util.cc', # This provides timegm implementation, but we use the one in bionic. 'base/os_compat_nacl.cc', 'base/path_service.cc', 'base/perftimer.cc', 'base/rand_util.cc', 'base/rand_util_nacl.cc', 'base/rand_util_posix.cc', 'base/sync_socket_posix.cc', 'base/third_party/dmg_fp/dtoa_wrapper.cc', 'base/threading/watchdog.cc', 'base/x11/edid_parser_x11.cc', 'base/x11/x11_error_tracker.cc' ] if ((f in excludes) or # Exclude non-cc files. (not f.endswith('.cc') and not f.endswith('.c')) or # Exclude tests. re.search(r'test?\.cc|unittest|/test/', f) or # Exclude directories that are not compatible with nacl-g++. re.search(r'/(i18n|prefs|histogram|metrics|xdg_mime|process)/', f) or # Exclude files for other architectures. Also excludes files that # operates files. These files do not seem to support OS_NACL build. re.search( r'[/_](win|mac|linux|chromeos|android|ios|glib|gtk|' 'openbsd|freebsd|kqueue|libevent|aurax11|' # TODO(yusukes): Try to compile file_util*.cc with NaCl g++ # to minimize the |excludes| list above. 'sys_info|process_|shim|file_util)', f)): return False return True build_files = filter(relevant, n.find_all_sources()) n.build_default(build_files, base_path=None).archive() # Dump global symbols in libchromium_base. if not enable_libcxx: out_path = os.path.join( ninja_generator.CNinjaGenerator.get_symbols_path(), 'libchromium_base.a.defined') n.build([out_path], 'dump_defined_symbols', build_common.get_build_path_for_library('libchromium_base.a'), implicit='src/build/symbol_tool.py')