Skip to content

Commit 8946c75

Browse files
committed
Clean up the build scripts
1 parent f753411 commit 8946c75

File tree

3 files changed

+176
-36
lines changed

3 files changed

+176
-36
lines changed

.github/workflows/docs-build-branch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Run the Build-Script
3636
run: |
3737
chmod +x build.sh
38-
./build.sh
38+
./build.sh docs
3939
# - name: Commit build artifacts
4040
# # if: github.event_name == 'push'
4141
# run: |

build-atom.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

build.sh

Lines changed: 175 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,181 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env bash
22

3-
rm -rf build
4-
rm -rf docs
5-
cp -rp Shaders docs
6-
cp -rp Tools/Assets/Profiles docs
7-
cp -rp Tools/Documentation docs/
3+
ATOM_URI="com.JiPi.Shadertoys"
84

9-
cd 'Tools/Shell/'
10-
# lua generate_atom.lua
11-
lua generate_csv.lua
12-
lua generate_markdown.lua
13-
lua generate_installer.lua
14-
cd ..
15-
cd ..
5+
# ----------------------------------------------------------------------------
166

17-
lua Tools/Shell/print_videos.lua > docs/Videos.md
7+
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
8+
SCRIPTNAME=`basename $0`
189

19-
cp Shaders.csv docs
10+
set -o errexit
11+
set -o pipefail
12+
set -o nounset
2013

21-
# sudo apt-get install zip
22-
cp -rp build/Shaderfuse-Installers/* docs
23-
cd build
24-
zip -r Shaderfuse-Installers.zip Shaderfuse-Installers
25-
mv Shaderfuse-Installers.zip ../docs/
14+
if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace; fi
2615

16+
cd "$(dirname "$0")"
17+
18+
# ----------------------------------------------------------------------------
19+
20+
function do_clean {
21+
rm -rf assets
22+
rm -rf atom
23+
rm -rf build
24+
rm -rf docs
25+
rm -rf site
26+
rm -f Shaders.csv
27+
}
28+
29+
# ----------------------------------------------------------------------------
30+
31+
function do_csv {
32+
rm -f Shaders.csv
33+
cd 'Tools/Shell/'
34+
lua generate_csv.lua
35+
cd ../..
36+
}
37+
38+
# ----------------------------------------------------------------------------
39+
40+
function do_atom {
41+
42+
rm -rf atom
43+
mkdir atom
44+
45+
cd 'Tools/Shell/'
46+
lua generate_atom.lua
47+
cd ../..
48+
49+
cd "atom/${ATOM_URI}"
50+
zip -r "../${ATOM_URI}.zip" Fuses "${ATOM_URI}.atom"
51+
cd ../..
52+
}
53+
54+
# ----------------------------------------------------------------------------
55+
56+
function do_installers {
57+
58+
rm -rf build/Shaderfuse-Installers
59+
rm -f build/Shaderfuse-Installers.zip
60+
61+
cd 'Tools/Shell/'
62+
lua generate_installer.lua
63+
cd ../..
64+
65+
cd build
66+
zip -r Shaderfuse-Installers.zip Shaderfuse-Installers
67+
cd ..
68+
}
69+
70+
# ----------------------------------------------------------------------------
71+
72+
function do_assets {
73+
# this function does just call some of the other
74+
# do_whatsoever functions to then move theire
75+
# generated output into an assets/ directory that
76+
# can then be used as a source for the assets to
77+
# be uploaded with a new GitHub release.
78+
79+
rm -rf assets
80+
mkdir -p assets
81+
82+
do_csv
83+
mv Shaders.csv assets/Shaderfuses.csv
84+
85+
do_atom
86+
mv "atom/${ATOM_URI}.zip" assets/
87+
rm -rf atom
88+
89+
do_installers
90+
mv build/Shaderfuse-Installers.zip assets/
91+
rm -rf build/Shaderfuse-Installers
92+
}
93+
94+
# ----------------------------------------------------------------------------
95+
96+
function do_docs {
97+
98+
rm -rf docs
99+
100+
# copy Shades/ as a basis
101+
cp -rp Shaders docs
102+
103+
# add some more markdown files
104+
cp -rp Tools/Assets/Profiles docs
105+
cp -rp Tools/Documentation docs/
106+
107+
# patch the markdown files and generate overviews
108+
cd 'Tools/Shell/'
109+
lua generate_markdown.lua
110+
cd ../..
111+
112+
# create the videos list file
113+
lua Tools/Shell/print_videos.lua > docs/Videos.md
114+
115+
# create the installers, as they are referenced in the markdown files
116+
do_installers
117+
cp -rp build/Shaderfuse-Installers/* docs
118+
mv build/Shaderfuse-Installers.zip docs/
119+
rm -rf build/Shaderfuse-Installers/
120+
}
121+
122+
# ----------------------------------------------------------------------------
123+
124+
main() {
125+
126+
local COMMAND="${1-}"
127+
128+
case $COMMAND in
129+
130+
"clean")
131+
do_clean
132+
;;
133+
134+
"csv")
135+
do_csv
136+
;;
137+
138+
"assets")
139+
do_assets
140+
;;
141+
142+
"docs")
143+
do_docs
144+
;;
145+
146+
"atom")
147+
do_atom
148+
;;
149+
150+
"installers")
151+
do_installers
152+
;;
153+
154+
"help" | "-h" | "--help")
155+
echo ""
156+
echo "Usage:"
157+
echo ""
158+
echo " $SCRIPTNAME <command>"
159+
echo ""
160+
echo "The commands are:"
161+
echo ""
162+
echo " atom create the atom package under 'atom/'"
163+
echo " csv create Shaders.csv with a list of all the shaders"
164+
echo " assets create 'assets/' with files to add to a GitHub release"
165+
echo " installers create the drag'n'drop installer lua scripts"
166+
echo " docs create all the input needed for mkdocs"
167+
echo " clean delete any of the autogenerated / temporary content"
168+
echo ""
169+
;;
170+
171+
*)
172+
echo "unknown command '$COMMAND'" >&2
173+
echo "try '$SCRIPTNAME help' for usage" >&2
174+
exit 10
175+
;;
176+
esac
177+
178+
}
179+
180+
181+
main "$@"

0 commit comments

Comments
 (0)