1+ #
2+ # Copyright (C) 2025 Texas Instruments Incorporated.
3+ #
4+ # Redistribution and use in source and binary forms, with or without
5+ # modification, are permitted provided that the following conditions
6+ # are met:
7+ #
8+ # Redistributions of source code must retain the above copyright
9+ # notice, this list of conditions and the following disclaimer.
10+ #
11+ # Redistributions in binary form must reproduce the above copyright
12+ # notice, this list of conditions and the following disclaimer in the
13+ # documentation and/or other materials provided with the
14+ # distribution.
15+ #
16+ # Neither the name of Texas Instruments Incorporated nor the names of
17+ # its contributors may be used to endorse or promote products derived
18+ # from this software without specific prior written permission.
19+ #
20+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+ #
32+
33+
34+ # ########################################################################
35+ # Params #
36+ # ########################################################################
37+ # Get user input
38+ while [ $# -gt 0 ]; do
39+ case " $1 " in
40+ --device=* )
41+ device=" ${1#* =} "
42+ ;;
43+ --profile_list=* )
44+ profile_list=" ${1#* =} "
45+ ;;
46+ --enable_test_build=* )
47+ enable_test_build=" ${1#* =} "
48+ ;;
49+ -h|--help)
50+ echo Usage: $0 [options]
51+ echo
52+ echo Options:
53+ echo --device Device to be built
54+ echo --profile_list Profile list separated by comma to be built. Default to release,debug
55+ echo --enable_test_build Enable test build
56+ exit 0
57+ ;;
58+ * )
59+ printf " Error: Invalid argument $1 !!\n"
60+ esac
61+ shift
62+ done
63+
64+ # Default value if not provided
65+ : ${device:= " am64x" }
66+ : ${enable_test_build:= " true" }
67+ : ${profile_list:= " debug,release" }
68+
69+ # Convert , to space
70+ profile_list=` echo ${profile_list} | sed -e " s|\,| |g" `
71+
72+ # ########################################################################
73+ # Log files #
74+ # ########################################################################
75+ log_dir=$GITHUB_WORKSPACE /logs
76+ build_dir=$GITHUB_WORKSPACE /mcu_plus_sdk
77+ pr_checkout_dir=$GITHUB_WORKSPACE /pr_checkout
78+ build_log=${log_dir} /build.log
79+ build_error_log=${log_dir} /build_error.log
80+
81+
82+ # ########################################################################
83+ # Functions #
84+ # ########################################################################
85+ print_time_diff () {
86+ local end_time=$( date +%s)
87+ local start_time=$1
88+ local deltatime=$(( end_time- start_time ))
89+ local hours=$(( deltatime/ 3600 ))
90+ local minutes=$(( deltatime/ 60 ))
91+ local minutes=$(( minutes% 60 ))
92+ local seconds=$(( deltatime% 60 ))
93+ printf " $2 : %d:%02d:%02d\n" $hours $minutes $seconds
94+ printf " \n"
95+ }
96+
97+ make_folders () {
98+ echo " Making required folder..."
99+ mkdir -p ${log_dir}
100+ echo " Making required folder ... Done"
101+ echo " "
102+ }
103+
104+ proc=` nproc`
105+ repo_init () {
106+ mkdir workarea
107+ cd workaread
108+ echo " Doing repo init and sync ..."
109+ local start_time=` date +%s`
110+ sudo apt-get update
111+ sudo apt-get -y install repo
112+
113+ repo init -u https://github.com/TexasInstruments/mcupsdk-manifests.git -m ${device} /dev.xml -b main --depth=1
114+ repo sync -j${proc} -q
115+
116+ # Show the current branch/git status
117+ repo forall -c " pwd;git branch -vv | cut -d ' ' -f 1-4"
118+
119+ print_time_diff $start_time " Repo Init Time"
120+ echo " Doing repo init and sync ... Done"
121+ echo " "
122+
123+ # Checkout the PR
124+ pushd ${build_dir} 1> /dev/null
125+
126+ git fetch origin pull/${PR_NUMBER} /head:pr_${PR_NUMBER} -q
127+ git switch pr_${PR_NUMBER}
128+ git log --oneline -n5
129+ popd 1> /dev/null
130+
131+ }
132+
133+ download_components () {
134+ echo " Downloading Components ..."
135+
136+ local start_time=` date +%s`
137+
138+ mkdir ${HOME} /ti
139+
140+ find ./mcupsdk_setup -name " *.sh" -execdir chmod u+x {} +
141+ ./mcupsdk_setup/${device} /download_components.sh --skip_ccs=true
142+ pip3 install pyserial xmodem tqdm pyelftools construct
143+
144+ print_time_diff $start_time " Download Components Time"
145+ echo " Downloading Components ... Done"
146+ echo " "
147+ }
148+
149+ check_logs () {
150+ if [ -e ${build_error_log} ]; then
151+ if [ -s ${build_error_log} ]; then
152+ echo " Build for SOC $device failed ...."
153+ echo
154+ echo
155+ cat ${build_error_log}
156+ exit 1
157+ fi
158+ fi
159+ }
160+
161+ build_sdk () {
162+ echo " Build SDK ..."
163+ local start_time=` date +%s`
164+
165+ pushd ${build_dir} 1> /dev/null
166+
167+ # Scrub build files
168+
169+ echo " Scrub Build Files for DEVICE:${device} ..."
170+ make -s ${jobs_option} scrub DEVICE=${device} 1>> ${build_log} 2>> ${build_error_log}
171+ make -s gen-buildfiles-clean DEVICE=${device} 1>> ${build_log} 2>> ${build_error_log}
172+ echo " Scrub Build Files for DEVICE:${device} completed!!"
173+ check_logs
174+
175+ echo " Generate Build Files for DEVICE:${device} ..."
176+ make -s gen-buildfiles DEVICE=${device} 1>> ${build_log} 2>> ${build_error_log}
177+ echo " Generate Build Files for DEVICE:${device} completed!!"
178+ check_logs
179+
180+ for profile in ${profile_list}
181+ do
182+ echo " Building for DEVICE:${device} PROFILE:${profile} ..."
183+ make -s -j${proc} all DEVICE=${device} PROFILE=${profile} 1>> ${build_log} 2>> ${build_error_log}
184+ echo " Building for DEVICE:${device} PROFILE:${profile} completed!!"
185+ check_logs
186+ done
187+
188+ if [ " ${enable_test_build} " == " true" ]; then
189+ for profile in ${profile_list}
190+ do
191+ echo " Building Tests for DEVICE:${device} PROFILE:${profile} ..."
192+ make -s -j${proc} tests DEVICE=${device} PROFILE=${profile} 1>> ${build_log} 2>> ${build_error_log}
193+ echo " Building Tests for DEVICE:${device} PROFILE:${profile} completed!!"
194+ check_logs
195+ done
196+ fi
197+
198+ echo " Generate docs for DEVICE:${device} ..."
199+ make -s docs DEVICE=${device} 1>> ${build_log} 2>> ${build_error_log}
200+ echo " Generate docs for DEVICE:${device} completed!!"
201+ # Redirect doxy error
202+ cat docs_src/docs/api_guide/doxy_warnings_${device} .txt >> ${build_error_log}
203+ check_logs
204+
205+ popd 1> /dev/null
206+
207+ print_time_diff $start_time " Build Time"
208+ echo " Build SDK ... Done"
209+ }
210+
211+ # ########################################################################
212+ # Script run #
213+ # ########################################################################
214+ make_folders
215+ repo_init
216+ download_components
217+ build_sdk
0 commit comments