-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_mpegh.sh
executable file
·101 lines (67 loc) · 2.38 KB
/
build_mpegh.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
#!/bin/bash
set -x
pushd .
if [ -d "mpeghdec" ];
then
cd mpeghdec
sed -i'.bak' -e 's/[email protected]:/https:\/\/github.com\//' CMakeLists.txt
mpeghdec="${PWD}"
IOS_SDK_VERSION=""
IOS_MIN_SDK_VERSION="8.0"
DEVELOPER=`xcode-select -print-path`
buildIOS() {
ARCH=$1
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then
PLATFORM="iPhoneSimulator"
SDK_TO_USE="iphonesimulator"
else
PLATFORM="iPhoneOS"
SDK_TO_USE="iphoneos"
fi
mkdir -p build_$ARCH
cat << EOF > build_$ARCH/ios_clang_$ARCH.cmake
set(CMAKE_SYSTEM_NAME "iOS")
set(IOS TRUE)
# https://gitlab.kitware.com/cmake/cmake/-/issues/19655
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
set(SDK_TO_USE $SDK_TO_USE)
set(CMAKE_OSX_ARCHITECTURES $ARCH CACHE STRING "OSX Architectures")
set(CMAKE_OSX_DEPLOYMENT_TARGET 9.0 CACHE STRING "OSX Deployment target")
if(NOT "\${CMAKE_GENERATOR}" MATCHES "Xcode")
message(FATAL_ERROR "Only Xcode as generator for iOS builds supported")
endif()
execute_process(COMMAND xcodebuild -version -sdk \${SDK_TO_USE} Path
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT DEFINED CMAKE_OSX_SYSROOT)
message(FATAL_ERROR "Please make sure Xcode is installed")
endif()
EOF
if [[ "${ARCH}" == "armv7" ]]; then
echo 'set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -marm" CACHE STRING "c++ flags")' >> build_$ARCH/ios_clang_$ARCH.cmake
echo 'set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -marm" CACHE STRING "c flags")' >> build_$ARCH/ios_clang_$ARCH.cmake
sed -i'.bak' -e 's/__arm__/__thumb__/' src/libMpeghDec/src/stereo.cpp src/libFDK/src/scale.cpp
fi
echo -e "**Building mpeghdec for ${PLATFORM} ${IOS_SDK_VERSION} ${ARCH}"
cmake -S . -B build_$ARCH -G Xcode -Dmpeghdec_BUILD_BINARIES=OFF -DCMAKE_TOOLCHAIN_FILE=build_$ARCH/ios_clang_$ARCH.cmake
cmake --build build_$ARCH --config Release
libtool -static -o build_$ARCH/lib/libmpegh.a build_$ARCH/lib/Release/*.a
}
buildIOS "armv7"
buildIOS "arm64"
buildIOS "i386"
buildIOS "x86_64"
# #buildIOS "arm64e" "nobitcode"
lipo build_*/lib/*.a -create -output ../lib/iOS/libmpegh.a
# lipo \
# "${NGHTTP2}/iOS/armv7/lib/libnghttp2.a" \
# "${NGHTTP2}/iOS/arm64/lib/libnghttp2.a" \
# "${NGHTTP2}/iOS/i386/lib/libnghttp2.a" \
# "${NGHTTP2}/iOS/x86_64/lib/libnghttp2.a" \
# -create -output "${NGHTTP2}/iOS/libnghttp2.a"
fi
popd
# cp -av ${NGHTTP2}/iOS/libnghttp2.a lib/iOS/
set +x