From 270eb87ce2cdd3b35061eb8c3200bbd57da12e18 Mon Sep 17 00:00:00 2001 From: Jack Morrison Date: Tue, 2 Jan 2024 18:46:27 +0000 Subject: [PATCH 1/2] Zenoh: Fix badly behaved build.rs scripts. * Zenoh: Fix badly behaved build.rs scripts. build.rs should only ever modify OUT_DIR. These scripts were modifying local files which caused a git index update which caused them to rebuild due to the git-version appearing out of date. --- plugins/zenoh-plugin-rest/build.rs | 12 ++++++------ plugins/zenoh-plugin-storage-manager/build.rs | 11 +++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/plugins/zenoh-plugin-rest/build.rs b/plugins/zenoh-plugin-rest/build.rs index ba19bf8514..71242ffbe6 100644 --- a/plugins/zenoh-plugin-rest/build.rs +++ b/plugins/zenoh-plugin-rest/build.rs @@ -27,13 +27,13 @@ fn main() { ); // Generate config schema let schema = schema_for!(Config); - std::fs::write( - "config_schema.json5", - serde_json::to_string_pretty(&schema).unwrap(), - ) - .unwrap(); + + let schema_file = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()) + .join("config_schema.json5"); + std::fs::write(&schema_file, 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 = std::fs::read_to_string(schema_file).unwrap(); let schema: serde_json::Value = serde_json::from_str(&schema).unwrap(); let schema = jsonschema::JSONSchema::compile(&schema).unwrap(); let config = std::fs::read_to_string("config.json5").unwrap(); diff --git a/plugins/zenoh-plugin-storage-manager/build.rs b/plugins/zenoh-plugin-storage-manager/build.rs index ce5b6f0bff..6d034ba232 100644 --- a/plugins/zenoh-plugin-storage-manager/build.rs +++ b/plugins/zenoh-plugin-storage-manager/build.rs @@ -23,13 +23,12 @@ fn main() { ); // Generate default config schema let schema = schema_for!(PluginConfig); - std::fs::write( - "config_schema.json5", - serde_json::to_string_pretty(&schema).unwrap(), - ) - .unwrap(); + let schema_file = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()) + .join("config_schema.json5"); + std::fs::write(&schema_file, 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 = std::fs::read_to_string(schema_file).unwrap(); let schema: serde_json::Value = serde_json::from_str(&schema).unwrap(); let schema = jsonschema::JSONSchema::compile(&schema).unwrap(); let config = std::fs::read_to_string("config.json5").unwrap(); From b13bf57ceb0a35d808ffcd019c240c707a07508d Mon Sep 17 00:00:00 2001 From: Jack Morrison Date: Tue, 2 Apr 2024 07:03:15 -0600 Subject: [PATCH 2/2] Fix formatting issues. --- plugins/zenoh-plugin-rest/build.rs | 4 ++-- plugins/zenoh-plugin-storage-manager/build.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/zenoh-plugin-rest/build.rs b/plugins/zenoh-plugin-rest/build.rs index 71242ffbe6..98551fc977 100644 --- a/plugins/zenoh-plugin-rest/build.rs +++ b/plugins/zenoh-plugin-rest/build.rs @@ -28,8 +28,8 @@ fn main() { // Generate config schema let schema = schema_for!(Config); - let schema_file = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()) - .join("config_schema.json5"); + let schema_file = + std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()).join("config_schema.json5"); std::fs::write(&schema_file, serde_json::to_string_pretty(&schema).unwrap()).unwrap(); // Check that the example config matches the schema diff --git a/plugins/zenoh-plugin-storage-manager/build.rs b/plugins/zenoh-plugin-storage-manager/build.rs index 6d034ba232..46e28b2162 100644 --- a/plugins/zenoh-plugin-storage-manager/build.rs +++ b/plugins/zenoh-plugin-storage-manager/build.rs @@ -23,8 +23,8 @@ fn main() { ); // Generate default config schema let schema = schema_for!(PluginConfig); - let schema_file = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()) - .join("config_schema.json5"); + let schema_file = + std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()).join("config_schema.json5"); std::fs::write(&schema_file, serde_json::to_string_pretty(&schema).unwrap()).unwrap(); // Check that the example config matches the schema