Skip to content

Commit

Permalink
feat(build)!: switch from wasip1 to wasip2 - Pterodactyl driver curre…
Browse files Browse the repository at this point in the history
…ntly broken because of servo/rust-url#960
  • Loading branch information
HttpRafa committed Aug 30, 2024
1 parent 13c744c commit 528c66c
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 23 deletions.
1 change: 1 addition & 0 deletions .github/workflows/rust_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- name: Set Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
targets: ${{ matrix.target.platform }}

- name: Install Protobuf and MinGW (for Windows build)
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/rust_clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- name: Set Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
components: clippy

- name: Install Protobuf
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/rust_controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- name: Set Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
targets: ${{ matrix.target.platform }}

- name: Install Protobuf and MinGW (for Windows build)
Expand Down
22 changes: 10 additions & 12 deletions .github/workflows/rust_pterodactyl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,24 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install wasi-sdk
run: |
mkdir tools/
cd tools/
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-x86_64-linux.deb
sudo dpkg -i wasi-sdk-24.0-x86_64-linux.deb
- name: Set Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
targets: wasm32-wasip1

- name: Install wasm-tools
run: |
mkdir tools/
cd tools/
wget https://github.com/bytecodealliance/wasm-tools/releases/download/v1.209.0/wasm-tools-1.209.0-x86_64-linux.tar.gz
tar -xvf wasm-tools-1.209.0-x86_64-linux.tar.gz
mv wasm-tools-1.209.0-x86_64-linux/* .
targets: wasm32-wasip2

- name: Build Driver
run: |
export RUSTFLAGS="-Z wasi-exec-model=reactor"
cargo +nightly build -p pterodactyl --target wasm32-wasip1 --release
./tools/wasm-tools component new ./target/wasm32-wasip1/release/pterodactyl.wasm \
-o ./pterodactyl.wasm --adapt ./drivers/files/wasi_snapshot_preview1.reactor.wasm
cargo build -p pterodactyl --target wasm32-wasip2 --release
mv ./target/wasm32-wasip2/release/pterodactyl.wasm ./pterodactyl.wasm
env:
CURRENT_COMMIT: ${{ steps.commit.outputs.short }}
CURRENT_BUILD: ${{ github.run_number }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/rust_wrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- name: Set Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
targets: ${{ matrix.target.platform }}

- name: Install Protobuf and MinGW (for Windows build)
Expand Down
15 changes: 5 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
.PHONY: run run-controller build build-controller build-wrapper build-drivers create-components clean fix
.PHONY: run run-controller build build-controller build-wrapper build-drivers clean fix

# Configuration
WASM_RUSTFLAGS = -Z wasi-exec-model=reactor
WASM_TARGET = wasm32-wasip1
WASM_COMPONENT = target/wasm32-wasip1/release/pterodactyl.wasm
WASM_ADAPT_COMPONENT = drivers/files/wasi_snapshot_preview1.reactor.wasm
WASM_TARGET = wasm32-wasip2
WASM_COMPONENT = target/wasm32-wasip2/release/pterodactyl.wasm

# Directories
RUN_DIR = run
Expand Down Expand Up @@ -43,7 +42,7 @@ fix:
cargo clippy --fix --allow-dirty --allow-staged --all-targets --all-features

## Build target
build: build-controller build-wrapper build-drivers create-components
build: build-controller build-wrapper build-drivers

## Run target
run: build run-controller
Expand All @@ -63,11 +62,7 @@ build-wrapper:
## Build drivers target
build-drivers:
$(SETENV) RUSTFLAGS="$(WASM_RUSTFLAGS)"
cargo +nightly build -p pterodactyl --target $(WASM_TARGET) --release

## Component target
create-components: $(DRIVER_DIR)
wasm-tools component new $(WASM_COMPONENT) -o $(DRIVER_DIR)/pterodactyl.wasm --adapt $(WASM_ADAPT_COMPONENT)
cargo build -p pterodactyl --target $(WASM_TARGET) --release

# Create driver directory if it doesn't exist
$(DRIVER_DIR):
Expand Down
3 changes: 2 additions & 1 deletion controller/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ prost = "0.13.1"
tonic = "0.12.2"

# Drivers
wasmtime = { version = "24.0.0", default-features = false, features = ["runtime", "component-model", "cranelift", "parallel-compilation", "cache"], optional = true }
# TODO: Disable gc when wasmtime 25 is released
wasmtime = { version = "24.0.0", default-features = false, features = ["runtime", "component-model", "cranelift", "parallel-compilation", "cache", "gc"], optional = true }
wasmtime-wasi = { version = "24.0.0", optional = true }
minreq = { version = "2.12.0", features = ["https-rustls"], optional = true }

Expand Down
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "nightly"
components = ["rustfmt", "clippy"]
targets = ["wasm32-wasip2"]

0 comments on commit 528c66c

Please sign in to comment.