Unverified 提交 9e7335f7 authored 作者: Romain Tartière's avatar Romain Tartière 提交者: GitHub

Fix build on FreeBSD (#585)

FreeBSD make and GNU make share a common base but provide extensions
not supported by the other.  This leads to build failures and can be
fixed by using the right version of make.  On FreeBSD, GNU make is
installed as `gmake` so detect and use this.  While here, also check
the environment for allowing overriding the binary to make in case
other platform can benefit from it (e.g. OpenBSD, NetBSD and probably
others).

While here, also catch the right number of CPU for parallel build.
上级 0a1fa55f
...@@ -4,6 +4,7 @@ const fs = require('fs'); ...@@ -4,6 +4,7 @@ const fs = require('fs');
const { execSync } = require('child_process'); const { execSync } = require('child_process');
const { version } = require('./package.json'); const { version } = require('./package.json');
const isFreeBSD = os.platform() === 'freebsd';
const isWindows = os.platform() === 'win32'; const isWindows = os.platform() === 'win32';
const task = process.argv.slice(2).join(' '); const task = process.argv.slice(2).join(' ');
...@@ -24,6 +25,17 @@ if (isWindows) ...@@ -24,6 +25,17 @@ if (isWindows)
MEDIASOUP_TEST_TAGS = process.env.MEDIASOUP_TEST_TAGS || ''; MEDIASOUP_TEST_TAGS = process.env.MEDIASOUP_TEST_TAGS || '';
} }
let MAKE;
if (isFreeBSD)
{
MAKE = process.env.MAKE || 'gmake';
}
else
{
MAKE = process.env.MAKE || 'make';
}
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(`npm-scripts.js [INFO] running task "${task}"`); console.log(`npm-scripts.js [INFO] running task "${task}"`);
...@@ -77,14 +89,14 @@ switch (task) ...@@ -77,14 +89,14 @@ switch (task)
case 'lint:worker': case 'lint:worker':
{ {
execute('make lint -C worker'); execute(`${MAKE} lint -C worker`);
break; break;
} }
case 'format:worker': case 'format:worker':
{ {
execute('make format -C worker'); execute(`${MAKE} format -C worker`);
break; break;
} }
...@@ -109,7 +121,7 @@ switch (task) ...@@ -109,7 +121,7 @@ switch (task)
{ {
if (!isWindows) if (!isWindows)
{ {
execute('make test -C worker'); execute(`${MAKE} test -C worker`);
} }
else if (!process.env.MEDIASOUP_WORKER_BIN) else if (!process.env.MEDIASOUP_WORKER_BIN)
{ {
...@@ -136,7 +148,7 @@ switch (task) ...@@ -136,7 +148,7 @@ switch (task)
{ {
if (!isWindows) if (!isWindows)
{ {
execute('make -C worker'); execute(`${MAKE} -C worker`);
} }
else else
{ {
......
...@@ -7,7 +7,7 @@ NUM_CORES= ...@@ -7,7 +7,7 @@ NUM_CORES=
case "${OS}" in case "${OS}" in
Linux*) NUM_CORES=$(nproc);; Linux*) NUM_CORES=$(nproc);;
Darwin*) NUM_CORES=$(sysctl -n hw.ncpu);; Darwin*|FreeBSD) NUM_CORES=$(sysctl -n hw.ncpu);;
*) NUM_CORES=1;; *) NUM_CORES=1;;
esac esac
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论