Unverified 提交 25039048 authored 作者: Jesús Leganés-Combarro's avatar Jesús Leganés-Combarro 提交者: GitHub

Clean-ups (#1003)

上级 3bdad193
...@@ -20,15 +20,15 @@ jobs: ...@@ -20,15 +20,15 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Node.js - name: Node.js
uses: actions/setup-node@v2 uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.ci.node }} node-version: ${{ matrix.ci.node }}
- name: Configure cache - name: Configure cache
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: | path: |
~/.npm ~/.npm
......
...@@ -19,10 +19,10 @@ jobs: ...@@ -19,10 +19,10 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Configure cache - name: Configure cache
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: | path: |
~/.cargo/registry ~/.cargo/registry
......
...@@ -47,10 +47,10 @@ jobs: ...@@ -47,10 +47,10 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Node.js - name: Node.js
uses: actions/setup-node@v2 uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
...@@ -62,7 +62,7 @@ jobs: ...@@ -62,7 +62,7 @@ jobs:
if: runner.os != 'Windows' if: runner.os != 'Windows'
- name: Configure cache - name: Configure cache
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: | path: |
~/.npm ~/.npm
......
...@@ -36,3 +36,6 @@ ...@@ -36,3 +36,6 @@
/.vscode /.vscode
# JetBrains IDE stuff. # JetBrains IDE stuff.
/.idea /.idea
# Packaged module.
*.tgz
...@@ -2,133 +2,108 @@ ...@@ -2,133 +2,108 @@
This document is intended for mediasoup developers. This document is intended for mediasoup developers.
## NPM scripts ## NPM scripts
The `package.json` file in the main folder includes the following scripts: The `package.json` file in the main folder includes the following scripts:
### `npm run typescript:build` ### `npm run typescript:build`
Compiles mediasoup TypeScript code (`lib` folder) JavaScript and places it into the `lib` directory. Compiles mediasoup TypeScript code (`lib` folder) JavaScript and places it into the `lib` directory.
### `npm run typescript:watch` ### `npm run typescript:watch`
Compiles mediasoup TypeScript code (`lib` folder) JavaScript, places it into the `lib` directory an watches for changes in the TypeScript files. Compiles mediasoup TypeScript code (`lib` folder) JavaScript, places it into the `lib` directory an watches for changes in the TypeScript files.
### `npm run worker:build` ### `npm run worker:build`
Builds the `mediasoup-worker` binary. It invokes `make`below. Builds the `mediasoup-worker` binary. It invokes `make`below.
### `npm run lint` ### `npm run lint`
Runs both `npm run lint:node` and `npm run lint:worker`. Runs both `npm run lint:node` and `npm run lint:worker`.
### `npm run lint:node` ### `npm run lint:node`
Validates mediasoup JavaScript files using [ESLint](https://eslint.org). Validates mediasoup JavaScript files using [ESLint](https://eslint.org).
### `npm run lint:worker` ### `npm run lint:worker`
Validates mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html). It invokes `make lint` below. Validates mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html). It invokes `make lint` below.
### `npm run format:worker` ### `npm run format:worker`
Rewrites mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html). It invokes `make format` below. Rewrites mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html). It invokes `make format` below.
### `npm run test` ### `npm run test`
Runs both `npm run test:node` and `npm run test:worker`. Runs both `npm run test:node` and `npm run test:worker`.
### `npm run test:node` ### `npm run test:node`
Runs [Jest](https://jestjs.io) test units located at `test/` folder. Runs [Jest](https://jestjs.io) test units located at `test/` folder.
### `npm run test:worker` ### `npm run test:worker`
Runs [Catch2](https://github.com/catchorg/Catch2) test units located at `worker/test/` folder. It invokes `make test` below. Runs [Catch2](https://github.com/catchorg/Catch2) test units located at `worker/test/` folder. It invokes `make test` below.
### `npm run coverage:node` ### `npm run coverage:node`
Same as `npm run test:node` but it also opens a browser window with JavaScript coverage results. Same as `npm run test:node` but it also opens a browser window with JavaScript coverage results.
### `npm run install-deps:node` ### `npm run install-deps:node`
Installs NPM dependencies and updates `package-lock.json`. Installs NPM dependencies and updates `package-lock.json`.
### `npm run install-clang-tools` ### `npm run install-clang-tools`
Installs clang tools needed for local development. Installs clang tools needed for local development.
## Rust ## Rust
The only special feature in Rust case is special environment variable `KEEP_BUILD_ARTIFACTS`, that when set to `1` will allow incremental recompilation of changed C++ sources during hacking on mediasoup. The only special feature in Rust case is special environment variable `KEEP_BUILD_ARTIFACTS`, that when set to `1` will allow incremental recompilation of changed C++ sources during hacking on mediasoup.
It is not necessary for normal usage of mediasoup as a dependency. It is not necessary for normal usage of mediasoup as a dependency.
## Makefile ## Makefile
The `worker` folder contains a `Makefile` for the mediasoup-worker C++ subproject. It includes the following tasks: The `worker` folder contains a `Makefile` for the mediasoup-worker C++ subproject. It includes the following tasks:
### `make` or `make mediasoup-worker` ### `make` or `make mediasoup-worker`
Alias of ``make mediasoup-worker` below. Alias of ``make mediasoup-worker` below.
### `make meson-ninja` ### `make meson-ninja`
Installs `meson` and `ninja`. Installs `meson` and `ninja`.
### `make clean` ### `make clean`
Cleans built objects and binaries. Cleans built objects and binaries.
### `make clean-build` ### `make clean-build`
Cleans built objects and other artifacts, but keeps `mediasoup-worker` binary in place. Cleans built objects and other artifacts, but keeps `mediasoup-worker` binary in place.
### `make clean-pip` ### `make clean-pip`
Cleans `meson` and `ninja` installed in local prefix with pip. Cleans `meson` and `ninja` installed in local prefix with pip.
### `make clean-subprojects` ### `make clean-subprojects`
Cleans subprojects downloaded with Meson. Cleans subprojects downloaded with Meson.
### `make clean-all` ### `make clean-all`
Cleans built objects and binaries, `meson` and `ninja` installed in local prefix with pip and all subprojects downloaded with Meson. Cleans built objects and binaries, `meson` and `ninja` installed in local prefix with pip and all subprojects downloaded with Meson.
### `make update-wrap-file` ### `make update-wrap-file`
Update the wrap file of a subproject with Meson. Usage example: Update the wrap file of a subproject with Meson. Usage example:
```bash ```bash
$ cd worker cd worker
$ make update-wrap-file SUBPROJECT=openssl make update-wrap-file SUBPROJECT=openssl
``` ```
### `make mediasoup-worker` ### `make mediasoup-worker`
Builds the `mediasoup-worker` binary at `worker/out/Release/`. Builds the `mediasoup-worker` binary at `worker/out/Release/`.
...@@ -144,44 +119,37 @@ Binary is built at `worker/out/MEDIASOUP_BUILDTYPE/build`. ...@@ -144,44 +119,37 @@ Binary is built at `worker/out/MEDIASOUP_BUILDTYPE/build`.
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: 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
``` ```
If the "MEDIASOUP_WORKER_BIN" environment variable is set, mediasoup will use the it as mediasoup-worker binary and **won't** compile the binary: If the "MEDIASOUP_WORKER_BIN" environment variable is set, mediasoup will use the it as mediasoup-worker binary and **won't** compile the binary:
```bash ```bash
$ MEDIASOUP_WORKER_BIN="/home/xxx/src/foo/mediasoup-worker" node myapp.js MEDIASOUP_WORKER_BIN="/home/xxx/src/foo/mediasoup-worker" node myapp.js
``` ```
### `make libmediasoup-worker` ### `make libmediasoup-worker`
Builds the `libmediasoup-worker` static library at `worker/out/Release/`. Builds the `libmediasoup-worker` static library at `worker/out/Release/`.
`MEDIASOUP_MAX_CORES` and `MEDIASOUP_BUILDTYPE` environment variables from above still apply for static library build. `MEDIASOUP_MAX_CORES` and `MEDIASOUP_BUILDTYPE` environment variables from above still apply for static library build.
### `make xcode` ### `make xcode`
Builds a Xcode project for the mediasoup-worker subproject. Builds a Xcode project for the mediasoup-worker subproject.
### `make lint` ### `make lint`
Validates mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html) and rules in `worker/.clang-format`. Validates mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html) and rules in `worker/.clang-format`.
### `make format` ### `make format`
Rewrites mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html). Rewrites mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html).
### `make test` ### `make test`
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. 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 tidy` ### `make tidy`
Runs [clang-tidy](http://clang.llvm.org/extra/clang-tidy/) and performs C++ code checks following `worker/.clang-tidy` rules. Runs [clang-tidy](http://clang.llvm.org/extra/clang-tidy/) and performs C++ code checks following `worker/.clang-tidy` rules.
...@@ -190,8 +158,7 @@ Runs [clang-tidy](http://clang.llvm.org/extra/clang-tidy/) and performs C++ code ...@@ -190,8 +158,7 @@ Runs [clang-tidy](http://clang.llvm.org/extra/clang-tidy/) and performs C++ code
* `make clean` and `make` must have been called first. * `make clean` and `make` must have been called first.
* [PyYAML](https://pyyaml.org/) is required. * [PyYAML](https://pyyaml.org/) is required.
- In OSX install it with `brew install libyaml` and `sudo easy_install-X.Y pyyaml`. * In OSX install it with `brew install libyaml` and `sudo easy_install-X.Y pyyaml`.
### `make fuzzer` ### `make fuzzer`
...@@ -205,12 +172,10 @@ Builds the `mediasoup-worker-fuzzer` binary (which uses [libFuzzer](http://llvm. ...@@ -205,12 +172,10 @@ Builds the `mediasoup-worker-fuzzer` binary (which uses [libFuzzer](http://llvm.
Read the [Fuzzer](Fuzzer.md) documentation for detailed information. Read the [Fuzzer](Fuzzer.md) documentation for detailed information.
### `make fuzzer-run-all` ### `make fuzzer-run-all`
Runs all fuzzer cases. Runs all fuzzer cases.
### `make docker` ### `make docker`
Builds a Linux image with fuzzer capable clang++. Builds a Linux image with fuzzer capable clang++.
...@@ -218,11 +183,10 @@ Builds a Linux image with fuzzer capable clang++. ...@@ -218,11 +183,10 @@ Builds a Linux image with fuzzer capable clang++.
**NOTE:** Before running this command, a specific version of Linux clang must be downloaded. To get it, run: **NOTE:** Before running this command, a specific version of Linux clang must be downloaded. To get it, run:
```bash ```bash
$ cd worker cd worker
$ ./scripts/get-dep.sh clang-fuzzer ./scripts/get-dep.sh clang-fuzzer
``` ```
### `make docker-run` ### `make docker-run`
Runs a container of the Docker image created with `make docker`. It automatically executes a `bash` session in the `/mediasoup` directory, which is a Docker volume that points to the real `mediasoup` directory. Runs a container of the Docker image created with `make docker`. It automatically executes a `bash` session in the `/mediasoup` directory, which is a Docker volume that points to the real `mediasoup` directory.
...@@ -4,7 +4,6 @@ Once we have built the `mediasoup-worker-fuzzer` target in a Linux environment w ...@@ -4,7 +4,6 @@ Once we have built the `mediasoup-worker-fuzzer` target in a Linux environment w
**NOTE:** From now on, we assume we are in the mediasoup `worker` directory. **NOTE:** From now on, we assume we are in the mediasoup `worker` directory.
## Related documentation ## Related documentation
* [libFuzzer documentation](http://llvm.org/docs/LibFuzzer.html) * [libFuzzer documentation](http://llvm.org/docs/LibFuzzer.html)
...@@ -12,14 +11,12 @@ Once we have built the `mediasoup-worker-fuzzer` target in a Linux environment w ...@@ -12,14 +11,12 @@ Once we have built the `mediasoup-worker-fuzzer` target in a Linux environment w
* [webrtcH4cKS ~ Lets get better at fuzzing in 2019](https://webrtchacks.com/lets-get-better-at-fuzzing-in-2019-heres-how/) * [webrtcH4cKS ~ Lets get better at fuzzing in 2019](https://webrtchacks.com/lets-get-better-at-fuzzing-in-2019-heres-how/)
* [OSS-Fuzz](https://github.com/google/oss-fuzz) - Continuous fuzzing of open source software ("fuzz for me") * [OSS-Fuzz](https://github.com/google/oss-fuzz) - Continuous fuzzing of open source software ("fuzz for me")
## Corpus files ## Corpus files
The `deps/webrtc-fuzzer-corpora/corpora` directory has corpus directories taken from the [webrtc-fuzzer-corpora](https://github.com/RTC-Cartel/webrtc-fuzzer-corpora) project. They should be use to feed fuzzer with appropriate input. The `deps/webrtc-fuzzer-corpora/corpora` directory has corpus directories taken from the [webrtc-fuzzer-corpora](https://github.com/RTC-Cartel/webrtc-fuzzer-corpora) project. They should be use to feed fuzzer with appropriate input.
However, given how `libFuzzer` [works](http://llvm.org/docs/LibFuzzer.html#options), the first directory given as command line parameter is not just used for reading corpus files, but also to store newly generated ones. So, it's recommended to pass `fuzzer/new-corpus` as first directory. Such a directory is gitignored. However, given how `libFuzzer` [works](http://llvm.org/docs/LibFuzzer.html#options), the first directory given as command line parameter is not just used for reading corpus files, but also to store newly generated ones. So, it's recommended to pass `fuzzer/new-corpus` as first directory. Such a directory is gitignored.
## Crash reports ## Crash reports
When the fuzzer detects an issue it generates a crash report file which contains the bytes given as input. Those files can be individually used later (instead of passing corpus directories) to the fuzzer to verify that the issue has been fixed. When the fuzzer detects an issue it generates a crash report file which contains the bytes given as input. Those files can be individually used later (instead of passing corpus directories) to the fuzzer to verify that the issue has been fixed.
...@@ -50,41 +47,40 @@ The mediasoup-worker fuzzer reads some custom environment variables to decide wh ...@@ -50,41 +47,40 @@ The mediasoup-worker fuzzer reads some custom environment variables to decide wh
The log level can also be set by setting the `MS_FUZZ_LOG_LEVEL` environment variable to "debug", "warn" or "error" (it is "none" if unset). The log level can also be set by setting the `MS_FUZZ_LOG_LEVEL` environment variable to "debug", "warn" or "error" (it is "none" if unset).
## Usage examples ## Usage examples
* Detect memory leaks and just fuzz STUN: * Detect memory leaks and just fuzz STUN:
```bash ```bash
$ MS_FUZZ_STUN=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus MS_FUZZ_STUN=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus
``` ```
* Detect memory leaks and just fuzz RTP: * Detect memory leaks and just fuzz RTP:
```bash ```bash
$ MS_FUZZ_RTP=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus MS_FUZZ_RTP=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus
``` ```
* Detect memory leaks and just fuzz RTCP: * Detect memory leaks and just fuzz RTCP:
```bash ```bash
$ MS_FUZZ_RTCP=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus MS_FUZZ_RTCP=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus
``` ```
* Detect memory leaks and just fuzz mediasoup-worker C++ utils: * Detect memory leaks and just fuzz mediasoup-worker C++ utils:
```bash ```bash
$ MS_FUZZ_UTILS=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=2000 fuzzer/new-corpus MS_FUZZ_UTILS=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=2000 fuzzer/new-corpus
``` ```
* Detect memory leaks and fuzz everything with log level "warn": * Detect memory leaks and fuzz everything with log level "warn":
```bash ```bash
$ MS_FUZZ_LOG_LEVEL=warn LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/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 MS_FUZZ_LOG_LEVEL=warn LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/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
``` ```
* Verify that a specific crash is fixed: * Verify that a specific crash is fixed:
```bash ```bash
$ LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer fuzzer/reports/crash-f39771f7a03c0e7e539d4e52f48f7adad8976404 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer fuzzer/reports/crash-f39771f7a03c0e7e539d4e52f48f7adad8976404
``` ```
...@@ -20,23 +20,23 @@ ...@@ -20,23 +20,23 @@
"main": "node/lib/index.js", "main": "node/lib/index.js",
"types": "node/lib/index.d.ts", "types": "node/lib/index.d.ts",
"files": [ "files": [
"npm-scripts.js",
"node/lib", "node/lib",
"worker/Makefile",
"worker/meson.build",
"worker/meson_options.txt",
"worker/src",
"worker/include",
"worker/test/src",
"worker/test/include",
"worker/fuzzer/src",
"worker/fuzzer/include",
"worker/subprojects/*.wrap",
"worker/deps/libwebrtc", "worker/deps/libwebrtc",
"worker/fuzzer/include",
"worker/fuzzer/src",
"worker/include",
"worker/scripts/*.js",
"worker/scripts/*.json",
"worker/scripts/*.py", "worker/scripts/*.py",
"worker/scripts/*.sh", "worker/scripts/*.sh",
"worker/scripts/*.js", "worker/src",
"worker/scripts/*.json" "worker/subprojects/*.wrap",
"worker/test/include",
"worker/test/src",
"worker/Makefile",
"worker/meson.build",
"worker/meson_options.txt",
"npm-scripts.js"
], ],
"keywords": [ "keywords": [
"webrtc", "webrtc",
......
...@@ -18,7 +18,7 @@ LCOV = ./deps/lcov/bin/lcov ...@@ -18,7 +18,7 @@ LCOV = ./deps/lcov/bin/lcov
DOCKER ?= docker DOCKER ?= docker
PIP_DIR = $(MEDIASOUP_OUT_DIR)/pip PIP_DIR = $(MEDIASOUP_OUT_DIR)/pip
INSTALL_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) INSTALL_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
BUILD_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/build BUILD_DIR ?= $(INSTALL_DIR)/build
MESON ?= $(PIP_DIR)/bin/meson MESON ?= $(PIP_DIR)/bin/meson
MESON_VERSION ?= 0.61.5 MESON_VERSION ?= 0.61.5
# `MESON_ARGS` can be used to provide extra configuration parameters to Meson, # `MESON_ARGS` can be used to provide extra configuration parameters to Meson,
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论