onnxruntime/tools/ci_build/github/azure-pipelines/templates/use-android-ndk.yml
Edward Chen 6d46007028
Add explicit 'set +x' before printing a vso[] command to avoid output getting parsed again with a trailing quote. (#15986)
Here's the motivating issue:
https://github.com/microsoft/azure-pipelines-tasks/issues/10331

Noticed some problems in other repos so also updating usages in ORT.

We may be fine now without it, but this change adds some safeguard against future additions of 'set -x' for debugging.
2023-05-17 19:30:28 -07:00

33 lines
1 KiB
YAML

# Installs the Android NDK and sets environment variables ANDROID_NDK_HOME and ANDROID_NDK_ROOT to refer to it.
parameters:
- name: AndroidNdkVersion
type: string
default: "25.0.8775105" # LTS version
steps:
- bash: |
set -e
"${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager" --install "ndk;${{ parameters.AndroidNdkVersion }}"
NDK_PATH="${ANDROID_SDK_ROOT}/ndk/${{ parameters.AndroidNdkVersion }}"
if [[ ! -d "${NDK_PATH}" ]]; then
echo "NDK directory is not in expected location: ${NDK_PATH}"
exit 1
fi
# Do not output ##vso[] commands with `set -x` or they may be parsed again and include a trailing quote.
set +x
set_var() {
local VAR_NAME=${1:?}
local VAR_VALUE=${2:?}
echo "##vso[task.setvariable variable=${VAR_NAME}]${VAR_VALUE}"
echo "${VAR_NAME}: ${VAR_VALUE}"
}
set_var "ANDROID_NDK_HOME" "${NDK_PATH}"
set_var "ANDROID_NDK_ROOT" "${NDK_PATH}"
displayName: Use Android NDK ${{ parameters.AndroidNdkVersion }}