Kiibohd Controller
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
此仓库已存档。您可以查看文件和克隆,但不能推送或创建工单/合并请求。

cmake.bash 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/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. make
  75. echo "Firmware has been compiled into: '${BuildPath}'"
  76. cd -