@@ -109,6 +109,81 @@ install_qnn() {
109109 echo " Set QNN_SDK_ROOT=${QNN_SDK_ROOT} "
110110}
111111
112+ # Install the Hexagon SDK required for direct-mode CI builds.
113+ install_hexagon_sdk () {
114+ # Check if already configured externally and valid.
115+ if [ -n " ${HEXAGON_SDK_ROOT:- } " ] && [ -d " ${HEXAGON_SDK_ROOT:- } " ] \
116+ && [ -n " ${HEXAGON_TOOLS_ROOT:- } " ] && [ -d " ${HEXAGON_TOOLS_ROOT:- } " ]; then
117+ echo " Hexagon SDK already set to ${HEXAGON_SDK_ROOT} - skipping installation"
118+ return
119+ fi
120+
121+ echo " Start installing Hexagon SDK v${HEXAGON_SDK_VERSION} (tools v${HEXAGON_TOOLS_VERSION} )"
122+ HEXAGON_INSTALLATION_DIR=" /tmp/hexagon-sdk"
123+ HEXAGON_SDK_DIR=" ${HEXAGON_INSTALLATION_DIR} /Hexagon_SDK/${HEXAGON_SDK_VERSION} "
124+ HEXAGON_TOOLS_DIR=" ${HEXAGON_SDK_DIR} /tools/HEXAGON_Tools/${HEXAGON_TOOLS_VERSION} "
125+
126+ # Idempotent re-run guard: skip the download if a previous run already
127+ # extracted both the SDK root and the pinned toolchain version.
128+ if [ -d " ${HEXAGON_SDK_DIR} " ] && [ -d " ${HEXAGON_TOOLS_DIR} " ]; then
129+ echo " Hexagon SDK already installed at ${HEXAGON_SDK_DIR} "
130+ export HEXAGON_SDK_ROOT=" ${HEXAGON_SDK_DIR} "
131+ export HEXAGON_TOOLS_ROOT=" ${HEXAGON_TOOLS_DIR} "
132+ return
133+ fi
134+
135+ mkdir -p " ${HEXAGON_INSTALLATION_DIR} "
136+
137+ HEXAGON_ZIP_FILE=" Hexagon_SDK_Linux.zip"
138+ # Match install_qnn's retry shape: --fail rejects HTTP errors,
139+ # --retry-all-errors retries transport failures, and `unzip -t`
140+ # validates the archive before we proceed.
141+ HEXAGON_DOWNLOAD_MAX_ATTEMPTS=5
142+ for attempt in $( seq 1 ${HEXAGON_DOWNLOAD_MAX_ATTEMPTS} ) ; do
143+ rm -f " /tmp/${HEXAGON_ZIP_FILE} "
144+ if curl --fail --retry 3 --retry-delay 5 --retry-connrefused --retry-all-errors \
145+ -Lo " /tmp/${HEXAGON_ZIP_FILE} " " ${HEXAGON_SDK_ZIP_URL} " \
146+ && unzip -tq " /tmp/${HEXAGON_ZIP_FILE} " ; then
147+ break
148+ fi
149+ ls -l " /tmp/${HEXAGON_ZIP_FILE} " 2>&1 || true
150+ if [ " ${attempt} " = " ${HEXAGON_DOWNLOAD_MAX_ATTEMPTS} " ]; then
151+ echo " ERROR: Hexagon SDK download failed after ${attempt} attempts" >&2
152+ exit 1
153+ fi
154+ echo " Hexagon SDK download attempt ${attempt} failed; retrying in $(( attempt * 10 )) s..."
155+ sleep $(( attempt * 10 ))
156+ done
157+ echo " Finishing downloading Hexagon SDK."
158+
159+ unzip -qo " /tmp/${HEXAGON_ZIP_FILE} " -d " ${HEXAGON_INSTALLATION_DIR} "
160+ echo " Finishing unzip Hexagon SDK."
161+
162+ export HEXAGON_SDK_ROOT=" ${HEXAGON_SDK_DIR} "
163+ export HEXAGON_TOOLS_ROOT=" ${HEXAGON_TOOLS_DIR} "
164+
165+ # Verify the unzipped layout matches what build.sh and the QNN CMake
166+ # files actually consume. If any of these are missing, a future SDK
167+ # release likely changed the directory shape; updating
168+ # HEXAGON_SDK_VERSION / HEXAGON_TOOLS_VERSION in qnn_config.sh (or the
169+ # extraction layout below) is the fix.
170+ for hexagon_required_path in \
171+ " ${HEXAGON_SDK_ROOT} " \
172+ " ${HEXAGON_SDK_ROOT} /build/cmake/hexagon_toolchain.cmake" \
173+ " ${HEXAGON_TOOLS_ROOT} " \
174+ " ${HEXAGON_TOOLS_ROOT} /Tools/target/hexagon" ; do
175+ if [ ! -e " ${hexagon_required_path} " ]; then
176+ echo " [Hexagon] ERROR: expected path not found: ${hexagon_required_path} " >&2
177+ echo " [Hexagon] Hexagon SDK ${HEXAGON_SDK_VERSION} or tools ${HEXAGON_TOOLS_VERSION} layout differs from what we pinned." >&2
178+ ls -la " $( dirname " ${hexagon_required_path} " ) " >&2 || true
179+ exit 1
180+ fi
181+ done
182+
183+ echo " Set HEXAGON_SDK_ROOT=${HEXAGON_SDK_ROOT} "
184+ echo " Set HEXAGON_TOOLS_ROOT=${HEXAGON_TOOLS_ROOT} "
185+ }
186+
112187setup_libcpp () {
113188 clang_version=$1
114189 LLVM_VERSION=" 14.0.0"
0 commit comments