[gxml] Meson: making reusable build config



commit d0381f8e4873ae067c85b0a2a4c2a7964131f49f
Author: Daniel Espinosa <esodan gmail com>
Date:   Fri May 12 09:09:24 2017 -0500

    Meson: making reusable build config
    
    Changing some definitions in order to help others
    to re-use GXml Meson configuration to build their
    own Vala library projects

 gxml/meson.build |   26 ++++++++------
 meson.build      |   10 ++++--
 po/meson.build   |    2 +-
 test/meson.build |   95 +++++++++++++++++++++++++-----------------------------
 4 files changed, 67 insertions(+), 66 deletions(-)
---
diff --git a/gxml/meson.build b/gxml/meson.build
index 5c2f1b7..4f5fc8e 100644
--- a/gxml/meson.build
+++ b/gxml/meson.build
@@ -1,4 +1,7 @@
 vapidir = join_paths (get_option('datadir'),'vala','vapi')
+GIR_NAME= VERSIONED_CAMEL_CASE_NAME+'.gir'
+TYPELIB_NAME= VERSIONED_CAMEL_CASE_NAME+'.typelib'
+VAPI_NAME = VERSIONED_PROJECT_NAME+'.vapi'
 
 conf = configuration_data()
 conf.set('prefix', get_option('prefix'))
@@ -7,7 +10,7 @@ conf.set('libdir', join_paths (get_option ('prefix'),get_option ('libdir')))
 conf.set('includedir', get_option ('includedir'))
 conf.set('VALADEPS', VALADEPS)
 conf.set('PCDEPS', PCDEPS)
