diff options
author | Jason Francis <zxzax@protonmail.com> | 2021-03-22 08:50:10 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-04-26 17:08:26 +0100 |
commit | 39c751b94c5e12bb7a48a64941ccf225d93359ff (patch) | |
tree | 85564bb750d0b9b99007e964ea54d6c8d18f9022 | |
parent | bb12587e0ba83ed6cde0f395c0a31cee9a3ace26 (diff) | |
download | meson-39c751b94c5e12bb7a48a64941ccf225d93359ff.zip meson-39c751b94c5e12bb7a48a64941ccf225d93359ff.tar.gz meson-39c751b94c5e12bb7a48a64941ccf225d93359ff.tar.bz2 |
introspection: export all sources for custom targets
Also adds some test cases for source files in target_sources.
-rw-r--r-- | mesonbuild/backend/backends.py | 2 | ||||
-rwxr-xr-x | run_unittests.py | 26 | ||||
-rw-r--r-- | test cases/unit/57 introspection/meson.build | 11 |
3 files changed, 30 insertions, 9 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index e6628b6..ee5f446 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -1523,6 +1523,8 @@ class Backend: source_list += [j.absolute_path(self.source_dir, self.build_dir)] elif isinstance(j, str): source_list += [os.path.join(self.source_dir, j)] + elif isinstance(j, (build.CustomTarget, build.BuildTarget)): + source_list += [os.path.join(self.build_dir, j.get_subdir(), o) for o in j.get_outputs()] source_list = list(map(lambda x: os.path.normpath(x), source_list)) compiler = [] diff --git a/run_unittests.py b/run_unittests.py index 8674426..a0eb670 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -4678,10 +4678,12 @@ class AllPlatformTests(BasePlatformTests): # Match target ids to input and output files for ease of reference src_to_id = {} out_to_id = {} + name_to_out = {} for i in res['targets']: print(json.dump(i, sys.stdout)) out_to_id.update({os.path.relpath(out, self.builddir): i['id'] for out in i['filename']}) + name_to_out.update({i['name']: i['filename']}) for group in i['target_sources']: src_to_id.update({os.path.relpath(src, testdir): i['id'] for src in group['sources']}) @@ -4690,7 +4692,7 @@ class AllPlatformTests(BasePlatformTests): tests_to_find = ['test case 1', 'test case 2', 'benchmark 1'] deps_to_find = {'test case 1': [src_to_id['t1.cpp']], 'test case 2': [src_to_id['t2.cpp'], src_to_id['t3.cpp']], - 'benchmark 1': [out_to_id['file2'], src_to_id['t3.cpp']]} + 'benchmark 1': [out_to_id['file2'], out_to_id['file3'], out_to_id['file4'], src_to_id['t3.cpp']]} for i in res['benchmarks'] + res['tests']: assertKeyTypes(test_keylist, i) if i['name'] in tests_to_find: @@ -4737,11 +4739,22 @@ class AllPlatformTests(BasePlatformTests): # Check targets targets_to_find = { - 'sharedTestLib': ('shared library', True, False, 'sharedlib/meson.build'), - 'staticTestLib': ('static library', True, False, 'staticlib/meson.build'), - 'test1': ('executable', True, True, 'meson.build'), - 'test2': ('executable', True, False, 'meson.build'), - 'test3': ('executable', True, False, 'meson.build'), + 'sharedTestLib': ('shared library', True, False, 'sharedlib/meson.build', + [os.path.join(testdir, 'sharedlib', 'shared.cpp')]), + 'staticTestLib': ('static library', True, False, 'staticlib/meson.build', + [os.path.join(testdir, 'staticlib', 'static.c')]), + 'custom target test 1': ('custom', False, False, 'meson.build', + [os.path.join(testdir, 'cp.py')]), + 'custom target test 2': ('custom', False, False, 'meson.build', + name_to_out['custom target test 1']), + 'test1': ('executable', True, True, 'meson.build', + [os.path.join(testdir, 't1.cpp')]), + 'test2': ('executable', True, False, 'meson.build', + [os.path.join(testdir, 't2.cpp')]), + 'test3': ('executable', True, False, 'meson.build', + [os.path.join(testdir, 't3.cpp')]), + 'custom target test 3': ('custom', False, False, 'meson.build', + name_to_out['test3']), } for i in res['targets']: assertKeyTypes(targets_typelist, i) @@ -4754,6 +4767,7 @@ class AllPlatformTests(BasePlatformTests): targets_to_find.pop(i['name'], None) for j in i['target_sources']: assertKeyTypes(targets_sources_typelist, j) + self.assertEqual(j['sources'], [os.path.normpath(f) for f in tgt[4]]) self.assertDictEqual(targets_to_find, {}) def test_introspect_file_dump_equals_all(self): diff --git a/test cases/unit/57 introspection/meson.build b/test cases/unit/57 introspection/meson.build index 2b38151..2f666f3 100644 --- a/test cases/unit/57 introspection/meson.build +++ b/test cases/unit/57 introspection/meson.build @@ -27,13 +27,18 @@ var1 = '1' var2 = 2.to_string() var3 = 'test3' -cus = custom_target('custom target test', output: 'file2', input: 'cp.py', - command: [find_program('cp.py'), '@INPUT@', '@OUTPUT@']) +cus1 = custom_target('custom target test 1', output: 'file2', input: 'cp.py', + command: [find_program('cp.py'), '@INPUT@', '@OUTPUT@']) +cus2 = custom_target('custom target test 2', output: 'file3', input: cus1, + command: [find_program('cp.py'), '@INPUT@', '@OUTPUT@']) t1 = executable('test' + var1, ['t1.cpp'], link_with: [sharedlib], install: not false, build_by_default: get_option('test_opt2')) t2 = executable('test@0@'.format('@0@'.format(var2)), sources: ['t2.cpp'], link_with: [staticlib]) t3 = executable(var3, 't3.cpp', link_with: [sharedlib, staticlib], dependencies: [dep1]) +cus3 = custom_target('custom target test 3', output: 'file4', input: t3, + command: [find_program('cp.py'), '@INPUT@', '@OUTPUT@']) + ### BEGIN: Test inspired by taisei: https://github.com/taisei-project/taisei/blob/master/meson.build#L293 systype = '@0@'.format(host_machine.system()) systype = '@0@, @1@, @2@'.format(systype, host_machine.cpu_family(), host_machine.cpu()) @@ -49,7 +54,7 @@ message(osmesa_lib_name) # Infinite recursion gets triggered here when the param test('test case 1', t1) test('test case 2', t2, depends: t3) -benchmark('benchmark 1', t3, args: cus) +benchmark('benchmark 1', t3, args: [cus1, cus2, cus3]) ### Stuff to test the AST JSON printer foreach x : ['a', 'b', 'c'] |