Skip to content

Commit

Permalink
build: Add sandboxed mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bragefuglseth committed May 29, 2024
1 parent 5656212 commit 824f407
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ option(
value: 'default',
description: 'The build profile for Fretboard. One of "default" or "development".'
)
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'
)

8 changes: 7 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ run_command(
cargo_bin = find_program('cargo')
cargo_opt = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ]
cargo_opt += [ '--target-dir', meson.project_build_root() / 'src' ]
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

if get_option('profile') == 'default'
cargo_opt += [ '--release' ]
Expand Down

0 comments on commit 824f407

Please sign in to comment.