Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine imxlinux_example.sh build script #38017

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 45 additions & 12 deletions scripts/examples/imxlinux_example.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

#!/bin/bash
#
# Copyright (c) 2022 Project CHIP Authors
# Copyright 2023, 2025 NXP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,11 +18,48 @@

set -e
set -x
if [ "$#" != 2 && "$#" != 3 ]; then
exit -1
helpFunction()
{
cat << EOF
Usage: $0 -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)
EOF
exit 1
}

trusty=0
release_build=true
PARSED_OPTIONS="$(getopt -o s:o:tdn --long src:,out:,trusty,debug,no-init -- "$@")"
if [ $? -ne 0 ];
then
helpFunction
fi
eval set -- "$PARSED_OPTIONS"
while true; do
case "$1" in
-s|--src) src="$2"; shift 2 ;;
-o|--out) out="$2"; shift 2 ;;
-t|--trusty) trusty=1; shift ;;
-d|--debug) release_build=false; shift ;;
-n|--no-init) no_init=1; shift ;;
--) shift; break ;;
*) echo "Invalid option: $1" >&2; exit 1 ;;
esac
done

if [ -z "$src" ] || [ -z "$out" ]; then
echo "Some or all of the required -s|--src and -o|--out parameters are empty.";
helpFunction
fi

source "$(dirname "$0")/../../scripts/activate.sh"

if [ "$no_init" != 1 ]; then
source "$(dirname "$0")/../../scripts/activate.sh"
fi

if [ "$IMX_SDK_ROOT" = "" -o ! -d "$IMX_SDK_ROOT" ]; then
echo "the Yocto SDK path is not specified with the shell env IMX_SDK_ROOT or an invalid path is specified"
Expand Down Expand Up @@ -100,13 +137,9 @@ if [ -z "$target_cpu" -o -z "$cross_compile" ]; then
exit 1
fi

release_build=true
if [ "$3" = "debug" ]; then
release_build=false
fi

PLATFORM_CFLAGS='-DCHIP_DEVICE_CONFIG_WIFI_STATION_IF_NAME=\"mlan0\"", "-DCHIP_DEVICE_CONFIG_LINUX_DHCPC_CMD=\"udhcpc -b -i %s \"'
gn gen --check --fail-on-unused-args --root="$1" "$2" --args="target_os=\"linux\" target_cpu=\"$target_cpu\" arm_arch=\"$arm_arch\"
gn gen --check --fail-on-unused-args --root="$src" "$out" --args="target_os=\"linux\" target_cpu=\"$target_cpu\" arm_arch=\"$arm_arch\"
chip_with_trusty_os=$trusty
treat_warnings_as_errors=false
import(\"//build_overrides/build.gni\")
sysroot=\"$sdk_target_sysroot\"
Expand All @@ -117,4 +150,4 @@ target_cxx=\"$IMX_SDK_ROOT/sysroots/x86_64-pokysdk-linux/usr/bin/$cross_compile/
target_ar=\"$IMX_SDK_ROOT/sysroots/x86_64-pokysdk-linux/usr/bin/$cross_compile/$cross_compile-ar\"
$(if [ "$release_build" = "true" ]; then echo "is_debug=false"; else echo "optimize_debug=true"; fi)"

ninja -C "$2"
ninja -C "$out"
Loading