]> git.donarmstrong.com Git - kiibohd-controller.git/blob - buildall.bash
Ensure directories can only be made with printable characters
[kiibohd-controller.git] / buildall.bash
1 #!/usr/bin/env bash
2 ###| Builder Script |###
3 #
4 # Builds all permutations of modules
5 # This script is an attempt to maintain module sanity as new ones are added
6 #
7 # Fortunately, sweeping API changes don't happen much anymore...but just in case...
8 #
9 # Written by Jacob Alexander 2013 for the Kiibohd Controller
10 # Released into the Public Domain
11 #
12 ###
13
14 ## TODO List ##
15 # - Complete non-Scan module permutations (will take extra work)
16 # - Add command line arguments
17 # - Add help flag for usage
18 # - Make sure the script is being run from the correct directory
19
20
21 main() {
22         ERROR="\e[5;1;31mERROR\e[0m:"
23         failCount=0
24
25         # Scan for list of Scan Modules
26         scanModules=$(ls Scan)
27
28         # Prune out "invalid" modules (parent modules)
29         scanModules=${scanModules[@]//matrix/}
30
31         # Create permutation directories
32         # Then run cmake, and run each build permutation
33         # Keeping track of how many builds failed/passed
34         for mod in $scanModules; do
35                 module=$(tr -dc "[:print:]" <<< "$mod")
36                 # Create directory, but do not error if it exists already
37                 mkdir -p build/$module
38                 cd build/$module
39
40                 # Make sure CMake has been run, and attempt to build
41                 cmake -DScanModuleOverride=$module ../.. && make || let failCount++
42
43                 # Cleanup, for the next build
44                 cd - > /dev/null
45         done
46
47         totalModules=$(echo $scanModules | wc -w)
48         if (( failCount > 0 )); then
49                 echo -e "$ERROR $failCount/$totalModules failed"
50         else
51                 echo -e "Build Success!"
52         fi
53 }
54
55
56 #| Main Script Entry
57 main "$@"
58
59
60 exit 0
61