1
- #! /usr/bin/env bash
2
-
1
+ #! /bin/bash
3
2
#
4
3
# Copyright (c) 2022 Project CHIP Authors
5
4
#
16
15
# limitations under the License.
17
16
#
18
17
19
- set -e
20
- set -x
21
- if [ " $# " != 2 && " $# " != 3 ]; then
22
- exit -1
18
+ helpFunction ()
19
+ {
20
+ cat << EOF
21
+ Usage: $0 -s|--src <src folder> -o|--out <out folder> [-d|--debug] [-n|--no-init] [-t|--trusty]
22
+ -s, --src Source folder
23
+ -o, --out Output folder
24
+ -d, --debug Debug build (optional)
25
+ -n, --no-init No init mode (optional)
26
+ -t, --trusty Build with Trusty OS backed security enhancement (optional)
27
+ EOF
28
+ exit 1
29
+ }
30
+
31
+ trusty=0
32
+ release_build=true
33
+ PARSED_OPTIONS=" $( getopt -o s:o:tdn --long src:,out:,trusty,debug,no-init -- " $@ " ) "
34
+ if [ $? -ne 0 ];
35
+ then
36
+ helpFunction
37
+ fi
38
+ eval set -- " $PARSED_OPTIONS "
39
+ while true ; do
40
+ case " $1 " in
41
+ -s|--src) src=" $2 " ; shift 2 ;;
42
+ -o|--out) out=" $2 " ; shift 2 ;;
43
+ -t|--trusty) trusty=1; shift ;;
44
+ -d|--debug) release_build=false; shift ;;
45
+ -n|--no-init) no_init=1; shift ;;
46
+ --) shift ; break ;;
47
+ * ) echo " Invalid option: $1 " >&2 ; exit 1 ;;
48
+ esac
49
+ done
50
+
51
+ if [ -z " $src " ] || [ -z " $out " ];
52
+ then
53
+ echo " Some or all of the required -s|--src and -o|--out parameters are empty." ;
54
+ helpFunction
23
55
fi
24
56
25
- source " $( dirname " $0 " ) /../../scripts/activate.sh"
57
+
58
+ if [ " $no_init " != 1 ]; then
59
+ source " $( dirname " $0 " ) /../../scripts/activate.sh"
60
+ fi
61
+
62
+ set -e
63
+ set -x
26
64
27
65
if [ " $IMX_SDK_ROOT " = " " -o ! -d " $IMX_SDK_ROOT " ]; then
28
66
echo " the Yocto SDK path is not specified with the shell env IMX_SDK_ROOT or an invalid path is specified"
@@ -100,13 +138,9 @@ if [ -z "$target_cpu" -o -z "$cross_compile" ]; then
100
138
exit 1
101
139
fi
102
140
103
- release_build=true
104
- if [ " $3 " = " debug" ]; then
105
- release_build=false
106
- fi
107
-
108
141
PLATFORM_CFLAGS=' -DCHIP_DEVICE_CONFIG_WIFI_STATION_IF_NAME=\"mlan0\"", "-DCHIP_DEVICE_CONFIG_LINUX_DHCPC_CMD=\"udhcpc -b -i %s \"'
109
- gn gen --check --fail-on-unused-args --root=" $1 " " $2 " --args=" target_os=\" linux\" target_cpu=\" $target_cpu \" arm_arch=\" $arm_arch \"
142
+ gn gen $executable_python --check --fail-on-unused-args --root=" $src " " $out " --args=" target_os=\" linux\" target_cpu=\" $target_cpu \" arm_arch=\" $arm_arch \"
143
+ chip_with_trusty_os=$trusty
110
144
treat_warnings_as_errors=false
111
145
import(\" //build_overrides/build.gni\" )
112
146
sysroot=\" $sdk_target_sysroot \"
@@ -117,4 +151,4 @@ target_cxx=\"$IMX_SDK_ROOT/sysroots/x86_64-pokysdk-linux/usr/bin/$cross_compile/
117
151
target_ar=\" $IMX_SDK_ROOT /sysroots/x86_64-pokysdk-linux/usr/bin/$cross_compile /$cross_compile -ar\"
118
152
$( if [ " $release_build " = " true" ]; then echo " is_debug=false" ; else echo " optimize_debug=true" ; fi) "
119
153
120
- ninja -C " $2 "
154
+ ninja -C " $out "
0 commit comments