mirror of
https://github.com/mollyim/ringrtc.git
synced 2025-05-14 06:10:38 +01:00
108 lines
2.7 KiB
Bash
Executable file
108 lines
2.7 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
#
|
|
# Copyright 2023 Signal Messenger, LLC
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
#
|
|
|
|
set -e
|
|
|
|
# shellcheck source=bin/env.sh
|
|
. "$(dirname "$0")"/env.sh
|
|
|
|
usage()
|
|
{
|
|
echo 'usage: build-call_sim-cli [-d|-r|-c]
|
|
where:
|
|
-d to create a debug build (default)
|
|
-r to create a release build
|
|
-c to clean the build artifacts'
|
|
}
|
|
|
|
clean()
|
|
{
|
|
# Remove all possible artifact directories.
|
|
cargo clean
|
|
}
|
|
|
|
BUILD_TYPE=debug
|
|
|
|
while [ "$1" != "" ]; do
|
|
case $1 in
|
|
-d | --debug )
|
|
BUILD_TYPE=debug
|
|
;;
|
|
-r | --release )
|
|
BUILD_TYPE=release
|
|
;;
|
|
-c | --clean )
|
|
clean
|
|
exit
|
|
;;
|
|
-h | --help )
|
|
usage
|
|
exit
|
|
;;
|
|
* )
|
|
usage
|
|
exit 1
|
|
esac
|
|
shift
|
|
done
|
|
|
|
get_default_platform()
|
|
{
|
|
hash rustup 2>/dev/null || { echo >&2 "Make sure you have rustup installed and properly configured! Aborting."; exit 1; }
|
|
|
|
case "$(rustup show active-toolchain)" in
|
|
*"x86_64-apple-darwin"* | *"aarch64-apple-darwin"* )
|
|
echo "darwin"
|
|
;;
|
|
*"x86_64-pc-windows"* )
|
|
echo "win32"
|
|
;;
|
|
*"x86_64-unknown-linux"* )
|
|
echo "linux"
|
|
;;
|
|
* )
|
|
echo "unknown"
|
|
esac
|
|
}
|
|
|
|
DEFAULT_PLATFORM=$(get_default_platform)
|
|
if [ "${DEFAULT_PLATFORM}" = "unknown" ]
|
|
then
|
|
printf "Unknown platform detected!\nPlease make sure you have installed a valid Rust toolchain via rustup! Aborting.\n"
|
|
exit 1
|
|
fi
|
|
|
|
export MACOSX_DEPLOYMENT_TARGET="10.15"
|
|
|
|
# Build WebRTC.
|
|
(
|
|
cd src/webrtc/src
|
|
WEBRTC_ARGS="rtc_build_examples=false rtc_build_tools=false rtc_include_tests=false rtc_enable_protobuf=false rtc_use_x11=false rtc_enable_sctp=false rtc_libvpx_build_vp9=true rtc_disable_metrics=true rtc_disable_trace_events=true rtc_use_dummy_audio_file_devices=true"
|
|
|
|
if [ "${BUILD_TYPE}" = "debug" ]
|
|
then
|
|
gn gen -C "${OUTPUT_DIR}"/debug "--args=${WEBRTC_ARGS}"
|
|
ninja -C "${OUTPUT_DIR}"/debug
|
|
else
|
|
gn gen -C "${OUTPUT_DIR}"/release "--args=${WEBRTC_ARGS} is_debug=false symbol_level=1"
|
|
ninja -C "${OUTPUT_DIR}"/release
|
|
fi
|
|
)
|
|
|
|
# Build and link the final RingRTC library.
|
|
(
|
|
if [ "${BUILD_TYPE}" = "debug" ]
|
|
then
|
|
OUTPUT_DIR="${OUTPUT_DIR}" cargo build --package ringrtc --bin call_sim-cli --features=call_sim
|
|
echo "Can run with target/debug/call_sim-cli"
|
|
else
|
|
# Build with debug line tables, but not full debug info.
|
|
export CARGO_PROFILE_RELEASE_DEBUG=1
|
|
OUTPUT_DIR="${OUTPUT_DIR}" cargo build --package ringrtc --bin call_sim-cli --features=call_sim --release
|
|
echo "Can run with target/release/call_sim-cli"
|
|
fi
|
|
)
|