From cb392256bf6ec0f70c7611a1fcb0898eda03d1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Fri, 5 Apr 2024 17:25:07 +0200 Subject: [PATCH] build: Add support for when the build is sandboxed When using flatpak-cargo-generator, the crates cannot be placed in the build dir before the build happens, so we must change the CARGO_HOME env variable. --- meson.options | 8 ++++++++ src/meson.build | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/meson.options b/meson.options index 12d03017..7e59a5ac 100644 --- a/meson.options +++ b/meson.options @@ -10,3 +10,11 @@ option( value: 'default', description: 'The build profile for Fractal. One of "default", "beta", "development" or "hack".' ) +option( + 'sandboxed', + type : 'boolean', + value : false, + description: 'Whether the build happens in a sandbox.' + + 'When that is the case, cargo will not be able to download the dependencies during' + + 'the build so they are assumed to be in meson.project_source_root()/cargo' +) diff --git a/src/meson.build b/src/meson.build index f9a266e2..c589d51a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -39,7 +39,12 @@ else message('Building in release mode') endif -cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ] +if get_option('sandboxed') + # This is the path used by flatpak-cargo-generator in flatpak-builder-tools + cargo_env = [ 'CARGO_HOME=' + meson.project_source_root() / 'cargo' ] +else + cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ] +endif custom_target( 'cargo-build',