Allow different directories for Vala files

pull/2413/head
Corentin Noël 7 years ago
parent ae532c807c
commit ac8d5f2156
  1. 10
      mesonbuild/backend/ninjabackend.py
  2. 5
      test cases/vala/22 same target in directories/Subdir/Test.vala
  3. 5
      test cases/vala/22 same target in directories/Test.vala
  4. 11
      test cases/vala/22 same target in directories/meson.build
  5. 9
      test cases/vala/22 same target in directories/prog.vala

@ -1131,9 +1131,14 @@ 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:
realpath = os.path.abspath(os.path.join(self.environment.get_build_dir(), vala_file))
if (realpath.startswith(os.path.join(self.environment.get_source_dir(), target.get_subdir()))):
relpath = os.path.relpath(realpath, os.path.join(self.environment.get_source_dir(), target.get_subdir()))
vala_c_file = os.path.join(os.path.dirname(relpath), os.path.splitext(os.path.basename(vala_file))[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 +1150,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]

@ -0,0 +1,5 @@
public class Subdir.Test : GLib.Object {
construct {
stdout.printf("Test from subdir.\n");
}
}

@ -0,0 +1,5 @@
public class Test : GLib.Object {
construct {
stdout.printf("Test from main directory.\n");
}
}

@ -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)

@ -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;
}
}
Loading…
Cancel
Save