Add icons cache dir path to developer env file

This commit is contained in:
Veronica Berglyd Olsen
2026-10-02 00:09:56 +02:00
parent 54505d3102
commit 2beca51c5a
3 changed files with 31 additions and 6 deletions

View File

@@ -3,3 +3,7 @@
# Crowdin Personal Access Token scoped to at least `project.report` (Read only) # Crowdin Personal Access Token scoped to at least `project.report` (Read only)
# Needed for `qtlimport --credits-since` # Needed for `qtlimport --credits-since`
CROWDIN_REPORT_READ_TOKEN= CROWDIN_REPORT_READ_TOKEN=
# Path for long-term cached files, like downloaded icon packs
# Used by `icons` unless `--work-dir` is set
CACHE_DIR=

View File

@@ -153,7 +153,7 @@ if __name__ == "__main__":
styles = ", ".join(["all", "default", "optional", "free", "non_free", *utils.icon_themes.ICON_SOURCES.keys()]) styles = ", ".join(["all", "default", "optional", "free", "non_free", *utils.icon_themes.ICON_SOURCES.keys()])
cmdIcons = parsers.add_parser("icons", help="Build icon theme files from upstream sources.") cmdIcons = parsers.add_parser("icons", help="Build icon theme files from upstream sources.")
cmdIcons.add_argument("style", help=f"What icon style to build: {styles}") cmdIcons.add_argument("style", help=f"What icon style to build: {styles}")
cmdIcons.add_argument("--work-dir", help="Working directory.", default="build_icons") cmdIcons.add_argument("--work-dir", help="Working directory.")
cmdIcons.set_defaults(func=utils.icon_themes.main) cmdIcons.set_defaults(func=utils.icon_themes.main)
# Import Translations # Import Translations

View File

@@ -30,22 +30,34 @@ import zipfile
from pathlib import Path from pathlib import Path
from xml.etree import ElementTree as ET from xml.etree import ElementTree as ET
from utils.common import ROOT_DIR, log from utils.common import ROOT_DIR, log, readEnvFile
UTILS = Path(__file__).parent UTILS = Path(__file__).parent
ET.register_namespace("", "http://www.w3.org/2000/svg") ET.register_namespace("", "http://www.w3.org/2000/svg")
# FontAwesome
# Repo: https://github.com/FortAwesome/Font-Awesome/
# Website: https://fontawesome.com/
# Remix
# Repo: https://github.com/Remix-Design/RemixIcon
# Website: https://remixicon.com/
# Lucide
# Repo: https://github.com/lucide-icons/lucide
# Website: https://lucide.dev/
ICON_SOURCES = { ICON_SOURCES = {
"material": "https://github.com/google/material-design-icons.git", "material": "https://github.com/google/material-design-icons.git",
"font_awesome": "https://github.com/FortAwesome/Font-Awesome/archive/refs/tags/7.3.1.zip", "font_awesome": "https://github.com/FortAwesome/Font-Awesome/archive/refs/tags/7.3.1.zip",
"remix": "https://github.com/Remix-Design/RemixIcon/archive/refs/tags/v4.9.1.zip", "remix": "https://github.com/Remix-Design/RemixIcon/archive/refs/tags/v4.9.1.zip",
"lucide": "https://github.com/lucide-icons/lucide/archive/refs/tags/1.24.0.zip", "lucide": "https://github.com/lucide-icons/lucide/archive/refs/tags/1.49.0.zip",
} }
ICON_EXTRACT = { ICON_EXTRACT = {
"material": "material-design-icons", "material": "material-design-icons",
"font_awesome": "Font-Awesome-7.3.1", "font_awesome": "Font-Awesome-7.3.1",
"remix": "RemixIcon-4.9.1", "remix": "RemixIcon-4.9.1",
"lucide": "lucide-1.24.0", "lucide": "lucide-1.49.0",
} }
ICONS = [ ICONS = [
# Remember to also update tests/files/all_icons.json for test coverage # Remember to also update tests/files/all_icons.json for test coverage
@@ -397,10 +409,19 @@ def main(args: argparse.Namespace) -> None:
log("") log("")
log("[b]Build Icon Themes[e]") log("[b]Build Icon Themes[e]")
log("[b]=================[e]") log("[b]=================[e]")
if args.work_dir:
workDir = Path(args.work_dir).absolute()
elif cacheDir := readEnvFile().get("CACHE_DIR"):
workDir = Path(cacheDir).expanduser().absolute() / "icons"
else:
workDir = ROOT_DIR / "build_icons"
workDir.mkdir(parents=True, exist_ok=True)
log(f"Work Dir: {workDir}")
log("") log("")
workDir = Path(args.work_dir).absolute()
workDir.mkdir(exist_ok=True)
iconsDir = ROOT_DIR / "novelwriter" / "assets" / "icons" iconsDir = ROOT_DIR / "novelwriter" / "assets" / "icons"
style = args.style style = args.style