From ed580cfe2ab1cdd8eca351bab08b64c33844db34 Mon Sep 17 00:00:00 2001 From: Chris Cromer Date: Sat, 5 Jan 2019 00:28:18 -0300 Subject: [PATCH] update build system --- data/gschema/meson.build | 7 +++++ data/ui/meson.build | 8 +++--- doc/meson.build | 3 ++- lib/db/arrienda.vala | 2 +- lib/db/asociado.vala | 2 +- lib/db/categoria.vala | 2 +- lib/db/ciudad.vala | 2 +- lib/db/contacto_emergencia.vala | 2 +- lib/db/descuento.vala | 2 +- lib/db/empresa.vala | 2 +- lib/db/enfermedad.vala | 2 +- lib/db/especialidad.vala | 2 +- lib/db/guia.vala | 2 +- lib/db/lugar.vala | 2 +- lib/db/participa.vala | 2 +- lib/db/posee.vala | 2 +- lib/db/realiza.vala | 2 +- lib/db/region.vala | 2 +- lib/db/requerir_auto.vala | 2 +- lib/db/tiene_enfermedad.vala | 2 +- lib/db/tour.vala | 2 +- lib/db/turista.vala | 2 +- lib/db/vehiculo.vala | 2 +- lib/dbwrapper.vala | 2 +- lib/meson.build | 17 ++++++++----- lib/rut.vala | 2 +- meson.build | 6 ++--- po/es.po | 24 +++++++++++++++--- po/meson.build | 7 ++++- po/sernatur.pot | 20 ++++++++++++--- src/config.vala.in | 6 +++++ src/meson.build | 26 ++++++++++++------- src/sernatur-window.vala | 15 ++++++----- src/sernatur.vala | 45 ++++++++++++++++++++++++++++++--- 34 files changed, 164 insertions(+), 64 deletions(-) create mode 100644 src/config.vala.in diff --git a/data/gschema/meson.build b/data/gschema/meson.build index 60f75b0..02fe6b6 100644 --- a/data/gschema/meson.build +++ b/data/gschema/meson.build @@ -1,2 +1,9 @@ +gnome = import('gnome') +gschemas = files( + 'cl.cromer.ubb.sernatur.db.gschema.xml', + 'cl.cromer.ubb.sernatur.window.gschema.xml') +gnome.compile_schemas(build_by_default: true, + depend_files: gschemas +) install_data('cl.cromer.ubb.sernatur.db.gschema.xml', install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'glib-2.0', 'schemas')) install_data('cl.cromer.ubb.sernatur.window.gschema.xml', install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'glib-2.0', 'schemas')) diff --git a/data/ui/meson.build b/data/ui/meson.build index f4549ab..9f63950 100644 --- a/data/ui/meson.build +++ b/data/ui/meson.build @@ -1,5 +1,7 @@ gnome = import('gnome') -sernatur_gresource_c = gnome.compile_resources('sernatur-resources', +gresource = gnome.compile_resources(meson.project_name() + '_gresource_main', 'sernatur.gresource.xml', - source_dir : '.', - c_name : 'sernatur') + source_dir: '.', + c_name: meson.project_name() + '_resource_main', + export: true, + install_header: true) diff --git a/doc/meson.build b/doc/meson.build index 14854f1..422d0b8 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -2,6 +2,7 @@ docs_enabled = get_option('valadocs') valadoc = find_program('valadoc', required: docs_enabled) vala_doc_sources = vala_sources vala_doc_sources += lib_sources +vala_doc_sources += config_data_file if docs_enabled valadocs_deps = get_option('valadocs_deps') docs_deps = ['--pkg=gtk+-3.0'] @@ -20,7 +21,7 @@ if docs_enabled '--force', '--package-name=@0@'.format(meson.project_name()), '--package-version=@0@'.format(meson.project_version()), - '--vapidir=@0@'.format(join_paths(meson.source_root(), 'src/vapi')), + '--vapidir=@0@'.format(join_paths(meson.source_root(), 'vapi')), '--directory=@OUTDIR@/valadoc', vala_doc_sources, ], diff --git a/lib/db/arrienda.vala b/lib/db/arrienda.vala index f6c4003..9bee2f1 100644 --- a/lib/db/arrienda.vala +++ b/lib/db/arrienda.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/asociado.vala b/lib/db/asociado.vala index fd6c31d..ded3d3c 100644 --- a/lib/db/asociado.vala +++ b/lib/db/asociado.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/categoria.vala b/lib/db/categoria.vala index eca82ce..7310e64 100644 --- a/lib/db/categoria.vala +++ b/lib/db/categoria.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/ciudad.vala b/lib/db/ciudad.vala index af5bd04..2bb8bc3 100644 --- a/lib/db/ciudad.vala +++ b/lib/db/ciudad.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/contacto_emergencia.vala b/lib/db/contacto_emergencia.vala index 75b1761..8f7c2a3 100644 --- a/lib/db/contacto_emergencia.vala +++ b/lib/db/contacto_emergencia.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/descuento.vala b/lib/db/descuento.vala index cfa3129..e2e0071 100644 --- a/lib/db/descuento.vala +++ b/lib/db/descuento.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/empresa.vala b/lib/db/empresa.vala index aef643b..33fd266 100644 --- a/lib/db/empresa.vala +++ b/lib/db/empresa.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/enfermedad.vala b/lib/db/enfermedad.vala index d8789f9..eff648d 100644 --- a/lib/db/enfermedad.vala +++ b/lib/db/enfermedad.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/especialidad.vala b/lib/db/especialidad.vala index 8bf71c0..d2ce6de 100644 --- a/lib/db/especialidad.vala +++ b/lib/db/especialidad.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/guia.vala b/lib/db/guia.vala index 4d7f4b6..fbcee60 100644 --- a/lib/db/guia.vala +++ b/lib/db/guia.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/lugar.vala b/lib/db/lugar.vala index b1b65c5..40e9e95 100644 --- a/lib/db/lugar.vala +++ b/lib/db/lugar.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/participa.vala b/lib/db/participa.vala index 6c19fb0..38d21f7 100644 --- a/lib/db/participa.vala +++ b/lib/db/participa.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/posee.vala b/lib/db/posee.vala index 97ea1b2..a654d6f 100644 --- a/lib/db/posee.vala +++ b/lib/db/posee.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/realiza.vala b/lib/db/realiza.vala index 3ad3237..e0d568f 100644 --- a/lib/db/realiza.vala +++ b/lib/db/realiza.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/region.vala b/lib/db/region.vala index fac737b..42dbca4 100644 --- a/lib/db/region.vala +++ b/lib/db/region.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/requerir_auto.vala b/lib/db/requerir_auto.vala index 2298046..bd56b47 100644 --- a/lib/db/requerir_auto.vala +++ b/lib/db/requerir_auto.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/tiene_enfermedad.vala b/lib/db/tiene_enfermedad.vala index dc9341e..4995f06 100644 --- a/lib/db/tiene_enfermedad.vala +++ b/lib/db/tiene_enfermedad.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/tour.vala b/lib/db/tour.vala index f338b65..5337e34 100644 --- a/lib/db/tour.vala +++ b/lib/db/tour.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/turista.vala b/lib/db/turista.vala index 350ed51..4d2f2a5 100644 --- a/lib/db/turista.vala +++ b/lib/db/turista.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/db/vehiculo.vala b/lib/db/vehiculo.vala index 03ffd02..75df85e 100644 --- a/lib/db/vehiculo.vala +++ b/lib/db/vehiculo.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace DB { using Postgres; using Wrapper; diff --git a/lib/dbwrapper.vala b/lib/dbwrapper.vala index bdc69c5..70d0226 100644 --- a/lib/dbwrapper.vala +++ b/lib/dbwrapper.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { /** * This is the database namespace for Sernatur */ diff --git a/lib/meson.build b/lib/meson.build index e382c5a..2e07e4d 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -26,19 +26,22 @@ lib_sources = files( 'db/turista.vala', 'db/vehiculo.vala') -vala_args = ['--vapidir='+join_paths(meson.source_root(),'vapi')] +vala_args = ['--vapidir=' + join_paths(meson.source_root(), 'vapi')] -sernatur_lib = library('sernatur', +lib = library(meson.project_name(), lib_sources, - vala_header: 'sernatur.h', - vala_vapi: 'sernatur-1.0.0.vapi', -# vala_gir: 'Sernatur-1.0.0.gir', + vala_header: 'lib' + meson.project_name() + '.h', + vala_vapi: 'lib' + meson.project_name() + '.vapi', +# vala_gir: 'LibSernatur-1.0.0.gir', vala_args: vala_args, dependencies: [glib_dep, gobject_dep, pq_dep], version: '1.0.0', - soversion: '1', + soversion: '0', install: true, install_dir: [true, true, true]) pkg_mod = import('pkgconfig') -pkg_mod.generate(sernatur_lib) +pkg_mod.generate(lib) + +lib_dep = declare_dependency( + link_with: lib) diff --git a/lib/rut.vala b/lib/rut.vala index 33733a3..c8916e4 100644 --- a/lib/rut.vala +++ b/lib/rut.vala @@ -1,4 +1,4 @@ -namespace Sernatur { +namespace LibSernatur { namespace Person { public errordomain InvalidRut { diff --git a/meson.build b/meson.build index 145568c..6d63b8a 100644 --- a/meson.build +++ b/meson.build @@ -9,12 +9,12 @@ project('sernatur', 'b_ndebug=if-release' ] ) -add_global_arguments('-DGETTEXT_PACKAGE="sernatur"', language: 'c') +add_project_arguments('-DGETTEXT_PACKAGE="' + meson.project_name() + '"', language: 'c') debugging = get_option('debugging') if debugging - add_global_arguments('-DDEBUG', language : 'c') - add_global_arguments('-D', 'DEBUG', language : 'vala') + add_project_arguments('-DDEBUG', language : 'c') + add_project_arguments('-D', 'DEBUG', language : 'vala') endif add_project_arguments(['--vapidir', diff --git a/po/es.po b/po/es.po index 373903f..158f6d4 100644 --- a/po/es.po +++ b/po/es.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: sernatur\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-01-03 20:50-0300\n" -"PO-Revision-Date: 2019-01-03 20:49-0300\n" +"POT-Creation-Date: 2019-01-05 00:27-0300\n" +"PO-Revision-Date: 2019-01-04 19:59-0300\n" "Last-Translator: Chris Cromer \n" "Language-Team: none\n" "Language: es\n" @@ -38,11 +38,27 @@ msgstr "El RUT %s es demasiado grande!" msgid "The verifier %C is invalid!" msgstr "El verificador %C es invalido!" -#: src/sernatur-window.vala:128 +#: src/sernatur.vala:96 +#, c-format +msgid "Error: %s\n" +msgstr "Error %s\n" + +#: src/sernatur.vala:97 +#, c-format +msgid "Run '%s --help' to see a full list of available command line options.\n" +msgstr "" +"Correr '%s --help' para ver una lista completa de las opciones de la " +"consola.\n" + +#: src/sernatur.vala:102 +msgid "SERNATUR version: " +msgstr "Versión de SERNATUR:" + +#: src/sernatur-window.vala:129 msgid "Error" msgstr "Error" -#: src/sernatur-window.vala:133 +#: src/sernatur-window.vala:134 msgid "Postgresql server version:" msgstr "Versión del servidor Postgresql:" diff --git a/po/meson.build b/po/meson.build index 174a3e4..7800440 100644 --- a/po/meson.build +++ b/po/meson.build @@ -1,7 +1,12 @@ install_translations = get_option('install_translations') +i18n = import('i18n') if install_translations - i18n = import('i18n') i18n.gettext(meson.project_name(), args: '--directory=' + meson.source_root() ) +else + i18n.gettext(meson.project_name(), + args: '--directory=' + meson.source_root(), + install: false + ) endif diff --git a/po/sernatur.pot b/po/sernatur.pot index 50ce620..aca484e 100644 --- a/po/sernatur.pot +++ b/po/sernatur.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: sernatur\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-01-03 20:50-0300\n" +"POT-Creation-Date: 2019-01-05 00:27-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -37,11 +37,25 @@ msgstr "" msgid "The verifier %C is invalid!" msgstr "" -#: src/sernatur-window.vala:128 +#: src/sernatur.vala:96 +#, c-format +msgid "Error: %s\n" +msgstr "" + +#: src/sernatur.vala:97 +#, c-format +msgid "Run '%s --help' to see a full list of available command line options.\n" +msgstr "" + +#: src/sernatur.vala:102 +msgid "SERNATUR version: " +msgstr "" + +#: src/sernatur-window.vala:129 msgid "Error" msgstr "" -#: src/sernatur-window.vala:133 +#: src/sernatur-window.vala:134 msgid "Postgresql server version:" msgstr "" diff --git a/src/config.vala.in b/src/config.vala.in new file mode 100644 index 0000000..511417c --- /dev/null +++ b/src/config.vala.in @@ -0,0 +1,6 @@ +namespace Sernatur { + namespace Constants { + public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@"; + public const string VERSION = "@VERSION@"; + } +} diff --git a/src/meson.build b/src/meson.build index 253af5b..bab49ad 100644 --- a/src/meson.build +++ b/src/meson.build @@ -5,23 +5,31 @@ gtk_dep = dependency('gtk+-3.0', version: '>=3.0.0') gmodule_dep = dependency('gmodule-2.0', version: '>=2.0') pq_dep = dependency('libpq', version: '>=9.0') +config_data = configuration_data() +config_data.set('VERSION', meson.project_version()) +config_data.set('GETTEXT_PACKAGE', meson.project_name()) + +config_data_file = configure_file(input: 'config.vala.in', + output: 'config.vala', + configuration: config_data) + vala_sources = files( 'sernatur.vala', 'sernatur-window.vala') sources = vala_sources -c_sources = [sernatur_gresource_c] +sources += gresource +sources += config_data_file -sources = vala_sources -sources += c_sources +vala_args = ['--vapidir=' + join_paths(meson.source_root(), 'vapi')] +vala_args += ['--gresources=' + join_paths(meson.source_root(), 'data/ui/sernatur.gresource.xml')] -vala_args = ['--vapidir='+join_paths(meson.source_root(),'vapi')] -vala_args += ['--gresources='+join_paths(meson.source_root(),'data/ui/sernatur.gresource.xml')] +inc = include_directories('../lib', './') -sernatur_dep = declare_dependency(link_with: sernatur_lib, include_directories: include_directories('../lib')) - -exe = executable('sernatur', +exe = executable(meson.project_name(), sources, vala_args: vala_args, - dependencies: [glib_dep, gobject_dep, gtk_dep, gmodule_dep, pq_dep, sernatur_dep], + include_directories : inc, + gui_app: true, + dependencies: [glib_dep, gobject_dep, gtk_dep, gmodule_dep, pq_dep, lib_dep], install: true) diff --git a/src/sernatur-window.vala b/src/sernatur-window.vala index 18b4496..fba1017 100644 --- a/src/sernatur-window.vala +++ b/src/sernatur-window.vala @@ -16,14 +16,15 @@ * The main Sernatur namespace */ namespace Sernatur { - using DB; + using LibSernatur.Person; + using LibSernatur.DB; /** * The MainWindow class */ [GtkTemplate (ui = "/cl/cromer/ubb/sernatur/sernatur.window.ui")] public class MainWindow : Gtk.ApplicationWindow { - Gtk.Grid content; + private Gtk.Grid content; [GtkChild] private Gtk.Box mainbox; @@ -132,7 +133,7 @@ namespace Sernatur { } print (dgettext (null, "Postgresql server version:") + " %d\n", conn.get_server_version ()); - /*var tour = Tour.get_all_tours (conn); + var tour = Tour.get_all_tours (conn); print (tour[0].ciudad.region.nombre_region + "\n"); var tiene_enfermedad = TieneEnfermedad.get_all_tiene_enfermedades (conn); print (tiene_enfermedad[0].turista.contacto_emergencia.nombre_emergencia + "\n"); @@ -150,18 +151,18 @@ namespace Sernatur { var requerir_auto = RequerirAuto.get_all_requerir_autos (conn); print (requerir_auto[0].vehiculo.marca + "\n"); try { - var rut = new Person.Rut ("23.660.457-8"); + var rut = new Rut ("23.660.457-8"); print (rut.get_rut () + "\n"); - if (rut.type () == Person.Rut.Type.RUN) { + if (rut.type () == Rut.Type.RUN) { print ("person\n"); } else { print ("company\n"); } } - catch (Person.InvalidRut e) { + catch (InvalidRut e) { print ("Rut is invalid"); - }*/ + } } } } diff --git a/src/sernatur.vala b/src/sernatur.vala index bbf1e7a..d5f1b84 100644 --- a/src/sernatur.vala +++ b/src/sernatur.vala @@ -16,8 +16,23 @@ * The main Sernatur namespace */ namespace Sernatur { + using Constants; using Gtk; + private static bool version = false; + + private const GLib.OptionEntry[] options = { + // --version + { "version", 'v', 0, OptionArg.NONE, ref version, "Display version number", null }, + + // list terminator + { null } + }; + + public unowned string MyTranslateFunc (string str) { + return dgettext (null, str); + } + /** * The application class */ @@ -55,8 +70,6 @@ namespace Sernatur { * Run when the application starts */ public override void startup () { - Intl.textdomain ("sernatur"); - Intl.setlocale (LocaleCategory.ALL, ""); base.startup (); } } @@ -67,7 +80,31 @@ namespace Sernatur { * @return success of the application */ public static int main (string[] args) { - var application = new Application (); - return application.run (args); + Intl.setlocale (LocaleCategory.ALL, ""); + Intl.bindtextdomain (GETTEXT_PACKAGE, "/usr/share/locale"); + Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + Intl.textdomain (GETTEXT_PACKAGE); + try { + var opt_context = new OptionContext (""); + opt_context.set_translation_domain (GETTEXT_PACKAGE); + opt_context.set_translate_func (MyTranslateFunc, null); + opt_context.set_help_enabled (true); + opt_context.add_main_entries (options, null); + opt_context.parse (ref args); + } + catch (OptionError e) { + print (dgettext (null, "Error: %s\n"), e.message); + print (dgettext (null, "Run '%s --help' to see a full list of available command line options.\n"), args[0]); + return 1; + } + + if (version) { + print (dgettext (null, "SERNATUR version: ") + VERSION + "\n"); + return 0; + } + else { + var application = new Application (); + return application.run (args); + } } }