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. # 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 " -t, --tag <tag> Git tag/version"
  25. echo
  26. echo "If a tag, commit or bleeding-edge flag is not given, the latest Coreboot release will be built."
  27. echo
  28. echo
  29. echo "Available models:"
  30. for AVAILABLE_MODEL in $AVAILABLE_MODELS; do
  31. echo "$(printf '\t')$AVAILABLE_MODEL"
  32. done
  33. }
  34. ## Iterate through command line parameters
  35. while :
  36. do
  37. case "$1" in
  38. --bleeding-edge)
  39. COREBOOT_COMMIT="master"
  40. shift 1;;
  41. --clean-slate)
  42. CLEAN_SLATE=true
  43. shift 1;;
  44. -c | --commit)
  45. COREBOOT_COMMIT="$2"
  46. shift 2;;
  47. -h | --help)
  48. usage >&2
  49. exit 0;;
  50. -i | --config)
  51. COREBOOT_CONFIG=true
  52. shift 1;;
  53. -t | --tag)
  54. COREBOOT_TAG="$2"
  55. shift 2;;
  56. -*)
  57. echo "Error: Unknown option: $1" >&2
  58. usage >&2
  59. exit 1;;
  60. *)
  61. break;;
  62. esac
  63. done
  64. ## Validate and normalize given model number
  65. MODEL=$(echo "$@" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]');
  66. ## Check if valid model
  67. if [ -z "$MODEL" ] || [ ! -d "$PWD/$MODEL" ]; then
  68. usage
  69. exit 1;
  70. fi;
  71. ################################################################################
  72. ################################################################################
  73. if [ ! -d "$PWD/$MODEL/build" ]; then
  74. mkdir "$PWD/$MODEL/build"
  75. elif [ "$CLEAN_SLATE" ]; then
  76. rm -rf "$PWD/$MODEL/build" || true
  77. mkdir "$PWD/$MODEL/build"
  78. fi
  79. ## Run Docker
  80. docker run --rm -it \
  81. --user "$(id -u):$(id -g)" \
  82. -v "$PWD/$MODEL/build:$DOCKER_COREBOOT_DIR" \
  83. -v "$PWD/$MODEL:$DOCKER_SCRIPT_DIR" \
  84. -v "$PWD/common:$DOCKER_COMMON_SCRIPT_DIR" \
  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