Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -ex |
| 4 | set -eo pipefail |
| 5 | |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 6 | BUILD_INFO=0 |
Pridhiviraj Paidipeddi | 24d94a2 | 2016-08-15 16:51:31 +0530 | [diff] [blame] | 7 | CONFIGTAG="_defconfig" |
| 8 | |
| 9 | DEFCONFIGS=(); |
| 10 | |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame^] | 11 | SDK_DIR="" |
| 12 | |
| 13 | while getopts "o:p:rs:" opt; do |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 14 | case $opt in |
| 15 | o) |
| 16 | echo "Output directory: $OPTARG" |
| 17 | OUTDIR="$OPTARG" |
| 18 | ;; |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame^] | 19 | s) |
| 20 | echo "SDK is in: $OPTARG" |
| 21 | SDK_DIR=$OPTARG |
| 22 | ;; |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 23 | p) |
| 24 | echo "Platforms to build: $OPTARG" |
| 25 | PLATFORM_LIST="$OPTARG" |
| 26 | ;; |
| 27 | r) |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame^] | 28 | echo "Build legal-info etc for release" |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 29 | BUILD_INFO=1 |
| 30 | ;; |
| 31 | \?) |
| 32 | echo "Invalid option: -$OPTARG" |
| 33 | exit 1 |
| 34 | ;; |
| 35 | :) |
| 36 | echo "Option -$OPTARG requires an argument." |
| 37 | exit 1 |
| 38 | ;; |
| 39 | esac |
| 40 | done |
| 41 | |
| 42 | if [ -z "${PLATFORM_LIST}" ]; then |
Pridhiviraj Paidipeddi | 24d94a2 | 2016-08-15 16:51:31 +0530 | [diff] [blame] | 43 | echo "Using all the defconfigs for all the platforms" |
| 44 | DEFCONFIGS=`(cd openpower/configs; ls -1 *_defconfig)` |
| 45 | else |
| 46 | IFS=', ' |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 47 | for p in ${PLATFORM_LIST}; |
Pridhiviraj Paidipeddi | 24d94a2 | 2016-08-15 16:51:31 +0530 | [diff] [blame] | 48 | do |
| 49 | DEFCONFIGS+=($p$CONFIGTAG) |
| 50 | done |
| 51 | fi |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 52 | |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 53 | if [ -z "${OUTDIR}" or ! -d "${OUTDIR}" ]; then |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 54 | echo "No output directory specified" |
| 55 | exit 1; |
| 56 | fi |
| 57 | |
| 58 | if [ -z "$CCACHE_DIR" ]; then |
| 59 | CCACHE_DIR=`pwd`/.op-build_ccache |
| 60 | fi |
| 61 | |
| 62 | shopt -s expand_aliases |
| 63 | source op-build-env |
| 64 | |
Samuel Mendoza-Jonas | 94ec86a | 2018-08-06 15:18:26 +1000 | [diff] [blame] | 65 | if [ -n "$DL_DIR" ]; then |
| 66 | unset BR2_DL_DIR |
| 67 | export BR2_DL_DIR=${DL_DIR} |
| 68 | fi |
| 69 | |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame^] | 70 | if [ -f $(ldconfig -p | grep libeatmydata.so | tr ' ' '\n' | grep /|head -n1) ]; then |
| 71 | export LD_PRELOAD=${LD_PRELOAD:+"$LD_PRELOAD "}libeatmydata.so |
| 72 | fi |
| 73 | |
Pridhiviraj Paidipeddi | 24d94a2 | 2016-08-15 16:51:31 +0530 | [diff] [blame] | 74 | for i in ${DEFCONFIGS[@]}; do |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame^] | 75 | export O=${OUTDIR}-$i |
| 76 | rm -rf $O |
| 77 | op-build O=$O $i |
| 78 | ./buildroot/utils/config --file $O/.config --set-val BR2_CCACHE y |
| 79 | ./buildroot/utils/config --file $O/.config --set-str BR2_CCACHE_DIR $CCACHE_DIR |
| 80 | if [ -d "$SDK_DIR" ]; then |
| 81 | ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL y |
| 82 | ./buildroot/utils/config --file $O/.config --set-str BR2_TOOLCHAIN_EXTERNAL_PATH $SDK_DIR |
| 83 | ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC y |
| 84 | ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_CXX y |
| 85 | # FIXME: How do we work this out programatically? |
| 86 | ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_GCC_6 y |
| 87 | ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_18 y |
| 88 | fi |
| 89 | op-build O=$O olddefconfig |
| 90 | op-build O=$O |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 91 | r=$? |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame^] | 92 | if [ ${BUILD_INFO} = 1 ] && [ $r = 0 ]; then |
| 93 | op-build O=$O legal-info |
| 94 | op-build O=$O graph-build |
| 95 | op-build O=$O graph-size |
| 96 | op-build O=$O graph-depends |
| 97 | fi |
| 98 | lsb_release -a > $O/lsb_release |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 99 | if [ $r -ne 0 ]; then |
| 100 | exit $r |
| 101 | fi |
| 102 | done |
| 103 | |