forked from johnbeard/kiplot
-
Notifications
You must be signed in to change notification settings - Fork 68
/
entrypoint.sh
executable file
·228 lines (205 loc) · 7.16 KB
/
entrypoint.sh
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/bin/bash
# Script configurations
SCRIPT="KiBot"
# Arguments and their default values
CONFIG=""
BOARD=""
SCHEMA=""
SKIP=""
DIR=""
VARIANT=""
TARGETS=""
QUICKSTART="NO"
INSTALL3D="NO"
CACHE3D="NO"
EXTRA_ARGS=""
# Exit error code
EXIT_ERROR=1
function msg_example {
echo -e "example: $SCRIPT '-d docs' '-b example.kicad_pcb' '-e example.sch' '-c docs.kibot.yaml'"
}
function msg_usage {
echo -e "usage: $SCRIPT [OPTIONS]..."
}
function msg_disclaimer {
echo -e "This is free software: you are free to change and redistribute it"
echo -e "There is NO WARRANTY, to the extent permitted by law.\n"
echo -e "See <https://github.com/INTI-CMNB/KiBot>."
}
function msg_illegal_arg {
echo -e "$SCRIPT: illegal option $@"
}
function msg_help {
echo -e "\nOptional control arguments:"
echo -e " '-c FILE' .kibot.yaml config file"
echo -e " '-C YES' cache the 3D models."
echo -e " '-d DIR' output path. Default: current dir, will be used as prefix of dir configured in config file"
echo -e " '-b FILE' .kicad_pcb board file. Use __SCAN__ to get the first board file found in current folder."
echo -e " '-e FILE' .sch schematic file. Use __SCAN__ to get the first schematic file found in current folder."
echo -e " '-i YES' install the 3D models."
echo -e " '-q YES' generate configs and outputs automagically (-b, -e, -s, -V, -c are ignored)."
echo -e " '-s PRES' skip preflights, comma separated or 'all'"
echo -e " '-t TARGETS' list of targets to generate separated by spaces. To only run preflights use __NONE__."
echo -e " '-V VARIANT' global variant"
echo -e " '-x EXTRA_ARGS' extra arguments to concatenate"
echo -e "\nMiscellaneous:"
echo -e " '-v LEVEL' annotate program execution"
echo -e " -h display this message and exit"
}
function msg_more_info {
echo -e "Try '$SCRIPT -h' for more information."
}
function help {
msg_usage
echo ""
msg_help
echo ""
msg_example
echo ""
msg_disclaimer
}
function illegal_arg {
msg_illegal_arg "$@"
echo ""
msg_usage
echo ""
msg_example
echo ""
msg_more_info
}
function usage {
msg_usage
echo ""
msg_more_info
}
function args_process {
while [ "$1" != "" ];
do
ARG="$1"
VAL=${ARG:3:10000}
case ${ARG:0:2} in
-c) if [ "$VAL" == "__SCAN__" ]; then
CONFIG=""
else
CONFIG="-c '$VAL'"
fi
;;
-b) if [ "$VAL" == "__SCAN__" ]; then
BOARD=""
else
BOARD="-b '$VAL'"
fi
;;
-e) if [ "$VAL" == "__SCAN__" ]; then
SCHEMA=""
else
SCHEMA="-e '$VAL'"
fi
;;
-t) if [ "$VAL" == "__NONE__" ]; then
TARGETS="-i"
elif [ "$VAL" == "__ALL__" ]; then
TARGETS=""
else
TARGETS="$VAL"
fi
;;
-V) if [ "$VAL" == "__NONE__" ]; then
VARIANT=""
else
VARIANT="-g variant=$VAL"
fi
;;
-d) DIR="-d '$VAL'"
;;
-q) QUICKSTART="$VAL"
;;
-i) INSTALL3D="$VAL"
;;
-C) CACHE3D="$VAL"
;;
-s) if [ "$VAL" == "__NONE__" ]; then
SKIP=""
else
SKIP="-s $VAL"
fi
;;
-v) if [ "$VAL" == "0" ]; then
VERBOSE=""
elif [ "$VAL" == "1" ]; then
VERBOSE="-v"
elif [ "$VAL" == "2" ]; then
VERBOSE="-vv"
elif [ "$VAL" == "3" ]; then
VERBOSE="-vvv"
else
VERBOSE="-vvvv"
fi
;;
-x) EXTRA_ARGS="$VAL"
;;
-h) help
exit
;;
*) illegal_arg "$@"
exit $EXIT_ERROR
;;
esac
shift
done
}
function run {
if [ -d .git ]; then
/usr/bin/kicad-git-filters.py
fi
if [ $INSTALL3D == "YES" ]; then
/usr/bin/kicad_3d_install.sh
fi
if [ $CACHE3D == "YES" ]; then
export KIBOT_3D_MODELS="$HOME/cache_3d"
echo Exporting KIBOT_3D_MODELS=$KIBOT_3D_MODELS
fi
if [ $QUICKSTART == "YES" ]; then
echo Quick-start options: $VERBOSE --quick-start
/bin/bash -c "kibot $VERBOSE --quick-start"
else
echo Options: $CONFIG $DIR $BOARD $SCHEMA $SKIP $VERBOSE $VARIANT $TARGETS $EXTRA_ARGS
/bin/bash -c "kibot $CONFIG $DIR $BOARD $SCHEMA $SKIP $VERBOSE $VARIANT $TARGETS $EXTRA_ARGS"
fi
}
function main {
args_process "$@"
run
}
echo "*****************************************************************************************"
echo "*****************************************************************************************"
echo
echo "KKKKKKKKK KKKKKKK iiii BBBBBBBBBBBBBBBBB tttt"
echo "K:::::::K K:::::K i::::i B::::::::::::::::B ttt:::t"
echo "K:::::::K K:::::K iiii B::::::BBBBBB:::::B t:::::t"
echo "K:::::::K K::::::K BB:::::B B:::::B t:::::t"
echo "KK::::::K K:::::KKKiiiiiii B::::B B:::::B ooooooooooo ttttttt:::::ttttttt"
echo " K:::::K K:::::K i:::::i B::::B B:::::B oo:::::::::::oo t:::::::::::::::::t"
echo " K::::::K:::::K i::::i B::::BBBBBB:::::B o:::::::::::::::ot:::::::::::::::::t"
echo " K:::::::::::K i::::i B:::::::::::::BB o:::::ooooo:::::otttttt:::::::tttttt"
echo " K:::::::::::K i::::i B::::BBBBBB:::::B o::::o o::::o t:::::t"
echo " K::::::K:::::K i::::i B::::B B:::::Bo::::o o::::o t:::::t"
echo " K:::::K K:::::K i::::i B::::B B:::::Bo::::o o::::o t:::::t"
echo "KK::::::K K:::::KKK i::::i B::::B B:::::Bo::::o o::::o t:::::t tttttt"
echo "K:::::::K K::::::Ki::::::iBB:::::BBBBBB::::::Bo:::::ooooo:::::o t::::::tttt:::::t"
echo "K:::::::K K:::::Ki::::::iB:::::::::::::::::B o:::::::::::::::o tt::::::::::::::t"
echo "K:::::::K K:::::Ki::::::iB::::::::::::::::B oo:::::::::::oo tt:::::::::::tt"
echo "KKKKKKKKK KKKKKKKiiiiiiiiBBBBBBBBBBBBBBBBB ooooooooooo ttttttttttt"
echo
echo 🤖 KiBot GitHub Action v2 🚀
echo
kibot --version | awk '{ print $1 ": " $2 }'
echo KiCad: `dpkg --robot -l kicad | grep kicad | awk '{print $3}'`
echo Debian: `cat /etc/debian_version`
pcbnew_do --version | awk 'BEGIN{ done=0 } { if (done == 0) { print "KiAuto: " $2; done=1 } }'
kicost --version | tr -d 'v'
echo "iBoM:" `INTERACTIVE_HTML_BOM_NO_DISPLAY=True generate_interactive_bom.py --version 2> /dev/null | grep "^v" | tr -d 'v'`
echo
echo "*****************************************************************************************"
echo "*****************************************************************************************"
main "$@"