@@ -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,45 +99,14 @@ 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 \
100106 use_custom_libcxx=true \
101107 use_sysroot=true"
102108fi
103109
104- set -x
105-
106- if [ ! -e " $( pwd) /depot_tools" ]
107- then
108- git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
109- fi
110-
111- # must be done after runing `which` to find toolchain's executables above
112- export PATH=" $( pwd) /depot_tools:$PATH "
113-
114- if [ ! -e " $( pwd) /src" ]; then
115- # use --nohooks to avoid the download_from_google_storage hook that takes > 6 minutes
116- # then manually run the other hooks
117- gclient sync -D --no-history --nohooks
118- python3 src/tools/rust/update_rust.py
119- if [ " $toolchain " == " chromium-llvm" ] || [ " $toolchain " == " llvm" ]; then
120- python3 src/tools/clang/scripts/update.py
121- fi
122- if [ " $toolchain " == " chromium-llvm" ]; then
123- python3 src/build/linux/sysroot_scripts/install-sysroot.py --arch=x64
124- python3 src/build/linux/sysroot_scripts/install-sysroot.py --arch=arm64
125- fi
126- fi
127-
128- cd src
129- git apply " $COMMAND_DIR /patches/add_licenses.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
130- git apply " $COMMAND_DIR /patches/ssl_verify_callback_with_native_handle.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
131- git apply " $COMMAND_DIR /patches/add_deps.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
132- git apply " $COMMAND_DIR /patches/david_disable_gun_source_macro.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
133- cd ..
134-
135110debug=" false"
136111if [ " $profile " = " debug" ]; then
137112 debug=" true"
@@ -163,29 +138,35 @@ args="is_debug=$debug \
163138 rtc_use_x11=false \
164139 $toolchain_gn_args "
165140
166- set -e
141+ set -xe
142+
143+ if [ " $toolchain " == " chromium-llvm" ]; then
144+ python3 " $sources /build/linux/sysroot_scripts/install-sysroot.py" --arch=x64
145+ python3 " $sources /build/linux/sysroot_scripts/install-sysroot.py" --arch=arm64
146+ fi
167147
168148# generate ninja files
169- gn gen " $OUTPUT_DIR " --root=" src" --args=" ${args} "
149+ export PATH=" $sources /depot_tools:$PATH "
150+ gn gen " $BUILD_DIR " --root=" $sources " --args=" ${args} "
170151
171152# build static library
172- ninja -C " $OUTPUT_DIR " :default
153+ ninja -C " $BUILD_DIR " :default
173154
174155mkdir -p " $ARTIFACTS_DIR /lib"
175156
176157# make libwebrtc.a
177158# don't include nasm
178- " $AR " -rc " $ARTIFACTS_DIR /lib/libwebrtc.a" ` find " $OUTPUT_DIR /obj" -name ' *.o' -not -path " */third_party/nasm/*" `
159+ " $AR " -rc " $ARTIFACTS_DIR /lib/libwebrtc.a" ` find " $BUILD_DIR /obj" -name ' *.o' -not -path " */third_party/nasm/*" `
179160" $OBJCOPY " --redefine-syms=" $COMMAND_DIR /boringssl_prefix_symbols.txt" " $ARTIFACTS_DIR /lib/libwebrtc.a"
180161
181- python3 " ./src /tools_webrtc/libs/generate_licenses.py" \
182- --target :default " $OUTPUT_DIR " " $OUTPUT_DIR "
162+ python3 " $sources /tools_webrtc/libs/generate_licenses.py" \
163+ --target :default " $BUILD_DIR " " $BUILD_DIR "
183164
184- cp " $OUTPUT_DIR /obj/webrtc.ninja" " $ARTIFACTS_DIR "
185- cp " $OUTPUT_DIR /args.gn" " $ARTIFACTS_DIR "
186- cp " $OUTPUT_DIR /LICENSE.md" " $ARTIFACTS_DIR "
165+ cp " $BUILD_DIR /obj/webrtc.ninja" " $ARTIFACTS_DIR "
166+ cp " $BUILD_DIR /args.gn" " $ARTIFACTS_DIR "
167+ cp " $BUILD_DIR /LICENSE.md" " $ARTIFACTS_DIR "
187168
188- cd src
169+ cd $sources
189170if [ $chromium_libcxx == " true" ]; then
190171 mkdir -p " $ARTIFACTS_DIR /include/buildtools/third_party"
191172 cp -R buildtools/third_party/libc++ " $ARTIFACTS_DIR /include/buildtools/third_party"
0 commit comments