Build Universal Binary on MacOS and add to cmake.yml (#76) #148
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: CMake | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| branches: [ master ] | |
| env: | |
| # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | |
| BUILD_TYPE: Release | |
| jobs: | |
| build: | |
| # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. | |
| # You can convert this to a matrix build if you need cross-platform coverage. | |
| # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | |
| name: ${{ matrix.config.name }} | |
| runs-on: ${{ matrix.config.os }} | |
| strategy: | |
| matrix: | |
| config: | |
| - { | |
| name: "Windows_Latest_MSVC", | |
| os: windows-latest, | |
| artifact: "windows_msvc", | |
| atrifact_path: "build/src/Release", | |
| build_type: "Release", | |
| cc: "cl", | |
| cxx: "cl", | |
| environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat", | |
| generators: "Visual Studio 16 2019" | |
| } | |
| - { | |
| name: "Ubuntu_Latest_GCC", | |
| os: ubuntu-latest, | |
| artifact: "ubuntu_gcc.7z", | |
| atrifact_path: "build/src/atracdenc", | |
| build_type: "Release", | |
| cc: "gcc", | |
| cxx: "g++", | |
| generators: "make" | |
| } | |
| - { | |
| name: "MacOS_Latest_Clang", | |
| os: macos-latest, | |
| artifact: "mac_clang.7z", | |
| atrifact_path: "build/src/atracdenc", | |
| build_type: "Release", | |
| cc: "clang", | |
| cxx: "clang++", | |
| generators: "make" | |
| } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| # install dependencies | |
| - name: Install dependencies on windows | |
| if: startsWith(matrix.config.os,'Windows') | |
| run: | | |
| choco install cmake | |
| cmake --version | |
| - name: Install dependencies on ubuntu | |
| if: startsWith(matrix.config.name,'Ubuntu_Latest_GCC') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -yq libsndfile1 libsndfile1-dev cmake googletest libgtest-dev | |
| cmake --version | |
| gcc --version | |
| # have to libsndfile as not installed by default and no package manager on MacOS. | |
| - name: Install dependencies on mac | |
| if: startsWith(matrix.config.name,'MacOS_Latest_Clang') | |
| run: | | |
| git clone https://github.com/libsndfile/libsndfile.git --recursive | |
| cd libsndfile | |
| cmake -B build -DBUILD_SHARED_LIBS=off -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" | |
| cd build | |
| sudo make install | |
| cd ../.. | |
| rm -rf libsndfile | |
| - name: Configure CMake | |
| # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | |
| # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | |
| run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} | |
| - name: Build | |
| # Build your program with the given configuration | |
| run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} | |
| - name: Upload | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| path: ${{ matrix.config.atrifact_path }} | |
| name: ${{ matrix.config.artifact }} | |
| - name: Test | |
| working-directory: ${{github.workspace}}/build | |
| # Execute tests defined by the CMake configuration. | |
| # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | |
| run: ctest -C ${{env.BUILD_TYPE}} | |
| msys2: | |
| name: Windows_Latest_MSYS2 | |
| runs-on: windows-latest | |
| defaults: | |
| run: | |
| shell: msys2 {0} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: MINGW64 | |
| update: true | |
| install: >- | |
| git | |
| mingw-w64-x86_64-cmake | |
| mingw-w64-x86_64-gcc | |
| mingw-w64-x86_64-gtest | |
| mingw-w64-x86_64-libsndfile | |
| mingw-w64-x86_64-ninja | |
| mingw-w64-x86_64-python | |
| - name: Configure CMake | |
| run: > | |
| cmake -S . -B build-msys2 -G Ninja | |
| -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} | |
| -DATRACDENC_PCM_IO_BACKEND=libsndfile | |
| - name: Build | |
| run: cmake --build build-msys2 | |
| - name: Package | |
| run: bash tools/package-msys2-runtime.sh build-msys2/src/atracdenc.exe dist-msys2 | |
| - name: Upload | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| path: dist-msys2 | |
| name: windows_msys2 | |
| - name: Test | |
| run: ctest --test-dir build-msys2 --output-on-failure |