diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-10-30 23:27:51 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-11-02 21:02:25 +0200 |
commit | 23ed0e18575075f78009caabedf9e6246d440dde (patch) | |
tree | ea8c782fc49c1436d63621826c8d6cb17121c8af /mesonbuild | |
parent | beb1f00f3bca05a0d9bd30a115da2621f43e2b73 (diff) | |
download | meson-23ed0e18575075f78009caabedf9e6246d440dde.zip meson-23ed0e18575075f78009caabedf9e6246d440dde.tar.gz meson-23ed0e18575075f78009caabedf9e6246d440dde.tar.bz2 |
Make string division do path joining.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/interpreter.py | 2 | ||||
-rw-r--r-- | mesonbuild/interpreterbase.py | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 7e5ad27..2b27694 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3810,7 +3810,7 @@ different subdirectory. @stringArgs @noKwargs def func_join_paths(self, node, args, kwargs): - return os.path.join(*args).replace('\\', '/') + return self.join_path_strings(args) def run(self): super().run() diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index aee1c87..66e9dd6 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -382,6 +382,9 @@ class InterpreterBase: me.file = environment.build_filename raise me + def join_path_strings(self, args): + return os.path.join(*args).replace('\\', '/') + def parse_project(self): """ Parses project() and initializes languages, compilers etc. Do this @@ -628,9 +631,13 @@ The result of this is undefined and will become a hard error in a future Meson r raise InvalidCode('Multiplication works only with integers.') return l * r elif cur.operation == 'div': - if not isinstance(l, int) or not isinstance(r, int): - raise InvalidCode('Division works only with integers.') - return l // r + if isinstance(l, str) and isinstance(r, str): + return self.join_path_strings((l, r)) + if isinstance(l, int) and isinstance(r, int): + if r == 0: + raise InvalidCode('Division by zero.') + return l // r + raise InvalidCode('Division works only with strings or integers.') elif cur.operation == 'mod': if not isinstance(l, int) or not isinstance(r, int): raise InvalidCode('Modulo works only with integers.') |