shithub: m8c

ref: 3b59f68a2a9a66129567872251dee58b6cbbf131
dir: /.github/workflows/build-macos-intel.yml/

View raw version
name: m8c macos intel build 

on:
  push:
  pull_request:
  workflow_dispatch:

jobs:
     
  build-macos:
    runs-on: macos-14
    env:
      SDL_VERSION: 2.32.0
      SDL_SHA256: f5c2b52498785858f3de1e2996eba3c1b805d08fe168a47ea527c7fc339072d0

    steps:
      - name: 'Install dependencies'
        run: brew install cmake pkg-config autoconf automake libtool

      - name: 'Cache x86_64 files'
        id: cache-x86_64-files
        uses: actions/cache@v4
        with:
          path: '/Users/runner/x86_64'
          key: mac-x86_64-files
          
      - name: 'Download 10.7 SDK for x86_64'
        if: steps.cache-x86_64-files.outputs.cache-hit != 'true'
        run: |
          mkdir -p "$HOME/x86_64"
          pushd "$HOME/x86_64"
          mkdir SDKs
          cd SDKs
          curl -L "https://github.com/alexey-lysiuk/macos-sdk/releases/download/10.7/MacOSX10.7.tar.bz2" | tar -xvf -
          popd

      - name: 'Checkout'
        uses: actions/checkout@v4

      - name: Set current date as env variable
        run: echo "NOW=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

      - name: 'Cache SDL2 files'
        id: cache-x86_64-sdl2-files
        uses: actions/cache@v4
        with:
          path: 'SDL2-2.30.4'
          key: mac-x86_64-sdl2-files        
        
      - name: 'Download SDL2 sources'
        if: steps.cache-x86_64-sdl2-files.outputs.cache-hit != 'true'
        run: |
          (curl https://www.libsdl.org/release/SDL2-$SDL_VERSION.tar.gz || curl -L https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL2-$SDL_VERSION.tar.gz) | tar xvf -
        
      - name: 'Build SDL2'
        if: steps.cache-x86_64-sdl2-files.outputs.cache-hit != 'true'
        run: |
          export MACOSX_DEPLOYMENT_TARGET="10.9"
          pushd SDL2-$SDL_VERSION
          mkdir build_x86_64
          cd build_x86_64
          ../configure CPPFLAGS="-arch x86_64 -mmacosx-version-min=10.7 -DMAC_OS_X_VERSION_MIN_REQUIRED=1070 -isysroot $HOME/x86_64/SDKs/MacOSX10.7.sdk" CFLAGS="-arch x86_64" CXXFLAGS="-arch x86_64" LDFLAGS="-arch x86_64 -F$HOME/x86_64/SDKs/MacOSX10.7.sdk/System/Library/Frameworks -L/usr/lib -L/usr/lib/system -Wl,-syslibroot,$HOME/x86_64/SDKs/MacOSX10.7.sdk" --host=x86_64-apple-darwin13 --prefix="$HOME/x86_64prefix"
          make
          popd

      - name: 'Install SDL2'
        run: |
          pushd SDL2-$SDL_VERSION/build_x86_64
          make install 
          popd

      - name: 'Download libserialport sources'
        run: |
          curl -L -O https://github.com/sigrokproject/libserialport/archive/refs/heads/master.zip && unzip master.zip && rm master.zip
          
      - name: 'Build libserialport'
        run: |
          pushd libserialport-master
          mkdir autostuff
          autoreconf -I"$HOME/x86_64prefix/share/aclocal" -i
          export MACOSX_DEPLOYMENT_TARGET="10.7" && mkdir build_x86_64 && cd build_x86_64 && ../configure CFLAGS="-arch x86_64 -mmacosx-version-min=10.7 -DMAC_OS_X_VERSION_MIN_REQUIRED=1070 -isysroot $HOME/x86_64/SDKs/MacOSX10.7.sdk" LDFLAGS="-arch x86_64 -F$HOME/x86_64/SDKs/MacOSX10.7.sdk/System/Library/Frameworks -L/usr/lib -L/usr/lib/system -Wl,-syslibroot,$HOME/x86_64/SDKs/MacOSX10.7.sdk" --host=x86_64-apple-darwin13 --prefix="$HOME/x86_64prefix" && make && make install
          popd

      - name: 'Build m8c'
        run: |
          export MACOSX_DEPLOYMENT_TARGET="10.7" && export PKG_CONFIG_PATH="$HOME/x86_64prefix/lib/pkgconfig" && export CFLAGS="-arch x86_64 -mmacosx-version-min=10.7 -DMAC_OS_X_VERSION_MIN_REQUIRED=1070 -isysroot $HOME/x86_64/SDKs/MacOSX10.7.sdk" && mkdir build_x86_64 && cd build_x86_64 && cmake -DCMAKE_OSX_ARCHITECTURES="x86_64" .. && cpack -V

      - name: 'Build package'
        run: |
          mv build_x86_64/m8c-0.1.1-Darwin.dmg m8c-${{ env.NOW }}-macos-intel.dmg
      - name: 'Upload artifact'
        uses: actions/upload-artifact@v4
        with:
          name: m8c-${{ env.NOW }}-macos-intel
          path: |
            m8c-${{ env.NOW }}-macos-intel.dmg