Skip to content
This repository has been archived by the owner on Feb 21, 2025. It is now read-only.

Commit

Permalink
Node: Remove compiled JavaScript from repository and compile TypeScri…
Browse files Browse the repository at this point in the history
…pt code on NPM `prepare` script on demand when installed via git (versatica#954)
  • Loading branch information
ibc authored and piranna committed Feb 8, 2023
1 parent 6babfe0 commit ebc97e9
Show file tree
Hide file tree
Showing 96 changed files with 10,384 additions and 8,813 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Tell GitHub to ignore some folders when detecting the project language.
art/* linguist-vendored=true
doc/* linguist-vendored=true
node/lib/* linguist-vendored=true
node/test/* linguist-vendored=true
rust/benches/* linguist-vendored=true
rust/examples/* linguist-vendored=true
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/mediasoup-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ jobs:
- run: npm install
- run: npm run lint:node
if: runner.os == 'Linux'
- run: npm run typescript:build
- run: npm run test:node
27 changes: 15 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,36 @@
/coverage/
/NO_GIT/
*.tgz
/node_modules
/node/lib

## Rust.
/Cargo.lock
/rust/examples-frontend/*/node_modules/
/rust/examples-frontend/*/node_modules
/rust/examples-frontend/*/package-lock.json
/target/
/target

## Worker.
/worker/out/
/worker/scripts/node_modules/
/worker/out
/worker/scripts/node_modules
# Vistual Studio generated Stuff.
/worker/**/Debug/
/worker/**/Release/
/worker/.vs/
/worker/**/Debug
/worker/**/Release
/worker/.vs
# clang-fuzzer stuff is too big.
/worker/deps/clang-fuzzer/
/worker/deps/clang-fuzzer
# Ignore all fuzzer generated test inputs.
/worker/fuzzer/new-corpus/*
!/worker/fuzzer/new-corpus/.placeholder

## Others.
/coverage/
/NO_GIT/
/coverage
/NO_GIT
*.swp
*.swo
.DS_Store/
.DS_Store
# Vistual Studio Code stuff.
/.vscode/
/.vscode
# JetBrains IDE stuff.
/.idea/

Expand All @@ -52,3 +54,4 @@

# Temporarily included meson.build files
!/worker/subprojects/packagefiles
/.idea
7 changes: 5 additions & 2 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
package-lock=false
@mafalda:registry=https://npm.pkg.github.com/
# Generate package-lock.json.
package-lock=true
@dyte-in:registry=https://npm.pkg.github.com/
always-auth=true
# For bad node/npm version to throw actual error.
engine-strict=true
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

### NEXT

* Node: Remove compiled JavaScript from repository and compile TypeScript code on NPM `prepare` script on demand when installed via git (PR #954).
* `Worker`: Add `RTC::Shared` singleton for RTC entities (PR #953).


Expand Down
83 changes: 48 additions & 35 deletions doc/Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,66 @@

This document is intended for mediasoup developers.


## NPM scripts

The `package.json` file in the main folder includes the following scripts:


### `npm run typescript:build`

Compiles mediasoup TypeScript code (`lib` folder) JavaScript and places it into the `lib` directory.


### `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.

### `npm run worker:build`

Builds the `mediasoup-worker` binary. It invokes `make`below.

### `npm run lint`

Runs both `npm run lint:node` and `npm run lint:worker`.


### `npm run lint:node`

Validates mediasoup JavaScript files using [ESLint](https://eslint.org).


### `npm run lint:worker`

Validates mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html). It invokes `make lint` below.


### `npm run format:worker`

Rewrites mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html). It invokes `make format` below.


### `npm run test`

Runs both `npm run test:node` and `npm run test:worker`.


### `npm run test:node`

Runs [Jest](https://jestjs.io) test units located at `test/` folder.


### `npm run test:worker`

Runs [Catch2](https://github.com/catchorg/Catch2) test units located at `worker/test/` folder. It invokes `make test` below.


### `npm run coverage:node`

Same as `npm run test:node` but it also opens a browser window with JavaScript coverage results.

### `npm run install-deps:node`

Installs NPM dependencies and updates `package-lock.json`.

### `npm run install-clang-tools`

Installs clang tools needed for local development.

## Makefile

The `worker` folder contains a `Makefile` for the mediasoup-worker C++ subproject. It includes the following tasks:


### `make` or `make mediasoup-worker`

Builds the `mediasoup-worker` binary at `worker/out/*/Release/`.
Expand All @@ -77,77 +77,94 @@ 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:

```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:

```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 meson-ninja`

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.

### `make clean`

Cleans built objects and binaries.


### `make clean-build`

Cleans built objects and other artifacts, but keeps `mediasoup-worker` binary in place.


### `make clean-pip`

Cleans `meson` and `ninja` installed in local prefix with pip.


### `make clean-subprojects`

Cleans subprojects downloaded with Meson.


### `make clean-all`

Cleans built objects and binaries, `meson` and `ninja` installed in local prefix with pip and all subprojects downloaded with Meson.


### `make update-wrap-file`

Update the wrap file of a subproject with Meson. Usage example:

```bash
$ cd worker
$ make update-wrap-file SUBPROJECT=openssl
cd worker
make update-wrap-file SUBPROJECT=openssl
```

### `make mediasoup-worker`

Builds the `mediasoup-worker` binary at `worker/out/Release/`.

If the "MEDIASOUP_MAX_CORES" environment variable is set, the build process will use that number of CPU cores. Otherwise it will auto-detect the number of cores in the machine.

"MEDIASOUP_BUILDTYPE" environment variable controls build types, `Release` and `Debug` are presets optimized for those use cases.
Other build types are possible too, but they are not presets and will require "MESON_ARGS" use to customize build configuration.
Check the meaning of useful macros in the `worker/include/Logger.hpp` header file if you want to enable tracing or other debug information.

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:

```bash
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:

```bash
MEDIASOUP_WORKER_BIN="/home/xxx/src/foo/mediasoup-worker" node myapp.js
```

### `make libmediasoup-worker`

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.

### `make xcode`

Builds a Xcode project for the mediasoup-worker subproject.


### `make lint`

Validates mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html) and rules in `worker/.clang-format`.


### `make format`

Rewrites mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html).


### `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.


### `make tidy`

Runs [clang-tidy](http://clang.llvm.org/extra/clang-tidy/) and performs C++ code checks following `worker/.clang-tidy` rules.
Expand All @@ -156,8 +173,7 @@ Runs [clang-tidy](http://clang.llvm.org/extra/clang-tidy/) and performs C++ code

* `make clean` and `make` must have been called first.
* [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`

Expand All @@ -171,24 +187,21 @@ Builds the `mediasoup-worker-fuzzer` binary (which uses [libFuzzer](http://llvm.

Read the [Fuzzer](Fuzzer.md) documentation for detailed information.


### `make fuzzer-run-all`

Runs all fuzzer cases.


### `make docker-build`

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:

```bash
$ cd worker
$ ./scripts/get-dep.sh clang-fuzzer
cd worker
./scripts/get-dep.sh clang-fuzzer
```


### `make docker-run`

Runs a container of the Docker image created with `make docker-build`. It automatically executes a `bash` session in the `/mediasoup` directory, which is a Docker volume that points to the real `mediasoup` directory.
36 changes: 0 additions & 36 deletions node/lib/ActiveSpeakerObserver.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion node/lib/ActiveSpeakerObserver.d.ts.map

This file was deleted.

44 changes: 0 additions & 44 deletions node/lib/ActiveSpeakerObserver.js

This file was deleted.

Loading

0 comments on commit ebc97e9

Please sign in to comment.