BlueGit

ict rusty-teams

Files

rusty-teams / vendor / webrtc-sys / libwebrtc / build_ios.sh

build_ios.sh

build_ios.sh 4.6 KiB Download Raw
1#!/bin/bash
2# Exit immediately if any command fails. This ensures CI properly reports build
3# failures instead of continuing to create empty/broken artifacts.
4set -e
5
6# Copyright 2023 LiveKit, Inc.
7#
8# Licensed under the Apache License, Version 2.0 (the "License");
9# you may not use this file except in compliance with the License.
10# You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS,
16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17# See the License for the specific language governing permissions and
18# limitations under the License.
19
20
21arch=""
22profile="release"
23environment="device"
24
25while [ "$#" -gt 0 ]; do
26 case "$1" in
27 --arch)
28 arch="$2"
29 if [ "$arch" != "arm64" ]; then
30 echo "Error: Invalid value for --arch. Must 'arm64'."
31 exit 1
32 fi
33 shift 2
34 ;;
35 --environment)
36 environment="$2"
37 if [ "$environment" != "device" ] && [ "$environment" != "simulator" ]; then
38 echo "Error: Invalid value for --environment. Must be 'device' or 'simulator'."
39 exit 1
40 fi
41 shift 2
42 ;;
43 --profile)
44 profile="$2"
45 if [ "$profile" != "debug" ] && [ "$profile" != "release" ]; then
46 echo "Error: Invalid value for --profile. Must be 'debug' or 'release'."
47 exit 1
48 fi
49 shift 2
50 ;;
51 *)
52 echo "Error: Unknown argument '$1'"
53 exit 1
54 ;;
55 esac
56done
57
58if [ -z "$arch" ]; then
59 echo "Error: --arch must be set."
60 exit 1
61fi
62
63echo "Building LiveKit WebRTC - iOS"
64echo "Arch: $arch"
65echo "Profile: $profile"
66echo "Environment: $environment"
67
68if [ ! -e "$(pwd)/depot_tools" ]
69then
70 git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
71fi
72
73export COMMAND_DIR=$(cd $(dirname $0); pwd)
74export PATH="$(pwd)/depot_tools:$PATH"
75
76export OUTPUT_DIR="$(pwd)/src/out-$arch-$profile"
77export ARTIFACTS_DIR="$(pwd)/ios-$environment-$arch-$profile"
78
79if [ ! -e "$(pwd)/src" ]
80then
81 gclient sync -D --no-history
82fi
83
84source "$COMMAND_DIR/apply_patch.sh"
85
86cd src
87
88apply_patch "$COMMAND_DIR/patches/add_licenses.patch"
89apply_patch "$COMMAND_DIR/patches/fix_license_json_parsing.patch"
90apply_patch "$COMMAND_DIR/patches/ssl_verify_callback_with_native_handle.patch"
91apply_patch "$COMMAND_DIR/patches/add_deps.patch"
92apply_patch "$COMMAND_DIR/patches/external_audio_source.patch"
93
94cd ..
95
96mkdir -p "$ARTIFACTS_DIR/lib"
97
98debug="false"
99if [ "$profile" = "debug" ]; then
100 debug="true"
101fi
102
103# generate ninja files
104# Note: use_clang_modules=false is required to avoid libc++ header incompatibility
105# with Xcode 26.0. When enabled, C++ module compilation fails with errors like
106# "unknown type name 'size_t'" due to conflicts between WebRTC's bundled libc++
107# headers and the iOS SDK headers.
108gn gen "$OUTPUT_DIR" --root="src" \
109 --args="is_debug=$debug \
110 enable_dsyms=$debug \
111 target_os=\"ios\" \
112 target_cpu=\"$arch\" \
113 target_environment=\"$environment\" \
114 treat_warnings_as_errors=false \
115 ios_enable_code_signing=false \
116 rtc_enable_protobuf=false \
117 rtc_include_tests=false \
118 rtc_build_examples=false \
119 rtc_build_tools=false \
120 rtc_libvpx_build_vp9=false \
121 is_component_build=false \
122 enable_stripping=true \
123 rtc_enable_symbol_export=true \
124 rtc_enable_objc_symbol_export=false \
125 rtc_use_h264=false \
126 use_custom_libcxx=false \
127 use_clang_modules=false \
128 clang_use_chrome_plugins=false \
129 use_rtti=true \
130 use_lld=false"
131
132# build static library
133ninja -C "$OUTPUT_DIR" :default \
134 api/audio_codecs:builtin_audio_decoder_factory \
135 api/task_queue:default_task_queue_factory \
136 sdk:native_api \
137 sdk:default_codec_factory_objc \
138 pc:peer_connection \
139 sdk:videocapture_objc \
140 sdk:framework_objc
141
142# make libwebrtc.a
143# don't include nasm
144ar -rc "$ARTIFACTS_DIR/lib/libwebrtc.a" `find "$OUTPUT_DIR/obj" -name '*.o' -not -path "*/third_party/nasm/*"`
145
146# License generation - may fail locally due to GN warnings breaking JSON parsing
147# Use vpython3 from depot_tools for consistent Python version
148vpython3 "./src/tools_webrtc/libs/generate_licenses.py" \
149 --target :webrtc "$OUTPUT_DIR" "$OUTPUT_DIR" || echo "Warning: License generation failed"
150
151cp "$OUTPUT_DIR/obj/webrtc.ninja" "$ARTIFACTS_DIR"
152cp "$OUTPUT_DIR/obj/modules/desktop_capture/desktop_capture.ninja" "$ARTIFACTS_DIR" 2>/dev/null || true
153cp "$OUTPUT_DIR/args.gn" "$ARTIFACTS_DIR"
154
155cp "$OUTPUT_DIR/LICENSE.md" "$ARTIFACTS_DIR"
156
157cd src
158find . -name "*.h" -print | cpio -pd "$ARTIFACTS_DIR/include"
159find . -name "*.inc" -print | cpio -pd "$ARTIFACTS_DIR/include"