-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbuild.mac.sh
More file actions
executable file
·138 lines (124 loc) · 5.72 KB
/
build.mac.sh
File metadata and controls
executable file
·138 lines (124 loc) · 5.72 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/env bash
set -euo pipefail
cmake_configure() {
local test_arg=""
if [ -n "${LT_ENABLE_TEST:-}" ]; then
test_arg=" -DLT_ENABLE_TEST=${LT_ENABLE_TEST}"
fi
if [ -z "${LT_DUMP_URL:-}" ]; then
cmake -B build/$build_type -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=$build_type -DCMAKE_INSTALL_PREFIX=install/$build_type${test_arg}
else
cmake -B build/$build_type -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=$build_type -DLT_DUMP=ON -DLT_DUMP_URL="$LT_DUMP_URL" -DCMAKE_INSTALL_PREFIX=install/$build_type${test_arg}
fi
}
cmake_build() {
cmake --build build/$build_type --parallel $(sysctl -n hw.logicalcpu)
cmake --install build/$build_type
}
cmake_clean() {
cmake --build build/$build_type --target clean
}
check_build_type() {
bt=$( tr '[:upper:]' '[:lower:]' <<<"$build_type" )
if [ ${bt} = "debug" ]; then
build_type="Debug"
echo "Debug"
elif [ ${bt} = "release" ] || [ ${bt} = "relwithdebinfo" ]; then
build_type="RelWithDebInfo"
echo "RelWithDebInfo"
else
echo "Please specify target type [ Debug | Release ]"
exit -1
fi
}
rtc_fetch() {
rtc_url="https://github.com/numbaa/rtc-prebuilt/releases/download/v0.7.10/rtc.mac.zip"
mkdir -p ./src/transport/rtc/mac
echo "Fetch $rtc_url"
curl -L $rtc_url -o ./third_party/prebuilt/rtc.mac.zip
echo "Extra rtc.mac.zip"
unzip ./third_party/prebuilt/rtc.mac.zip -d ./src/transport/rtc/mac
}
prebuilt_fetch() {
libs=(
"mbedtls https://github.com/numbaa/mbedtls-build/releases/download/v3.5.2-2/mbedtls.mac.v3.5.2-2.tar.gz"
"sdl https://github.com/numbaa/sdl-build/releases/download/v2.28.4-7/sdl.mac.v2.28.4-7.tar.gz"
"libuv https://github.com/numbaa/libuv-build/releases/download/v1.44.1-5/libuv.mac.v1.44.1-5.tar.gz"
"opus https://github.com/numbaa/opus-build/releases/download/v1.4-4/opus.mac.v1.4-4.tar.gz"
"g3log https://github.com/numbaa/g3log-build/releases/download/v2.3-6/g3log.mac.v2.3-6.tar.gz"
"googletest https://github.com/numbaa/googletest-build/releases/download/v1.13.0-4/googletest.mac.v1.13.0-4.tar.gz"
"ffmpeg https://github.com/numbaa/ffmpeg-build/releases/download/v5.1.3-13/ffmpeg.mac.v5.1.3-13.tar.gz"
"protobuf https://github.com/numbaa/protobuf-build/releases/download/v3.24.3-9/protobuf.mac.v3.24.3-9.tar.gz"
"sqlite https://github.com/numbaa/sqlite-build/releases/download/v3.43.1-8/sqlite3.mac.v3.43.1-8.tar.gz"
)
mkdir -p ./third_party/prebuilt
for lib in "${libs[@]}"; do
item=($lib)
lib_name=${item[0]}
lib_url=${item[1]}
echo "Fetch $lib_url"
curl -L $lib_url -o ./third_party/prebuilt/$lib_name.mac.tar.gz
mkdir -p ./third_party/prebuilt/$lib_name/mac
echo "Extra $lib_name.mac.tar.gz"
tar -xzvf ./third_party/prebuilt/$lib_name.mac.tar.gz -C ./third_party/prebuilt/$lib_name/mac
done
rtc_fetch
}
make_bundle() {
mkdir -p install/$build_type/lanthing.app/Contents/Frameworks
cp third_party/prebuilt/g3log/mac/lib/*.dylib install/$build_type/lanthing.app/Contents/Frameworks/
cp third_party/prebuilt/protobuf/mac/lib/*.dylib install/$build_type/lanthing.app/Contents/Frameworks/
cp third_party/prebuilt/ffmpeg/mac/lib/libavutil.57.28.100.dylib install/$build_type/lanthing.app/Contents/Frameworks/
cp third_party/prebuilt/ffmpeg/mac/lib/libavcodec.59.37.100.dylib install/$build_type/lanthing.app/Contents/Frameworks/
cp third_party/prebuilt/ffmpeg/mac/lib/libswresample.4.7.100.dylib install/$build_type/lanthing.app/Contents/Frameworks/
cp third_party/prebuilt/libuv/mac/lib/*.dylib install/$build_type/lanthing.app/Contents/Frameworks/
cp third_party/prebuilt/sdl/mac/lib/*.dylib install/$build_type/lanthing.app/Contents/Frameworks/
cp third_party/prebuilt/mbedtls/mac/lib/*.dylib install/$build_type/lanthing.app/Contents/Frameworks/
cp third_party/prebuilt/sqlite/mac/*.dylib install/$build_type/lanthing.app/Contents/Frameworks/
cp install/$build_type/bin/librtc* install/$build_type/lanthing.app/Contents/Frameworks/
install_name_tool -change ./install/lib/libavcodec.59.dylib @rpath/libavcodec.59.37.100.dylib install/$build_type/lanthing.app/Contents/MacOS/lanthing
install_name_tool -change ./install/lib/libavutil.57.dylib @rpath/libavutil.57.28.100.dylib install/$build_type/lanthing.app/Contents/MacOS/lanthing
install_name_tool -change ./install/lib/libswresample.4.dylib @rpath/libswresample.4.7.100.dylib install/$build_type/lanthing.app/Contents/MacOS/lanthing
install_name_tool -change /Users/runner/work/sqlite-build/sqlite-build/sqlite/build/install/lib/libsqlite3.0.dylib @rpath/libsqlite3.0.dylib install/RelWithDebInfo/lanthing.app/Contents/MacOS/lanthing
macdeployqt install/$build_type/lanthing.app
}
create_dmg() {
create-dmg lanthing.dmg install/$build_type/lanthing.app
}
prebuilt_clean() {
rm -rf third_party/prebuilt
rm -rf src/transport/rtc
}
print_usage() {
echo "Usage:"
echo " build.sh prebuilt [ fetch | clean ]"
echo " build.sh build [ Debug | Release ]"
echo " build.sh package [ Debug | Release ]"
echo " build.sh clean [ Debug | Release ]"
}
if [ "$1" = "prebuilt" ]; then
if [ "$2" = "fetch" ]; then
prebuilt_fetch
elif [ "$2" = "clean" ]; then
prebuilt_clean
else
echo "Please specify prebuilt type [ fetch | clean ]"
exit -1
fi
elif [ "$1" = "clean" ]; then
build_type=$2
check_build_type
cmake_clean
elif [ "$1" = "build" ]; then
build_type=$2
check_build_type
cmake_configure
cmake_build
elif [ "$1" = "package" ]; then
build_type=$2
check_build_type
make_bundle
create_dmg
else
print_usage
fi