正在显示
7 个修改的文件
包含
437 行增加
和
1 行删除
.github/workflows/riscv64-linux.yaml
0 → 100644
| 1 | +name: riscv64-linux | ||
| 2 | + | ||
| 3 | +on: | ||
| 4 | + push: | ||
| 5 | + branches: | ||
| 6 | + - master | ||
| 7 | + paths: | ||
| 8 | + - '.github/workflows/riscv64-linux.yaml' | ||
| 9 | + - 'CMakeLists.txt' | ||
| 10 | + - 'cmake/**' | ||
| 11 | + - 'sherpa-onnx/csrc/*' | ||
| 12 | + - 'toolchains/riscv64-linux-gnu.toolchain.cmake' | ||
| 13 | + - 'build-riscv64-linux-gnu.sh' | ||
| 14 | + tags: | ||
| 15 | + - '*' | ||
| 16 | + pull_request: | ||
| 17 | + branches: | ||
| 18 | + - master | ||
| 19 | + paths: | ||
| 20 | + - '.github/workflows/riscv64-linux.yaml' | ||
| 21 | + - 'CMakeLists.txt' | ||
| 22 | + - 'cmake/**' | ||
| 23 | + - 'sherpa-onnx/csrc/*' | ||
| 24 | + - 'toolchains/riscv64-linux-gnu.toolchain.cmake' | ||
| 25 | + - 'build-riscv64-linux-gnu.sh' | ||
| 26 | + | ||
| 27 | + workflow_dispatch: | ||
| 28 | + | ||
| 29 | +concurrency: | ||
| 30 | + group: riscv64-linux-${{ github.ref }} | ||
| 31 | + cancel-in-progress: true | ||
| 32 | + | ||
| 33 | +jobs: | ||
| 34 | + riscv64_linux: | ||
| 35 | + runs-on: ${{ matrix.os }} | ||
| 36 | + name: ${{ matrix.os }} ${{ matrix.lib_type }} | ||
| 37 | + strategy: | ||
| 38 | + fail-fast: false | ||
| 39 | + matrix: | ||
| 40 | + os: [ubuntu-latest] | ||
| 41 | + lib_type: [static, shared] | ||
| 42 | + | ||
| 43 | + steps: | ||
| 44 | + - uses: actions/checkout@v4 | ||
| 45 | + with: | ||
| 46 | + fetch-depth: 0 | ||
| 47 | + | ||
| 48 | + - name: ccache | ||
| 49 | + uses: hendrikmuhs/ccache-action@v1.2 | ||
| 50 | + with: | ||
| 51 | + key: ${{ matrix.os }}-riscv64-${{ matrix.lib_type }} | ||
| 52 | + | ||
| 53 | + - name: cache-qemu | ||
| 54 | + id: cache-qemu | ||
| 55 | + uses: actions/cache@v4 | ||
| 56 | + with: | ||
| 57 | + path: qemu-install | ||
| 58 | + key: qemu-riscv-install-20240225 | ||
| 59 | + | ||
| 60 | + - name: install-qemu-build-deps | ||
| 61 | + if: steps.cache-qemu.outputs.cache-hit != 'true' | ||
| 62 | + run: | | ||
| 63 | + sudo apt-get update | ||
| 64 | + sudo apt-get install autoconf automake autotools-dev ninja-build | ||
| 65 | + | ||
| 66 | + - name: checkout-qemu | ||
| 67 | + if: steps.cache-qemu.outputs.cache-hit != 'true' | ||
| 68 | + uses: actions/checkout@v3 | ||
| 69 | + with: | ||
| 70 | + repository: qemu/qemu | ||
| 71 | + path: qemu | ||
| 72 | + | ||
| 73 | + - name: qemu | ||
| 74 | + if: steps.cache-qemu.outputs.cache-hit != 'true' | ||
| 75 | + run: | | ||
| 76 | + cd qemu | ||
| 77 | + ./configure --prefix=$GITHUB_WORKSPACE/qemu-install --target-list=riscv64-linux-user --disable-system | ||
| 78 | + make -j2 | ||
| 79 | + make install | ||
| 80 | + ls -lh $GITHUB_WORKSPACE/qemu-install | ||
| 81 | + ls -lh $GITHUB_WORKSPACE/qemu-install/bin | ||
| 82 | + | ||
| 83 | + - name: cache-toolchain | ||
| 84 | + id: cache-toolchain | ||
| 85 | + uses: actions/cache@v4 | ||
| 86 | + with: | ||
| 87 | + path: toolchain | ||
| 88 | + key: riscv64-glibc-ubuntu-20.04-gcc-nightly-2023.10.17-nightly | ||
| 89 | + | ||
| 90 | + - name: Download toolchain | ||
| 91 | + if: steps.cache-toolchain.outputs.cache-hit != 'true' | ||
| 92 | + shell: bash | ||
| 93 | + run: | | ||
| 94 | + mkdir $GITHUB_WORKSPACE/toolchain | ||
| 95 | + wget -q https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2023.10.17/riscv64-glibc-ubuntu-20.04-gcc-nightly-2023.10.17-nightly.tar.gz | ||
| 96 | + tar xvf ./riscv64-glibc-ubuntu-20.04-gcc-nightly-2023.10.17-nightly.tar.gz --strip-components 1 -C $GITHUB_WORKSPACE/toolchain | ||
| 97 | + | ||
| 98 | + - name: Display toolchain info | ||
| 99 | + shell: bash | ||
| 100 | + run: | | ||
| 101 | + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH | ||
| 102 | + riscv64-unknown-linux-gnu-gcc --version | ||
| 103 | + | ||
| 104 | + - name: Display qemu-riscv64 -h | ||
| 105 | + shell: bash | ||
| 106 | + run: | | ||
| 107 | + export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH | ||
| 108 | + export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot | ||
| 109 | + qemu-riscv64 -h | ||
| 110 | + | ||
| 111 | + - name: build riscv64-linux | ||
| 112 | + shell: bash | ||
| 113 | + run: | | ||
| 114 | + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH | ||
| 115 | + | ||
| 116 | + export CMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| 117 | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
| 118 | + | ||
| 119 | + cmake --version | ||
| 120 | + | ||
| 121 | + lib_type=${{ matrix.lib_type }} | ||
| 122 | + | ||
| 123 | + if [[ $lib_type == "shared" ]]; then | ||
| 124 | + export BUILD_SHARED_LIBS=ON | ||
| 125 | + else | ||
| 126 | + export BUILD_SHARED_LIBS=OFF | ||
| 127 | + fi | ||
| 128 | + | ||
| 129 | + ./build-riscv64-linux-gnu.sh | ||
| 130 | + | ||
| 131 | + ls -lh build-riscv64-linux-gnu/bin | ||
| 132 | + ls -lh build-riscv64-linux-gnu/lib | ||
| 133 | + | ||
| 134 | + file build-riscv64-linux-gnu/bin/sherpa-onnx | ||
| 135 | + | ||
| 136 | + - name: Test sherpa-onnx | ||
| 137 | + shell: bash | ||
| 138 | + run: | | ||
| 139 | + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH | ||
| 140 | + export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH | ||
| 141 | + export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot | ||
| 142 | + | ||
| 143 | + ls -lh ./build-riscv64-linux-gnu/bin | ||
| 144 | + | ||
| 145 | + echo "----------sherpa-onnx----------" | ||
| 146 | + qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx --help | ||
| 147 | + readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx | ||
| 148 | + | ||
| 149 | + echo "----------sherpa-onnx-offline----------" | ||
| 150 | + qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline --help | ||
| 151 | + readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline | ||
| 152 | + | ||
| 153 | + echo "----------sherpa-onnx-offline-tts----------" | ||
| 154 | + qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts --help | ||
| 155 | + readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts | ||
| 156 | + | ||
| 157 | + - name: Copy files | ||
| 158 | + shell: bash | ||
| 159 | + run: | | ||
| 160 | + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH | ||
| 161 | + riscv64-unknown-linux-gnu-strip --version | ||
| 162 | + | ||
| 163 | + SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | ||
| 164 | + | ||
| 165 | + dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-riscv64-${{ matrix.lib_type }} | ||
| 166 | + mkdir $dst | ||
| 167 | + | ||
| 168 | + ls -lh build-riscv64-linux-gnu/install/lib | ||
| 169 | + | ||
| 170 | + cp -a build-riscv64-linux-gnu/install/bin $dst/ | ||
| 171 | + ls -lh $dst/bin/* | ||
| 172 | + riscv64-unknown-linux-gnu-strip $dst/bin/* | ||
| 173 | + ls -lh $dst | ||
| 174 | + | ||
| 175 | + lib_type=${{ matrix.lib_type }} | ||
| 176 | + if [[ $lib_type == "shared" ]]; then | ||
| 177 | + cp -a build-riscv64-linux-gnu/install/lib $dst/ | ||
| 178 | + rm -fv $dst/lib/libasound.so | ||
| 179 | + rm -fv $dst/lib/libonnxruntime.so | ||
| 180 | + rm -fv $dst/lib/libsherpa-onnx-fst.so | ||
| 181 | + fi | ||
| 182 | + | ||
| 183 | + tree $dst | ||
| 184 | + | ||
| 185 | + tar cjvf ${dst}.tar.bz2 $dst | ||
| 186 | + | ||
| 187 | + - uses: actions/upload-artifact@v4 | ||
| 188 | + if: matrix.lib_type == 'shared' | ||
| 189 | + with: | ||
| 190 | + name: sherpa-onnx-linux-riscv64-shared | ||
| 191 | + path: sherpa-onnx-*linux-riscv64-shared.tar.bz2 | ||
| 192 | + | ||
| 193 | + - uses: actions/upload-artifact@v4 | ||
| 194 | + if: matrix.lib_type == 'static' | ||
| 195 | + with: | ||
| 196 | + name: sherpa-onnx-linux-riscv64-static | ||
| 197 | + path: sherpa-onnx-*linux-riscv64-static.tar.bz2 | ||
| 198 | + | ||
| 199 | + - name: Release pre-compiled binaries and libs for riscv64 linux ${{ matrix.lib_type }} | ||
| 200 | + if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') | ||
| 201 | + uses: svenstaro/upload-release-action@v2 | ||
| 202 | + with: | ||
| 203 | + file_glob: true | ||
| 204 | + overwrite: true | ||
| 205 | + file: sherpa-onnx-*linux-riscv64*.tar.bz2 |
build-riscv64-linux-gnu.sh
0 → 100755
| 1 | +#!/usr/bin/env bash | ||
| 2 | + | ||
| 3 | +if ! command -v riscv64-unknown-linux-gnu-g++ &> /dev/null; then | ||
| 4 | + echo "Please install the toolchain first." | ||
| 5 | + echo | ||
| 6 | + echo "You can use the following command to install the toolchain:" | ||
| 7 | + echo | ||
| 8 | + echo " mkdir -p $HOME/software" | ||
| 9 | + echo " cd $HOME/software" | ||
| 10 | + echo " mkdir riscv64-glibc-ubuntu-18.04-nightly-2022.11.12-nightly" | ||
| 11 | + echo " cd riscv64-glibc-ubuntu-18.04-nightly-2022.11.12-nightly" | ||
| 12 | + echo " wget https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2022.11.12/riscv64-glibc-ubuntu-18.04-nightly-2022.11.12-nightly.tar.gz" | ||
| 13 | + echo " tar xvf riscv64-glibc-ubuntu-18.04-nightly-2022.11.12-nightly.tar.gz --strip-components=1" | ||
| 14 | + echo " export PATH=$HOME/software/riscv64-glibc-ubuntu-18.04-nightly-2022.11.12-nightly/bin" | ||
| 15 | + echo | ||
| 16 | + exit 1 | ||
| 17 | +fi | ||
| 18 | + | ||
| 19 | +if [ x$dir = x"" ]; then | ||
| 20 | + dir=build-riscv64-linux-gnu | ||
| 21 | +fi | ||
| 22 | +mkdir -p $dir | ||
| 23 | +cd $dir | ||
| 24 | + | ||
| 25 | +if [ ! -f alsa-lib/src/.libs/libasound.so ]; then | ||
| 26 | + echo "Start to cross-compile alsa-lib" | ||
| 27 | + if [ ! -d alsa-lib ]; then | ||
| 28 | + git clone --depth 1 https://github.com/alsa-project/alsa-lib | ||
| 29 | + fi | ||
| 30 | + # If it shows: | ||
| 31 | + # ./gitcompile: line 79: libtoolize: command not found | ||
| 32 | + # Please use: | ||
| 33 | + # sudo apt-get install libtool m4 automake | ||
| 34 | + # | ||
| 35 | + pushd alsa-lib | ||
| 36 | + CC=riscv64-unknown-linux-gnu-gcc ./gitcompile --host=riscv64-unknown-linux-gnu | ||
| 37 | + popd | ||
| 38 | + echo "Finish cross-compiling alsa-lib" | ||
| 39 | +fi | ||
| 40 | + | ||
| 41 | +export CPLUS_INCLUDE_PATH=$PWD/alsa-lib/include:$CPLUS_INCLUDE_PATH | ||
| 42 | +export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs | ||
| 43 | + | ||
| 44 | +if [[ x"$BUILD_SHARED_LIBS" == x"" ]]; then | ||
| 45 | + # By default, use static link | ||
| 46 | + BUILD_SHARED_LIBS=OFF | ||
| 47 | +fi | ||
| 48 | + | ||
| 49 | +cmake \ | ||
| 50 | + -DBUILD_PIPER_PHONMIZE_EXE=OFF \ | ||
| 51 | + -DBUILD_PIPER_PHONMIZE_TESTS=OFF \ | ||
| 52 | + -DBUILD_ESPEAK_NG_EXE=OFF \ | ||
| 53 | + -DBUILD_ESPEAK_NG_TESTS=OFF \ | ||
| 54 | + -DCMAKE_INSTALL_PREFIX=./install \ | ||
| 55 | + -DCMAKE_BUILD_TYPE=Release \ | ||
| 56 | + -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS \ | ||
| 57 | + -DSHERPA_ONNX_ENABLE_TESTS=OFF \ | ||
| 58 | + -DSHERPA_ONNX_ENABLE_PYTHON=OFF \ | ||
| 59 | + -DSHERPA_ONNX_ENABLE_CHECK=OFF \ | ||
| 60 | + -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ | ||
| 61 | + -DSHERPA_ONNX_ENABLE_JNI=OFF \ | ||
| 62 | + -DSHERPA_ONNX_ENABLE_C_API=OFF \ | ||
| 63 | + -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \ | ||
| 64 | + -DCMAKE_TOOLCHAIN_FILE=../toolchains/riscv64-linux-gnu.toolchain.cmake \ | ||
| 65 | + .. | ||
| 66 | + | ||
| 67 | +make VERBOSE=1 -j4 | ||
| 68 | +make install/strip | ||
| 69 | + | ||
| 70 | +# Enable it if only needed | ||
| 71 | +# cp -v $SHERPA_ONNX_ALSA_LIB_DIR/libasound.so* ./install/lib/ |
cmake/onnxruntime-linux-riscv64-static.cmake
0 → 100644
| 1 | +# Copyright (c) 2022-2024 Xiaomi Corporation | ||
| 2 | +message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") | ||
| 3 | +message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") | ||
| 4 | + | ||
| 5 | +if(NOT CMAKE_SYSTEM_NAME STREQUAL Linux) | ||
| 6 | + message(FATAL_ERROR "This file is for Linux only. Given: ${CMAKE_SYSTEM_NAME}") | ||
| 7 | +endif() | ||
| 8 | + | ||
| 9 | +if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL riscv64) | ||
| 10 | + message(FATAL_ERROR "This file is for riscv64 only. Given: ${CMAKE_SYSTEM_PROCESSOR}") | ||
| 11 | +endif() | ||
| 12 | + | ||
| 13 | +if(BUILD_SHARED_LIBS) | ||
| 14 | + message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") | ||
| 15 | +endif() | ||
| 16 | + | ||
| 17 | +set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.18.0/onnxruntime-linux-riscv64-static_lib-1.18.0.zip") | ||
| 18 | +set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.18.0/onnxruntime-linux-riscv64-static_lib-1.18.0.zip") | ||
| 19 | +set(onnxruntime_HASH "SHA256=6791d695d17118db6815364c975a9d7ea9a8909754516ed1b089fe015c20912e") | ||
| 20 | + | ||
| 21 | +# If you don't have access to the Internet, | ||
| 22 | +# please download onnxruntime to one of the following locations. | ||
| 23 | +# You can add more if you want. | ||
| 24 | +set(possible_file_locations | ||
| 25 | + $ENV{HOME}/Downloads/onnxruntime-linux-riscv64-static_lib-1.18.0.zip | ||
| 26 | + ${CMAKE_SOURCE_DIR}/onnxruntime-linux-riscv64-static_lib-1.18.0.zip | ||
| 27 | + ${CMAKE_BINARY_DIR}/onnxruntime-linux-riscv64-static_lib-1.18.0.zip | ||
| 28 | + /tmp/onnxruntime-linux-riscv64-static_lib-1.18.0.zip | ||
| 29 | + /star-fj/fangjun/download/github/onnxruntime-linux-riscv64-static_lib-1.18.0.zip | ||
| 30 | +) | ||
| 31 | + | ||
| 32 | +foreach(f IN LISTS possible_file_locations) | ||
| 33 | + if(EXISTS ${f}) | ||
| 34 | + set(onnxruntime_URL "${f}") | ||
| 35 | + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL) | ||
| 36 | + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}") | ||
| 37 | + set(onnxruntime_URL2) | ||
| 38 | + break() | ||
| 39 | + endif() | ||
| 40 | +endforeach() | ||
| 41 | + | ||
| 42 | +FetchContent_Declare(onnxruntime | ||
| 43 | + URL | ||
| 44 | + ${onnxruntime_URL} | ||
| 45 | + ${onnxruntime_URL2} | ||
| 46 | + URL_HASH ${onnxruntime_HASH} | ||
| 47 | +) | ||
| 48 | + | ||
| 49 | +FetchContent_GetProperties(onnxruntime) | ||
| 50 | +if(NOT onnxruntime_POPULATED) | ||
| 51 | + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}") | ||
| 52 | + FetchContent_Populate(onnxruntime) | ||
| 53 | +endif() | ||
| 54 | +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}") | ||
| 55 | + | ||
| 56 | +# for static libraries, we use onnxruntime_lib_files directly below | ||
| 57 | +include_directories(${onnxruntime_SOURCE_DIR}/include) | ||
| 58 | + | ||
| 59 | +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/lib*.a") | ||
| 60 | + | ||
| 61 | +set(onnxruntime_lib_files ${onnxruntime_lib_files} PARENT_SCOPE) | ||
| 62 | + | ||
| 63 | +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") | ||
| 64 | +install(FILES ${onnxruntime_lib_files} DESTINATION lib) |
cmake/onnxruntime-linux-riscv64.cmake
0 → 100644
| 1 | +# Copyright (c) 2022-2024 Xiaomi Corporation | ||
| 2 | +message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") | ||
| 3 | +message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") | ||
| 4 | + | ||
| 5 | +if(NOT CMAKE_SYSTEM_NAME STREQUAL Linux) | ||
| 6 | + message(FATAL_ERROR "This file is for Linux only. Given: ${CMAKE_SYSTEM_NAME}") | ||
| 7 | +endif() | ||
| 8 | + | ||
| 9 | +if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL riscv64) | ||
| 10 | + message(FATAL_ERROR "This file is for riscv64 only. Given: ${CMAKE_SYSTEM_PROCESSOR}") | ||
| 11 | +endif() | ||
| 12 | + | ||
| 13 | +if(NOT BUILD_SHARED_LIBS) | ||
| 14 | + message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") | ||
| 15 | +endif() | ||
| 16 | + | ||
| 17 | +set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.18.0/onnxruntime-linux-riscv64-1.18.0.zip") | ||
| 18 | +set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.18.0/onnxruntime-linux-riscv64-1.18.0.zip") | ||
| 19 | +set(onnxruntime_HASH "SHA256=87ef36dbba28ee332069e7e511dcb409913bdeeed231b45172fe200d71c690a2") | ||
| 20 | + | ||
| 21 | +# If you don't have access to the Internet, | ||
| 22 | +# please download onnxruntime to one of the following locations. | ||
| 23 | +# You can add more if you want. | ||
| 24 | +set(possible_file_locations | ||
| 25 | + $ENV{HOME}/Downloads/onnxruntime-linux-riscv64-1.18.0.zip | ||
| 26 | + ${CMAKE_SOURCE_DIR}/onnxruntime-linux-riscv64-1.18.0.zip | ||
| 27 | + ${CMAKE_BINARY_DIR}/onnxruntime-linux-riscv64-1.18.0.zip | ||
| 28 | + /tmp/onnxruntime-linux-riscv64-1.18.0.zip | ||
| 29 | + /star-fj/fangjun/download/github/onnxruntime-linux-riscv64-1.18.0.zip | ||
| 30 | +) | ||
| 31 | + | ||
| 32 | +foreach(f IN LISTS possible_file_locations) | ||
| 33 | + if(EXISTS ${f}) | ||
| 34 | + set(onnxruntime_URL "${f}") | ||
| 35 | + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL) | ||
| 36 | + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}") | ||
| 37 | + set(onnxruntime_URL2) | ||
| 38 | + break() | ||
| 39 | + endif() | ||
| 40 | +endforeach() | ||
| 41 | + | ||
| 42 | +FetchContent_Declare(onnxruntime | ||
| 43 | + URL | ||
| 44 | + ${onnxruntime_URL} | ||
| 45 | + ${onnxruntime_URL2} | ||
| 46 | + URL_HASH ${onnxruntime_HASH} | ||
| 47 | +) | ||
| 48 | + | ||
| 49 | +FetchContent_GetProperties(onnxruntime) | ||
| 50 | +if(NOT onnxruntime_POPULATED) | ||
| 51 | + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}") | ||
| 52 | + FetchContent_Populate(onnxruntime) | ||
| 53 | +endif() | ||
| 54 | +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}") | ||
| 55 | + | ||
| 56 | +find_library(location_onnxruntime onnxruntime | ||
| 57 | + PATHS | ||
| 58 | + "${onnxruntime_SOURCE_DIR}/lib" | ||
| 59 | + NO_CMAKE_SYSTEM_PATH | ||
| 60 | +) | ||
| 61 | + | ||
| 62 | +message(STATUS "location_onnxruntime: ${location_onnxruntime}") | ||
| 63 | + | ||
| 64 | +add_library(onnxruntime SHARED IMPORTED) | ||
| 65 | + | ||
| 66 | +set_target_properties(onnxruntime PROPERTIES | ||
| 67 | + IMPORTED_LOCATION ${location_onnxruntime} | ||
| 68 | + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include/onnxruntime" | ||
| 69 | +) | ||
| 70 | + | ||
| 71 | +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*") | ||
| 72 | +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") | ||
| 73 | +install(FILES ${onnxruntime_lib_files} DESTINATION lib) |
| @@ -6,6 +6,12 @@ function(download_onnxruntime) | @@ -6,6 +6,12 @@ function(download_onnxruntime) | ||
| 6 | message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") | 6 | message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") |
| 7 | if(SHERPA_ONNX_ENABLE_WASM) | 7 | if(SHERPA_ONNX_ENABLE_WASM) |
| 8 | include(onnxruntime-wasm-simd) | 8 | include(onnxruntime-wasm-simd) |
| 9 | + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL riscv64) | ||
| 10 | + if(BUILD_SHARED_LIBS) | ||
| 11 | + include(onnxruntime-linux-riscv64) | ||
| 12 | + else() | ||
| 13 | + include(onnxruntime-linux-riscv64-static) | ||
| 14 | + endif() | ||
| 9 | elseif(CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) | 15 | elseif(CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) |
| 10 | if(BUILD_SHARED_LIBS) | 16 | if(BUILD_SHARED_LIBS) |
| 11 | include(onnxruntime-linux-aarch64) | 17 | include(onnxruntime-linux-aarch64) |
| @@ -2,7 +2,7 @@ function(download_piper_phonemize) | @@ -2,7 +2,7 @@ function(download_piper_phonemize) | ||
| 2 | include(FetchContent) | 2 | include(FetchContent) |
| 3 | 3 | ||
| 4 | set(piper_phonemize_URL "https://github.com/csukuangfj/piper-phonemize/archive/dc6b5f4441bffe521047086930b0fc12686acd56.zip") | 4 | set(piper_phonemize_URL "https://github.com/csukuangfj/piper-phonemize/archive/dc6b5f4441bffe521047086930b0fc12686acd56.zip") |
| 5 | - set(piper_phonemize_URL2 "") | 5 | + set(piper_phonemize_URL2 "https://hub.nuaa.cf/csukuangfj/piper-phonemize/archive/dc6b5f4441bffe521047086930b0fc12686acd56.zip") |
| 6 | set(piper_phonemize_HASH "SHA256=b9faa04204b1756fa455a962abb1f037041c040133d55be58d11f11ab9b3ce14") | 6 | set(piper_phonemize_HASH "SHA256=b9faa04204b1756fa455a962abb1f037041c040133d55be58d11f11ab9b3ce14") |
| 7 | 7 | ||
| 8 | # If you don't have access to the Internet, | 8 | # If you don't have access to the Internet, |
toolchains/riscv64-linux-gnu.toolchain.cmake
0 → 100644
| 1 | +# Copied from https://github.com/Tencent/ncnn/blob/master/toolchains/riscv64-linux-gnu.toolchain.cmake | ||
| 2 | +set(CMAKE_SYSTEM_NAME Linux) | ||
| 3 | +set(CMAKE_SYSTEM_PROCESSOR riscv64) | ||
| 4 | + | ||
| 5 | +set(CMAKE_C_COMPILER "riscv64-unknown-linux-gnu-gcc") | ||
| 6 | +set(CMAKE_CXX_COMPILER "riscv64-unknown-linux-gnu-g++") | ||
| 7 | + | ||
| 8 | +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
| 9 | +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
| 10 | +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
| 11 | + | ||
| 12 | +set(CMAKE_C_FLAGS "-march=rv64gc") | ||
| 13 | +set(CMAKE_CXX_FLAGS "-march=rv64gc") | ||
| 14 | + | ||
| 15 | +# cache flags | ||
| 16 | +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") | ||
| 17 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") |
-
请 注册 或 登录 后发表评论