[gnome-break-timer/dylanmccall/meson-build: 3/25] Improved Meson build configuration



commit 09f5ee98b2c83b40b814c813cd683d87183bd876
Author: Dylan McCall <dylan dylanmccall com>
Date:   Fri Jun 8 23:13:58 2018 -0700

    Improved Meson build configuration
    
    For now we'll just build the settings application.

 common/meson.build   |  7 ++++---
 config.vala.in       |  9 ---------
 config.vapi          | 10 ++++++++++
 helper/meson.build   | 21 +++++++++++++++++++--
 meson.build          | 52 +++++++++++++++++++++++++++++-----------------------
 settings/meson.build | 23 ++++++++++++++++++-----
 6 files changed, 80 insertions(+), 42 deletions(-)
---
diff --git a/common/meson.build b/common/meson.build
index 885b299..0b8a3e3 100644
--- a/common/meson.build
+++ b/common/meson.build
@@ -5,6 +5,7 @@ common_sources = [
 ]
 
 common_dependencies = [
+    config_lib_dep,
     gio_dep
 ]
 
@@ -14,7 +15,7 @@ common_lib = static_library(
     dependencies: common_dependencies
 )
 
-common_dep = declare_dependency(
-    link_with: common_lib
+common_lib_dep = declare_dependency(
+    link_with: common_lib,
+    include_directories: include_directories('.')
 )
-
diff --git a/config.vapi b/config.vapi
new file mode 100644
index 0000000..328d656
--- /dev/null
+++ b/config.vapi
@@ -0,0 +1,10 @@
+[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")]
+namespace Config {
+       public const string GETTEXT_PACKAGE;
+       public const string PACKAGE_NAME;
+       public const string PACKAGE_VERSION;
+       public const string PACKAGE_URL;
+       public const string VERSION;
+       public const string HELPER_DESKTOP_ID;
+       public const string SETTINGS_DESKTOP_ID;
+}
diff --git a/helper/meson.build b/helper/meson.build
index 6fd7110..9776a50 100644
--- a/helper/meson.build
+++ b/helper/meson.build
@@ -17,7 +17,8 @@ helper_sources = [
     'HelperApplication.vala',
     'ScreenOverlay.vala',
     'SessionStatus.vala',
-    'UIManager.vala'
+    'UIManager.vala',
+    'main.vala'
 ]
 
 # TODO: Build and link activity_monitor and util subdirs
@@ -26,7 +27,7 @@ helper_dependencies = [
     gtk_dep,
     gio_dep,
     gio_unix_dep,
-    # gee_dep,
+    gee_dep,
     json_glib_dep,
     libcanberra_dep,
     libcanberra_gtk_dep,
@@ -44,3 +45,19 @@ helper_lib = static_library(
 helper_dep = declare_dependency(
     link_with: helper_lib
 )
+
+main_sources = [
+    'helper/main.vala'
+]
+
+main_dependencies = [
+    glib_dep,
+    gobject_dep
+]
+
+executable(
+    'gnome-break-timer-service',
+    sources : main_sources,
+    dependencies : main_dependencies
+)
+
diff --git a/meson.build b/meson.build
index 707cfa3..72bb4f7 100644
--- a/meson.build
+++ b/meson.build
@@ -1,7 +1,11 @@
 project('gnome-break-timer', 'vala', 'c')
 
+valac = meson.get_compiler('vala')
+
+env = environment()
+
 cairo_dep = dependency('cairo')
-# gee_dep = dependency('gee-0.8')
+gee_dep = dependency('gee-0.8')
 gio_dep = dependency('gio-2.0')
 gio_unix_dep = dependency('gio-unix-2.0')
 glib_dep = dependency('glib-2.0')
@@ -13,30 +17,32 @@ libcanberra_gtk_dep = dependency('libcanberra-gtk')
 libnotify_dep = dependency('libnotify')
 # posix_dep = dependency('posix')
 
-build_config_data = configuration_data()
-build_config_data.set('VERSION', '1.2.3')
-
-build_config = configure_file(
-    input : 'config.vala.in',
-    output : 'config.vala',
-    configuration : build_config_data
-)
+conf = configuration_data()
+conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
+conf.set_quoted('PACKAGE_NAME', meson.project_name())
+conf.set_quoted('PACKAGE_VERSION', meson.project_version())
+conf.set_quoted('PACKAGE_URL', 'TODO')
+conf.set_quoted('VERSION', meson.project_version())
+conf.set_quoted('HELPER_DESKTOP_ID', 'TODO')
+conf.set_quoted('SETTINGS_DESKTOP_ID', 'TODO')
 
-subdir('common')
-subdir('settings')
-subdir('helper')
+add_global_arguments('-DGETTEXT_PACKAGE="gnome-break-timer"', language: 'c')
 
-main_sources = [
-    'helper/main.vala'
-]
+configure_file(
+    output: 'config.h',
+    configuration: conf
+)
 
-main_dependencies = [
-    glib_dep,
-    gobject_dep
-]
+config_lib = valac.find_library(
+    'config',
+    dirs: meson.source_root()
+)
 
-executable(
-    'gnome-break-timer-service',
-    sources : main_sources,
-    dependencies : main_dependencies
+config_lib_dep = declare_dependency(
+    dependencies: config_lib,
+    include_directories: include_directories('.')
 )
+
+subdir('common')
+subdir('settings')
+# subdir('helper')
diff --git a/settings/meson.build b/settings/meson.build
index 534d757..38f8eb8 100644
--- a/settings/meson.build
+++ b/settings/meson.build
@@ -3,7 +3,6 @@
 #     $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(top_srcdir)/data/ --generate-source $<
 
 settings_sources = [
-    build_config,
     'BreakManager.vala',
     'BreakSettingsDialog.vala',
     'BreakType.vala',
@@ -18,12 +17,13 @@ settings_sources = [
 ]
 
 settings_dependencies = [
+    config_lib_dep,
+    common_lib_dep,
     cairo_dep,
     gtk_dep,
     gio_dep,
     gio_unix_dep,
-    # gee_dep,
-    common_dep
+    gee_dep
 ]
 
 settings_lib = static_library(
@@ -32,6 +32,19 @@ settings_lib = static_library(
     dependencies: settings_dependencies
 )
 
-settings_dep = declare_dependency(
-    link_with: settings_lib
+settings_lib_dep = declare_dependency(
+    link_with: settings_lib,
+    dependencies: settings_dependencies,
+    include_directories: include_directories('.')
+)
+
+settings_main_sources = [
+    'main.vala'
+]
+
+executable(
+    'gnome-break-timer-settings',
+    sources : settings_main_sources,
+    dependencies : settings_lib_dep,
+    install: true
 )


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