Skip to content

Commit 9ef405f

Browse files
committed
refactor: normalize line endings
1 parent 37a4098 commit 9ef405f

File tree

15 files changed

+6751
-6751
lines changed

15 files changed

+6751
-6751
lines changed

examples/gauge/package-lock.json

Lines changed: 6125 additions & 6125 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
[target.wasm32-wasi]
2-
rustflags = [
3-
"-Clink-arg=--export-table",
4-
"-Clink-arg=--export=malloc",
5-
"-Clink-arg=--export=free",
6-
"-Clink-arg=-L/usr/lib/llvm-15/lib/clang/15.0.7/lib/wasi",
7-
"-Clink-arg=-lclang_rt.builtins-wasm32"
8-
]
9-
10-
[build]
1+
[target.wasm32-wasi]
2+
rustflags = [
3+
"-Clink-arg=--export-table",
4+
"-Clink-arg=--export=malloc",
5+
"-Clink-arg=--export=free",
6+
"-Clink-arg=-L/usr/lib/llvm-15/lib/clang/15.0.7/lib/wasi",
7+
"-Clink-arg=-lclang_rt.builtins-wasm32"
8+
]
9+
10+
[build]
1111
target = "wasm32-wasi"

src/wasm_navdata_interface/Cargo.toml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
[package]
2-
name = "navdata_interface"
3-
version = "0.1.0"
4-
edition = "2021"
5-
rust-version = "1.72.1"
6-
7-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8-
9-
[lib]
10-
crate-type = ["cdylib"]
11-
12-
[profile.release]
13-
lto = true
14-
strip = true
15-
16-
[dependencies]
17-
msfs = { git = "https://github.com/flybywiresim/msfs-rs.git", rev = "b438d3e" }
18-
serde = "1.0.190"
19-
serde_json = "1.0.108"
20-
rusqlite = { git = "https://github.com/navigraph/rusqlite", rev = "f9170d0", features = ["bundled"] }
21-
zip = { version = "0.6.4", default-features = false, features = ["deflate"] }
1+
[package]
2+
name = "navdata_interface"
3+
version = "0.1.0"
4+
edition = "2021"
5+
rust-version = "1.72.1"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[lib]
10+
crate-type = ["cdylib"]
11+
12+
[profile.release]
13+
lto = true
14+
strip = true
15+
16+
[dependencies]
17+
msfs = { git = "https://github.com/flybywiresim/msfs-rs.git", rev = "b438d3e" }
18+
serde = "1.0.190"
19+
serde_json = "1.0.108"
20+
rusqlite = { git = "https://github.com/navigraph/rusqlite", rev = "f9170d0", features = ["bundled"] }
21+
zip = { version = "0.6.4", default-features = false, features = ["deflate"] }

src/wasm_navdata_interface/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Building:
2-
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`)
5-
6-
7-
# Warning
1+
# Building:
2+
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`)
5+
6+
7+
# Warning
88
The only file system functions that properly work are `fs::remove_file`, `fs::File::create`, `fs::create_dir`, `fs::remove_dir`, `fs::remove_file`. All the other functions regarding the filesystem do not work due to the MSFS implementation of WASI

