amiro-os / ide / qtcreator / setup.sh @ 0f37fb41
History | View | Annotate | Download (16.481 KB)
1 | 58fe0e0b | Thomas Schöpping | #!/bin/bash |
---|---|---|---|
2 | |||
3 | ############################ |
||
4 | ### HELPER FUNCTIONS ### |
||
5 | ############################ |
||
6 | |||
7 | function absoluteToRelativePath { |
||
8 | # both $1 and $2 are absolute paths beginning with / |
||
9 | # stores the relative path from $1/START_PATH to $2/TARGET_PATH in $3/RESULT_PATH or echoes it |
||
10 | |||
11 | START_PATH=$1 |
||
12 | TARGET_PATH=$2 |
||
13 | |||
14 | # check whether one of both paths ends with / and remove it for now |
||
15 | ENDS_WITH_SLASH=false |
||
16 | while [ "${START_PATH%"/"}" != "$START_PATH" ]; do |
||
17 | START_PATH=${START_PATH::-1} |
||
18 | ENDS_WITH_SLASH=true |
||
19 | done |
||
20 | while [ "${TARGET_PATH%"/"}" != "$TARGET_PATH" ]; do |
||
21 | TARGET_PATH=${TARGET_PATH::-1} |
||
22 | ENDS_WITH_SLASH=true |
||
23 | done |
||
24 | |||
25 | # initialize the common prefix and the relative path from START_PATH to TARGET_PATH |
||
26 | COMMON_PREFIX=$START_PATH |
||
27 | RELATIVE_PATH="" |
||
28 | while [ "${TARGET_PATH#$COMMON_PREFIX}" == "$TARGET_PATH" ]; do |
||
29 | # while the COMMOM_PREFIX is no substring of TARGET_PATH, reduce it |
||
30 | COMMON_PREFIX="$(dirname $COMMON_PREFIX)" |
||
31 | |||
32 | # thereby record the relative path |
||
33 | if [ -z $RELATIVE_PATH ]; then |
||
34 | RELATIVE_PATH=".." |
||
35 | else |
||
36 | RELATIVE_PATH="../$RELATIVE_PATH" |
||
37 | fi |
||
38 | done |
||
39 | |||
40 | # if the reltiva path is empty, set it as the current directory |
||
41 | if [ -z $RELATIVE_PATH ]; then |
||
42 | RELATIVE_PATH="." |
||
43 | fi |
||
44 | |||
45 | if [ $COMMON_PREFIX == "/" ]; then |
||
46 | # special case if only root is the common path |
||
47 | RELATIVE_PATH="$RELATIVE_PATH/" |
||
48 | fi |
||
49 | |||
50 | # compute the unique part of the target path |
||
51 | UNIQUE_POSTFIX="${TARGET_PATH#$COMMON_PREFIX}" |
||
52 | |||
53 | # append the unique postfix to the relative path |
||
54 | if [ -n $RELATIVE_PATH ] && [ -n $UNIQUE_POSTFIX ]; then |
||
55 | RELATIVE_PATH="$RELATIVE_PATH$UNIQUE_POSTFIX" |
||
56 | elif [ -n $UNIQUE_POSTFIX ]; then |
||
57 | # remove the slash |
||
58 | RELATIVE_PATH="${UNIQUE_POSTFIX:1}" |
||
59 | fi |
||
60 | |||
61 | # remove a prepending slash if any |
||
62 | if [ "${RELATIVE_PATH#"/"}" != "$RELATIVE_PATH" ]; then |
||
63 | RELATIVE_PATH=${RELATIVE_PATH:1} |
||
64 | fi |
||
65 | |||
66 | # if at least one input ended with a slash, add it to the result as well |
||
67 | if [ $ENDS_WITH_SLASH == true ]; then |
||
68 | RELATIVE_PATH="${RELATIVE_PATH}/" |
||
69 | fi |
||
70 | |||
71 | # return the result |
||
72 | if [ $# -gt 2 ]; then |
||
73 | eval $3="$RELATIVE_PATH" |
||
74 | else |
||
75 | echo $RELATIVE_PATH |
||
76 | fi |
||
77 | |||
78 | # clean up |
||
79 | unset START_PATH |
||
80 | unset TARGET_PATH |
||
81 | unset ENDS_WITH_SLASH |
||
82 | unset COMMON_PREFIX |
||
83 | unset RELATIVE_PATH |
||
84 | unset UNIQUE_POSTFIX |
||
85 | } |
||
86 | |||
87 | |||
88 | function cleanupVariables { |
||
89 | |||
90 | unset HELP_FLAG |
||
91 | unset CLEAN_FLAG |
||
92 | unset WIPE_FLAG |
||
93 | unset CHOS |
||
94 | unset LR |
||
95 | unset PM |
||
96 | unset DWD |
||
97 | unset ARG_LIST |
||
98 | |||
99 | unset USER_DIR |
||
100 | unset SCRIPT_DIR |
||
101 | |||
102 | unset GCC_ARM_NONE_EABI_INCLUDE_PATH |
||
103 | unset PROJECT_ROOT_PATH |
||
104 | unset AMIROOS_ROOT_PATH |
||
105 | unset CHIBIOS_ROOT_PATH |
||
106 | |||
107 | unset CHIBIOS_PROJECT_PREFIX |
||
108 | unset LIGHTRING_PROJECT_PREFIX |
||
109 | unset POWERMANAGEMENT_PROJECT_PREFIX |
||
110 | unset DIWHEELDRIVE_PROJECT_PREFIX |
||
111 | |||
112 | unset PROJECT_ROOT_TO_CHIBIOS |
||
113 | unset PROJECT_ROOT_TO_AMIROOS |
||
114 | } |
||
115 | |||
116 | |||
117 | ################# |
||
118 | ### INTRO ### |
||
119 | ################# |
||
120 | |||
121 | echo "-------------------------------------------------------------------------------" |
||
122 | echo "" |
||
123 | echo "Setup to create QtCreator projects" |
||
124 | echo "==================================" |
||
125 | echo "" |
||
126 | |||
127 | |||
128 | |||
129 | ########################## |
||
130 | ### INITIALIZATION ### |
||
131 | ########################## |
||
132 | |||
133 | # ignore case when comparing strings |
||
134 | shopt -s nocasematch |
||
135 | |||
136 | # detect what exactly should be done |
||
137 | HELP_FLAG="HELP" |
||
138 | CLEAN_FLAG="CLEAN" |
||
139 | WIPE_FLAG="WIPE" |
||
140 | CHIBIOS_FLAG="CHOS" |
||
141 | LIGHTRING_FLAG="LR" |
||
142 | POWERMANAGEMENT_FLAG="PM" |
||
143 | DIWHEELDRIVE_FLAG="DWD" |
||
144 | |||
145 | # start with an empty array |
||
146 | ARG_LIST=() |
||
147 | if [ $# == 0 ]; then |
||
148 | # if no argument was specified, 'help' is considered as default |
||
149 | ARG_LIST+=($HELP_FLAG) |
||
150 | else |
||
151 | for ARG in "$@"; do |
||
152 | case ${ARG,,} in |
||
153 | "help"|"-help"|"--help") |
||
154 | ARG_LIST+=($HELP_FLAG) |
||
155 | ;; |
||
156 | "clean") |
||
157 | ARG_LIST+=($CLEAN_FLAG) |
||
158 | ;; |
||
159 | "wipe") |
||
160 | ARG_LIST+=($WIPE_FLAG) |
||
161 | ;; |
||
162 | "all") |
||
163 | ARG_LIST+=($LIGHTRING_FLAG $POWERMANAGEMENT_FLAG $DIWHEELDRIVE_FLAG) |
||
164 | ;; |
||
165 | "ChibiOS") |
||
166 | ArrayContainsElement "${ARG_LIST[@]}" "$CHIBIOS_FLAG" |
||
167 | if [ $? != 1 ]; then |
||
168 | ARG_LIST+=($CHIBIOS_FLAG) |
||
169 | fi |
||
170 | ;; |
||
171 | "LightRing") |
||
172 | ArrayContainsElement "${ARG_LIST[@]}" "$LIGHTRING_FLAG" |
||
173 | if [ $? != 1 ]; then |
||
174 | ARG_LIST+=($LIGHTRING_FLAG) |
||
175 | fi |
||
176 | ;; |
||
177 | "PowerManagement") |
||
178 | ArrayContainsElement "${ARG_LIST[@]}" "$POWERMANAGEMENT_FLAG" |
||
179 | if [ $? != 1 ]; then |
||
180 | ARG_LIST+=($POWERMANAGEMENT_FLAG) |
||
181 | fi |
||
182 | ;; |
||
183 | "DiWheelDrive") |
||
184 | ArrayContainsElement "{$ARG_LIST[@]}" "DIWHEELDRIVE_FLAG" |
||
185 | if [ $? != 1 ]; then |
||
186 | ARG_LIST+=($DIWHEELDRIVE_FLAG) |
||
187 | fi |
||
188 | ;; |
||
189 | esac |
||
190 | done |
||
191 | fi |
||
192 | |||
193 | |||
194 | |||
195 | ###################### |
||
196 | ### PRINT HELP ### |
||
197 | ###################### |
||
198 | |||
199 | if [[ "${ARG_LIST[@]}" == *"$HELP_FLAG"* ]]; then |
||
200 | echo -e "> HELP" |
||
201 | echo -e "" |
||
202 | echo -e "\tThe following commands are available:" |
||
203 | echo -e "" |
||
204 | echo -e "\t help - Prints this help text." |
||
205 | echo -e "\t clean - Deletes all files created by this script." |
||
206 | echo -e "\t wipe - Deletes the .user files, created by QtCreator." |
||
207 | echo -e "\t ChibiOS - Creates a project for ChibiOS." |
||
208 | echo -e "\t LightRing - Creates a project for the LightRing module." |
||
209 | echo -e "\t PowerManagement - Creates a project for the PowerManagement module." |
||
210 | echo -e "\t DiWheelDrive - Creates a project for the DiWheelDrive module." |
||
211 | echo -e "\t all - Creates all three projects (no ChibiOS project)." |
||
212 | echo -e "" |
||
213 | echo -e "\tAny of these commands can be combined, e.g." |
||
214 | echo -e "\t $> ./setup.sh PowerManagement ChibiOS" |
||
215 | echo -e "\twill create two projects." |
||
216 | echo -e "" |
||
217 | echo -e "-------------------------------------------------------------------------------" |
||
218 | |||
219 | cleanupVariables |
||
220 | exit |
||
221 | fi |
||
222 | |||
223 | |||
224 | |||
225 | ######################### |
||
226 | ### CONFIGURATION ### |
||
227 | ######################### |
||
228 | |||
229 | USER_DIR=${PWD} |
||
230 | cd $(dirname ${BASH_SOURCE[0]}) |
||
231 | SCRIPT_DIR=${PWD} |
||
232 | cd $USER_DIR |
||
233 | |||
234 | ### the include path for GCC specific headers |
||
235 | GCC_ARM_NONE_EABI_INCLUDE_PATH="/opt/gcc-arm-none-eabi-4_8-2014q1/arm-none-eabi/include" |
||
236 | read -p "gcc_arm_none_eabi include path: " -i "$GCC_ARM_NONE_EABI_INCLUDE_PATH" -e GCC_ARM_NONE_EABI_INCLUDE_PATH |
||
237 | # make absolute |
||
238 | if [ "/$GCC_ARM_NONE_EABI_INCLUDE_PATH" != "$GCC_ARM_NONE_EABI_INCLUDE_PATH" ]; then |
||
239 | cd $GCC_ARM_NONE_EABI_INCLUDE_PATH |
||
240 | GCC_ARM_NONE_EABI_INCLUDE_PATH=${PWD} |
||
241 | cd $USER_DIR |
||
242 | fi |
||
243 | # append a slash if required |
||
244 | if [ "${GCC_ARM_NONE_EABI_INCLUDE_PATH%"/"}" == "$GCC_ARM_NONE_EABI_INCLUDE_PATH" ]; then |
||
245 | GCC_ARM_NONE_EABI_INCLUDE_PATH="${GCC_ARM_NONE_EABI_INCLUDE_PATH}/" |
||
246 | fi |
||
247 | |||
248 | ### the relative path where all project files shall be generated |
||
249 | cd "$SCRIPT_DIR/../../" |
||
250 | PROJECT_ROOT_PATH=${PWD} |
||
251 | cd $USER_DIR |
||
252 | read -p "path where to create project files: " -i "$PROJECT_ROOT_PATH" -e PROJECT_ROOT_PATH |
||
253 | # make absolute |
||
254 | if [ "/$PROJECT_ROOT_PATH" != "$PROJECT_ROOT_PATH" ]; then |
||
255 | cd $PROJECT_ROOT_PATH |
||
256 | PROJECT_ROOT_PATH=${PWD} |
||
257 | cd $USER_DIR |
||
258 | fi |
||
259 | # append a slash if required |
||
260 | if [ "${PROJECT_ROOT_PATH%"/"}" == "$PROJECT_ROOT_PATH" ]; then |
||
261 | PROJECT_ROOT_PATH="${PROJECT_ROOT_PATH}/" |
||
262 | fi |
||
263 | |||
264 | # the relative path to the AMiRo-OS root directory |
||
265 | cd "$SCRIPT_DIR/../../" |
||
266 | AMIROOS_ROOT_PATH=${PWD} |
||
267 | cd $USER_DIR |
||
268 | read -p "AMiRo-OS root path: " -i "$AMIROOS_ROOT_PATH" -e AMIROOS_ROOT_PATH |
||
269 | # make absolute |
||
270 | if [ "/$AMIROOS_ROOT_PATH" != "$AMIROOS_ROOT_PATH" ]; then |
||
271 | cd $AMIROOS_ROOT_PATH |
||
272 | AMIROOS_ROOT_PATH=${PWD} |
||
273 | cd $USER_DIR |
||
274 | fi |
||
275 | # append a slash if required |
||
276 | if [ "${AMIROOS_ROOT_PATH%"/"}" == "$AMIROOS_ROOT_PATH" ]; then |
||
277 | AMIROOS_ROOT_PATH="${AMIROOS_ROOT_PATH}/" |
||
278 | fi |
||
279 | |||
280 | # the relative path to the ChibiOS root directory |
||
281 | cd "${AMIROOS_ROOT_PATH}../ChibiOS/" |
||
282 | CHIBIOS_ROOT_PATH=${PWD} |
||
283 | cd $USER_DIR |
||
284 | read -p "ChibiOS root path: " -i "$CHIBIOS_ROOT_PATH" -e CHIBIOS_ROOT_PATH |
||
285 | # make absolute |
||
286 | if [ "/$CHIBIOS_ROOT_PATH" != "$CHIBIOS_ROOT_PATH" ]; then |
||
287 | cd $CHIBIOS_ROOT_PATH |
||
288 | CHIBIOS_ROOT_PATH=${PWD} |
||
289 | cd $USER_DIR |
||
290 | fi |
||
291 | # append a slash if required |
||
292 | if [ "${CHIBIOS_ROOT_PATH%"/"}" == "$CHIBIOS_ROOT_PATH" ]; then |
||
293 | CHIBIOS_ROOT_PATH="${CHIBIOS_ROOT_PATH}/" |
||
294 | fi |
||
295 | |||
296 | # the prefix names for the projects to be generated |
||
297 | CHIBIOS_PROJECT_PREFIX="ChibiOS" |
||
298 | LIGHTRING_PROJECT_PREFIX="LightRing" |
||
299 | POWERMANAGEMENT_PROJECT_PREFIX="PowerManagement" |
||
300 | DIWHEELDRIVE_PROJECT_PREFIX="DiWheelDrive" |
||
301 | |||
302 | echo "" |
||
303 | |||
304 | |||
305 | |||
306 | ############################# |
||
307 | ### ENVIRONMENT SETUP ### |
||
308 | ############################# |
||
309 | |||
310 | # generate the relative path from the project root to ChibiOS |
||
311 | absoluteToRelativePath "$PROJECT_ROOT_PATH" "$CHIBIOS_ROOT_PATH" PROJECT_ROOT_TO_CHIBIOS |
||
312 | # generate the relative path from the project root to AMiRo-OS |
||
313 | absoluteToRelativePath "$PROJECT_ROOT_PATH" "$AMIROOS_ROOT_PATH" PROJECT_ROOT_TO_AMIROOS |
||
314 | |||
315 | # move back to the project root directory |
||
316 | cd $PROJECT_ROOT_PATH |
||
317 | |||
318 | |||
319 | |||
320 | ###################### |
||
321 | ### CLEAN STEP ### |
||
322 | ###################### |
||
323 | |||
324 | # clean the project files |
||
325 | if [[ "${ARG_LIST[@]}" == *"$CLEAN_FLAG"* ]]; then |
||
326 | echo -n "removing existing project files..." |
||
327 | |||
328 | # remove all files |
||
329 | rm -f ${CHIBIOS_PROJECT_PREFIX}.includes |
||
330 | rm -f ${CHIBIOS_PROJECT_PREFIX}.files |
||
331 | rm -f ${CHIBIOS_PROJECT_PREFIX}.config |
||
332 | rm -f ${CHIBIOS_PROJECT_PREFIX}.creator |
||
333 | |||
334 | rm -f ${LIGHTRING_PROJECT_PREFIX}.includes |
||
335 | rm -f ${LIGHTRING_PROJECT_PREFIX}.files |
||
336 | rm -f ${LIGHTRING_PROJECT_PREFIX}.config |
||
337 | rm -f ${LIGHTRING_PROJECT_PREFIX}.creator |
||
338 | |||
339 | rm -f ${POWERMANAGEMENT_PROJECT_PREFIX}.includes |
||
340 | rm -f ${POWERMANAGEMENT_PROJECT_PREFIX}.files |
||
341 | rm -f ${POWERMANAGEMENT_PROJECT_PREFIX}.config |
||
342 | rm -f ${POWERMANAGEMENT_PROJECT_PREFIX}.creator |
||
343 | |||
344 | rm -f ${DIWHEELDRIVE_PROJECT_PREFIX}.includes |
||
345 | rm -f ${DIWHEELDRIVE_PROJECT_PREFIX}.files |
||
346 | rm -f ${DIWHEELDRIVE_PROJECT_PREFIX}.config |
||
347 | rm -f ${DIWHEELDRIVE_PROJECT_PREFIX}.creator |
||
348 | |||
349 | echo -e "\tdone" |
||
350 | fi |
||
351 | |||
352 | # wipe even the user specific files (created by QtCreator) |
||
353 | if [[ "${ARG_LIST[@]}" == *"$WIPE_FLAG"* ]]; then |
||
354 | echo -n "removing existing user specific project files..." |
||
355 | |||
356 | # remove all user files |
||
357 | rm -f ${CHIBIOS_PROJECT_PREFIX}.creator.user |
||
358 | rm -f ${LIGHTRING_PROJECT_PREFIX}.creator.user |
||
359 | rm -f ${POWERMANAGEMENT_PROJECT_PREFIX}.creator.user |
||
360 | rm -f ${DIWHEELDRIVE_PROJECT_PREFIX}.creator.user |
||
361 | |||
362 | echo -e "\tdone" |
||
363 | fi |
||
364 | |||
365 | |||
366 | |||
367 | ######################### |
||
368 | ### CHIBIOS SETUP ### |
||
369 | ######################### |
||
370 | |||
371 | if [[ "${ARG_LIST[@]}" == *"$CHIBIOS_FLAG"* ]]; then |
||
372 | echo -n "creating project files for ${CHIBIOS_PROJECT_PREFIX}..." |
||
373 | |||
374 | # generate a file that contains all subdirectories as includes (but ignore hidden and documentation directories) |
||
375 | find $PROJECT_ROOT_TO_CHIBIOS -type d | grep -v /[.][^.] | grep -v /doc/ > ${CHIBIOS_PROJECT_PREFIX}.includes |
||
376 | # generate a file that specifies all files |
||
377 | find $PROJECT_ROOT_TO_CHIBIOS -type f -iname "*.c" -o -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" -o -iname "*.s" | grep -v /[.][^.] | grep -v /doc/ > ${CHIBIOS_PROJECT_PREFIX}.files |
||
378 | # generate a default project configuration file if none exists so far |
||
379 | if [ ! -f ${CHIBIOS_PROJECT_PREFIX}.config ]; then |
||
380 | echo -e "// Add predefined macros for your project here. For example:\n// #define YOUR_CONFIGURATION belongs here\n" > ${CHIBIOS_PROJECT_PREFIX}.config |
||
381 | fi |
||
382 | # generate a default .creator file if none exists so far |
||
383 | if [ ! -f ${CHIBIOS_PROJECT_PREFIX}.creator ]; then |
||
384 | echo -e "[general]\n" > ${CHIBIOS_PROJECT_PREFIX}.creator |
||
385 | fi |
||
386 | |||
387 | echo -e "\tdone" |
||
388 | fi |
||
389 | |||
390 | |||
391 | |||
392 | ########################### |
||
393 | ### LIGHTRING SETUP ### |
||
394 | ########################### |
||
395 | |||
396 | if [[ "${ARG_LIST[@]}" == *"$LIGHTRING_FLAG"* ]]; then |
||
397 | echo -n "creating project files for ${LIGHTRING_PROJECT_PREFIX}..." |
||
398 | |||
399 | # generate a file that contains all subdirectories as includes (but ignore hidden and documentation directories) |
||
400 | echo $GCC_ARM_NONE_EABI_INCLUDE_PATH > ${LIGHTRING_PROJECT_PREFIX}.includes |
||
401 | find $PROJECT_ROOT_TO_AMIROOS -type d | grep -v /[.][^.] | grep -v /doc/ | grep "devices\|include\|util\|boards\|components\|hal" | grep -iv "PowerManagement" | grep -iv "DiWheelDrive" >> ${LIGHTRING_PROJECT_PREFIX}.includes |
||
402 | find $PROJECT_ROOT_TO_CHIBIOS -type d | grep -v /[.][^.] | grep -v /doc/ | grep /os/ >> ${LIGHTRING_PROJECT_PREFIX}.includes |
||
403 | # generate a file that specifies all files |
||
404 | find $PROJECT_ROOT_TO_AMIROOS -type f -iname "*.c" -o -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" -o -iname "*.s" -o -iname "*.tpp" | grep -v /[.][^.] | grep -v /doc/ | grep -iv "PowerManagement" | grep -iv "DiWheelDrive" > ${LIGHTRING_PROJECT_PREFIX}.files |
||
405 | find $PROJECT_ROOT_TO_CHIBIOS -type f -iname "*.c" -o -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" -o -iname "*.s" | grep -v /[.][^.] | grep -v /doc/ | grep /os/ >> ${LIGHTRING_PROJECT_PREFIX}.files |
||
406 | # generate a default project configuration file if none exists so far |
||
407 | if [ ! -f ${LIGHTRING_PROJECT_PREFIX}.config ]; then |
||
408 | echo -e "// Add predefined macros for your project here. For example:\n//#define YOUR_CONFIGURATION belongs here\n" > ${LIGHTRING_PROJECT_PREFIX}.config |
||
409 | fi |
||
410 | # generate a default .creator file if none exists so far |
||
411 | if [ ! -f ${LIGHTRING_PROJECT_PREFIX}.creator ]; then |
||
412 | echo -e "[general]\n" > ${LIGHTRING_PROJECT_PREFIX}.creator |
||
413 | fi |
||
414 | |||
415 | echo -e "\tdone" |
||
416 | fi |
||
417 | |||
418 | |||
419 | |||
420 | ################################# |
||
421 | ### POWERMANAGEMENT SETUP ### |
||
422 | ################################# |
||
423 | |||
424 | if [[ "${ARG_LIST[@]}" == *"$POWERMANAGEMENT_FLAG"* ]]; then |
||
425 | echo -n "creating project files for ${POWERMANAGEMENT_PROJECT_PREFIX}..." |
||
426 | |||
427 | # generate a file that contains all subdirectories as includes (but ignore hidden and documentation directories) |
||
428 | echo $GCC_ARM_NONE_EABI_INCLUDE_PATH > ${POWERMANAGEMENT_PROJECT_PREFIX}.includes |
||
429 | find $PROJECT_ROOT_TO_AMIROOS -type d | grep -v /[.][^.] | grep -v /doc/ | grep "devices\|include\|util\|boards\|components\|hal" | grep -iv "LightRing" | grep -iv "DiWheelDrive" >> ${POWERMANAGEMENT_PROJECT_PREFIX}.includes |
||
430 | find $PROJECT_ROOT_TO_CHIBIOS -type d | grep -v /[.][^.] | grep -v /doc/ >> ${POWERMANAGEMENT_PROJECT_PREFIX}.includes |
||
431 | # generate a file that specifies all files |
||
432 | find $PROJECT_ROOT_TO_AMIROOS -type f -iname "*.c" -o -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" -o -iname "*.s" -o -iname "*.tpp" | grep -v /[.][^.] | grep -v /doc/ | grep -iv "LightRing" | grep -iv "DiWheelDrive" > ${POWERMANAGEMENT_PROJECT_PREFIX}.files |
||
433 | find $PROJECT_ROOT_TO_CHIBIOS -type f -iname "*.c" -o -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" -o -iname "*.s" | grep -v /[.][^.] | grep -v /doc/ | grep /os/ >> ${POWERMANAGEMENT_PROJECT_PREFIX}.files |
||
434 | # generate a default project configuration file if none exists so far |
||
435 | if [ ! -f ${POWERMANAGEMENT_PROJECT_PREFIX}.config ]; then |
||
436 | echo -e "// Add predefined macros for your project here. For example:\n//#define YOUR_CONFIGURATION belongs here\n" > ${POWERMANAGEMENT_PROJECT_PREFIX}.config |
||
437 | fi |
||
438 | # generate a default .creator file if none exists so far |
||
439 | if [ ! -f ${POWERMANAGEMENT_PROJECT_PREFIX}.creator ]; then |
||
440 | echo -e "[general]\n" > ${POWERMANAGEMENT_PROJECT_PREFIX}.creator |
||
441 | fi |
||
442 | |||
443 | echo -e "\tdone" |
||
444 | fi |
||
445 | |||
446 | |||
447 | |||
448 | ############################## |
||
449 | ### DIWHEELDRIVE SETUP ### |
||
450 | ############################## |
||
451 | |||
452 | if [[ "${ARG_LIST[@]}" == *"$DIWHEELDRIVE_FLAG"* ]]; then |
||
453 | echo -n "creating project files for ${DIWHEELDRIVE_PROJECT_PREFIX}..." |
||
454 | |||
455 | # generate a file that contains all subdirectories as includes (but ignore hidden and documentation directories) |
||
456 | echo $GCC_ARM_NONE_EABI_INCLUDE_PATH > ${DIWHEELDRIVE_PROJECT_PREFIX}.includes |
||
457 | find $PROJECT_ROOT_TO_AMIROOS -type d | grep -v /[.][^.] | grep -v /doc/ | grep "devices\|include\|util\|boards\|components\|hal" | grep -iv "LightRing" | grep -iv "PowerManagement" >> ${DIWHEELDRIVE_PROJECT_PREFIX}.includes |
||
458 | find $PROJECT_ROOT_TO_CHIBIOS -type d | grep -v /[.][^.] | grep -v /doc/ >> ${DIWHEELDRIVE_PROJECT_PREFIX}.includes |
||
459 | # generate a file that specifies all files |
||
460 | find $PROJECT_ROOT_TO_AMIROOS -type f -iname "*.c" -o -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" -o -iname "*.s" -o -iname "*.tpp" | grep -v /[.][^.] | grep -v /doc/ | grep -iv "LightRing" | grep -iv "PowerManagement" > ${DIWHEELDRIVE_PROJECT_PREFIX}.files |
||
461 | find $PROJECT_ROOT_TO_CHIBIOS -type f -iname "*.c" -o -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" -o -iname "*.s" | grep -v /[.][^.] | grep -v /doc/ | grep /os/ >> ${DIWHEELDRIVE_PROJECT_PREFIX}.files |
||
462 | # generate a default project configuration file if none exists so far |
||
463 | if [ ! -f ${DIWHEELDRIVE_PROJECT_PREFIX}.config ]; then |
||
464 | echo -e "// Add predefined macros for your project here. For example:\n//#define YOUR_CONFIGURATION belongs here\n" > ${DIWHEELDRIVE_PROJECT_PREFIX}.config |
||
465 | fi |
||
466 | # generate a default .creator file if none exists so far |
||
467 | if [ ! -f ${DIWHEELDRIVE_PROJECT_PREFIX}.creator ]; then |
||
468 | echo -e "[general]\n" > ${DIWHEELDRIVE_PROJECT_PREFIX}.creator |
||
469 | fi |
||
470 | |||
471 | echo -e "\tdone" |
||
472 | fi |
||
473 | |||
474 | |||
475 | |||
476 | ################# |
||
477 | ### OUTRO ### |
||
478 | ################# |
||
479 | |||
480 | cleanupVariables |
||
481 | |||
482 | echo "" |
||
483 | echo "-------------------------------------------------------------------------------" |