Browse Source

build: Clean up meson files

Use `env` parameter instead of adding it to the command, and copy the
hook rather than adding a symbolic link to it to avoid losing it with
`cargo clean`.
merge-requests/2152/head
Kévin Commaille 1 week ago
parent
commit
254644290c
No known key found for this signature in database
GPG Key ID: F26F4BE20A08255B
  1. 24
      meson.build
  2. 10
      src/meson.build

24
meson.build

@ -116,25 +116,23 @@ if profile == 'Devel'
release_date = run_command('git', 'show', '-s', '--format=%cI', check: true).stdout().strip()
# Setup pre-commit hook for ensuring coding style is always consistent
checks_build_result = run_command(
'env',
cargo_env,
message('Compiling pre-commit binary…')
run_command(
cargo,
'build',
'--manifest-path',
'hooks/checks/Cargo.toml',
check: true,
env: cargo_env,
)
if checks_build_result.returncode() == 0
run_command(
'ln',
'-s',
cp_bin_result = run_command(
'cp',
'-f',
cargo_target_dir / 'debug/checks',
'hooks/checks-bin',
check: false,
)
cp_result = run_command(
cp_hook_result = run_command(
'cp',
'-f',
'hooks/pre-commit.hook',
@ -142,10 +140,14 @@ if profile == 'Devel'
check: false,
)
if cp_result.returncode() == 0
if cp_bin_result.returncode() == 0 and cp_hook_result.returncode() == 0
message('Pre-commit hook installed')
else
message('Could not install pre-commit hook: ' + cp_result.stderr())
if cp_bin_result.returncode() != 0
message('Could not install pre-commit binary: ' + cp_bin_result.stderr())
endif
if cp_hook_result.returncode() != 0
message('Could not install pre-commit hook: ' + cp_hook_result.stderr())
endif
endif
endif

10
src/meson.build

@ -108,9 +108,8 @@ if not build_env_only
install: true,
install_dir: bindir,
depends: [resources, ui_resources],
env: cargo_env,
command: [
'env',
cargo_env,
cargo,
'build',
cargo_options,
@ -128,9 +127,8 @@ if not build_env_only
output: 'junit.xml',
console: true,
depends: [resources, ui_resources],
env: cargo_env,
command: [
'env',
cargo_env,
'cargo-nextest',
'nextest',
'run',
@ -180,13 +178,11 @@ cargo_doc_options = ['--package=fractal', '--no-deps', '-Zrustdoc-map']
custom_target(
'cargo-doc',
build_by_default: false,
build_always_stale: true,
output: 'doc',
console: true,
env: cargo_env + cargo_doc_env,
command: [
'env',
cargo_env + cargo_doc_env,
cargo,
'doc',
cargo_options + cargo_doc_options,

Loading…
Cancel
Save