-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_include.sh
More file actions
executable file
·42 lines (33 loc) · 1.01 KB
/
Copy pathcustom_include.sh
File metadata and controls
executable file
·42 lines (33 loc) · 1.01 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
#!/bin/bash
# this is to parse the @custom_include statements in Tweak.x
# in order to achieve hooks spread up into multiple files.
# read the file line by line and save everything back to Tweak.x
# except for the @custom_include statements, which will be replaced
echo "generating code ..."
read -r -d '' fileheader << MEOW
/*
* !! THIS FILE IS AUTOGENERATED !!
* DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN
*/
MEOW
function codegen {
echo "running codegen for $1"
echo "$fileheader" > ".gen_$1"
while read line; do
if [[ $line == @custom_include* ]]; then
file=${line#*@custom_include }
file=${file%\"*}
file=${file#\"*}
echo "found custom include for $file"
if [ -f "$file" ]; then
echo "including $file"
line=$(cat "$file")
else
echo "file $file not found"
exit 1
fi
fi
echo "$line" >> ".gen_$1"
done < "$1"
}
codegen Tweak.x