-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use default GTK theme option, and custom theme alternative
- Loading branch information
Showing
15 changed files
with
8,273 additions
and
457 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,46 @@ | ||
.POSIX: | ||
.SUFFIXES: | ||
CARGOBIN = cargo | ||
TAGREFBIN = tagref | ||
BLACKBIN = black | ||
SASSCBIN = sassc | ||
SASSCOPTS = -a -M -t compact | ||
PRINTF = /usr/bin/printf | ||
|
||
fmt: pyfmt | ||
cargo fmt | ||
cargo sort | ||
cargo clippy --bin gerb | ||
$(CARGOBIN) fmt | ||
$(CARGOBIN) sort | ||
$(CARGOBIN) clippy --bin gerb | ||
|
||
.PHONY: check | ||
check: tags | ||
cargo check --bin gerb | ||
$(CARGOBIN) check --bin gerb | ||
|
||
.PHONY: tags | ||
tags: | ||
@which tagref > /dev/null && tagref || (printf "Warning: tagref binary not in PATH.\n" 1>&2) | ||
@which $(TAGREFBIN) > /dev/null && $(TAGREFBIN) || ($(PRINTF) "Warning: tagref binary not in PATH.\n" 1>&2) | ||
|
||
.PHONY: pyfmt | ||
pyfmt: | ||
@which black > /dev/null && (find src -name "*.py" | xargs black) || (printf "Warning: black binary not in PATH.\n" 1>&2) | ||
@which $(BLACKBIN) > /dev/null && (find src -name "*.py" | xargs $(BLACKBIN)) || ($(PRINTF) "Warning: black binary not in PATH.\n" 1>&2) | ||
|
||
.PHONY: feature-check | ||
feature-check: check | ||
# No features | ||
@sh -c 'cargo check --bin gerb --no-default-features || (export EXIT="$$?"; /usr/bin/printf "--no-default-features fails cargo check.\n" && exit $$EXIT)' | ||
@cargo clippy --bin gerb --no-default-features | ||
@sh -c '$(CARGOBIN) check --bin gerb --no-default-features || (export EXIT="$$?"; $(PRINTF) "--no-default-features fails cargo check.\n" && exit $$EXIT)' | ||
@$(CARGOBIN) clippy --bin gerb --no-default-features | ||
# `git` | ||
@sh -c 'cargo check --bin gerb --no-default-features --features git || (export EXIT="$$?"; /usr/bin/printf "--features git fails cargo check.\n" && exit $$EXIT)' | ||
@cargo clippy --bin gerb --no-default-features --features git | ||
@sh -c '$(CARGOBIN) check --bin gerb --no-default-features --features git || (export EXIT="$$?"; $(PRINTF) "--features git fails cargo check.\n" && exit $$EXIT)' | ||
@$(CARGOBIN) clippy --bin gerb --no-default-features --features git | ||
# `python` | ||
@sh -c 'cargo check --bin gerb --no-default-features --features python || (export EXIT="$$?"; /usr/bin/printf "--features python fails cargo check.\n" && exit $$EXIT)' | ||
@cargo clippy --bin gerb --no-default-features --features python | ||
@sh -c '$(CARGOBIN) check --bin gerb --no-default-features --features python || (export EXIT="$$?"; $(PRINTF) "--features python fails cargo check.\n" && exit $$EXIT)' | ||
@$(CARGOBIN) clippy --bin gerb --no-default-features --features python | ||
# all features | ||
@sh -c 'cargo check --bin gerb --all-features || (export EXIT="$$?"; /usr/bin/printf "--all-features fails cargo check.\n" && exit $$EXIT)' | ||
@cargo clippy --bin gerb --all-features | ||
@sh -c '$(CARGOBIN) check --bin gerb --all-features || (export EXIT="$$?"; $(PRINTF) "--all-features fails cargo check.\n" && exit $$EXIT)' | ||
@$(CARGOBIN) clippy --bin gerb --all-features | ||
|
||
src/themes/paperwhite/gtk.css: src/themes/paperwhite/*.scss | ||
$(SASSCBIN) $(SASSCOPTS) "src/themes/paperwhite/gtk.scss" "src/themes/paperwhite/gtk.css" | ||
|
||
.PHONY: | ||
themes: src/themes/paperwhite/gtk.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,35 @@ | ||
fn main() { | ||
use std::collections::VecDeque; | ||
use std::path::{Path, PathBuf}; | ||
|
||
fn main() -> std::io::Result<()> { | ||
println!("cargo:rerun-if-changed=src/themes"); | ||
{ | ||
fn read_fn(p: impl AsRef<Path>) -> Result<VecDeque<PathBuf>, std::io::Error> { | ||
std::fs::read_dir(p)? | ||
.map(|res| res.map(|e| e.path())) | ||
.collect::<Result<VecDeque<_>, std::io::Error>>() | ||
} | ||
let theme_dirs = read_fn("src/themes/")?; | ||
for theme in theme_dirs.into_iter().filter(|p| p.is_dir()) { | ||
let theme_css = theme.join("gtk.css"); | ||
let mdata = std::fs::metadata(&theme_css)?.modified()?; | ||
let mut entries = read_fn(&theme)?; | ||
while let Some(p) = entries.pop_front() { | ||
if p.is_dir() { | ||
entries.extend(read_fn(&p)?.drain(..)); | ||
continue; | ||
} | ||
if p.extension() == Some("scss".as_ref()) && p.metadata()?.modified()? > mdata { | ||
println!( | ||
"cargo:warning=Theme {} might need to be recompiled from .scss sources:", | ||
theme.file_name().unwrap().to_string_lossy() | ||
); | ||
println!("cargo:warning=File {} has a newer modified time than the compiled .css, {}.", p.display(), theme_css.display()); | ||
} | ||
} | ||
} | ||
} | ||
#[cfg(feature = "build-info")] | ||
build_info_build::build_script(); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.