From 963107b737daf28ec7e26856bb977bd92ab00033 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sun, 11 Feb 2018 16:34:37 +0000 Subject: [PATCH 1/3] Add a test for 'meson introspect --targets|--target-files' v2: Use asssertCountEqual for list comparison ignoring order --- run_unittests.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/run_unittests.py b/run_unittests.py index 96802cc8c..58ab3e1f0 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -2372,6 +2372,38 @@ int main(int argc, char **argv) { self.init(testdir, ['--cross-file=' + name], inprocess=True) self.wipe() + def test_introspect_target_files(self): + ''' + Tests that mesonintrospect --target-files returns expected output. + ''' + testdir = os.path.join(self.common_test_dir, '8 install') + self.init(testdir) + expected = { + 'stat@sta': ['stat.c'], + 'prog@exe': ['prog.c'], + } + t_intro = self.introspect('--targets') + self.assertCountEqual([t['id'] for t in t_intro], expected) + for t in t_intro: + id = t['id'] + tf_intro = self.introspect(['--target-files', id]) + self.assertEqual(tf_intro, expected[id]) + self.wipe() + + testdir = os.path.join(self.common_test_dir, '53 custom target') + self.init(testdir) + expected = { + 'bindat@cus': ['data_source.txt'], + 'depfile@cus': [], + } + t_intro = self.introspect('--targets') + self.assertCountEqual([t['id'] for t in t_intro], expected) + for t in t_intro: + id = t['id'] + tf_intro = self.introspect(['--target-files', id]) + self.assertEqual(tf_intro, expected[id]) + self.wipe() + def test_compiler_run_command(self): ''' The test checks that the compiler object can be passed to From 0a1468f8f3a3f64bf2a02a594c705ebb81c8c1f7 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Tue, 13 Feb 2018 19:57:46 +0000 Subject: [PATCH 2/3] Convert custom target sources to Files with self.source_strings_to_files. --- mesonbuild/interpreter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 0e6a041ce..76e443975 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3231,6 +3231,8 @@ root and issuing %s. 'Implementation-only, without FeatureNew checks, for internal use' name = args[0] kwargs['install_mode'] = self._get_kwarg_install_mode(kwargs) + if 'input' in kwargs: + kwargs['input'] = self.source_strings_to_files(extract_as_list(kwargs, 'input')) tg = CustomTargetHolder(build.CustomTarget(name, self.subdir, self.subproject, kwargs), self) self.add_target(name, tg.held_object) return tg @@ -3908,7 +3910,7 @@ Try setting b_lundef to false instead.'''.format(self.coredata.base_options['b_s sources = [sources] for s in sources: if isinstance(s, (mesonlib.File, GeneratedListHolder, - CustomTargetHolder, CustomTargetIndexHolder)): + TargetHolder, CustomTargetIndexHolder)): pass elif isinstance(s, str): self.validate_within_subproject(self.subdir, s) From e702d754b150dea00dcdf0956bc958d059e47ce9 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sat, 15 Sep 2018 16:02:12 +0100 Subject: [PATCH 3/3] Tolerate custom target sources which can't be converted to Files For backwards compatibility, tolerate but warn about custom target sources which can't be converted to Files --- mesonbuild/interpreter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 76e443975..1d6d67090 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3232,7 +3232,11 @@ root and issuing %s. name = args[0] kwargs['install_mode'] = self._get_kwarg_install_mode(kwargs) if 'input' in kwargs: - kwargs['input'] = self.source_strings_to_files(extract_as_list(kwargs, 'input')) + try: + kwargs['input'] = self.source_strings_to_files(extract_as_list(kwargs, 'input')) + except mesonlib.MesonException: + mlog.warning('''Custom target input \'%s\' can\'t be converted to File object(s). +This will become a hard error in the future.''' % kwargs['input']) tg = CustomTargetHolder(build.CustomTarget(name, self.subdir, self.subproject, kwargs), self) self.add_target(name, tg.held_object) return tg