From 1fa95f97d78347eb995910f51de6a2690a045de4 Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 16 Feb 2024 14:42:06 +0800 Subject: [PATCH] Fix #8039 - library support and add back roopacker dependancy --- .roobuilder.jcfg | 6 +- README.md | 29 ++- debian/changelog | 11 +- debian/control | 1 + meson.build | 9 +- org.roojs.roobuilder.json | 2 +- src/Builder4/ValaProjectSettingsPopover.bjs | 135 +++++++++--- src/Builder4/ValaProjectSettingsPopover.vala | 219 ++++++++++++++++++- src/Palete/Javascript.vala | 124 +++++------ src/Project/Gtk.vala | 10 +- src/Project/GtkValaSettings.vala | 51 ++++- src/Project/Meson.vala | 14 +- src/Project/Project.vala | 4 +- 13 files changed, 479 insertions(+), 136 deletions(-) diff --git a/.roobuilder.jcfg b/.roobuilder.jcfg index ef31a5938..9e4dbd687 100644 --- a/.roobuilder.jcfg +++ b/.roobuilder.jcfg @@ -3,6 +3,7 @@ "compilegroups" : [ { "name" : "roobuilder", + "is_library" : false, "execute_args" : "", "sources" : [ "src/Builder4/About.bjs", @@ -74,6 +75,8 @@ } ], "compile_flags" : "", + "version" : "5.0.4", + "licence" : "LGPL", "packages" : [ "gtk4", "gee-0.8", @@ -89,6 +92,7 @@ "gtksourceview-5", "jsonrpc-glib-1.0", "gio-unix-2.0", - "libadwaita-1" + "libadwaita-1", + "roojspack-1.5" ] } \ No newline at end of file diff --git a/README.md b/README.md index 2d6434cfe..afe14d5e2 100644 --- a/README.md +++ b/README.md @@ -2,43 +2,48 @@ Vala and Javascript IDE - for building Vala Desktop applications and Javascript UI's using the roojs libraries (for bootstrap and classic) --- -Videos +**Videos** GLib Settings Demo Part 1 - click to view on youtube -[![GLib Settings Demo Part 1](https://i.ytimg.com/an_webp/kx4B0frG-vc/mqdefault_6s.webp?du=3000&sqp=COfHkK4G&rs=AOn4CLCCsPUOERRGmjq3GJyjjKojAaFeNQ)](https://www.youtube.com/watch?v=kx4B0frG-vc&t=20s "GLib Settings Demo Part 1 - Click to Watch!") +[![GLib Settings Demo Part 1](https://i.ytimg.com/vi/kx4B0frG-vc/hqdefault.jpg)](https://www.youtube.com/watch?v=kx4B0frG-vc&t=20s "GLib Settings Demo Part 1 - Click to Watch!") Part 2 - click to view on youtube -[![GLib Settings Demo Part 2](https://i.ytimg.com/an_webp/XChS0YEB4yY/mqdefault_6s.webp?du=3000&sqp=CNLbkK4G&rs=AOn4CLCnEOREfuG7Pw2UBnGGasCEUlV4Rw)](https://www.youtube.com/watch?v=XChS0YEB4yY&t=6s "GLib Settings Demo Part 2 - Click to Watch!") +[![GLib Settings Demo Part 2](https://i.ytimg.com/vi/XChS0YEB4yY/hqdefault.jpg)](https://www.youtube.com/watch?v=XChS0YEB4yY&t=6s "GLib Settings Demo Part 2 - Click to Watch!") --- -Changlog +**Changlog** https://github.com/roojs/roobuilder/blob/master/debian/changelog --- -Features Wishlist +**Features Wishlist** Random list of ideas to add - I regulary add these in totally random order. https://docs.google.com/spreadsheets/d/1-qNQX1Bwwd1cV405Kj1l3B3Mi6K-GvECnMeuzRKfbGA/edit?usp=sharing --- -Debian and Ubuntu packages +**Debian and Ubuntu packages** you will need libvala (available on most debian/ubuntu repos), and vala-language-server (available below) - * https://github.com/roojs/roobuilder/releases +Dependancies + * https://github.com/roojs/vala-language-server/releases + * https://github.com/roojs/roojspacker/releases ---- +Release + * https://github.com/roojs/roobuilder/releases + +--- -Building it +**Building it** a) Clone this code.. @@ -58,7 +63,7 @@ Building it --- -Notes on updating packaging.. +**Notes on updating packaging..** Update Package details. Edit the about version (check debian/changelog) @@ -74,7 +79,7 @@ Build it.. --- -Known issues +**Known issues** * Flatpack - run doesnt work - needs more work understanding how flatpack would manage to compile with libraries from the system, or inside the pack - \ No newline at end of file + * See the wishlist.. \ No newline at end of file diff --git a/debian/changelog b/debian/changelog index 242ab4c52..f36bcf666 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,18 @@ -roobuilder (5.0.3) UNRELEASED; urgency=medium +roobuilder (5.0.4) UNRELEASED; urgency=medium * error popups with tree of errors, now default to expanding current file * row detection for drag/drop + contect menu replaced with pick/ bounds and row counting (far more reliable) * css moved to resource * editor resize font now centralized and synced on all windows + * added back roopacker dependancy (uses threaded compile) + * reference to wishlist on readme + * support for structs when adding objects (eg. CClosureExpression) + * editor font size uses ctrl-scroll to enlarges / shrink + * fixed issue with missing references on node creation + * completion now uses editor context to decide if to try and complete + * target names in gtk settings only support a-z + * file dialogs can be closed with esc key + * added library support for meson creation, including version and licence in settings -- Alan Wed, 07 Feb 2024 09:51:44 +0800 diff --git a/debian/control b/debian/control index e213924ff..7163c2e5a 100644 --- a/debian/control +++ b/debian/control @@ -20,6 +20,7 @@ Depends: ninja-build, vala-language-server, gnome-terminal, + roojspacker (>= 1.5), gdb Description: Vala and Javascript IDE for building Vala Desktop applications and Javascript UI's using the roojs libraries (for bootstrap and classic) diff --git a/meson.build b/meson.build index 7f59afc85..4c54fc39d 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('roobuilder', 'vala', 'c', - version: '1.0', + version: '5.0.4', license: 'LGPL', default_options: [ 'default_library=static', @@ -31,6 +31,7 @@ deps = [ dependency('jsonrpc-glib-1.0'), dependency('gio-unix-2.0'), dependency('libadwaita-1'), + dependency('roojspack-1.5'), ] @@ -159,8 +160,8 @@ roobuilder_src = files([ roobuilder = executable('roobuilder', - dependencies: deps, - sources: [ roobuilder_src , roobuilder_resources ], - install: true + dependencies: deps, + sources: [ roobuilder_src , roobuilder_resources ], + install: true ) diff --git a/org.roojs.roobuilder.json b/org.roojs.roobuilder.json index b243e209a..c8b91b9be 100644 --- a/org.roojs.roobuilder.json +++ b/org.roojs.roobuilder.json @@ -69,7 +69,7 @@ { "type": "git", "url": "https://github.com/roojs/roobuilder.git", - "commit" : "c9e3306f3a430ed15155ac45ef097f9d7dbafe03" + "tag" : "release-5.0.3" } ], "post-install": [ diff --git a/src/Builder4/ValaProjectSettingsPopover.bjs b/src/Builder4/ValaProjectSettingsPopover.bjs index 8cd541d86..07634bc04 100644 --- a/src/Builder4/ValaProjectSettingsPopover.bjs +++ b/src/Builder4/ValaProjectSettingsPopover.bjs @@ -3,13 +3,13 @@ "gen_extended" : false, "items" : [ { + "# Project.Gtk project" : "null", + "# Project.GtkValaSettings? selected_target" : "null", + "# Xcls_MainWindow window" : "null", + "# bool cg_loading" : false, + "# bool done" : false, "$ Project.Callback doneObj" : "null", "$ xns" : "Gtk", - "Project.Gtk project" : "null", - "Project.GtkValaSettings? selected_target" : "null", - "Xcls_MainWindow window" : "null", - "bool cg_loading" : false, - "bool done" : false, "bool modal" : true, "items" : [ { @@ -60,27 +60,83 @@ "items" : [ { "$ xns" : "Gtk", - "Gtk.Align halign" : "Gtk.Align.START", - "bool hexpand" : true, - "utf8 label" : "compile flags", - "xtype" : "Label" - }, - { - "$ xns" : "Gtk", - "id" : "compile_flags", - "listeners" : { - "changed" : [ - "() => {", - " ", - " _this.project.compile_flags = this.el.buffer.text;", - " _this.project.save();", - "// _this.project.save();", - "", - "}" - ] - }, - "utf8 placeholder_text" : "eg. -g --valasrc $BASEDIR ", - "xtype" : "Entry" + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "int spacing" : 10, + "items" : [ + { + "$ xns" : "Gtk", + "Gtk.Align halign" : "Gtk.Align.START", + "bool hexpand" : false, + "utf8 label" : "Compile flags:", + "xtype" : "Label" + }, + { + "$ xns" : "Gtk", + "id" : "compile_flags", + "listeners" : { + "changed" : [ + "() => {", + " ", + " _this.project.compile_flags = this.el.buffer.text;", + " _this.project.save();", + "// _this.project.save();", + "", + "}" + ] + }, + "utf8 placeholder_text" : "eg. -g --valasrc $BASEDIR ", + "xtype" : "Entry" + }, + { + "$ xns" : "Gtk", + "Gtk.Align halign" : "Gtk.Align.START", + "bool hexpand" : false, + "utf8 label" : "Version:", + "xtype" : "Label" + }, + { + "$ xns" : "Gtk", + "id" : "version", + "listeners" : { + "changed" : [ + "() => {", + " ", + " _this.project.version = this.el.buffer.text;", + " _this.project.save();", + "// _this.project.save();", + "", + "}" + ] + }, + "utf8 placeholder_text" : "eg. 1.5", + "xtype" : "Entry" + }, + { + "$ xns" : "Gtk", + "Gtk.Align halign" : "Gtk.Align.START", + "bool hexpand" : false, + "utf8 label" : "Licence:", + "xtype" : "Label" + }, + { + "$ xns" : "Gtk", + "id" : "licence", + "listeners" : { + "changed" : [ + "() => {", + " ", + " _this.project.licence = this.el.buffer.text;", + " _this.project.save();", + "// _this.project.save();", + "", + "}" + ] + }, + "utf8 placeholder_text" : "eg. LGPL", + "xtype" : "Entry" + } + ], + "xtype" : "Box" }, { "$ xns" : "Gtk", @@ -715,7 +771,7 @@ "\t GLib.debug(\"Set name to %s\", cg.name);", "\t ", " \t_this.build_name.el.buffer.set_text(cg.name.data);", - " ", + " \t_this.build_as_library.el.active = cg.is_library;", " ", "\t_this.build_execute_args.el.buffer.set_text( cg.execute_args.data );", " ", @@ -883,6 +939,24 @@ }, "string placeholder_text" : "eg. -f somefile -g ", "xtype" : "Entry" + }, + { + "$ xns" : "Gtk", + "id" : "build_as_library", + "listeners" : { + "notify[\"active\"]" : [ + "() => {", + " if (_this.selected_target == null) {", + " return;", + " }", + " _this.selected_target.is_library = this.el.active;", + " ", + "}", + "" + ] + }, + "string label" : "build as library", + "xtype" : "CheckButton" } ], "xtype" : "Box" @@ -993,7 +1067,12 @@ " this.compile_flags.el.buffer.set_text(", " \tproject.compile_flags.data", "\t);", - "\t ", + " this.version.el.buffer.set_text(", + " \tproject.version.data", + "\t);", + "\t this.licence.el.buffer.set_text(", + " \tproject.licence.data", + "\t); ", " project.loadVapiIntoStore(_this.vapimodel.el);", " GLib.Timeout.add(500, () => {", " \t\t this.vapi_scroll.el.vadjustment.value = 0;\t ", diff --git a/src/Builder4/ValaProjectSettingsPopover.vala b/src/Builder4/ValaProjectSettingsPopover.vala index c6fc50a25..2d5593077 100644 --- a/src/Builder4/ValaProjectSettingsPopover.vala +++ b/src/Builder4/ValaProjectSettingsPopover.vala @@ -16,6 +16,8 @@ public class ValaProjectSettingsPopover : Object public Xcls_label_global label_global; public Xcls_label_targets label_targets; public Xcls_compile_flags compile_flags; + public Xcls_version version; + public Xcls_licence licence; public Xcls_vapi_scroll vapi_scroll; public Xcls_vapimodel vapimodel; public Xcls_vapi_filter vapi_filter; @@ -32,6 +34,7 @@ public class ValaProjectSettingsPopover : Object public Xcls_set_vboxb set_vboxb; public Xcls_build_name build_name; public Xcls_build_execute_args build_execute_args; + public Xcls_build_as_library build_as_library; public Xcls_save_btn save_btn; // my vars (def) @@ -39,9 +42,9 @@ public class ValaProjectSettingsPopover : Object public bool cg_loading; public Xcls_MainWindow window; public Project.GtkValaSettings? selected_target; - public uint border_width; public bool done; public Project.Gtk project; + public uint border_width; // ctor public ValaProjectSettingsPopover() @@ -54,13 +57,14 @@ public class ValaProjectSettingsPopover : Object this.cg_loading = false; this.window = null; this.selected_target = null; - this.border_width = 0; this.done = false; this.project = null; + this.border_width = 0; // set gobject values this.el.modal = true; var child_1 = new Xcls_HeaderBar1( _this ); + child_1.ref(); this.el.titlebar = child_1.el; var child_2 = new Xcls_Box3( _this ); child_2.ref(); @@ -91,7 +95,12 @@ public class ValaProjectSettingsPopover : Object this.compile_flags.el.buffer.set_text( project.compile_flags.data ); - + this.version.el.buffer.set_text( + project.version.data + ); + this.licence.el.buffer.set_text( + project.licence.data + ); project.loadVapiIntoStore(_this.vapimodel.el); GLib.Timeout.add(500, () => { this.vapi_scroll.el.vadjustment.value = 0; @@ -140,6 +149,7 @@ public class ValaProjectSettingsPopover : Object // set gobject values var child_1 = new Xcls_Label2( _this ); + child_1.ref(); this.el.title_widget = child_1.el; } @@ -291,11 +301,9 @@ public class ValaProjectSettingsPopover : Object // set gobject values this.el.homogeneous = false; - var child_1 = new Xcls_Label8( _this ); + var child_1 = new Xcls_Box834( _this ); child_1.ref(); this.el.append( child_1.el ); - new Xcls_compile_flags( _this ); - this.el.append( _this.compile_flags.el ); new Xcls_vapi_scroll( _this ); this.el.append( _this.vapi_scroll.el ); new Xcls_vapi_search( _this ); @@ -304,7 +312,43 @@ public class ValaProjectSettingsPopover : Object // user defined functions } - public class Xcls_Label8 : Object + public class Xcls_Box834 : Object + { + public Gtk.Box el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_Box834(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 10 ); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Label853( _this ); + child_1.ref(); + this.el.append( child_1.el ); + new Xcls_compile_flags( _this ); + this.el.append( _this.compile_flags.el ); + var child_3 = new Xcls_Label886( _this ); + child_3.ref(); + this.el.append( child_3.el ); + new Xcls_version( _this ); + this.el.append( _this.version.el ); + var child_5 = new Xcls_Label906( _this ); + child_5.ref(); + this.el.append( child_5.el ); + new Xcls_licence( _this ); + this.el.append( _this.licence.el ); + } + + // user defined functions + } + public class Xcls_Label853 : Object { public Gtk.Label el; private ValaProjectSettingsPopover _this; @@ -313,16 +357,16 @@ public class ValaProjectSettingsPopover : Object // my vars (def) // ctor - public Xcls_Label8(ValaProjectSettingsPopover _owner ) + public Xcls_Label853(ValaProjectSettingsPopover _owner ) { _this = _owner; - this.el = new Gtk.Label( "compile flags" ); + this.el = new Gtk.Label( "Compile flags:" ); // my vars (dec) // set gobject values this.el.halign = Gtk.Align.START; - this.el.hexpand = true; + this.el.hexpand = false; } // user defined functions @@ -361,6 +405,121 @@ public class ValaProjectSettingsPopover : Object // user defined functions } + public class Xcls_Label886 : Object + { + public Gtk.Label el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_Label886(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Version:" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + this.el.hexpand = false; + } + + // user defined functions + } + + public class Xcls_version : Object + { + public Gtk.Entry el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_version(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.version = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.placeholder_text = "eg. 1.5"; + + //listeners + this.el.changed.connect( () => { + + _this.project.version = this.el.buffer.text; + _this.project.save(); + // _this.project.save(); + + }); + } + + // user defined functions + } + + public class Xcls_Label906 : Object + { + public Gtk.Label el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_Label906(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Licence:" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + this.el.hexpand = false; + } + + // user defined functions + } + + public class Xcls_licence : Object + { + public Gtk.Entry el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_licence(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.licence = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.placeholder_text = "eg. LGPL"; + + //listeners + this.el.changed.connect( () => { + + _this.project.licence = this.el.buffer.text; + _this.project.save(); + // _this.project.save(); + + }); + } + + // user defined functions + } + + public class Xcls_vapi_scroll : Object { public Gtk.ScrolledWindow el; @@ -385,6 +544,7 @@ public class ValaProjectSettingsPopover : Object this.el.vexpand = true; this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC; var child_1 = new Xcls_ColumnView11( _this ); + child_1.ref(); this.el.child = child_1.el; } @@ -817,6 +977,7 @@ public class ValaProjectSettingsPopover : Object new Xcls_set_vbox( _this ); this.el.set_end_child ( _this.set_vbox.el ); var child_2 = new Xcls_Box42( _this ); + child_2.ref(); this.el.start_child = child_2.el; } @@ -1518,6 +1679,7 @@ public class ValaProjectSettingsPopover : Object // set gobject values this.el.vexpand = true; var child_1 = new Xcls_ColumnView47( _this ); + child_1.ref(); this.el.child = child_1.el; // init method @@ -1630,7 +1792,7 @@ public class ValaProjectSettingsPopover : Object GLib.debug("Set name to %s", cg.name); _this.build_name.el.buffer.set_text(cg.name.data); - + _this.build_as_library.el.active = cg.is_library; _this.build_execute_args.el.buffer.set_text( cg.execute_args.data ); @@ -1762,6 +1924,8 @@ public class ValaProjectSettingsPopover : Object this.el.append( child_3.el ); new Xcls_build_execute_args( _this ); this.el.append( _this.build_execute_args.el ); + new Xcls_build_as_library( _this ); + this.el.append( _this.build_as_library.el ); } // user defined functions @@ -1934,6 +2098,39 @@ public class ValaProjectSettingsPopover : Object // user defined functions } + public class Xcls_build_as_library : Object + { + public Gtk.CheckButton el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_build_as_library(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.build_as_library = this; + this.el = new Gtk.CheckButton(); + + // my vars (dec) + + // set gobject values + this.el.label = "build as library"; + + //listeners + this.el.notify["active"].connect( () => { + if (_this.selected_target == null) { + return; + } + _this.selected_target.is_library = this.el.active; + + }); + } + + // user defined functions + } + diff --git a/src/Palete/Javascript.vala b/src/Palete/Javascript.vala index 6a7512b83..255e9b23a 100644 --- a/src/Palete/Javascript.vala +++ b/src/Palete/Javascript.vala @@ -21,49 +21,7 @@ namespace Palete { Javascript instance = null; public class Javascript { - -/* - public static JSCore.Object class_constructor( - JSCore.Context ctx, - JSCore.Object constructor, - JSCore.Value[] arguments, - out JSCore.Value exception) - { - var c = new JSCore.Class (class_definition); - var o = new JSCore.Object (ctx, c, null); - exception = null; - return o; - } - const JSCore.StaticFunction[] class_functions = { - { null, null, 0 } - }; - const JSCore.ClassDefinition class_definition = { - 0, - JSCore.ClassAttribute.None, - "App", - null, - - null, - class_functions, - - null, - null, - - null, - null, - null, - null, - - null, - null, - class_constructor, - null, - null - }; - - - public JSCore.GlobalContext js_global_context = null; -*/ + public static Javascript singleton() { if (instance == null) { @@ -78,6 +36,9 @@ namespace Palete { } + + + public void validate(string code, JsRender.JsRender file) { @@ -90,8 +51,13 @@ namespace Palete { var ar = new Gee.ArrayList((a,b) => { return a.equals(b); }); if (ex == null) { - file.updateErrors( ar ); - return ; // this.compressionErrors(code, fn); << to slow on large files? +// file.updateErrors( ar ); // clear old errors ?? + this.compressionErrors.begin(code, file.path, (obj, res) => { + ar = this.compressionErrors.end(res); + file.updateErrors( ar ); + }); + + return ; } @@ -103,32 +69,62 @@ namespace Palete { } - /* - - public Json.Object compressionErrors(string code , string fn) + + bool packer_running = false; + public async new Gee.ArrayList compressionErrors(string code , string fn) throws ThreadError { // this uses the roojspacker code to try and compress the code. // it should highlight errors before we actually push live the code. + SourceFunc callback = compressionErrors.callback; + Json.Object ret = new Json.Object(); + var ar = new Gee.ArrayList((a,b) => { return a.equals(b); }); + if (this.packer_running) { + return ar; + } + this.packer_running = true; + + ThreadFunc run = () => { + // standard error format: file %s, line %s, Error - - - var cfg = new JSDOC.PackerRun(); - cfg.opt_keep_whitespace = false; - cfg.opt_skip_scope = false; - cfg.opt_dump_tokens = false; - cfg.opt_clean_cache = false; - + + var cfg = new JSDOC.PackerRun(); + cfg.opt_keep_whitespace = false; + cfg.opt_skip_scope = false; + cfg.opt_dump_tokens = false; + cfg.opt_clean_cache = false; + - var p = new JSDOC.Packer(cfg); - - - p.packFile(code, fn,""); - - return p.result; - + var p = new JSDOC.Packer(cfg); + + + p.packFile(code, fn,""); + + ret = p.result; + Idle.add((owned) callback); + return true; + }; + new Thread("roopacker", run); + yield; + this.packer_running = false; + if (!ret.has_member(fn)) { + return ar; + } + var jar = ret.get_array_member(fn); + for(var i = 0; i < jar.get_length(); i++ ){ + var d = jar.get_object_element(i); + + ar.add( + new Lsp.Diagnostic.simple((int) d.get_int_member("line") , 1, d.get_string_member("message")) + ); + } + + return ar; + + } - */ + + /** * extension API concept.. diff --git a/src/Project/Gtk.vala b/src/Project/Gtk.vala index 1c0a8f629..983bc3c90 100644 --- a/src/Project/Gtk.vala +++ b/src/Project/Gtk.vala @@ -98,7 +98,12 @@ namespace Project if (obj.has_member("compiler_flags")) { this.compile_flags = obj.get_string_member("compile_flags"); } - + if (obj.has_member("version")) { + this.version = obj.get_string_member("version"); + } + if (obj.has_member("licence")) { + this.licence = obj.get_string_member("licence"); + } if (!obj.has_member("compilegroups") || obj.get_member("compilegroups").get_node_type () != Json.NodeType.ARRAY) { // make _default_ ? return; @@ -130,6 +135,9 @@ namespace Project obj.set_array_member("compilegroups", ar); obj.set_string_member("compile_flags", this.compile_flags); + obj.set_string_member("version", this.version); + obj.set_string_member("licence", this.licence); + var par = new Json.Array(); foreach(var p in this.packages) { par.add_string_element(p); diff --git a/src/Project/GtkValaSettings.vala b/src/Project/GtkValaSettings.vala index ed51c6830..47c3feab8 100644 --- a/src/Project/GtkValaSettings.vala +++ b/src/Project/GtkValaSettings.vala @@ -13,6 +13,7 @@ namespace Project public string execute_args; public bool loading_ui = true; + public bool is_library = false; public GtkValaSettings(Gtk project, string name) { @@ -29,7 +30,9 @@ namespace Project this.project = project; this.name = el.get_string_member("name"); - + if (el.has_member("is_library")) { + this.is_library = el.get_boolean_member("is_library"); + } if ( el.has_member("execute_args")) { this.execute_args = el.get_string_member("execute_args"); } else { @@ -49,6 +52,7 @@ namespace Project { var ret = new Json.Object(); ret.set_string_member("name", this.name); + ret.set_boolean_member("is_library", this.is_library); ret.set_string_member("execute_args", this.execute_args); ret.set_array_member("sources", this.writeArray( this.filterFiles(this.sources))); @@ -94,5 +98,50 @@ namespace Project return ret; } + public string writeMesonExe(string resources) + { + + var cgname = this.name; + if (!this.is_library) { + return @" +$cgname = executable('$cgname', + dependencies: deps, + sources: [ $(cgname)_src $resources ], + install: true +) +"; + } + string[] deps = {}; + foreach(var p in this.project.packages) { + if (p == "posix" ) { + continue; + } + deps += "'" + p + "'"; + + } + var depstr = deps.length < 1 ? "" : ( "[" + string.joinv(",", deps) + "]"); + + + var version = this.project.version; + // it's a library.. + return @" +$(cgname)_lib = shared_library('$cgname', + sources : [ $(cgname)_src $resources ], + vala_vapi: '$(cgname)-$(version).vapi', + dependencies: deps, + install: true, + install_dir: [true, true, true] +) +pkg = import('pkgconfig') +pkg.generate( $(cgname)_lib, + filebase: '$(cgname)-$(version)', + requires : $(depstr) +) + +"; + + + } + } } \ No newline at end of file diff --git a/src/Project/Meson.vala b/src/Project/Meson.vala index 16637c2af..21eb15e2e 100644 --- a/src/Project/Meson.vala +++ b/src/Project/Meson.vala @@ -16,8 +16,8 @@ namespace Project { { this.has_resources = false; var project_name = this.project.name; - var project_version = "1.0"; //this.project.version; - var project_licence = "LGPL"; // this.project.licence + var project_version = this.project.version; + var project_licence = this.project.licence; var deps = ""; foreach(var p in this.project.packages) { @@ -127,15 +127,9 @@ GLib.debug("write meson : %s" , data); str += "])\n\n"; var resources = this.has_resources ? (", " + this.project.name + "_resources") : ""; - var cgname = cg.name; + - str += @" -$cgname = executable('$cgname', - dependencies: deps, - sources: [ " + cgname + @"_src $resources ], - install: true -) -"; + str += cg.writeMesonExe(resources); return str; } diff --git a/src/Project/Project.vala b/src/Project/Project.vala index 0d9a8adbb..c9bd36036 100644 --- a/src/Project/Project.vala +++ b/src/Project/Project.vala @@ -68,8 +68,8 @@ namespace Project { } } - - + public string version = "1.0"; + public string licence = "LGPL"; public string path = ""; private Gee.ArrayList sub_paths; -- 2.39.2