Skip to content

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 (#954)
  • Loading branch information
ibc authored Nov 18, 2022
1 parent 47147af commit c8a7113
Show file tree
Hide file tree
Showing 96 changed files with 10,353 additions and 8,841 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
29 changes: 15 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,35 @@
!/worker/subprojects/*.wrap

## Node.
/node_modules/
/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/
/.idea
5 changes: 4 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
package-lock=false
# Generate package-lock.json.
package-lock=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
70 changes: 49 additions & 21 deletions doc/Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Compiles mediasoup TypeScript code (`lib` folder) JavaScript and places it into

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`.
Expand Down Expand Up @@ -57,41 +63,30 @@ Runs [Catch2](https://github.com/catchorg/Catch2) test units located at `worker/
Same as `npm run test:node` but it also opens a browser window with JavaScript coverage results.


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

The `worker` folder contains a `Makefile` for the mediasoup-worker C++ subproject. It includes the following tasks:
Installs NPM dependencies and updates `package-lock.json`.


### `make` or `make mediasoup-worker`
### `npm run install-clang-tools`

Builds the `mediasoup-worker` binary at `worker/out/Release/`.
Installs clang tools needed for local development.

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

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:
The `worker` folder contains a `Makefile` for the mediasoup-worker C++ subproject. It includes the following tasks:

```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:
### `make` or `make mediasoup-worker`

```bash
$ MEDIASOUP_WORKER_BIN="/home/xxx/src/foo/mediasoup-worker" node myapp.js
```
Alias of ``make mediasoup-worker` below.


### `make libmediasoup-worker`
### `make meson-ninja`

Builds the `libmediasoup-worker` static library at `worker/out/Release/`.
Installs `meson` and `ninja`.

`MEDIASOUP_MAX_CORES` and `MEDIASOUP_BUILDTYPE` environment variables from above still apply for static library build.

### `make clean`

Expand Down Expand Up @@ -128,6 +123,39 @@ $ 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.
Expand Down
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.

55 changes: 0 additions & 55 deletions node/lib/AudioLevelObserver.d.ts

This file was deleted.

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

This file was deleted.

56 changes: 0 additions & 56 deletions node/lib/AudioLevelObserver.js

This file was deleted.

Loading

0 comments on commit c8a7113

Please sign in to comment.