aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/backend/ninjabackend.py9
-rw-r--r--test cases/vala/22 same target in directories/Subdir/Test.vala5
-rw-r--r--test cases/vala/22 same target in directories/Test.vala5
-rw-r--r--test cases/vala/22 same target in directories/meson.build11
-rw-r--r--test cases/vala/22 same target in directories/prog.vala9
5 files changed, 37 insertions, 2 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 2e6e351..5d02991 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1131,9 +1131,13 @@ int dummy;
# file is outside the build directory, the path components will be
# stripped and just the basename will be used.
if isinstance(gensrc, (build.CustomTarget, build.GeneratedList)) or gensrc.is_built:
- vala_c_file = os.path.splitext(vala_file)[0] + '.c'
- else:
vala_c_file = os.path.splitext(os.path.basename(vala_file))[0] + '.c'
+ else:
+ path_to_target = os.path.join(self.build_to_src, target.get_subdir())
+ if vala_file.startswith(path_to_target):
+ vala_c_file = os.path.splitext(os.path.relpath(vala_file, path_to_target))[0] + '.c'
+ else:
+ vala_c_file = os.path.splitext(os.path.basename(vala_file))[0] + '.c'
# All this will be placed inside the c_out_dir
vala_c_file = os.path.join(c_out_dir, vala_c_file)
vala_c_src.append(vala_c_file)
@@ -1145,6 +1149,7 @@ int dummy;
# means it will also preserve the directory components of Vala sources
# found inside the build tree (generated sources).
args += ['-d', c_out_dir]
+ args += ['-b', os.path.join(self.environment.get_source_dir(), target.get_subdir())]
if not isinstance(target, build.Executable):
# Library name
args += ['--library=' + target.name]
diff --git a/test cases/vala/22 same target in directories/Subdir/Test.vala b/test cases/vala/22 same target in directories/Subdir/Test.vala
new file mode 100644
index 0000000..3a311f4
--- /dev/null
+++ b/test cases/vala/22 same target in directories/Subdir/Test.vala
@@ -0,0 +1,5 @@
+public class Subdir.Test : GLib.Object {
+ construct {
+ stdout.printf("Test from subdir.\n");
+ }
+}
diff --git a/test cases/vala/22 same target in directories/Test.vala b/test cases/vala/22 same target in directories/Test.vala
new file mode 100644
index 0000000..1b57dd9
--- /dev/null
+++ b/test cases/vala/22 same target in directories/Test.vala
@@ -0,0 +1,5 @@
+public class Test : GLib.Object {
+ construct {
+ stdout.printf("Test from main directory.\n");
+ }
+}
diff --git a/test cases/vala/22 same target in directories/meson.build b/test cases/vala/22 same target in directories/meson.build
new file mode 100644
index 0000000..144e310
--- /dev/null
+++ b/test cases/vala/22 same target in directories/meson.build
@@ -0,0 +1,11 @@
+project('valatest', 'vala', 'c')
+
+valadeps = [dependency('glib-2.0'), dependency('gobject-2.0')]
+valafiles = files(
+ 'prog.vala',
+ 'Test.vala',
+ 'Subdir/Test.vala'
+)
+
+e = executable('multidir_prog', valafiles, dependencies : valadeps)
+test('valatest', e)
diff --git a/test cases/vala/22 same target in directories/prog.vala b/test cases/vala/22 same target in directories/prog.vala
new file mode 100644
index 0000000..f3ac099
--- /dev/null
+++ b/test cases/vala/22 same target in directories/prog.vala
@@ -0,0 +1,9 @@
+class MainProg : GLib.Object {
+
+ public static int main(string[] args) {
+ var test1 = new Test ();
+ var test2 = new Subdir.Test ();
+ stdout.printf("Vala is working.\n");
+ return 0;
+ }
+}