Skip to content

Commit a727e2d

Browse files
committed
fix: make building of kernel errors file conditional on env variable
1 parent d4e1182 commit a727e2d

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

.github/workflows/lint.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,18 @@ jobs:
7171
override: true
7272
- name: check rust versions
7373
run: ./scripts/check-rust-version.sh
74+
75+
kernel_errors:
76+
name: kernel errors check
77+
runs-on: ubuntu-latest
78+
steps:
79+
- uses: actions/checkout@main
80+
- name: Rustup
81+
run: rustup update --no-self-update
82+
- uses: Swatinem/rust-cache@v2
83+
with:
84+
save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/next' }}
85+
- name: Rebuild kernel errors
86+
run: BUILD_KERNEL_ERRORS=1 cargo check -p miden-tx
87+
- name: Diff check
88+
run: git diff --exit-code

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ help:
99
WARNINGS=RUSTDOCFLAGS="-D warnings"
1010
DEBUG_ASSERTIONS=RUSTFLAGS="-C debug-assertions"
1111
ALL_FEATURES_BUT_ASYNC=--features concurrent,testing
12+
BUILD_KERNEL_ERRORS=BUILD_KERNEL_ERRORS=1
1213

1314
# -- linting --------------------------------------------------------------------------------------
1415

@@ -70,18 +71,18 @@ test: test-default test-prove ## Run all tests
7071

7172
.PHONY: check
7273
check: ## Check all targets and features for errors without code generation
73-
cargo check --all-targets $(ALL_FEATURES_BUT_ASYNC)
74+
${BUILD_KERNEL_ERRORS} cargo check --all-targets $(ALL_FEATURES_BUT_ASYNC)
7475

7576
# --- building ------------------------------------------------------------------------------------
7677

7778
.PHONY: build
7879
build: ## By default we should build in release mode
79-
cargo build --release
80+
${BUILD_KERNEL_ERRORS} cargo build --release
8081

8182

8283
.PHONY: build-no-std
8384
build-no-std: ## Build without the standard library
84-
cargo build --no-default-features --target wasm32-unknown-unknown --workspace --lib
85+
${BUILD_KERNEL_ERRORS} cargo build --no-default-features --target wasm32-unknown-unknown --workspace --lib
8586

8687

8788
.PHONY: build-no-std-testing
@@ -91,7 +92,7 @@ build-no-std-testing: ## Build without the standard library. Includes the `testi
9192

9293
.PHONY: build-async
9394
build-async: ## Build with the `async` feature enabled (only libraries)
94-
cargo build --lib --release --features async
95+
${BUILD_KERNEL_ERRORS} cargo build --lib --release --features async
9596

9697

9798
# --- benchmarking --------------------------------------------------------------------------------

miden-tx/build.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,20 @@ const ASM_DIR: &str = "../miden-lib/asm";
1111
const KERNEL_ERRORS_FILE: &str = "src/errors/tx_kernel_errors.rs";
1212
const MASM_FILE_EXTENSION: &str = "masm";
1313

14+
/// Generates error mappings for transaction kernel errors.
15+
///
16+
/// This is done only if BUILD_KERNEL_ERRORS environment variable is set to `1` to avoid running
17+
/// the script on crates.io where MASM files from miden-lib are not available.
1418
fn main() -> Result<()> {
1519
// re-build when the MASM code changes
1620
println!("cargo:rerun-if-changed={ASM_DIR}");
1721
println!("cargo:rerun-if-changed={KERNEL_ERRORS_FILE}");
22+
println!("cargo::rerun-if-env-changed=BUILD_KERNEL_ERRORS");
23+
24+
// Skip this build script in BUILD_KERNEL_ERRORS environment variable is not set to `1`.
25+
if env::var("BUILD_KERNEL_ERRORS").unwrap_or("0".to_string()) == "0" {
26+
return Ok(());
27+
}
1828

1929
// Copies the MASM code to the build directory
2030
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();

0 commit comments

Comments
 (0)