2 # This is bash lib file for the convenience build scripts
3 # Don't call this script directly
6 # Make sure all of the relevant variables have been set
7 # NOTE: PartialMaps and DefaultMap do not have to be set
8 VariablesList=(BuildPath BaseMap ScanModule MacroModule OutputModule DebugModule Chip Compiler)
10 for var in ${VariablesList[@]}; do
11 if [ -z ${!var+x} ]; then
12 echo "ERROR: Unset variable => '${var}'"
17 # Error was detected, exit immediately
24 PartialMapsExpanded="${PartialMaps[1]}"
25 count=2 # Start the loop at index 2
26 while [ "$count" -le "${#PartialMaps[@]}" ]; do
27 PartialMapsExpanded="${PartialMapsExpanded};${PartialMaps[count]}"
33 CMakeListsPath="../.."
34 PROG_NAME=$(basename $0)
37 # Process the command line arguments (if any)
38 while (( "$#" >= "1" )); do
47 # Remove the old directory first
55 echo "Usage: $PROG_NAME [options...]"
57 echo "Convenience script to build the source of a given keyboard."
58 echo "Edit '$PROG_NAME' to configure the keyboard options such as KLL layouts."
61 echo " -c, --cmakelists-path PATH Set the path of CMakeLists.txt"
62 echo " Default: ${CMakeListsPath}"
63 echo " -f, --force-rebuild Deletes the old build directory and rebuilds from scratch."
64 echo " -o, --output-path PATH Set the path of the build files."
65 echo " Default: ${BuildPath}"
66 echo " -h, --help This message."
70 echo "INVALID ARG: '$1'"
75 # Shift to the next argument
81 ## TODO Check for windows and do windows specific things ##
82 mkdir -p "${BuildPath}"
84 cmake -DCHIP="${Chip}" -DCOMPILER="${Compiler}" -DScanModule="${ScanModule}" -DMacroModule="${MacroModule}" -DOutputModule="${OutputModule}" -DDebugModule="${DebugModule}" -DBaseMap="${BaseMap}" -DDefaultMap="${DefaultMap}" -DPartialMaps="${PartialMapsExpanded}" "${CMakeListsPath}"
87 echo "Firmware has been compiled into: '${BuildPath}'"