mirror of
https://github.com/rozniak/xfce-winxp-tc.git
synced 2026-05-01 19:51:33 +00:00
Enhancement: Fixes #140, Shift as much of the packaging script steps into CMake as possible
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
This directory contains development tools for working on parts of the project.
|
||||
|
||||
## Structure
|
||||
Each directory houses a tool or multiple tools related to a particular area of development. There is no strict layout to these tools, essentially you will be looking at mostly Bash scripts and `README`s.
|
||||
Each directory houses a tool or multiple tools related to a particular area of development. There is no strict layout to these tools, essentially you will be looking at mostly Bash/Python scripts and `README`s.
|
||||
|
||||
## Tooling areas
|
||||
Here is a brief overview of each subdirectory:
|
||||
- `locale` - contains tools for aiding in localization
|
||||
- `bldutils` - contains tools used by CMake build processes
|
||||
|
||||
32
tools/bldutils/README.MD
Normal file
32
tools/bldutils/README.MD
Normal file
@@ -0,0 +1,32 @@
|
||||
# Build Utilities
|
||||
This directory contains tools used by build processes.
|
||||
|
||||
## Tools Available
|
||||
Below describes each tool in this directory.
|
||||
|
||||
### bldmaps
|
||||
`bldmaps.py` is used to create the symbolic links via a `mappings` file.
|
||||
|
||||
This script is used mainly for the cursors, icons, and sounds, so that there can be one 'dumping ground' (`res/` directory) and then the actual XDG filenames just point to the resources.
|
||||
|
||||
The mapping file is quite simply just a text file in the form:
|
||||
```
|
||||
symlink_name-->target_resource
|
||||
```
|
||||
|
||||
### bldtheme
|
||||
`bldtheme.py` is used to compose the graphics for the *Windows Classic* theme (either the GTK2 theme used by everything, or the actual *Windows Classic* theme for the GTK3 bits).
|
||||
|
||||
It scans an input directory looking for files that need composing and files that should just go straight to output:
|
||||
|
||||
For files that need composing, there must be a `*.src.png` file for the graphic, and a `*.mask.png` that will be used to apply the colour scheme to it.
|
||||
|
||||
For files that don't need composing (just copy to output), name the file `*.static.png`.
|
||||
|
||||
### compcurs
|
||||
`compcurs.py` is used to compile the X11 cursor images from source graphics, and a configuration (which defines the hotspot of the cursor).
|
||||
|
||||
It is quite self explanitory, PNGs for graphics, and it will glob for `*.cfg` files to start compiling from.
|
||||
|
||||
## If you're stuck
|
||||
For specific details on usages, you can pass `--help` to each script to get the parameter information. The above should give you enough context to understand how each tool is used, should you ever need them.
|
||||
117
tools/bldutils/bldmaps/bldmaps.py
Normal file
117
tools/bldutils/bldmaps/bldmaps.py
Normal file
@@ -0,0 +1,117 @@
|
||||
import argparse
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main():
|
||||
"""Constructs symlinks from mappings for an XDG theme.
|
||||
"""
|
||||
|
||||
VALID_KINDS = ["cursors", "icons", "sounds"]
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="XDG Theme Symlink Utility",
|
||||
description="Constructs symlinks from mappings for an XDG theme.",
|
||||
epilog="See `./README.MD` for details."
|
||||
)
|
||||
|
||||
parser.add_argument("inputdir", help="the icon theme source directory")
|
||||
parser.add_argument("outputdir", help="the output directory to construct into")
|
||||
parser.add_argument("kind", help="the kind of XDG theme being mapped")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
input_dir = Path(args.inputdir)
|
||||
output_dir = Path(args.outputdir).resolve()
|
||||
kind = args.kind.lower()
|
||||
|
||||
if not input_dir.is_dir():
|
||||
raise NotADirectoryError(f"{input_dir} is not a directory")
|
||||
|
||||
if not output_dir.is_dir():
|
||||
output_dir.mkdir(parents=True)
|
||||
|
||||
if not kind in VALID_KINDS:
|
||||
raise ValueError(f"{kind} is not a known XDG theme kind")
|
||||
|
||||
# Set up paths
|
||||
#
|
||||
mappings_path = input_dir / "mappings"
|
||||
rel_res_path = Path("res")
|
||||
res_path = input_dir / rel_res_path
|
||||
|
||||
if not mappings_path.is_file():
|
||||
raise FileNotFoundError(f"{mappings_path} could not be found")
|
||||
|
||||
if not res_path.is_dir():
|
||||
raise NotADirectoryError(f"{res_path} could not be found")
|
||||
|
||||
# Set up symlinks
|
||||
#
|
||||
if kind == "icons":
|
||||
# See what sizes we need
|
||||
#
|
||||
sizes = list()
|
||||
|
||||
for sub_path in res_path.glob("*x*"):
|
||||
if not sub_path.is_dir():
|
||||
continue
|
||||
|
||||
size_name = sub_path.stem
|
||||
|
||||
size_path = output_dir / size_name
|
||||
|
||||
if not size_path.is_dir():
|
||||
size_path.mkdir(parents=True)
|
||||
|
||||
sizes.append(size_name)
|
||||
|
||||
# Attempt to read through the mappings
|
||||
#
|
||||
res_path_rel_to_mapping = Path("../..") / rel_res_path
|
||||
|
||||
with open(mappings_path) as mappings_file:
|
||||
for mapping in mappings_file:
|
||||
if mapping == "":
|
||||
continue
|
||||
|
||||
rel_icon_path, _, rel_res_name = mapping.partition("-->")
|
||||
|
||||
rel_res_name = rel_res_name.strip()
|
||||
|
||||
for size in sizes:
|
||||
target_res_path = res_path_rel_to_mapping / size / f"{rel_res_name}.png"
|
||||
theme_icon_path = output_dir / size / f"{rel_icon_path}.png"
|
||||
|
||||
theme_icon_path_dir = theme_icon_path.parent
|
||||
|
||||
if not theme_icon_path_dir.is_dir():
|
||||
theme_icon_path_dir.mkdir(parents=True)
|
||||
|
||||
theme_icon_path.symlink_to(target_res_path)
|
||||
else:
|
||||
# Parse the mappings
|
||||
#
|
||||
with open(mappings_path) as mappings_file:
|
||||
for mapping in mappings_file:
|
||||
if mapping == "":
|
||||
continue
|
||||
|
||||
rel_link_name, _, rel_res_name = mapping.partition("-->")
|
||||
|
||||
rel_res_name = rel_res_name.strip()
|
||||
|
||||
target_res_path = rel_res_path / rel_res_name
|
||||
target_link_path = output_dir / rel_link_name
|
||||
|
||||
# Sound themes have the .wav extension
|
||||
#
|
||||
if kind == "sounds":
|
||||
target_res_path = Path(f"{target_res_path}.wav")
|
||||
target_link_path = Path(f"{target_link_path}.wav")
|
||||
|
||||
target_link_path.symlink_to(target_res_path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
46
tools/bldutils/compcurs/compcurs.py
Normal file
46
tools/bldutils/compcurs/compcurs.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main():
|
||||
"""Compiled X11 cursors from source images.
|
||||
"""
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="X11 Cusor Compiler Utility",
|
||||
description="Compiles X11 cursors from source images.",
|
||||
epilog="See `./README.MD` for details."
|
||||
)
|
||||
|
||||
parser.add_argument("cfgdir", help="the cursor configs source directory")
|
||||
parser.add_argument("imgdir", help="the cursor images source directory")
|
||||
parser.add_argument("outputdir", help="the output directory for the compiled cursors")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
config_dir = Path(args.cfgdir)
|
||||
image_dir = Path(args.imgdir)
|
||||
output_dir = Path(args.outputdir)
|
||||
|
||||
if not config_dir.is_dir():
|
||||
raise NotADirectoryError(f"{config_dir} is not a directory")
|
||||
|
||||
if not image_dir.is_dir():
|
||||
raise NotADirectoryError(f"{image_dir} is not a directory")
|
||||
|
||||
if not output_dir.is_dir():
|
||||
output_dir.mkdir(parents=True)
|
||||
|
||||
# Generate the cursors
|
||||
#
|
||||
for src_file in config_dir.glob("*.cfg"):
|
||||
cur_name = src_file.stem
|
||||
output_file_path = output_dir / cur_name
|
||||
|
||||
subprocess.run(["xcursorgen", "--prefix", image_dir, src_file, output_file_path], check=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user