Fangjun Kuang
Committed by GitHub

Support building debug version on Windows (#583)

@@ -74,7 +74,7 @@ jobs: @@ -74,7 +74,7 @@ jobs:
74 export PATH=/c/hostedtoolcache/windows/Python/3.8.10/x64/bin:$PATH 74 export PATH=/c/hostedtoolcache/windows/Python/3.8.10/x64/bin:$PATH
75 export PATH=/c/hostedtoolcache/windows/Python/3.9.13/x64/bin:$PATH 75 export PATH=/c/hostedtoolcache/windows/Python/3.9.13/x64/bin:$PATH
76 export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH 76 export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH
77 - export PATH=/c/hostedtoolcache/windows/Python/3.11.7/x64/bin:$PATH 77 + export PATH=/c/hostedtoolcache/windows/Python/3.11.8/x64/bin:$PATH
78 78
79 which sherpa-onnx 79 which sherpa-onnx
80 sherpa-onnx --help 80 sherpa-onnx --help
@@ -67,7 +67,7 @@ jobs: @@ -67,7 +67,7 @@ jobs:
67 export PATH=/c/hostedtoolcache/windows/Python/3.8.10/x64/bin:$PATH 67 export PATH=/c/hostedtoolcache/windows/Python/3.8.10/x64/bin:$PATH
68 export PATH=/c/hostedtoolcache/windows/Python/3.9.13/x64/bin:$PATH 68 export PATH=/c/hostedtoolcache/windows/Python/3.9.13/x64/bin:$PATH
69 export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH 69 export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH
70 - export PATH=/c/hostedtoolcache/windows/Python/3.11.7/x64/bin:$PATH 70 + export PATH=/c/hostedtoolcache/windows/Python/3.11.8/x64/bin:$PATH
71 71
72 sherpa-onnx --help 72 sherpa-onnx --help
73 sherpa-onnx-keyword-spotter --help 73 sherpa-onnx-keyword-spotter --help
  1 +name: windows-x64-debug
  2 +
  3 +on:
  4 + push:
  5 + branches:
  6 + - master
  7 + tags:
  8 + - '*'
  9 + paths:
  10 + - '.github/workflows/windows-x64-debug.yaml'
  11 + - '.github/scripts/test-online-transducer.sh'
  12 + - '.github/scripts/test-online-paraformer.sh'
  13 + - '.github/scripts/test-offline-transducer.sh'
  14 + - '.github/scripts/test-offline-ctc.sh'
  15 + - '.github/scripts/test-online-ctc.sh'
  16 + - '.github/scripts/test-offline-tts.sh'
  17 + - 'CMakeLists.txt'
  18 + - 'cmake/**'
  19 + - 'sherpa-onnx/csrc/*'
  20 + pull_request:
  21 + branches:
  22 + - master
  23 + paths:
  24 + - '.github/workflows/windows-x64-debug.yaml'
  25 + - '.github/scripts/test-online-transducer.sh'
  26 + - '.github/scripts/test-online-paraformer.sh'
  27 + - '.github/scripts/test-offline-transducer.sh'
  28 + - '.github/scripts/test-offline-ctc.sh'
  29 + - '.github/scripts/test-online-ctc.sh'
  30 + - '.github/scripts/test-offline-tts.sh'
  31 + - 'CMakeLists.txt'
  32 + - 'cmake/**'
  33 + - 'sherpa-onnx/csrc/*'
  34 +
  35 + workflow_dispatch:
  36 +
  37 +concurrency:
  38 + group: windows-x64-debug-${{ github.ref }}
  39 + cancel-in-progress: true
  40 +
  41 +jobs:
  42 + windows_x64_debug:
  43 + name: Windows x64 debug
  44 + runs-on: ${{ matrix.os }}
  45 + strategy:
  46 + fail-fast: false
  47 + matrix:
  48 + os: [windows-latest]
  49 + shared_lib: [OFF]
  50 +
  51 + steps:
  52 + - uses: actions/checkout@v4
  53 + with:
  54 + fetch-depth: 0
  55 +
  56 + - name: Configure CMake
  57 + shell: bash
  58 + run: |
  59 + mkdir build
  60 + cd build
  61 + cmake -A x64 -D CMAKE_BUILD_TYPE=Debug -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -DCMAKE_INSTALL_PREFIX=./install ..
  62 +
  63 + - name: Build sherpa-onnx for windows
  64 + shell: bash
  65 + run: |
  66 + cd build
  67 + cmake --build . --config Debug -- -m:2
  68 + cmake --build . --config Debug --target install -- -m:2
  69 +
  70 + ls -lh ./bin/Debug/sherpa-onnx.exe
  71 +
  72 + - name: Test online CTC
  73 + shell: bash
  74 + run: |
  75 + export PATH=$PWD/build/bin/Debug:$PATH
  76 + export EXE=sherpa-onnx.exe
  77 +
  78 + .github/scripts/test-online-ctc.sh
  1 +name: windows-x86-debug
  2 +
  3 +on:
  4 + push:
  5 + branches:
  6 + - master
  7 + tags:
  8 + - '*'
  9 + paths:
  10 + - '.github/workflows/windows-x86-debug.yaml'
  11 + - '.github/scripts/test-online-transducer.sh'
  12 + - '.github/scripts/test-online-paraformer.sh'
  13 + - '.github/scripts/test-offline-transducer.sh'
  14 + - '.github/scripts/test-offline-ctc.sh'
  15 + - '.github/scripts/test-offline-tts.sh'
  16 + - '.github/scripts/test-online-ctc.sh'
  17 + - 'CMakeLists.txt'
  18 + - 'cmake/**'
  19 + - 'sherpa-onnx/csrc/*'
  20 + pull_request:
  21 + branches:
  22 + - master
  23 + paths:
  24 + - '.github/workflows/windows-x86-debug.yaml'
  25 + - '.github/scripts/test-online-transducer.sh'
  26 + - '.github/scripts/test-online-paraformer.sh'
  27 + - '.github/scripts/test-offline-transducer.sh'
  28 + - '.github/scripts/test-offline-ctc.sh'
  29 + - '.github/scripts/test-offline-tts.sh'
  30 + - '.github/scripts/test-online-ctc.sh'
  31 + - 'CMakeLists.txt'
  32 + - 'cmake/**'
  33 + - 'sherpa-onnx/csrc/*'
  34 +
  35 + workflow_dispatch:
  36 +
  37 +concurrency:
  38 + group: windows-x86-debug-${{ github.ref }}
  39 + cancel-in-progress: true
  40 +
  41 +jobs:
  42 + windows_x86_debug:
  43 + name: Windows x86 debug
  44 + runs-on: ${{ matrix.os }}
  45 + strategy:
  46 + fail-fast: false
  47 + matrix:
  48 + os: [windows-latest]
  49 + shared_lib: [OFF]
  50 +
  51 + steps:
  52 + - uses: actions/checkout@v4
  53 + with:
  54 + fetch-depth: 0
  55 +
  56 + - name: Configure CMake
  57 + shell: bash
  58 + run: |
  59 + mkdir build
  60 + cd build
  61 + cmake -A Win32 -D CMAKE_BUILD_TYPE=Debug -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -D CMAKE_INSTALL_PREFIX=./install ..
  62 +
  63 + - name: Build sherpa-onnx for windows
  64 + shell: bash
  65 + run: |
  66 + cd build
  67 + cmake --build . --config Debug -- -m:2
  68 + cmake --build . --config Debug --target install -- -m:2
  69 +
  70 + ls -lh ./bin/Debug/sherpa-onnx.exe
  71 +
  72 + - name: Test online CTC
  73 + shell: bash
  74 + run: |
  75 + export PATH=$PWD/build/bin/Debug:$PATH
  76 + export EXE=sherpa-onnx.exe
  77 +
  78 + .github/scripts/test-online-ctc.sh
  1 +# Copyright (c) 2022-2023 Xiaomi Corporation
  2 +message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
  3 +message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
  4 +message(STATUS "CMAKE_VS_PLATFORM_NAME: ${CMAKE_VS_PLATFORM_NAME}")
  5 +
  6 +if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
  7 + message(FATAL_ERROR "This file is for Windows only. Given: ${CMAKE_SYSTEM_NAME}")
  8 +endif()
  9 +
  10 +if(NOT (CMAKE_VS_PLATFORM_NAME STREQUAL X64 OR CMAKE_VS_PLATFORM_NAME STREQUAL x64))
  11 + message(FATAL_ERROR "This file is for Windows x64 only. Given: ${CMAKE_VS_PLATFORM_NAME}")
  12 +endif()
  13 +
  14 +if(BUILD_SHARED_LIBS)
  15 + message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
  16 +endif()
  17 +
  18 +if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
  19 + message(FATAL_ERROR "This file is for building a debug version on Windows x64")
  20 +endif()
  21 +
  22 +set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.0/onnxruntime-win-x64-static_lib-debug-1.17.0.tar.bz2")
  23 +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x64-static_lib-debug-1.17.0.tar.bz2")
  24 +set(onnxruntime_HASH "SHA256=6010bbab913cee3f11c421aeff9d173980623da6e72e88078396839a26d65c98")
  25 +
  26 +# If you don't have access to the Internet,
  27 +# please download onnxruntime to one of the following locations.
  28 +# You can add more if you want.
  29 +set(possible_file_locations
  30 + $ENV{HOME}/Downloads/onnxruntime-win-x64-static_lib-debug-1.17.0.tar.bz2
  31 + ${CMAKE_SOURCE_DIR}/onnxruntime-win-x64-static_lib-debug-1.17.0.tar.bz2
  32 + ${CMAKE_BINARY_DIR}/onnxruntime-win-x64-static_lib-debug-1.17.0.tar.bz2
  33 + /tmp/onnxruntime-win-x64-static_lib-debug-1.17.0.tar.bz2
  34 +)
  35 +
  36 +foreach(f IN LISTS possible_file_locations)
  37 + if(EXISTS ${f})
  38 + set(onnxruntime_URL "${f}")
  39 + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
  40 + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
  41 + set(onnxruntime_URL2)
  42 + break()
  43 + endif()
  44 +endforeach()
  45 +
  46 +FetchContent_Declare(onnxruntime
  47 + URL
  48 + ${onnxruntime_URL}
  49 + ${onnxruntime_URL2}
  50 + URL_HASH ${onnxruntime_HASH}
  51 +)
  52 +
  53 +FetchContent_GetProperties(onnxruntime)
  54 +if(NOT onnxruntime_POPULATED)
  55 + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")
  56 + FetchContent_Populate(onnxruntime)
  57 +endif()
  58 +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
  59 +
  60 +# for static libraries, we use onnxruntime_lib_files directly below
  61 +include_directories(${onnxruntime_SOURCE_DIR}/include)
  62 +
  63 +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.lib")
  64 +
  65 +set(onnxruntime_lib_files ${onnxruntime_lib_files} PARENT_SCOPE)
  66 +
  67 +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  68 +if(SHERPA_ONNX_ENABLE_PYTHON)
  69 + install(FILES ${onnxruntime_lib_files} DESTINATION ..)
  70 +else()
  71 + install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  72 +endif()
@@ -15,6 +15,10 @@ if(BUILD_SHARED_LIBS) @@ -15,6 +15,10 @@ if(BUILD_SHARED_LIBS)
15 message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") 15 message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
16 endif() 16 endif()
17 17
  18 +if(NOT CMAKE_BUILD_TYPE STREQUAL Release)
  19 + message(FATAL_ERROR "This file is for building a release version on Windows x64")
  20 +endif()
  21 +
18 set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.0/onnxruntime-win-x64-static_lib-1.17.0.tar.bz2") 22 set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.0/onnxruntime-win-x64-static_lib-1.17.0.tar.bz2")
19 set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x64-static_lib-1.17.0.tar.bz2") 23 set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x64-static_lib-1.17.0.tar.bz2")
20 set(onnxruntime_HASH "SHA256=7ff33b989fbe32546d694284d46653fd4c38f47155105ec14907e6d3cd4b01bb") 24 set(onnxruntime_HASH "SHA256=7ff33b989fbe32546d694284d46653fd4c38f47155105ec14907e6d3cd4b01bb")
  1 +# Copyright (c) 2022-2023 Xiaomi Corporation
  2 +message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
  3 +message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
  4 +message(STATUS "CMAKE_VS_PLATFORM_NAME: ${CMAKE_VS_PLATFORM_NAME}")
  5 +
  6 +if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
  7 + message(FATAL_ERROR "This file is for Windows only. Given: ${CMAKE_SYSTEM_NAME}")
  8 +endif()
  9 +
  10 +if(NOT (CMAKE_VS_PLATFORM_NAME STREQUAL Win32 OR CMAKE_VS_PLATFORM_NAME STREQUAL win32))
  11 + message(FATAL_ERROR "This file is for Windows x86 only. Given: ${CMAKE_VS_PLATFORM_NAME}")
  12 +endif()
  13 +
  14 +if(BUILD_SHARED_LIBS)
  15 + message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
  16 +endif()
  17 +
  18 +if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
  19 + message(FATAL_ERROR "This file is for building a debug version on Windows x86")
  20 +endif()
  21 +
  22 +set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.0/onnxruntime-win-x86-static_lib-debug-1.17.0.tar.bz2")
  23 +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x86-static_lib-debug-1.17.0.tar.bz2")
  24 +set(onnxruntime_HASH "SHA256=aa18677dd45338a90fc1bc14c86fe1e8a21f63913d40b3644924f5b24654218e")
  25 +
  26 +# If you don't have access to the Internet,
  27 +# please download onnxruntime to one of the following locations.
  28 +# You can add more if you want.
  29 +set(possible_file_locations
  30 + $ENV{HOME}/Downloads/onnxruntime-win-x86-static_lib-debug-1.17.0.tar.bz2
  31 + ${CMAKE_SOURCE_DIR}/onnxruntime-win-x86-static_lib-debug-1.17.0.tar.bz2
  32 + ${CMAKE_BINARY_DIR}/onnxruntime-win-x86-static_lib-debug-1.17.0.tar.bz2
  33 + /tmp/onnxruntime-win-x86-static_lib-debug-1.17.0.tar.bz2
  34 +)
  35 +
  36 +foreach(f IN LISTS possible_file_locations)
  37 + if(EXISTS ${f})
  38 + set(onnxruntime_URL "${f}")
  39 + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
  40 + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
  41 + set(onnxruntime_URL2)
  42 + break()
  43 + endif()
  44 +endforeach()
  45 +
  46 +FetchContent_Declare(onnxruntime
  47 + URL
  48 + ${onnxruntime_URL}
  49 + ${onnxruntime_URL2}
  50 + URL_HASH ${onnxruntime_HASH}
  51 +)
  52 +
  53 +FetchContent_GetProperties(onnxruntime)
  54 +if(NOT onnxruntime_POPULATED)
  55 + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")
  56 + FetchContent_Populate(onnxruntime)
  57 +endif()
  58 +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
  59 +
  60 +# for static libraries, we use onnxruntime_lib_files directly below
  61 +include_directories(${onnxruntime_SOURCE_DIR}/include)
  62 +
  63 +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.lib")
  64 +set(onnxruntime_lib_files ${onnxruntime_lib_files} PARENT_SCOPE)
  65 +
  66 +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  67 +if(SHERPA_ONNX_ENABLE_PYTHON)
  68 + install(FILES ${onnxruntime_lib_files} DESTINATION ..)
  69 +else()
  70 + install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  71 +endif()
