build.rs 710 B

12345678910111213141516171819202122232425
  1. // Copyright 2019-2024 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. use std::{
  5. error::Error,
  6. fs::File,
  7. io::{BufWriter, Write},
  8. path::PathBuf,
  9. };
  10. pub fn main() -> Result<(), Box<dyn Error>> {
  11. let schema = schemars::schema_for!(tauri_utils::config::Config);
  12. let schema_str = serde_json::to_string_pretty(&schema).unwrap();
  13. let crate_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?);
  14. for file in [
  15. crate_dir.join("schema.json"),
  16. crate_dir.join("../../tooling/cli/schema.json"),
  17. ] {
  18. let mut schema_file = BufWriter::new(File::create(file)?);
  19. write!(schema_file, "{schema_str}")?;
  20. }
  21. Ok(())
  22. }