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 | |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 11 | while getopts "o:p:r" opt; do |
| 12 | case $opt in |
| 13 | o) |
| 14 | echo "Output directory: $OPTARG" |
| 15 | OUTDIR="$OPTARG" |
| 16 | ;; |
| 17 | p) |
| 18 | echo "Platforms to build: $OPTARG" |
| 19 | PLATFORM_LIST="$OPTARG" |
| 20 | ;; |
| 21 | r) |
| 22 | echo "Build legal-info for release" |
| 23 | BUILD_INFO=1 |
| 24 | ;; |
| 25 | \?) |
| 26 | echo "Invalid option: -$OPTARG" |
| 27 | exit 1 |
| 28 | ;; |
| 29 | :) |
| 30 | echo "Option -$OPTARG requires an argument." |
| 31 | exit 1 |
| 32 | ;; |
| 33 | esac |
| 34 | done |
| 35 | |
| 36 | if [ -z "${PLATFORM_LIST}" ]; then |
Pridhiviraj Paidipeddi | 24d94a2 | 2016-08-15 16:51:31 +0530 | [diff] [blame] | 37 | echo "Using all the defconfigs for all the platforms" |
| 38 | DEFCONFIGS=`(cd openpower/configs; ls -1 *_defconfig)` |
| 39 | else |
| 40 | IFS=', ' |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 41 | for p in ${PLATFORM_LIST}; |
Pridhiviraj Paidipeddi | 24d94a2 | 2016-08-15 16:51:31 +0530 | [diff] [blame] | 42 | do |
| 43 | DEFCONFIGS+=($p$CONFIGTAG) |
| 44 | done |
| 45 | fi |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 46 | |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 47 | if [ -z "${OUTDIR}" or ! -d "${OUTDIR}" ]; then |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 48 | echo "No output directory specified" |
| 49 | exit 1; |
| 50 | fi |
| 51 | |
| 52 | if [ -z "$CCACHE_DIR" ]; then |
| 53 | CCACHE_DIR=`pwd`/.op-build_ccache |
| 54 | fi |
| 55 | |
| 56 | shopt -s expand_aliases |
| 57 | source op-build-env |
| 58 | |
Samuel Mendoza-Jonas | 94ec86a | 2018-08-06 15:18:26 +1000 | [diff] [blame] | 59 | if [ -n "$DL_DIR" ]; then |
| 60 | unset BR2_DL_DIR |
| 61 | export BR2_DL_DIR=${DL_DIR} |
| 62 | fi |
| 63 | |
Pridhiviraj Paidipeddi | 24d94a2 | 2016-08-15 16:51:31 +0530 | [diff] [blame] | 64 | for i in ${DEFCONFIGS[@]}; do |
Samuel Mendoza-Jonas | 7f4c37d | 2018-08-07 14:51:51 +1000 | [diff] [blame] | 65 | rm -rf output/* |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 66 | op-build $i |
| 67 | echo 'BR2_CCACHE=y' >> output/.config |
| 68 | echo "BR2_CCACHE_DIR=\"$CCACHE_DIR\"" >> output/.config |
| 69 | echo 'BR2_CCACHE_INITIAL_SETUP=""' >> output/.config |
| 70 | |
| 71 | op-build olddefconfig |
| 72 | op-build |
| 73 | r=$? |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 74 | |
| 75 | if [ ${BUILD_INFO} = 1 ] && [ $r = 0 ]; then |
| 76 | op-build legal-info |
| 77 | mv output/legal-info ${OUTDIR}/$i-legal-info |
| 78 | fi |
| 79 | |
| 80 | mkdir ${OUTDIR}/$i-images |
| 81 | mv output/images/* ${OUTDIR}/$i-images/ |
| 82 | mv output/.config ${OUTDIR}/$i-images/.config |
| 83 | lsb_release -a > ${OUTDIR}/$i-images/lsb_release |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 84 | if [ $r -ne 0 ]; then |
| 85 | exit $r |
| 86 | fi |
| 87 | done |
| 88 | |