@@ -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) "
@@ -91,39 +97,12 @@ elif [ "$toolchain" == "llvm" ]; then
9197 custom_toolchain=\" //build/toolchain/linux/unbundle:default\" \
9298 host_toolchain=\" //build/toolchain/linux/unbundle:default\" "
9399elif [ " $toolchain " == " chromium-llvm" ]; then
94- AR=" $COMMAND_DIR /src /third_party/llvm-build/Release+Asserts/bin/llvm-ar"
95- OBJCOPY=" $COMMAND_DIR /src /third_party/llvm-build/Release+Asserts/bin/llvm-objcopy"
100+ AR=" $sources /third_party/llvm-build/Release+Asserts/bin/llvm-ar"
101+ OBJCOPY=" $sources /third_party/llvm-build/Release+Asserts/bin/llvm-objcopy"
96102 chromium_libcxx=true
97103 toolchain_gn_args=" is_clang=true use_custom_libcxx=true"
98104fi
99105
100- set -x
101-
102- if [ ! -e " $( pwd) /depot_tools" ]
103- then
104- git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
105- fi
106-
107- # must be done after runing `which` to find toolchain's executables above
108- export PATH=" $( pwd) /depot_tools:$PATH "
109-
110- if [ ! -e " $( pwd) /src" ]; then
111- # use --nohooks to avoid the download_from_google_storage hook that takes > 6 minutes
112- # then manually run the other hooks
113- gclient sync -D --no-history --nohooks
114- python3 src/tools/rust/update_rust.py
115- if [ " $toolchain " == " chromium-llvm" ] || [ " $toolchain " == " llvm" ]; then
116- python3 src/tools/clang/scripts/update.py
117- fi
118- fi
119-
120- cd src
121- git apply " $COMMAND_DIR /patches/add_licenses.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
122- git apply " $COMMAND_DIR /patches/ssl_verify_callback_with_native_handle.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
123- git apply " $COMMAND_DIR /patches/add_deps.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
124- git apply " $COMMAND_DIR /patches/david_disable_gun_source_macro.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
125- cd ..
126-
127106debug=" false"
128107if [ " $profile " = " debug" ]; then
129108 debug=" true"
@@ -156,29 +135,30 @@ args="is_debug=$debug \
156135 rtc_use_x11=false \
157136 $toolchain_gn_args "
158137
159- set -e
138+ set -xe
160139
161140# generate ninja files
162- gn gen " $OUTPUT_DIR " --root=" src" --args=" ${args} "
141+ export PATH=" $sources /depot_tools:$PATH "
142+ gn gen " $BUILD_DIR " --root=" $sources " --args=" ${args} "
163143
164144# build static library
165- ninja -C " $OUTPUT_DIR " :default
145+ ninja -C " $BUILD_DIR " :default
166146
167147mkdir -p " $ARTIFACTS_DIR /lib"
168148
169149# make libwebrtc.a
170150# don't include nasm
171- " $AR " -rc " $ARTIFACTS_DIR /lib/libwebrtc.a" ` find " $OUTPUT_DIR /obj" -name ' *.o' -not -path " */third_party/nasm/*" `
151+ " $AR " -rc " $ARTIFACTS_DIR /lib/libwebrtc.a" ` find " $BUILD_DIR /obj" -name ' *.o' -not -path " */third_party/nasm/*" `
172152" $OBJCOPY " --redefine-syms=" $COMMAND_DIR /boringssl_prefix_symbols.txt" " $ARTIFACTS_DIR /lib/libwebrtc.a"
173153
174- python3 " ./src /tools_webrtc/libs/generate_licenses.py" \
175- --target :default " $OUTPUT_DIR " " $OUTPUT_DIR "
154+ python3 " $sources /tools_webrtc/libs/generate_licenses.py" \
155+ --target :default " $BUILD_DIR " " $BUILD_DIR "
176156
177- cp " $OUTPUT_DIR /obj/webrtc.ninja" " $ARTIFACTS_DIR "
178- cp " $OUTPUT_DIR /args.gn" " $ARTIFACTS_DIR "
179- cp " $OUTPUT_DIR /LICENSE.md" " $ARTIFACTS_DIR "
157+ cp " $BUILD_DIR /obj/webrtc.ninja" " $ARTIFACTS_DIR "
158+ cp " $BUILD_DIR /args.gn" " $ARTIFACTS_DIR "
159+ cp " $BUILD_DIR /LICENSE.md" " $ARTIFACTS_DIR "
180160
181- cd src
161+ cd $sources
182162if [ $chromium_libcxx == " true" ]; then
183163 mkdir -p " $ARTIFACTS_DIR /include/buildtools/third_party"
184164 cp -R buildtools/third_party/libc++ " $ARTIFACTS_DIR /include/buildtools/third_party"
0 commit comments