vala: Fix shared_module linking with export_dynamic executable

Need to generate a vapi and a header, and then use that in the shared
module. Needed for GNOME games.

Closes https://github.com/mesonbuild/meson/issues/3538
0.46
Nirbheek Chauhan 7 years ago
parent 987c1cd70a
commit d1e8ae19e6
  1. 4
      mesonbuild/backend/ninjabackend.py
  2. 2
      mesonbuild/build.py
  3. 21
      test cases/vala/24 export dynamic shared module/app.vala
  4. 20
      test cases/vala/24 export dynamic shared module/meson.build
  5. 3
      test cases/vala/24 export dynamic shared module/module.vala

@ -1056,6 +1056,8 @@ int dummy;
""" """
result = OrderedSet() result = OrderedSet()
for dep in itertools.chain(target.link_targets, target.link_whole_targets): for dep in itertools.chain(target.link_targets, target.link_whole_targets):
if not dep.is_linkable_target():
continue
for i in dep.sources: for i in dep.sources:
if hasattr(i, 'fname'): if hasattr(i, 'fname'):
i = i.fname i = i.fname
@ -1178,7 +1180,7 @@ int dummy;
# found inside the build tree (generated sources). # found inside the build tree (generated sources).
args += ['--directory', c_out_dir] args += ['--directory', c_out_dir]
args += ['--basedir', srcbasedir] args += ['--basedir', srcbasedir]
if not isinstance(target, build.Executable): if target.is_linkable_target():
# Library name # Library name
args += ['--library', target.name] args += ['--library', target.name]
# Outputted header # Outputted header

@ -698,7 +698,7 @@ just like those detected with the dependency() function.''')
for key, value in compiler_args.items(): for key, value in compiler_args.items():
self.add_compiler_args(key, value) self.add_compiler_args(key, value)
if not isinstance(self, Executable): if not isinstance(self, Executable) or 'export_dynamic' in kwargs:
self.vala_header = kwargs.get('vala_header', self.name + '.h') self.vala_header = kwargs.get('vala_header', self.name + '.h')
self.vala_vapi = kwargs.get('vala_vapi', self.name + '.vapi') self.vala_vapi = kwargs.get('vala_vapi', self.name + '.vapi')
self.vala_gir = kwargs.get('vala_gir', None) self.vala_gir = kwargs.get('vala_gir', None)

@ -0,0 +1,21 @@
const string MODULE_LIB = "libapp_module.so";
delegate int ModuleFunc ();
public int app_func () {
return 41;
}
int main () {
Module module;
void *func;
unowned ModuleFunc mfunc;
module = Module.open (MODULE_LIB, ModuleFlags.BIND_LAZY);
module.symbol ("module_func", out func);
mfunc = (ModuleFunc) func;
print ("%d\n", mfunc ());
return 0;
}

@ -0,0 +1,20 @@
project ('test', ['c', 'vala'], version: '0.1')
deps = [
dependency ('glib-2.0'),
dependency ('gmodule-2.0'),
]
app = executable (
'app',
['app.vala'],
dependencies: deps,
export_dynamic: true
)
shared_module (
'app_module',
['module.vala'],
link_with: app,
dependencies : deps,
)

@ -0,0 +1,3 @@
public int module_func () {
return app_func() + 1;
}
Loading…
Cancel
Save