-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathbuildffmpeg
executable file
·80 lines (71 loc) · 4.09 KB
/
buildffmpeg
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
#!/bin/bash
set -e
shopt -s extglob
SCRIPT=`readlink -fn "$0"`
EXES="ffmpeg ffprobe"
LIBS="libavcodec libavfilter libavformat libavutil libpostproc libswresample libswscale"
if [ "${ACTION}" == "clean" ]; then
echo Remove "${OBJECT_FILE_DIR}"
[ -n "${OBJECT_FILE_DIR}" -a -d "${OBJECT_FILE_DIR}" ] && rm -rf "${OBJECT_FILE_DIR}"
else
# For yasm and pkg-config
PATH=$PATH:/opt/homebrew/bin:/usr/local/bin
echo Build in ${OBJECT_FILE_DIR}
BUILT=""
for ARCH in $ARCHS; do
mkdir -p "${OBJECT_FILE_DIR}/${ARCH}"
cd "${OBJECT_FILE_DIR}/${ARCH}"
if [ -f config.h -a config.h -nt "${SCRIPT}" ]; then
echo Skipping configure
else
rm -f config.h
if [ "${CONFIGURATION}" == "Debug" ]; then
FLAGS="--disable-optimizations --disable-stripping"
else
FLAGS=
fi
if [ $ARCH == arm64 ]; then
FLAGS="$FLAGS --enable-cross-compile --enable-vfp --enable-neon"
elif [ $ARCH == x86_64 ]; then
FLAGS="$FLAGS --enable-cross-compile --cpu=haswell"
fi
PKG_CONFIG_LIBDIR="${BUILT_PRODUCTS_DIR}/${ARCH}/lib/pkgconfig" "${SRCROOT}/${TARGET_NAME}/configure" --prefix="${BUILT_PRODUCTS_DIR}/${ARCH}" --arch=${ARCH} --cc="clang -arch ${ARCH} -fapplication-extension" ${FLAGS} --enable-shared --enable-rpath --install-name-dir=@rpath --extra-ldflags=-liconv --enable-gpl --disable-doc --disable-indevs --disable-outdevs --disable-network --disable-avdevice --disable-muxers --disable-encoders --disable-bsfs --disable-filters --disable-protocols --disable-autodetect --enable-appkit --enable-avfoundation --enable-bzlib --enable-coreimage --enable-iconv --enable-libaom --enable-zlib --enable-audiotoolbox --enable-videotoolbox --enable-filter=scale --enable-muxer=image2 --enable-muxer=mp4 --enable-muxer=m4v --enable-muxer=ipod --enable-muxer=matroska --enable-muxer=webm --enable-encoder=png --enable-protocol=file --enable-protocol=pipe
fi
make -j`sysctl -n hw.physicalcpu` install
# Add rpath for install-time location of executables
for LIB in $LIBS; do
install_name_tool -delete_rpath "${BUILT_PRODUCTS_DIR}/${ARCH}/lib" `realpath "${BUILT_PRODUCTS_DIR}/${ARCH}/lib/${LIB}.dylib"`
done
for EXE in $EXES; do
install_name_tool -rpath "${BUILT_PRODUCTS_DIR}/${ARCH}/lib" @executable_path/../Frameworks "${BUILT_PRODUCTS_DIR}/${ARCH}/bin/${EXE}"
done
done
# Combine into Universal
echo Installing into ${BUILT_PRODUCTS_DIR}/universal
mkdir -p "${BUILT_PRODUCTS_DIR}/universal/bin"
for EXE in $EXES; do
lipo -create "${BUILT_PRODUCTS_DIR}/"+(${ARCHS/ /|})"/bin/${EXE}" -output "${BUILT_PRODUCTS_DIR}/universal/bin/${EXE}"
if [ -n "$DEVELOPMENT_TEAM" -a -n "$PRODUCT_BUNDLE_IDENTIFIER" ]; then
# Add sandbox entitlement suitable for a helper app
ENTITLEMENTS=`mktemp -t buildffmpeg`
if [ "${CONFIGURATION}" == "Debug" ]; then
echo -e '<plist version="1.0">\n<dict>\n<key>com.apple.security.inherit</key>\n<true/>\n<key>com.apple.security.get-task-allow</key>\n<true/>\n</dict>\n</plist>' > "${ENTITLEMENTS}"
else
echo -e '<plist version="1.0">\n<dict>\n<key>com.apple.security.inherit</key>\n<true/>\n</dict>\n</plist>' > "${ENTITLEMENTS}"
fi
codesign -s "${DEVELOPMENT_TEAM}" -i "${PRODUCT_BUNDLE_IDENTIFIER}.${EXE}" -o runtime --entitlements "${ENTITLEMENTS}" "${BUILT_PRODUCTS_DIR}/universal/bin/${EXE}"
rm "${ENTITLEMENTS}"
fi
done
mkdir -p "${BUILT_PRODUCTS_DIR}/universal/include"
# Assumes there aren't any material client impacting differences in config between archs
cp -p "${OBJECT_FILE_DIR}/${ARCHS/ */}/config.h" "${BUILT_PRODUCTS_DIR}/universal/include/"
mkdir -p "${BUILT_PRODUCTS_DIR}/universal/lib"
for LIB in $LIBS; do
cp -pr "${BUILT_PRODUCTS_DIR}/${ARCHS/ */}/include/${LIB}" "${BUILT_PRODUCTS_DIR}/universal/include/"
lipo -create "${BUILT_PRODUCTS_DIR}/"+(${ARCHS/ /|})"/lib/${LIB}.a" -output "${BUILT_PRODUCTS_DIR}/universal/lib/${LIB}.a"
# Install using the dylib's "install name" since that's what other FFmpeg dylibs will look for
DYLIB=$(basename `otool -DX ${BUILT_PRODUCTS_DIR}/${ARCHS/ */}/lib/${LIB}.dylib`)
lipo -create "${BUILT_PRODUCTS_DIR}/"+(${ARCHS/ /|})"/lib/${LIB}.dylib" -output "${BUILT_PRODUCTS_DIR}/universal/lib/${DYLIB}"
done
fi