From a55ac07f999f62bf5ddcdbb1a3912071196287bf Mon Sep 17 00:00:00 2001 From: Masahiro Sakai Date: Sun, 10 Nov 2024 00:05:55 +0900 Subject: [PATCH] GitHub Actions: build x86_64 and aarch64 binaries for macos --- .github/workflows/build.yaml | 33 ++++++++++++++++++++++++++++----- misc/build_artifacts.hs | 2 +- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ef977986..90aef69b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -34,11 +34,19 @@ jobs: coveralls: false release: true - ghc: '9.6.6' - os: macos-13 # Intel Mac + os: macos-latest stack_yaml: 'stack-ghc-9.6.yaml' stack_args: '' flags: '--flag toysolver:BuildToyFMF --flag toysolver:BuildSamplePrograms --flag toysolver:BuildMiscPrograms --flag toysolver:optparse-applicative-018' - platform: macos + platform: macos-aarch64 + coveralls: false + release: true + - ghc: '9.6.6' + os: macos-latest + stack_yaml: 'stack-ghc-9.6.yaml' + stack_args: '' + flags: '--flag toysolver:BuildToyFMF --flag toysolver:BuildSamplePrograms --flag toysolver:BuildMiscPrograms --flag toysolver:optparse-applicative-018' + platform: macos-x86_64 coveralls: false release: true @@ -101,6 +109,11 @@ jobs: with: submodules: true + - name: Write arch to stack.yaml (macos-x86_64) + if: matrix.platform == 'macos-x86_64' + run: | + echo "arch: x86_64" >> ${STACK_YAML} + - uses: haskell-actions/setup@v2 id: setup-haskell name: Setup Haskell @@ -108,9 +121,11 @@ jobs: ghc-version: ${{ matrix.ghc }} enable-stack: true stack-version: 'latest' + stack-no-global: ${{ (matrix.platform == 'macos-x86_64' || matrix.platform == 'win32') && 'true' || '' }} cabal-update: false - - name: Setup stack + - name: Setup stack to use system GHC + if: matrix.platform != 'macos-x86_64' && matrix.platform != 'win32' run: stack config set system-ghc --global true #- name: Fix ld path (Windows) @@ -166,7 +181,11 @@ jobs: - name: Test IPASIR DLL using genipaessentials shell: bash run: | - stack exec -- g++ -Wall -Iapp/toysat-ipasir/ misc/genipaessentials/genipaessentials.cpp -L`stack path --local-install-root`/lib -ltoysat-ipasir -o genipaessentials + if [[ ${{ matrix.platform }} = "macos-x86_64" ]]; then + stack exec -- arch -x86_64 g++ -Wall -Iapp/toysat-ipasir/ misc/genipaessentials/genipaessentials.cpp -L`stack path --local-install-root`/lib -ltoysat-ipasir -o genipaessentials + else + stack exec -- g++ -Wall -Iapp/toysat-ipasir/ misc/genipaessentials/genipaessentials.cpp -L`stack path --local-install-root`/lib -ltoysat-ipasir -o genipaessentials + fi if [[ ${{ runner.os }} = "macOS" ]]; then install_name_tool -add_rpath `stack path --local-install-root`/lib genipaessentials elif [[ ${{ runner.os }} = "Windows" ]]; then @@ -220,7 +239,11 @@ jobs: path: binary-packages - uses: actions/download-artifact@v4 with: - name: binary-packages-macos + name: binary-packages-macos-aarch64 + path: binary-packages + - uses: actions/download-artifact@v4 + with: + name: binary-packages-macos-x86_64 path: binary-packages - uses: actions/download-artifact@v4 with: diff --git a/misc/build_artifacts.hs b/misc/build_artifacts.hs index 6500c2da..c3ca01c5 100644 --- a/misc/build_artifacts.hs +++ b/misc/build_artifacts.hs @@ -23,7 +23,7 @@ main = sh $ do case Info.os of "mingw32" -> (if Info.arch == "x86_64" then "win64" else "win32", Just "exe", archive7z) "linux" -> ("linux-" ++ Info.arch, Nothing, archiveTarXz) - "darwin" -> ("macos", Nothing, archiveTarXz) + "darwin" -> ("macos-" ++ Info.arch, Nothing, archiveTarXz) _ -> error ("unknown os: " ++ Info.os) exe_files = [ "toyconvert"