Skip to content

Commit fd9b839

Browse files
Try to determine the active Rust toolchain and print a helpful warning if it does not match the version defined in our toolchain file.
1 parent 66f308a commit fd9b839

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

Makefile

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,8 @@ bpf-bytecode:
483483
endif
484484

485485
.PHONY: rdpclient
486-
rdpclient:
486+
rdpclient: rustup-toolchain-warning
487487
ifeq ("$(with_rdpclient)", "yes")
488-
@rustup -q override unset
489488
$(RDPCLIENT_ENV) \
490489
cargo build -p rdp-client $(if $(FIPS),--features=fips) --release --locked $(CARGO_TARGET)
491490
endif
@@ -505,7 +504,6 @@ export ironrdp_package_json
505504
.PHONY: build-ironrdp-wasm
506505
build-ironrdp-wasm: ironrdp = web/packages/shared/libs/ironrdp
507506
build-ironrdp-wasm: ensure-wasm-deps
508-
@rustup -q override unset
509507
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' cargo build --package ironrdp --lib --target $(CARGO_WASM_TARGET) --release
510508
wasm-opt target/$(CARGO_WASM_TARGET)/release/ironrdp.wasm -o target/$(CARGO_WASM_TARGET)/release/ironrdp.wasm -O
511509
wasm-bindgen target/$(CARGO_WASM_TARGET)/release/ironrdp.wasm --out-dir $(ironrdp)/pkg --typescript --target web
@@ -1868,7 +1866,7 @@ ensure-js-deps:
18681866
ifeq ($(WEBASSETS_SKIP_BUILD),1)
18691867
ensure-wasm-deps:
18701868
else
1871-
ensure-wasm-deps: ensure-wasm-bindgen ensure-wasm-opt
1869+
ensure-wasm-deps: rustup-toolchain-warning ensure-wasm-bindgen ensure-wasm-opt
18721870

18731871
WASM_BINDGEN_VERSION = $(shell awk ' \
18741872
$$1 == "name" && $$3 == "\"wasm-bindgen\"" { in_pkg=1; next } \
@@ -1925,6 +1923,26 @@ rustup-set-version: ; # obsoleted by toolchain file
19251923
rustup-install-target-toolchain:
19261924
rustup target add $(RUST_TARGET_ARCH)
19271925

1926+
1927+
define rust_toolchain_warning
1928+
The active Rust toolchain version does not match the toolchain required
1929+
to build Teleport. This is likely caused by a directory override. You
1930+
can inspect your current overrides with 'rustup show active-toolchain'
1931+
and clear directory overrides with 'rustup override unset'
1932+
endef
1933+
export rust_toolchain_warning
1934+
1935+
# inspect the current active toolchain and display a warning if it doesn't
1936+
# match the version defined in our toolchain file.
1937+
.PHONY: rustup-toolchain-warning
1938+
rustup-toolchain-warning: EXPECTED = $(shell $(MAKE) print-rust-toolchain-version)
1939+
rustup-toolchain-warning:
1940+
@if [ "$(shell rustup show active-toolchain | cut -d'-' -f1)" != "$(EXPECTED)" ]; then \
1941+
echo -en "\033[31m";\
1942+
echo "$$rust_toolchain_warning";\
1943+
echo -en "\033[0m";\
1944+
fi
1945+
19281946
# changelog generates PR changelog between the provided base tag and the tip of
19291947
# the specified branch.
19301948
#

0 commit comments

Comments
 (0)