Skip to content

Commit f9ebcd2

Browse files
authored
Merge pull request #22 from NavAbility:25Q1/enh/buildrs
integrate schema introspection to build and CI
2 parents 6b1d1e2 + bd57f40 commit f9ebcd2

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

.github/workflows/ci-rs.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ jobs:
3030
echo "::add-mask::$NVA_API_URL"
3131
export NVA_API_TOKEN=$(cat $GITHUB_EVENT_PATH | jq -r ".inputs.nva_token" )
3232
echo "::add-mask::$NVA_API_TOKEN"
33-
make fetch-schema
3433
- name: Build wasm
3534
run: make build-wasm
3635
- name: Build tokio
@@ -40,6 +39,3 @@ jobs:
4039
- name: Run tests
4140
run: |
4241
make test-tokio
43-
make generate-cbindgen-c
44-
make generate-cbindgen-cpp
45-
# make test-capi

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ Documentation for [Python](https://navability.github.io/NavAbilitySDK.py/) or [J
1414

1515
## Compiling
1616

17-
Get the schema with NVA_API_URL and NVA_API_TOKEN args/env var set:
17+
Get deps
1818
```shell
1919
make install-deps # modifies system cargo crates
20-
make fetch-schema
2120
```
2221

23-
Compile for either native or wasm:
22+
Set required NVA_API_URL and NVA_API_TOKEN args/env variables and compile for either native or wasm:
2423
```shell
2524
make build-wasm
2625
make build-tokio

build.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
// build.rs
3+
4+
use std::process::Command;
5+
use std::fs;
6+
7+
fn main() {
8+
let path = "src/schema.json";
9+
match fs::exists(path) {
10+
Ok(e) => {
11+
if e {
12+
if 100 < fs::metadata(path).unwrap().len() {
13+
println!("cargo::warning=NavAbilitySDK.rs build did not update existing schema.json.");
14+
return ();
15+
} else {
16+
println!("cargo::warning=NavAbilitySDK.rs build schema.json file is incomplete - trying to introspect again.");
17+
}
18+
}
19+
let mut fetchschema = Command::new("sh");
20+
fetchschema.arg("-c").arg("make fetch-schema");
21+
match fetchschema.output() {
22+
Ok(o) => {
23+
println!("cargo::warning={}: {:?}","NavAbilitySDK.rs trying schema introspection (ensure env variables NVA_API_API/TOKEN)", o);
24+
}
25+
Err(e) => {
26+
println!("cargo::warning={} {:?}","NavAbilitySDK.rs build schema introspection failed with error:", e);
27+
}
28+
}
29+
}
30+
Err(e) => {
31+
println!("cargo::warning=NavAbilitySDK.rs build unable to check for src/schema.json: {:?}", e);
32+
}
33+
}
34+
// println!("cargo::rerun-if-changed=build.rs");
35+
}
36+

0 commit comments

Comments
 (0)