forked from lovell/sharp-libvips
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.sh
executable file
·105 lines (90 loc) · 3.24 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env bash
set -e
if [ $# -lt 1 ]; then
echo
echo "Usage: $0 VERSION [PLATFORM]"
echo "Build shared libraries for libvips and its dependencies via containers"
echo
echo "Please specify the libvips VERSION, e.g. 8.16.0"
echo
echo "Optionally build for only one PLATFORM, defaults to building for all"
echo
echo "Possible values for PLATFORM are:"
echo "- linux-x64"
echo "- linux-arm"
echo "- linux-arm64"
echo "- linux-musl-x64"
echo "- linux-musl-arm64"
echo "- win-x64"
echo "- win-x64.net452"
echo "- win-x86"
echo "- win-x86.net452"
echo "- win-arm64"
echo "- osx-x64"
echo "- osx-arm64"
echo
exit 1
fi
VERSION_VIPS="$1"
PLATFORM="${2:-all}"
# macOS
# Note: we intentionally don't build these binaries inside a Docker container
for flavour in osx-x64 osx-arm64; do
if [ $PLATFORM = $flavour ] && [ "$(uname)" == "Darwin" ]; then
echo "Building $flavour..."
# Use Clang provided by XCode
export CC="clang"
export CXX="clang++"
export VERSION_VIPS
export PLATFORM
# Use pkg-config provided by Homebrew
export PKG_CONFIG="$(brew --prefix)/bin/pkg-config --static"
# Earliest supported version of macOS
export MACOSX_DEPLOYMENT_TARGET="10.13"
# Added -fno-stack-check to workaround a stack misalignment bug on macOS 10.15
# See:
# https://forums.developer.apple.com/thread/121887
# https://trac.ffmpeg.org/ticket/8073#comment:12
export FLAGS="-fno-stack-check"
# Prevent use of API newer than the deployment target
export FLAGS+=" -Werror=unguarded-availability-new"
export MESON="--cross-file=$PWD/platforms/$PLATFORM/meson.ini"
if [ $PLATFORM = "osx-arm64" ]; then
# ARM64 builds work via cross compilation from an x86_64 machine
export CHOST="aarch64-apple-darwin"
export RUST_TARGET="aarch64-apple-darwin"
export FLAGS+=" -target arm64-apple-macos11"
# macOS 11 Big Sur is the first version to support ARM-based macs
export MACOSX_DEPLOYMENT_TARGET="11.0"
# Set SDKROOT to the latest SDK available
export SDKROOT=$(xcrun -sdk macosx --show-sdk-path)
fi
. $PWD/build/osx.sh
exit 0
fi
done
# Is docker available?
if ! [ -x "$(command -v docker)" ]; then
echo "Please install docker"
exit 1
fi
# Update base images
for baseimage in alpine:3.15 amazonlinux:2 debian:bullseye; do
docker pull $baseimage
done
# Windows (x64, x86 and arm64)
for flavour in win-x64 win-x64.net452 win-x86 win-x86.net452 win-arm64; do
if [ $PLATFORM = "all" ] || [ $PLATFORM = $flavour ]; then
echo "Building $flavour..."
docker build -t vips-dev-win32 platforms/win32
docker run --rm -e "VERSION_VIPS=$VERSION_VIPS" -e "PLATFORM=$flavour" -v $PWD:/packaging vips-dev-win32 sh -c "/packaging/build/win.sh"
fi
done
# Linux (x64, ARMv7 and ARM64v8)
for flavour in linux-x64 linux-arm linux-arm64 linux-musl-x64 linux-musl-arm64; do
if [ $PLATFORM = "all" ] || [ $PLATFORM = $flavour ]; then
echo "Building $flavour..."
docker build --cache-from vips-dev-$flavour --build-arg BUILDKIT_INLINE_CACHE=1 -t vips-dev-$flavour platforms/$flavour
docker run --rm -e "VERSION_VIPS=$VERSION_VIPS" -e VERSION_LATEST_REQUIRED -v $PWD:/packaging vips-dev-$flavour sh -c "/packaging/build/lin.sh"
fi
done