提交 3223f806 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Improve build system and gulp/make tasks.

上级 d5e438d0
...@@ -17,18 +17,12 @@ Builds a more verbose mediasoup and less optimized worker binary at `worker/out/ ...@@ -17,18 +17,12 @@ Builds a more verbose mediasoup and less optimized worker binary at `worker/out/
Check the meaning of these macros in the [Logger.h](worker/include/Logger.h) header file. Check the meaning of these macros in the [Logger.h](worker/include/Logger.h) header file.
In order to instruct the **mediasoup** Node.js module to use the `Debug` mediasoup worker binary, an environment variable must be set before running the Node.js application or the JavaScript test units: In order to instruct the **mediasoup** Node.js module to use the `Debug` mediasoup worker binary, an environment variable must be set before running the Node.js application:
```bash ```bash
$ MEDIASOUP_BUILDTYPE=Debug node myapp.js $ MEDIASOUP_BUILDTYPE=Debug node myapp.js
``` ```
Or, in order to run the JavaScript test units with the `Debug` mediasoup worker:
```bash
$ MEDIASOUP_BUILDTYPE=Debug gulp test-debug
```
### `make test` ### `make test`
Builds the `mediasoup-worker-test` test unit binary at `worker/out/Debug/` in `Debug` mode. Builds the `mediasoup-worker-test` test unit binary at `worker/out/Debug/` in `Debug` mode.
...@@ -43,11 +37,11 @@ Cleans objects and binaries related to the mediasoup worker. ...@@ -43,11 +37,11 @@ Cleans objects and binaries related to the mediasoup worker.
### `make clean-all` ### `make clean-all`
Clean all the objects and binaries, including those generated for library dependencies (such as libuv, openssl and libsrtp). Cleans all the objects and binaries, including those generated for library dependencies (such as libuv, openssl and libsrtp).
### `make` ### `make`
The default task runs the `Release` task. The default task runs the `Release` task unless the environment `MEDIASOUP_BUILDTYPE` is set to `Debug` (if so it runs the `Debug` task).
## gulpfile.js ## gulpfile.js
...@@ -64,22 +58,20 @@ $ npm install -g gulp-cli ...@@ -64,22 +58,20 @@ $ npm install -g gulp-cli
Validates the JavaScript code. Validates the JavaScript code.
### `gulp capabilities` ### `gulp rtpcapabilities`
Reads **mediasoup** [media capabilities](https://github.com/ibc/mediasoup/blob/master/data/supportedCapabilities.js) and inserts them into the worker C++ code. After that, `make Release` or `make Debug` must be called. Reads **mediasoup** [supported RTP capabilities](https://github.com/ibc/mediasoup/blob/master/lib/supportedRtpCapabilities.js) and inserts them into the worker C++ code. After that, `make Release` and/or `make Debug` must be called.
### `gulp test` ### `gulp test-api`
Run the JavaScript [test units](test/). Runs the JavaScript [test units](test/). Before it, it invokes the `make` command.
### `gulp test-debug` In order to run the JavaScript test units with the mediasoup worker in `Debug` mode the `MEDIASOUP_BUILDTYPE` environment variable must be set to `Debug`:
Run the JavaScript [test units](test/) in a more verbose fashion. Note however that running this task does not use the `Debug` mediasoup worker binary. If you wish to use it, set the `MEDIASOUP_BUILDTYPE` environment variable as explained above. ```bash
$ MEDIASOUP_BUILDTYPE=Debug gulp test-debug
```
### `gulp test-worker` ### `gulp test-worker`
Run the mediasoup worker [test units](worker/test/). Take into account that, before running this task, the mediasoup worker test unit binary must be built by running `make test` (as explained above). Runs the mediasoup worker [test units](worker/test/) in `Debug` mode. Before it, it invokes the `make test` command.
### `gulp`
The default task runs the `link` task.
...@@ -4,7 +4,12 @@ ...@@ -4,7 +4,12 @@
.PHONY: default Release Debug test xcode clean clean-all .PHONY: default Release Debug test xcode clean clean-all
default: Release default:
ifeq ($(MEDIASOUP_BUILDTYPE),Debug)
make Debug
else
make Release
endif
Release: Release:
cd worker && ./scripts/configure.py -R mediasoup-worker cd worker && ./scripts/configure.py -R mediasoup-worker
......
...@@ -3,18 +3,18 @@ ...@@ -3,18 +3,18 @@
const gulp = require('gulp'); const gulp = require('gulp');
const eslint = require('gulp-eslint'); const eslint = require('gulp-eslint');
const replace = require('gulp-replace'); const replace = require('gulp-replace');
const touch = require('gulp-touch'); const touch = require('gulp-touch-cmd');
const shell = require('gulp-shell'); const shell = require('gulp-shell');
let tests = let tests =
[ [
'test/test_mediasoup.js', 'test/test_mediasoup.js',
'test/test_Server.js', // 'test/test_Server.js',
'test/test_Room.js', // 'test/test_Room.js',
'test/test_Peer.js', // 'test/test_Peer.js',
'test/test_Transport.js', // 'test/test_Transport.js',
'test/test_RtpReceiver.js', // 'test/test_RtpReceiver.js',
'test/test_extra.js' // 'test/test_extra.js'
// NOTE: Disable this test until fixed // NOTE: Disable this test until fixed
// 'test/test_scene_1.js' // 'test/test_scene_1.js'
]; ];
...@@ -27,8 +27,7 @@ gulp.task('lint', () => ...@@ -27,8 +27,7 @@ gulp.task('lint', () =>
'gulpfile.js', 'gulpfile.js',
'lib/**/*.js', 'lib/**/*.js',
'data/**/*.js', 'data/**/*.js',
'test/**/*.js', 'test/**/*.js'
'!node_modules/**'
]; ];
return gulp.src(src) return gulp.src(src)
...@@ -37,37 +36,33 @@ gulp.task('lint', () => ...@@ -37,37 +36,33 @@ gulp.task('lint', () =>
.pipe(eslint.failAfterError()); .pipe(eslint.failAfterError());
}); });
gulp.task('capabilities', () => gulp.task('rtpcapabilities', () =>
{ {
let capabilities = require('./data/supportedCapabilities'); let supportedRtpCapabilities = require('./lib/supportedRtpCapabilities');
return gulp.src('worker/src/RTC/Room.cpp') return gulp.src('worker/src/RTC/Room.cpp')
.pipe(replace(/(std::string capabilities =).*/, `$1 R"(${JSON.stringify(capabilities)})";`)) .pipe(replace(/(const std::string supportedRtpCapabilities =).*/, `$1 R"(${JSON.stringify(supportedRtpCapabilities)})";`))
.pipe(gulp.dest('worker/src/RTC/')) .pipe(gulp.dest('worker/src/RTC/'))
.pipe(touch()); .pipe(touch());
}); });
gulp.task('test', shell.task( gulp.task('test-api', shell.task(
[ `tap --bail --color --reporter=spec ${tests.join(' ')}` ], [
'if type make &> /dev/null; then make; fi',
`tap --bail --color --reporter=spec ${tests.join(' ')}`
],
{ {
verbose : true,
env : { DEBUG: '*ABORT*' } env : { DEBUG: '*ABORT*' }
} }
)); ));
gulp.task('test-debug', shell.task(
[ `tap --bail --reporter=tap ${tests.join(' ')}` ],
{
env : { DEBUG: '*WARN* *ERROR* *ABORT*' },
verbose : true
}
));
gulp.task('test-worker', shell.task( gulp.task('test-worker', shell.task(
[ 'worker/out/Debug/mediasoup-worker-test' ], [
'if type make &> /dev/null; then make test; fi',
'worker/out/Debug/mediasoup-worker-test'
],
{ {
env : { DEBUG: '*WARN* *ERROR* *ABORT*' },
verbose : true verbose : true
} }
)); ));
gulp.task('default', gulp.series('lint'));
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论