aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-03-28 14:31:45 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-03-28 14:49:32 +0530
commit976c9abcd0348ffb29863ac2688c661eda524a47 (patch)
tree968913d082a1ce8ab8202aee71a9d15ba5f4688d /mesonbuild/backend
parent03d0feec7ceed1a1ee2e6284a86dbc26a088440f (diff)
downloadmeson-976c9abcd0348ffb29863ac2688c661eda524a47.zip
meson-976c9abcd0348ffb29863ac2688c661eda524a47.tar.gz
meson-976c9abcd0348ffb29863ac2688c661eda524a47.tar.bz2
modules: Start using @SOURCE_ROOT@ and @BUILD_ROOT@
First step in fixing https://github.com/mesonbuild/meson/issues/1419 Also works around an issue in the MinGW windres.exe that causes it to fail if any of the arguments passed to it contain a space. There seems to be no way to quote or escape the spaces in the path to make windres parse the path correctly, so we just warn about it instead. https://sourceware.org/bugzilla/show_bug.cgi?id=4933 https://github.com/mesonbuild/meson/pull/1346
Diffstat (limited to 'mesonbuild/backend')
-rw-r--r--mesonbuild/backend/backends.py9
-rw-r--r--mesonbuild/backend/ninjabackend.py2
-rw-r--r--mesonbuild/backend/vs2010backend.py6
3 files changed, 16 insertions, 1 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index fa9a82f..99be172 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -601,8 +601,13 @@ class Backend:
def eval_custom_target_command(self, target, absolute_outputs=False):
# We want the outputs to be absolute only when using the VS backend
+ # XXX: Maybe allow the vs backend to use relative paths too?
+ source_root = self.build_to_src
+ build_root = '.'
outdir = self.get_target_dir(target)
if absolute_outputs:
+ source_root = self.environment.get_source_dir()
+ build_root = self.environment.get_source_dir()
outdir = os.path.join(self.environment.get_build_dir(), outdir)
outputs = []
for i in target.output:
@@ -628,6 +633,10 @@ class Backend:
elif not isinstance(i, str):
err_msg = 'Argument {0} is of unknown type {1}'
raise RuntimeError(err_msg.format(str(i), str(type(i))))
+ elif '@SOURCE_ROOT@' in i:
+ i = i.replace('@SOURCE_ROOT@', source_root)
+ elif '@BUILD_ROOT@' in i:
+ i = i.replace('@BUILD_ROOT@', build_root)
elif '@DEPFILE@' in i:
if target.depfile is None:
msg = 'Custom target {!r} has @DEPFILE@ but no depfile ' \
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index cc350b2..8486060 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1602,6 +1602,8 @@ 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]
+ args = [x.replace("@SOURCE_ROOT@", self.build_to_src).replace("@BUILD_ROOT@", '.')
+ for x in args]
cmdlist = exe_arr + self.replace_extra_args(args, genlist)
elem = NinjaBuildElement(self.all_outputs, outfiles, rulename, infilename)
if generator.depfile is not None:
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
index 84e8296..8c0cce6 100644
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -151,7 +151,11 @@ class Vs2010Backend(backends.Backend):
args = [x.replace("@INPUT@", infilename).replace('@OUTPUT@', sole_output)
for x in base_args]
args = self.replace_outputs(args, target_private_dir, outfiles_rel)
- args = [x.replace("@SOURCE_DIR@", self.environment.get_source_dir()).replace("@BUILD_DIR@", target_private_dir)
+ args = [x.replace("@SOURCE_DIR@", self.environment.get_source_dir())
+ .replace("@BUILD_DIR@", target_private_dir)
+ for x in args]
+ args = [x.replace("@SOURCE_ROOT@", self.environment.get_source_dir())
+ .replace("@BUILD_ROOT@", self.environment.get_build_dir())
for x in args]
cmd = exe_arr + self.replace_extra_args(args, genlist)
cbs = ET.SubElement(idgroup, 'CustomBuild', Include=infilename)