def _get_generated_file(ninja, out_name, script_name): script_path = os.path.join('src/common', script_name) rule_name = os.path.splitext(os.path.basename(script_path))[0] ninja.rule(rule_name, command='%s > $out.tmp && mv $out.tmp $out' % script_path, description=rule_name + ' $in') out_path = os.path.join(build_common.get_build_dir(), 'common_gen_sources', out_name) implicit = python_deps.find_deps(script_path) ninja.build(out_path, rule_name, implicit=implicit) return out_path
def _get_generated_file(ninja, out_name, script_name): script_path = os.path.join('src/common', script_name) rule_name = os.path.splitext(os.path.basename(script_path))[0] ninja.rule(rule_name, command='%s > $out.tmp && mv $out.tmp $out' % script_path, description=rule_name + ' $in') out_path = os.path.join(build_common.get_build_dir(), 'common_gen_sources', out_name) implicit = python_deps.find_deps(script_path) ninja.build(out_path, rule_name, implicit=implicit) return out_path
def test_normal_success(self): # Get the dependencies of this test module. deps = python_deps.find_deps('src/build/util/python_deps_test.py') # build_common is imported by python_deps, which we import. self.assertIn('src/build/build_common.py', deps) # python_deps is something we import directly. self.assertIn('src/build/util/python_deps.py', deps) # The dependencies should include the file at the root of the search. self.assertIn('src/build/util/python_deps_test.py', deps) # We should not see any standard library modules such as 'unittest' which # this test imports. for path in deps: self.assertNotRegexpMatches(path, r'\Wunittest\W')
def test_normal_success(self): # Get the dependencies of this test module. deps = python_deps.find_deps('src/build/util/python_deps_test.py') # build_common is imported by python_deps, which we import. self.assertIn('src/build/build_common.py', deps) # python_deps is something we import directly. self.assertIn('src/build/util/python_deps.py', deps) # The dependencies should include the file at the root of the search. self.assertIn('src/build/util/python_deps_test.py', deps) # We should not see any standard library modules such as 'unittest' which # this test imports. for path in deps: self.assertNotRegexpMatches(path, r'\Wunittest\W')
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})