aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/build.py2
-rw-r--r--mesonbuild/interpreter.py9
-rw-r--r--test cases/failing/53 slashname/meson.build12
-rw-r--r--test cases/failing/53 slashname/sub/meson.build2
-rw-r--r--test cases/failing/53 slashname/sub/prog.c6
5 files changed, 30 insertions, 1 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 8163bca..2426417 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -270,6 +270,8 @@ class EnvironmentVariables:
class Target:
def __init__(self, name, subdir, build_by_default):
+ if '/' in name or '\\' in name:
+ raise InvalidArguments('Target name must not contain a path separator.')
self.name = name
self.subdir = subdir
self.build_by_default = build_by_default
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 948a6d4..63725ab 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2593,7 +2593,14 @@ different subdirectory.
else:
mlog.debug('Unknown target type:', str(targetholder))
raise RuntimeError('Unreachable code')
- target = targetclass(name, self.subdir, self.subproject, is_cross, sources, objs, self.environment, kwargs)
+ # Fix failing test 53 when removing this.
+ if '/' in name or '\\' in name:
+ mlog.warning('Target name must not contain a path separator. This will become a hard error in a future release.')
+ subpart, name = os.path.split(name)
+ subdir = os.path.join(self.subdir, subpart)
+ else:
+ subdir = self.subdir
+ target = targetclass(name, subdir, self.subproject, is_cross, sources, objs, self.environment, kwargs)
if is_cross:
self.add_cross_stdlib_info(target)
l = targetholder(target, self)
diff --git a/test cases/failing/53 slashname/meson.build b/test cases/failing/53 slashname/meson.build
new file mode 100644
index 0000000..bba5301
--- /dev/null
+++ b/test cases/failing/53 slashname/meson.build
@@ -0,0 +1,12 @@
+project('slashname', 'c')
+
+# Traverse this subdir so the corresponding dir
+# is created inside the build dir.
+subdir('sub')
+
+# Try to create an executable that would go in the "sub" dir
+# inside the build dir. This is prohibited.
+executable('sub/prog', pf)
+
+error('Re-enable me once slash in name is finally prohibited.')
+
diff --git a/test cases/failing/53 slashname/sub/meson.build b/test cases/failing/53 slashname/sub/meson.build
new file mode 100644
index 0000000..e104890
--- /dev/null
+++ b/test cases/failing/53 slashname/sub/meson.build
@@ -0,0 +1,2 @@
+pf = files('prog.c')
+
diff --git a/test cases/failing/53 slashname/sub/prog.c b/test cases/failing/53 slashname/sub/prog.c
new file mode 100644
index 0000000..722de0a
--- /dev/null
+++ b/test cases/failing/53 slashname/sub/prog.c
@@ -0,0 +1,6 @@
+#include<stdio.h>
+
+int main(int argc, char **argv) {
+ printf("I should not be run ever.\n");
+ return 1;
+}