project( 'ca-certs', version: '0.1.0', meson_version: '>=0.60.0', ) cargo = find_program('cargo', required: true) sh = find_program('sh', required: true) # Track Rust inputs explicitly so Meson knows when the Cargo build output is stale. tracked_rust_inputs = files( 'Cargo.toml', 'Cargo.lock', 'src/main.rs', ) tracked_install_paths = [ join_paths(get_option('bindir'), 'ca-certs'), join_paths(get_option('datadir'), 'licenses', meson.project_name(), 'LICENSE'), join_paths(get_option('mandir'), 'man8', 'ca-certs.8'), join_paths(get_option('datadir'), 'bash-completion', 'completions', 'ca-certs'), join_paths(get_option('datadir'), 'fish', 'vendor_completions.d', 'ca-certs.fish'), join_paths(get_option('datadir'), 'zsh', 'site-functions', '_ca-certs'), ] cargo_target_dir = meson.current_build_dir() / 'cargo-target' ca_certs_bin_path = meson.current_build_dir() / 'ca-certs' ca_certs_bin = custom_target( 'ca-certs-bin', output: 'ca-certs', depend_files: tracked_rust_inputs, command: [ sh, '-c', 'set -eu; src="$1"; out="$2"; target_dir="$3"; cd "$src"; CARGO_TARGET_DIR="$target_dir" "$4" build --locked --release; cp "$target_dir/release/ca-certs" "$out"', 'meson-cargo-build', meson.project_source_root(), ca_certs_bin_path, cargo_target_dir, cargo, ], build_by_default: true, console: true, install: true, install_dir: get_option('bindir'), ) meson.add_install_script( sh, files('scripts/install-generated-docs.sh'), ca_certs_bin_path, get_option('mandir'), get_option('datadir'), ) summary( { 'tracked rust inputs': tracked_rust_inputs.length(), 'generated docs on install': true, 'tracked install paths': '\n ' + '\n '.join(tracked_install_paths), }, section: 'Packaging', )