From 108dac5c162eb086b8cce3f4d0575f7282c72c48 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 30 Apr 2017 20:58:25 +0300 Subject: [PATCH] Store extra_files as file objects. Helps with #1686. --- mesonbuild/backend/vs2010backend.py | 2 +- mesonbuild/build.py | 7 +++---- mesonbuild/interpreter.py | 5 +++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 16e96c941..ac4c93b25 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -980,7 +980,7 @@ class Vs2010Backend(backends.Backend): for h in gen_hdrs: ET.SubElement(inc_hdrs, 'CLInclude', Include=h) for h in target.extra_files: - relpath = os.path.join(proj_to_src_dir, h) + relpath = os.path.join(down, h.rel_to_builddir(self.build_to_src)) ET.SubElement(inc_hdrs, 'CLInclude', Include=relpath) if len(sources) + len(gen_src) + len(pch_sources) > 0: diff --git a/mesonbuild/build.py b/mesonbuild/build.py index c8d692ed1..7dc0bc7b5 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -648,12 +648,11 @@ class BuildTarget(Target): elif 'gui_app' in kwargs: raise InvalidArguments('Argument gui_app can only be used on executables.') extra_files = kwargs.get('extra_files', []) - if isinstance(extra_files, str): + if not isinstance(extra_files, list): extra_files = [extra_files] for i in extra_files: - if not isinstance(i, str): - raise InvalidArguments('Arguments to extra_files must be strings.') - trial = os.path.join(environment.get_source_dir(), self.subdir, i) + assert(isinstance(i, File)) + trial = os.path.join(environment.get_source_dir(), i.subdir, i.fname) if not(os.path.isfile(trial)): raise InvalidArguments('Tried to add non-existing extra file %s.' % i) self.extra_files = extra_files diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 979cdccf2..d8f3b2b69 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2554,6 +2554,11 @@ different subdirectory. sources = self.source_strings_to_files(sources) objs = self.flatten(kwargs.get('objects', [])) kwargs['dependencies'] = self.flatten(kwargs.get('dependencies', [])) + if 'extra_files' in kwargs: + ef = kwargs['extra_files'] + if not isinstance(ef, list): + ef = [ef] + kwargs['extra_files'] = self.source_strings_to_files(ef) if not isinstance(objs, list): objs = [objs] self.check_sources_exist(os.path.join(self.source_root, self.subdir), sources)