Merge pull request #1194 from centricular/critical-bugfixes-vala
A bunch of bugfixes for Valapull/1191/merge
commit
21e475b64b
25 changed files with 331 additions and 49 deletions
@ -0,0 +1,34 @@ |
|||||||
|
from .. import build |
||||||
|
from .. import dependencies |
||||||
|
|
||||||
|
_found_programs = {} |
||||||
|
|
||||||
|
def find_program(program_name, target_name): |
||||||
|
if program_name in _found_programs: |
||||||
|
return _found_programs[program_name] |
||||||
|
program = dependencies.ExternalProgram(program_name) |
||||||
|
if not program.found(): |
||||||
|
m = "Target {!r} can't be generated as {!r} could not be found" |
||||||
|
raise MesonException(m.format(target_name, program_name)) |
||||||
|
_found_programs[program_name] = program |
||||||
|
return program |
||||||
|
|
||||||
|
class GResourceTarget(build.CustomTarget): |
||||||
|
def __init__(self, name, subdir, kwargs): |
||||||
|
super().__init__(name, subdir, kwargs) |
||||||
|
|
||||||
|
class GResourceHeaderTarget(build.CustomTarget): |
||||||
|
def __init__(self, name, subdir, kwargs): |
||||||
|
super().__init__(name, subdir, kwargs) |
||||||
|
|
||||||
|
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) |
||||||
|
|
||||||
|
class VapiTarget(build.CustomTarget): |
||||||
|
def __init__(self, name, subdir, kwargs): |
||||||
|
super().__init__(name, subdir, kwargs) |
@ -0,0 +1,3 @@ |
|||||||
|
res = gnome.compile_resources('testui', |
||||||
|
'test-resources.xml', |
||||||
|
source_dir : '.') |
@ -0,0 +1,6 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<gresources> |
||||||
|
<gresource prefix="/org/Meson"> |
||||||
|
<file compressed="true" preprocess="xml-stripblanks">test.ui</file> |
||||||
|
</gresource> |
||||||
|
</gresources> |
@ -0,0 +1,19 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<interface> |
||||||
|
<!-- interface-requires gtk+ 3.8 --> |
||||||
|
<template class="TestWidget" parent="GtkBox"> |
||||||
|
<property name="visible">True</property> |
||||||
|
<property name="can_focus">False</property> |
||||||
|
<property name="orientation">vertical</property> |
||||||
|
<property name="spacing">4</property> |
||||||
|
<child> |
||||||
|
<object class="GtkEntry" id="entry"> |
||||||
|
<property name="visible">True</property> |
||||||
|
<property name="can_focus">True</property> |
||||||
|
</object> |
||||||
|
<packing> |
||||||
|
<property name="position">0</property> |
||||||
|
</packing> |
||||||
|
</child> |
||||||
|
</template> |
||||||
|
</interface> |
@ -0,0 +1,12 @@ |
|||||||
|
project('test glib target version and gresources', 'c', 'vala') |
||||||
|
|
||||||
|
gnome = import('gnome') |
||||||
|
|
||||||
|
glib = dependency('glib-2.0', version : '>=2.38') |
||||||
|
gtk = dependency('gtk+-3.0') |
||||||
|
|
||||||
|
subdir('gres') |
||||||
|
|
||||||
|
e = executable('gtktemplate', 'test.vala', res, dependencies : [glib, gtk]) |
||||||
|
# No X on the CI, so disable this for now |
||||||
|
#test('test-target-glib', e) |
@ -0,0 +1,37 @@ |
|||||||
|
using Gtk; |
||||||
|
using GLib; |
||||||
|
|
||||||
|
[GtkTemplate (ui = "/org/Meson/test.ui")] |
||||||
|
public class TestWidget : Box { |
||||||
|
public string text { |
||||||
|
get { return entry.text; } |
||||||
|
set { entry.text = value; } |
||||||
|
} |
||||||
|
|
||||||
|
[GtkChild] |
||||||
|
private Entry entry; |
||||||
|
|
||||||
|
public TestWidget (string text) { |
||||||
|
this.text = text; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void main(string[] args) { |
||||||
|
Gtk.init (ref args); |
||||||
|
var win = new Window(); |
||||||
|
win.destroy.connect (Gtk.main_quit); |
||||||
|
|
||||||
|
var widget = new TestWidget ("SOME TEXT HERE"); |
||||||
|
|
||||||
|
win.add (widget); |
||||||
|
win.show_all (); |
||||||
|
|
||||||
|
/* Exit immediately */ |
||||||
|
Timeout.add_full (Priority.DEFAULT_IDLE, 1, () => |
||||||
|
{ |
||||||
|
Gtk.main_quit(); |
||||||
|
return false; |
||||||
|
}); |
||||||
|
|
||||||
|
Gtk.main (); |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
project('static vapi', 'c', 'vala') |
||||||
|
|
||||||
|
glib = dependency('glib-2.0') |
||||||
|
|
||||||
|
conf = configuration_data() |
||||||
|
conf.set_quoted('VERSION', '1.0.0') |
||||||
|
config_h = configure_file(output : 'config.h', |
||||||
|
configuration : conf) |
||||||
|
|
||||||
|
e = executable('static-vapi', 'vapi/config.vapi', 'test.vala', |
||||||
|
dependencies : glib) |
||||||
|
|
||||||
|
test('test-config', e) |
@ -0,0 +1,6 @@ |
|||||||
|
using GLib; |
||||||
|
using Config; |
||||||
|
|
||||||
|
public int main (string[] args) { |
||||||
|
return GLib.strcmp(VERSION, "1.0.0"); |
||||||
|
} |
@ -0,0 +1,4 @@ |
|||||||
|
[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")] |
||||||
|
namespace Config { |
||||||
|
public const string VERSION; |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
/*** BEGIN file-header ***/ |
||||||
|
|
||||||
|
#include "enum-types.h" |
||||||
|
|
||||||
|
/*** END file-header ***/ |
||||||
|
|
||||||
|
/*** BEGIN file-production ***/ |
||||||
|
/* enumerations from "@filename@" */ |
||||||
|
#include "@filename@" |
||||||
|
/*** END file-production ***/ |
||||||
|
|
||||||
|
|
||||||
|
/*** BEGIN value-header ***/ |
||||||
|
GType |
||||||
|
@enum_name@_get_type (void) |
||||||
|
{ |
||||||
|
static volatile gsize g_define_type_id__volatile = 0; |
||||||
|
|
||||||
|
if (g_once_init_enter (&g_define_type_id__volatile)) { |
||||||
|
static const G@Type@Value values[] = { |
||||||
|
/*** END value-header ***/ |
||||||
|
|
||||||
|
/*** BEGIN value-production ***/ |
||||||
|
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" }, |
||||||
|
/*** END value-production ***/ |
||||||
|
|
||||||
|
/*** BEGIN value-tail ***/ |
||||||
|
{ 0, NULL, NULL } |
||||||
|
}; |
||||||
|
GType g_define_type_id = |
||||||
|
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); |
||||||
|
|
||||||
|
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); |
||||||
|
} |
||||||
|
|
||||||
|
return g_define_type_id__volatile; |
||||||
|
} |
||||||
|
|
||||||
|
/*** END value-tail ***/ |
||||||
|
|
||||||
|
/*** BEGIN file-tail ***/ |
||||||
|
|
||||||
|
/*** END file-tail ***/ |
@ -0,0 +1,26 @@ |
|||||||
|
/*** BEGIN file-header ***/ |
||||||
|
|
||||||
|
#ifndef __EXAMPLE_ENUMS_TYPES_H__ |
||||||
|
#define __EXAMPLE_ENUMS_TYPES_H__ |
||||||
|
|
||||||
|
#include <glib-object.h> |
||||||
|
#include "enums.h" |
||||||
|
|
||||||
|
G_BEGIN_DECLS |
||||||
|
/*** END file-header ***/ |
||||||
|
|
||||||
|
/*** BEGIN file-production ***/ |
||||||
|
|
||||||
|
/* enumerations from "@filename@" */ |
||||||
|
/*** END file-production ***/ |
||||||
|
|
||||||
|
/*** BEGIN value-header ***/ |
||||||
|
GType @enum_name@_get_type (void) G_GNUC_CONST; |
||||||
|
#define EXAMPLE_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) |
||||||
|
/*** END value-header ***/ |
||||||
|
|
||||||
|
/*** BEGIN file-tail ***/ |
||||||
|
G_END_DECLS |
||||||
|
|
||||||
|
#endif /* __EXAMPLE_ENUMS_TYPES_H__ */ |
||||||
|
/*** END file-tail ***/ |
@ -0,0 +1,15 @@ |
|||||||
|
#ifndef __EXAMPLE_ENUMS_H__ |
||||||
|
#define __EXAMPLE_ENUMS_H__ |
||||||
|
|
||||||
|
G_BEGIN_DECLS |
||||||
|
|
||||||
|
typedef enum { |
||||||
|
EXAMPLE_VERBOSITY_ERRORS, |
||||||
|
EXAMPLE_VERBOSITY_MINIMAL, |
||||||
|
EXAMPLE_VERBOSITY_DETAILED, |
||||||
|
EXAMPLE_VERBOSITY_DEBUG, |
||||||
|
} ExampleVerbosity; |
||||||
|
|
||||||
|
G_END_DECLS |
||||||
|
|
||||||
|
#endif /* __EXAMPLE_ENUMS_H__ */ |
@ -0,0 +1,3 @@ |
|||||||
|
int whatever() { |
||||||
|
return 0; |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
int main() { |
||||||
|
return 0; |
||||||
|
} |
@ -0,0 +1,44 @@ |
|||||||
|
# Test that dependencies with their own generated sources don't |
||||||
|
# confuse the Vala build instruction generator. |
||||||
|
|
||||||
|
# Test case for https://github.com/mesonbuild/meson/issues/1084 |
||||||
|
|
||||||
|
gnome = import('gnome') |
||||||
|
|
||||||
|
gobject = dependency('gobject-2.0') |
||||||
|
|
||||||
|
enums = gnome.mkenums('enum-types', |
||||||
|
sources: 'enums.h', |
||||||
|
c_template: 'enum-types.c.template', |
||||||
|
h_template: 'enum-types.h.template', |
||||||
|
) |
||||||
|
|
||||||
|
libcommon = library('common', |
||||||
|
enums[0], enums[1], |
||||||
|
dependencies: gobject) |
||||||
|
|
||||||
|
common_dep = declare_dependency( |
||||||
|
# This is required so that whoever depends on this also depends |
||||||
|
# on the generated header; that won't happen implicitly. |
||||||
|
# See: https://github.com/mesonbuild/meson/issues/1084 |
||||||
|
sources: enums[1], |
||||||
|
link_with: libcommon, |
||||||
|
) |
||||||
|
|
||||||
|
libplover_vala = library('plover', |
||||||
|
'lib.vala', |
||||||
|
dependencies: [common_dep, gobject] |
||||||
|
) |
||||||
|
|
||||||
|
plover_dep = declare_dependency( |
||||||
|
link_with: libplover_vala, |
||||||
|
dependencies: common_dep |
||||||
|
) |
||||||
|
|
||||||
|
vala_prog = executable('hello', |
||||||
|
'main.vala', |
||||||
|
link_with: libplover_vala, |
||||||
|
# There's no need to specify common_dep here since plover_dep pulls it |
||||||
|
# in, but it should be harmless to do so. |
||||||
|
dependencies: [common_dep, plover_dep, gobject] |
||||||
|
) |
@ -0,0 +1 @@ |
|||||||
|
//
|
Loading…
Reference in new issue