Four cargo builds with four target directories compiled the GTK and GStreamer bindings four times; one build with a shared target directory takes a package build from about an hour to about seven minutes. Adds the ahfail binary and /etc/pam.d/ahfail to the install, the update_check option, an AUR PKGBUILD (offline build after cargo fetch --locked) and a tag-triggered workflow that publishes it and mirrors the PKGBUILD to the tarballz index. Claude-Session: https://claude.ai/code/session_012LCTmU2ewo8tnM1dByYAoG
100 lines
3.4 KiB
Meson
100 lines
3.4 KiB
Meson
project(
|
|
'ahfail',
|
|
['c', 'rust'],
|
|
version: '0.10.0',
|
|
meson_version: '>=1.3.0',
|
|
default_options: ['warning_level=3', 'c_std=c11']
|
|
)
|
|
|
|
ahfail_inc = include_directories('include')
|
|
|
|
cc = meson.get_compiler('c')
|
|
m_dep = cc.find_library('m', required : false)
|
|
gtk_dep = dependency('gtk+-3.0')
|
|
gstplayer_dep = dependency('gstreamer-player-1.0')
|
|
gnome = import('gnome')
|
|
|
|
resources = gnome.compile_resources(
|
|
'ahfail-resources',
|
|
'assets/ahfail.gresource.xml',
|
|
source_dir: 'assets',
|
|
c_name: 'ahfail'
|
|
)
|
|
|
|
# All Rust artefacts come from ONE cargo invocation with one target directory.
|
|
# Four separate builds with four target directories compiled the whole GTK and
|
|
# GStreamer binding stack four times over (about an hour for a package build).
|
|
#
|
|
# -Dupdate_check=false (distro packages) builds without the ahfail-ui feature
|
|
# `update-check`, so the binaries never ask Gitea for new releases and the HTTP
|
|
# client is not compiled in at all.
|
|
cargo_features = get_option('update_check') ? '' : '--no-default-features'
|
|
|
|
cargo_all = custom_target(
|
|
'ahfail-cargo-build',
|
|
input: ['Cargo.toml', 'Cargo.lock'],
|
|
output: ['libahfail_module.a', 'libahfail_pam.so', 'ahfail-display', 'ahfail'],
|
|
command: [
|
|
'sh', '-c',
|
|
# The PAM module's build.rs needs the absolute libdir to know where
|
|
# ahfail-display is installed; get_option('libdir') alone is relative.
|
|
'AHFAIL_LIBDIR=' + get_option('prefix') / get_option('libdir')
|
|
+ ' cargo build --release --locked'
|
|
+ ' -p ahfail-gtklock -p ahfail-pam -p ahfail-display -p ahfail ' + cargo_features
|
|
+ ' --target-dir "@OUTDIR@/target"'
|
|
+ ' && cp "@OUTDIR@/target/release/libahfail_module.a" "@OUTPUT0@"'
|
|
+ ' && cp "@OUTDIR@/target/release/libahfail_pam.so" "@OUTPUT1@"'
|
|
+ ' && cp "@OUTDIR@/target/release/ahfail-display" "@OUTPUT2@"'
|
|
+ ' && cp "@OUTDIR@/target/release/ahfail" "@OUTPUT3@"'
|
|
],
|
|
build_by_default: true,
|
|
build_always_stale: true, # cargo decides what is out of date, not meson
|
|
install: true,
|
|
# module archive: linked below, not installed; PAM module + display binary:
|
|
# libdir/ahfail; the ahfail command: bindir.
|
|
install_dir: [false, get_option('libdir') / 'ahfail', get_option('libdir') / 'ahfail', get_option('bindir')],
|
|
install_mode: 'rwxr-xr-x'
|
|
)
|
|
cargo_target = cargo_all[0]
|
|
pam_cargo = cargo_all[1]
|
|
|
|
# The locker's own PAM service. Shipped as its own file, like swaylock and
|
|
# gtklock do, so no other package's PAM configuration is ever touched.
|
|
install_data('data/pam.d/ahfail',
|
|
install_dir: get_option('sysconfdir') / 'pam.d',
|
|
install_mode: 'rw-r--r--'
|
|
)
|
|
|
|
libahfail = shared_library(
|
|
'ahfail-module',
|
|
resources,
|
|
link_args: ['-Wl,--whole-archive', meson.current_build_dir() / 'libahfail_module.a', '-Wl,--no-whole-archive'],
|
|
link_depends: cargo_target,
|
|
include_directories: ahfail_inc,
|
|
dependencies: [gtk_dep, gstplayer_dep, m_dep],
|
|
install: true,
|
|
install_dir: get_option('libdir') / 'gtklock',
|
|
name_prefix: ''
|
|
)
|
|
|
|
smoke = executable(
|
|
'module_smoke_test',
|
|
'tests/module_test.c',
|
|
include_directories: ahfail_inc,
|
|
link_with: libahfail,
|
|
dependencies: [gtk_dep, gstplayer_dep]
|
|
)
|
|
|
|
test('module symbols', smoke)
|
|
|
|
# PAM module smoke test: dlopen libahfail_pam.so and verify pam_sm_authenticate is exported.
|
|
pam_smoke = executable(
|
|
'pam_smoke_test',
|
|
'tests/pam_smoke_test.c',
|
|
dependencies: [cc.find_library('dl', required: true)]
|
|
)
|
|
|
|
test('pam symbols', pam_smoke,
|
|
args: [meson.current_build_dir() / 'libahfail_pam.so'],
|
|
depends: pam_cargo)
|