Skip to content

Commit c6459ed

Browse files
committed
refactor: removed the 2024 wasm module build
1 parent 6830d40 commit c6459ed

File tree

3 files changed

+45
-51
lines changed

3 files changed

+45
-51
lines changed

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ RUN cargo install --git https://github.com/navigraph/cargo-msfs
2222
# Cache bust arg to re-install both SDKs
2323
ARG CACHEBUST
2424

25-
# Install MSFS2020 and MSFS2024 SDK
26-
RUN cargo-msfs install msfs2020 && \
27-
cargo-msfs install msfs2024
25+
# Install MSFS2020 SDK
26+
RUN cargo-msfs install msfs2020
2827

2928
# Needed when running in CI/CD to avoid dubious ownership errors
3029
RUN git config --global --add safe.directory /workspace

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
"lint": "bun run --filter \"*\" lint",
99
"typecheck": "bun run --filter \"*\" typecheck",
1010
"build:wasm": "bun ./scripts/cargo-msfs.ts",
11-
"build:wasm:2020": "bun ./scripts/cargo-msfs.ts --version 2020",
12-
"build:wasm:2024": "bun ./scripts/cargo-msfs.ts --version 2024",
1311
"package": "bestzip wasm.zip dist/wasm/*"
1412
},
1513
"devDependencies": {

scripts/cargo-msfs.ts

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { $ } from "bun";
2-
import { existsSync, mkdirSync, readFileSync, rmdirSync } from "node:fs";
2+
import { constants, copyFile, existsSync, mkdirSync, readFileSync, rmdirSync } from "node:fs";
33
import { dirname, join, normalize, resolve } from "node:path";
4-
import { parseArgs } from "util";
54

65
/// The type returned from the `cargo-msfs info -f` command
76
interface InstalledSdkVersions {
8-
versions: { sim: "Msfs2020" | "Msfs2024"; up_to_date: boolean; installed?: string; latest: string }[];
7+
versions: { sim: "Msfs2020"; up_to_date: boolean; installed?: string; latest: string }[];
98
}
109

1110
/// The docker image name
@@ -37,23 +36,6 @@ function findWorkspaceRoot() {
3736
return null;
3837
}
3938

40-
// Determine which version(s) to build based on command line argument --version
41-
const allowedVersions = ["2020", "2024"];
42-
43-
const { values } = parseArgs({
44-
args: Bun.argv,
45-
options: { version: { type: "string" } },
46-
strict: true,
47-
allowPositionals: true,
48-
});
49-
50-
if (values.version && !allowedVersions.includes(values.version)) {
51-
console.error(`Invalid version argument: ${values.version}. Allowed values are ${allowedVersions.join(", ")}`);
52-
process.exit(1);
53-
}
54-
55-
const versionsToBuild = values.version ? [values.version] : allowedVersions;
56-
5739
// Get workspace root for docker commands
5840
const workspaceRoot = findWorkspaceRoot();
5941
if (!workspaceRoot) {
@@ -85,36 +67,51 @@ if (installedSdks.versions.some(v => !v.up_to_date)) {
8567

8668
// Clear out dir
8769
const outDir = resolve(workspaceRoot, "dist/wasm");
70+
const panelDir = resolve(
71+
workspaceRoot,
72+
"example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/panel",
73+
);
74+
8875
if (existsSync(outDir)) rmdirSync(outDir, { recursive: true });
8976

9077
// The work directory, relative to workspace root
9178
const relativeWorkdDir = process.cwd().replace(workspaceRoot, "").replaceAll("\\", "/");
9279

93-
// Build the selected versions
94-
await Promise.all(
95-
versionsToBuild.map(async simVersion => {
96-
console.info(`[*] Building for ${simVersion}`);
97-
98-
// Create the subfolder
99-
const simDir = join(outDir, simVersion);
100-
const relativeSimDir = simDir.replace(workspaceRoot, "").replaceAll("\\", "/");
101-
mkdirSync(simDir, { recursive: true });
102-
103-
const color = simVersion === "2020" ? "\x1b[34m" : "\x1b[32m";
104-
105-
// Run cargo-msfs
106-
await $`docker run \
107-
--rm -t \
108-
--name msfs-${simVersion}-wasm-builder \
109-
-v ${workspaceRoot}:/workspace \
110-
-w /workspace${relativeWorkdDir} \
111-
-e CARGO_TARGET_DIR=/workspace/targets/${simVersion} \
112-
${IMAGE_NAME} \
113-
bash -c "cargo-msfs build msfs${simVersion} -i ./src/wasm -o ./${relativeSimDir}/msfs_navigation_data_interface.wasm \
114-
1> >(sed \"s/^/[${color}${simVersion}\\x1b[0m]/\") \
115-
2> >(sed \"s/^/[${color}${simVersion}\\x1b[0m]/\" >&2)"`.catch((err: { exitCode?: number; stderr?: Buffer }) => {
116-
console.error(`[-] Error building for ${simVersion}: ${err.exitCode} ${err.stderr?.toString()}`);
80+
// Build the 2020 version
81+
const simVersion = "2020";
82+
83+
console.info(`[*] Building for ${simVersion}`);
84+
85+
// Create the subfolder
86+
const simDir = join(outDir, simVersion);
87+
const relativeSimDir = simDir.replace(workspaceRoot, "").replaceAll("\\", "/");
88+
mkdirSync(simDir, { recursive: true });
89+
90+
// Run cargo-msfs
91+
await $`docker run \
92+
--rm -t \
93+
--name msfs-${simVersion}-wasm-builder \
94+
-v ${workspaceRoot}:/workspace \
95+
-w /workspace${relativeWorkdDir} \
96+
-e CARGO_TARGET_DIR=/workspace/targets/${simVersion} \
97+
${IMAGE_NAME} \
98+
bash -c "cargo-msfs build msfs${simVersion} -i ./src/wasm -o ./${relativeSimDir}/msfs_navigation_data_interface.wasm \
99+
1> >(sed \"s/^/[\x1b[34m${simVersion}\\x1b[0m]/\") \
100+
2> >(sed \"s/^/[\x1b[34m${simVersion}\\x1b[0m]/\" >&2)"`.catch((err: { exitCode?: number; stderr?: Buffer }) => {
101+
console.error(`[-] Error building for ${simVersion}: ${err.exitCode} ${err.stderr?.toString()}`);
102+
process.exit(1);
103+
});
104+
105+
copyFile(
106+
`${join(simDir, "msfs_navigation_data_interface.wasm")}`,
107+
`${join(panelDir, "msfs_navigation_data_interface.wasm")}`,
108+
constants.COPYFILE_FICLONE,
109+
err => {
110+
if (err) {
111+
console.error("[-] Wasm module copy failed ");
117112
process.exit(1);
118-
});
119-
}),
113+
}
114+
115+
console.info(`[*] Copying WASM module to aircraft panel folder`);
116+
},
120117
);

0 commit comments

Comments
 (0)