mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-22 16:41:06 +00:00
d7f06c5c77
* Sheet metal: one model, the part's surfaces; the flat pattern is derived (#6748) Rebased onto main (b7cb08979) as one commit. The full history of the branch is kept on h0witzer/solidcraft fix-6748-develop-history (d648f1460plus the merge ofb7cb08979). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Kernel rig: crates/develop leaves the sheet-metal area's paths, as it left the workflow's triggers; it only re-exports solidcore (#6748) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Surface cuts test from #17831 on the surface model: a consumed sheet leaves no surface sheet (#6748) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Kernel rig: crates/develop is back in the workflow's triggers and the sheet-metal area's paths, as review asked (#6748) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Sheet metal: a bend radius of 0 is refused with the fix in the message (use the tooling's real inside radius, or a tiny one like 0.001 mm), as review asked; Cargo.lock takes 0.44.0 for solidcraft-develop (#6748) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Sheet DXF byte pins re-recorded for main's nine-decimal DXF numbers (#5321), Windows set; the Ubuntu set follows from CI. A flat's measured volume is held to 1e-11, the kernel's measure moving in the twelfth digit (#6748) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Sheet metal: a conversion's first face is a face pick with or without bends, so it is named and followed like the faces after it; DXF pins for #18336's MTEXT notes (#6748) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Sheet metal: the kernel keeps main's plane section of an extruded B-spline; an elliptical cut-out across a fold waits on #19107; Ubuntu DXF pins from CI (#6748) The arm that sectioned a B-spline surface of extrusion by a parallel plane as its profile moved 6 cases of the topology.brep_local_operation golden. It is taken out so solidcore stays as main has it; landing it again needs those cases derived (#19107). The ellipse case of round_cut_outs_cross_a_fold_across_slanted_edges needs it and is ignored until then; the circle case runs. The Ubuntu DXF byte pins are the ones Actions run 44139450763 reported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Cargo.lock: solidcraft-develop at 0.45.0-rc.3 (#6748) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * solidcore: wr_450's upstream-path failures as main has them, the extrusion arm being out (#6748, #19107) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
96 lines
5.1 KiB
Rust
96 lines
5.1 KiB
Rust
//! What the model cache is keyed by. `SOLIDCRAFT_EVALUATION_SOURCE`: the digest of the committed
|
|
//! source a design's model is computed from: the `doc` crate and every workspace crate it is
|
|
//! built from, the vendored kernel, the patched dependencies, the locked versions of all others,
|
|
//! the workspace's build settings and the cache's own reader. A cache is only the result of evaluating its design when
|
|
//! that source computed it, and an update that changed none of it (only the interface, the
|
|
//! commands or the other file formats, or the version number) computes the same model.
|
|
//! `SOLIDCRAFT_SOURCE_COMMIT`: the commit, recorded with the cache. Both are "unknown" without git
|
|
//! (a source tarball), which never trusts a cache.
|
|
|
|
use sha2::{Digest, Sha256};
|
|
use std::path::{Path, PathBuf};
|
|
use std::process::Command;
|
|
|
|
/// The workspace crates a design's model is computed from: `doc` and every workspace crate it
|
|
/// depends on (a test checks the list against their manifests).
|
|
const EVALUATION_CRATES: [&str; 12] =
|
|
["color", "geom", "profile", "smlib", "sketch", "kernel", "render", "derive", "develop", "doc", "format", "viewport"];
|
|
/// The other files the saved model depends on, relative to the workspace root.
|
|
const EVALUATION_FILES: [&str; 3] = ["crates/io/build.rs", "crates/io/src/design/native_cache.rs", ".cargo/config.toml"];
|
|
/// The committed trees whose every file computes models, hashed as one tree id each: the vendored
|
|
/// kernel, so any change under `solidcore/` invalidates the models the old kernel computed.
|
|
const EVALUATION_TREES: [&str; 1] = ["solidcore"];
|
|
/// What under `vendor/` does not compute models: notes, and the interface's renderer. The kernel is
|
|
/// not under `vendor/`; it is `solidcore/`, in [`EVALUATION_TREES`].
|
|
const VENDOR_OUTSIDE: [&str; 2] = ["README.md", "egui-wgpu"];
|
|
|
|
fn git(root: &Path, args: &[&str]) -> Option<String> {
|
|
let out = Command::new("git").arg("-C").arg(root).args(args).output().ok()?;
|
|
out.status.success().then(|| String::from_utf8_lossy(&out.stdout).into_owned()).filter(|s| !s.trim().is_empty())
|
|
}
|
|
|
|
/// The committed `Cargo.lock` without the workspace's own packages: their version is the
|
|
/// application's, which every release changes; the source they are built from is hashed itself.
|
|
fn locked_dependencies(lock: &str) -> String {
|
|
lock.split("\n[[package]]").filter(|block| block.lines().any(|l| l.starts_with("source = "))).collect::<Vec<_>>().join("\n[[package]]")
|
|
}
|
|
|
|
/// The committed workspace `Cargo.toml` without the application's version.
|
|
fn workspace_settings(manifest: &str) -> String {
|
|
let mut section = "";
|
|
let mut kept = Vec::new();
|
|
for line in manifest.lines() {
|
|
if line.starts_with('[') {
|
|
section = line.trim();
|
|
}
|
|
if !(section == "[workspace.package]" && line.trim_start().starts_with("version")) {
|
|
kept.push(line);
|
|
}
|
|
}
|
|
kept.join("\n")
|
|
}
|
|
|
|
/// The digest of the committed source of the saved model (see the module notes), or `None` when
|
|
/// a part of it is not in the commit.
|
|
fn evaluation_source(root: &Path) -> Option<String> {
|
|
let mut paths: Vec<String> = EVALUATION_CRATES.iter().map(|c| format!("crates/{c}")).collect();
|
|
paths.extend(EVALUATION_TREES.iter().map(|t| t.to_string()));
|
|
paths.extend(EVALUATION_FILES.iter().map(|f| f.to_string()));
|
|
let specs: Vec<String> = paths.iter().map(|p| format!("HEAD:./{p}")).collect();
|
|
let mut args = vec!["rev-parse"];
|
|
args.extend(specs.iter().map(String::as_str));
|
|
let ids = git(root, &args)?;
|
|
if ids.lines().count() != paths.len() {
|
|
return None;
|
|
}
|
|
let mut digest = Sha256::new();
|
|
for (path, id) in paths.iter().zip(ids.lines()) {
|
|
digest.update(format!("{path} {id}\n"));
|
|
}
|
|
// `vendor/`: one line per entry, "<mode> <type> <id>\t<name>".
|
|
for entry in git(root, &["ls-tree", "HEAD", "./vendor/"])?.lines() {
|
|
let name = entry.rsplit(['\t', '/']).next().unwrap_or(entry);
|
|
if !VENDOR_OUTSIDE.contains(&name) {
|
|
digest.update(format!("vendor {entry}\n"));
|
|
}
|
|
}
|
|
digest.update(locked_dependencies(&git(root, &["show", "HEAD:./Cargo.lock"])?));
|
|
digest.update(workspace_settings(&git(root, &["show", "HEAD:./Cargo.toml"])?));
|
|
Some(digest.finalize().iter().map(|b| format!("{b:02x}")).collect())
|
|
}
|
|
|
|
fn main() {
|
|
let crate_dir = PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap_or_default());
|
|
let root = crate_dir.join("../..");
|
|
let commit = git(&crate_dir, &["rev-parse", "HEAD"]).map(|s| s.trim().to_string()).unwrap_or_else(|| "unknown".into());
|
|
println!("cargo:rustc-env=SOLIDCRAFT_SOURCE_COMMIT={commit}");
|
|
let source = evaluation_source(&root).unwrap_or_else(|| "unknown".into());
|
|
println!("cargo:rustc-env=SOLIDCRAFT_EVALUATION_SOURCE={source}");
|
|
println!("cargo:rustc-env=SOLIDCRAFT_EVALUATION_CRATES={}", EVALUATION_CRATES.join(","));
|
|
// A new commit in this checkout (or worktree) restamps the build.
|
|
if let Some(dir) = git(&crate_dir, &["rev-parse", "--git-dir"]) {
|
|
println!("cargo:rerun-if-changed={}/logs/HEAD", dir.trim());
|
|
}
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
}
|