Blame 0011-Created-path_join-function.patch

Igor Gnatenko 57d01a
From f12c0f31e27ca37400c5ca8deb700af222f0bcb6 Mon Sep 17 00:00:00 2001
Igor Gnatenko 57d01a
From: Jussi Pakkanen <jpakkane@gmail.com>
Igor Gnatenko 57d01a
Date: Sun, 9 Oct 2016 05:29:11 -0400
Igor Gnatenko 57d01a
Subject: [PATCH 11/16] Created path_join function.
Igor Gnatenko 57d01a
Igor Gnatenko 57d01a
(cherry picked from commit c2b852c9b392059cba933b0787c1c7880af5e1ae)
Igor Gnatenko 57d01a
---
Igor Gnatenko 57d01a
 mesonbuild/interpreter.py                  | 10 ++++++++++
Igor Gnatenko 57d01a
 test cases/common/119 pathjoin/meson.build |  9 +++++++++
Igor Gnatenko 57d01a
 2 files changed, 19 insertions(+)
Igor Gnatenko 57d01a
 create mode 100644 test cases/common/119 pathjoin/meson.build
Igor Gnatenko 57d01a
Igor Gnatenko 57d01a
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
Igor Gnatenko 57d01a
index b3bb1f2..be19bab 100644
Igor Gnatenko 57d01a
--- a/mesonbuild/interpreter.py
Igor Gnatenko 57d01a
+++ b/mesonbuild/interpreter.py
Igor Gnatenko 57d01a
@@ -1196,6 +1196,7 @@ class Interpreter():
Igor Gnatenko 57d01a
                       'declare_dependency': self.func_declare_dependency,
Igor Gnatenko 57d01a
                       'assert': self.func_assert,
Igor Gnatenko 57d01a
                       'environment' : self.func_environment,
Igor Gnatenko 57d01a
+                      'path_join' : self.func_path_join,
Igor Gnatenko 57d01a
                      }
Igor Gnatenko 57d01a
 
Igor Gnatenko 57d01a
     def parse_project(self):
Igor Gnatenko 57d01a
@@ -2237,6 +2238,15 @@ class Interpreter():
Igor Gnatenko 57d01a
     def func_environment(self, node, args, kwargs):
Igor Gnatenko 57d01a
         return EnvironmentVariablesHolder()
Igor Gnatenko 57d01a
 
Igor Gnatenko 57d01a
+    @stringArgs
Igor Gnatenko 57d01a
+    @noKwargs
Igor Gnatenko 57d01a
+    def func_path_join(self, node, args, kwargs):
Igor Gnatenko 57d01a
+        if isinstance(args, str):
Igor Gnatenko 57d01a
+            st = (args,)
Igor Gnatenko 57d01a
+        else:
Igor Gnatenko 57d01a
+            st = tuple(args)
Igor Gnatenko 57d01a
+        return os.path.join(*args).replace('\\', '/')
Igor Gnatenko 57d01a
+
Igor Gnatenko 57d01a
     def flatten(self, args):
Igor Gnatenko 57d01a
         if isinstance(args, mparser.StringNode):
Igor Gnatenko 57d01a
             return args.value
Igor Gnatenko 57d01a
diff --git a/test cases/common/119 pathjoin/meson.build b/test cases/common/119 pathjoin/meson.build
Igor Gnatenko 57d01a
new file mode 100644
Igor Gnatenko 57d01a
index 0000000..dd1cf9c
Igor Gnatenko 57d01a
--- /dev/null
Igor Gnatenko 57d01a
+++ b/test cases/common/119 pathjoin/meson.build	
Igor Gnatenko 57d01a
@@ -0,0 +1,9 @@
Igor Gnatenko 57d01a
+project('pathjoin', 'c')
Igor Gnatenko 57d01a
+
Igor Gnatenko 57d01a
+assert(path_join('foo') == 'foo', 'Single argument join is broken')
Igor Gnatenko 57d01a
+assert(path_join('foo', 'bar') == 'foo/bar', 'Path joining is broken')
Igor Gnatenko 57d01a
+assert(path_join('foo', 'bar', 'baz') == 'foo/bar/baz', 'Path joining is broken')
Igor Gnatenko 57d01a
+assert(path_join('/foo', 'bar') == '/foo/bar', 'Path joining is broken')
Igor Gnatenko 57d01a
+assert(path_join('foo', '/bar') == '/bar', 'Absolute path joining is broken')
Igor Gnatenko 57d01a
+assert(path_join('/foo', '/bar') == '/bar', 'Absolute path joining is broken')
Igor Gnatenko 57d01a
+
Igor Gnatenko 57d01a
-- 
Igor Gnatenko 57d01a
2.10.1
Igor Gnatenko 57d01a