Skip to content

Commit

Permalink
Merge branch 'add-locked-to-cargo-build'
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Jan 30, 2025
2 parents af3d57f + 80583ad commit a07e803
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/testframework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:

- name: Build test framework
working-directory: test
run: cargo build --release
run: cargo build --release --locked

# Build the test runner + test manager at once.
build-test-framework-macos:
Expand All @@ -91,7 +91,7 @@ jobs:

- name: Build test runner
working-directory: test
run: cargo build
run: cargo build --locked

# Build only the test-runner binary on Windows. Windows is not a supported host for test-manager.
build-test-runner-windows:
Expand All @@ -112,4 +112,4 @@ jobs:

- name: Build test runner
working-directory: test
run: cargo build --release -p test-runner --target x86_64-pc-windows-gnu
run: cargo build --release --locked -p test-runner --target x86_64-pc-windows-gnu
16 changes: 12 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,17 @@ fi
if [[ "$OPTIMIZE" == "true" ]]; then
CARGO_ARGS+=(--release)
RUST_BUILD_MODE="release"
CPP_BUILD_MODE="Release"
NPM_PACK_ARGS+=(--release)
else
RUST_BUILD_MODE="debug"
NPM_PACK_ARGS+=(--no-compression)
fi
# The cargo builds that are part of the C++ builds only enforce `--locked` when built
# in release mode. And we must enforce `--locked` for all signed builds. So we enable
# release mode if either optimizations or signing is enabled.
if [[ "$OPTIMIZE" == "true" || "$SIGN" == "true" ]]; then
CPP_BUILD_MODE="Release"
else
CPP_BUILD_MODE="Debug"
fi

Expand All @@ -116,6 +122,11 @@ if [[ "$SIGN" == "true" ]]; then
exit 1
fi

# Will not allow an outdated lockfile when building with signatures
# (The build servers should never build without --locked for
# reproducibility and supply chain security)
CARGO_ARGS+=(--locked)

if [[ "$(uname -s)" == "Darwin" ]]; then
log_info "Configuring environment for signing of binaries"
if [[ -z ${CSC_LINK-} ]]; then
Expand Down Expand Up @@ -156,9 +167,6 @@ fi
if [[ "$IS_RELEASE" == "true" ]]; then
log_info "Removing old Rust build artifacts..."
cargo clean

# Will not allow an outdated lockfile in releases
CARGO_ARGS+=(--locked)
else
# Allow dev builds to override which API server to use at runtime.
CARGO_ARGS+=(--features api-override)
Expand Down
4 changes: 2 additions & 2 deletions desktop/packages/nseventforwarder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"scripts": {
"cargo-build": "tsc && cargo build",
"build-debug": "npm run cargo-build && mkdir -p debug && cp ${CARGO_TARGET_DIR:-../../../target}/debug/libnseventforwarder.dylib debug/index.node",
"build-arm": "npm run cargo-build -- --release --target aarch64-apple-darwin && mkdir -p dist/darwin-arm64 && cp ${CARGO_TARGET_DIR:-../../../target}/aarch64-apple-darwin/release/libnseventforwarder.dylib dist/darwin-arm64/index.node",
"build-x86": "npm run cargo-build -- --release --target x86_64-apple-darwin && mkdir -p dist/darwin-x64 && cp ${CARGO_TARGET_DIR:-../../../target}/x86_64-apple-darwin/release/libnseventforwarder.dylib dist/darwin-x64/index.node",
"build-arm": "npm run cargo-build -- --release --locked --target aarch64-apple-darwin && mkdir -p dist/darwin-arm64 && cp ${CARGO_TARGET_DIR:-../../../target}/aarch64-apple-darwin/release/libnseventforwarder.dylib dist/darwin-arm64/index.node",
"build-x86": "npm run cargo-build -- --release --locked --target x86_64-apple-darwin && mkdir -p dist/darwin-x64 && cp ${CARGO_TARGET_DIR:-../../../target}/x86_64-apple-darwin/release/libnseventforwarder.dylib dist/darwin-x64/index.node",
"clean": "rm -rf debug; rm -rf dist",
"lint": "eslint .",
"lint-fix": "eslint --fix ."
Expand Down
2 changes: 1 addition & 1 deletion windows/nsis-plugins/src/cleanup/cleanup.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<ModuleDefinitionFile>cleanup.def</ModuleDefinitionFile>
</Link>
<PreBuildEvent>
<Command>powershell.exe -Command "&amp; { Remove-Item Env:VSTEL_MSBuildProjectFullPath; cargo build --target i686-pc-windows-msvc --release -p mullvad-nsis }"
<Command>powershell.exe -Command "&amp; { Remove-Item Env:VSTEL_MSBuildProjectFullPath; cargo build --target i686-pc-windows-msvc --release --locked -p mullvad-nsis }"
</Command>
<Message>Build mullvad-nsis library</Message>
</PreBuildEvent>
Expand Down
2 changes: 1 addition & 1 deletion windows/nsis-plugins/src/log/log.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<ModuleDefinitionFile>log.def</ModuleDefinitionFile>
</Link>
<PreBuildEvent>
<Command>powershell.exe -Command "&amp; { Remove-Item Env:VSTEL_MSBuildProjectFullPath; cargo build --target i686-pc-windows-msvc --release -p mullvad-nsis }"
<Command>powershell.exe -Command "&amp; { Remove-Item Env:VSTEL_MSBuildProjectFullPath; cargo build --target i686-pc-windows-msvc --release --locked -p mullvad-nsis }"
</Command>
<Message>Build mullvad-nsis library</Message>
</PreBuildEvent>
Expand Down

0 comments on commit a07e803

Please sign in to comment.