meson: Don't mangle profile and app id suffix

This commit is contained in:
Sophie Herold 2024-09-27 21:22:52 +02:00
parent bf9392e8a2
commit f6b7ae7567
8 changed files with 28 additions and 27 deletions

View file

@ -15,7 +15,7 @@ flatpak:
variables:
# We are running tests manually
RUN_TESTS: "0"
CONFIG_OPTS: "-Dprofile=ci"
CONFIG_OPTS: "-Dprofile=release -Dapp_id_suffix=.Devel"
flatpak@aarch64:
extends: ".flatpak@aarch64"
@ -23,7 +23,7 @@ flatpak@aarch64:
interruptible: true
variables:
RUN_TESTS: "0"
CONFIG_OPTS: "-Dprofile=ci"
CONFIG_OPTS: "-Dprofile=release -Dapp_id_suffix=.Devel"
cargo-fmt:
image: "rust:slim"

View file

@ -120,7 +120,8 @@
"name": "loupe",
"buildsystem": "meson",
"config-opts": [
"-Dprofile=development"
"-Dprofile=dev",
"-Dapp_id_suffix=.Devel"
],
"sources": [
{

View file

@ -108,7 +108,7 @@ gschema_conf = configuration_data()
gschema_conf.set('app-id', app_id)
gschema_conf.set('gettext-package', meson.project_name())
configure_file(
input: '@0@.gschema.xml.in'.format(base_id),
input: 'org.gnome.Loupe.gschema.xml.in',
output: '@0@.gschema.xml'.format(app_id),
configuration: gschema_conf,
install: true,

View file

@ -24,11 +24,9 @@ gtk4_x11 = dependency('gtk4-x11', required: get_option('x11'))
cargo = find_program('cargo', required: true)
glib_compile_schemas = find_program('glib-compile-schemas', required: true)
profile = ''
version_suffix = ''
if get_option('profile') != 'release'
profile = '.Devel'
vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD', check: false).stdout().strip()
if vcs_tag == ''
version_suffix = '-devel'
@ -39,8 +37,8 @@ endif
prefix = get_option('prefix')
base_id = 'org.gnome.Loupe'
app_id = 'org.gnome.Loupe@0@'.format(profile)
app_id = 'org.gnome.Loupe@0@'.format(get_option('app_id_suffix'))
profile = get_option('profile')
version = meson.project_version() + version_suffix
localedir = prefix / get_option('localedir')
bindir = prefix / get_option('bindir')

View file

@ -1,13 +1,16 @@
option(
'profile',
type: 'combo',
description: 'The build profiles for the application. Use development or ci for the .Devel app ID. ci also produces optimized bundles.',
choices: [
'release',
'development',
'ci',
],
choices: ['release', 'dev'],
value: 'release',
description: 'Cargo profile value.',
)
option(
'app_id_suffix',
type: 'combo',
choices: ['', '.Devel'],
value: '',
description: 'Value will be appended to the app id.',
)
option(
'x11',

View file

@ -16,7 +16,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pub const APP_ID: &str = default_env(option_env!("APP_ID"), "org.gnome.Loupe.Devel");
pub const PROFILE: &str = default_env(option_env!("PROFILE"), ".Devel");
pub const VERSION: &str = default_env(option_env!("VERSION"), "unknown");
pub const LOCALEDIR: &str = default_env(option_env!("LOCALEDIR"), "/usr/share/locale/");

View file

@ -3,28 +3,26 @@ source_root = meson.project_source_root()
cargo_options = ['--manifest-path', source_root / 'Cargo.toml']
cargo_options += ['--target-dir', build_root / 'src']
if get_option('profile') == 'development'
rust_target = 'debug'
message('Building in debug mode')
else
cargo_options += ['--release']
rust_target = 'release'
message('Building in release mode')
endif
cargo_options += ['--profile', profile]
if gtk4_x11.found()
cargo_options += ['--features', 'x11']
endif
if profile == 'dev'
rust_target = 'debug'
elif profile == 'release'
rust_target = 'release'
endif
cargo_env = {
'CARGO_HOME': build_root / 'cargo-home',
'APP_ID': app_id,
'PROFILE': profile,
'VERSION': version,
'LOCALEDIR': localedir,
}
# Build binary
cargo_build = custom_target(
'cargo-build',
build_by_default: true,
@ -39,6 +37,7 @@ cargo_build = custom_target(
],
)
# Copy binary
custom_target(
'cp-binary',
depends: cargo_build,
@ -67,6 +66,7 @@ custom_target(
],
)
# Run tests
test(
'cargo-test',
cargo,

View file

@ -205,7 +205,7 @@ mod imp {
}
));
if config::PROFILE == ".Devel" {
if config::APP_ID.ends_with(".Devel") {
obj.add_css_class("devel");
}