From f8d61d957d4a2d086f4b97f2e3d7d19d0bb35f13 Mon Sep 17 00:00:00 2001 From: Vika Date: Sun, 1 Sep 2024 18:10:26 +0300 Subject: Mesonify build This took a while and had me scratching my head often. But I managed to combine the best parts of Crane and Meson together, allowing me to have blazing fast Nix builds. This also adds initial scaffolding for gettext and other cool things. --- src/meson.build | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/meson.build (limited to 'src') diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..350b911 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,36 @@ +cargo_options = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ] +cargo_options += [ '--target-dir', meson.project_build_root() / 'src' ] + +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 + +cargo_env = [ + 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home', + 'PKGDATADIR=' + pkgdatadir, + 'LOCALEDIR=' + localedir, +] + +cargo_build = custom_target( + 'cargo-build', + build_by_default: true, + build_always_stale: true, + output: meson.project_name(), + console: true, + install: true, + install_dir: bindir, + #depends: resources, + command: [ + 'env', + cargo_env, + cargo, 'build', + cargo_options, + '&&', + 'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@', + ] +) -- cgit 1.4.1