From ced176a31b892d2b446bbba240780ac3b80b4670 Mon Sep 17 00:00:00 2001 From: David Declerck Date: Mon, 18 Mar 2024 14:38:51 +0100 Subject: [PATCH] Add Windows MSVC workflow --- .github/workflows/macos.yml | 2 + .github/workflows/ubuntu.yml | 1 + .github/workflows/windows-msvc.yml | 194 ++++++++++++++++++ .../{windows.yml => windows-msys2.yml} | 12 +- 4 files changed, 203 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/windows-msvc.yml rename .github/workflows/{windows.yml => windows-msys2.yml} (93%) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index ffc2dcec1..aa61cb3b2 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -5,6 +5,8 @@ on: branches: [ gcos4gnucobol-3.x ] push: branches: [ gcos4gnucobol-3.x ] + # manual run in actions tab - for all branches + workflow_dispatch: jobs: build: diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 352b6282f..a16d542aa 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -4,6 +4,7 @@ on: pull_request: branches: [ gcos4gnucobol-3.x ] push: + branches: [ gcos4gnucobol-3.x ] # manual run in actions tab - for all branches workflow_dispatch: diff --git a/.github/workflows/windows-msvc.yml b/.github/workflows/windows-msvc.yml new file mode 100644 index 000000000..59c9021a4 --- /dev/null +++ b/.github/workflows/windows-msvc.yml @@ -0,0 +1,194 @@ +name: Windows MSVC Workflow + +on: + pull_request: + branches: [ gcos4gnucobol-3.x ] + push: + branches: [ gcos4gnucobol-3.x ] + # manual run in actions tab - for all branches + workflow_dispatch: + +env: + FLEXBISON: https://github.com/lexxmark/winflexbison/releases/download/v2.5.25/win_flex_bison-2.5.25.zip + MSBUILD: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe + VCVARS32: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat + VCVARS64: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat + VCPKG_ROOT: C:\vcpkg + VCPKGS32: mpir:x86-windows pdcurses:x86-windows berkeleydb:x86-windows libxml2:x86-windows cjson:x86-windows + VCPKGS64: mpir:x64-windows pdcurses:x64-windows berkeleydb:x64-windows libxml2:x64-windows cjson:x64-windows + MSYS2_ROOT: C:\msys64 + MSYSPKGS: autoconf + MSYSTEM: UCRT64 + MSYSTEM_CHOST: x86_64-w64-mingw32 + +jobs: + build: + strategy: + fail-fast: false + matrix: + os: + - windows-latest + arch: + - x86 + - x64 + target: + - Debug + - Release + + runs-on: ${{ matrix.os }} + + steps: + + - name: Set git user + run: | + git config --global user.name github-actions + git config --global user.email github-actions-bot@users.noreply.github.com + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup environment + run: | + echo GITHUB_WORKSPACE=$env:GITHUB_WORKSPACE >> $env:GITHUB_ENV + If ("${{ matrix.arch }}" -eq "x86") { + echo VCVARS=$env:VCVARS32 >> $env:GITHUB_ENV + echo VCPKGS=$env:VCPKGS32 >> $env:GITHUB_ENV + echo ARCHDIR=Win32 >> $env:GITHUB_ENV + } Else { + echo VCVARS=$env:VCVARS64 >> $env:GITHUB_ENV + echo VCPKGS=$env:VCPKGS64 >> $env:GITHUB_ENV + echo ARCHDIR=x64 >> $env:GITHUB_ENV + } + + - name: Restore VCPKG package cache + id: restore-vcpkg + uses: actions/cache/restore@v3 + with: + key: cache-vcpkg-${{ matrix.arch }}-${{ matrix.target }} + path: | + ${{ env.VCPKG_ROOT }}/installed + ${{ env.VCPKG_ROOT }}/packages + + - name: Install VCPKG packages + if: steps.restore-vcpkg.outputs.cache-hit != 'true' + run: | + cd $env:VCPKG_ROOT + git pull + .\bootstrap-vcpkg.bat -disableMetrics + vcpkg integrate install + vcpkg install (-split $env:VCPKGS) + vcpkg update + vcpkg upgrade (-split $env:VCPKGS) --no-dry-run + + - name: Save VCPKG package cache + if: steps.restore-vcpkg.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + key: cache-vcpkg-${{ matrix.arch }}-${{ matrix.target }} + path: | + ${{ env.VCPKG_ROOT }}/installed + ${{ env.VCPKG_ROOT }}/packages + + - name: Restore WinFlexBison cache + uses: actions/cache/restore@v3 + id: restore-flexbison + with: + key: cache-flexbison-${{ matrix.arch }}-${{ matrix.target }} + path: ${{ env.GITHUB_WORKSPACE }}\flexbison + + - name: Install WinFlexBison + if: steps.restore-flexbison.outputs.cache-hit != 'true' + run: | + Invoke-WebRequest -Uri $env:FLEXBISON -OutFile flexbison.zip + Expand-Archive flexbison.zip -DestinationPath flexbison + + - name: Save WinFlexBison cache + if: steps.restore-flexbison.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + key: cache-flexbison-${{ matrix.arch }}-${{ matrix.target }} + path: ${{ env.GITHUB_WORKSPACE }}/flexbison + + - name: Configure GnuCOBOL + run: | + cd build_windows + Get-Content -Path 'config.h.in' | ForEach-Object { $_ ` + -replace '(#define\s+CONFIGURED_ISAM)\s.+$', '$1 BDB' ` + -replace '(#define\s+CONFIGURED_CURSES)\s.+$', '$1 PDCURSES' ` + -replace '(#define\s+CONFIGURED_XML)\s.+$', '$1 XML2' ` + -replace '(#define\s+CONFIGURED_JSON)\s.+$', '$1 CJSON_CJSON' ` + } | Set-Content -Path 'config.h' + & .\maketarstamp.ps1 > tarstamp.h + + - name: Generate parser + run: | + $env:PATH = "$pwd\flexbison;$env:PATH" + cd build_windows + cmd /C makebisonflex.cmd + + - name: Build GnuCOBOL + run: | + cd build_windows + vcpkg integrate install + & $env:MSBUILD "vs2019\GnuCOBOL.sln" /m /p:Platform=${{ matrix.arch }} /p:Configuration=${{ matrix.target }} + + # - name: Package GnuCOBOL + # shell: cmd + # run: | + # set COB_CFLAGS=/I "%cd%" /I "%VCPKG_ROOT%\installed\${{ matrix.arch }}-windows\include" + # set COB_LIBS=libcob.lib /LIBPATH:"%cd%\build_windows\${{ env.ARCHDIR }}\${{ matrix.target }}" /FORCE:MULTIPLE + # call "%VCVARS%" + # cd build_windows + # cmd /C makedist.cmd + # dir + + # - name: Upload distribution + # uses: actions/upload-artifact@v3 + # with: + # name: GnuCOBOL_3.3-dev_${{ matrix.arch }}-${{ matrix.target }}.7z + # path: ${{ env.GITHUB_WORKSPACE }}/GnuCOBOL_3.3-dev_vs_bin.7z + + - name: Install MSYS2 packages + shell: C:\shells\msys2bash.cmd {0} + run: | + pacman --needed --noconfirm -S $MSYSPKGS + + - name: Building testsuite + shell: C:\shells\msys2bash.cmd {0} + run: | + cd tests + echo at_testdir=\'tests\' > atconfig + echo abs_builddir=\'$(pwd)\' >> atconfig + echo at_srcdir=\'./\' >> atconfig + echo abs_srcdir=\'$(pwd)/\' >> atconfig + echo at_top_srcdir=\'../\' >> atconfig + echo abs_top_srcdir=\'$(pwd)/../\' >> atconfig + echo at_top_build_prefix=\'../\' >> atconfig + echo abs_top_builddir=\'$(pwd)/../\' >> atconfig + echo at_top_builddir=\$at_top_build_prefix >> atconfig + echo EXEEXT=\'.exe\' >> atconfig + echo AUTOTEST_PATH=\'tests\' >> atconfig + echo SHELL=\${CONFIG_SHELL-\'/bin/sh\'} >> atconfig + echo m4_define\([AT_PACKAGE_STRING], [GnuCOBOL 3.3-dev]\) > package.m4 + echo m4_define\([AT_PACKAGE_BUGREPORT], [bug-gnucobol@gnu.org]\) >> package.m4 + sed 's/x64\/Debug/${{ env.ARCHDIR }}\/${{ matrix.target }}/g' atlocal_win > atlocal + sed -i '/AT_SETUP(\[runtime check: write to internal storage (1)\])/a AT_SKIP_IF(\[true\])' testsuite.src/run_misc.at + sed -i '/AT_SETUP(\[CURRENCY SIGN WITH PICTURE SYMBOL\])/a AT_SKIP_IF(\[true\])' testsuite.src/run_misc.at + sed -i '/AT_SETUP(\[FUNCTION RANDOM\])/a AT_SKIP_IF(\[true\])' testsuite.src/run_functions.at + autom4te --lang=autotest -I ./testsuite.src ./testsuite.at -o ./testsuite + + - name: Running testsuite + shell: cmd + run: | + set COB_CFLAGS=/I "%cd%" /I "%VCPKG_ROOT%\installed\${{ matrix.arch }}-windows\include" + set COB_LIBS=libcob.lib /LIBPATH:"%cd%\build_windows\${{ env.ARCHDIR }}\${{ matrix.target }}" /FORCE:MULTIPLE + call "%VCVARS%" + cd tests + bash -c "./testsuite || ./testsuite --recheck --verbose" + + - name: Upload testsuite.log + uses: actions/upload-artifact@v3 + if: failure() + with: + name: testsuite.log + path: ${{ env.GITHUB_WORKSPACE }}/tests/testsuite.log diff --git a/.github/workflows/windows.yml b/.github/workflows/windows-msys2.yml similarity index 93% rename from .github/workflows/windows.yml rename to .github/workflows/windows-msys2.yml index e238d741a..c880f28bb 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows-msys2.yml @@ -1,12 +1,12 @@ -name: Windows Workflow +name: Windows MSYS2 Workflow on: - pull_request: - branches: [ gcos4gnucobol-3.x ] - push: - branches: [ gcos4gnucobol-3.x ] + pull_request: + branches: [ gcos4gnucobol-3.x ] + push: + branches: [ gcos4gnucobol-3.x ] # manual run in actions tab - for all branches - # workflow_dispatch: + workflow_dispatch: jobs: build: