|
| 1 | +name: Build gettext with Cygwin |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + version: |
| 6 | + description: gettext tag to build |
| 7 | + required: true |
| 8 | + php: |
| 9 | + description: PHP version to build for |
| 10 | + required: true |
| 11 | +defaults: |
| 12 | + run: |
| 13 | + shell: cmd |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + arch: [x64, x86] |
| 20 | + runs-on: windows-2022 |
| 21 | + steps: |
| 22 | + - name: Disable Git CRLF conversion |
| 23 | + run: | |
| 24 | + git config --global core.autocrlf false |
| 25 | + git config --global core.eol lf |
| 26 | + - name: Checkout winlib-builder |
| 27 | + uses: actions/checkout@v5 |
| 28 | + with: |
| 29 | + path: winlib-builder |
| 30 | + - name: Checkout gettext |
| 31 | + uses: actions/checkout@v5 |
| 32 | + with: |
| 33 | + path: gettext |
| 34 | + repository: winlibs/gettext |
| 35 | + ref: ${{github.event.inputs.version}} |
| 36 | + - name: Compute virtual inputs |
| 37 | + id: virtuals |
| 38 | + run: powershell winlib-builder/scripts/compute-virtuals -version ${{github.event.inputs.php}} -arch ${{matrix.arch}} |
| 39 | + - name: Setup MSVC |
| 40 | + uses: ilammy/msvc-dev-cmd@v1 |
| 41 | + with: |
| 42 | + arch: ${{matrix.arch}} |
| 43 | + sdk: ${{steps.virtuals.outputs.winsdk}} |
| 44 | + toolset: ${{steps.virtuals.outputs.toolset}} |
| 45 | + - name: Setup Cygwin |
| 46 | + run: | |
| 47 | + curl -fsSL https://cygwin.com/setup-x86_64.exe -o setup-x86_64.exe |
| 48 | + setup-x86_64.exe -q -n -N -R C:\cygwin64 -l C:\cygwin-packages -s https://mirrors.kernel.org/sourceware/cygwin/ -P make,binutils,mingw64-i686-binutils,mingw64-i686-gcc-core,mingw64-x86_64-binutils,mingw64-x86_64-gcc-core |
| 49 | + - name: Build gettext |
| 50 | + shell: pwsh |
| 51 | + env: |
| 52 | + HOST_TRIPLET: ${{matrix.arch == 'x64' && 'x86_64-w64-mingw32' || 'i686-w64-mingw32'}} |
| 53 | + run: | |
| 54 | + $script = @' |
| 55 | + win_to_cygpath() { |
| 56 | + local raw="$1" |
| 57 | + local path |
| 58 | + path="$(cygpath -u "$raw")" |
| 59 | + case "$path" in |
| 60 | + /[A-Za-z]/*) |
| 61 | + local drive |
| 62 | + drive="$(printf '%s' "${path:1:1}" | tr '[:upper:]' '[:lower:]')" |
| 63 | + path="/cygdrive/$drive${path:2}" |
| 64 | + ;; |
| 65 | + esac |
| 66 | + printf '%s\n' "$path" |
| 67 | + } |
| 68 | + workspace="$(win_to_cygpath "$GITHUB_WORKSPACE")" |
| 69 | + runtime="$workspace/gettext/gettext-runtime" |
| 70 | + src="$runtime/intl" |
| 71 | + prefix="$workspace/install" |
| 72 | + cl_path="$(win_to_cygpath "$(cmd /c where cl.exe | tr -d '\r' | head -n 1)")" |
| 73 | + tool_dir="$(dirname "$cl_path")" |
| 74 | + export PATH="$tool_dir:/usr/bin:$PATH" |
| 75 | + static_pdb="$(cygpath -w "$prefix/lib/libintl_a.pdb" | sed 's/\\/\\\\/g')" |
| 76 | + mkdir -p "$prefix/lib" |
| 77 | + cd "$runtime" |
| 78 | + ./configure \ |
| 79 | + --host="$HOST_TRIPLET" \ |
| 80 | + --prefix="$prefix" \ |
| 81 | + --enable-shared \ |
| 82 | + --enable-static \ |
| 83 | + CC="$runtime/../build-aux/compile cl -nologo" \ |
| 84 | + CFLAGS="-MD -O2 -Zi -FS /Fd$static_pdb" \ |
| 85 | + CXX="$runtime/../build-aux/compile cl -nologo" \ |
| 86 | + CXXFLAGS="-MD -O2 -Zi -FS /Fd$static_pdb" \ |
| 87 | + CPPFLAGS="-D_WIN32_WINNT=0x0601" \ |
| 88 | + LDFLAGS="-Wl,-DEBUG" \ |
| 89 | + LD="link.exe" \ |
| 90 | + NM="dumpbin.exe -symbols" \ |
| 91 | + STRIP=":" \ |
| 92 | + AR="$workspace/winlib-builder/autotools/ar-lib lib.exe" \ |
| 93 | + RANLIB=":" || { cat config.log; exit 1; } |
| 94 | + touch aclocal.m4 configure config.h.in Makefile.in |
| 95 | + touch intl/aclocal.m4 intl/configure intl/config.h.in intl/Makefile.in intl/gnulib-lib/Makefile.in |
| 96 | + perl -0pi -e 's/ -version-info \$\(LTV_CURRENT\):\$\(LTV_REVISION\):\$\(LTV_AGE\) \\\n/ -avoid-version \\\n/' intl/Makefile |
| 97 | + make -C intl -j2 |
| 98 | + make -C intl install |
| 99 | + '@ |
| 100 | + $scriptPath = Join-Path $env:GITHUB_WORKSPACE 'build-gettext.sh' |
| 101 | + [System.IO.File]::WriteAllText($scriptPath, $script.Replace("`r`n", "`n"), [System.Text.Encoding]::ASCII) |
| 102 | + $cygwinScriptPath = & C:\cygwin64\bin\cygpath.exe -u $scriptPath |
| 103 | + & C:\cygwin64\bin\bash.exe --noprofile --norc -eo pipefail $cygwinScriptPath |
| 104 | + if ($LASTEXITCODE -ne 0) { |
| 105 | + exit $LASTEXITCODE |
| 106 | + } |
| 107 | + - name: Normalize gettext install |
| 108 | + shell: pwsh |
| 109 | + env: |
| 110 | + LIB_MACHINE: ${{matrix.arch == 'x64' && 'X64' || 'X86'}} |
| 111 | + run: | |
| 112 | + $ErrorActionPreference = 'Stop' |
| 113 | + New-Item -ItemType Directory -Force -Path install/bin, install/include, install/lib | Out-Null |
| 114 | + Copy-Item 'install/bin/intl-8.dll' 'install/bin/libintl.dll' -Force |
| 115 | + Copy-Item 'gettext/gettext-runtime/intl/.libs/intl-8.pdb' 'install/bin/libintl.pdb' -Force |
| 116 | + Copy-Item 'install/lib/intl.lib' 'install/lib/libintl_a.lib' -Force |
| 117 | +
|
| 118 | + $symbols = Get-Content 'gettext/gettext-runtime/intl/.libs/intl.expsym' | |
| 119 | + Where-Object { $_ -and $_ -notmatch '^\s*(LIBRARY|NAME|EXPORTS)\b' -and $_ -notmatch '^\s*;' } | |
| 120 | + ForEach-Object { " $_" } |
| 121 | + $def = @('LIBRARY libintl.dll', 'EXPORTS') + $symbols |
| 122 | + Set-Content -Path 'install/lib/libintl.def' -Value $def -Encoding ASCII |
| 123 | +
|
| 124 | + & lib.exe /nologo /machine:$env:LIB_MACHINE /def:install/lib/libintl.def /name:libintl.dll /out:install/lib/libintl.lib |
| 125 | + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } |
| 126 | + Remove-Item -Force -ErrorAction SilentlyContinue 'install/bin/intl*.dll', 'install/lib/intl*.lib', 'install/lib/libintl.def', 'install/lib/libintl.exp', 'install/lib/libintl.la' |
| 127 | +
|
| 128 | + $required = @('bin/libintl.dll', 'bin/libintl.pdb', 'include/libintl.h', 'lib/libintl.lib', 'lib/libintl_a.lib', 'lib/libintl_a.pdb') |
| 129 | + foreach ($file in $required) { |
| 130 | + if (!(Test-Path "install/$file")) { throw "Missing install/$file" } |
| 131 | + } |
| 132 | + - name: Upload artifacts |
| 133 | + uses: actions/upload-artifact@v4 |
| 134 | + with: |
| 135 | + name: ${{github.event.inputs.version}}-${{steps.virtuals.outputs.vs}}-${{matrix.arch}} |
| 136 | + path: install |
0 commit comments