From df73a9d2a9713ccbb4be435ca28cb31f81646041 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 13 Apr 2018 14:22:02 +0530 Subject: [PATCH] custom targets: Don't replace \\ with / This is no longer required since we always use `/` as the path separator for file arguments on Windows now. The only effect this now has is to mangle the string args people pass to custom targets. Closes https://github.com/mesonbuild/meson/issues/1564 --- mesonbuild/backend/backends.py | 19 ------------------- test cases/common/48 test args/copyfile.py | 11 +++++++++++ test cases/common/48 test args/meson.build | 6 +----- .../common/48 test args/sub1/meson.build | 5 +++++ 4 files changed, 17 insertions(+), 24 deletions(-) create mode 100644 test cases/common/48 test args/sub1/meson.build diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 916f68099da5..5c5bcb4b9a2c 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -839,25 +839,6 @@ def eval_custom_target_command(self, target, absolute_outputs=False): # Substitute the rest of the template strings values = mesonlib.get_filenames_templates_dict(inputs, outputs) cmd = mesonlib.substitute_values(cmd, values) - # This should not be necessary but removing it breaks - # building GStreamer on Windows. The underlying issue - # is problems with quoting backslashes on Windows - # which is the seventh circle of hell. The downside is - # that this breaks custom targets whose command lines - # have backslashes. If you try to fix this be sure to - # check that it does not break GST. - # - # The bug causes file paths such as c:\foo to get escaped - # into c:\\foo. - # - # Unfortunately we have not been able to come up with an - # isolated test case for this so unless you manage to come up - # with one, the only way is to test the building with Gst's - # setup. Note this in your MR or ping us and we will get it - # fixed. - # - # https://github.com/mesonbuild/meson/pull/737 - cmd = [i.replace('\\', '/') for i in cmd] return inputs, outputs, cmd def run_postconf_scripts(self): diff --git a/test cases/common/48 test args/copyfile.py b/test cases/common/48 test args/copyfile.py index ff42ac359020..1b5bbaf4953f 100644 --- a/test cases/common/48 test args/copyfile.py +++ b/test cases/common/48 test args/copyfile.py @@ -3,4 +3,15 @@ import sys import shutil +# If either of these use `\` as the path separator, it will cause problems with +# MSYS, MSYS2, and Cygwin tools that expect the path separator to always be +# `/`. All Native-Windows tools also accept `/` as the path separator, so +# it's fine to always use that for arguments. +# See: https://github.com/mesonbuild/meson/issues/1564 +if '\\' in sys.argv[1]: + raise AssertionError('Found \\ in {!r}'.format(sys.argv[1])) + +if '\\' in sys.argv[2]: + raise AssertionError('Found \\ in {!r}'.format(sys.argv[2])) + shutil.copyfile(sys.argv[1], sys.argv[2]) diff --git a/test cases/common/48 test args/meson.build b/test cases/common/48 test args/meson.build index 81d34915abec..99f995e21608 100644 --- a/test cases/common/48 test args/meson.build +++ b/test cases/common/48 test args/meson.build @@ -27,9 +27,5 @@ test('file arg', testerpy, args : testfile, env : env_array) copy = find_program('copyfile.py') tester = executable('tester', 'tester.c') -testfilect = custom_target('testfile', - input : testfile, - output : 'outfile.txt', - build_by_default : true, - command : [copy, '@INPUT@', '@OUTPUT@']) +subdir('sub1') test('custom target arg', tester, args : testfilect, env : env_array) diff --git a/test cases/common/48 test args/sub1/meson.build b/test cases/common/48 test args/sub1/meson.build new file mode 100644 index 000000000000..4bbfb6fc1b00 --- /dev/null +++ b/test cases/common/48 test args/sub1/meson.build @@ -0,0 +1,5 @@ +testfilect = custom_target('testfile', + input : testfile, + output : 'outfile.txt', + build_by_default : true, + command : [copy, '@INPUT@', '@OUTPUT@'])