Fangjun Kuang
Committed by GitHub

Fix static link without tts (#2328)

@@ -33,13 +33,14 @@ concurrency: @@ -33,13 +33,14 @@ concurrency:
33 jobs: 33 jobs:
34 pkg_config: 34 pkg_config:
35 runs-on: ${{ matrix.os }} 35 runs-on: ${{ matrix.os }}
36 - name: ${{ matrix.os }} ${{ matrix.build_type }} ${{ matrix.lib_type }} 36 + name: ${{ matrix.os }} ${{ matrix.build_type }} ${{ matrix.lib_type }} tts-${{ matrix.tts }}
37 strategy: 37 strategy:
38 fail-fast: false 38 fail-fast: false
39 matrix: 39 matrix:
40 os: [ubuntu-latest, macos-latest] 40 os: [ubuntu-latest, macos-latest]
41 build_type: [Release, Debug] 41 build_type: [Release, Debug]
42 lib_type: [shared, static] 42 lib_type: [shared, static]
  43 + tts: [ON, OFF]
43 44
44 steps: 45 steps:
45 - uses: actions/checkout@v4 46 - uses: actions/checkout@v4
@@ -67,12 +68,12 @@ jobs: @@ -67,12 +68,12 @@ jobs:
67 mkdir build 68 mkdir build
68 cd build 69 cd build
69 if [[ ${{ matrix.lib_type }} == "shared" ]]; then 70 if [[ ${{ matrix.lib_type }} == "shared" ]]; then
70 - cmake -DSHERPA_ONNX_ENABLE_C_API=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=./install -DBUILD_SHARED_LIBS=ON .. 71 + cmake -DSHERPA_ONNX_ENABLE_TTS=${{ matrix.tts }} -DSHERPA_ONNX_ENABLE_C_API=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=./install -DBUILD_SHARED_LIBS=ON ..
71 else 72 else
72 - cmake -DSHERPA_ONNX_ENABLE_C_API=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=./install -DBUILD_SHARED_LIBS=OFF .. 73 + cmake -DSHERPA_ONNX_ENABLE_TTS=${{ matrix.tts }} -DSHERPA_ONNX_ENABLE_C_API=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=./install -DBUILD_SHARED_LIBS=OFF ..
73 fi 74 fi
74 75
75 - - name: Build sherpa-onnx for ${{ matrix.os }} ${{ matrix.build_type }} ${{ matrix.lib_type }} 76 + - name: Build sherpa-onnx for ${{ matrix.os }} ${{ matrix.build_type }} ${{ matrix.lib_type }} tts-${{ matrix.tts }}
76 shell: bash 77 shell: bash
77 run: | 78 run: |
78 export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" 79 export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
@@ -104,16 +105,36 @@ jobs: @@ -104,16 +105,36 @@ jobs:
104 105
105 cat build/install/sherpa-onnx.pc 106 cat build/install/sherpa-onnx.pc
106 107
  108 + - name: Show pkg-config
  109 + shell: bash
  110 + run: |
  111 + export PKG_CONFIG_PATH=$PWD/build/install:$PKG_CONFIG_PATH
  112 + pkg-config --cflags sherpa-onnx
  113 + pkg-config --libs sherpa-onnx
  114 +
107 - name: Build C API example 115 - name: Build C API example
108 shell: bash 116 shell: bash
109 run: | 117 run: |
110 export PKG_CONFIG_PATH=$PWD/build/install:$PKG_CONFIG_PATH 118 export PKG_CONFIG_PATH=$PWD/build/install:$PKG_CONFIG_PATH
111 cd c-api-examples 119 cd c-api-examples
112 120
  121 + pkg-config --cflags sherpa-onnx
  122 +
113 gcc -o decode-file-c-api $(pkg-config --cflags sherpa-onnx) ./decode-file-c-api.c $(pkg-config --libs sherpa-onnx) 123 gcc -o decode-file-c-api $(pkg-config --cflags sherpa-onnx) ./decode-file-c-api.c $(pkg-config --libs sherpa-onnx)
  124 +
114 ./decode-file-c-api --help 125 ./decode-file-c-api --help
115 126
  127 + - name: Build C API example (tts)
  128 + if: matrix.tts == 'ON'
  129 + shell: bash
  130 + run: |
  131 + export PKG_CONFIG_PATH=$PWD/build/install:$PKG_CONFIG_PATH
  132 + cd c-api-examples
  133 +
  134 + pkg-config --cflags sherpa-onnx
  135 +
116 gcc -o offline-tts-c-api $(pkg-config --cflags sherpa-onnx) ./offline-tts-c-api.c $(pkg-config --libs sherpa-onnx) 136 gcc -o offline-tts-c-api $(pkg-config --cflags sherpa-onnx) ./offline-tts-c-api.c $(pkg-config --libs sherpa-onnx)
  137 +
117 ./offline-tts-c-api --help 138 ./offline-tts-c-api --help
118 139
119 - name: Test online transducer (C API) 140 - name: Test online transducer (C API)
@@ -126,5 +147,5 @@ jobs: @@ -126,5 +147,5 @@ jobs:
126 147
127 - uses: actions/upload-artifact@v4 148 - uses: actions/upload-artifact@v4
128 with: 149 with:
129 - name: tts-generated-test-files-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.lib_type }} 150 + name: tts-generated-test-files-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.lib_type }}-tts-${{ matrix.tts }}
130 path: tts 151 path: tts
@@ -22,4 +22,4 @@ Cflags: -I"${includedir}" @@ -22,4 +22,4 @@ Cflags: -I"${includedir}"
22 # Note: -lcargs is required only for the following file 22 # Note: -lcargs is required only for the following file
23 # https://github.com/k2-fsa/sherpa-onnx/blob/master/c-api-examples/decode-file-c-api.c 23 # https://github.com/k2-fsa/sherpa-onnx/blob/master/c-api-examples/decode-file-c-api.c
24 # We add it here so that users don't need to specify -lcargs when compiling decode-file-c-api.c 24 # We add it here so that users don't need to specify -lcargs when compiling decode-file-c-api.c
25 -Libs: -L"${libdir}" -lsherpa-onnx-c-api -lsherpa-onnx-core -lkaldi-decoder-core -lsherpa-onnx-kaldifst-core -lsherpa-onnx-fst -lkaldi-native-fbank-core -lkissfft-float -lonnxruntime -lssentencepiece_core -Wl,-rpath,${libdir} @SHERPA_ONNX_PKG_WITH_CARGS@ @SHERPA_ONNX_PKG_CONFIG_EXTRA_LIBS@ 25 +Libs: -L"${libdir}" -lsherpa-onnx-c-api -lsherpa-onnx-core -lkaldi-decoder-core -lsherpa-onnx-kaldifst-core -lsherpa-onnx-fstfar -lsherpa-onnx-fst -lkaldi-native-fbank-core -lkissfft-float -lonnxruntime -lssentencepiece_core -Wl,-rpath,${libdir} @SHERPA_ONNX_PKG_WITH_CARGS@ @SHERPA_ONNX_PKG_CONFIG_EXTRA_LIBS@