v0.34.9_css_refactor
This commit is contained in:
1 parent
2b7c67d755
commit
66ff9dfaa2
28 files changed
+11518
-13023
No files matched your search
@@ -1,6 +1,53 @@
|
||||
use serde_json::{json, Value};
|
||||
use std::{collections::HashSet, env, fs, path::PathBuf, process::Command};
|
||||
|
||||
fn panel_styles(
|
||||
root: &std::path::Path,
|
||||
out: &std::path::Path,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("cargo:rerun-if-env-changed=RUST_PROXY_PYTHON");
|
||||
let helper = root.join("scripts/build/panel_css.py");
|
||||
println!("cargo:rerun-if-changed={}", helper.display());
|
||||
println!("cargo:rerun-if-changed={}", root.join("src/admin/web/css").display());
|
||||
let interpreters = match env::var_os("RUST_PROXY_PYTHON") {
|
||||
Some(value) if !value.is_empty() => vec![value],
|
||||
_ => vec!["python3".into(), "python".into()],
|
||||
};
|
||||
for interpreter in interpreters {
|
||||
match Command::new(&interpreter)
|
||||
.arg(&helper)
|
||||
.arg("--root")
|
||||
.arg(root)
|
||||
.arg("--out-dir")
|
||||
.arg(out)
|
||||
.arg("--cargo")
|
||||
.status()
|
||||
{
|
||||
Ok(status) if status.success() => {
|
||||
let generated = out.join("panel-style.css");
|
||||
let metadata = fs::metadata(&generated).map_err(|error| {
|
||||
format!(
|
||||
"Panel CSS helper succeeded but {} is unavailable: {error}",
|
||||
generated.display()
|
||||
)
|
||||
})?;
|
||||
if !metadata.is_file() || metadata.len() == 0 {
|
||||
return Err(format!(
|
||||
"Panel CSS helper did not create a non-empty regular file: {}",
|
||||
generated.display()
|
||||
)
|
||||
.into());
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
Ok(_) => return Err("Panel CSS preparation failed; see the diagnostic above and src/admin/web/css/README.md".into()),
|
||||
Err(error) if error.kind() == std::io::ErrorKind::NotFound => continue,
|
||||
Err(error) => return Err(error.into()),
|
||||
}
|
||||
}
|
||||
Err("Python 3.10+ is required for build assets; install python3 or set RUST_PROXY_PYTHON to its executable".into())
|
||||
}
|
||||
|
||||
fn swagger_assets(
|
||||
root: &std::path::Path,
|
||||
out: &std::path::Path,
|
||||
@@ -35,6 +82,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
env::var_os("CARGO_MANIFEST_DIR").ok_or("Cargo did not supply CARGO_MANIFEST_DIR")?,
|
||||
);
|
||||
let out = PathBuf::from(env::var_os("OUT_DIR").ok_or("Cargo did not supply OUT_DIR")?);
|
||||
panel_styles(&root, &out)?;
|
||||
swagger_assets(&root, &out)?;
|
||||
let langs = root.join("langs");
|
||||
println!("cargo:rerun-if-changed={}", langs.display());
|
||||
|
||||
Reference in new issue
Block a user