mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 17:19:37 +00:00
Added:
- Workspace support (`[workspace]` with deps ordering) - `clean --all` for workspace members Changed: - Project root discovery for `build/run/clean` (searches parent dirs) - Workspace paths are excluded from root source scan - Build output now uses a Cargo-style `Compiling <name> v<version>` line - Build time now reports total time for the whole build stage (workspace included) - Cache hits are silent (no compile line when nothing is rebuilt) - Safer build cache: fingerprints include headers and resolved library files
This commit is contained in:
@@ -115,7 +115,7 @@ impl Config {
|
||||
.and_then(|v| v.as_table())
|
||||
.ok_or_else(|| ConfigError::Invalid("missing [build]".into()))?;
|
||||
|
||||
for key in ["language", "standard", "compiler", "kind"] {
|
||||
for key in ["language", "standard", "compiler"] {
|
||||
let value = build.get(key).and_then(|v| v.as_str()).unwrap_or("");
|
||||
if value.trim().is_empty() {
|
||||
return Err(ConfigError::Invalid(format!("build.{key} is empty")));
|
||||
@@ -140,10 +140,11 @@ impl Config {
|
||||
}
|
||||
if let Some(kind) = build.get("kind").and_then(|v| v.as_str()) {
|
||||
let kind = kind.trim();
|
||||
if kind != "bin" && kind != "staticlib" && kind != "sharedlib" {
|
||||
if !kind.is_empty() && kind != "bin" && kind != "staticlib" && kind != "sharedlib" {
|
||||
return Err(ConfigError::Invalid("build.kind is invalid".into()));
|
||||
}
|
||||
}
|
||||
self.validate_workspace()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -159,6 +160,39 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
impl Config {
|
||||
fn validate_workspace(&self) -> Result<(), ConfigError> {
|
||||
let Some(workspace) = self.get("workspace").and_then(|v| v.as_table()) else {
|
||||
return Ok(());
|
||||
};
|
||||
for (name, value) in workspace {
|
||||
let tbl = value
|
||||
.as_table()
|
||||
.ok_or_else(|| ConfigError::Invalid(format!("workspace.{name} must be a table")))?;
|
||||
let path = tbl.get("path").and_then(|v| v.as_str()).unwrap_or("");
|
||||
if path.trim().is_empty() {
|
||||
return Err(ConfigError::Invalid(format!(
|
||||
"workspace.{name}.path is empty"
|
||||
)));
|
||||
}
|
||||
if let Some(deps) = tbl.get("deps") {
|
||||
let arr = deps.as_array().ok_or_else(|| {
|
||||
ConfigError::Invalid(format!("workspace.{name}.deps must be array"))
|
||||
})?;
|
||||
for item in arr {
|
||||
let s = item.as_str().unwrap_or("");
|
||||
if s.trim().is_empty() {
|
||||
return Err(ConfigError::Invalid(format!(
|
||||
"workspace.{name}.deps contains empty value"
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn read_toml(path: &Path) -> Result<Value, ConfigError> {
|
||||
let content = fs::read_to_string(path)?;
|
||||
Ok(toml::from_str(&content)?)
|
||||
|
||||
Reference in New Issue
Block a user