From 330be891c1cbc115bef765c04730b1004d5cb20a Mon Sep 17 00:00:00 2001 From: Nicolas Schneider Date: Tue, 29 Mar 2016 00:37:03 +0200 Subject: [PATCH 1/4] vs2010: fix generator command A shebang line on Windows will be resolved to [binary, script_path]. Thus, we need to use both instead of just taking the first element of the command. --- mesonbuild/backend/vs2010backend.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index ec10d4c5c..3aa3ca8de 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -51,10 +51,7 @@ class Vs2010Backend(backends.Backend): exe = generator.get_exe() infilelist = genlist.get_infilelist() outfilelist = genlist.get_outfilelist() - if isinstance(exe, build.BuildTarget): - exe_file = os.path.join(self.environment.get_build_dir(), self.get_target_filename(exe)) - else: - exe_file = exe.get_command()[0] + exe_arr = self.exe_object_to_cmd_array(exe) base_args = generator.get_arglist() for i in range(len(infilelist)): if len(infilelist) == len(outfilelist): @@ -70,7 +67,7 @@ class Vs2010Backend(backends.Backend): for x in base_args] args = [x.replace("@SOURCE_DIR@", self.environment.get_source_dir()).replace("@BUILD_DIR@", self.get_target_private_dir(target)) for x in args] - fullcmd = [exe_file] + args + fullcmd = exe_arr + args commands.append(' '.join(self.special_quote(fullcmd))) inputs.append(infilename) outputs.extend(outfiles) From ba8b650cdaf926fc183ae6fa4d1348996b07fb6c Mon Sep 17 00:00:00 2001 From: Nicolas Schneider Date: Tue, 29 Mar 2016 01:46:47 +0200 Subject: [PATCH 2/4] vs2010: fix relative path to target private dir for generators backend.get_target_private_dir() includes the target directory in the path. However, we want to treat all paths relative from the target directory, because that's where our VS project file lives in. --- mesonbuild/backend/vs2010backend.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 3aa3ca8de..eb5678890 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -53,19 +53,20 @@ class Vs2010Backend(backends.Backend): outfilelist = genlist.get_outfilelist() exe_arr = self.exe_object_to_cmd_array(exe) base_args = generator.get_arglist() + target_private_dir = self.relpath(self.get_target_private_dir(target), self.get_target_dir(target)) for i in range(len(infilelist)): if len(infilelist) == len(outfilelist): - sole_output = os.path.join(self.get_target_private_dir(target), outfilelist[i]) + sole_output = os.path.join(target_private_dir, outfilelist[i]) else: sole_output = '' curfile = infilelist[i] infilename = os.path.join(self.environment.get_source_dir(), curfile) outfiles = genlist.get_outputs_for(curfile) - outfiles = [os.path.join(self.get_target_private_dir(target), of) for of in outfiles] + outfiles = [os.path.join(target_private_dir, of) for of in outfiles] all_output_files += outfiles args = [x.replace("@INPUT@", infilename).replace('@OUTPUT@', sole_output)\ for x in base_args] - args = [x.replace("@SOURCE_DIR@", self.environment.get_source_dir()).replace("@BUILD_DIR@", self.get_target_private_dir(target)) + args = [x.replace("@SOURCE_DIR@", self.environment.get_source_dir()).replace("@BUILD_DIR@", target_private_dir) for x in args] fullcmd = exe_arr + args commands.append(' '.join(self.special_quote(fullcmd))) From c2a9f81b68ce5d5370a6eff5df1fa678fc59fb17 Mon Sep 17 00:00:00 2001 From: Nicolas Schneider Date: Tue, 29 Mar 2016 01:48:39 +0200 Subject: [PATCH 3/4] vs2010: fix generated files' path Generated files should always come with the correct relative path set, so we don't have to modify it at all. --- mesonbuild/backend/vs2010backend.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index eb5678890..c81e44b0d 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -552,11 +552,7 @@ class Vs2010Backend(backends.Backend): relpath = h.rel_to_builddir(proj_to_src_root) ET.SubElement(inc_hdrs, 'CLInclude', Include=relpath) for h in gen_hdrs: - if isinstance(h, str): - relpath = h - else: - relpath = h.rel_to_builddir(proj_to_src_root) - ET.SubElement(inc_hdrs, 'CLInclude', Include = relpath) + ET.SubElement(inc_hdrs, 'CLInclude', Include=h) if len(sources) + len(gen_src) + len(pch_sources) > 0: inc_src = ET.SubElement(root, 'ItemGroup') for s in sources: @@ -565,8 +561,7 @@ class Vs2010Backend(backends.Backend): self.add_pch(inc_cl, proj_to_src_dir, pch_sources, s) self.add_additional_options(s, inc_cl, extra_args, additional_options_set) for s in gen_src: - relpath = self.relpath(s, target.subdir) - inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=relpath) + inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=s) self.add_pch(inc_cl, proj_to_src_dir, pch_sources, s) self.add_additional_options(s, inc_cl, extra_args, additional_options_set) for lang in pch_sources: From a33d9d56cf72e493e2176b33e95afa8921f26e06 Mon Sep 17 00:00:00 2001 From: Nicolas Schneider Date: Tue, 29 Mar 2016 12:07:21 +0200 Subject: [PATCH 4/4] vs2010: support EXTRA_ARGS for generators --- mesonbuild/backend/backends.py | 9 +++++++++ mesonbuild/backend/ninjabackend.py | 8 +------- mesonbuild/backend/vs2010backend.py | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 8d0b0f613..bcd891329 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -388,6 +388,15 @@ class Backend(): exe_arr = exe.get_command() return exe_arr + def replace_extra_args(self, args, genlist): + final_args = [] + for a in args: + if a == '@EXTRA_ARGS@': + final_args += genlist.get_extra_args() + else: + final_args.append(a) + return final_args + def eval_custom_target_command(self, target, absolute_paths=False): if not absolute_paths: ofilenames = [os.path.join(self.get_target_dir(target), i) for i in target.output] diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 8e8fa4285..8c3902442 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1349,13 +1349,7 @@ rule FORTRAN_DEP_HACK relout = self.get_target_private_dir(target) args = [x.replace("@SOURCE_DIR@", self.build_to_src).replace("@BUILD_DIR@", relout) for x in args] - final_args = [] - for a in args: - if a == '@EXTRA_ARGS@': - final_args += genlist.get_extra_args() - else: - final_args.append(a) - cmdlist = exe_arr + final_args + cmdlist = exe_arr + self.replace_extra_args(args, genlist) elem = NinjaBuildElement(self.all_outputs, outfiles, 'CUSTOM_COMMAND', infilename) if len(extra_dependencies) > 0: elem.add_dep(extra_dependencies) diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index c81e44b0d..3f6c53461 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -68,7 +68,7 @@ class Vs2010Backend(backends.Backend): for x in base_args] args = [x.replace("@SOURCE_DIR@", self.environment.get_source_dir()).replace("@BUILD_DIR@", target_private_dir) for x in args] - fullcmd = exe_arr + args + fullcmd = exe_arr + self.replace_extra_args(args, genlist) commands.append(' '.join(self.special_quote(fullcmd))) inputs.append(infilename) outputs.extend(outfiles)