Can now generate GObject introspection data and install it.

pull/15/head
Jussi Pakkanen 11 years ago
parent 0c853a7038
commit 8467c5b0a6
  1. 11
      build.py
  2. 13
      ninjabackend.py
  3. 7
      test cases/common/56 custom target/meson.build
  4. 1
      test cases/frameworks/7 gir/installed_files.txt
  5. 26
      test cases/frameworks/7 gir/meson.build
  6. 17
      test cases/frameworks/7 gir/prog.c

@ -569,10 +569,12 @@ class CustomTarget:
self.subdir = subdir
self.dependencies = []
self.process_kwargs(kwargs)
self.sources = []
self.extra_files = []
def process_kwargs(self, kwargs):
self.sources = kwargs.get('input', [])
if not isinstance(self.sources, list):
self.sources = [self.sources]
if 'output' not in kwargs:
raise InvalidArguments('Missing keyword argument "output".')
self.output = kwargs['output']
@ -598,6 +600,13 @@ class CustomTarget:
elif isinstance(c, BuildTarget) or isinstance(c, CustomTarget):
self.dependencies.append(c)
final_cmd.append(os.path.join(c.get_subdir(), c.get_filename()))
elif isinstance(c, list):
# Hackety hack, only supports one level of flattening. Should really
# work to arbtrary depth.
for s in c:
if not isinstance(s, str):
raise InvalidArguments('Array as argument %d contains a non-string.' % i)
final_cmd.append(s)
else:
raise InvalidArguments('Argument %s in "command" is invalid.' % i)
self.command = final_cmd

@ -137,8 +137,19 @@ class NinjaBackend(backends.Backend):
def generate_custom_target(self, target, outfile):
ofilename = os.path.join(target.subdir, target.output)
deps = [os.path.join(i.get_subdir(), i.get_filename()) for i in target.get_dependencies()]
srcs = [os.path.join(self.build_to_src, i) for i in target.sources]
deps += srcs
elem = NinjaBuildElement(ofilename, 'CUSTOM_COMMAND', deps)
elem.add_item('COMMAND', target.command)
cmd = []
for i in target.command:
if i == '@INPUT@':
cmd += srcs
elif i == '@OUTPUT@':
cmd.append(ofilename)
else:
cmd.append(i)
elem.add_item('COMMAND', cmd)
elem.add_item('description', 'Generating %s with a custom command.' % ofilename)
elem.write(outfile)
self.processed_targets[target.name] = True

@ -2,13 +2,14 @@ project('custom target', 'c')
python = find_program('python3')
# Note that this will not add a depencency to the compiler executable.
# Code will not be rebuilt if it changes.
comp = '@0@/@1@'.format(meson.current_source_dir(), 'my_compiler.py')
infile = '@0@/@1@'.format(meson.current_source_dir(), 'data_source.txt')
outfile = '@0@/@1@'.format(meson.current_build_dir(), 'data.dat')
mytarget = custom_target('bindat',
output : 'data.dat',
command : [python, comp, infile, outfile],
input : 'data_source.txt',
command : [python, comp, '@INPUT@', '@OUTPUT@'],
install : true,
install_dir : 'subdir'
)

@ -0,0 +1 @@
typelibdir/Meson-1.0.typelib

@ -2,10 +2,34 @@ project('gobject-introspection', 'c')
glib = dependency('glib-2.0')
gobj = dependency('gobject-2.0')
gir = dependency('gobject-introspection-1.0')
gmod = dependency('gmodule-2.0')
girscan = find_program('g-ir-scanner')
girc = find_program('g-ir-compiler')
libsources = ['golib.c', 'golib.h']
exe = executable('goprog', libsources, 'prog.c',
deps : [glib, gobj])
deps : [glib, gobj, gir, gmod])
test('gobjtest', exe)
# Let's create Gir data with custom targets to prove that
# Meson's syntax is expressive enough.
r = run_command('pkg-config', '--cflags', 'gobject-introspection-1.0')
custom_gir_args = r.stdout().strip().split()
golibgir = custom_target('golibgir',
output : 'Meson-1.0.gir',
input : libsources,
command : [girscan, '@INPUT@', '--program', exe, custom_gir_args, '--include=GObject-2.0',
'--namespace=Meson', '--nsversion=1.0', '--output', '@OUTPUT@'],
)
custom_target('golibtypelib',
output : 'Meson-1.0.typelib',
command : [girc, golibgir,'--output', '@OUTPUT@'],
install : true,
install_dir : 'typelibdir'
)

@ -1,11 +1,20 @@
#include<glib.h>
#include<glib-object.h>
#include"golib.h"
int main (int argc, char *argv[])
{
#include<girepository.h>
int main(int argc, char *argv[]) {
GOptionContext *ctx;
GError *error = NULL;
MesonSample *i;
ctx = g_option_context_new(NULL);
g_option_context_add_group(ctx, g_irepository_get_option_group ());
if (!g_option_context_parse(ctx, &argc, &argv, &error)) {
g_print("sample: %s\n", error->message);
return 1;
}
i = meson_sample_new();
meson_sample_func(i);
g_object_unref(G_OBJECT(i));

Loading…
Cancel
Save