@@ -15,6 +15,10 @@ if(BUILD_SHARED_LIBS) @@ -15,6 +15,10 @@ if(BUILD_SHARED_LIBS)
15 message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") 15 message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
16 endif() 16 endif()
17 17
  18 +if(NOT CMAKE_BUILD_TYPE STREQUAL Release)
  19 + message(FATAL_ERROR "This file is for building a release version on Windows x86")
  20 +endif()
  21 +
18 set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.0/onnxruntime-win-x86-static_lib-1.17.0.tar.bz2") 22 set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.0/onnxruntime-win-x86-static_lib-1.17.0.tar.bz2")
19 set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x86-static_lib-1.17.0.tar.bz2") 23 set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x86-static_lib-1.17.0.tar.bz2")
20 set(onnxruntime_HASH "SHA256=3c40c53fef937452bf6cfbac1584875d5627bd908ca731d120642112526c8352") 24 set(onnxruntime_HASH "SHA256=3c40c53fef937452bf6cfbac1584875d5627bd908ca731d120642112526c8352")
@@ -69,7 +69,13 @@ function(download_onnxruntime) @@ -69,7 +69,13 @@ function(download_onnxruntime)
69 if(BUILD_SHARED_LIBS) 69 if(BUILD_SHARED_LIBS)
70 include(onnxruntime-win-x86) 70 include(onnxruntime-win-x86)
71 else() 71 else()
72 - include(onnxruntime-win-x86-static) 72 + if(CMAKE_BUILD_TYPE STREQUAL Release)
  73 + include(onnxruntime-win-x86-static)
  74 + elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
  75 + include(onnxruntime-win-x86-static-debug)
  76 + else()
  77 + message(STATUS "Support only CMAKE_BUILD_TYPE Release or Debug. Given: ${CMAKE_BUILD_TYPE}")
  78 + endif()
73 endif() 79 endif()
74 80
75 if(SHERPA_ONNX_ENABLE_GPU) 81 if(SHERPA_ONNX_ENABLE_GPU)
@@ -87,7 +93,13 @@ function(download_onnxruntime) @@ -87,7 +93,13 @@ function(download_onnxruntime)
87 else() 93 else()
88 # static libraries for windows x64 94 # static libraries for windows x64
89 message(STATUS "Use static onnxruntime libraries") 95 message(STATUS "Use static onnxruntime libraries")
90 - include(onnxruntime-win-x64-static) 96 + if(CMAKE_BUILD_TYPE STREQUAL Release)
  97 + include(onnxruntime-win-x64-static)
  98 + elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
  99 + include(onnxruntime-win-x64-static-debug)
  100 + else()
  101 + message(STATUS "Support only CMAKE_BUILD_TYPE Release or Debug. Given: ${CMAKE_BUILD_TYPE}")
  102 + endif()
91 endif() 103 endif()
92 endif() 104 endif()
93 else() 105 else()