Skip to content

Commit

Permalink
fix: build script should not write outside of OUT_DIR (#939)
Browse files Browse the repository at this point in the history
See #885

Instead of writing out the result of the parsing of the schema, after
this change the build of the plugins will simply fail.

* plugins/zenoh-plugin-rest/build.rs:
  - don't write out the result of the parsing of the schema in
    zenoh-plugin-rest/config_schema.json5,
  - if the schema does not match the default config.json5, panic.
* plugins/zenoh-plugin-storage-manager/build.rs:
  - don't write out the result of the parsing of the schema in
    zenoh-plugin-storage-manager/config_schema.json5,
  - if the schema does not match the default config.json5, panic.

Signed-off-by: Julien Loudet <[email protected]>
  • Loading branch information
J-Loudet authored Apr 16, 2024
1 parent 279317c commit 3537ee6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
12 changes: 2 additions & 10 deletions plugins/zenoh-plugin-rest/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,8 @@ fn main() {
"cargo:rustc-env=RUSTC_VERSION={}",
version_meta.short_version_string
);
// Generate config schema
let schema = schema_for!(Config);
std::fs::write(
"config_schema.json5",
serde_json::to_string_pretty(&schema).unwrap(),
)
.unwrap();
// Check that the example config matches the schema
let schema = std::fs::read_to_string("config_schema.json5").unwrap();
let schema: serde_json::Value = serde_json::from_str(&schema).unwrap();

let schema = serde_json::to_value(schema_for!(Config)).unwrap();
let schema = jsonschema::JSONSchema::compile(&schema).unwrap();
let config = std::fs::read_to_string("config.json5").unwrap();
let config: serde_json::Value = serde_json::from_str(&config).unwrap();
Expand Down
12 changes: 2 additions & 10 deletions plugins/zenoh-plugin-storage-manager/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,8 @@ fn main() {
"cargo:rustc-env=RUSTC_VERSION={}",
version_meta.short_version_string
);
// Generate default config schema
let schema = schema_for!(PluginConfig);
std::fs::write(
"config_schema.json5",
serde_json::to_string_pretty(&schema).unwrap(),
)
.unwrap();
// Check that the example config matches the schema
let schema = std::fs::read_to_string("config_schema.json5").unwrap();
let schema: serde_json::Value = serde_json::from_str(&schema).unwrap();

let schema = serde_json::to_value(schema_for!(PluginConfig)).unwrap();
let schema = jsonschema::JSONSchema::compile(&schema).unwrap();
let config = std::fs::read_to_string("config.json5").unwrap();
let config: serde_json::Value = serde_json::from_str(&config).unwrap();
Expand Down

0 comments on commit 3537ee6

Please sign in to comment.