From ac00edab5bec3b2a5ef69ddde79bce40095d90c2 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Sat, 18 Nov 2023 16:13:09 +0800 Subject: [PATCH] Build MFC examples for Windows x86 (Win32) (#434) Also, strip binaries on Linux before uploading. --- .../workflows/aarch64-linux-gnu-shared.yaml | 21 +++++++------- .../workflows/aarch64-linux-gnu-static.yaml | 21 +++++++------- .github/workflows/arm-linux-gnueabihf.yaml | 14 ++++++++- .github/workflows/linux.yaml | 17 +++++++++++ .github/workflows/mfc.yaml | 29 +++++++++++++------ 5 files changed, 71 insertions(+), 31 deletions(-) diff --git a/.github/workflows/aarch64-linux-gnu-shared.yaml b/.github/workflows/aarch64-linux-gnu-shared.yaml index 25eb3cbd7..5835345db 100644 --- a/.github/workflows/aarch64-linux-gnu-shared.yaml +++ b/.github/workflows/aarch64-linux-gnu-shared.yaml @@ -24,15 +24,6 @@ on: - 'toolchains/aarch64-linux-gnu.toolchain.cmake' workflow_dispatch: - inputs: - release: - description: "Whether to release" - type: boolean - -env: - RELEASE: - |- # Release if there is a release tag name or a release flag in workflow_dispatch - ${{ github.event.release.tag_name != '' || github.event.inputs.release == 'true' }} concurrency: group: aarch64-linux-gnu-shared-${{ github.ref }} @@ -150,6 +141,9 @@ jobs: - name: Copy files shell: bash run: | + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH + aarch64-none-linux-gnu-strip --version + SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-aarch64-shared @@ -158,6 +152,13 @@ jobs: cp -a build-aarch64-linux-gnu/install/bin $dst/ cp -a build-aarch64-linux-gnu/install/lib $dst/ + ls -lh build-aarch64-linux-gnu/install/lib + ls -lh build-aarch64-linux-gnu/install/bin + + ls -lh $dst/bin/ + echo "strip" + aarch64-none-linux-gnu-strip $dst/bin/* + tree $dst tar cjvf ${dst}.tar.bz2 $dst @@ -168,7 +169,7 @@ jobs: path: sherpa-onnx-*linux-aarch64-shared.tar.bz2 - name: Release pre-compiled binaries and libs for aarch64 linux - if: env.RELEASE == 'true' + if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') uses: svenstaro/upload-release-action@v2 with: file_glob: true diff --git a/.github/workflows/aarch64-linux-gnu-static.yaml b/.github/workflows/aarch64-linux-gnu-static.yaml index 1d01bfde0..e47cdae80 100644 --- a/.github/workflows/aarch64-linux-gnu-static.yaml +++ b/.github/workflows/aarch64-linux-gnu-static.yaml @@ -24,15 +24,6 @@ on: - 'toolchains/aarch64-linux-gnu.toolchain.cmake' workflow_dispatch: - inputs: - release: - description: "Whether to release" - type: boolean - -env: - RELEASE: - |- # Release if there is a release tag name or a release flag in workflow_dispatch - ${{ github.event.release.tag_name != '' || github.event.inputs.release == 'true' }} concurrency: group: aarch64-linux-gnu-static-${{ github.ref }} @@ -151,13 +142,21 @@ jobs: - name: Copy files shell: bash run: | + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH + aarch64-none-linux-gnu-strip --version + SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-aarch64-static mkdir $dst + ls -lh build-aarch64-linux-gnu/install/lib + cp -a build-aarch64-linux-gnu/install/bin $dst/ - cp -a build-aarch64-linux-gnu/install/lib $dst/ + ls -lh $dst/bin/ + echo "strip" + aarch64-none-linux-gnu-strip $dst/bin/* + ls -lh $dst/bin/ tree $dst @@ -169,7 +168,7 @@ jobs: path: sherpa-onnx-*linux-aarch64-static.tar.bz2 - name: Release pre-compiled binaries and libs for aarch64 linux - if: env.RELEASE == 'true' + if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') uses: svenstaro/upload-release-action@v2 with: file_glob: true diff --git a/.github/workflows/arm-linux-gnueabihf.yaml b/.github/workflows/arm-linux-gnueabihf.yaml index 3cb430e4d..cb342935a 100644 --- a/.github/workflows/arm-linux-gnueabihf.yaml +++ b/.github/workflows/arm-linux-gnueabihf.yaml @@ -150,13 +150,25 @@ jobs: - name: Copy files shell: bash run: | + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH + arm-none-linux-gnueabihf-strip --version + SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-arm-gnueabihf-${{ matrix.lib_type }} mkdir $dst + ls -lh build-arm-linux-gnueabihf/install/lib + cp -a build-arm-linux-gnueabihf/install/bin $dst/ - cp -a build-arm-linux-gnueabihf/install/lib $dst/ + ls -lh $dst/bin/* + arm-none-linux-gnueabihf-strip $dst/bin/* + ls -lh $dst + + lib_type=${{ matrix.lib_type }} + if [[ $lib_type == "shared" ]]; then + cp -a build-arm-linux-gnueabihf/install/lib $dst/ + fi tree $dst diff --git a/.github/workflows/linux.yaml b/.github/workflows/linux.yaml index cbe4dac97..b25600474 100644 --- a/.github/workflows/linux.yaml +++ b/.github/workflows/linux.yaml @@ -88,9 +88,25 @@ jobs: - name: Display dependencies of sherpa-onnx for linux shell: bash run: | + ls -lh build/bin + ls -lh build/_deps/onnxruntime-src/lib/ + + echo "strip" + strip build/bin/* + echo "after strip" + ls -lh build/bin + file build/bin/sherpa-onnx + file build/bin/sherpa-onnx + ls -lh build/bin/sherpa-onnx readelf -d build/bin/sherpa-onnx + - uses: actions/upload-artifact@v3 + if: matrix.shared_lib == 'OFF' && matrix.build_type == 'Release' + with: + name: release-static + path: build/bin/* + - name: Test online CTC shell: bash run: | @@ -186,3 +202,4 @@ jobs: with: name: tts-generated-test-files path: tts + diff --git a/.github/workflows/mfc.yaml b/.github/workflows/mfc.yaml index 578cfec6e..9d7c7117f 100644 --- a/.github/workflows/mfc.yaml +++ b/.github/workflows/mfc.yaml @@ -36,8 +36,7 @@ jobs: fail-fast: false matrix: os: [windows-latest] - # arch: [x64, Win32] - arch: [x64] + arch: [x64, x86] steps: - uses: actions/checkout@v4 @@ -55,7 +54,11 @@ jobs: run: | mkdir build cd build - cmake -A ${{ matrix.arch }} -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./install .. + arch=${{ matrix.arch }} + if [[ $arch == "x86" ]]; then + arch=Win32 + fi + cmake -A $arch -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./install .. - name: Build sherpa-onnx for windows shell: bash @@ -83,32 +86,40 @@ jobs: run: | SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) arch=${{ matrix.arch }} + if [[ $arch == "x86" ]]; then + src=mfc-examples/Release + ls -h $src + dst=mfc-examples/$arch/Release + + mkdir -p $dst + cp $src/* $dst + fi cd mfc-examples/$arch/Release ls -lh - cp -v StreamingSpeechRecognition.exe sherpa-onnx-streaming-${SHERPA_ONNX_VERSION}.exe - cp -v NonStreamingSpeechRecognition.exe sherpa-onnx-non-streaming-${SHERPA_ONNX_VERSION}.exe - cp -v NonStreamingTextToSpeech.exe ../sherpa-onnx-non-streaming-tts-${SHERPA_ONNX_VERSION}.exe + cp -v StreamingSpeechRecognition.exe sherpa-onnx-streaming-asr-$arch-${SHERPA_ONNX_VERSION}.exe + cp -v NonStreamingSpeechRecognition.exe sherpa-onnx-non-streaming-asr-$arch-${SHERPA_ONNX_VERSION}.exe + cp -v NonStreamingTextToSpeech.exe ../sherpa-onnx-non-streaming-tts-$arch-${SHERPA_ONNX_VERSION}.exe ls -lh - name: Upload artifact tts uses: actions/upload-artifact@v3 with: name: non-streaming-tts-${{ matrix.arch }} - path: ./mfc-examples/${{ matrix.arch }}/Release/NonStreamingTextToSpeech.exe + path: ./mfc-examples/${{ matrix.arch }}/sherpa-onnx-non-streaming-tts-*.exe - name: Upload artifact uses: actions/upload-artifact@v3 with: name: streaming-speech-recognition-${{ matrix.arch }} - path: ./mfc-examples/${{ matrix.arch }}/Release/StreamingSpeechRecognition.exe + path: ./mfc-examples/${{ matrix.arch }}/Release/sherpa-onnx-streaming-asr-*.exe - name: Upload artifact uses: actions/upload-artifact@v3 with: name: non-streaming-speech-recognition-${{ matrix.arch }} - path: ./mfc-examples/${{ matrix.arch }}/Release/NonStreamingSpeechRecognition.exe + path: ./mfc-examples/${{ matrix.arch }}/Release/sherpa-onnx-non-streaming-asr-*.exe - name: Release pre-compiled binaries and libs for Windows ${{ matrix.arch }} if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')