Skip to content

Commit 28a5b3e

Browse files
committed
refactor: use docker to build, bump rust version
1 parent af6d929 commit 28a5b3e

File tree

9 files changed

+23
-20
lines changed

9 files changed

+23
-20
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1+
[target.wasm32-wasi]
2+
rustflags = [
3+
"-Clink-arg=--export-table",
4+
"-Clink-arg=--export=malloc",
5+
"-Clink-arg=--export=free",
6+
]
7+
18
[build]
29
target = "wasm32-wasi"
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
run `rustup toolchain install 1.65`, `rustup target add wasm32-wasi`
1+
Building:
22

3-
building: `.\build.bat`
4-
5-
you need clang v15 to compile this properly. you MUST build with the release flag or the sim crashes
6-
you need wasi sdk v19 and set a WASI_SDK environment variable to its install location
3+
- Install Docker
4+
- Run `.\build.bat` to build, and `.\run_cargo_cmd.bat` followed by a Cargo command to run a specified command (e.g `.\run_cargo_cmd.bat clippy`)
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
call run_cargo_cmd.bat build --release
2-
copy "target\wasm32-wasi\release\navdata_updater.wasm" "..\..\..\..\PackageSources\SimObjects\Airplanes\Navigraph_Navdata_Updater_Aircraft\panel\navdata_updater.wasm"
1+
.\scripts\run_docker_cmd.bat ./scripts/build.sh
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
@echo off
22

3-
set "CLANG_LIB_WASI=%WASI_SDK%\\lib\\clang\\15.0.7\\lib\\wasi"
4-
set "WASI_SYSROOT=%WASI_SDK%\\share\\wasi-sysroot"
5-
set "CC=%WASI_SDK%\\bin\\clang --sysroot=%WASI_SYSROOT%"
6-
set "AR=%WASI_SDK%\\bin\\llvm-ar"
7-
set "CC_wasm32_wasi=%WASI_SDK%\\bin\\clang"
8-
set "LIBSQLITE3_FLAGS=-DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_SHARED_CACHE -D_LARGEFILE64_SOURCE"
9-
set "RUSTFLAGS=-Clink-arg=-L%CLANG_LIB_WASI% -Clink-arg=-lclang_rt.builtins-wasm32 -Clink-arg=--export-table -Clink-arg=--export=malloc -Clink-arg=--export=free"
10-
11-
12-
:: Run the Cargo command passed as an argument
133
if "%1"=="" (
14-
echo No Cargo command specified.
4+
echo No Cargo command specified
155
) else (
16-
cargo %*
6+
.\scripts\run_docker_cmd.bat ./scripts/cargo_cmd.sh %*
177
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
22
profile = "default"
3-
channel = "1.65"
3+
channel = "1.72.1"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Flags needed to get sqlite3 to work in the sim
2+
export LIBSQLITE3_FLAGS="-DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_SHARED_CACHE -D_LARGEFILE64_SOURCE"
3+
4+
cargo build --target wasm32-wasi --release && wasm-opt -O1 --signext-lowering --enable-bulk-memory -o /out/navdata_updater.wasm /external/target/wasm32-wasi/release/navdata_updater.wasm
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cargo "$@"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@echo off
2+
3+
set image="ghcr.io/flybywiresim/dev-env@sha256:528f8e1ca9063b9346c7d4f684d7aadbcb58ca1fba2b1a3c2cdd9c820c4236f4"
4+
docker run --rm -it -v "%cd%:/external" -v "%cd%\..\..\..\..\PackageSources\SimObjects\Airplanes\Navigraph_Navdata_Updater_Aircraft\panel:/out" %image% %*

0 commit comments

Comments
 (0)