Skip to content

Commit

Permalink
Rework the Node.js section of the build guide
Browse files Browse the repository at this point in the history
- Use Node.js as the name, as that's also what's on the website
- Link to the websites of the dependencies
- Move the Node.js API prerequisites below the C++ section, in order of priority
- Create a Node.js Tests section, similar to C++, just for running the tests
- Change the remaining Node.js API build section, similar to C++, to
  explain what's needed to build it from git and how to use it.
  • Loading branch information
tronical committed Sep 22, 2022
1 parent e97e12d commit 2b7343c
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,20 @@ For Linux a few additional packages beyond the usual build essentials are needed
- Make sure the MSVC Build Tools are installed: `winget install Microsoft.VisualStudio.2022.BuildTools`
- (optional) make sure Qt is installed and `qmake` is in the `Path`

### NodeJS API (optional)

To use Slint from Node.JS, the following extra dependencies are needed.

- **node** (including npm) At this time you will need to use the LTS version.
- **python**

Node.JS support is not built by default! Check below for the extra commands
to run.

### C++ API (optional)

To use Slint from C++, the following extra dependencies are needed:

- **[cmake](https://cmake.org/download/)** (3.19 or newer)
- A C++ compiler that can supports C++20 (e.g., **MSVC 2019 16.6** on Windows)

### Node.js API (optional)

To use Slint from Node.js, the following extra dependencies are needed.

- **[Node.js](https://nodejs.org/en/)** (including npm) At this time you will need to use the LTS version.
- **[Python](https://www.python.org)**

## Building and Testing

Most of the project is written in Rust, and compiling and running the test can
Expand All @@ -71,6 +68,17 @@ cargo build --lib -p slint-cpp
cargo test -p test-driver-cpp
```

### Node.js Tests

The Node.js tests are contained in the `test-driver-nodejs` crate. It requires the Slint node library to be built,
which is not done by default. Build it explicitly before running the tests:

```sh
```sh
cargo build -p slint-node
cargo build -p test-driver-nodejs
```

### More Info About Tests

For more details about the tests and how they are implemented, see [testing.md](./testing.md).
Expand All @@ -94,17 +102,23 @@ cmake --install .

You can pass `-DCMAKE_INSTALL_PREFIX` in the first cmake command in order to choose the installation location.

### Node.JS API Build
### Node.js API Build

Run
The Slint Node.js API is implemented as npm build. You can build it locally using the following command line:

```sh
cargo build -p slint-node
cargo build -p test-driver-nodejs
cd api/node
npm install
```

after the steps above were done as `slint-node` will need the build results
of the default build step to function.
To build your own project against the Git version of the Slint Node.js API, add the path to the `api/node` folder
in the dependencies section of your `package.json`:

```json
"dependencies": {
"slint-ui": "/path/to/api/node"
},
```

## Cross-Compiling

Expand Down

0 comments on commit 2b7343c

Please sign in to comment.