Skip to content

Commit

Permalink
workflow: switch to cargo-msfs for building the package (#12)
Browse files Browse the repository at this point in the history
* workflow(cherrypick): switch to cargo-msfs

* chore: update npm workflow run

* workflow: attempt to fix new build

* workflow: more fixes

* workflow: try windows build

* workflow: change clang version

* workflow: try newer ubuntu

* workflow: trying manual clang version

* workflow: change clang version

* workflow: try windows one last time

* fix: package comparison now includes revisions

* workflow(fix): correct version of windows

* workflow(fix): switch to a different clang installer

* workflow(fix): now autocreates the out folder

* workflow(fix): final workflow fix

* workflow(test): is the preopens issue local

* workflow(fix): add winpty to call

* fix: implement course for dfdv2

* feat: add description_code to fix output

* fix: change test to test-workflow

* fix: move winpty

* chore: update package version
  • Loading branch information
ZigTag authored Feb 4, 2025
1 parent a177538 commit 7ff9ee3
Show file tree
Hide file tree
Showing 44 changed files with 331 additions and 250 deletions.
4 changes: 2 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[target.wasm32-wasi]
[target.wasm32-wasip1]
rustflags = [
"-Ctarget-feature=-crt-static,+bulk-memory",
"-Clink-self-contained=no",
Expand All @@ -21,4 +21,4 @@ rustflags = [
]

[build]
target = "wasm32-wasi"
target = "wasm32-wasip1"
17 changes: 15 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

build-test:
name: Build & test 🛠️
runs-on: ubuntu-latest
runs-on: windows-2022
if: ${{ !github.event.pull_request.draft && !contains(github.event.pull_request.labels.*.name , 'release') }}
steps:
- name: Checkout
Expand All @@ -60,10 +60,23 @@ jobs:

- name: Create env file
run: |
touch .env
echo NAVIGATION_DATA_SIGNED_URL=${{ secrets.NAVIGATION_DATA_SIGNED_URL }} >> .env
echo NAVIGATION_DATA_SIGNED_URL_V2=${{ secrets.NAVIGATION_DATA_SIGNED_URL_V2 }} >> .env
- name: Install LLVM and Clang
uses: KyleMayes/[email protected]
with:
version: "17.0.6"

- name: Cache cargo-msfs
uses: actions/cache@v4
with:
path: ~\.cargo\bin
key: ${{ runner.os }}-cargo-msfs

- name: Setup
run: npm run setup

- name: Build WASM module
run: npm run build:wasm-workflow

Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,24 @@ run-name: Create pre-release for `${{ github.ref_name }}`

jobs:
release-wasm:
runs-on: ubuntu-latest
runs-on: windows-2022
steps:
- uses: actions/checkout@v4

- name: Install LLVM and Clang
uses: KyleMayes/[email protected]
with:
version: "17.0.6"

- name: Cache cargo-msfs
uses: actions/cache@v4
with:
path: ~\.cargo\bin
key: ${{ runner.os }}-cargo-msfs

- name: Setup
run: npm run setup

- name: Build WASM module
run: npm run build:wasm-workflow

Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,24 @@ run-name: Create release for `${{ github.ref_name }}`

jobs:
release-wasm:
runs-on: ubuntu-latest
runs-on: windows-2022
steps:
- uses: actions/checkout@v4

- name: Install LLVM and Clang
uses: KyleMayes/[email protected]
with:
version: "17.0.6"

- name: Cache cargo-msfs
uses: actions/cache@v4
with:
path: ~\.cargo\bin
key: ${{ runner.os }}-cargo-msfs

- name: Setup
run: npm run setup

- name: Build WASM module
run: npm run build:wasm-workflow

Expand Down
25 changes: 9 additions & 16 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ lto = true
strip = true

[patch.crates-io]
rusqlite = { git = "https://github.com/navigraph/rusqlite", rev = "7921774" }
rusqlite = { git = "https://github.com/navigraph/rusqlite", rev = "f716d5c" }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Before building, make sure you have properly created and set an `.env` file in `

## Building the WASM Module Yourself

1. [Download](https://www.docker.com/products/docker-desktop/) Docker Desktop
1. [Install](https://github.com/navigraph/cargo-msfs) cargo-msfs
2. Run `npm run build:wasm` (must be on Windows)
- This will take a while to download and build the first time, but subsequent runs will be quicker
3. The compiled WASM module will be copied to `out` **and** `examples/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/panel`
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
"scripts": {
"format": "prettier --write .",
"lint:js": "eslint \"src/js/**/*.ts\"",
"setup": ".\\scripts\\setup.bat",
"build:wasm": ".\\scripts\\build.bat",
"build:wasm-workflow": "./scripts/run_docker_cmd.sh ./scripts/build.sh",
"build:wasm-workflow": ".\\scripts\\build_workflow.bat",
"build:js": "cd .\\src\\js && npm run build",
"build:gauge": "cd .\\examples\\gauge && npm run build",
"dev:gauge": "cd .\\examples\\gauge && npm run dev",
"jest": "jest --verbose",
"test": ".\\scripts\\test.bat",
"test-workflow": "./scripts/test.sh",
"test-workflow": ".\\scripts\\test_workflow.bat",
"docker": ".\\scripts\\run_docker_cmd.bat"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[toolchain]
profile = "default"
channel = "1.79.0"
channel = "1.83"
targets = ["wasm32-wasip1"]
4 changes: 2 additions & 2 deletions scripts/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

cd %~dp0

call .\run_docker_cmd.bat ./scripts/build.sh
mkdir ..\out

cd %~dp0
cargo-msfs build msfs2020 -i .. -o ..\out\msfs_navigation_data_interface.wasm

copy ..\out\msfs_navigation_data_interface.wasm ..\examples\aircraft\PackageSources\SimObjects\Airplanes\Navigraph_Navigation_Data_Interface_Aircraft\panel
6 changes: 0 additions & 6 deletions scripts/build.sh

This file was deleted.

7 changes: 7 additions & 0 deletions scripts/build_workflow.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@echo off

cd %~dp0

mkdir ..\out

cargo-msfs build msfs2020 -i .. -o ..\out\msfs_navigation_data_interface.wasm
9 changes: 0 additions & 9 deletions scripts/run_docker_cmd.sh

This file was deleted.

7 changes: 7 additions & 0 deletions scripts/run_docker_cmd_workflow.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@echo off

set image="ghcr.io/flybywiresim/dev-env@sha256:aa36c0e4b8c66c2ec0195a104f8ae04a8ffbf45e8ddb6a8aca4f7237436bd876"

cd %~dp0

docker run --rm -it -v "%cd%\..\:/external" -v "%cd%\..\out:/out" %image% %*
5 changes: 5 additions & 0 deletions scripts/setup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off

cargo install --git https://github.com/navigraph/cargo-msfs

cargo-msfs install msfs2020
1 change: 1 addition & 0 deletions scripts/test.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ cd %~dp0
rmdir /s /q ..\test_work
mkdir ..\test_work

:: Docker is a must for now, WASI preopens don't exist on windows.
call .\run_docker_cmd.bat npm run jest
7 changes: 0 additions & 7 deletions scripts/test.sh

This file was deleted.

9 changes: 9 additions & 0 deletions scripts/test_workflow.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo off

cd %~dp0

rmdir /s /q ..\test_work
mkdir ..\test_work

:: Docker is a must for now, WASI preopens don't exist on windows.
winpty .\run_docker_cmd_workflow.bat npm run jest
4 changes: 2 additions & 2 deletions src/database/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rusqlite = { version = "0.30.0", features = ["bundled"] }
serde_rusqlite = "0.34.0"
rusqlite = { version = "0.32.0", features = ["bundled"] }
serde_rusqlite = "0.36.0"
serde = { version = "1.0.190", features = ["derive"] }
serde_json = "1.0.108"
serde_with = "3.4.0"
Expand Down
1 change: 1 addition & 0 deletions src/database/src/output/airway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub(crate) fn map_airways(data: Vec<sql_structs::EnrouteAirways>) -> Vec<Airway>
airway_row.icao_code.unwrap_or("NULL".to_string()),
None,
airway_row.waypoint_ref_table,
airway_row.waypoint_description_code.clone(),
));

if airway_row
Expand Down
Loading

0 comments on commit 7ff9ee3

Please sign in to comment.