Kiibohd Controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

cmake.bash 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/usr/bin/env bash
  2. # This is bash lib file for the convenience build scripts
  3. # Don't call this script directly
  4. # Jacob Alexander 2015
  5. # Make sure all of the relevant variables have been set
  6. # NOTE: PartialMaps and DefaultMap do not have to be set
  7. VariablesList=(BuildPath BaseMap ScanModule MacroModule OutputModule DebugModule Chip Compiler)
  8. ExitEarly=false
  9. for var in ${VariablesList[@]}; do
  10. if [ -z ${!var+x} ]; then
  11. echo "ERROR: Unset variable => '${var}'"
  12. ExitEarly=true
  13. fi
  14. done
  15. # Error was detected, exit immediately
  16. if $ExitEarly; then
  17. exit 1
  18. fi
  19. # Prepare PartialMaps
  20. PartialMapsExpanded="${PartialMaps[1]}"
  21. count=2 # Start the loop at index 2
  22. while [ "$count" -le "${#PartialMaps[@]}" ]; do
  23. PartialMapsExpanded="${PartialMapsExpanded};${PartialMaps[count]}"
  24. count=$(($count+1))
  25. done
  26. # Internal Variables
  27. CMakeListsPath="../.."
  28. PROG_NAME=$(basename $0)
  29. # Process the command line arguments (if any)
  30. while (( "$#" >= "1" )); do
  31. # Scan each argument
  32. key="$1"
  33. case $key in
  34. -c|--cmakelists-path)
  35. CMakeListsPath="$2"
  36. shift
  37. ;;
  38. -f|--force-rebuild)
  39. # Remove the old directory first
  40. rm -rf "${BuildPath}"
  41. ;;
  42. -o|--output-path)
  43. BuildPath="$2"
  44. shift
  45. ;;
  46. -h|--help)
  47. echo "Usage: $PROG_NAME [options...]"
  48. echo ""
  49. echo "Convenience script to build the source of a given keyboard."
  50. echo "Edit '$PROG_NAME' to configure the keyboard options such as KLL layouts."
  51. echo ""
  52. echo "Arguments:"
  53. echo " -c, --cmakelists-path PATH Set the path of CMakeLists.txt"
  54. echo " Default: ${CMakeListsPath}"
  55. echo " -f, --force-rebuild Deletes the old build directory and rebuilds from scratch."
  56. echo " -o, --output-path PATH Set the path of the build files."
  57. echo " Default: ${BuildPath}"
  58. echo " -h, --help This message."
  59. exit 1
  60. ;;
  61. *)
  62. echo "INVALID ARG: '$1'"
  63. exit 2
  64. ;;
  65. esac
  66. # Shift to the next argument
  67. shift
  68. done
  69. # Run CMake commands
  70. ## TODO Check for windows and do windows specific things ##
  71. mkdir -p "${BuildPath}"
  72. cd "${BuildPath}"
  73. cmake -DCHIP="${Chip}" -DCOMPILER="${Compiler}" -DScanModule="${ScanModule}" -DMacroModule="${MacroModule}" -DOutputModule="${OutputModule}" -DDebugModule="${DebugModule}" -DBaseMap="${BaseMap}" -DDefaultMap="${DefaultMap}" -DPartialMaps="${PartialMapsExpanded}" "${CMakeListsPath}"
  74. return_code=$?
  75. if [ $return_code != 0 ] ; then
  76. echo "Error in cmake. Exiting..."
  77. exit $return_code
  78. fi
  79. make
  80. return_code=$?
  81. if [ $return_code != 0 ] ; then
  82. echo "Error in make. Exiting..."
  83. exit $return_code
  84. fi
  85. echo "Firmware has been compiled into: '${BuildPath}'"
  86. cd -