• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15# Description: Menuconfig entry
16#
17set -e
18set -o pipefail
19CROOT=$(pwd)
20source $CROOT/build_patch.sh
21BUILD_SELECT=$1
22
23cd $CROOT/third_party/u-boot-v2019.07
24build_uboot_patch
25cd $CROOT
26
27if [ "$BUILD_SELECT" = "menuconfig" ]; then
28	python3 $CROOT/tools/menuconfig/usr_config.py
29elif [ "$BUILD_SELECT" = "clean" ]; then
30	scons -c
31elif [ "$BUILD_SELECT" = "all_clean" ]; then
32	scons -c
33	rm -rf third_party/u-boot-v2019.07/u-boot-v2019.07
34	rm -rf .sconsign.dblite
35	rm -rf build/config/usr_config.mk.old
36elif [ "$BUILD_SELECT" = "all" ]; then
37	if [ $(grep -cw "CONFIG_FACTORY_TEST_SUPPORT=y" $CROOT/build/config/usr_config.mk) != 0 ]; then
38		echo Start build factory bin.
39		rm -rf build/libs/factory_bin
40		scons -c
41		if [ ! -d $CROOT/build/build_tmp/logs/ ]; then
42			mkdir -p $CROOT/build/build_tmp/logs
43		fi
44		scons -Q factory_mode='yes' 2>&1 | tee $CROOT/build/build_tmp/logs/build_kernel.log
45		if [ -f build/libs/factory_bin/*_factory.bin ];  then
46			scons -c
47			if [ ! -d $CROOT/build/build_tmp/logs/ ]; then
48				mkdir -p $CROOT/build/build_tmp/logs
49			fi
50			scons -Q 2>&1 | tee $CROOT/build/build_tmp/logs/build_kernel.log
51			echo See build log from: $CROOT/build/build_tmp/logs/build_kernel.log
52		fi
53	else
54		rm -rf build/libs/factory_bin
55		if [ ! -d $CROOT/build/build_tmp/logs/ ]; then
56			mkdir -p $CROOT/build/build_tmp/logs
57		fi
58		scons -Q 2>&1 | tee $CROOT/build/build_tmp/logs/build_kernel.log
59		echo See build log from: $CROOT/build/build_tmp/logs/build_kernel.log
60	fi
61elif [ -z $BUILD_SELECT ]; then
62	if [ -d "output/bin" ]; then
63		rm -rf output/bin
64	fi
65	if [ $(grep -cw "CONFIG_FACTORY_TEST_SUPPORT=y" $CROOT/build/config/usr_config.mk) != 0 ]; then
66		echo Start build factory bin.
67		rm -rf build/libs/factory_bin
68		scons -c
69		if [ ! -d $CROOT/build/build_tmp/logs/ ]; then
70			mkdir -p $CROOT/build/build_tmp/logs
71		fi
72		scons -Q factory_mode='yes' 2>&1 | tee $CROOT/build/build_tmp/logs/build_kernel.log
73		if [ -f build/libs/factory_bin/*_factory.bin ];  then
74			scons -c
75			if [ ! -d $CROOT/build/build_tmp/logs/ ]; then
76				mkdir -p $CROOT/build/build_tmp/logs
77			fi
78			scons -Q 2>&1 | tee $CROOT/build/build_tmp/logs/build_kernel.log
79			echo See build log from: $CROOT/build/build_tmp/logs/build_kernel.log
80		fi
81	else
82		rm -rf build/libs/factory_bin
83		if [ ! -d $CROOT/build/build_tmp/logs/ ]; then
84			mkdir -p $CROOT/build/build_tmp/logs
85		fi
86		scons -Q 2>&1 | tee $CROOT/build/build_tmp/logs/build_kernel.log
87		echo See build log from: $CROOT/build/build_tmp/logs/build_kernel.log
88	fi
89else
90	if [ $(grep -cw "CONFIG_FACTORY_TEST_SUPPORT=y" $CROOT/build/config/usr_config.mk) != 0 ]; then
91		echo Start build factory bin.
92		rm -rf build/libs/factory_bin
93		scons -c
94		if [ ! -d $CROOT/build/build_tmp/logs/ ]; then
95			mkdir -p $CROOT/build/build_tmp/logs
96		fi
97		scons -Q app=$BUILD_SELECT factory_mode='yes' 2>&1 | tee $CROOT/build/build_tmp/logs/build_kernel.log
98		if [ -f build/libs/factory_bin/*_factory.bin ];  then
99			scons -c
100			if [ ! -d $CROOT/build/build_tmp/logs/ ]; then
101				mkdir -p $CROOT/build/build_tmp/logs
102			fi
103			scons -Q app=$BUILD_SELECT 2>&1 | tee $CROOT/build/build_tmp/logs/build_kernel.log
104			echo See build log from: $CROOT/build/build_tmp/logs/build_kernel.log
105		fi
106	else
107		rm -rf build/libs/factory_bin
108		if [ ! -d $CROOT/build/build_tmp/logs/ ]; then
109			mkdir -p $CROOT/build/build_tmp/logs
110		fi
111		scons -Q app=$BUILD_SELECT 2>&1 | tee $CROOT/build/build_tmp/logs/build_kernel.log
112		echo See build log from: $CROOT/build/build_tmp/logs/build_kernel.log
113	fi
114fi
115