aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends.py5
-rw-r--r--data/macros.meson (renamed from macros.meson)0
-rwxr-xr-xinstall_meson.py17
-rw-r--r--interpreter.py9
-rw-r--r--man/mesonintrospect.135
-rw-r--r--manual tests/5 rpm/meson.build1
-rwxr-xr-xmeson_test.py3
-rw-r--r--modules/gnome.py34
-rw-r--r--modules/rpm.py12
-rw-r--r--test cases/common/75 should fail/failing.c3
-rw-r--r--test cases/common/75 should fail/meson.build4
-rw-r--r--test cases/frameworks/7 gnome/gir/golib.h4
-rw-r--r--test cases/frameworks/7 gnome/gir/meson.build4
-rw-r--r--test cases/frameworks/7 gnome/installed_files.txt3
-rw-r--r--test cases/frameworks/7 gnome/meson.build1
15 files changed, 118 insertions, 17 deletions
diff --git a/backends.py b/backends.py
index f00e76c..cb59453 100644
--- a/backends.py
+++ b/backends.py
@@ -87,7 +87,7 @@ def do_conf_file(src, dst, confdata):
class TestSerialisation:
def __init__(self, name, fname, is_cross, exe_wrapper, is_parallel, cmd_args, env,
- valgrind_args):
+ should_fail, valgrind_args):
self.name = name
self.fname = fname
self.is_cross = is_cross
@@ -95,6 +95,7 @@ class TestSerialisation:
self.is_parallel = is_parallel
self.cmd_args = cmd_args
self.env = env
+ self.should_fail = should_fail
self.valgrind_args = valgrind_args
# This class contains the basic functionality that is needed by all backends.
@@ -315,7 +316,7 @@ class Backend():
else:
exe_wrapper = None
ts = TestSerialisation(t.get_name(), fname, is_cross, exe_wrapper,
- t.is_parallel, t.cmd_args, t.env, t.valgrind_args)
+ t.is_parallel, t.cmd_args, t.env, t.should_fail, t.valgrind_args)
arr.append(ts)
pickle.dump(arr, datafile)
diff --git a/macros.meson b/data/macros.meson
index 42ad949..42ad949 100644
--- a/macros.meson
+++ b/data/macros.meson
diff --git a/install_meson.py b/install_meson.py
index 2c13046..672576b 100755
--- a/install_meson.py
+++ b/install_meson.py
@@ -44,9 +44,11 @@ bin_dir = os.path.join(install_root, 'bin')
bin_script = os.path.join(script_dir, 'meson.py')
gui_script = os.path.join(script_dir, 'mesongui.py')
conf_script = os.path.join(script_dir, 'mesonconf.py')
+intro_script = os.path.join(script_dir, 'mesonintrospect.py')
bin_name = os.path.join(bin_dir, 'meson')
gui_name = os.path.join(bin_dir, 'mesongui')
conf_name = os.path.join(bin_dir, 'mesonconf')
+intro_name = os.path.join(bin_dir, 'mesonintrospect')
man_dir = os.path.join(install_root, 'share/man/man1')
in_manfile = 'man/meson.1'
out_manfile = os.path.join(man_dir, 'meson.1.gz')
@@ -54,11 +56,14 @@ in_guimanfile = 'man/mesongui.1'
out_guimanfile = os.path.join(man_dir, 'mesongui.1.gz')
in_confmanfile = 'man/mesonconf.1'
out_confmanfile = os.path.join(man_dir, 'mesonconf.1.gz')
+in_intromanfile = 'man/mesonintrospect.1'
+out_intromanfile = os.path.join(man_dir, 'mesonintrospect.1.gz')
rpmmacros_dir = os.path.join(install_root, 'lib/rpm/macros.d')
symlink_value = os.path.relpath(bin_script, os.path.dirname(bin_name))
guisymlink_value = os.path.relpath(gui_script, os.path.dirname(gui_name))
confsymlink_value = os.path.relpath(conf_script, os.path.dirname(conf_name))
+introsymlink_value = os.path.relpath(intro_script, os.path.dirname(intro_name))
files = glob.glob('*.py')
files += glob.glob('*.ui')
@@ -79,7 +84,7 @@ try:
os.remove(bin_name)
except OSError:
pass
-print('Creating symlinks %s and %s.' % (bin_name, gui_name))
+print('Creating symlinks.')
try:
os.unlink(bin_name)
except FileNotFoundError:
@@ -92,13 +97,19 @@ try:
os.unlink(conf_name)
except FileNotFoundError:
pass
+try:
+ os.unlink(intro_name)
+except FileNotFoundError:
+ pass
os.symlink(symlink_value, bin_name)
os.symlink(guisymlink_value, gui_name)
os.symlink(confsymlink_value, conf_name)
+os.symlink(introsymlink_value, intro_name)
print('Installing manfiles to %s.' % man_dir)
open(out_manfile, 'wb').write(gzip.compress(open(in_manfile, 'rb').read()))
open(out_confmanfile, 'wb').write(gzip.compress(open(in_confmanfile, 'rb').read()))
open(out_guimanfile, 'wb').write(gzip.compress(open(in_guimanfile, 'rb').read()))
+open(out_intromanfile, 'wb').write(gzip.compress(open(in_intromanfile, 'rb').read()))
print('Installing modules to %s.' % module_dir)
if os.path.exists('modules/__pycache__'):
@@ -111,5 +122,5 @@ if os.path.exists('/usr/bin/rpm'):
print('Installing RPM macros to %s.' % rpmmacros_dir)
outfilename = os.path.join(rpmmacros_dir, 'macros.meson')
os.makedirs(rpmmacros_dir, exist_ok=True)
- shutil.copyfile('macros.meson', outfilename)
- shutil.copystat('macros.meson', outfilename)
+ shutil.copyfile('data/macros.meson', outfilename)
+ shutil.copystat('data/macros.meson', outfilename)
diff --git a/interpreter.py b/interpreter.py
index 9aae7a4..832233f 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -429,13 +429,14 @@ class RunTargetHolder(InterpreterObject):
self.held_object = build.RunTarget(name, command, args, subdir)
class Test(InterpreterObject):
- def __init__(self, name, exe, is_parallel, cmd_args, env, valgrind_args):
+ def __init__(self, name, exe, is_parallel, cmd_args, env, should_fail, valgrind_args):
InterpreterObject.__init__(self)
self.name = name
self.exe = exe
self.is_parallel = is_parallel
self.cmd_args = cmd_args
self.env = env
+ self.should_fail = should_fail
self.valgrind_args = valgrind_args
def get_exe(self):
@@ -622,6 +623,7 @@ class ModuleHolder(InterpreterObject):
state.headers = self.interpreter.build.get_headers()
state.man = self.interpreter.build.get_man()
state.pkgconfig_gens = self.interpreter.build.pkgconfig_gens
+ state.global_args = self.interpreter.build.global_args
value = fn(state, args, kwargs)
return self.interpreter.module_method_callback(value)
@@ -1310,7 +1312,10 @@ class Interpreter():
for a in valgrind_args:
if not isinstance(a, str):
raise InterpreterException('Valgrind_arg not a string.')
- t = Test(args[0], args[1].held_object, par, cmd_args, env, valgrind_args)
+ should_fail = kwargs.get('should_fail', False)
+ if not isinstance(should_fail, bool):
+ raise InterpreterException('Keyword argument should_fail must be a boolean.')
+ t = Test(args[0], args[1].held_object, par, cmd_args, env, should_fail, valgrind_args)
self.build.tests.append(t)
mlog.debug('Adding test "', mlog.bold(args[0]), '".', sep='')
diff --git a/man/mesonintrospect.1 b/man/mesonintrospect.1
new file mode 100644
index 0000000..85cc8c6
--- /dev/null
+++ b/man/mesonintrospect.1
@@ -0,0 +1,35 @@
+.TH MESONCONF "1" "April 2015" "mesonintrospect 0.23.0" "User Commands"
+.SH NAME
+mesonintrospect - a tool to extract information about a Meson build
+.SH DESCRIPTION
+
+Mesonintrospect is a tool designed to make it simple to integrate with
+other tools, such as IDEs. The output of this command is in JSON.
+
+.B mesonintrospect [
+.I build directory
+.B ] [
+.I option
+.B ]
+
+If build directory is omitted, the current directory is used instead.
+
+.SS "options:"
+.TP
+\fB\-\-targets\fR
+print all top level targets (executables, libraries, etc)
+.TP
+\fB\-\-target\-files\fR
+print the source files of the given target
+.TP
+\fB\-\-buildsystem\-files\fR
+print all files that make up the build system (meson.build, meson_options.txt etc)
+.TP
+\fB\-\-tests\fR
+print all unit tests
+.TP
+\fB\-\-help\fR
+print command line help
+
+.SH SEE ALSO
+https://jpakkane.github.io/meson/
diff --git a/manual tests/5 rpm/meson.build b/manual tests/5 rpm/meson.build
index ebbbdfd..131da39 100644
--- a/manual tests/5 rpm/meson.build
+++ b/manual tests/5 rpm/meson.build
@@ -2,6 +2,7 @@ project('test spec', 'c')
rpm = import('rpm')
dependency('zlib')
+find_program('nonexistprog', required : false)
lib = shared_library('mesontest_shared', ['lib.c', 'lib.h'],
version : '0.1', soversion : '0',
diff --git a/meson_test.py b/meson_test.py
index 533cd87..51a7db6 100755
--- a/meson_test.py
+++ b/meson_test.py
@@ -99,7 +99,8 @@ def run_single_test(wrap, test):
duration = endtime - starttime
stdo = stdo.decode()
stde = stde.decode()
- if p.returncode == 0:
+ if (not test.should_fail and p.returncode == 0) or \
+ (test.should_fail and p.returncode != 0):
res = 'OK'
else:
res = 'FAIL'
diff --git a/modules/gnome.py b/modules/gnome.py
index c0e391f..539ed27 100644
--- a/modules/gnome.py
+++ b/modules/gnome.py
@@ -58,19 +58,37 @@ class GnomeModule:
scan_name = girtarget.name + '-gir'
scan_command = ['g-ir-scanner', '@INPUT@', '--program', girtarget]
scan_command += pkgargs
- scan_command += ['--include=GObject-2.0', '--namespace='+ns,
- '--nsversion=' + nsversion, '--output', '@OUTPUT@']
+ scan_command += ['--namespace='+ns, '--nsversion=' + nsversion,
+ '--output', '@OUTPUT@']
+ if 'includes' in kwargs:
+ includes = kwargs.pop('includes')
+ if isinstance(includes, str):
+ scan_command += ['--include=%s' % includes]
+ elif isinstance(includes, list):
+ scan_command += ['--include=%s' % inc for inc in includes]
+ else:
+ raise MesonException('Gir includes must be str or list')
+ if state.global_args.get('c'):
+ scan_command += ['--cflags-begin']
+ scan_command += state.global_args['c']
+ scan_command += ['--cflags-end']
scankwargs = {'output' : girfile,
'input' : libsources,
'command' : scan_command}
- scan_target = build.CustomTarget(scan_name, state.subdir, scankwargs)
+ if kwargs.get('install'):
+ scankwargs['install'] = kwargs['install']
+ scankwargs['install_dir'] = os.path.join(state.environment.get_datadir(), 'gir-1.0')
+ scan_target = GirTarget(scan_name, state.subdir, scankwargs)
typelib_name = girtarget.name + '-typelib'
typelib_output = '%s-%s.typelib' % (ns, nsversion)
typelib_cmd = ['g-ir-compiler', scan_target, '--output', '@OUTPUT@']
kwargs['output'] = typelib_output
kwargs['command'] = typelib_cmd
- typelib_target = build.CustomTarget(typelib_name, state.subdir, kwargs)
+ # Note that this can't be libdir, because e.g. on Debian it points to
+ # lib/x86_64-linux-gnu but the girepo dir is always under lib.
+ kwargs['install_dir'] = 'lib/girepository-1.0'
+ typelib_target = TypelibTarget(typelib_name, state.subdir, kwargs)
return [scan_target, typelib_target]
def compile_schemas(self, state, args, kwargs):
@@ -111,3 +129,11 @@ def initialize():
mlog.log('Warning, glib compiled dependencies will not work until this upstream issue is fixed:',
mlog.bold('https://bugzilla.gnome.org/show_bug.cgi?id=745754'))
return GnomeModule()
+
+class GirTarget(build.CustomTarget):
+ def __init__(self, name, subdir, kwargs):
+ super().__init__(name, subdir, kwargs)
+
+class TypelibTarget(build.CustomTarget):
+ def __init__(self, name, subdir, kwargs):
+ super().__init__(name, subdir, kwargs)
diff --git a/modules/rpm.py b/modules/rpm.py
index 9222f05..01c50ce 100644
--- a/modules/rpm.py
+++ b/modules/rpm.py
@@ -19,6 +19,7 @@ import build
import compilers
import datetime
import mlog
+import modules.gnome
import os
class RPMModule:
@@ -62,6 +63,10 @@ class RPMModule:
to_delete.add('%%{buildroot}%%{_libdir}/%s' % target.get_filename())
mlog.log('Warning, removing', mlog.bold(target.get_filename()),
'from package because packaging static libs not recommended')
+ elif isinstance(target, modules.gnome.GirTarget) and target.should_install():
+ files_devel.add('%%{_datadir}/gir-1.0/%s' % target.get_filename()[0])
+ elif isinstance(target, modules.gnome.TypelibTarget) and target.should_install():
+ files.add('%%{_libdir}/girepository-1.0/%s' % target.get_filename()[0])
for header in state.headers:
if len(header.get_install_subdir()) > 0:
files_devel.add('%%{_includedir}/%s/' % header.get_install_subdir())
@@ -94,7 +99,10 @@ class RPMModule:
'You can use following command to find package which contains this lib:',
mlog.bold('dnf provides %s' % lib.fullpath))
for prog in state.environment.coredata.ext_progs.values():
- fn.write('BuildRequires: %s\n' % ' '.join(prog.fullpath))
+ if not prog.found():
+ fn.write('BuildRequires: /usr/bin/%s # FIXME\n' % prog.get_name())
+ else:
+ fn.write('BuildRequires: %s\n' % ' '.join(prog.fullpath))
fn.write('BuildRequires: meson\n')
fn.write('\n')
fn.write('%description\n')
@@ -148,7 +156,7 @@ class RPMModule:
fn.write('- \n')
fn.write('\n')
fn.close()
- mlog.log('Please, look at RPM spec file and fix FIXME\'s')
+ mlog.log('RPM spec template written to %s.spec.\n' % proj)
def initialize():
return RPMModule()
diff --git a/test cases/common/75 should fail/failing.c b/test cases/common/75 should fail/failing.c
new file mode 100644
index 0000000..adada8d
--- /dev/null
+++ b/test cases/common/75 should fail/failing.c
@@ -0,0 +1,3 @@
+int main(int argc, char **argv) {
+ return 1;
+}
diff --git a/test cases/common/75 should fail/meson.build b/test cases/common/75 should fail/meson.build
new file mode 100644
index 0000000..dffbbb3
--- /dev/null
+++ b/test cases/common/75 should fail/meson.build
@@ -0,0 +1,4 @@
+project('should fail', 'c')
+
+exe = executable('prog', 'failing.c')
+test('failing', exe, should_fail : true)
diff --git a/test cases/frameworks/7 gnome/gir/golib.h b/test cases/frameworks/7 gnome/gir/golib.h
index 40bf901..272d65c 100644
--- a/test cases/frameworks/7 gnome/gir/golib.h
+++ b/test cases/frameworks/7 gnome/gir/golib.h
@@ -1,6 +1,10 @@
#ifndef GOLIB_H
#define GOLIB_H
+#if !defined (MESON_TEST)
+#error "MESON_TEST not defined."
+#endif
+
#include <glib.h>
#include <glib-object.h>
diff --git a/test cases/frameworks/7 gnome/gir/meson.build b/test cases/frameworks/7 gnome/gir/meson.build
index 115631e..f4b118d 100644
--- a/test cases/frameworks/7 gnome/gir/meson.build
+++ b/test cases/frameworks/7 gnome/gir/meson.build
@@ -8,8 +8,8 @@ gnome.generate_gir(girexe,
sources : libsources,
nsversion : '1.0',
namespace : 'Meson',
-install : true,
-install_dir : 'typelibdir',
+includes : ['GObject-2.0', 'Gio-2.0'],
+install : true
)
test('gobject introspection', girexe)
diff --git a/test cases/frameworks/7 gnome/installed_files.txt b/test cases/frameworks/7 gnome/installed_files.txt
index 019b81a..8464839 100644
--- a/test cases/frameworks/7 gnome/installed_files.txt
+++ b/test cases/frameworks/7 gnome/installed_files.txt
@@ -1,2 +1,3 @@
-usr/typelibdir/Meson-1.0.typelib
+usr/lib/girepository-1.0/Meson-1.0.typelib
+usr/share/gir-1.0/Meson-1.0.gir
usr/share/glib-2.0/schemas/com.github.meson.gschema.xml
diff --git a/test cases/frameworks/7 gnome/meson.build b/test cases/frameworks/7 gnome/meson.build
index ceddb5e..6afe508 100644
--- a/test cases/frameworks/7 gnome/meson.build
+++ b/test cases/frameworks/7 gnome/meson.build
@@ -7,6 +7,7 @@ glib = dependency('glib-2.0')
gobj = dependency('gobject-2.0')
gir = dependency('gobject-introspection-1.0')
gmod = dependency('gmodule-2.0')
+add_global_arguments('-DMESON_TEST', language : 'c')
subdir('resources')
subdir('gir')