Fangjun Kuang
Committed by GitHub

Support macOS (#14)

* support macos

* Update CI to test macos
1 -name: test-linux 1 +name: test-linux-macos
2 2
3 on: 3 on:
4 push: 4 push:
5 branches: 5 branches:
6 - master 6 - master
7 paths: 7 paths:
8 - - '.github/workflows/test-linux.yaml' 8 + - '.github/workflows/test-linux-macos.yaml'
9 - 'CMakeLists.txt' 9 - 'CMakeLists.txt'
10 - 'cmake/**' 10 - 'cmake/**'
11 - 'sherpa-onnx/csrc/*' 11 - 'sherpa-onnx/csrc/*'
@@ -13,13 +13,13 @@ on: @@ -13,13 +13,13 @@ on:
13 branches: 13 branches:
14 - master 14 - master
15 paths: 15 paths:
16 - - '.github/workflows/test-linux.yaml' 16 + - '.github/workflows/test-linux-macos.yaml'
17 - 'CMakeLists.txt' 17 - 'CMakeLists.txt'
18 - 'cmake/**' 18 - 'cmake/**'
19 - 'sherpa-onnx/csrc/*' 19 - 'sherpa-onnx/csrc/*'
20 20
21 concurrency: 21 concurrency:
22 - group: test-linux-${{ github.ref }} 22 + group: test-linux-macos-${{ github.ref }}
23 cancel-in-progress: true 23 cancel-in-progress: true
24 24
25 permissions: 25 permissions:
@@ -31,7 +31,7 @@ jobs: @@ -31,7 +31,7 @@ jobs:
31 strategy: 31 strategy:
32 fail-fast: false 32 fail-fast: false
33 matrix: 33 matrix:
34 - os: [ubuntu-latest] 34 + os: [ubuntu-latest, macos-latest]
35 35
36 steps: 36 steps:
37 - uses: actions/checkout@v2 37 - uses: actions/checkout@v2
@@ -51,12 +51,12 @@ jobs: @@ -51,12 +51,12 @@ jobs:
51 cd build 51 cd build
52 cmake -D CMAKE_BUILD_TYPE=Release .. 52 cmake -D CMAKE_BUILD_TYPE=Release ..
53 53
54 - - name: Build sherpa-onnx for ubuntu 54 + - name: Build sherpa-onnx for ubuntu/macos
55 run: | 55 run: |
56 cd build 56 cd build
57 make VERBOSE=1 -j3 57 make VERBOSE=1 -j3
58 58
59 - - name: Run tests for ubuntu (English) 59 + - name: Run tests for ubuntu/macos (English)
60 run: | 60 run: |
61 time ./build/bin/sherpa-onnx \ 61 time ./build/bin/sherpa-onnx \
62 ./icefall-asr-librispeech-pruned-transducer-stateless3-2022-05-13/exp/onnx/encoder.onnx \ 62 ./icefall-asr-librispeech-pruned-transducer-stateless3-2022-05-13/exp/onnx/encoder.onnx \
@@ -22,8 +22,17 @@ function(download_onnxruntime) @@ -22,8 +22,17 @@ function(download_onnxruntime)
22 # 22 #
23 # ./include 23 # ./include
24 # It contains all the needed header files 24 # It contains all the needed header files
  25 + elseif(APPLE)
  26 + set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.12.1/onnxruntime-osx-x86_64-1.12.1.tgz")
  27 + set(onnxruntime_HASH "SHA256=10921c2e75817edcbfc8b29882612be07e25dd33c8449d5892a9d45588898099")
  28 + # After downloading, it contains:
  29 + # ./lib/libonnxruntime.1.12.1.dylib
  30 + # ./lib/libonnxruntime.dylib, which is a symlink to lib/libonnxruntime.1.12.1.dylib
  31 + #
  32 + # ./include
  33 + # It contains all the needed header files
25 else() 34 else()
26 - message(FATAL_ERROR "Only support Linux at present. Will support other OSes later") 35 + message(FATAL_ERROR "Only support Linux and macOS at present. Will support other OSes later")
27 endif() 36 endif()
28 37
29 FetchContent_Declare(onnxruntime 38 FetchContent_Declare(onnxruntime