Created path_join function.

pull/886/head
Jussi Pakkanen 8 years ago
parent 6eacca2024
commit c2b852c9b3
  1. 10
      mesonbuild/interpreter.py
  2. 9
      test cases/common/119 pathjoin/meson.build

@ -1196,6 +1196,7 @@ class Interpreter():
'declare_dependency': self.func_declare_dependency,
'assert': self.func_assert,
'environment' : self.func_environment,
'path_join' : self.func_path_join,
}
def parse_project(self):
@ -2237,6 +2238,15 @@ class Interpreter():
def func_environment(self, node, args, kwargs):
return EnvironmentVariablesHolder()
@stringArgs
@noKwargs
def func_path_join(self, node, args, kwargs):
if isinstance(args, str):
st = (args,)
else:
st = tuple(args)
return os.path.join(*args).replace('\\', '/')
def flatten(self, args):
if isinstance(args, mparser.StringNode):
return args.value

@ -0,0 +1,9 @@
project('pathjoin', 'c')
assert(path_join('foo') == 'foo', 'Single argument join is broken')
assert(path_join('foo', 'bar') == 'foo/bar', 'Path joining is broken')
assert(path_join('foo', 'bar', 'baz') == 'foo/bar/baz', 'Path joining is broken')
assert(path_join('/foo', 'bar') == '/foo/bar', 'Path joining is broken')
assert(path_join('foo', '/bar') == '/bar', 'Absolute path joining is broken')
assert(path_join('/foo', '/bar') == '/bar', 'Absolute path joining is broken')
Loading…
Cancel
Save