make.sh: support "./make.sh" build without [board] option

this default use exist .config to build project. because users
maybe don't like their .config to be override after "make menuconfig"
change.

Only one SoC in the .config is allowed, otherwise still use
"./make.sh [board]".

Change-Id: Ib65a4b6d6f84b822f6bdaf84b9784521fbf200e9
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2018-06-13 19:28:58 +08:00 committed by Jianhong Chen
parent f91f3b3427
commit 30b04afc78
1 changed files with 51 additions and 15 deletions

66
make.sh
View File

@ -5,7 +5,7 @@ SUBCMD=$2
RKCHIP=${BOARD##*-} RKCHIP=${BOARD##*-}
RKCHIP=$(echo ${RKCHIP} | tr '[a-z]' '[A-Z]') RKCHIP=$(echo ${RKCHIP} | tr '[a-z]' '[A-Z]')
JOB=`sed -n "N;/processor/p" /proc/cpuinfo|wc -l` JOB=`sed -n "N;/processor/p" /proc/cpuinfo|wc -l`
SUPPROT_LIST=`ls configs/*-[r,p][x,v,k][0-9][0-9]*_defconfig` SUPPORT_LIST=`ls configs/*-[r,p][x,v,k][0-9][0-9]*_defconfig`
########################################### User can modify ############################################# ########################################### User can modify #############################################
# User's rkbin tool relative path # User's rkbin tool relative path
@ -42,26 +42,53 @@ PLATFORM_AARCH32=
prepare() prepare()
{ {
local absolute_path cmd local absolute_path cmd count
# Assign output directory
cmd=${SUBCMD%=*}
if [ "${cmd}" = 'O' ]; then
OUTDIR=${SUBCMD#*=}
OUTOPT=O=${OUTDIR}
else
OUTDIR=.
fi
# Check invalid args and help # Check invalid args and help
if [ "$BOARD" = '--help' -o "$BOARD" = '-h' -o "$BOARD" = '--h' -o "$BOARD" = '' ]; then if [ "$BOARD" = '--help' -o "$BOARD" = '-help' -o "$BOARD" = 'help' -o "$BOARD" = '-h' -o "$BOARD" = '--h' ]; then
echo echo
echo "Usage: ./make.sh [board]" echo "Usage: ./make.sh [board]"
echo "Example:" echo "Example:"
echo "./make.sh ---- build with exist .config"
echo "./make.sh evb-rk3399 ---- build for evb-rk3399_defconfig" echo "./make.sh evb-rk3399 ---- build for evb-rk3399_defconfig"
echo "./make.sh firefly-rk3288 ---- build for firefly-rk3288_defconfig" echo "./make.sh firefly-rk3288 ---- build for firefly-rk3288_defconfig"
exit 1 exit 1
elif [ ! -f configs/${BOARD}_defconfig ]; then elif [ $BOARD ] && [ ! -f configs/${BOARD}_defconfig ]; then
echo
echo "Can't find: configs/${BOARD}_defconfig" echo "Can't find: configs/${BOARD}_defconfig"
echo echo
echo "*************** Support list ***************" echo "******** Rockchip Support List *************"
echo "${SUPPROT_LIST}" echo "${SUPPORT_LIST}"
echo "********************************************" echo "********************************************"
echo echo
exit 1 exit 1
fi fi
# Get RKCHIP from exist .config file
if [ "$RKCHIP" = '' ]; then
count=`grep -c '^CONFIG_ROCKCHIP_[R,P][X,V,K][0-9][0-9]' ${OUTDIR}/.config`
RKCHIP=`grep '^CONFIG_ROCKCHIP_[R,P][X,V,K][0-9][0-9]' ${OUTDIR}/.config`
if [ $count -gt 1 ]; then
echo "Find $count SoC in .config file:"
echo "$RKCHIP"
echo
echo "I'm confused, please compile with [board], like: ./make.sh [board]"
exit 1
else
RKCHIP=${RKCHIP%=*}
RKCHIP=${RKCHIP##*_}
fi
fi
# Initialize RKBIN and RKTOOLS # Initialize RKBIN and RKTOOLS
if [ -d ${RKBIN_TOOLS} ]; then if [ -d ${RKBIN_TOOLS} ]; then
absolute_path=$(cd `dirname ${RKBIN_TOOLS}`; pwd) absolute_path=$(cd `dirname ${RKBIN_TOOLS}`; pwd)
@ -76,14 +103,13 @@ prepare()
echo " 3. Download full release SDK repository" echo " 3. Download full release SDK repository"
exit 1 exit 1
fi fi
}
# Assign output directory make_defconfig()
cmd=${SUBCMD%=*} {
if [ "${cmd}" = 'O' ]; then if [ $BOARD ]; then
OUTDIR=${SUBCMD#*=} echo "make for ${BOARD}_defconfig by -j${JOB}"
OUTOPT=O=${OUTDIR} make ${BOARD}_defconfig ${OUTOPT}
else
OUTDIR=.
fi fi
} }
@ -279,9 +305,18 @@ pack_trust_image()
fi fi
} }
finish()
{
echo
if [ "$BOARD" = '' ]; then
echo "Platform ${RKCHIP}${PLATFORM_AARCH32} is build OK, with exist .config"
else
echo "Platform ${RKCHIP}${PLATFORM_AARCH32} is build OK, with new .config(make ${BOARD}_defconfig)"
fi
}
prepare prepare
echo "make for ${BOARD}_defconfig by -j${JOB}" make_defconfig
make ${BOARD}_defconfig ${OUTOPT}
select_toolchain select_toolchain
fixup_platform_configure fixup_platform_configure
sub_commands sub_commands
@ -289,3 +324,4 @@ make CROSS_COMPILE=${TOOLCHAIN_GCC} all --jobs=${JOB} ${OUTOPT}
pack_uboot_image pack_uboot_image
pack_loader_image pack_loader_image
pack_trust_image pack_trust_image
finish