Skip to content

Commit 4d21e1e

Browse files
TE-N-ElvenWang“nxf90552”
authored and
“nxf90552”
committed
Refine imxlinux_example.sh build script
Now the build script are refined to use parameter for different option: Usage: ./scripts/examples/imxlinux_example.sh -s|--src <src folder> -o|--out <out folder> [-d|--debug] [-n|--no-init] [-t|--trusty] -s, --src Source folder -o, --out Output folder -d, --debug Debug build (optional) -n, --no-init No init mode (optional) -t, --trusty Build with Trusty OS backed security enhancement (optional) example: ./scripts/examples/imxlinux_example.sh -s examples/chip-tool -o out -dnt #will build examples/chip-tool to out/ folder with debug build and skip init and use Trusty OS. Change-Id: I3ac3b60395255b3bfe45fdf21184ba0b6c7ba265 Signed-off-by: Haoran.Wang <elven.wang@nxp.com> Reviewed-on: http://androidsource.nxp.com/project/21564 Reviewed-by: Faqiang Zhu <faqiang.zhu@nxp.com> Reviewed-on: http://androidsource.nxp.com/project/23009
1 parent e158e77 commit 4d21e1e

File tree

1 file changed

+48
-14
lines changed

1 file changed

+48
-14
lines changed

scripts/examples/imxlinux_example.sh

+48-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env bash
2-
1+
#!/bin/bash
32
#
43
# Copyright (c) 2022 Project CHIP Authors
54
#
@@ -16,13 +15,52 @@
1615
# limitations under the License.
1716
#
1817

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
2355
fi
2456

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
2664

2765
if [ "$IMX_SDK_ROOT" = "" -o ! -d "$IMX_SDK_ROOT" ]; then
2866
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
100138
exit 1
101139
fi
102140

103-
release_build=true
104-
if [ "$3" = "debug" ]; then
105-
release_build=false
106-
fi
107-
108141
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
110144
treat_warnings_as_errors=false
111145
import(\"//build_overrides/build.gni\")
112146
sysroot=\"$sdk_target_sysroot\"
@@ -117,4 +151,4 @@ target_cxx=\"$IMX_SDK_ROOT/sysroots/x86_64-pokysdk-linux/usr/bin/$cross_compile/
117151
target_ar=\"$IMX_SDK_ROOT/sysroots/x86_64-pokysdk-linux/usr/bin/$cross_compile/$cross_compile-ar\"
118152
$(if [ "$release_build" = "true" ]; then echo "is_debug=false"; else echo "optimize_debug=true"; fi)"
119153

120-
ninja -C "$2"
154+
ninja -C "$out"

0 commit comments

Comments
 (0)