src/wasm_navdata_interface/build.bat

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
@echo off
2-
3-
cd %~dp0
4-
5-
call .\scripts\run_docker_cmd.bat ./scripts/build.sh
6-
7-
@REM For some reason, the call command messes up the working directory, so we need to change it back
8-
cd %~dp0
9-
1+
@echo off
2+
3+
cd %~dp0
4+
5+
call .\scripts\run_docker_cmd.bat ./scripts/build.sh
6+
7+
@REM For some reason, the call command messes up the working directory, so we need to change it back
8+
cd %~dp0
9+
1010
copy .\out\navdata_interface.wasm ..\..\examples\aircraft\PackageSources\SimObjects\Airplanes\Navigraph_Navdata_Interface_Aircraft\panel
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
@echo off
2-
3-
cd %~dp0
4-
5-
if "%1"=="" (
6-
echo No Cargo command specified
7-
) else (
8-
.\scripts\run_docker_cmd.bat ./scripts/cargo_cmd.sh %*
1+
@echo off
2+
3+
cd %~dp0
4+
5+
if "%1"=="" (
6+
echo No Cargo command specified
7+
) else (
8+
.\scripts\run_docker_cmd.bat ./scripts/cargo_cmd.sh %*
99
)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[toolchain]
2-
profile = "default"
3-
channel = "1.72.1"
1+
[toolchain]
2+
profile = "default"
3+
channel = "1.72.1"
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
@echo off
2-
3-
set image="ghcr.io/flybywiresim/dev-env@sha256:528f8e1ca9063b9346c7d4f684d7aadbcb58ca1fba2b1a3c2cdd9c820c4236f4"
4-
5-
cd %~dp0
6-
1+
@echo off
2+
3+
set image="ghcr.io/flybywiresim/dev-env@sha256:528f8e1ca9063b9346c7d4f684d7aadbcb58ca1fba2b1a3c2cdd9c820c4236f4"
4+
5+
cd %~dp0
6+
77
docker run --rm -it -v "%cd%\..\:/external" -v "%cd%\..\out:/out" %image% %*
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#!/bin/bash
2-
3-
IMAGE="ghcr.io/flybywiresim/dev-env@sha256:528f8e1ca9063b9346c7d4f684d7aadbcb58ca1fba2b1a3c2cdd9c820c4236f4"
4-
5-
cd "$(dirname "$0")"
6-
7-
docker run --rm -v "$(pwd)/../:/external" -v "$(pwd)/../out:/out" $IMAGE "$@"
1+
#!/bin/bash
2+
3+
IMAGE="ghcr.io/flybywiresim/dev-env@sha256:528f8e1ca9063b9346c7d4f684d7aadbcb58ca1fba2b1a3c2cdd9c820c4236f4"
4+
5+
cd "$(dirname "$0")"
6+
7+
docker run --rm -v "$(pwd)/../:/external" -v "$(pwd)/../out:/out" $IMAGE "$@"
Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,80 @@
1-
use std::rc::Rc;
2-
3-
use crate::download::downloader::NavdataDownloader;
4-
use msfs::{commbus::*, sys::sGaugeDrawData, MSFSEvent};
5-
6-
pub struct Dispatcher<'a> {
7-
commbus: CommBus<'a>,
8-
downloader: Rc<NavdataDownloader>,
9-
delta_time: std::time::Duration,
10-
}
11-
12-
impl<'a> Dispatcher<'a> {
13-
pub fn new() -> Self {
14-
Dispatcher {
15-
commbus: CommBus::default(),
16-
downloader: Rc::new(NavdataDownloader::new()),
17-
delta_time: std::time::Duration::from_secs(0),
18-
}
19-
}
20-
21-
pub fn on_msfs_event(&mut self, event: MSFSEvent) {
22-
match event {
23-
MSFSEvent::PostInitialize => {
24-
self.handle_initialized();
25-
}
26-
MSFSEvent::PreDraw(data) => {
27-
self.handle_update(data);
28-
}
29-
MSFSEvent::PreKill => {
30-
self.commbus.unregister_all();
31-
}
32-
33-
_ => {}
34-
}
35-
}
36-
37-
fn handle_initialized(&mut self) {
38-
{
39-
let captured_downloader = self.downloader.clone();
40-
self.commbus
41-
.register("NAVIGRAPH_DownloadNavdata", move |args| {
42-
captured_downloader.download(Dispatcher::trim_null_terminator(args))
43-
})
44-
.expect("Failed to register NAVIGRAPH_DownloadNavdata");
45-
}
46-
{
47-
let captured_downloader = self.downloader.clone();
48-
self.commbus
49-
.register("NAVIGRAPH_SetDownloadOptions", move |args| {
50-
captured_downloader.set_download_options(Dispatcher::trim_null_terminator(args))
51-
})
52-
.expect("Failed to register NAVIGRAPH_SetDownloadOptions");
53-
}
54-
{
55-
let captured_downloader = self.downloader.clone();
56-
self.commbus
57-
.register("NAVIGRAPH_DeleteAllNavdata", move |_| {
58-
captured_downloader.delete_all_navdata()
59-
})
60-
.expect("Failed to register NAVIGRAPH_DeleteAllNavdata");
61-
}
62-
}
63-
64-
fn handle_update(&mut self, data: &sGaugeDrawData) {
65-
// Accumulate delta time for heartbeat
66-
self.delta_time += data.delta_time();
67-
68-
// Send heartbeat every 5 seconds
69-
if self.delta_time >= std::time::Duration::from_secs(5) {
70-
CommBus::call("NAVIGRAPH_Heartbeat", "", CommBusBroadcastFlags::All);
71-
self.delta_time = std::time::Duration::from_secs(0);
72-
}
73-
74-
self.downloader.on_update();
75-
}
76-
77-
fn trim_null_terminator(s: &str) -> &str {
78-
s.trim_end_matches(char::from(0))
79-
}
80-
}
1+
use std::rc::Rc;
2+
3+
use crate::download::downloader::NavdataDownloader;
4+
use msfs::{commbus::*, sys::sGaugeDrawData, MSFSEvent};
5+
6+
pub struct Dispatcher<'a> {
7+
commbus: CommBus<'a>,
8+
downloader: Rc<NavdataDownloader>,
9+
delta_time: std::time::Duration,
10+
}
11+
12+
impl<'a> Dispatcher<'a> {
13+
pub fn new() -> Self {
14+
Dispatcher {
15+
commbus: CommBus::default(),
16+
downloader: Rc::new(NavdataDownloader::new()),
17+
delta_time: std::time::Duration::from_secs(0),
18+
}
19+
}
20+
21+
pub fn on_msfs_event(&mut self, event: MSFSEvent) {
22+
match event {
23+
MSFSEvent::PostInitialize => {
24+
self.handle_initialized();
25+
}
26+
MSFSEvent::PreDraw(data) => {
27+
self.handle_update(data);
28+
}
29+
MSFSEvent::PreKill => {
30+
self.commbus.unregister_all();
31+
}
32+
33+
_ => {}
34+
}
35+
}
36+
37+
fn handle_initialized(&mut self) {
38+
{
39+
let captured_downloader = self.downloader.clone();
40+
self.commbus
41+
.register("NAVIGRAPH_DownloadNavdata", move |args| {
42+
captured_downloader.download(Dispatcher::trim_null_terminator(args))
43+
})
44+
.expect("Failed to register NAVIGRAPH_DownloadNavdata");
45+
}
46+
{
47+
let captured_downloader = self.downloader.clone();
48+
self.commbus
49+
.register("NAVIGRAPH_SetDownloadOptions", move |args| {
50+
captured_downloader.set_download_options(Dispatcher::trim_null_terminator(args))
51+
})
52+
.expect("Failed to register NAVIGRAPH_SetDownloadOptions");
53+
}
54+
{
55+
let captured_downloader = self.downloader.clone();
56+
self.commbus
57+
.register("NAVIGRAPH_DeleteAllNavdata", move |_| {
58+
captured_downloader.delete_all_navdata()
59+
})
60+
.expect("Failed to register NAVIGRAPH_DeleteAllNavdata");
61+
}
62+
}
63+
64+
fn handle_update(&mut self, data: &sGaugeDrawData) {
65+
// Accumulate delta time for heartbeat
66+
self.delta_time += data.delta_time();
67+
68+
// Send heartbeat every 5 seconds
69+
if self.delta_time >= std::time::Duration::from_secs(5) {
70+
CommBus::call("NAVIGRAPH_Heartbeat", "", CommBusBroadcastFlags::All);
71+
self.delta_time = std::time::Duration::from_secs(0);
72+
}
73+
74+
self.downloader.on_update();
75+
}
76+
77+
fn trim_null_terminator(s: &str) -> &str {
78+
s.trim_end_matches(char::from(0))
79+
}
80+
}

0 commit comments

Comments
 (0)