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.

99 lines
2.8 KiB

  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-3.0+
  3. set -e
  4. ## import variables
  5. . ./common/variables.sh
  6. ################################################################################
  7. ## Menu
  8. ################################################################################
  9. ## Parse avialble models from directory names
  10. AVAILABLE_MODELS=$(find ./ -maxdepth 1 -mindepth 1 -type d | sed 's/\.\///g' | grep -Ev "common|git")
  11. ## Help menu
  12. usage()
  13. {
  14. echo "Usage: "
  15. echo
  16. echo " $0 [-t <TAG>] [-c <COMMIT>] [--config] [--bleeding-edge] [--clean-slate] <model>"
  17. echo
  18. echo " --bleeding-edge Build from the latest commit"
  19. echo " --clean-slate Purge previous build directory and config"
  20. echo " -c, --commit <commit> Git commit hash"
  21. echo " -h, --help Show this help"
  22. echo " -i, --config Execute with interactive make config"
  23. echo " -t, --tag <tag> Git tag/version"
  24. echo
  25. echo "If a tag, commit or bleeding-edge flag is not given, the latest Coreboot release will be built."
  26. echo
  27. echo
  28. echo "Available models:"
  29. for AVAILABLE_MODEL in $AVAILABLE_MODELS; do
  30. echo "$(printf '\t')$AVAILABLE_MODEL"
  31. done
  32. }
  33. ## Iterate through command line parameters
  34. while :
  35. do
  36. case "$1" in
  37. --bleeding-edge)
  38. COREBOOT_COMMIT="master"
  39. shift 1;;
  40. --clean-slate)
  41. CLEAN_SLATE=true
  42. shift 1;;
  43. -c | --commit)
  44. COREBOOT_COMMIT="$2"
  45. shift 2;;
  46. -h | --help)
  47. usage >&2
  48. exit 0;;
  49. -i | --config)
  50. COREBOOT_CONFIG=true
  51. shift 1;;
  52. -t | --tag)
  53. COREBOOT_TAG="$2"
  54. shift 2;;
  55. -*)
  56. echo "Error: Unknown option: $1" >&2
  57. usage >&2
  58. exit 1;;
  59. *)
  60. break;;
  61. esac
  62. done
  63. ## Validate and normalize given model number
  64. MODEL=$(echo "$@" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]');
  65. ## Check if valid model
  66. if [ -z "$MODEL" ] || [ ! -d "$PWD/$MODEL" ]; then
  67. usage
  68. exit 1;
  69. fi;
  70. ################################################################################
  71. ################################################################################
  72. if [ ! -d "$PWD/$MODEL/build" ]; then
  73. mkdir "$PWD/$MODEL/build"
  74. elif [ "$CLEAN_SLATE" ]; then
  75. rm -rf "$PWD/$MODEL/build" || true
  76. mkdir "$PWD/$MODEL/build"
  77. fi
  78. ## Run Docker
  79. docker run --rm -it \
  80. --user "$(id -u):$(id -g)" \
  81. -v "$PWD/$MODEL/build:$DOCKER_COREBOOT_DIR" \
  82. -v "$PWD/$MODEL:$DOCKER_SCRIPT_DIR" \
  83. -v "$PWD/common:$DOCKER_COMMON_SCRIPT_DIR" \
  84. -v "$PWD/$MODEL/stock_bios:$DOCKER_STOCK_BIOS_DIR:ro" \
  85. -e COREBOOT_COMMIT="$COREBOOT_COMMIT" \
  86. -e COREBOOT_TAG="$COREBOOT_TAG" \
  87. -e COREBOOT_CONFIG="$COREBOOT_CONFIG" \
  88. coreboot/coreboot-sdk:"$COREBOOT_SDK_VERSION" \
  89. /home/coreboot/scripts/compile.sh