Skip to content

Commit 40502b6

Browse files
committed
build: refine script for developers/experts's effort on cDSP side
1 parent f5a892a commit 40502b6

File tree

4 files changed

+54
-19
lines changed

4 files changed

+54
-19
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,6 @@ poetry.toml
150150
HEXAGON_Tools/
151151
prebuilts/QNN_SDK/qairt/2.35.0.250530/
152152
prebuilts/QNN_SDK/v2.35.0.250530.zip
153+
prebuilts/Hexagon_SDK/minimal-hexagon-sdk-6.2.0.1.xz
154+
155+

prebuilts/Hexagon_SDK/.lock

Whitespace-only changes.

prebuilts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ we should strictly follow Qualcomm's IPR policy, even in open-source community.
55

66
### the [KanTV](https://github.com/kantv-ai) way
77

8-
- Simple is the beautiful
8+
- Simple is beautiful
99

1010
we believe the philosophy of "<b>simple is beautiful</b>" which <b>comes from the great Unix</b>.
1111

scripts/build-run-android.sh

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,56 @@ function show_pwd()
112112
}
113113

114114

115-
function check_hexagon_sdk()
115+
function check_command_in_host()
116+
{
117+
set +e
118+
cmd=$1
119+
ls /usr/bin/${cmd}
120+
if [ $? -eq 0 ]; then
121+
#printf "${cmd} already exist on host machine\n"
122+
echo ""
123+
else
124+
printf "${cmd} not exist on host machine, pls install command line utility ${cmd} firstly and accordingly\n"
125+
exit 1
126+
fi
127+
set -e
128+
}
129+
130+
131+
function check_commands_in_host()
132+
{
133+
check_command_in_host wget
134+
check_command_in_host xzcat
135+
}
136+
137+
138+
function check_and_download_hexagon_sdk()
116139
{
117140
is_hexagon_llvm_exist=1
118141
if [ ! -f ${PROJECT_ROOT_PATH}/prebuilts/Hexagon_SDK/6.2.0.1/tools/HEXAGON_Tools/8.8.06/NOTICE.txt ]; then
119-
echo -e "${TEXT_RED}hexagon LLVM toolchain not exist, pls check...${TEXT_RESET}\n"
142+
echo -e "${TEXT_RED}minimal-hexagon-sdk not exist...${TEXT_RESET}\n"
120143
is_hexagon_llvm_exist=0
121-
else
122-
printf "hexagon LLVM toolchain already exist\n\n"
123144
fi
124145

125-
#download customized LLVM toolchain HEXAGON_TOOLs_8.8.06.tar.gz
126146
if [ ${is_hexagon_llvm_exist} -eq 0 ]; then
127-
echo -e "begin downloading hexagon LLVM toolchain \n"
128-
wget --no-config --quiet --show-progress -O ${PROJECT_ROOT_PATH}/prebuilts/Hexagon_SDK/6.2.0.1/tools/HEXAGON_Tools/HEXAGON_TOOLs_8.8.06.tar.gz https://github.com/kantv-ai/toolchain/raw/refs/heads/main/HEXAGON_TOOLs_8.8.06.tar.gz
147+
if [ -f ${PROJECT_ROOT_PATH}/prebuilts/Hexagon_SDK/minimal-hexagon-sdk-6.2.0.1.xz ]; then
148+
echo -e "minimal-hexagon-sdk-6.2.0.1.xz already exist\n"
149+
else
150+
echo -e "begin downloading minimal-hexagon-sdk-6.2.0.1.xz \n"
151+
wget --no-config --quiet --show-progress -O ${PROJECT_ROOT_PATH}/prebuilts/Hexagon_SDK/minimal-hexagon-sdk-6.2.0.1.xz https://github.com/kantv-ai/toolchain/raw/refs/heads/main/minimal-hexagon-sdk-6.2.0.1.xz
152+
if [ $? -ne 0 ]; then
153+
printf "failed to download minimal-hexagon-sdk-6.2.0.1.xz\n"
154+
exit 1
155+
fi
156+
fi
157+
158+
echo -e "begin decompressing minimal-hexagon-sdk-6.2.0.1.xz \n"
159+
xzcat ${PROJECT_ROOT_PATH}/prebuilts/Hexagon_SDK/minimal-hexagon-sdk-6.2.0.1.xz | tar -C ${PROJECT_ROOT_PATH}/prebuilts/Hexagon_SDK/ -xf -
129160
if [ $? -ne 0 ]; then
130-
printf "failed to download hexagon LLVM toolchain\n"
161+
printf "failed to decompress minimal-hexagon-sdk-6.2.0.1.xz\n"
131162
exit 1
132-
else
133-
zcat ${PROJECT_ROOT_PATH}/prebuilts/Hexagon_SDK/6.2.0.1/tools/HEXAGON_Tools/HEXAGON_TOOLs_8.8.06.tar.gz | tar -C ${PROJECT_ROOT_PATH}/prebuilts/Hexagon_SDK/6.2.0.1/tools/HEXAGON_Tools -xvf -
134-
printf "install hexagon LLVM toolchain successfully\n\n"
135163
fi
164+
printf "install minimal-hexagon-sdk successfully\n\n"
136165
fi
137166

138167
if [ ! -d ${HEXAGON_SDK_PATH} ]; then
@@ -166,7 +195,7 @@ function check_and_download_qnn_sdk()
166195
printf "Qualcomm QNN SDK saved to ${QNN_SDK_PATH} \n\n"
167196
cd ${PROJECT_ROOT_PATH}
168197
else
169-
printf "Qualcomm QNN SDK already exist:${QNN_SDK_PATH} \n\n"
198+
printf "Qualcomm QNN SDK already exist: ${QNN_SDK_PATH} \n\n"
170199
fi
171200
}
172201

