Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to the build system #1245

Merged
merged 10 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions npm-scripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const IS_WINDOWS = os.platform() === 'win32';
const MAYOR_VERSION = PKG.version.split('.')[0];
const PYTHON = getPython();
const PIP_INVOKE_DIR = path.resolve('worker/pip_invoke');
const INVOKE_VERSION = process.env.INVOKE_VERSION ?? '2.2.0';
const FLATBUFFERS_VERSION = '23.3.3';
const WORKER_RELEASE_DIR = 'worker/out/Release';
const WORKER_RELEASE_BIN = IS_WINDOWS ? 'mediasoup-worker.exe' : 'mediasoup-worker';
Expand Down Expand Up @@ -318,7 +317,8 @@ function installInvoke()
// Install pip invoke into custom location, so we don't depend on system-wide
// installation.
executeCmd(
`"${PYTHON}" -m pip install --upgrade --target="${PIP_INVOKE_DIR}" invoke==${INVOKE_VERSION}`, /* exitOnError */ true
`"${PYTHON}" -m pip install --upgrade --target="${PIP_INVOKE_DIR}" invoke`,
/* exitOnError */ true
);
}

Expand All @@ -331,15 +331,7 @@ function deleteNodeLib()

logInfo('deleteNodeLib()');

if (!IS_WINDOWS)
{
executeCmd('rm -rf node/lib');
}
else
{
// NOTE: This command fails in Windows if the dir doesn't exist.
executeCmd('rmdir /s /q "node/lib"', /* exitOnError */ false);
}
fs.rmSync('node/lib', { recursive: true, force: true });
}

function buildTypescript({ force = false } = { force: false })
Expand Down Expand Up @@ -584,7 +576,7 @@ async function downloadPrebuiltWorker()
const resolvedBinPath = path.resolve(WORKER_RELEASE_BIN_PATH);

execSync(
resolvedBinPath,
`"${resolvedBinPath}"`,
{
stdio : [ 'ignore', 'ignore', 'ignore' ],
// Ensure no env is passed to avoid accidents.
Expand Down
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,22 @@
"types": "node/lib/index.d.ts",
"files": [
"node/lib",
"worker/src",
"worker/include",
"worker/deps/libwebrtc",
"worker/fbs",
"worker/test/src",
"worker/test/include",
"worker/fuzzer/src",
"worker/fuzzer/include",
"worker/scripts/*.mjs",
"worker/fuzzer/src",
"worker/include",
"worker/src",
"worker/scripts/*.json",
"worker/scripts/*.mjs",
"worker/scripts/*.py",
"worker/scripts/*.sh",
"worker/subprojects/*.wrap",
"worker/deps/libwebrtc",
"worker/tasks.py",
"worker/Makefile",
"worker/test/include",
"worker/test/src",
"worker/meson.build",
"worker/meson_options.txt",
"worker/tasks.py",
"npm-scripts.mjs"
],
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ include = [
"/test/src",
"/build.rs",
"/Cargo.toml",
"/Makefile",
ibc marked this conversation as resolved.
Show resolved Hide resolved
"/meson.build",
"/meson_options.txt",
"/tasks.py"
]

[package.metadata.docs.rs]
Expand Down
3 changes: 1 addition & 2 deletions worker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

PYTHON ?= $(shell command -v python3 2> /dev/null || echo python)
PIP_INVOKE_DIR = $(shell pwd)/pip_invoke
INVOKE_VERSION ?= 2.2.0

# Instruct Python where to look for invoke module.
ifeq ($(OS),Windows_NT)
Expand Down Expand Up @@ -48,7 +47,7 @@ invoke:
ifeq ($(wildcard $(PIP_INVOKE_DIR)),)
# Install pip invoke into custom location, so we don't depend on system-wide
# installation.
$(PYTHON) -m pip install --upgrade --target="$(PIP_INVOKE_DIR)" invoke==$(INVOKE_VERSION)
$(PYTHON) -m pip install --upgrade --target="$(PIP_INVOKE_DIR)" invoke
endif

meson-ninja: invoke
Expand Down
9 changes: 4 additions & 5 deletions worker/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,8 @@ fn main() {

// Install Python invoke package in custom folder
let pip_invoke_dir = format!("{out_dir}/pip_invoke");
let invoke_version = "2.2.0";
let python = env::var("PYTHON").unwrap_or("python3".to_string());
let mut pythonpath = if env::var("PYTHONPATH").is_ok() {
let original_pythonpath = env::var("PYTHONPATH").unwrap();
let mut pythonpath = if let Ok(original_pythonpath) = env::var("PYTHONPATH") {
format!("{pip_invoke_dir}:{original_pythonpath}")
} else {
pip_invoke_dir.clone()
Expand All @@ -126,8 +124,9 @@ fn main() {
.arg("pip")
.arg("install")
.arg("--upgrade")
.arg(format!("--target={pip_invoke_dir}"))
.arg(format!("invoke=={invoke_version}"))
.arg("--target")
.arg(pip_invoke_dir)
.arg("invoke")
.spawn()
.expect("Failed to start")
.wait()
Expand Down