@@ -20,12 +20,12 @@ toolchain="gnu"
2020
2121while [ " $# " -gt 0 ]; do
2222 case " $1 " in
23+ --sources)
24+ sources=" $( realpath $2 ) "
25+ shift 2
26+ ;;
2327 --arch)
2428 arch=" $2 "
25- if [ " $arch " != " x64" ] && [ " $arch " != " arm64" ]; then
26- echo " Error: Invalid value for --arch. Must be 'x64' or 'arm64'."
27- exit 1
28- fi
2929 shift 2
3030 ;;
3131 --profile)
@@ -56,14 +56,20 @@ if [ -z "$arch" ]; then
5656 exit 1
5757fi
5858
59+ if [ -z " $sources " ]; then
60+ echo " Error: --sources must be set."
61+ exit 1
62+ fi
63+
5964echo " Building LiveKit WebRTC - Linux"
6065echo " Arch: $arch "
6166echo " Profile: $profile "
6267echo " Toolchain: $toolchain "
6368
64- export COMMAND_DIR=$( cd $( dirname $0 ) ; pwd)
65- export OUTPUT_DIR=" $( pwd) /build-$arch -$profile "
66- export ARTIFACTS_DIR=" $( pwd) /linux-$arch -$profile "
69+ COMMAND_DIR=$( cd $( dirname $0 ) ; pwd)
70+ OUTPUT_DIR=" $( dirname " $sources " ) "
71+ BUILD_DIR=" $OUTPUT_DIR /build-$arch -$profile "
72+ ARTIFACTS_DIR=" $OUTPUT_DIR /linux-$arch -$profile "
6773
6874if [ " $toolchain " == " gnu" ]; then
6975 [ -n " $CC " ] || export CC=" $( which gcc) "
@@ -93,39 +99,12 @@ elif [ "$toolchain" == "llvm" ]; then
9399 custom_toolchain=\" //build/toolchain/linux/unbundle:default\" \
94100 host_toolchain=\" //build/toolchain/linux/unbundle:default\" "
95101elif [ " $toolchain " == " chromium-llvm" ]; then
96- AR=" $COMMAND_DIR /src /third_party/llvm-build/Release+Asserts/bin/llvm-ar"
97- OBJCOPY=" $COMMAND_DIR /src /third_party/llvm-build/Release+Asserts/bin/llvm-objcopy"
102+ AR=" $sources /third_party/llvm-build/Release+Asserts/bin/llvm-ar"
103+ OBJCOPY=" $sources /third_party/llvm-build/Release+Asserts/bin/llvm-objcopy"
98104 chromium_libcxx=true
99105 toolchain_gn_args=" is_clang=true use_custom_libcxx=true"
100106fi
101107
102- set -x
103-
104- if [ ! -e " $( pwd) /depot_tools" ]
105- then
106- git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
107- fi
108-
109- # must be done after runing `which` to find toolchain's executables above
110- export PATH=" $( pwd) /depot_tools:$PATH "
111-
112- if [ ! -e " $( pwd) /src" ]; then
113- # use --nohooks to avoid the download_from_google_storage hook that takes > 6 minutes
114- # then manually run the other hooks
115- gclient sync -D --no-history --nohooks
116- python3 src/tools/rust/update_rust.py
117- if [ " $toolchain " == " chromium-llvm" ] || [ " $toolchain " == " llvm" ]; then
118- python3 src/tools/clang/scripts/update.py
119- fi
120- fi
121-
122- cd src
123- git apply " $COMMAND_DIR /patches/add_licenses.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
124- git apply " $COMMAND_DIR /patches/ssl_verify_callback_with_native_handle.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
125- git apply " $COMMAND_DIR /patches/add_deps.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
126- git apply " $COMMAND_DIR /patches/david_disable_gun_source_macro.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
127- cd ..
128-
129108debug=" false"
130109if [ " $profile " = " debug" ]; then
131110 debug=" true"
@@ -158,29 +137,30 @@ args="is_debug=$debug \
158137 rtc_use_x11=false \
159138 $toolchain_gn_args "
160139
161- set -e
140+ set -xe
162141
163142# generate ninja files
164- gn gen " $OUTPUT_DIR " --root=" src" --args=" ${args} "
143+ export PATH=" $sources /depot_tools:$PATH "
144+ gn gen " $BUILD_DIR " --root=" $sources " --args=" ${args} "
165145
166146# build static library
167- ninja -C " $OUTPUT_DIR " :default
147+ ninja -C " $BUILD_DIR " :default
168148
169149mkdir -p " $ARTIFACTS_DIR /lib"
170150
171151# make libwebrtc.a
172152# don't include nasm
173- " $AR " -rc " $ARTIFACTS_DIR /lib/libwebrtc.a" ` find " $OUTPUT_DIR /obj" -name ' *.o' -not -path " */third_party/nasm/*" `
153+ " $AR " -rc " $ARTIFACTS_DIR /lib/libwebrtc.a" ` find " $BUILD_DIR /obj" -name ' *.o' -not -path " */third_party/nasm/*" `
174154" $OBJCOPY " --redefine-syms=" $COMMAND_DIR /boringssl_prefix_symbols.txt" " $ARTIFACTS_DIR /lib/libwebrtc.a"
175155
176- python3 " ./src /tools_webrtc/libs/generate_licenses.py" \
177- --target :default " $OUTPUT_DIR " " $OUTPUT_DIR "
156+ python3 " $sources /tools_webrtc/libs/generate_licenses.py" \
157+ --target :default " $BUILD_DIR " " $BUILD_DIR "
178158
179- cp " $OUTPUT_DIR /obj/webrtc.ninja" " $ARTIFACTS_DIR "
180- cp " $OUTPUT_DIR /args.gn" " $ARTIFACTS_DIR "
181- cp " $OUTPUT_DIR /LICENSE.md" " $ARTIFACTS_DIR "
159+ cp " $BUILD_DIR /obj/webrtc.ninja" " $ARTIFACTS_DIR "
160+ cp " $BUILD_DIR /args.gn" " $ARTIFACTS_DIR "
161+ cp " $BUILD_DIR /LICENSE.md" " $ARTIFACTS_DIR "
182162
183- cd src
163+ cd $sources
184164if [ $chromium_libcxx == " true" ]; then
185165 mkdir -p " $ARTIFACTS_DIR /include/buildtools/third_party"
186166 cp -R buildtools/third_party/libc++ " $ARTIFACTS_DIR /include/buildtools/third_party"
0 commit comments