Files

99 lines
3.2 KiB
Meson

project('regent', 'rust',
version: '0.1.0',
license: 'Unlicense',
meson_version: '>= 1.1',
)
gnome = import('gnome')
cargo = find_program('cargo')
blueprint_compiler = find_program('blueprint-compiler')
# A development/nightly build is a separate application identity, per the GNOME
# convention: the app id carries a `.Devel` suffix and *everything* derived from
# it follows — the desktop file, the AppStream id, the icon, the GSettings schema
# id and path, the GResource bundle name, the well-known D-Bus name and the XDG
# data/config/cache directories. That is what lets a nightly Regent run beside a
# stable one without clobbering its config or fighting over the D-Bus name.
#
# Select it with `-Dprofile=development`; the default builds the stable identity.
# The binary is named `regent-devel` too, so a `~/.local` nightly install does not
# overwrite the stable `regent` on PATH (see `build-aux/regent-deploy.sh`).
profile = get_option('profile')
devel = profile == 'development'
if devel
app_id = 'org.kosmos.raucao.Regent.Devel'
binary_name = 'regent-devel'
# The Rust side switches `APP_ID`/`RESOURCE_PATH` on this cargo feature; see
# src/main.rs. A feature (not an env var) so the shared cargo target directory
# cannot hand back a binary built for the other profile.
cargo_features = '--features devel'
else
app_id = 'org.kosmos.raucao.Regent'
binary_name = 'regent'
cargo_features = ''
endif
# The GSettings path is the app id with dots replaced by slashes. (The GResource
# prefix is separate and fixed in data/resources/resources.gresource.xml.)
app_path = '/' + app_id.replace('.', '/')
pkgdatadir = get_option('datadir') / app_id
subdir('data')
# Meson has no native cargo integration, so cargo is driven through a sh -c
# wrapper that also copies the binary to the location Meson expects. Every
# source file is listed as an input so edits trigger a rebuild.
cargo_build = custom_target(binary_name,
output: binary_name,
input: files(
'Cargo.toml',
'Cargo.lock',
'src/main.rs',
'src/application.rs',
'src/config.rs',
'src/headless.rs',
'src/instance.rs',
'src/portal.rs',
'src/runner.rs',
'src/runtime.rs',
'src/sanitize.rs',
'src/signer/approval.rs',
'src/signer/mod.rs',
'src/signer/policy.rs',
'src/state.rs',
'src/store/apps.rs',
'src/store/audit.rs',
'src/store/icons.rs',
'src/store/mod.rs',
'src/store/keys.rs',
'src/store/nip05.rs',
'src/store/profiles.rs',
'src/ui/about.rs',
'src/ui/activity_view.rs',
'src/ui/apps_view.rs',
'src/ui/approval.rs',
'src/ui/connect.rs',
'src/ui/content.rs',
'src/ui/kind.rs',
'src/ui/keys_view.rs',
'src/ui/mod.rs',
'src/ui/plain.rs',
'src/ui/preferences.rs',
'src/ui/qr.rs',
'src/ui/switcher.rs',
'src/ui/tray.rs',
'src/window.rs',
),
command: [
find_program('sh'), '-c',
'cargo build --release --locked @0@ --manifest-path "$1" --target-dir "$2" && cp "$2/release/regent" "$3"'.format(cargo_features),
'sh',
meson.current_source_dir() / 'Cargo.toml',
meson.current_build_dir() / 'cargo-target',
'@OUTPUT@',
],
build_by_default: true,
install: true,
install_dir: get_option('bindir'),
)