|
| 1 | +name: Cross compile for Windows |
| 2 | +on: |
| 3 | + - push |
| 4 | + - pull_request |
| 5 | +env: |
| 6 | + PIDGIN_VERSION: 2.14.14 |
| 7 | + GLIB_VERSION: 2.28.8 |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: build |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 17 | + |
| 18 | + - name: Make cross directory |
| 19 | + run: mkdir -p $RUNNER_TEMP |
| 20 | + |
| 21 | + - name: Write cross file |
| 22 | + run: | |
| 23 | + cat << EOF | tee $RUNNER_TEMP/cross-file.ini |
| 24 | + [binaries] |
| 25 | + c = '/usr/bin/i686-w64-mingw32-gcc' |
| 26 | + ar = '/usr/bin/i686-w64-mingw32-gcc-ar' |
| 27 | + strip = '/usr/bin/i686-w64-mingw32-strip' |
| 28 | + pkg-config = ['/usr/bin/pkg-config', '--define-prefix'] |
| 29 | + windres = '/usr/bin/i686-w64-mingw32-windres' |
| 30 | +
|
| 31 | + [host_machine] |
| 32 | + system = 'windows' |
| 33 | + cpu_family = 'x86' |
| 34 | + cpu = 'i686' |
| 35 | + endian = 'little' |
| 36 | +
|
| 37 | + [properties] |
| 38 | + sys_root = '$RUNNER_TEMP' |
| 39 | + pidgin_top = sys_root / 'pidgin' |
| 40 | + win32_dev = sys_root / 'win32-dev' |
| 41 | + pkg_config_libdir = [win32_dev / 'lib/pkgconfig', pidgin_top / 'libpurple/data/'] |
| 42 | + c_args = ['-I' + win32_dev / 'include'] |
| 43 | + c_link_args = ['-L' + win32_dev / 'lib'] |
| 44 | + EOF |
| 45 | +
|
| 46 | + - name: Install native packages |
| 47 | + run: | |
| 48 | + sudo apt update -yy |
| 49 | + sudo apt install -yy --no-install-recommends \ |
| 50 | + codespell \ |
| 51 | + gcc-mingw-w64-i686-win32 \ |
| 52 | + meson \ |
| 53 | + pkg-config |
| 54 | +
|
| 55 | + - name: Load Pidgin from cache |
| 56 | + id: pidgin-cache |
| 57 | + uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 |
| 58 | + with: |
| 59 | + path: ${{ runner.temp }}/pidgin |
| 60 | + key: pidgin-${{ env.PIDGIN_VERSION }} |
| 61 | + |
| 62 | + - name: Download Pidgin |
| 63 | + if: steps.pidgin-cache.outputs.cache-hit != 'true' |
| 64 | + run: | |
| 65 | + curl -L https://sourceforge.net/projects/pidgin/files/Pidgin/$PIDGIN_VERSION/pidgin-$PIDGIN_VERSION.tar.bz2/download -o pidgin.tar.bz2 |
| 66 | + mkdir -p $RUNNER_TEMP/pidgin |
| 67 | + tar -xf pidgin.tar.bz2 --strip-components=1 --directory=$RUNNER_TEMP/pidgin |
| 68 | + curl -L https://sourceforge.net/projects/pidgin/files/Pidgin/$PIDGIN_VERSION/pidgin-$PIDGIN_VERSION-win32-bin.zip/download -o pidgin-win32bin.zip |
| 69 | + unzip -j pidgin-win32bin.zip pidgin-*-win32bin/libpurple.dll -d $RUNNER_TEMP/pidgin/libpurple/ |
| 70 | +
|
| 71 | + - name: Create purple.pc |
| 72 | + run : | |
| 73 | + cat << 'EOF' | tee $RUNNER_TEMP/pidgin/libpurple/data/purple.pc |
| 74 | + prefix=${{ runner.temp }}/pidgin/libpurple |
| 75 | + exec_prefix=${prefix} |
| 76 | + libdir=${exec_prefix} |
| 77 | + includedir=${prefix} |
| 78 | + datarootdir=${prefix}/share |
| 79 | + datadir=${datarootdir} |
| 80 | + sysconfdir=${prefix}/etc |
| 81 | +
|
| 82 | + plugindir=${libdir}/purple-2 |
| 83 | +
|
| 84 | + Name: libpurple |
| 85 | + Description: libpurple is a GLib-based instant messenger library. |
| 86 | + Version: ${{ env.PIDGIN_VERSION }} |
| 87 | + Requires: glib-2.0 |
| 88 | + Cflags: -I${prefix} -I${prefix}/win32 |
| 89 | + Libs: -L${libdir} -lpurple |
| 90 | + EOF |
| 91 | +
|
| 92 | + - name: Load Win32 deps from cache |
| 93 | + id: win32-cache |
| 94 | + uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 |
| 95 | + with: |
| 96 | + path: ${{ runner.temp }}/win32-dev |
| 97 | + key: win32-dev |
| 98 | + |
| 99 | + - name: Setup WinPidgin build |
| 100 | + if: steps.win32-cache.outputs.cache-hit != 'true' |
| 101 | + run: | |
| 102 | + curl -L http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.28/glib-dev_2.28.8-1_win32.zip -o glib-dev.zip |
| 103 | + unzip glib-dev.zip -d $RUNNER_TEMP/win32-dev |
| 104 | + curl -L http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime-dev_0.18.1.1-2_win32.zip -o gettext-runtime.zip |
| 105 | + unzip gettext-runtime.zip -d $RUNNER_TEMP/win32-dev |
| 106 | + curl -L http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/zlib-dev_1.2.5-2_win32.zip -o zlib-dev.zip |
| 107 | + unzip zlib-dev.zip -d $RUNNER_TEMP/win32-dev |
| 108 | +
|
| 109 | + - name: Setup Meson Build |
| 110 | + run: meson setup --cross-file $RUNNER_TEMP/cross-file.ini --prefix=/usr -Duse-purple-prefix=false build |
| 111 | + |
| 112 | + - name: Build Project |
| 113 | + run: meson compile -C build |
| 114 | + |
| 115 | + - name: Install build results |
| 116 | + run: DESTDIR=$PWD/dist meson install -C build |
| 117 | + |
| 118 | + - name: archive |
| 119 | + if: ${{ !env.ACT }} |
| 120 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 121 | + with: |
| 122 | + name: "Win32 cross compiled" |
| 123 | + path: | |
| 124 | + ./dist/ |
| 125 | + !./dist/**/*.dll.a |
0 commit comments