Skip to content

Commit

Permalink
Merge pull request #1099 from tleedjarv/portable-make-9
Browse files Browse the repository at this point in the history
GHA: Use NMAKE with pure Windows builds
  • Loading branch information
gdt authored Dec 19, 2024
2 parents c9fc0bc + 1f76f53 commit 8db0681
Showing 1 changed file with 13 additions and 29 deletions.
42 changes: 13 additions & 29 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
name: CI

env:
PROJECT_NAME: unison
PROJECT_DESC: "`unison` file synchronizer"
PROJECT_EXES: "unison unison-fsmonitor"

on:
- pull_request
- push
Expand Down Expand Up @@ -101,12 +96,13 @@ jobs:
PKG_suffix='.tar.gz' ; case '${{ matrix.job.os }}' in windows-*) PKG_suffix='.zip' ;; esac;
PKG_VER="${REF_TAG:-git_$REF_SHAS}"
PKG_VER="${PKG_VER#v}"
PKG_BASENAME="${PROJECT_NAME}-${PKG_VER}${{ matrix.job.fnsuffix }}"
PKG_BASENAME="unison-${PKG_VER}${{ matrix.job.fnsuffix }}"
PKG_NAME="${PKG_BASENAME}${PKG_suffix}"
PKG_DIR="${STAGING_DIR}/${PKG_BASENAME}"
outputs PKG_VER PKG_BASENAME PKG_DIR PKG_NAME PKG_suffix
COMPRESS_CMD='tar czf'; case '${{ matrix.job.os }}' in windows-*) COMPRESS_CMD='7z -y a' ;; esac;
outputs COMPRESS_CMD
case '${{ matrix.job.ocaml-version }}' in *msvc*) echo "_MAKE=nmake" >> $GITHUB_ENV ;; *) echo "_MAKE=make" >> $GITHUB_ENV ;; esac
- name: Create/configure any needed build/workspace
shell: bash
Expand Down Expand Up @@ -135,22 +131,15 @@ jobs:
run: |
echo SHELLOPTS=igncr>> %GITHUB_ENV%
- shell: bash
- run: |
opam exec -- ${{ env._MAKE }} tui fsmonitor
# stage
cp "src/unison${{ steps.vars.outputs.EXE_suffix }}" "${{ steps.vars.outputs.PKG_DIR }}/bin" || echo unison${{ steps.vars.outputs.EXE_suffix }} not built
cp "src/unison-fsmonitor${{ steps.vars.outputs.EXE_suffix }}" "${{ steps.vars.outputs.PKG_DIR }}/bin" || echo unison-fsmonitor${{ steps.vars.outputs.EXE_suffix }} not built
env:
LDFLAGS: ${{ matrix.job.static }}
run: |
opam exec -- make tui
opam exec -- make fsmonitor
# stage
# * notes: darwin/macos doesn't build `unison-fsmonitor`
for file in ${PROJECT_EXES} ; do
if [ -f "src/${file}${{ steps.vars.outputs.EXE_suffix }}" ]; then
cp "src/${file}${{ steps.vars.outputs.EXE_suffix }}" '${{ steps.vars.outputs.PKG_DIR }}/bin'
echo "'src/${file}${{ steps.vars.outputs.EXE_suffix }}' copied to '${{ steps.vars.outputs.PKG_DIR }}/bin'"
fi
done
- run: opam exec -- make test
- run: opam exec -- ${{ env._MAKE }} test

## There is still code to run tests with old ocaml on Windows.
## That remains intentionally so that someone could turn it on if
Expand Down Expand Up @@ -456,26 +445,21 @@ jobs:
run: opam install lablgtk3 ocamlfind

- if: ${{ !matrix.job.static }} ## unable to build static gtk/gui
shell: bash
run: |
opam exec -- make gui
opam exec -- ${{ env._MAKE }} gui
# stage
# * copy only main/first project binary
project_exe_stem=${PROJECT_EXES%% *}
cp "src/${project_exe_stem}-gui${{ steps.vars.outputs.EXE_suffix }}" "${{ steps.vars.outputs.PKG_DIR }}/bin/"
cp "src/unison-gui${{ steps.vars.outputs.EXE_suffix }}" "${{ steps.vars.outputs.PKG_DIR }}/bin/"
- name: "Build WinOS text+gui hybrid"
if: ${{ runner.os == 'Windows' && !matrix.job.static && !contains(matrix.job.ocaml-version, 'msvc') }} ## WinOS, non-static (unable to build static gtk/gui)
shell: bash
run: |
# create and stage text+gui hybrid for Windows
# * copy only main/first project binary
project_exe_stem=${PROJECT_EXES%% *}
# * clean/remove build artifact(s)
rm "src/${project_exe_stem}-gui${{ steps.vars.outputs.EXE_suffix }}" ##.or.# opam exec -- make -C src clean #.or.# opam exec -- make clean
rm "src/unison-gui${{ steps.vars.outputs.EXE_suffix }}" ##.or.# opam exec -- make -C src clean #.or.# opam exec -- make clean
# * re-create (with hybrid text+gui UI)
opam exec -- make gui UI_WINOS=hybrid
cp "src/${project_exe_stem}-gui${{ steps.vars.outputs.EXE_suffix }}" "${{ steps.vars.outputs.PKG_DIR }}/bin/${project_exe_stem}-text+gui${{ steps.vars.outputs.EXE_suffix }}"
cp "src/unison-gui${{ steps.vars.outputs.EXE_suffix }}" "${{ steps.vars.outputs.PKG_DIR }}/bin/unison-text+gui${{ steps.vars.outputs.EXE_suffix }}"
- uses: actions/upload-artifact@v4
if: false ## disable by default; only useful for debugging GHA
Expand Down Expand Up @@ -1126,7 +1110,7 @@ jobs:
unset REF_TAG ; case "${GITHUB_REF}" in refs/tags/*) REF_TAG="${GITHUB_REF#refs/tags/}" ;; esac;
PKG_VER="${REF_TAG:-git_$REF_SHAS}"
PKG_VER="${PKG_VER#v}"
echo PKG_NAME="${PROJECT_NAME}-${PKG_VER}${{ matrix.job.fnsuffix }}.tar.gz" >> $GITHUB_OUTPUT
echo PKG_NAME="unison-${PKG_VER}${{ matrix.job.fnsuffix }}.tar.gz" >> $GITHUB_OUTPUT
echo REF_SHAS=${REF_SHAS} >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
Expand Down

0 comments on commit 8db0681

Please sign in to comment.