| 1 |
1 |
|
use std::path::Path;
|
| 2 |
2 |
|
|
| 3 |
|
- |
/// Write the themes `makeover` ships into `themes/`, where `tauri.conf.json`
|
| 4 |
|
- |
/// picks them up as a bundled resource.
|
| 5 |
|
- |
///
|
| 6 |
|
- |
/// Tauri's resource globs are read by the Tauri CLI against the crate
|
| 7 |
|
- |
/// directory, so they cannot point into a registry checkout or `OUT_DIR`.
|
| 8 |
|
- |
/// Materializing the embedded set here keeps `makeover` the single source of
|
| 9 |
|
- |
/// truth without vendoring a second copy of the theme files into this repo.
|
| 10 |
|
- |
/// The directory is generated, and gitignored.
|
| 11 |
|
- |
fn materialize_themes() {
|
| 12 |
|
- |
let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("themes");
|
| 13 |
|
- |
std::fs::create_dir_all(&dir).expect("create themes/");
|
| 14 |
|
- |
|
| 15 |
|
- |
// Clear stale files first, so a theme removed upstream (or renamed) does
|
| 16 |
|
- |
// not linger in the bundle from an earlier build.
|
| 17 |
|
- |
for entry in std::fs::read_dir(&dir).expect("read themes/").flatten() {
|
| 18 |
|
- |
let path = entry.path();
|
| 19 |
|
- |
if path.extension().is_some_and(|e| e == "toml") {
|
| 20 |
|
- |
std::fs::remove_file(&path).expect("remove stale theme");
|
| 21 |
|
- |
}
|
| 22 |
|
- |
}
|
| 23 |
|
- |
|
| 24 |
|
- |
for (id, source) in makeover::embedded_themes() {
|
| 25 |
|
- |
std::fs::write(dir.join(format!("{id}.toml")), source).expect("write theme");
|
| 26 |
|
- |
}
|
| 27 |
|
- |
}
|
| 28 |
|
- |
|
| 29 |
3 |
|
/// Write the geometry layer `makeover-geometry` defines into
|
| 30 |
4 |
|
/// `frontend/css/geometry.css`, which `index.html` links ahead of the
|
| 31 |
5 |
|
/// stylesheet.
|
| 69 |
43 |
|
std::fs::write(path, css).expect("write geometry.css");
|
| 70 |
44 |
|
}
|
| 71 |
45 |
|
|
| 72 |
|
- |
/// Write the component layer `makeover-webview` emits into
|
| 73 |
|
- |
/// `frontend/css/layout.css`, which `index.html` links after `geometry.css`
|
| 74 |
|
- |
/// and before the stylesheet.
|
| 75 |
|
- |
///
|
| 76 |
|
- |
/// Third generated file, same shape as the other two: a crate owns the rule,
|
| 77 |
|
- |
/// `build.rs` materialises it, this app links it and never edits it.
|
| 78 |
|
- |
///
|
| 79 |
|
- |
/// Phase A is the stylesheet only. This app builds its DOM through
|
| 80 |
|
- |
/// `createElement` at 175 sites, so adopting generated markup is a migration
|
| 81 |
|
- |
/// while adopting a generated stylesheet is a deletion. The `--bevel-*`
|
| 82 |
|
- |
/// properties were hand-written in `styles.css` until now, and the crate
|
| 83 |
|
- |
/// asserts its emitted text against exactly what this app wrote, so nothing
|
| 84 |
|
- |
/// changes on screen.
|
| 85 |
|
- |
///
|
| 86 |
|
- |
/// The file is generated, and gitignored.
|
| 87 |
|
- |
fn materialize_layout() {
|
| 88 |
|
- |
let css = makeover_webview::stylesheet(&makeover_webview::Emit::default());
|
| 89 |
|
- |
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
|
| 90 |
|
- |
.join("frontend")
|
| 91 |
|
- |
.join("css")
|
| 92 |
|
- |
.join("layout.css");
|
| 93 |
|
- |
std::fs::write(path, css).expect("write layout.css");
|
| 94 |
|
- |
}
|
| 95 |
|
- |
|
| 96 |
46 |
|
fn main() {
|
| 97 |
|
- |
materialize_themes();
|
|
47 |
+ |
// themes/ and frontend/css/layout.css. Both were written out here until
|
|
48 |
+ |
// they had a second identical copy in the other Tauri app; they live in
|
|
49 |
+ |
// makeover-build now. The geometry emitter below stays local, because the
|
|
50 |
+ |
// two apps genuinely disagree about how the touch preset is selected.
|
|
51 |
+ |
makeover_build::tauri_frontend(env!("CARGO_MANIFEST_DIR"), &makeover_build::Emit::default());
|
| 98 |
52 |
|
materialize_geometry();
|
| 99 |
|
- |
materialize_layout();
|
| 100 |
53 |
|
tauri_build::build();
|
| 101 |
54 |
|
}
|