From 8e019361f48e2cdc77ea22a7b47ceea9bac0e398 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 26 Jun 2023 11:38:25 +0200 Subject: [PATCH] Fix issues with the meson build --- ...vel.json => com.lemmygtk.lemoa.Devel.json} | 6 ++--- ...ic.svg => com.lemmygtk.lemoa-symbolic.svg} | 0 ...sktop.in => com.lemmygtk.lemoa.desktop.in} | 0 ...y-gtk.lemoa.svg => com.lemmygtk.lemoa.svg} | 0 data/meson.build | 6 +++-- meson.build | 26 +++++++++++++++---- meson_options.txt | 10 +++++++ src/config.rs | 2 +- src/meson.build | 20 +++++++++++--- 9 files changed, 54 insertions(+), 16 deletions(-) rename build-aux/{com.lemmy-gtk.lemoa.Devel.json => com.lemmygtk.lemoa.Devel.json} (94%) rename data/{com.lemmy-gtk.lemoa-symbolic.svg => com.lemmygtk.lemoa-symbolic.svg} (100%) rename data/{com.lemmy-gtk.lemoa.desktop.in => com.lemmygtk.lemoa.desktop.in} (100%) rename data/{com.lemmy-gtk.lemoa.svg => com.lemmygtk.lemoa.svg} (100%) create mode 100644 meson_options.txt diff --git a/build-aux/com.lemmy-gtk.lemoa.Devel.json b/build-aux/com.lemmygtk.lemoa.Devel.json similarity index 94% rename from build-aux/com.lemmy-gtk.lemoa.Devel.json rename to build-aux/com.lemmygtk.lemoa.Devel.json index 23bedab..977eb9e 100644 --- a/build-aux/com.lemmy-gtk.lemoa.Devel.json +++ b/build-aux/com.lemmygtk.lemoa.Devel.json @@ -13,7 +13,7 @@ "--socket=fallback-x11", "--socket=wayland", "--device=dri", - "--env=RUST_LOG=gtk_rust_template=debug", + "--env=RUST_LOG=lemoa=debug", "--env=G_MESSAGES_DEBUG=none", "--env=RUST_BACKTRACE=1" ], @@ -38,7 +38,7 @@ { "name": "lemoa", "buildsystem": "meson", - "run-tests": true, + "builddir": true, "config-opts": [ "-Dprofile=development" ], @@ -51,5 +51,3 @@ } ] } - - diff --git a/data/com.lemmy-gtk.lemoa-symbolic.svg b/data/com.lemmygtk.lemoa-symbolic.svg similarity index 100% rename from data/com.lemmy-gtk.lemoa-symbolic.svg rename to data/com.lemmygtk.lemoa-symbolic.svg diff --git a/data/com.lemmy-gtk.lemoa.desktop.in b/data/com.lemmygtk.lemoa.desktop.in similarity index 100% rename from data/com.lemmy-gtk.lemoa.desktop.in rename to data/com.lemmygtk.lemoa.desktop.in diff --git a/data/com.lemmy-gtk.lemoa.svg b/data/com.lemmygtk.lemoa.svg similarity index 100% rename from data/com.lemmy-gtk.lemoa.svg rename to data/com.lemmygtk.lemoa.svg diff --git a/data/meson.build b/data/meson.build index 89afe05..7bbcc4b 100644 --- a/data/meson.build +++ b/data/meson.build @@ -15,12 +15,14 @@ configure_file( # Scalable icon install_data( - '@0@.svg'.format(application_id), + '@0@.svg'.format(base_id), install_dir: iconsdir / 'hicolor' / 'scalable' / 'apps', + rename: '@0@.svg'.format(application_id) ) # Symbolic icon install_data( - '@0@-symbolic.svg'.format(application_id), + '@0@-symbolic.svg'.format(base_id), install_dir: iconsdir / 'hicolor' / 'symbolic' / 'apps', + rename: '@0@-symbolic.svg'.format(application_id) ) diff --git a/meson.build b/meson.build index 78cf8df..0f5ff27 100644 --- a/meson.build +++ b/meson.build @@ -8,8 +8,10 @@ project( gnome = import('gnome') -application_id = 'com.lemmygtk.lemoa' +base_id = 'com.lemmygtk.lemoa' +version = meson.project_version() +# Required packages dependency('glib-2.0', version: '>= 2.70') dependency('gio-2.0', version: '>= 2.70') dependency('gtk4', version: '>= 4.10.0') @@ -19,16 +21,31 @@ glib_compile_schemas = find_program('glib-compile-schemas', required: true) desktop_file_validate = find_program('desktop-file-validate', required: false) cargo = find_program('cargo', required: true) -version = meson.project_version() - +# Various directories needed for building prefix = get_option('prefix') bindir = prefix / get_option('bindir') - datadir = prefix / get_option('datadir') iconsdir = datadir / 'icons' applicationsdir = datadir / 'applications' pkgdatadir = datadir / meson.project_name() +# Add a version suffix for devel builds +if get_option('profile') == 'development' + profile = 'Devel' + vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD', check: false).stdout().strip() + if vcs_tag == '' + version_suffix = '-devel' + else + version_suffix = '-@0@'.format(vcs_tag) + endif + application_id = '@0@.@1@'.format(base_id, profile) +else + profile = '' + version_suffix = '' + application_id = base_id +endif + +# Modules that need to be built subdir('src') subdir('data') @@ -37,4 +54,3 @@ gnome.post_install( glib_compile_schemas: true, update_desktop_database: true, ) - diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..e6128dd --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,10 @@ +option( + 'profile', + type: 'combo', + choices: [ + 'default', + 'development' + ], + value: 'default', + description: 'The build profile for GTK Rust Template. One of "default" or "development".' +) diff --git a/src/config.rs b/src/config.rs index 03d0d73..ea7d279 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,3 +1,3 @@ -pub const APP_ID: &str = "com.lemmy-gtk.lemoa"; +pub const APP_ID: &str = "com.lemmygtk.lemoa"; pub const PKGDATADIR: &str = "/usr/local/share/lemoa"; pub const VERSION: &str = "0.1.0"; diff --git a/src/meson.build b/src/meson.build index af45b8f..3a26732 100644 --- a/src/meson.build +++ b/src/meson.build @@ -2,14 +2,16 @@ conf = configuration_data() conf.set_quoted('APP_ID', application_id) conf.set_quoted('PKGDATADIR', pkgdatadir) -conf.set_quoted('VERSION', version) +conf.set_quoted('VERSION', version + version_suffix) +# Update the application config info configure_file( input: 'config.rs.in', output: 'config.rs', configuration: conf ) +# copy the config info into the project run_command( 'cp', join_paths(meson.project_build_root(), 'src', 'config.rs'), @@ -20,10 +22,21 @@ run_command( # Setup cargo cargo = find_program('cargo') cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ] + cargo_options = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ] cargo_options += [ '--target-dir', meson.project_build_root() / 'target' ] -cargo_options += [ '--release' ] +# If the profile is development, build as debug, otherwise release +if get_option('profile') == 'default' + cargo_options += [ '--release' ] + rust_target = 'release' + message('Building in release mode') +else + rust_target = 'debug' + message('Building in debug mode') +endif + +# Build the actual package cargo_release = custom_target( 'cargo-build', build_by_default: true, @@ -38,7 +51,6 @@ cargo_release = custom_target( cargo, 'build', cargo_options, '&&', - 'cp', 'target' / 'release' / meson.project_name(), '@OUTPUT@', + 'cp', 'target' / rust_target / meson.project_name(), '@OUTPUT@', ] ) -