@@ -193,14 +222,14 @@ function check_and_download_ndk()
193222
unzip ${ANDROID_NDK_FULLNAME}
194223

195224
if [ $? -ne 0 ]; then
196-
printf "failed to download android ndk to %s \n" "${ANDROID_NDK}"
225+
printf "failed to download Android NDK to %s \n" "${ANDROID_NDK}"
197226
exit 1
198227
fi
199228
cd ${PROJECT_ROOT_PATH}
200229

201-
printf "android ndk saved to ${ANDROID_NDK} \n\n"
230+
printf "Android NDK saved to ${ANDROID_NDK} \n\n"
202231
else
203-
printf "android ndk already exist:${ANDROID_NDK} \n\n"
232+
printf "Android NDK already exist: ${ANDROID_NDK} \n\n"
204233
fi
205234
}
206235

@@ -281,7 +310,7 @@ function build_ggml_hexagon()
281310
show_pwd
282311
check_and_download_ndk
283312
check_and_download_qnn_sdk
284-
check_hexagon_sdk
313+
check_and_download_hexagon_sdk
285314
dump_vars
286315
remove_temp_dir
287316
build_arm64
@@ -293,7 +322,7 @@ function build_ggml_hexagon_debug()
293322
show_pwd
294323
check_and_download_ndk
295324
check_and_download_qnn_sdk
296-
check_hexagon_sdk
325+
check_and_download_hexagon_sdk
297326
dump_vars
298327
remove_temp_dir
299328
build_arm64_debug
@@ -600,8 +629,10 @@ echo "opname list: "
600629
echo ${oplist}
601630
}
602631

632+
603633
function show_usage()
604634
{
635+
echo -e "\n\n\n"
605636
echo "Usage:"
606637
echo " $0 help"
607638
echo " $0 print_oplist"
@@ -624,9 +655,10 @@ function show_usage()
624655

625656
show_pwd
626657

658+
check_commands_in_host
627659
check_and_download_ndk
628660
check_and_download_qnn_sdk
629-
check_hexagon_sdk
661+
check_and_download_hexagon_sdk
630662
check_prebuilt_models
631663

632664
if [ $# == 0 ]; then

0 commit comments

Comments
 (0)