提交 87b0ee24 authored 作者: Nazar Mokrynskyi's avatar Nazar Mokrynskyi

Switch from GYP to Meson for compiling all targets, remove `bear` dependency as…

Switch from GYP to Meson for compiling all targets, remove `bear` dependency as required files are generated automatically, link libmediasoup-worker dependencies together (except OpenSSL, Rust version is currently broken because of that)
上级 084a0a0d
......@@ -2,16 +2,8 @@
/coverage/
/NO_GIT/
# clang-tidy stuff.
/worker/compile_commands.json
# gyp generated stuff.
# Generated stuff.
/worker/out/
/worker/**/*.xcodeproj/
/worker/**/*.sln
/worker/**/*.vcxproj
/worker/**/*.vcxproj.filters
/worker/**/*.vcxproj.user
# clang-fuzzer stuff is too big.
/worker/deps/clang-fuzzer
......
......@@ -96,7 +96,7 @@ Cleans built objects and binaries.
### `make clean-all`
Cleans all objects and binaries, including those generated for library dependencies (such as libuv, openssl, libsrtp, etc).
Cleans all objects and binaries as well as `meson` and `ninja` installed in local prefix with pip.
### `make xcode`
......@@ -119,25 +119,13 @@ Rewrites mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/
Builds and runs the `mediasoup-worker-test` binary at `worker/out/Release/` (or at `worker/out/Debug/` if the "MEDIASOUP_BUILDTYPE" environment variable is set to "Debug"), which uses [Catch2](https://github.com/catchorg/Catch2) to run test units located at `worker/test/` folder.
### `make bear`
Generates the `worker/compile_commands_template.json` file which is a ["Clang compilation database"](https://clang.llvm.org/docs/JSONCompilationDatabase.html).
**Requirements:**
* [Bear](https://github.com/rizsotto/Bear) is required.
- Install it in Debian/Ubuntu via `apt install bear` and in OSX via `brew install bear`.
- For now, Bear version must be 2.1.X.
* Before running `make bear` you must have mediasoup C/C++ dependencies already compiled. To be sure, run `make clean-all && make` before running `make bear`.
### `make tidy`
Runs [clang-tidy](http://clang.llvm.org/extra/clang-tidy/) and performs C++ code checks following `worker/.clang-tidy` rules.
**Requirements:**
* `make clean-all`, then `make` and then `make bear` must have been called first.
* `make clean` and `make` must have been called first.
* [PyYAML](https://pyyaml.org/) is required.
- In OSX install it with `brew install libyaml` and `sudo easy_install-X.Y pyyaml`.
......
......@@ -7,7 +7,7 @@ RUN \
&& apt-get install --yes \
bash-completion wget curl subversion screen gcc g++ cmake ninja-build golang \
autoconf libtool apache2 python-dev pkg-config zlib1g-dev libgcrypt11-dev \
libgss-dev libssl-dev libxml2-dev nasm libarchive-dev make bear automake \
libgss-dev libssl-dev libxml2-dev nasm libarchive-dev make automake \
libdbus-1-dev libboost-dev autoconf-archive bash-completion python-yaml
# Install node 10.
......
......@@ -2,58 +2,69 @@
# make tasks for mediasoup-worker.
#
# Best effort to prefer Python 2 executable since there are yet pending issues
# with gyp and Python3.
PYTHON ?= $(shell command -v python2 2> /dev/null || command -v python 2> /dev/null || echo python3)
# We need Python 3 here.
PYTHON ?= $(shell command -v python3 2> /dev/null || echo python)
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
CORES ?= $(shell ${ROOT_DIR}/scripts/cpu_cores.sh || echo 4)
MEDIASOUP_OUT_DIR ?= out
MEDIASOUP_BUILDTYPE ?= Release
GULP = ./scripts/node_modules/.bin/gulp
LCOV = ./deps/lcov/bin/lcov
BEAR ?= bear
SED ?= sed
DOCKER ?= docker
PIP_DIR = $(MEDIASOUP_OUT_DIR)/pip
MESON ?= $(PIP_DIR)/bin/meson
MESON_ARGS ?= ""
# Disable `*.pyc` files creation
export PYTHONDONTWRITEBYTECODE = 1
# Instruct `meson` where to look for ninja binary
export NINJA = $(PIP_DIR)/bin/ninja
# Instruct Python where to look for modules it needs, such that `meson` actually runs from installed location
export PYTHONPATH = $(PIP_DIR)
.PHONY: \
default clean clean-all xcode lint format test bear tidy \
default meson-ninja setup clean clean-all mediasoup-worker xcode lint format test tidy \
fuzzer fuzzer-run-all docker-build docker-run libmediasoup-worker
default:
ifeq ($(MEDIASOUP_WORKER_BIN),)
$(PYTHON) ./scripts/configure.py -R mediasoup-worker
$(MAKE) -j$(CORES) BUILDTYPE=$(MEDIASOUP_BUILDTYPE) -C $(MEDIASOUP_OUT_DIR)
default: mediasoup-worker
meson-ninja:
ifeq ($(wildcard $(PIP_DIR)),)
# Updated pip and setuptools are needed for meson
# `--system` is not present everywhere and is only needed as workaround for Debian-specific issue (copied from
# https://github.com/gluster/gstatus/pull/33), fallback to command without `--system` if the first one fails.
$(PYTHON) -m pip install --system --target=$(PIP_DIR) pip setuptools || \
$(PYTHON) -m pip install --target=$(PIP_DIR) pip setuptools
# Install `meson` and `ninja` using `pip` into custom location, so we don't depend on system-wide installation
$(PYTHON) -m pip install --upgrade --target=$(PIP_DIR) meson ninja
endif
setup: meson-ninja
ifeq ($(wildcard $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)),)
ifeq ($(MEDIASOUP_BUILDTYPE),Release)
$(MESON) setup --buildtype release $(MESON_ARGS) $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
else
ifeq ($(MEDIASOUP_BUILDTYPE),Debug)
$(MESON) setup --buildtype debug $(MESON_ARGS) $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
else
$(MESON) setup --buildtype $(MEDIASOUP_BUILDTYPE) $(MESON_ARGS) $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
endif
endif
endif
clean:
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Release/mediasoup-worker
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Release/obj.target/mediasoup-worker
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Release/mediasoup-worker-test
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Release/obj.target/mediasoup-worker-test
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Release/mediasoup-worker-fuzzer
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Release/obj.target/mediasoup-worker-fuzzer
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Release/libmediasoup-worker.a
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Release/obj.target/libmediasoup-worker.a
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Debug/mediasoup-worker
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Debug/obj.target/mediasoup-worker
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Debug/mediasoup-worker-test
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Debug/obj.target/mediasoup-worker-test
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Debug/mediasoup-worker-fuzzer
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Debug/obj.target/mediasoup-worker-fuzzer
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Debug/libmediasoup-worker.a
$(RM) -rf $(MEDIASOUP_OUT_DIR)/Debug/obj.target/libmediasoup-worker.a
$(RM) -rf $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
clean-all:
$(RM) -rf $(MEDIASOUP_OUT_DIR)
$(RM) -rf $(ROOT_DIR)/mediasoup-worker.xcodeproj
$(RM) -rf $(ROOT_DIR)/mediasoup-worker-test.xcodeproj
$(RM) -rf $(ROOT_DIR)/deps/gyp/pylib/gyp/__pycache__
$(RM) -rf $(ROOT_DIR)/deps/gyp/pylib/gyp/generator/__pycache__
$(RM) -rf $(ROOT_DIR)/deps/*/*.xcodeproj
$(RM) -rf $(ROOT_DIR)/libwebrtc/*/*.xcodeproj
xcode:
$(PYTHON) ./scripts/configure.py --format=xcode
mediasoup-worker: setup
ifeq ($(MEDIASOUP_WORKER_BIN),)
$(MESON) compile -j $(CORES) -C $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) mediasoup-worker
endif
xcode: setup
$(MESON) setup --buildtype debug --backend xcode $(MEDIASOUP_OUT_DIR)/xcode
lint:
$(GULP) --gulpfile ./scripts/gulpfile.js lint:worker
......@@ -61,38 +72,30 @@ lint:
format:
$(GULP) --gulpfile ./scripts/gulpfile.js format:worker
test:
test: setup
ifeq ($(MEDIASOUP_WORKER_BIN),)
$(PYTHON) ./scripts/configure.py -R mediasoup-worker-test
$(MAKE) -j$(CORES) BUILDTYPE=$(MEDIASOUP_BUILDTYPE) -C $(MEDIASOUP_OUT_DIR)
$(MESON) compile -j $(CORES) -C $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) mediasoup-worker-test
$(LCOV) --directory ./ --zerocounters
./$(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/mediasoup-worker-test --invisibles --use-colour=yes $(MEDIASOUP_TEST_TAGS)
endif
bear:
$(MAKE) clean
$(BEAR) -o compile_commands_template.json $(MAKE)
$(SED) -i" " "s|$(PWD)|PATH|g" compile_commands_template.json
tidy:
$(SED) "s|PATH|$(PWD)|g" compile_commands_template.json > compile_commands.json
$(PYTHON) ./scripts/clang-tidy.py \
-clang-tidy-binary=./scripts/node_modules/.bin/clang-tidy \
-clang-apply-replacements-binary=./scripts/node_modules/.bin/clang-apply-replacements \
-header-filter='(Channel/**/*.hpp|DepLibSRTP.hpp|DepLibUV.hpp|DepLibWebRTC.hpp|DepOpenSSL.hpp|DepUsrSCTP.hpp|LogLevel.hpp|Logger.hpp|MediaSoupError.hpp|RTC/**/*.hpp|Settings.hpp|Utils.hpp|Worker.hpp|common.hpp|handles/**/*.hpp)' \
-p=. \
-p=$(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) \
-j=$(CORES) \
-checks=$(MEDIASOUP_TIDY_CHECKS) \
-quiet
fuzzer:
fuzzer: setup
ifeq ($(MEDIASOUP_WORKER_BIN),)
$(PYTHON) ./scripts/configure.py -R mediasoup-worker-fuzzer
$(MAKE) -j$(CORES) BUILDTYPE=$(MEDIASOUP_BUILDTYPE) -C $(MEDIASOUP_OUT_DIR)
$(MESON) compile -j $(CORES) -C $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) mediasoup-worker-fuzzer
endif
fuzzer-run-all:
LSAN_OPTIONS=verbosity=1:log_threads=1 ./$(MEDIASOUP_OUT_DIR)/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus
LSAN_OPTIONS=verbosity=1:log_threads=1 ./$(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus
docker-build:
ifeq ($(DOCKER_NO_CACHE),true)
......@@ -109,6 +112,5 @@ docker-run:
-v $(shell pwd)/../:/mediasoup \
mediasoup/docker:latest
libmediasoup-worker:
$(PYTHON) ./scripts/configure.py -R libmediasoup-worker
$(MAKE) -j$(CORES) BUILDTYPE=$(MEDIASOUP_BUILDTYPE) -C $(MEDIASOUP_OUT_DIR)
libmediasoup-worker: setup
$(MESON) compile -j $(CORES) -C $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) libmediasoup-worker
......@@ -116,7 +116,6 @@ fn main() {
// number of files. So instead we build in place, copy files to out directory and then clean
// after ourselves
{
// Build
if !Command::new("make")
.arg("libmediasoup-worker")
.env("PYTHONDONTWRITEBYTECODE", "1")
......@@ -129,18 +128,7 @@ fn main() {
panic!("Failed to build libmediasoup-worker")
}
for file in &[
"libnetstring.a",
"libuv.a",
"libopenssl.a",
"libsrtp.a",
"libusrsctp.a",
"libwebrtc.a",
"libmediasoup-worker.a",
"libabseil.a",
#[cfg(windows)]
"libgetopt.a",
] {
for file in &["libmediasoup-worker.a"] {
std::fs::copy(
format!("{}/out/Release/{}", current_dir, file),
format!("{}/{}", out_dir, file),
......@@ -168,15 +156,6 @@ fn main() {
}
}
println!("cargo:rustc-link-lib=static=netstring");
println!("cargo:rustc-link-lib=static=uv");
println!("cargo:rustc-link-lib=static=openssl");
println!("cargo:rustc-link-lib=static=srtp");
println!("cargo:rustc-link-lib=static=usrsctp");
println!("cargo:rustc-link-lib=static=webrtc");
println!("cargo:rustc-link-lib=static=mediasoup-worker");
println!("cargo:rustc-link-lib=static=abseil");
#[cfg(windows)]
println!("cargo:rustc-link-lib=static=getopt");
println!("cargo:rustc-link-search=native={}", out_dir);
}
{
'variables':
{
# libuv variables.
'uv_library%': 'static_library',
# openssl variables.
'library%': 'static_library',
'openssl_fips%': '',
'openssl_no_asm%': 0,
'libopenssl': '<(PRODUCT_DIR)/libopenssl.a',
# usrsctp variables.
'sctp_debug%': 'false',
# Others.
'clang%': 0,
'mediasoup_asan%': 'false'
},
'target_defaults':
{
'default_configuration': 'Release',
'configurations':
{
'Release':
{
'cflags': [ '-O3', '-Wno-unknown-warning-option', '-fPIC' ]
},
'Debug':
{
'defines': [ 'DEBUG', 'MS_LOG_TRACE', 'MS_LOG_FILE_LINE' ],
'cflags': [ '-g', '-O0', '-Wno-parentheses-equality', '-Wno-unknown-warning-option', '-fPIC' ],
'xcode_settings':
{
'GCC_OPTIMIZATION_LEVEL': '0'
}
}
},
'xcode_settings':
{
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES', # -Wnewline-eof
'PREBINDING': 'NO', # No -Wl,-prebind
'OTHER_CFLAGS':
[
'-fstrict-aliasing',
'-g',
'-fPIC'
],
'WARNING_CFLAGS':
[
'-Wall',
'-Wendif-labels',
'-W',
'-Wno-unused-parameter',
'-Wundeclared-selector',
'-Wno-parentheses-equality'
]
},
'conditions':
[
[ 'target_arch == "ia32"', {
'xcode_settings': { 'ARCHS': [ 'i386' ] }
}],
[ 'target_arch == "x64"', {
'xcode_settings': { 'ARCHS': [ 'x86_64' ] }
}],
[ 'target_arch == "arm64"', {
'xcode_settings': { 'ARCHS': [ 'arm64' ] }
}],
[ 'OS in "linux freebsd openbsd solaris"', {
'target_conditions':
[
[ '_type == "static_library"', {
# Disable thin archive which needs binutils >= 2.19.
'standalone_static_library': 1
}]
],
'conditions':
[
[ 'target_arch == "ia32"', {
'cflags': [ '-m32' ],
'ldflags': [ '-m32' ]
}],
[ 'target_arch == "x64"', {
'cflags': [ '-m64' ],
'ldflags': [ '-m64' ]
}]
]
}]
]
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
{
'make_global_settings':
[
['CC.target', '<(openssl_fips)/bin/fipsld'],
['LINK', '<(openssl_fips)/bin/fipsld']
]
}
{
'target_defaults': {
'type': 'executable',
'dependencies':
[
'deps/netstring/netstring.gyp:netstring',
'deps/libuv/uv.gyp:libuv',
'deps/openssl/openssl.gyp:openssl',
'deps/libsrtp/libsrtp.gyp:libsrtp',
'deps/usrsctp/usrsctp.gyp:usrsctp',
'deps/libwebrtc/libwebrtc.gyp:libwebrtc',
'deps/libwebrtc/deps/abseil-cpp/abseil-cpp.gyp:abseil'
],
# TODO: SCTP_DEBUG must be dynamic based on a condition variable in common.gyp.
# 'defines': [ 'SCTP_DEBUG' ],
'sources':
[
# C++ source files.
'src/lib.cpp',
'src/DepLibSRTP.cpp',
'src/DepLibUV.cpp',
'src/DepLibWebRTC.cpp',
'src/DepOpenSSL.cpp',
'src/DepUsrSCTP.cpp',
'src/Logger.cpp',
'src/MediaSoupErrors.cpp',
'src/Settings.cpp',
'src/Worker.cpp',
'src/Utils/Crypto.cpp',
'src/Utils/File.cpp',
'src/Utils/IP.cpp',
'src/Utils/String.cpp',
'src/handles/SignalsHandler.cpp',
'src/handles/TcpConnectionHandler.cpp',
'src/handles/TcpServerHandler.cpp',
'src/handles/Timer.cpp',
'src/handles/UdpSocketHandler.cpp',
'src/handles/UnixStreamSocket.cpp',
'src/Channel/ChannelNotifier.cpp',
'src/Channel/ChannelRequest.cpp',
'src/Channel/ChannelSocket.cpp',
'src/PayloadChannel/Notification.cpp',
'src/PayloadChannel/PayloadChannelNotifier.cpp',
'src/PayloadChannel/PayloadChannelRequest.cpp',
'src/PayloadChannel/PayloadChannelSocket.cpp',
'src/RTC/ActiveSpeakerObserver.cpp',
'src/RTC/AudioLevelObserver.cpp',
'src/RTC/Consumer.cpp',
'src/RTC/DataConsumer.cpp',
'src/RTC/DataProducer.cpp',
'src/RTC/DirectTransport.cpp',
'src/RTC/DtlsTransport.cpp',
'src/RTC/IceCandidate.cpp',
'src/RTC/IceServer.cpp',
'src/RTC/KeyFrameRequestManager.cpp',
'src/RTC/NackGenerator.cpp',
'src/RTC/PipeConsumer.cpp',
'src/RTC/PipeTransport.cpp',
'src/RTC/PlainTransport.cpp',
'src/RTC/PortManager.cpp',
'src/RTC/Producer.cpp',
'src/RTC/RateCalculator.cpp',
'src/RTC/Router.cpp',
'src/RTC/RtpListener.cpp',
'src/RTC/RtpObserver.cpp',
'src/RTC/RtpPacket.cpp',
'src/RTC/RtpProbationGenerator.cpp',
'src/RTC/RtpStream.cpp',
'src/RTC/RtpStreamRecv.cpp',
'src/RTC/RtpStreamSend.cpp',
'src/RTC/RtxStream.cpp',
'src/RTC/SctpAssociation.cpp',
'src/RTC/SctpListener.cpp',
'src/RTC/SenderBandwidthEstimator.cpp',
'src/RTC/SeqManager.cpp',
'src/RTC/SimpleConsumer.cpp',
'src/RTC/SimulcastConsumer.cpp',
'src/RTC/SrtpSession.cpp',
'src/RTC/StunPacket.cpp',
'src/RTC/SvcConsumer.cpp',
'src/RTC/TcpConnection.cpp',
'src/RTC/TcpServer.cpp',
'src/RTC/Transport.cpp',
'src/RTC/TransportCongestionControlClient.cpp',
'src/RTC/TransportCongestionControlServer.cpp',
'src/RTC/TransportTuple.cpp',
'src/RTC/TrendCalculator.cpp',
'src/RTC/UdpSocket.cpp',
'src/RTC/WebRtcTransport.cpp',
'src/RTC/Codecs/H264.cpp',
'src/RTC/Codecs/VP8.cpp',
'src/RTC/Codecs/VP9.cpp',
'src/RTC/RtpDictionaries/Media.cpp',
'src/RTC/RtpDictionaries/Parameters.cpp',
'src/RTC/RtpDictionaries/RtcpFeedback.cpp',
'src/RTC/RtpDictionaries/RtcpParameters.cpp',
'src/RTC/RtpDictionaries/RtpCodecMimeType.cpp',
'src/RTC/RtpDictionaries/RtpCodecParameters.cpp',
'src/RTC/RtpDictionaries/RtpEncodingParameters.cpp',
'src/RTC/RtpDictionaries/RtpHeaderExtensionParameters.cpp',
'src/RTC/RtpDictionaries/RtpHeaderExtensionUri.cpp',
'src/RTC/RtpDictionaries/RtpParameters.cpp',
'src/RTC/RtpDictionaries/RtpRtxParameters.cpp',
'src/RTC/SctpDictionaries/SctpStreamParameters.cpp',
'src/RTC/RTCP/Packet.cpp',
'src/RTC/RTCP/CompoundPacket.cpp',
'src/RTC/RTCP/SenderReport.cpp',
'src/RTC/RTCP/ReceiverReport.cpp',
'src/RTC/RTCP/Sdes.cpp',
'src/RTC/RTCP/Bye.cpp',
'src/RTC/RTCP/Feedback.cpp',
'src/RTC/RTCP/FeedbackPs.cpp',
'src/RTC/RTCP/FeedbackRtp.cpp',
'src/RTC/RTCP/FeedbackRtpNack.cpp',
'src/RTC/RTCP/FeedbackRtpTmmb.cpp',
'src/RTC/RTCP/FeedbackRtpSrReq.cpp',
'src/RTC/RTCP/FeedbackRtpTllei.cpp',
'src/RTC/RTCP/FeedbackRtpEcn.cpp',
'src/RTC/RTCP/FeedbackRtpTransport.cpp',
'src/RTC/RTCP/FeedbackPsPli.cpp',
'src/RTC/RTCP/FeedbackPsSli.cpp',
'src/RTC/RTCP/FeedbackPsRpsi.cpp',
'src/RTC/RTCP/FeedbackPsFir.cpp',
'src/RTC/RTCP/FeedbackPsTst.cpp',
'src/RTC/RTCP/FeedbackPsVbcm.cpp',
'src/RTC/RTCP/FeedbackPsLei.cpp',
'src/RTC/RTCP/FeedbackPsAfb.cpp',
'src/RTC/RTCP/FeedbackPsRemb.cpp',
'src/RTC/RTCP/XR.cpp',
'src/RTC/RTCP/XrDelaySinceLastRr.cpp',
'src/RTC/RTCP/XrReceiverReferenceTime.cpp',
# C++ include files.
'include/lib.hpp',
'include/DepLibSRTP.hpp',
'include/DepLibUV.hpp',
'include/DepLibWebRTC.hpp',
'include/DepOpenSSL.hpp',
'include/DepUsrSCTP.hpp',
'include/LogLevel.hpp',
'include/Logger.hpp',
'include/MediaSoupErrors.hpp',
'include/Settings.hpp',
'include/Utils.hpp',
'include/Worker.hpp',
'include/common.hpp',
'include/handles/SignalsHandler.hpp',
'include/handles/TcpConnectionHandler.hpp',
'include/handles/TcpServerHandler.hpp',
'include/handles/Timer.hpp',
'include/handles/UdpSocketHandler.hpp',
'include/handles/UnixStreamSocket.hpp',
'include/Channel/ChannelNotifier.hpp',
'include/Channel/ChannelRequest.hpp',
'include/Channel/ChannelSocket.hpp',
'include/PayloadChannel/Notification.hpp',
'include/PayloadChannel/PayloadChannelNotifier.hpp',
'include/PayloadChannel/PayloadChannelRequest.hpp',
'include/PayloadChannel/PayloadChannelSocket.hpp',
'include/RTC/BweType.hpp',
'include/RTC/ActiveSpeakerObserver.hpp',
'include/RTC/AudioLevelObserver.hpp',
'include/RTC/Consumer.hpp',
'include/RTC/DataConsumer.hpp',
'include/RTC/DirectTransport.hpp',
'include/RTC/DataProducer.hpp',
'include/RTC/DtlsTransport.hpp',
'include/RTC/IceCandidate.hpp',
'include/RTC/IceServer.hpp',
'include/RTC/KeyFrameRequestManager.hpp',
'include/RTC/NackGenerator.hpp',
'include/RTC/Parameters.hpp',
'include/RTC/PipeConsumer.hpp',
'include/RTC/PipeTransport.hpp',
'include/RTC/PlainTransport.hpp',
'include/RTC/PortManager.hpp',
'include/RTC/Producer.hpp',
'include/RTC/RateCalculator.hpp',
'include/RTC/Router.hpp',
'include/RTC/RtpDictionaries.hpp',
'include/RTC/RtpHeaderExtensionIds.hpp',
'include/RTC/RtpListener.hpp',
'include/RTC/RtpObserver.hpp',
'include/RTC/RtpPacket.hpp',
'include/RTC/RtpProbationGenerator.hpp',
'include/RTC/RtpStream.hpp',
'include/RTC/RtpStreamRecv.hpp',
'include/RTC/RtpStreamSend.hpp',
'include/RTC/RtxStream.hpp',
'include/RTC/SctpAssociation.hpp',
'include/RTC/SctpDictionaries.hpp',
'include/RTC/SctpListener.hpp',
'include/RTC/SenderBandwidthEstimator.hpp',
'include/RTC/SeqManager.hpp',
'include/RTC/SimpleConsumer.hpp',
'include/RTC/SimulcastConsumer.hpp',
'include/RTC/SrtpSession.hpp',
'include/RTC/StunPacket.hpp',
'include/RTC/SvcConsumer.hpp',
'include/RTC/TcpConnection.hpp',
'include/RTC/TcpServer.hpp',
'include/RTC/Transport.hpp',
'include/RTC/TransportCongestionControlClient.hpp',
'include/RTC/TransportCongestionControlServer.hpp',
'include/RTC/TransportTuple.hpp',
'include/RTC/TrendCalculator.hpp',
'include/RTC/UdpSocket.hpp',
'include/RTC/WebRtcTransport.hpp',
'include/RTC/Codecs/Tools.hpp',
'include/RTC/Codecs/PayloadDescriptorHandler.hpp',
'include/RTC/Codecs/H264.hpp',
'include/RTC/Codecs/VP8.hpp',
'include/RTC/Codecs/VP9.hpp',
'include/RTC/RTCP/Packet.hpp',
'include/RTC/RTCP/CompoundPacket.hpp',
'include/RTC/RTCP/SenderReport.hpp',
'include/RTC/RTCP/ReceiverReport.hpp',
'include/RTC/RTCP/Sdes.hpp',
'include/RTC/RTCP/Bye.hpp',
'include/RTC/RTCP/Feedback.hpp',
'include/RTC/RTCP/FeedbackItem.hpp',
'include/RTC/RTCP/FeedbackPs.hpp',
'include/RTC/RTCP/FeedbackRtp.hpp',
'include/RTC/RTCP/FeedbackRtpNack.hpp',
'include/RTC/RTCP/FeedbackRtpTmmb.hpp',
'include/RTC/RTCP/FeedbackRtpSrReq.hpp',
'include/RTC/RTCP/FeedbackRtpTllei.hpp',
'include/RTC/RTCP/FeedbackRtpEcn.hpp',
'include/RTC/RTCP/FeedbackRtpTransport.hpp',
'include/RTC/RTCP/FeedbackPsPli.hpp',
'include/RTC/RTCP/FeedbackPsSli.hpp',
'include/RTC/RTCP/FeedbackPsRpsi.hpp',
'include/RTC/RTCP/FeedbackPsFir.hpp',
'include/RTC/RTCP/FeedbackPsTst.hpp',
'include/RTC/RTCP/FeedbackPsVbcm.hpp',
'include/RTC/RTCP/FeedbackPsLei.hpp',
'include/RTC/RTCP/FeedbackPsAfb.hpp',
'include/RTC/RTCP/FeedbackPsRemb.hpp',
'include/RTC/RTCP/XR.hpp',
'include/RTC/RTCP/XrDelaySinceLastRr.hpp',
'include/RTC/RTCP/XrReceiverReferenceTime.hpp'
],
'include_dirs':
[
'include',
'deps/json/single_include'
],
'conditions':
[
# FIPS.
[ 'openssl_fips != ""', {
'defines': [ 'BUD_FIPS_ENABLED=1' ]
}],
# Endianness.
[ 'node_byteorder == "big"', {
# Define Big Endian.
'defines': [ 'MS_BIG_ENDIAN' ]
}, {
# Define Little Endian.
'defines': [ 'MS_LITTLE_ENDIAN' ]
}],
# Platform-specifics.
[ 'OS == "mac" and mediasoup_asan == "true"', {
'xcode_settings':
{
'OTHER_CFLAGS': [ '-fsanitize=address' ],
'OTHER_LDFLAGS': [ '-fsanitize=address' ]
}
}],
[ 'OS == "linux"', {
'defines':
[
'_POSIX_C_SOURCE=200112',
'_GNU_SOURCE'
]
}],
[ 'OS == "linux" and mediasoup_asan == "true"', {
'cflags': [ '-fsanitize=address' ],
'ldflags': [ '-fsanitize=address' ]
}],
[ 'OS in "linux freebsd"', {
'ldflags': [ '-Wl,--whole-archive <(libopenssl) -Wl,--no-whole-archive' ]
}],
[ 'OS in "freebsd"', {
'ldflags': [ '-Wl,--export-dynamic' ]
}],
[ 'OS == "win"', {
'dependencies': [ 'deps/getopt/getopt.gyp:getopt' ],
# Handle multi files with same name.
# https://stackoverflow.com/a/22936230/2085408
# https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.vcprojectengine.vcclcompilertool.objectfile?view=visualstudiosdk-2017#Microsoft_VisualStudio_VCProjectEngine_VCCLCompilerTool_ObjectFile
'msvs_settings': {
'VCCLCompilerTool': { 'ObjectFile': ['$(IntDir)\%(RelativeDir)\%(Filename).obj'], },
},
# Output Directory setting for msvc.
# https://github.com/nodejs/node-gyp/issues/1242#issuecomment-310921441
'msvs_configuration_attributes': {
'OutputDirectory': '$(SolutionDir)\\out\\$(Configuration)\\'
}
}],
[ 'OS != "win"', {
'cflags': [ '-std=c++11', '-Wall', '-Wextra', '-Wno-unused-parameter', '-Wno-implicit-fallthrough' ]
}],
[ 'OS == "mac"', {
'xcode_settings':
{
'WARNING_CFLAGS': [ '-Wall', '-Wextra', '-Wno-unused-parameter' ],
'OTHER_CPLUSPLUSFLAGS' : [ '-std=c++11' ]
}
}],
# Dependency-specifics.
[ 'sctp_debug == "true"', {
'defines': [ 'SCTP_DEBUG' ]
}]
]
},
'targets':
[
{
'target_name': 'mediasoup-worker',
'sources':
[
# C++ source files.
'src/main.cpp'
],
'defines': [ 'MS_EXECUTABLE' ]
},
{
'target_name': 'libmediasoup-worker',
'type': 'static_library'
},
{
'target_name': 'mediasoup-worker-test',
'defines': [ 'MS_LOG_STD', 'MS_TEST' ],
'sources':
[
# C++ source files.
'test/src/tests.cpp',
'test/src/RTC/TestKeyFrameRequestManager.cpp',
'test/src/RTC/TestNackGenerator.cpp',
'test/src/RTC/TestRateCalculator.cpp',
'test/src/RTC/TestRtpPacket.cpp',
'test/src/RTC/TestRtpStreamSend.cpp',
'test/src/RTC/TestRtpStreamRecv.cpp',
'test/src/RTC/TestSeqManager.cpp',
'test/src/RTC/TestTrendCalculator.cpp',
'test/src/RTC/TestRtpEncodingParameters.cpp',
'test/src/RTC/Codecs/TestVP8.cpp',
'test/src/RTC/RTCP/TestFeedbackPsAfb.cpp',
'test/src/RTC/RTCP/TestFeedbackPsFir.cpp',
'test/src/RTC/RTCP/TestFeedbackPsLei.cpp',
'test/src/RTC/RTCP/TestFeedbackPsPli.cpp',
'test/src/RTC/RTCP/TestFeedbackPsRemb.cpp',
'test/src/RTC/RTCP/TestFeedbackPsRpsi.cpp',
'test/src/RTC/RTCP/TestFeedbackPsSli.cpp',
'test/src/RTC/RTCP/TestFeedbackPsTst.cpp',
'test/src/RTC/RTCP/TestFeedbackPsVbcm.cpp',
'test/src/RTC/RTCP/TestFeedbackRtpEcn.cpp',
'test/src/RTC/RTCP/TestFeedbackRtpNack.cpp',
'test/src/RTC/RTCP/TestFeedbackRtpSrReq.cpp',
'test/src/RTC/RTCP/TestFeedbackRtpTllei.cpp',
'test/src/RTC/RTCP/TestFeedbackRtpTmmb.cpp',
'test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp',
'test/src/RTC/RTCP/TestBye.cpp',
'test/src/RTC/RTCP/TestReceiverReport.cpp',
'test/src/RTC/RTCP/TestSdes.cpp',
'test/src/RTC/RTCP/TestSenderReport.cpp',
'test/src/RTC/RTCP/TestPacket.cpp',
'test/src/RTC/RTCP/TestXr.cpp',
'test/src/Utils/TestBits.cpp',
'test/src/Utils/TestIP.cpp',
'test/src/Utils/TestJson.cpp',
'test/src/Utils/TestString.cpp',
'test/src/Utils/TestTime.cpp',
# C++ include files.
'test/include/helpers.hpp'
],
'include_dirs':
[
'test/include',
'deps/catch2/single_include'
],
'xcode_settings':
{
'OTHER_CPLUSPLUSFLAGS':
[
'--coverage'
],
'OTHER_LDFLAGS': [
'--coverage'
]
}
},
{
'target_name': 'mediasoup-worker-fuzzer',
'defines': [ 'DEBUG', 'MS_LOG_STD', 'MS_TEST' ],
'sources':
[
# C++ source files.
'fuzzer/src/fuzzer.cpp',
'fuzzer/src/FuzzerUtils.cpp',
'fuzzer/src/RTC/FuzzerStunPacket.cpp',
'fuzzer/src/RTC/FuzzerRtpPacket.cpp',
'fuzzer/src/RTC/FuzzerTrendCalculator.cpp',
'fuzzer/src/RTC/RTCP/FuzzerBye.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackPs.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackPsAfb.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackPsFir.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackPsLei.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackPsPli.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackPsRemb.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackPsRpsi.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackPsSli.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackPsTst.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackPsVbcm.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackRtp.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackRtpEcn.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackRtpNack.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackRtpSrReq.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackRtpTllei.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackRtpTmmb.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackRtpTransport.cpp',
'fuzzer/src/RTC/RTCP/FuzzerPacket.cpp',
'fuzzer/src/RTC/RTCP/FuzzerReceiverReport.cpp',
'fuzzer/src/RTC/RTCP/FuzzerSdes.cpp',
'fuzzer/src/RTC/RTCP/FuzzerSenderReport.cpp',
'fuzzer/src/RTC/RTCP/FuzzerXr.cpp',
# C++ include files.
'fuzzer/include/FuzzerUtils.hpp',
'fuzzer/include/RTC/FuzzerRtpPacket.hpp',
'fuzzer/include/RTC/FuzzerStunPacket.hpp',
'fuzzer/include/RTC/FuzzerTrendCalculator.hpp',
'fuzzer/include/RTC/RTCP/FuzzerBye.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackPs.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackPsAfb.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackPsFir.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackPsLei.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackPsPli.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackPsRemb.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackPsRpsi.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackPsSli.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackPsTst.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackPsVbcm.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackRtp.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackRtpEcn.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackRtpNack.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackRtpSrReq.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackRtpTllei.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackRtpTmmb.hpp',
'fuzzer/include/RTC/RTCP/FuzzerFeedbackRtpTransport.hpp',
'fuzzer/include/RTC/RTCP/FuzzerPacket.hpp',
'fuzzer/include/RTC/RTCP/FuzzerReceiverReport.hpp',
'fuzzer/include/RTC/RTCP/FuzzerSdes.hpp',
'fuzzer/include/RTC/RTCP/FuzzerSenderReport.hpp',
'fuzzer/include/RTC/RTCP/FuzzerXr.hpp',
],
'include_dirs':
[
'fuzzer/include'
],
'conditions':
[
[ 'OS == "linux"', {
'cflags': [ '-g', '-O0', '-fsanitize=address,fuzzer' ],
'ldflags': [ '-fsanitize=address,fuzzer' ]
}]
]
}
]
}
#!/usr/bin/env python
#
# Script inspired in bud:
# https://github.com/indutny/bud
#
import platform
import os
import subprocess
import sys
CC = os.environ.get('CC', 'cc')
script_dir = os.path.dirname(__file__)
root = os.path.normpath(os.path.join(script_dir, '..'))
output_dir = os.environ.get('MEDIASOUP_OUT_DIR', os.path.join(os.path.abspath(root), 'out'))
sys.path.insert(0, os.path.join(root, 'deps', 'gyp', 'pylib'))
try:
import gyp
except ImportError:
print('Error: you need to install gyp in deps/gyp first, run:')
print(' ./scripts/get-dep.sh gyp')
sys.exit(42)
def host_arch():
machine = platform.machine()
if machine == 'i386': return 'ia32'
if machine == 'x86_64': return 'x64'
if machine == 'AMD64': return 'x64'
if machine == 'aarch64': return 'arm64'
if machine == 'arm64': return 'arm64'
if machine == 'mips64': return 'mips64el'
if machine.startswith('arm'): return 'arm'
if machine.startswith('mips'): return 'mips'
return machine # Return as-is and hope for the best.
def compiler_version():
proc = subprocess.Popen(CC.split() + ['--version'], stdout=subprocess.PIPE)
is_clang = b'clang' in proc.communicate()[0].split(b'\n')[0]
proc = subprocess.Popen(CC.split() + ['-dumpversion'], stdout=subprocess.PIPE)
version = proc.communicate()[0].split(b'.')
mayor_version = int(version[:1][0])
if is_clang is False and mayor_version >= 7:
proc = subprocess.Popen(CC.split() + ['-dumpfullversion'], stdout=subprocess.PIPE)
version = proc.communicate()[0].split(b'.')
version = map(int, version[:2])
version = tuple(version)
return (version, is_clang)
def run_gyp(args):
rc = gyp.main(args)
if rc != 0:
print('Error running GYP')
sys.exit(rc)
if __name__ == '__main__':
args = sys.argv[1:]
# GYP bug.
# On msvs it will crash if it gets an absolute path.
# On Mac/make it will crash if it doesn't get an absolute path.
# NOTE ibc: Not sure that it requires absolute path in Mac/make...
if sys.platform == 'win32':
args.append(os.path.join(root, 'mediasoup-worker.gyp'))
common_fn = os.path.join(root, 'common.gypi')
# we force vs 2010 over 2008 which would otherwise be the default for gyp.
if not os.environ.get('GYP_MSVS_VERSION'):
os.environ['GYP_MSVS_VERSION'] = '2010'
else:
args.append(os.path.join(os.path.abspath(root), 'mediasoup-worker.gyp'))
common_fn = os.path.join(os.path.abspath(root), 'common.gypi')
if os.path.exists(common_fn):
args.extend(['-I', common_fn])
args.append('--depth=' + root)
# There's a bug with windows which doesn't allow this feature.
if sys.platform != 'win32':
if '-f' not in args:
args.extend('-f make'.split())
if 'ninja' not in args:
args.extend(['-Goutput_dir=' + output_dir])
args.extend(['--generator-output', output_dir])
(major, minor), is_clang = compiler_version()
args.append('-Dgcc_version=%d' % (10 * major + minor))
args.append('-Dclang=%d' % int(is_clang))
if is_clang is False and major == 4 and minor <= 8:
raise RuntimeError('gcc <= 4.8 not supported, please upgrade your gcc')
if not any(a.startswith('-Dhost_arch=') for a in args):
args.append('-Dhost_arch=%s' % host_arch())
if not any(a.startswith('-Dtarget_arch=') for a in args):
args.append('-Dtarget_arch=%s' % host_arch())
if any(a.startswith('-Dopenssl_fips=') for a in args):
fips_fn = os.path.join(os.path.abspath(root), 'fips.gypi')
args.extend(['-I', fips_fn])
else:
args.append('-Dopenssl_fips=')
if 'asan' in args:
args.append('-Dmediasoup_asan=true')
args = filter(lambda arg: arg != 'asan', args)
else:
args.append('-Dmediasoup_asan=false')
args.append('-Dnode_byteorder=' + sys.byteorder)
gyp_args = list(args)
print(gyp_args)
run_gyp(gyp_args)
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论