-conf.set('GXML_VERSION', PROJECT_VERSION)
+conf.set('PROJECT_VERSION', PROJECT_VERSION)
 conf.set('API_VERSION', API_VERSION)
 
 configure_file(input : 'gxml.pc.in',
@@ -123,14 +126,15 @@ sources = files ([
        'xlibxml.h'
 ])
 
-inc_gxmlh = include_directories ('.')
+inc_libh = include_directories ('.')
+inc_libh_dep = declare_dependency (include_directories : inc_libh)
 
-gxml = library('gxml-@0@'.format(API_VERSION),
+lib = library(VERSIONED_PROJECT_NAME,
        valasources+sources+configvapi,
        version : PROJECT_VERSION,
-       vala_header : 'gxml.h',
-       vala_vapi : 'gxml-@0@.vapi'.format(API_VERSION),
-       vala_gir : 'GXml-@0@.gir'.format(API_VERSION),
+       vala_header : PROJECT_NAME+'.h',
+       vala_vapi : VAPI_NAME,
+       vala_gir : GIR_NAME,
        dependencies : [ gee, gio, xml, namespaceinfo_dep ],
        c_args : [
                '-include',
@@ -146,14 +150,14 @@ gxml = library('gxml-@0@'.format(API_VERSION),
        ])
 
 g_ir_compiler = find_program('g-ir-compiler')
-custom_target('gxml-typelib',
+custom_target('typelib',
        command: [
                g_ir_compiler,
-               '--shared-library', 'libgxml-@0@.so'.format (API_VERSION),
+               '--shared-library', 'lib'+PROJECT_NAME+'-@0@.so'.format (API_VERSION),
                '--output', '@OUTPUT@',
-               join_paths(meson.current_build_dir(), 'GXml-@0@.gir'.format(API_VERSION))
+               join_paths(meson.current_build_dir(), GIR_NAME)
        ],
-       output: 'GXml-@0@.typelib'.format(API_VERSION),
-       depends: gxml,
+       output: TYPELIB_NAME,
+       depends: lib,
        install: true,
        install_dir: join_paths(get_option('libdir'), 'girepository-1.0'))
diff --git a/meson.build b/meson.build
index cc983f7..28eeb57 100644
--- a/meson.build
+++ b/meson.build
@@ -1,5 +1,12 @@
 project('gxml', [ 'vala', 'c'])
 
+PROJECT_NAME = 'gxml'
+API_VERSION = '0.14'
+PROJECT_VERSION = '0.15.0'
+VERSIONED_PROJECT_NAME = PROJECT_NAME+'-'+API_VERSION
+CAMEL_CASE_NAME = 'GXml'
+VERSIONED_CAMEL_CASE_NAME = CAMEL_CASE_NAME +'-'+ API_VERSION
+
 xml = dependency('libxml-2.0')
 gio = dependency('gio-2.0')
 gee = dependency('gee-0.8')
@@ -7,9 +14,6 @@ gee = dependency('gee-0.8')
 VALADEPS = 'gee-0.8\ngio-2.0\nlibxml-2.0'
 PCDEPS = 'gee-0.8 gio-2.0 libxml-2.0'
 
-API_VERSION = '0.14'
-PROJECT_VERSION = '0.15.0'
-
 xlibxml_cflags = '-I' + meson.current_source_dir()
 
 conf = configuration_data()
diff --git a/po/meson.build b/po/meson.build
index fd8855b..4b355bf 100644
--- a/po/meson.build
+++ b/po/meson.build
@@ -1,2 +1,2 @@
 i18n = import('i18n')
-i18n.gettext('GXml', preset : 'glib')
+i18n.gettext(CAMEL_CASE_NAME, preset : 'glib')
diff --git a/test/meson.build b/test/meson.build
index 87d0fe8..a610ab4 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -1,58 +1,51 @@
-glib_dep = dependency('glib-2.0')
-gobject_dep = dependency('gobject-2.0')
-gio_dep = dependency('gio-2.0')
-gee_dep = dependency('gee-0.8')
-lxml_dep = dependency('libxml-2.0')
-gxmlh_dep = declare_dependency (include_directories : inc_gxmlh)
 testdirs_dep = declare_dependency (compile_args : [
        '-DTEST_DIR="'+join_paths (meson.source_root (),'test')+'"',
        '-DTEST_SAVE_DIR="'+join_paths (meson.build_root (),'test')+'"',
 ])
-envtestdir = environment ()
-envtestdir.set ('TEST_DIR',meson.source_root ())
-envtestdir.set ('TEST_SAVE_DIR',meson.build_root ())
 
-t = executable('gxml_test', [
-       'GXmlTest.vala',
-       'NodeListTest.vala',
-       'ValaLibxml2Test.vala',
-       'EnumerationTest.vala',
-       'SerializableTest.vala',
-       'SerializablePropertyBoolTest.vala',
-       'SerializablePropertyDoubleTest.vala',
-       'SerializablePropertyFloatTest.vala',
-       'SerializablePropertyEnumTest.vala',
-       'SerializablePropertyIntTest.vala',
-       'SerializablePropertyValueListTest.vala',
-       'SerializableObjectModelTest.vala',
-       'SerializableObjectModel-TDocument-Test.vala',
-       'SerializableGeeTreeMapTest.vala',
-       'SerializableGeeDualKeyMapTest.vala',
-       'SerializableGeeArrayListTest.vala',
-       'SerializableGeeHashMapTest.vala',
-       'SerializableGeeCollectionsTest.vala',
-       'SerializableGeeCollections-TDocument-Test.vala',
-       'SerializableBasicTypesTest.vala',
-       'gxml-performance.vala',
-       'TElementTest.vala',
-       'TDocumentTest.vala',
-       'TCDATATest.vala',
-       'TCommentTest.vala',
-       'TProcessingInstructionTest.vala',
-       'GDocumentTest.vala',
-       'GElementTest.vala',
-       'GAttributeTest.vala',
-       'HtmlDocumentTest.vala',
-       'DomGDocumentTest.vala',
-       'XPathTest.vala',
-       'GomDocumentTest.vala',
-       'GomElementTest.vala',
-       'GomSerializationTest.vala',
-       'GomSchemaTest.vala'
-] + configvapi + configtestvapi,
-vala_args : [],
-dependencies : [glib_dep, gobject_dep, gio_dep, gee_dep, lxml_dep, gxmlh_dep, testdirs_dep],
-link_with: gxml
+files_tests = ([
+               'GXmlTest.vala',
+               'NodeListTest.vala',
+               'ValaLibxml2Test.vala',
+               'EnumerationTest.vala',
+               'SerializableTest.vala',
+               'SerializablePropertyBoolTest.vala',
+               'SerializablePropertyDoubleTest.vala',
+               'SerializablePropertyFloatTest.vala',
+               'SerializablePropertyEnumTest.vala',
+               'SerializablePropertyIntTest.vala',
+               'SerializablePropertyValueListTest.vala',
+               'SerializableObjectModelTest.vala',
+               'SerializableObjectModel-TDocument-Test.vala',
+               'SerializableGeeTreeMapTest.vala',
+               'SerializableGeeDualKeyMapTest.vala',
+               'SerializableGeeArrayListTest.vala',
+               'SerializableGeeHashMapTest.vala',
+               'SerializableGeeCollectionsTest.vala',
+               'SerializableGeeCollections-TDocument-Test.vala',
+               'SerializableBasicTypesTest.vala',
+               'gxml-performance.vala',
+               'TElementTest.vala',
+               'TDocumentTest.vala',
+               'TCDATATest.vala',
+               'TCommentTest.vala',
+               'TProcessingInstructionTest.vala',
+               'GDocumentTest.vala',
+               'GElementTest.vala',
+               'GAttributeTest.vala',
+               'HtmlDocumentTest.vala',
+               'DomGDocumentTest.vala',
+               'XPathTest.vala',
+               'GomDocumentTest.vala',
+               'GomElementTest.vala',
+               'GomSerializationTest.vala',
+               'GomSchemaTest.vala'
+       ])
+
+t = executable('tests', files_tests + configvapi + configtestvapi,
+       vala_args : [],
+       dependencies : [ gio, gee, xml, inc_libh_dep, testdirs_dep],
+       link_with: lib
 )
 
-test ('gxml', t)
+test ('tests', t)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]