feat: 添加 MNN 链接方式支持,允许使用预编译的动态库和静态库 #79
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust | |
| on: | |
| push: | |
| branches: [ "*" ] | |
| pull_request: | |
| branches: [ "*" ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build-and-test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux x86_64 | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| # Windows x86_64 | |
| - os: windows-2022 | |
| target: x86_64-pc-windows-msvc | |
| # macOS x86_64 | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| # Linux ARM64 | |
| - os: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| # macOS ARM64 | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| # Windows x86 | |
| - os: windows-2022 | |
| target: i686-pc-windows-msvc | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| override: true | |
| target: ${{ matrix.target }} | |
| - name: Setup Windows Build Environment | |
| if: matrix.os == 'windows-2022' | |
| run: | | |
| echo "RUSTFLAGS=-C target-feature=+crt-static" >> $GITHUB_ENV | |
| echo "LIBCLANG_PATH=C:\Program Files\LLVM\bin" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Install Cross-Compilation Dependencies | |
| if: contains(matrix.target, 'aarch64-unknown-linux-gnu') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| shell: bash | |
| - name: Set Cross-Compilation Environment Variables | |
| if: contains(matrix.target, 'aarch64-unknown-linux-gnu') | |
| run: | | |
| echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
| echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV | |
| echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar" >> $GITHUB_ENV | |
| echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Build | |
| uses: actions-rs/cargo@v1 | |
| with: | |
| command: build | |
| args: --verbose ${{ matrix.os == 'windows-2022' && '--release' || '' }} --target ${{ matrix.target }} | |
| - name: Run tests | |
| if: contains(matrix.target, 'x86_64') | |
| uses: actions-rs/cargo@v1 | |
| with: | |
| command: test | |
| args: --verbose ${{ matrix.os == 'windows-2022' && '--release' || '' }} --target ${{ matrix.target }} | |