forked from netpyoung/test-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-on-mac-for-arm.sh
108 lines (87 loc) · 4.15 KB
/
build-on-mac-for-arm.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
106
107
108
#!/usr/bin/env bash
set -e
# [variable]
readonly ROOT_ROOT=`pwd`
readonly BUILD_DIR="${ROOT_ROOT}/build/macos"
readonly LIB_DIR="${ROOT_ROOT}/lib/macos"
#---------------------------------------------------------------------------------------------
# for Apple©
#---------------------------------------------------------------------------------------------
DEVELOPER=$(xcode-select -print-path)
TOOLCHAIN_BIN="${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin"
export CC="${TOOLCHAIN_BIN}/clang"
export AR="${TOOLCHAIN_BIN}/ar"
export RANLIB="${TOOLCHAIN_BIN}/ranlib"
export STRIP="${TOOLCHAIN_BIN}/strip"
export LIBTOOL="${TOOLCHAIN_BIN}/libtool"
export NM="${TOOLCHAIN_BIN}/nm"
export LD="${TOOLCHAIN_BIN}/ld"
git clone https://github.com/webmproject/libwebp.git
cd libwebp
git checkout v1.2.2
OUT_LIB_PATHS_webp=''
OUT_LIB_PATHS_webpdecoder=''
OUT_LIB_PATHS_webpdemux=''
OUT_LIB_PATHS_webpmux=''
readonly HOST="aarch64-apple-darwin"
readonly ISYSROOT=`xcrun --sdk macosx --show-sdk-path`
for ARCH in x86_64 arm64 ; do
BUILD_ARCH_DIR="${BUILD_DIR}/${ARCH}"
LIB_ARCH_DIR="${LIB_DIR}/${ARCH}"
mkdir -p "${BUILD_ARCH_DIR}"
mkdir -p "${LIB_ARCH_DIR}"
TARGET="${ARCH}-apple-macos"
CFLAGS="\
-arch ${ARCH} \
-target ${TARGET} \
-isysroot ${ISYSROOT} \
-mmacos-version-min=13.0 \
-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include \
-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks \
"
./autogen.sh
set -x
./configure --prefix=${BUILD_ARCH_DIR} --enable-everything --disable-static --host="$HOST" CFLAGS="${CFLAGS}"
make && make install
set +x
path_libwebp=`realpath ${BUILD_ARCH_DIR}/lib/libwebp.dylib`
path_libwebpdecoder=`realpath ${BUILD_ARCH_DIR}/lib/libwebpdecoder.dylib`
path_libwebpdemux=`realpath ${BUILD_ARCH_DIR}/lib/libwebpdemux.dylib`
path_libwebpmux=`realpath ${BUILD_ARCH_DIR}/lib/libwebpmux.dylib`
cp -r ${path_libwebp} "${BUILD_ARCH_DIR}/webp.bundle"
cp -r ${path_libwebpdecoder} "${BUILD_ARCH_DIR}/webpdecoder.bundle"
cp -r ${path_libwebpdemux} "${BUILD_ARCH_DIR}/webpdemux.bundle"
cp -r ${path_libwebpmux} "${BUILD_ARCH_DIR}/webpmux.bundle"
otool -L ${BUILD_ARCH_DIR}/webp.bundle
otool -L ${BUILD_ARCH_DIR}/webpdecoder.bundle
otool -L ${BUILD_ARCH_DIR}/webpdemux.bundle
otool -L ${BUILD_ARCH_DIR}/webpmux.bundle
install_name_tool -id @loader_path/webp.bundle ${BUILD_ARCH_DIR}/webp.bundle
install_name_tool -id @loader_path/wewebpdecoderbp.bundle ${BUILD_ARCH_DIR}/webpdecoder.bundle
install_name_tool -id @loader_path/webpdemux.bundle ${BUILD_ARCH_DIR}/webpdemux.bundle
install_name_tool -id @loader_path/webpmux.bundle ${BUILD_ARCH_DIR}/webpmux.bundle
install_name_tool -change ${path_libwebp} @loader_path/webp.bundle ${BUILD_ARCH_DIR}/webpdemux.bundle
install_name_tool -change ${path_libwebp} @loader_path/webp.bundle ${BUILD_ARCH_DIR}/webpmux.bundle
otool -L ${BUILD_ARCH_DIR}/webp.bundle
otool -L ${BUILD_ARCH_DIR}/webpdecoder.bundle
otool -L ${BUILD_ARCH_DIR}/webpdemux.bundle
otool -L ${BUILD_ARCH_DIR}/webpmux.bundle
OUT_LIB_PATHS_webp+=" ${BUILD_ARCH_DIR}/webp.bundle"
OUT_LIB_PATHS_webpdecoder+=" ${BUILD_ARCH_DIR}/webpdecoder.bundle"
OUT_LIB_PATHS_webpdemux+=" ${BUILD_ARCH_DIR}/webpdemux.bundle"
OUT_LIB_PATHS_webpmux+=" ${BUILD_ARCH_DIR}/webpmux.bundle"
make clean
done
echo "OUT_LIB_PATHS_webp = ${OUT_LIB_PATHS_webp}"
lipo -create ${OUT_LIB_PATHS_webp} -output ${LIB_DIR}/webp.bundle
echo "OUT_LIB_PATHS_webpdecoder = ${OUT_LIB_PATHS_webpdecoder}"
lipo -create ${OUT_LIB_PATHS_webpdecoder} -output ${LIB_DIR}/webpdecoder.bundle
echo "OUT_LIB_PATHS_webpdemux = ${OUT_LIB_PATHS_webpdemux}"
lipo -create ${OUT_LIB_PATHS_webpdemux} -output ${LIB_DIR}/webpdemux.bundle
echo "OUT_LIB_PATHS_webpmux = ${OUT_LIB_PATHS_webpmux}"
lipo -create ${OUT_LIB_PATHS_webpmux} -output ${LIB_DIR}/webpmux.bundle
ls -al ${LIB_DIR}
lipo -info ${LIB_DIR}/webp.bundle
lipo -info ${LIB_DIR}/webpdecoder.bundle
lipo -info ${LIB_DIR}/webpdemux.bundle
lipo -info ${LIB_DIR}/webpmux.bundle