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