Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
bin = ["run", "--package", "cargo-bin", "--"]
3 changes: 0 additions & 3 deletions .github/workflows/build-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,5 @@ jobs:
rustup override set ${{ env.RUST_VERSION }}
rustup target add wasm32-unknown-unknown

- name: Install wasm-pack
run: make ensure-wasm-deps

- name: Build
run: make binaries
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,4 @@ msgfile/

# Dockerized builds generate .pnpm-store in the root, so ignore it
.pnpm-store
.bin/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this added to .gitignore? Can you add a comment as to why this is here and separate it from .pnmp-store as that description does not seem to apply?

2 changes: 0 additions & 2 deletions BUILD_macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ PRs with corrections and updates are welcome!
* `brew install node corepack`
* `corepack enable pnpm`
* The `Rust` and `Cargo` version in [build.assets/Makefile](https://github.com/gravitational/teleport/blob/master/build.assets/versions.mk#L11) (search for `RUST_VERSION`) are required.
* The [`wasm-pack`](https://github.com/rustwasm/wasm-pack) version in [build.assets/Makefile](https://github.com/gravitational/teleport/blob/master/build.assets/versions.mk#L12) (search for `WASM_PACK_VERSION`) is required:
`curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh`

##### Local Tests Dependencies

Expand Down
71 changes: 68 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["lib/srv/desktop/rdp/rdpclient", "web/packages/shared/libs/ironrdp"]
members = ["lib/srv/desktop/rdp/rdpclient", "tool/cargo-bin", "web/packages/shared/libs/ironrdp"]

[workspace.package]
edition = "2021"
Expand All @@ -18,7 +18,13 @@ debug = 1
codegen-units = 1
lto = "thin"

[workspace.metadata.bin]
wasm-strip = { version = "0.1.0", locked = true }
wasm-bindgen-cli = { version = "0.2.99", bins = ["wasm-bindgen"], locked = true }

[workspace.dependencies]
wasm-bindgen = "0.2.99" # when updating this version make sure you update version above to match!

# Note: To use a local IronRDP repository as a crate (for example, ironrdp-cliprdr), define the dependency as follows:
# ironrdp-cliprdr = { path = "/path/to/local/IronRDP/crates/ironrdp-cliprdr" }
ironrdp-cliprdr = { git = "https://github.com/Devolutions/IronRDP", rev = "dd221bf22401c4635798ec012724cba7e6d503b2" }
Expand Down
50 changes: 6 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ endif
rm -f *.zip
rm -f gitref.go
rm -rf build.assets/tooling/bin
# Clean up wasm-pack build artifacts
rm -rf web/packages/shared/libs/ironrdp/pkg/
# Clean up wasm-bindgen build artifacts
rm -rf web/packages/shared/libs/ironrdp/pkg/ironrdp*

.PHONY: clean-ui
clean-ui:
Expand Down Expand Up @@ -1326,6 +1326,7 @@ ADDLICENSE_COMMON_ARGS := -c 'Gravitational, Inc.' \
-ignore 'web/packages/design/src/assets/icomoon/style.css' \
-ignore 'web/packages/shared/libs/ironrdp/**' \
-ignore 'lib/limiter/internal/ratelimit/**' \
-ignore 'tool/cargo-bin/**' \
-ignore 'webassets/**' \
-ignore 'ignoreme'
ADDLICENSE_AGPL3_ARGS := $(ADDLICENSE_COMMON_ARGS) \
Expand Down Expand Up @@ -1804,54 +1805,14 @@ ensure-js-deps:
else $(MAKE) ensure-js-package-manager && pnpm install --frozen-lockfile; fi

.PHONY: ensure-wasm-deps
ifeq ($(WEBASSETS_SKIP_BUILD),1)
ensure-wasm-deps:
else
ensure-wasm-deps: ensure-wasm-pack ensure-wasm-bindgen

# Get the version of wasm-bindgen from cargo, as that is what wasm-pack is
# going to do when it checks for the right version. The buildboxes do not
# have jq installed (yet), so have a hacky awk version on standby.
CARGO_GET_VERSION_JQ = cargo metadata --locked --format-version=1 | jq -r 'first(.packages[] | select(.name? == "$(1)") | .version)'
CARGO_GET_VERSION_AWK = awk -F '[ ="]+' '/^name = "$(1)"$$/ {inpkg = 1} inpkg && $$1 == "version" {print $$2; exit}' Cargo.lock

BIN_JQ = $(shell which jq 2>/dev/null)
CARGO_GET_VERSION = $(if $(BIN_JQ),$(CARGO_GET_VERSION_JQ),$(CARGO_GET_VERSION_AWK))

ensure-wasm-pack: NEED_VERSION = $(shell $(MAKE) --no-print-directory -s -C build.assets print-wasm-pack-version)
ensure-wasm-pack: INSTALLED_VERSION = $(word 2,$(shell wasm-pack --version 2>/dev/null))
ensure-wasm-pack:
$(if $(filter-out $(INSTALLED_VERSION),$(NEED_VERSION)),\
cargo install wasm-pack --force --locked --version "$(NEED_VERSION)", \
@echo wasm-pack up-to-date: $(INSTALLED_VERSION) \
)

# TODO: Use CARGO_GET_VERSION_AWK instead of hardcoded version
# On 386 Arch, calling the variable produces a malformed command that fails the build.
#ensure-wasm-bindgen: NEED_VERSION = $(shell $(call CARGO_GET_VERSION,wasm-bindgen))
ensure-wasm-bindgen: NEED_VERSION = 0.2.99
ensure-wasm-bindgen: INSTALLED_VERSION = $(word 2,$(shell wasm-bindgen --version 2>/dev/null))
ensure-wasm-bindgen:
ifneq ($(CI)$(FORCE),)
@: $(or $(NEED_VERSION),$(error Unknown wasm-bindgen version. Is it in Cargo.lock?))
$(if $(filter-out $(INSTALLED_VERSION),$(NEED_VERSION)),\
cargo install wasm-bindgen-cli --force --locked --version "$(NEED_VERSION)", \
@echo wasm-bindgen-cli up-to-date: $(INSTALLED_VERSION) \
)
else
$(if $(filter-out $(INSTALLED_VERSION),$(NEED_VERSION)),\
@echo "Wrong wasm-bindgen version. Want $(NEED_VERSION) have $(INSTALLED_VERSION)"; \
echo "Run 'make $@ FORCE=true' to force installation." \
)
endif
endif

.PHONY: build-ui
build-ui: ensure-js-deps ensure-wasm-deps
build-ui: ensure-js-deps
@[ "${WEBASSETS_SKIP_BUILD}" -eq 1 ] || pnpm build-ui-oss

.PHONY: build-ui-e
build-ui-e: ensure-js-deps ensure-wasm-deps
build-ui-e: ensure-js-deps
@[ "${WEBASSETS_SKIP_BUILD}" -eq 1 ] || pnpm build-ui-e

.PHONY: docker-ui
Expand All @@ -1862,6 +1823,7 @@ docker-ui:
rustup-set-version: RUST_VERSION := $(shell $(MAKE) --no-print-directory -C build.assets print-rust-version)
rustup-set-version:
rustup override set $(RUST_VERSION)
rustup target add wasm32-unknown-unknown

# rustup-install-target-toolchain ensures the required rust compiler is
# installed to build for $(ARCH)/$(OS) for the version of rust we use, as
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ Ensure you have installed correct versions of necessary dependencies:
* [`pnpm`](https://pnpm.io/installation#using-corepack). If you have Node.js installed, run `corepack enable pnpm` to make `pnpm` available.
* If you prefer not to install/use pnpm, but have docker available, you can run `make docker-ui` instead.
* The `Rust` and `Cargo` version in [build.assets/Makefile](https://github.com/gravitational/teleport/blob/master/build.assets/versions.mk#L11) (search for `RUST_VERSION`) are required.
* The [`wasm-pack`](https://github.com/rustwasm/wasm-pack) version in [build.assets/Makefile](https://github.com/gravitational/teleport/blob/master/build.assets/versions.mk#L12) (search for `WASM_PACK_VERSION`) is required.
* [`binaryen`](https://github.com/WebAssembly/binaryen) (which contains `wasm-opt`) is required to be installed manually
on linux aarch64 (64-bit ARM). You can check if it's already installed on your system by running `which wasm-opt`. If not you can install it like `apt-get install binaryen` (for Debian-based Linux). `wasm-pack` will install this automatically on other platforms.

For an example of Dev Environment setup on a Mac, see [these instructions](BUILD_macos.md).

Expand Down
4 changes: 0 additions & 4 deletions build.assets/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,6 @@ RUN curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --p
rustup target add wasm32-unknown-unknown && \
if [ "$BUILDARCH" = "amd64" ]; then rustup target add aarch64-unknown-linux-gnu i686-unknown-linux-gnu; fi

ARG WASM_PACK_VERSION
# Install wasm-pack for targeting WebAssembly from Rust.
RUN cargo install wasm-pack --locked --version ${WASM_PACK_VERSION}

Comment on lines -231 to -234
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add some cache warming step here? How bad is it to compile wasm-bindgen-cli every time?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my machine it takes 25s for wasm-bindgen-cli to be ready. Priming it is a bit tricky because cargo-bin-run depends on data from Cargo.toml and during docker image creation we don't check out code.

# Switch back to root for the remaining instructions and keep it as the default
# user.
USER root
Expand Down
5 changes: 0 additions & 5 deletions build.assets/Dockerfile-centos7
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,6 @@ RUN curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --p
rustc --version && \
rustup target add wasm32-unknown-unknown

# Install wasm-pack for targeting WebAssembly from Rust.
ARG WASM_PACK_VERSION
# scl enable is required to use the newer C compiler installed above. Without it, the build fails.
RUN scl enable ${DEVTOOLSET} "cargo install wasm-pack --locked --version ${WASM_PACK_VERSION}"

# Do a quick switch back to root and copy/setup libfido2 and libpcsclite binaries.
# Do this last to take better advantage of the multi-stage build.
USER root
Expand Down
4 changes: 0 additions & 4 deletions build.assets/Dockerfile-node
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,3 @@ RUN curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --p
rustup component add rustfmt clippy && \
rustup target add wasm32-unknown-unknown && \
if [ "$BUILDARCH" = "amd64" ]; then rustup target add aarch64-unknown-linux-gnu; fi

# Install wasm-pack for targeting WebAssembly from Rust.
ARG WASM_PACK_VERSION
RUN cargo install wasm-pack --locked --version ${WASM_PACK_VERSION}
11 changes: 0 additions & 11 deletions build.assets/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ buildbox:
--build-arg GOLANG_VERSION=$(GOLANG_VERSION) \
--build-arg GOLANGCI_LINT_VERSION=$(GOLANGCI_LINT_VERSION) \
--build-arg RUST_VERSION=$(RUST_VERSION) \
--build-arg WASM_PACK_VERSION=$(WASM_PACK_VERSION) \
--build-arg NODE_VERSION=$(NODE_VERSION) \
--build-arg LIBBPF_VERSION=$(LIBBPF_VERSION) \
--build-arg BUF_VERSION=$(BUF_VERSION) \
Expand Down Expand Up @@ -219,7 +218,6 @@ buildbox-centos7:
--build-arg TARGETARCH=$(RUNTIME_ARCH) \
--build-arg GOLANG_VERSION=$(GOLANG_VERSION) \
--build-arg RUST_VERSION=$(RUST_VERSION) \
--build-arg WASM_PACK_VERSION=$(WASM_PACK_VERSION) \
--build-arg DEVTOOLSET=$(DEVTOOLSET) \
--build-arg LIBBPF_VERSION=$(LIBBPF_VERSION) \
--build-arg LIBPCSCLITE_VERSION=$(LIBPCSCLITE_VERSION) \
Expand Down Expand Up @@ -248,7 +246,6 @@ buildbox-centos7-fips:
--build-arg TARGETARCH=$(RUNTIME_ARCH) \
--build-arg GOLANG_VERSION=$(GOLANG_VERSION) \
--build-arg RUST_VERSION=$(RUST_VERSION) \
--build-arg WASM_PACK_VERSION=$(WASM_PACK_VERSION) \
--build-arg DEVTOOLSET=$(DEVTOOLSET) \
--build-arg LIBBPF_VERSION=$(LIBBPF_VERSION) \
--build-arg LIBPCSCLITE_VERSION=$(LIBPCSCLITE_VERSION) \
Expand Down Expand Up @@ -297,7 +294,6 @@ buildbox-node:
--build-arg GID=$(GID) \
--build-arg NODE_VERSION=$(NODE_VERSION) \
--build-arg RUST_VERSION=$(RUST_VERSION) \
--build-arg WASM_PACK_VERSION=$(WASM_PACK_VERSION) \
--cache-to type=inline \
--cache-from $(BUILDBOX_NODE) \
$(if $(PUSH),--push,--load) \
Expand Down Expand Up @@ -737,13 +733,6 @@ print-buf-version:
print-rust-version:
@echo $(RUST_VERSION)

#
# Print the wasm-pack version used to build Teleport.
#
.PHONY:print-wasm-pack-version
print-wasm-pack-version:
@echo $(WASM_PACK_VERSION)

#
# Print the Node version used to build Teleport Connect.
#
Expand Down
1 change: 0 additions & 1 deletion build.assets/versions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ NODE_VERSION ?= 22.14.0

# Run lint-rust check locally before merging code after you bump this.
RUST_VERSION ?= 1.81.0
WASM_PACK_VERSION ?= 0.12.1
LIBBPF_VERSION ?= 1.2.2
LIBPCSCLITE_VERSION ?= 1.9.9-teleport

Expand Down
Loading
Loading