Make scripts capable of 32-bit Windows builds
Now binaries can be (cross-)built using GCC for 32- and 64-bit Windows. Additional improvements: - Within MSYS2, try to install the required dependencies automatically. - Within MSYS2, fix passing libdir paths to pkg-config. - Prune documentation from extracted package files, addressing the incredible slowness of Windows filesystem operations. - Fix the script name in README.adoc instructions.
This commit is contained in:
parent
1eee1831a5
commit
a1f6ffd226
|
@ -68,7 +68,7 @@ dependencies listed at the beginning of 'msys2-configure.sh',
|
||||||
plus rsvg-convert from librsvg2, and icotool from icoutils.
|
plus rsvg-convert from librsvg2, and icotool from icoutils.
|
||||||
Beware that the build will take up about a gigabyte of disk space.
|
Beware that the build will take up about a gigabyte of disk space.
|
||||||
|
|
||||||
$ sh -e msys2-cross-configure.sh builddir
|
$ sh -e msys2-configure.sh builddir
|
||||||
$ meson install -C builddir
|
$ meson install -C builddir
|
||||||
|
|
||||||
If everything succeeds, you will find a portable build of the application
|
If everything succeeds, you will find a portable build of the application
|
||||||
|
|
|
@ -1,14 +1,25 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
# msys2-configure.sh: set up an MSYS2-based Meson build targeting x86-64.
|
# msys2-configure.sh: set up an MSYS2-based Meson build (x86-64 by default)
|
||||||
# Dependencies: AWK, sed, sha256sum, cURL, bsdtar,
|
#
|
||||||
|
# Dependencies: AWK, sed, coreutils, cURL, bsdtar (libarchive),
|
||||||
# wine64, Meson, mingw-w64-binutils, mingw-w64-gcc, pkg-config
|
# wine64, Meson, mingw-w64-binutils, mingw-w64-gcc, pkg-config
|
||||||
repository=https://repo.msys2.org/mingw/mingw64/
|
#
|
||||||
|
# We support running directly from within MSYS2 on Windows,
|
||||||
|
# albeit while still downloading a complete copy of runtime depencies.
|
||||||
|
pkg=${MINGW_PACKAGE_PREFIX:-mingw-w64-x86_64}
|
||||||
|
prefix=${MSYSTEM_PREFIX:-/mingw64}
|
||||||
|
repo=https://repo.msys2.org/mingw$prefix
|
||||||
|
|
||||||
|
chost=${MSYSTEM_CHOST:-x86_64-w64-mingw32}
|
||||||
|
carch=${MSYSTEM_CARCH:-x86_64}
|
||||||
|
[ "$carch" = "i686" ] && carch=x86
|
||||||
|
|
||||||
# Support running directly from within MSYS2 on Windows.
|
|
||||||
if [ -n "$MSYSTEM" ]
|
if [ -n "$MSYSTEM" ]
|
||||||
then
|
then
|
||||||
wine64() { "$@"; }
|
wine64() { "$@"; }
|
||||||
awk() { command awk -v RS='\r?\n' "$@"; }
|
awk() { command awk -v RS='\r?\n' "$@"; }
|
||||||
|
pacman -S --needed libarchive $pkg-ca-certificates $pkg-gcc $pkg-icoutils \
|
||||||
|
$pkg-librsvg $pkg-meson $pkg-pkgconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
status() {
|
status() {
|
||||||
|
@ -17,7 +28,7 @@ status() {
|
||||||
|
|
||||||
dbsync() {
|
dbsync() {
|
||||||
status Fetching repository DB
|
status Fetching repository DB
|
||||||
[ -f db.tsv ] || curl -# "$repository/mingw64.db" | bsdtar -xOf- | awk '
|
[ -f db.tsv ] || curl -# "$repo$prefix.db" | bsdtar -xOf- | awk '
|
||||||
function flush() { print f["%NAME%"] f["%FILENAME%"] f["%DEPENDS%"] }
|
function flush() { print f["%NAME%"] f["%FILENAME%"] f["%DEPENDS%"] }
|
||||||
NR > 1 && $0 == "%FILENAME%" { flush(); for (i in f) delete f[i] }
|
NR > 1 && $0 == "%FILENAME%" { flush(); for (i in f) delete f[i] }
|
||||||
!/^[^%]/ { field = $0; next } { f[field] = f[field] $0 "\t" }
|
!/^[^%]/ { field = $0; next } { f[field] = f[field] $0 "\t" }
|
||||||
|
@ -38,7 +49,7 @@ fetch() {
|
||||||
} for (i = 0; i < ARGC; i++) get(ARGV[i]) }' "$@" | while IFS= read -r name
|
} for (i = 0; i < ARGC; i++) get(ARGV[i]) }' "$@" | while IFS= read -r name
|
||||||
do
|
do
|
||||||
status Fetching "$name"
|
status Fetching "$name"
|
||||||
[ -f "packages/$name" ] || curl -#o "packages/$name" "$repository/$name"
|
[ -f "packages/$name" ] || curl -#o "packages/$name" "$repo/$name"
|
||||||
done
|
done
|
||||||
|
|
||||||
version=$(curl -# https://exiftool.org/ver.txt)
|
version=$(curl -# https://exiftool.org/ver.txt)
|
||||||
|
@ -59,7 +70,8 @@ extract() {
|
||||||
do [ -d "$subdir" -a "$subdir" != packages ] && rm -rf -- "$subdir"
|
do [ -d "$subdir" -a "$subdir" != packages ] && rm -rf -- "$subdir"
|
||||||
done
|
done
|
||||||
for i in packages/*
|
for i in packages/*
|
||||||
do bsdtar -xf "$i" --strip-components 1 mingw64
|
do bsdtar -xf "$i" --strip-components 1 \
|
||||||
|
--exclude '*/share/man' --exclude '*/share/doc'
|
||||||
done
|
done
|
||||||
|
|
||||||
bsdtar -xf exiftool.tar.gz
|
bsdtar -xf exiftool.tar.gz
|
||||||
|
@ -81,28 +93,30 @@ configure() {
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
status Setting up Meson
|
status Setting up Meson
|
||||||
[ -n "$MSYSTEM" ] && wrap=false || wrap=true
|
wrap=true pclibdir=$msys2_root/share/pkgconfig:$msys2_root/lib/pkgconfig
|
||||||
|
[ -n "$MSYSTEM" ] && \
|
||||||
|
wrap=false pclibdir="$(pwd -W)/share/pkgconfig;$(pwd -W)/lib/pkgconfig"
|
||||||
|
|
||||||
cat >"$toolchain" <<-EOF
|
cat >"$toolchain" <<-EOF
|
||||||
[binaries]
|
[binaries]
|
||||||
c = 'x86_64-w64-mingw32-gcc'
|
c = '$chost-gcc'
|
||||||
cpp = 'x86_64-w64-mingw32-g++'
|
cpp = '$chost-g++'
|
||||||
ar = 'x86_64-w64-mingw32-gcc-ar'
|
ar = '$chost-gcc-ar'
|
||||||
ranlib = 'x86_64-w64-mingw32-gcc-ranlib'
|
ranlib = '$chost-gcc-ranlib'
|
||||||
strip = 'x86_64-w64-mingw32-strip'
|
strip = '$chost-strip'
|
||||||
windres = 'x86_64-w64-mingw32-windres'
|
windres = '$chost-windres'
|
||||||
pkgconfig = 'pkg-config'
|
pkgconfig = 'pkg-config'
|
||||||
|
|
||||||
[properties]
|
[properties]
|
||||||
sys_root = '$builddir'
|
sys_root = '$builddir'
|
||||||
msys2_root = '$msys2_root'
|
msys2_root = '$msys2_root'
|
||||||
pkg_config_libdir = '$msys2_root/share/pkgconfig:$msys2_root/lib/pkgconfig'
|
pkg_config_libdir = '$pclibdir'
|
||||||
needs_exe_wrapper = $wrap
|
needs_exe_wrapper = $wrap
|
||||||
|
|
||||||
[host_machine]
|
[host_machine]
|
||||||
system = 'windows'
|
system = 'windows'
|
||||||
cpu_family = 'x86_64'
|
cpu_family = '$carch'
|
||||||
cpu = 'x86_64'
|
cpu = '$carch'
|
||||||
endian = 'little'
|
endian = 'little'
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
@ -117,15 +131,13 @@ toolchain=$builddir/msys2-cross-toolchain.meson
|
||||||
|
|
||||||
# This directory name matches the prefix in .pc files, so we don't need to
|
# This directory name matches the prefix in .pc files, so we don't need to
|
||||||
# modify them (pkgconf has --prefix-variable, but Meson can't pass that option).
|
# modify them (pkgconf has --prefix-variable, but Meson can't pass that option).
|
||||||
msys2_root=$builddir/mingw64
|
msys2_root=$builddir$prefix
|
||||||
|
|
||||||
mkdir -p "$msys2_root"
|
mkdir -p "$msys2_root"
|
||||||
cd "$msys2_root"
|
cd "$msys2_root"
|
||||||
dbsync
|
dbsync
|
||||||
fetch mingw-w64-x86_64-gtk3 mingw-w64-x86_64-lcms2 \
|
fetch $pkg-gtk3 $pkg-lcms2 $pkg-libraw $pkg-libheif $pkg-perl \
|
||||||
mingw-w64-x86_64-libraw mingw-w64-x86_64-libheif \
|
$pkg-perl-win32-api $pkg-libwinpthread-git # Because we don't do "provides"?
|
||||||
mingw-w64-x86_64-perl mingw-w64-x86_64-perl-win32-api \
|
|
||||||
mingw-w64-x86_64-libwinpthread-git # Because we don't do "provides"?
|
|
||||||
verify
|
verify
|
||||||
extract
|
extract
|
||||||
configure
|
configure
|
||||||
|
|
2
tiffer.h
2
tiffer.h
|
@ -161,7 +161,7 @@ static bool
|
||||||
tiffer_subifd(
|
tiffer_subifd(
|
||||||
const struct tiffer *self, uint32_t offset, struct tiffer *subreader)
|
const struct tiffer *self, uint32_t offset, struct tiffer *subreader)
|
||||||
{
|
{
|
||||||
if (self->end - self->begin < offset)
|
if (self->begin > self->end || self->end - self->begin < offset)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
*subreader = *self;
|
*subreader = *self;
|
||||||
|
|
Loading…
Reference in New Issue