Skip to content

Commit

Permalink
Try compiling windows deps on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ankith26 committed Dec 4, 2023
1 parent 6fed43d commit b2f1b77
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 1 deletion.
59 changes: 59 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,67 @@ concurrency:
cancel-in-progress: true

jobs:
deps:
name: ${{ matrix.name }} deps
runs-on: windows-latest
strategy:
matrix:
# make i686 deps and x86_64 deps
include:
- {
name: "64-bit",
winarch: x86_64,
msystem: MINGW64
}
- {
name: "32-bit",
winarch: i686,
msystem: MINGW32
}

steps:
- run: git config --global core.autocrlf input # do not introduce carriage returns
- uses: actions/[email protected]

- name: Test for Win Deps cache hit
id: windep-cache
uses: actions/[email protected]
with:
path: ${{ github.workspace }}/pygame_win_deps_${{ matrix.winarch }}
# The hash of all files in buildconfig manylinux-build and windependencies is
# the key to the cache. If anything changes here, the deps are built again
key: windep-${{ hashFiles('buildconfig/manylinux-build/**') }}-${{ hashFiles('buildconfig/windependencies/*.sh') }}-${{ matrix.winarch }}
lookup-only: true

- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
install: >-
mingw-w64-${{ matrix.winarch }}-gcc
mingw-w64-${{ matrix.winarch }}-cmake
mingw-w64-${{ matrix.winarch }}-autotools
mingw-w64-${{ matrix.winarch }}-nasm
mingw-w64-${{ matrix.winarch }}-python
# build win deps on cache miss
- name: Build Win Deps
if: steps.windep-cache.outputs.cache-hit != 'true'
shell: msys2 {0}
run: |
export WIN_ARCH="${{ matrix.winarch }}"
cd buildconfig/windependencies
bash ./build_win_deps.sh
# Uncomment when you want to manually verify the deps by downloading them
- name: Upload win deps
uses: actions/upload-artifact@v3
with:
name: pygame-win-deps-${{ matrix.winarch }}
path: ${{ github.workspace }}/pygame_win_deps_${{ matrix.winarch }}

build:
name: ${{ matrix.name }}
needs: deps
runs-on: windows-latest
strategy:
fail-fast: false # if a particular matrix build fails, don't skip the rest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cd $TIFF

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
./configure $PG_BASE_CONFIGURE_FLAGS --disable-lzma --disable-webp --disable-zstd
elif [[ "$OSTYPE" == "darwin"* ]]; then
else
# Use CMake on macOS because arm64 builds fail with weird errors in ./configure
cmake . $PG_BASE_CMAKE_FLAGS -Dlzma=OFF -Dwebp=OFF -Dzstd=OFF
fi
Expand Down
80 changes: 80 additions & 0 deletions buildconfig/windependencies/build_win_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# This uses manylinux build scripts to build dependencies on windows.

set -e -x

# The below three lines convert something like D:\path\goes\here to /d/path/goes/here
export BASE_DIR=$(echo "$GITHUB_WORKSPACE" | tr '[:upper:]' '[:lower:]')
export BASE_DIR="${BASE_DIR//\\//}" # //\\// replaces all \ with / in the variable
export BASE_DIR="/${BASE_DIR//:/}" # remove colon from drive part, add leading /

export PG_DEP_PREFIX="$BASE_DIR/pygame_win_deps_$WIN_ARCH"

export PKG_CONFIG_PATH="$PG_DEP_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"

mkdir $PG_DEP_PREFIX

# for great speed.
export MAKEFLAGS="-j 2"

# for scripts using ./configure
export CC="gcc"
export CXX="g++"

# With this we
# 1) Force install prefix to $PG_DEP_PREFIX
# 2) use lib directory within $PG_DEP_PREFIX (and not lib64)
# 3) make release binaries
# 4) build shared libraries
# 5) make cmake use gcc/g++/make
export PG_BASE_CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=$PG_DEP_PREFIX \
-DCMAKE_INSTALL_LIBDIR:PATH=lib \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=true \
-DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_MAKE_PROGRAM=make"

export CMAKE_GENERATOR="MSYS Makefiles"

export PG_BASE_CONFIGURE_FLAGS="--prefix=$PG_DEP_PREFIX"

export PG_BASE_MESON_FLAGS="--prefix=$PG_DEP_PREFIX \
-Dlibdir=lib \
-Dbuildtype=release \
-Ddefault_library=shared"

cd ../manylinux-build/docker_base

# Now start installing dependencies
# ---------------------------------

# install some buildtools
bash buildtools/install.sh

# sdl_image deps
bash zlib-ng/build-zlib-ng.sh
bash libpng/build-png.sh # depends on zlib
bash libjpegturbo/build-jpeg-turbo.sh
bash libtiff/build-tiff.sh
bash libwebp/build-webp.sh

# freetype (also sdl_ttf dep)
bash brotli/build-brotli.sh
bash bzip2/build-bzip2.sh
bash freetype/build-freetype.sh

# sdl_mixer deps
bash libmodplug/build-libmodplug.sh
bash ogg/build-ogg.sh
bash flac/build-flac.sh
bash mpg123/build-mpg123.sh
bash opus/build-opus.sh # needs libogg (which is a container format)

# fluidsynth (for sdl_mixer)
# bash gettext/build-gettext.sh
bash glib/build-glib.sh
bash sndfile/build-sndfile.sh
bash fluidsynth/build-fluidsynth.sh

bash sdl_libs/build-sdl2-libs.sh

# for pygame.midi
bash portmidi/build-portmidi.sh

0 comments on commit b2f1b77

Please sign in to comment.