blob: 839d30a54be9920ed66a90ab74b53bebf6b1757c [file] [log] [blame]
Stewart Smith098d03e2016-03-01 13:59:42 +11001#!/bin/bash
2
3set -ex
4set -eo pipefail
5
Samuel Mendoza-Jonas8d102aa2018-08-10 13:47:48 +10006BUILD_INFO=0
Pridhiviraj Paidipeddi24d94a22016-08-15 16:51:31 +05307CONFIGTAG="_defconfig"
8
9DEFCONFIGS=();
10
Samuel Mendoza-Jonas8d102aa2018-08-10 13:47:48 +100011while 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
34done
35
36if [ -z "${PLATFORM_LIST}" ]; then
Pridhiviraj Paidipeddi24d94a22016-08-15 16:51:31 +053037 echo "Using all the defconfigs for all the platforms"
38 DEFCONFIGS=`(cd openpower/configs; ls -1 *_defconfig)`
39else
40 IFS=', '
Samuel Mendoza-Jonas8d102aa2018-08-10 13:47:48 +100041 for p in ${PLATFORM_LIST};
Pridhiviraj Paidipeddi24d94a22016-08-15 16:51:31 +053042 do
43 DEFCONFIGS+=($p$CONFIGTAG)
44 done
45fi
Stewart Smith098d03e2016-03-01 13:59:42 +110046
Samuel Mendoza-Jonas8d102aa2018-08-10 13:47:48 +100047if [ -z "${OUTDIR}" or ! -d "${OUTDIR}" ]; then
Stewart Smith098d03e2016-03-01 13:59:42 +110048 echo "No output directory specified"
49 exit 1;
50fi
51
52if [ -z "$CCACHE_DIR" ]; then
53 CCACHE_DIR=`pwd`/.op-build_ccache
54fi
55
56shopt -s expand_aliases
57source op-build-env
58
Samuel Mendoza-Jonas94ec86a2018-08-06 15:18:26 +100059if [ -n "$DL_DIR" ]; then
60 unset BR2_DL_DIR
61 export BR2_DL_DIR=${DL_DIR}
62fi
63
Pridhiviraj Paidipeddi24d94a22016-08-15 16:51:31 +053064for i in ${DEFCONFIGS[@]}; do
Samuel Mendoza-Jonas7f4c37d2018-08-07 14:51:51 +100065 rm -rf output/*
Stewart Smith098d03e2016-03-01 13:59:42 +110066 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-Jonas8d102aa2018-08-10 13:47:48 +100074
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 Smith098d03e2016-03-01 13:59:42 +110084 if [ $r -ne 0 ]; then
85 exit $r
86 fi
87done
88