Unverified 提交 55c6015e authored 作者: Nazar Mokrynskyi's avatar Nazar Mokrynskyi 提交者: GitHub

Merge pull request #755 from nazar-pc/improved-meson-integration

Replace manual build artifacts management with Meson commands
[package]
name = "mediasoup-sys"
version = "0.3.1"
version = "0.3.2"
description = "FFI bindings to C++ libmediasoup-worker"
authors = ["Nazar Mokrynskyi <nazar@mokrynskyi.com>"]
edition = "2018"
......
......@@ -12,6 +12,7 @@ GULP = ./scripts/node_modules/.bin/gulp
LCOV = ./deps/lcov/bin/lcov
DOCKER ?= docker
PIP_DIR = $(MEDIASOUP_OUT_DIR)/pip
INSTALL_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
BUILD_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/build
MESON ?= $(PIP_DIR)/bin/meson
MESON_ARGS ?= ""
......@@ -71,6 +72,9 @@ setup: meson-ninja
# https://github.com/ninja-build/ninja/issues/1997
ifeq ($(MEDIASOUP_BUILDTYPE),Release)
$(MESON) setup \
--prefix $(INSTALL_DIR) \
--bindir '' \
--libdir '' \
--buildtype release \
-Db_ndebug=true \
-Db_pie=true \
......@@ -79,6 +83,9 @@ ifeq ($(MEDIASOUP_BUILDTYPE),Release)
$(MESON_ARGS) \
$(BUILD_DIR) || \
$(MESON) setup \
--prefix $(INSTALL_DIR) \
--bindir '' \
--libdir '' \
--buildtype release \
-Db_ndebug=true \
-Db_pie=true \
......@@ -88,6 +95,9 @@ ifeq ($(MEDIASOUP_BUILDTYPE),Release)
else
ifeq ($(MEDIASOUP_BUILDTYPE),Debug)
$(MESON) setup \
--prefix $(INSTALL_DIR) \
--bindir '' \
--libdir '' \
--buildtype debug \
-Db_pie=true \
-Db_staticpic=true \
......@@ -95,6 +105,9 @@ ifeq ($(MEDIASOUP_BUILDTYPE),Debug)
$(MESON_ARGS) \
$(BUILD_DIR) || \
$(MESON) setup \
--prefix $(INSTALL_DIR) \
--bindir '' \
--libdir '' \
--buildtype debug \
-Db_pie=true \
-Db_staticpic=true \
......@@ -102,6 +115,9 @@ ifeq ($(MEDIASOUP_BUILDTYPE),Debug)
$(BUILD_DIR)
else
$(MESON) setup \
--prefix $(INSTALL_DIR) \
--bindir '' \
--libdir '' \
--buildtype $(MEDIASOUP_BUILDTYPE) \
-Db_ndebug=if-release \
-Db_pie=true \
......@@ -110,6 +126,9 @@ else
$(MESON_ARGS) \
$(BUILD_DIR) || \
$(MESON) setup \
--prefix $(INSTALL_DIR) \
--bindir '' \
--libdir '' \
--buildtype $(MEDIASOUP_BUILDTYPE) \
-Db_ndebug=if-release \
-Db_pie=true \
......@@ -120,7 +139,7 @@ endif
endif
clean:
$(RM) -rf $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
$(RM) -rf $(INSTALL_DIR)
clean-build:
$(RM) -rf $(BUILD_DIR)
......@@ -136,12 +155,8 @@ clean-all: clean-subprojects
mediasoup-worker: setup
ifeq ($(MEDIASOUP_WORKER_BIN),)
$(MESON) compile -j $(CORES) -C $(BUILD_DIR) mediasoup-worker
endif
ifeq ($(OS),Windows_NT)
cp $(BUILD_DIR)/mediasoup-worker.exe $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/mediasoup-worker.exe
else
cp $(BUILD_DIR)/mediasoup-worker $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/mediasoup-worker
$(MESON) compile -C $(BUILD_DIR) -j $(CORES) mediasoup-worker
$(MESON) install -C $(BUILD_DIR) --no-rebuild --tags mediasoup-worker
endif
xcode: setup
......@@ -154,8 +169,8 @@ format:
$(GULP) --gulpfile ./scripts/gulpfile.js format:worker
test: setup
ifeq ($(MEDIASOUP_WORKER_BIN),)
$(MESON) compile -j $(CORES) -C $(BUILD_DIR) mediasoup-worker-test
$(MESON) compile -C $(BUILD_DIR) -j $(CORES) mediasoup-worker-test
$(MESON) install -C $(BUILD_DIR) --no-rebuild --tags mediasoup-worker-test
# On Windows lcov doesn't work (at least not yet) and we need to add `.exe` to
# the binary path.
ifeq ($(OS),Windows_NT)
......@@ -164,7 +179,6 @@ else
$(LCOV) --directory ./ --zerocounters
$(BUILD_DIR)/mediasoup-worker-test --invisibles --use-colour=yes $(MEDIASOUP_TEST_TAGS)
endif
endif
tidy:
$(PYTHON) ./scripts/clang-tidy.py \
......@@ -177,9 +191,8 @@ tidy:
-quiet
fuzzer: setup
ifeq ($(MEDIASOUP_WORKER_BIN),)
$(MESON) compile -j $(CORES) -C $(BUILD_DIR) mediasoup-worker-fuzzer
endif
$(MESON) compile -C $(BUILD_DIR) -j $(CORES) mediasoup-worker-fuzzer
$(MESON) install -C $(BUILD_DIR) --no-rebuild --tags mediasoup-worker-fuzzer
fuzzer-run-all:
LSAN_OPTIONS=verbosity=1:log_threads=1 ./$(BUILD_DIR)/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
......@@ -200,4 +213,5 @@ docker-run:
mediasoup/docker:latest
libmediasoup-worker: setup
$(MESON) compile -j $(CORES) -C $(BUILD_DIR) libmediasoup-worker
$(MESON) compile -C $(BUILD_DIR) -j $(CORES) libmediasoup-worker
$(MESON) install -C $(BUILD_DIR) --no-rebuild --tags libmediasoup-worker
......@@ -85,6 +85,8 @@ fn main() {
.arg("libmediasoup-worker")
.env("MEDIASOUP_OUT_DIR", &mediasoup_out_dir)
.env("MEDIASOUP_BUILDTYPE", &build_type)
// Force forward slashes on Windows too, otherwise Meson thinks path is not absolute 🤷
.env("INSTALL_DIR", &out_dir.replace('\\', "/"))
.spawn()
.expect("Failed to start")
.wait()
......@@ -94,49 +96,21 @@ fn main() {
panic!("Failed to build libmediasoup-worker")
}
#[cfg(not(target_os = "windows"))]
{
let from = format!(
"{}/{}/build/libmediasoup-worker.a",
mediasoup_out_dir, build_type
);
let to = format!("{}/libmediasoup-worker.a", out_dir);
std::fs::copy(&from, &to).unwrap_or_else(|error| {
panic!(
"Failed to copy static library from {} to {}: {}",
from, to, error
)
});
}
#[cfg(target_os = "windows")]
{
let dot_a = format!(
"{}/{}/build/libmediasoup-worker.a",
mediasoup_out_dir, build_type
);
let from = format!(
"{}/{}/build/mediasoup-worker.lib",
mediasoup_out_dir, build_type
);
let to = format!("{}/mediasoup-worker.lib", out_dir);
let dot_a = format!("{}/libmediasoup-worker.a", out_dir);
let dot_lib = format!("{}/mediasoup-worker.lib", out_dir);
// Meson builds `libmediasoup-worker.a` on Windows instead of `*.lib` file under MinGW
if std::path::Path::new(&dot_a).exists() {
std::fs::copy(&dot_a, &from).unwrap_or_else(|error| {
std::fs::copy(&dot_a, &dot_lib).unwrap_or_else(|error| {
panic!(
"Failed to copy static library from {} to {}: {}",
dot_a, from, error
dot_a, dot_lib, error
)
});
}
std::fs::copy(&from, &to).unwrap_or_else(|error| {
panic!(
"Failed to copy static library from {} to {}: {}",
from, to, error
)
});
// These are required by libuv on Windows
println!("cargo:rustc-link-lib=psapi");
println!("cargo:rustc-link-lib=user32");
......
......@@ -233,6 +233,8 @@ libmediasoup_worker = library(
'libmediasoup-worker',
name_prefix: '',
build_by_default: false,
install: true,
install_tag: 'libmediasoup-worker',
dependencies: dependencies,
sources: common_sources,
include_directories: include_directories('include'),
......@@ -243,6 +245,8 @@ libmediasoup_worker = library(
executable(
'mediasoup-worker',
build_by_default: true,
install: true,
install_tag: 'mediasoup-worker',
dependencies: dependencies,
sources: common_sources + ['src/main.cpp'],
include_directories: include_directories('include'),
......@@ -252,6 +256,8 @@ executable(
mediasoup_worker_test = executable(
'mediasoup-worker-test',
build_by_default: false,
install: true,
install_tag: 'mediasoup-worker-test',
dependencies: dependencies + [
catch2_proj.get_variable('catch2_dep'),
],
......@@ -314,6 +320,8 @@ if host_machine.system() == 'linux'
executable(
'mediasoup-worker-fuzzer',
build_by_default: false,
install: true,
install_tag: 'mediasoup-worker-fuzzer',
dependencies: dependencies,
sources: common_sources + [
'fuzzer/src/fuzzer.cpp',
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论