|
| 1 | +name: Libspectrum for MacOS |
| 2 | +run-name: Build and test Libspectrum for MacOS / ${{ github.actor }} / |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + key: |
| 8 | + type: string |
| 9 | + required: true |
| 10 | + libspectrum_ref: |
| 11 | + type: string |
| 12 | + required: false |
| 13 | + default: master |
| 14 | + use_zlib: |
| 15 | + type: boolean |
| 16 | + required: false |
| 17 | + default: true |
| 18 | + use_bzip2: |
| 19 | + type: boolean |
| 20 | + required: false |
| 21 | + default: true |
| 22 | + use_libgcrypt: |
| 23 | + type: boolean |
| 24 | + required: false |
| 25 | + default: true |
| 26 | + use_fake_glib: |
| 27 | + type: boolean |
| 28 | + required: false |
| 29 | + default: false |
| 30 | + |
| 31 | +jobs: |
| 32 | + build: |
| 33 | + name: Build & Test |
| 34 | + runs-on: macos-26 |
| 35 | + timeout-minutes: 15 |
| 36 | + defaults: |
| 37 | + run: |
| 38 | + shell: bash |
| 39 | + env: |
| 40 | + LIBSPECTRUM_DIR: libspectrum |
| 41 | + LIBSPECTRUM_GIT_URL: https://git.code.sf.net/p/fuse-emulator/libspectrum |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: (1) Prepare environment |
| 45 | + run: | |
| 46 | + echo -n "Current directory: " |
| 47 | + pwd |
| 48 | + ls -la |
| 49 | +
|
| 50 | + echo "Libspectrum URL: $LIBSPECTRUM_GIT_URL" |
| 51 | + echo "Libspectrum ref: ${{ inputs.libspectrum_ref }}" |
| 52 | +
|
| 53 | + echo "Use lib zlib: ${{ inputs.use_zlib && 'yes' || 'no' }}" |
| 54 | + echo "Use lib bzip2: ${{ inputs.use_bzip2 && 'yes' || 'no' }}" |
| 55 | + echo "Use lib libgcrypt: ${{ inputs.use_libgcrypt && 'yes' || 'no' }}" |
| 56 | + echo "Use lib libaudiofile: no" |
| 57 | + echo "Use fake glib: ${{ inputs.use_fake_glib && 'yes' || 'no' }}" |
| 58 | +
|
| 59 | + - name: (2) Clone libspectrum source |
| 60 | + run: | |
| 61 | + git init "$LIBSPECTRUM_DIR" |
| 62 | + git -C "$LIBSPECTRUM_DIR" remote add origin "$LIBSPECTRUM_GIT_URL" |
| 63 | + git -C "$LIBSPECTRUM_DIR" fetch --depth 1 origin "${{ inputs.libspectrum_ref }}" |
| 64 | + git -C "$LIBSPECTRUM_DIR" checkout FETCH_HEAD |
| 65 | +
|
| 66 | + - name: (3) Install dependencies |
| 67 | + run: | |
| 68 | + echo "Inspect if brew installed .." |
| 69 | + brew doctor || true |
| 70 | +
|
| 71 | + echo "Installing dependencies .." |
| 72 | + brew install \ |
| 73 | + automake \ |
| 74 | + bzip2 \ |
| 75 | + libgcrypt \ |
| 76 | + libtool \ |
| 77 | + glib |
| 78 | +
|
| 79 | + echo "Configuring Homebrew search paths .." |
| 80 | + echo "CPPFLAGS=-I$(brew --prefix)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix libgcrypt)/include -I$(brew --prefix glib)/include" >> "$GITHUB_ENV" |
| 81 | + echo "LDFLAGS=-L$(brew --prefix)/lib -L$(brew --prefix bzip2)/lib -L$(brew --prefix libgcrypt)/lib -L$(brew --prefix glib)/lib" >> "$GITHUB_ENV" |
| 82 | + echo "PKG_CONFIG_PATH=$(brew --prefix)/lib/pkgconfig:$(brew --prefix bzip2)/lib/pkgconfig:$(brew --prefix libgcrypt)/lib/pkgconfig:$(brew --prefix glib)/lib/pkgconfig" >> "$GITHUB_ENV" |
| 83 | +
|
| 84 | + - name: (4) Autogen.sh |
| 85 | + working-directory: ${{ env.LIBSPECTRUM_DIR }} |
| 86 | + run: | |
| 87 | + echo "Running autogen.sh .." |
| 88 | + ./autogen.sh |
| 89 | +
|
| 90 | + - name: (5) Configure for MacOS |
| 91 | + working-directory: ${{ env.LIBSPECTRUM_DIR }} |
| 92 | + run: | |
| 93 | + echo "Running configure .." |
| 94 | + ./configure \ |
| 95 | + ${{ inputs.use_zlib == false && '--without-zlib' || '' }} \ |
| 96 | + ${{ inputs.use_bzip2 == false && '--without-bzip2' || '' }} \ |
| 97 | + ${{ inputs.use_libgcrypt == false && '--without-libgcrypt' || '' }} \ |
| 98 | + --without-libaudiofile \ |
| 99 | + ${{ inputs.use_fake_glib == true && '--with-fake-glib' || '' }} \ |
| 100 | + | tee ./configure.out |
| 101 | +
|
| 102 | + - name: (6) Verify output from configure |
| 103 | + working-directory: ${{ env.LIBSPECTRUM_DIR }} |
| 104 | + run: | |
| 105 | + .github/scripts/in_config.sh "libspectrum is ready to be compiled" |
| 106 | + .github/scripts/in_config.sh "zlib support: ${{ inputs.use_zlib && 'yes' || 'no' }}" |
| 107 | + .github/scripts/in_config.sh "bzip2 support: ${{ inputs.use_bzip2 && 'yes' || 'no' }}" |
| 108 | + .github/scripts/in_config.sh "libgcrypt support: ${{ inputs.use_libgcrypt && 'yes' || 'no' }}" |
| 109 | + .github/scripts/in_config.sh "libaudiofile support: no" |
| 110 | + .github/scripts/in_config.sh "Internal GLib replacement: ${{ inputs.use_fake_glib && 'yes' || 'no' }}" |
| 111 | +
|
| 112 | + - name: (7) Make |
| 113 | + working-directory: ${{ env.LIBSPECTRUM_DIR }} |
| 114 | + run: | |
| 115 | + echo "Running make .." |
| 116 | + make |
| 117 | +
|
| 118 | + - name: (8) Install |
| 119 | + working-directory: ${{ env.LIBSPECTRUM_DIR }} |
| 120 | + run: | |
| 121 | + echo "Running make install .." |
| 122 | + sudo make install |
| 123 | +
|
| 124 | + - name: (9) Run tests |
| 125 | + id: run-tests |
| 126 | + working-directory: ${{ env.LIBSPECTRUM_DIR }} |
| 127 | + run: | |
| 128 | + echo "Building and running tests .." |
| 129 | + make check |
| 130 | +
|
| 131 | + - name: (10) Verbose check tests (on failure) |
| 132 | + if: failure() && steps.run-tests.outcome != 'success' |
| 133 | + working-directory: ${{ env.LIBSPECTRUM_DIR }} |
| 134 | + run: | |
| 135 | + echo "Listing all tests individually .." |
| 136 | + test/test |
| 137 | +
|
| 138 | + - name: (11) Pack installed library files |
| 139 | + working-directory: ${{ env.LIBSPECTRUM_DIR }} |
| 140 | + run: | |
| 141 | + find /usr/local | grep libspectrum > .tar_files |
| 142 | + sudo tar -cvf \ |
| 143 | + libspectrum-installed-macos.tar \ |
| 144 | + -C /usr/local/ -T.tar_files |
| 145 | +
|
| 146 | + - name: (12) Upload generated tar file |
| 147 | + uses: actions/upload-artifact@v8 |
| 148 | + with: |
| 149 | + name: libspectrum-installed-macos-${{ inputs.key }} |
| 150 | + path: | |
| 151 | + ${{ env.LIBSPECTRUM_DIR }}/libspectrum-installed-macos.tar |
| 152 | +
|
| 153 | + - name: (13) Finish |
| 154 | + run: | |
| 155 | + echo "Finishing with status ${{ job.status }}." |
0 commit comments