diff --git a/.gitignore b/.gitignore index baaaf97d..8e781a86 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ libvips* sharp-libvips* *.log build/wasm-vips-* +build-win64-mxe/ deps/ target/ npm/*/* diff --git a/README.md b/README.md index 466dafef..7eab537b 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,9 @@ the same shared libraries within multiple containers. ### Windows -The output of libvips' [build-win64-mxe](https://github.com/libvips/build-win64-mxe) -static "web" releases are [post-processed](build/win.sh) within a [container](platforms/win32/Dockerfile). +The [Windows build script](build/win.sh) runs on Linux and uses the +[build-win64-mxe](https://github.com/libvips/build-win64-mxe) repo +to cross-compile the "web" group of dependencies into static binaries. ### macOS diff --git a/build.sh b/build.sh index 07b8d637..632477d6 100755 --- a/build.sh +++ b/build.sh @@ -84,8 +84,7 @@ fi for flavour in win32-x64 win32-arm64v8; do if [ $PLATFORM = "all" ] || [ $PLATFORM = $flavour ]; then echo "Building $flavour..." - docker build --pull -t vips-dev-win32 platforms/win32 - docker run --rm -e "PLATFORM=${flavour}" -v $PWD:/packaging vips-dev-win32 sh -c "/packaging/build/win.sh" + PLATFORM=$flavour ./build/win.sh fi done diff --git a/build/win.sh b/build/win.sh index 4fc09326..1256c952 100755 --- a/build/win.sh +++ b/build/win.sh @@ -5,51 +5,44 @@ set -e ## SPDX-License-Identifier: Apache-2.0 # Dependency version numbers -source /packaging/versions.properties +source ./versions.properties VERSION_VIPS_SHORT=${VERSION_VIPS%.[[:digit:]]*} -# Common options for curl -CURL="curl --silent --location --retry 3 --retry-max-time 30" - -# Fetch and unzip -mkdir /vips -cd /vips - case ${PLATFORM} in *arm64v8) ARCH=arm64 + MXE_TARGET=aarch64 ;; *x64) ARCH=x64 + MXE_TARGET=x86_64 ;; esac -FILENAME="vips-dev-${ARCH}-web-${VERSION_VIPS}-static.zip" -URL="https://github.com/libvips/build-win64-mxe/releases/download/v${VERSION_VIPS}/${FILENAME}" -echo "Downloading $URL" -$CURL -O $URL -unzip $FILENAME - -# Clean and zip -cd /vips/vips-dev-${VERSION_VIPS_SHORT} -rm bin/libvips-cpp-42.dll -cp bin/*.dll lib/ +if [ ! -d "build-win64-mxe" ]; then + git clone https://github.com/libvips/build-win64-mxe.git +fi -# Add third-party notices -$CURL -O https://raw.githubusercontent.com/lovell/sharp-libvips/main/THIRD-PARTY-NOTICES.md +echo "Building libvips ${VERSION_VIPS} for ${MXE_TARGET}" +cd build-win64-mxe +git checkout master +git pull +./build.sh vips-web --target $MXE_TARGET-w64-mingw32.static --ref v${VERSION_VIPS} echo "Creating tarball" -tar czf /packaging/sharp-libvips-${PLATFORM}.tar.gz \ +COMMIT_SHA=$(git ls-remote --heads --tags --refs https://github.com/libvips/libvips.git v${VERSION_VIPS} | cut -c1-7) +mkdir -p "output" +unzip -oq "packaging/vips-dev-${ARCH}-web-${COMMIT_SHA}-static.zip" -d "output" +cd "output/vips-dev-${COMMIT_SHA}" +rm bin/libvips-cpp-42.dll +cp bin/*.dll lib/ +cp ../../../THIRD-PARTY-NOTICES.md . +sed -i "s/${COMMIT_SHA}/${VERSION_VIPS}/g" versions.json +tar czf "../../../sharp-libvips-${PLATFORM}.tar.gz" \ include \ lib/glib-2.0 \ lib/libvips.lib \ lib/*.dll \ *.json \ THIRD-PARTY-NOTICES.md - -# Allow tarballs to be read outside container -chmod 644 /packaging/sharp-libvips-${PLATFORM}.tar.* - -# Remove working directories -rm -rf lib include *.json THIRD-PARTY-NOTICES.md diff --git a/platforms/win32/Dockerfile b/platforms/win32/Dockerfile deleted file mode 100644 index 5713c4bb..00000000 --- a/platforms/win32/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM debian:trixie -LABEL org.opencontainers.image.authors="Lovell Fuller " - -## SPDX-FileCopyrightText: 2017 Lovell Fuller and others -## SPDX-License-Identifier: Apache-2.0 - -# Create Debian-based container suitable for post-processing Windows binaries - -RUN apt-get update && apt-get install -y curl zip