Fangjun Kuang
Committed by GitHub

Build MFC examples for Windows x86 (Win32) (#434)

Also, strip binaries on Linux before uploading.
@@ -24,15 +24,6 @@ on: @@ -24,15 +24,6 @@ on:
24 - 'toolchains/aarch64-linux-gnu.toolchain.cmake' 24 - 'toolchains/aarch64-linux-gnu.toolchain.cmake'
25 25
26 workflow_dispatch: 26 workflow_dispatch:
27 - inputs:  
28 - release:  
29 - description: "Whether to release"  
30 - type: boolean  
31 -  
32 -env:  
33 - RELEASE:  
34 - |- # Release if there is a release tag name or a release flag in workflow_dispatch  
35 - ${{ github.event.release.tag_name != '' || github.event.inputs.release == 'true' }}  
36 27
37 concurrency: 28 concurrency:
38 group: aarch64-linux-gnu-shared-${{ github.ref }} 29 group: aarch64-linux-gnu-shared-${{ github.ref }}
@@ -150,6 +141,9 @@ jobs: @@ -150,6 +141,9 @@ jobs:
150 - name: Copy files 141 - name: Copy files
151 shell: bash 142 shell: bash
152 run: | 143 run: |
  144 + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH
  145 + aarch64-none-linux-gnu-strip --version
  146 +
153 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) 147 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
154 148
155 dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-aarch64-shared 149 dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-aarch64-shared
@@ -158,6 +152,13 @@ jobs: @@ -158,6 +152,13 @@ jobs:
158 cp -a build-aarch64-linux-gnu/install/bin $dst/ 152 cp -a build-aarch64-linux-gnu/install/bin $dst/
159 cp -a build-aarch64-linux-gnu/install/lib $dst/ 153 cp -a build-aarch64-linux-gnu/install/lib $dst/
160 154
  155 + ls -lh build-aarch64-linux-gnu/install/lib
  156 + ls -lh build-aarch64-linux-gnu/install/bin
  157 +
  158 + ls -lh $dst/bin/
  159 + echo "strip"
  160 + aarch64-none-linux-gnu-strip $dst/bin/*
  161 +
161 tree $dst 162 tree $dst
162 163
163 tar cjvf ${dst}.tar.bz2 $dst 164 tar cjvf ${dst}.tar.bz2 $dst
@@ -168,7 +169,7 @@ jobs: @@ -168,7 +169,7 @@ jobs:
168 path: sherpa-onnx-*linux-aarch64-shared.tar.bz2 169 path: sherpa-onnx-*linux-aarch64-shared.tar.bz2
169 170
170 - name: Release pre-compiled binaries and libs for aarch64 linux 171 - name: Release pre-compiled binaries and libs for aarch64 linux
171 - if: env.RELEASE == 'true' 172 + if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
172 uses: svenstaro/upload-release-action@v2 173 uses: svenstaro/upload-release-action@v2
173 with: 174 with:
174 file_glob: true 175 file_glob: true
@@ -24,15 +24,6 @@ on: @@ -24,15 +24,6 @@ on:
24 - 'toolchains/aarch64-linux-gnu.toolchain.cmake' 24 - 'toolchains/aarch64-linux-gnu.toolchain.cmake'
25 25
26 workflow_dispatch: 26 workflow_dispatch:
27 - inputs:  
28 - release:  
29 - description: "Whether to release"  
30 - type: boolean  
31 -  
32 -env:  
33 - RELEASE:  
34 - |- # Release if there is a release tag name or a release flag in workflow_dispatch  
35 - ${{ github.event.release.tag_name != '' || github.event.inputs.release == 'true' }}  
36 27
37 concurrency: 28 concurrency:
38 group: aarch64-linux-gnu-static-${{ github.ref }} 29 group: aarch64-linux-gnu-static-${{ github.ref }}
@@ -151,13 +142,21 @@ jobs: @@ -151,13 +142,21 @@ jobs:
151 - name: Copy files 142 - name: Copy files
152 shell: bash 143 shell: bash
153 run: | 144 run: |
  145 + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH
  146 + aarch64-none-linux-gnu-strip --version
  147 +
154 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) 148 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
155 149
156 dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-aarch64-static 150 dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-aarch64-static
157 mkdir $dst 151 mkdir $dst
158 152
  153 + ls -lh build-aarch64-linux-gnu/install/lib
  154 +
159 cp -a build-aarch64-linux-gnu/install/bin $dst/ 155 cp -a build-aarch64-linux-gnu/install/bin $dst/
160 - cp -a build-aarch64-linux-gnu/install/lib $dst/ 156 + ls -lh $dst/bin/
  157 + echo "strip"
  158 + aarch64-none-linux-gnu-strip $dst/bin/*
  159 + ls -lh $dst/bin/
161 160
162 tree $dst 161 tree $dst
163 162
@@ -169,7 +168,7 @@ jobs: @@ -169,7 +168,7 @@ jobs:
169 path: sherpa-onnx-*linux-aarch64-static.tar.bz2 168 path: sherpa-onnx-*linux-aarch64-static.tar.bz2
170 169
171 - name: Release pre-compiled binaries and libs for aarch64 linux 170 - name: Release pre-compiled binaries and libs for aarch64 linux
172 - if: env.RELEASE == 'true' 171 + if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
173 uses: svenstaro/upload-release-action@v2 172 uses: svenstaro/upload-release-action@v2
174 with: 173 with:
175 file_glob: true 174 file_glob: true
@@ -150,13 +150,25 @@ jobs: @@ -150,13 +150,25 @@ jobs:
150 - name: Copy files 150 - name: Copy files
151 shell: bash 151 shell: bash
152 run: | 152 run: |
  153 + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH
  154 + arm-none-linux-gnueabihf-strip --version
  155 +
153 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) 156 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
154 157
155 dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-arm-gnueabihf-${{ matrix.lib_type }} 158 dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-arm-gnueabihf-${{ matrix.lib_type }}
156 mkdir $dst 159 mkdir $dst
157 160
  161 + ls -lh build-arm-linux-gnueabihf/install/lib
  162 +
158 cp -a build-arm-linux-gnueabihf/install/bin $dst/ 163 cp -a build-arm-linux-gnueabihf/install/bin $dst/
159 - cp -a build-arm-linux-gnueabihf/install/lib $dst/ 164 + ls -lh $dst/bin/*
  165 + arm-none-linux-gnueabihf-strip $dst/bin/*
  166 + ls -lh $dst
  167 +
  168 + lib_type=${{ matrix.lib_type }}
  169 + if [[ $lib_type == "shared" ]]; then
  170 + cp -a build-arm-linux-gnueabihf/install/lib $dst/
  171 + fi
160 172
161 tree $dst 173 tree $dst
162 174
@@ -88,9 +88,25 @@ jobs: @@ -88,9 +88,25 @@ jobs:
88 - name: Display dependencies of sherpa-onnx for linux 88 - name: Display dependencies of sherpa-onnx for linux
89 shell: bash 89 shell: bash
90 run: | 90 run: |
  91 + ls -lh build/bin
  92 + ls -lh build/_deps/onnxruntime-src/lib/
  93 +
  94 + echo "strip"
  95 + strip build/bin/*
  96 + echo "after strip"
  97 + ls -lh build/bin
  98 +
91 file build/bin/sherpa-onnx 99 file build/bin/sherpa-onnx
  100 + file build/bin/sherpa-onnx
  101 + ls -lh build/bin/sherpa-onnx
92 readelf -d build/bin/sherpa-onnx 102 readelf -d build/bin/sherpa-onnx
93 103
  104 + - uses: actions/upload-artifact@v3
  105 + if: matrix.shared_lib == 'OFF' && matrix.build_type == 'Release'
  106 + with:
  107 + name: release-static
  108 + path: build/bin/*
  109 +
94 - name: Test online CTC 110 - name: Test online CTC
95 shell: bash 111 shell: bash
96 run: | 112 run: |
@@ -186,3 +202,4 @@ jobs: @@ -186,3 +202,4 @@ jobs:
186 with: 202 with:
187 name: tts-generated-test-files 203 name: tts-generated-test-files
188 path: tts 204 path: tts
  205 +
@@ -36,8 +36,7 @@ jobs: @@ -36,8 +36,7 @@ jobs:
36 fail-fast: false 36 fail-fast: false
37 matrix: 37 matrix:
38 os: [windows-latest] 38 os: [windows-latest]
39 - # arch: [x64, Win32]  
40 - arch: [x64] 39 + arch: [x64, x86]
41 40
42 steps: 41 steps:
43 - uses: actions/checkout@v4 42 - uses: actions/checkout@v4
@@ -55,7 +54,11 @@ jobs: @@ -55,7 +54,11 @@ jobs:
55 run: | 54 run: |
56 mkdir build 55 mkdir build
57 cd build 56 cd build
58 - cmake -A ${{ matrix.arch }} -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./install .. 57 + arch=${{ matrix.arch }}
  58 + if [[ $arch == "x86" ]]; then
  59 + arch=Win32
  60 + fi
  61 + cmake -A $arch -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./install ..
59 62
60 - name: Build sherpa-onnx for windows 63 - name: Build sherpa-onnx for windows
61 shell: bash 64 shell: bash
@@ -83,32 +86,40 @@ jobs: @@ -83,32 +86,40 @@ jobs:
83 run: | 86 run: |
84 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) 87 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
85 arch=${{ matrix.arch }} 88 arch=${{ matrix.arch }}
  89 + if [[ $arch == "x86" ]]; then
  90 + src=mfc-examples/Release
  91 + ls -h $src
  92 + dst=mfc-examples/$arch/Release
  93 +
  94 + mkdir -p $dst
  95 + cp $src/* $dst
  96 + fi
86 97
87 cd mfc-examples/$arch/Release 98 cd mfc-examples/$arch/Release
88 ls -lh 99 ls -lh
89 100
90 - cp -v StreamingSpeechRecognition.exe sherpa-onnx-streaming-${SHERPA_ONNX_VERSION}.exe  
91 - cp -v NonStreamingSpeechRecognition.exe sherpa-onnx-non-streaming-${SHERPA_ONNX_VERSION}.exe  
92 - cp -v NonStreamingTextToSpeech.exe ../sherpa-onnx-non-streaming-tts-${SHERPA_ONNX_VERSION}.exe 101 + cp -v StreamingSpeechRecognition.exe sherpa-onnx-streaming-asr-$arch-${SHERPA_ONNX_VERSION}.exe
  102 + cp -v NonStreamingSpeechRecognition.exe sherpa-onnx-non-streaming-asr-$arch-${SHERPA_ONNX_VERSION}.exe
  103 + cp -v NonStreamingTextToSpeech.exe ../sherpa-onnx-non-streaming-tts-$arch-${SHERPA_ONNX_VERSION}.exe
93 ls -lh 104 ls -lh
94 105
95 - name: Upload artifact tts 106 - name: Upload artifact tts
96 uses: actions/upload-artifact@v3 107 uses: actions/upload-artifact@v3
97 with: 108 with:
98 name: non-streaming-tts-${{ matrix.arch }} 109 name: non-streaming-tts-${{ matrix.arch }}
99 - path: ./mfc-examples/${{ matrix.arch }}/Release/NonStreamingTextToSpeech.exe 110 + path: ./mfc-examples/${{ matrix.arch }}/sherpa-onnx-non-streaming-tts-*.exe
100 111
101 - name: Upload artifact 112 - name: Upload artifact
102 uses: actions/upload-artifact@v3 113 uses: actions/upload-artifact@v3
103 with: 114 with:
104 name: streaming-speech-recognition-${{ matrix.arch }} 115 name: streaming-speech-recognition-${{ matrix.arch }}
105 - path: ./mfc-examples/${{ matrix.arch }}/Release/StreamingSpeechRecognition.exe 116 + path: ./mfc-examples/${{ matrix.arch }}/Release/sherpa-onnx-streaming-asr-*.exe
106 117
107 - name: Upload artifact 118 - name: Upload artifact
108 uses: actions/upload-artifact@v3 119 uses: actions/upload-artifact@v3
109 with: 120 with:
110 name: non-streaming-speech-recognition-${{ matrix.arch }} 121 name: non-streaming-speech-recognition-${{ matrix.arch }}
111 - path: ./mfc-examples/${{ matrix.arch }}/Release/NonStreamingSpeechRecognition.exe 122 + path: ./mfc-examples/${{ matrix.arch }}/Release/sherpa-onnx-non-streaming-asr-*.exe
112 123
113 - name: Release pre-compiled binaries and libs for Windows ${{ matrix.arch }} 124 - name: Release pre-compiled binaries and libs for Windows ${{ matrix.arch }}
114 if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 125 if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')