Update cargo-px generator to avoid unnecessary regeneration
Dependencies
- [2]
6MR76MLLReplace build script with cargo-px - [3]
ONRIF4V7add basic snapshot test for pretty printer - [4]
5S4MZHL5pretty print decimals using icu - [5]
UESS5YZEmigrate dependencies into workspace manifest - [6]
KBSTC23NClean up testing using new builder methods on types - [*]
QRIJE4AQadd a simple pretty printer for beancount directives - [*]
I2P2FTLEadd basic parser for german decimals
Change contents
- edit in generators/src/bin/icu-data.rs at line 2
use std::fs; - edit in generators/src/bin/icu-data.rs at line 4
use camino::Utf8Path;use camino::Utf8PathBuf; - edit in generators/src/bin/icu-data.rs at line 15
let current_checksum = compute_checksum();let manifest_path = Utf8PathBuf::try_from(cargo_px_env::generated_pkg_manifest_path()?)?;let mut manifest = load_manifest(&manifest_path)?;let old_checksum = &mut manifest["package"]["metadata"]["px"]["source"]["checksum"];if let Some(old_checksum) = old_checksum.as_str() {if old_checksum == current_checksum {return Ok(());}} - replacement in generators/src/bin/icu-data.rs at line 33
let mut package_path = cargo_px_env::generated_pkg_manifest_path()?;package_path.pop();package_path.push("src");package_path.push("icu_data");package_pathlet mut path = manifest_path.clone();path.pop();path.push("src");path.push("icu_data");path.canonicalize()? - edit in generators/src/bin/icu-data.rs at line 61
// Update checksum*old_checksum = toml_edit::value(current_checksum);save_manifest(&manifest_path, manifest)?; - edit in generators/src/bin/icu-data.rs at line 67
}fn save_manifest(path: &Utf8Path, manifest: toml_edit::Document) -> Result<(), std::io::Error> {fs::write(path, manifest.to_string())}fn load_manifest(path: &Utf8Path) -> Result<toml_edit::Document, toml_edit::TomlError> {// Read the contents of the Cargo.toml filelet toml_content = fs::read_to_string(path).expect("Failed to read Cargo.toml");// Parse ittoml_content.parse::<toml_edit::Document>()}fn compute_checksum() -> String {let version_tag = format!("{}:{}",SourceData::LATEST_TESTED_CLDR_TAG,SourceData::LATEST_TESTED_ICUEXPORT_TAG);let current_checksum = xxhash_rust::xxh3::xxh3_128(version_tag.as_bytes());format!("{current_checksum:x}") - edit in generators/Cargo.toml at line 19[2.1723]
toml_edit.workspace = truexxhash-rust.workspace = true - edit in common/beancount-pretty-printer/Cargo.toml at line 9
[package.metadata.px.generate]# The generator is a binary in the current workspace.# It's the only generator type we support at the moment.generator_type = "cargo_workspace_binary"# The name of the binary.generator_name = "icu-data"[package.metadata.px.source]checksum = "396f9a15499d1e3de0eb8765ab1e3ce" - edit in common/beancount-pretty-printer/Cargo.toml at line 43
[package.metadata.px.generate]# The generator is a binary in the current workspace.# It's the only generator type we support at the moment.generator_type = "cargo_workspace_binary"# The name of the binary.generator_name = "icu-data" - edit in Cargo.toml at line 49
toml_edit = "0.19.8"