Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
163 lines (145 loc) · 6.33 KB
/
Copy pathTaskfile.yml
File metadata and controls
163 lines (145 loc) · 6.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
version: '3'
run: once # shared deps (image, generate, ...) run a single time per invocation
vars:
IMAGE: construct-brand
UID:
sh: id -u
GID:
sh: id -g
# Every generator runs in the image (Dockerfile): pinned Python, libraries and pngquant, as
# the user running task, so what it writes is theirs.
RUN: docker run --rm -u {{.UID}}:{{.GID}} -e FONT -e SIZE -v {{.ROOT_DIR}}:/w -w /w {{.IMAGE}}
FRAMES_DIR: frames
VIDEO: construct.mp4
DURATION: 5
SPRITE: sprite.png
COLS: 8
SIZE: 1080 # Plymouth frame width/height (>= 800; 1080 for a 1080p boot)
QUALITY: 80-95 # pngquant quality range for the Plymouth PNGs
PLY_DIR: plymouth
tasks:
default:
cmds:
- task: all
all:
desc: Everything - video, sprite, compressed Plymouth frames, logo, palette and wallpapers
deps: [encode, sprite, plymouth, logo, palette, wallpaper]
image:
desc: Build the {{.IMAGE}} image every generator runs in (Docker)
sources: [Dockerfile, requirements.txt]
cmds:
- docker build -q -t {{.IMAGE}} .
generate:
desc: Render the 48 PNG frames ({{.SIZE}}px) into {{.FRAMES_DIR}}/
label: generate-{{.SIZE}}-{{.FRAMES_DIR}}
deps: [image]
sources: [video.py, room.py, palette.py, palette.toml, fonts/*.ttf, Dockerfile, requirements.txt]
generates: ['{{.FRAMES_DIR}}/construct_*.png', '{{.FRAMES_DIR}}/segments.json']
cmds:
- SIZE={{.SIZE}} {{.RUN}} python video.py {{.FRAMES_DIR}}
encode:
desc: Build {{.VIDEO}} ({{.DURATION}}s) from the frames
label: encode-{{.DURATION}}
deps: [generate]
sources: ['{{.FRAMES_DIR}}/construct_*.png', encode.py]
generates: ['{{.VIDEO}}']
cmds:
- '{{.RUN}} python encode.py {{.FRAMES_DIR}} {{.VIDEO}} {{.DURATION}}'
play:
desc: Open {{.VIDEO}} in this machine's video player
deps: [encode]
cmds:
- if command -v xdg-open >/dev/null; then xdg-open {{.VIDEO}}; else open {{.VIDEO}}; fi
sprite:
desc: Build {{.SPRITE}}, a grid of all frames to see the progression
label: sprite-{{.COLS}}
deps: [generate]
sources: ['{{.FRAMES_DIR}}/construct_*.png', sprite.py]
generates: ['{{.SPRITE}}']
cmds:
- '{{.RUN}} python sprite.py {{.FRAMES_DIR}} {{.SPRITE}} {{.COLS}}'
plymouth:
desc: Transparent PNGs for Plymouth ({{.SIZE}}px, no background, each picture once) and sequence.json from {{.FRAMES_DIR}}/, compressed with pngquant, into {{.PLY_DIR}}/
label: plymouth-{{.SIZE}}-{{.QUALITY}}-{{.PLY_DIR}} # re-run when SIZE, QUALITY or the output change
deps: [generate]
sources: ['{{.FRAMES_DIR}}/construct_*.png', '{{.FRAMES_DIR}}/segments.json', plymouth.py, Dockerfile, requirements.txt]
generates: ['{{.PLY_DIR}}/*']
cmds:
- rm -rf {{.PLY_DIR}}
- '{{.RUN}} python plymouth.py {{.FRAMES_DIR}} {{.PLY_DIR}}' # lossless RGBA, then pngquant
- task: compress
vars: {PLY_DIR: '{{.PLY_DIR}}'}
compress:
desc: Compress the PNGs in {{.PLY_DIR}}/ in place with pngquant (replaces the files)
label: compress-{{.PLY_DIR}}
deps: [image]
cmds:
- >-
{{.RUN}} sh -c 'for file in "{{.PLY_DIR}}"/*.png; do
pngquant --force --ext .png --strip --speed 1 --skip-if-larger --quality {{.QUALITY}} "$file" ||
{ code=$?; [ "$code" -eq 98 ] || exit "$code"; }; done'
- du -sh {{.PLY_DIR}}
logo:
desc: The logo (SVG color, GNOME symbolic and Activities; PNG icon sizes) into logos/
label: logo-{{.LOGO_DIR}}
deps: [image]
vars:
LOGO_DIR: '{{.LOGO_DIR | default "logos"}}'
sources: [logo.py, room.py, palette.py, palette.toml, fonts/*.ttf]
generates: ['{{.LOGO_DIR}}/*']
cmds:
- '{{.RUN}} python logo.py {{.LOGO_DIR}}'
palette:
desc: Check the palette's contrast and perceptual separation and write it out into palette/ - CSS and the perception table and filters for preview.html, SCSS for Orchis, JSON for the image, Ghostty's and VS Code's themes
label: palette-{{.PALETTE_DIR}}
deps: [image]
vars:
PALETTE_DIR: '{{.PALETTE_DIR | default "palette"}}'
sources: [palette.py, palette.toml]
generates: ['{{.PALETTE_DIR}}/*']
cmds:
- '{{.RUN}} python palette.py {{.PALETTE_DIR}}'
wallpaper:
desc: The desktop backgrounds - default, quiet, offset, mark - dark and light, at 2880x1800, and Settings' construct.xml into wallpapers/
label: wallpaper-{{.WALLPAPER_DIR}}
deps: [image]
vars:
WALLPAPER_DIR: '{{.WALLPAPER_DIR | default "wallpapers"}}'
sources: [wallpaper.py, room.py, palette.py, palette.toml]
generates: ['{{.WALLPAPER_DIR}}/*']
cmds:
- '{{.RUN}} python wallpaper.py {{.WALLPAPER_DIR}}'
preview:
desc: Open preview.html - the desktop with the palette, in dark and light - in this machine's browser
deps: [palette, wallpaper, logo]
cmds:
- if command -v xdg-open >/dev/null; then xdg-open preview.html; else open preview.html; fi
lint:
desc: Fail if a fork in {{.FORKS}} writes a color palette.toml does not, draws the accent at an alpha that is not a token, rounds, spaces or shadows off THEMING.md's tables, or holds a stale copy of the palette (lint-forks.toml says which files and why)
deps: [image]
vars:
FORKS: '{{.FORKS | default ".."}}' # the forks checked out beside brand, as Construct-Linux's are
cmds:
- docker run --rm -u {{.UID}}:{{.GID}} -v {{.ROOT_DIR}}:/w -v "$(realpath {{.FORKS}})":/forks:ro -w /w {{.IMAGE}} python lint.py /forks
check:
desc: Fail if the committed plymouth/, logos/, wallpapers/ and palette/ are not what the sources make
deps: [image]
cmds:
- rm -rf .check {{.FRAMES_DIR}} # the frames are rendered again, not taken as they are
- task: plymouth
vars: {PLY_DIR: .check/plymouth}
- task: logo
vars: {LOGO_DIR: .check/logos}
- task: wallpaper
vars: {WALLPAPER_DIR: .check/wallpapers}
- task: palette
vars: {PALETTE_DIR: .check/palette}
- '{{.RUN}} python check.py plymouth .check/plymouth'
- '{{.RUN}} python check.py logos .check/logos'
- '{{.RUN}} python check.py wallpapers .check/wallpapers'
- '{{.RUN}} python check.py palette .check/palette'
- rm -rf .check
clean:
desc: Remove the generated frames, video and sprite (plymouth/, logos/, wallpapers/ and palette/ are committed)
cmds:
- rm -rf {{.FRAMES_DIR}} {{.VIDEO}} {{.SPRITE}} .check