onnxruntime/tools/ci_build/github/azure-pipelines/templates/build-linux-wasm-step.yml
Changming Sun 5eb5056c61
Always run emsdk_env.sh before build.py, even when ccache is disabled (#18477)
### Description
Always run emsdk_env.sh before build.py, even when ccache is disabled

This is a follow up to #18434. That PR didn't handle the case when
ccache was disabled.
2023-11-16 21:37:29 -08:00

75 lines
2.3 KiB
YAML

parameters:
- name: WithCache
displayName: Build with Cache
type: boolean
default: false
# if WithCahe is false, the following parameters are not used.
- name: Today
type: string
default: ""
- name: AdditionalKey
type: string
default: ""
- name: CacheDir
type: string
default: ""
- name: Arguments
type: string
- name: DisplayName
type: string
steps:
- task: Cache@2
inputs:
${{if eq(variables['Build.SourceBranchName'], 'merge')}}:
key: ' "${{parameters.TODAY}}" | ${{parameters.AdditionalKey}} | merge '
${{else}}:
key: '"${{parameters.TODAY}}" | ${{parameters.AdditionalKey}} | $(Build.SourceVersion) '
path: ${{parameters.CacheDir}}
restoreKeys: |
"${{parameters.TODAY}}" | ${{parameters.AdditionalKey}}
displayName: Cache Task
condition: eq('${{parameters.WithCache}}', true)
- ${{if eq(parameters.WithCache, true)}}:
- script: |
set -e -x
pushd '$(Build.SourcesDirectory)/cmake/external/emsdk'
source ./emsdk_env.sh
export PATH=$(Build.SourcesDirectory)/cmake/external/emsdk/:$PATH
export PATH=$(Build.SourcesDirectory)/cmake/external/emsdk/ccache/git-emscripten_64bit/bin:$PATH
echo $PATH
ccache -s
ccache -z
export EM_CONFIG="$(Build.SourcesDirectory)/cmake/external/emsdk/.emscripten"
popd
pushd '$(Build.BinariesDirectory)'
python3 '$(Build.SourcesDirectory)/tools/ci_build/build.py' ${{parameters.Arguments}}
ret=$?
if [ $ret -ne 0 ]; then
echo "Build failed with error code $ret"
exit 1
fi
ccache -s
popd
displayName: ${{parameters.DisplayName}}
env:
CCACHE_SLOPPINESS: include_file_ctime,include_file_mtime,time_macros
CCACHE_DIR: ${{parameters.CacheDir}}
_EMCC_CCACHE: 1
EM_COMPILER_WRAPPER: ccache
EM_DIR: '$(Build.SourcesDirectory)/cmake/external/emsdk/upstream/emscripten'
- ${{if eq(parameters.WithCache, false)}}:
- script: |
set -e -x
source $(Build.SourcesDirectory)/cmake/external/emsdk/emsdk_env.sh
cd '$(Build.BinariesDirectory)'
python3 '$(Build.SourcesDirectory)/tools/ci_build/build.py' ${{parameters.Arguments}}
displayName: ${{parameters.DisplayName}}