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.

104 lines
3.0 KiB

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