diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-02-27 11:01:56 +0100 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-03-04 13:00:05 +0100 |
commit | 2582f311b0a2f23d56a3cbfd99850bbec4f7b109 (patch) | |
tree | 038992170ee7d4d0b5e561e896fb5af34a566a13 /mesonbuild | |
parent | 760d1bff9cf7db9886aedb02226e5a7105d5d454 (diff) | |
download | meson-2582f311b0a2f23d56a3cbfd99850bbec4f7b109.zip meson-2582f311b0a2f23d56a3cbfd99850bbec4f7b109.tar.gz meson-2582f311b0a2f23d56a3cbfd99850bbec4f7b109.tar.bz2 |
rewriter: Make sure target sources are relative
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/rewriter.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mesonbuild/rewriter.py b/mesonbuild/rewriter.py index 2619aae..b959557 100644 --- a/mesonbuild/rewriter.py +++ b/mesonbuild/rewriter.py @@ -552,6 +552,19 @@ class Rewriter: if cmd['debug']: pprint(target) + # Make source paths relative to the current subdir + def rel_source(src: str) -> str: + subdir = os.path.abspath(os.path.join(self.sourcedir, target['subdir'])) + if os.path.isabs(src): + return os.path.relpath(src, subdir) + elif not os.path.exists(src): + return src # Trust the user when the source doesn't exist + # Make sure that the path is relative to the subdir + return os.path.relpath(os.path.abspath(src), subdir) + + if target is not None: + cmd['sources'] = [rel_source(x) for x in cmd['sources']] + # Utility function to get a list of the sources from a node def arg_list_from_node(n): args = [] |