Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: wasm tagrets in multiplatform dsl #4284

Merged
merged 4 commits into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions docs/topics/multiplatform/multiplatform-dsl-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ The complete list of available targets is the following:
<td><code>jvm</code></td>
<td></td>
</tr>
<tr>
<td rowspan="2">Kotlin/Wasm</td>
<td><code>wasmJs</code></td>
<td>Use it if you plan to run your projects in the JavaScript runtime.</td>
</tr>
<tr>
<td><code>wasmWasi</code></td>
<td>Use it if you need support for the <a href="https://github.com/WebAssembly/WASI">WASI</a> system interface.</td>
</tr>
<tr>
<td>Kotlin/JS</td>
<td><code>js</code></td>
Expand Down Expand Up @@ -129,7 +138,7 @@ In any target block, you can use the following declarations:
|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `attributes` | Attributes used for [disambiguating targets](multiplatform-set-up-targets.md#distinguish-several-targets-for-one-platform) for a single platform. |
| `preset` | The preset that the target has been created from, if any. |
| `platformType` | Designates the Kotlin platform of this target. Available values: `jvm`, `androidJvm`, `js`, `native`, `common`. |
| `platformType` | Designates the Kotlin platform of this target. Available values: `jvm`, `androidJvm`, `js`, `wasm`, `native`, `common`. |
| `artifactsTaskName` | The name of the task that builds the resulting artifacts of this target. |
| `components` | The components used to setup Gradle publications. |
| `compilerOptions` | The [compiler options](gradle-compiler-options.md) used for the target. This declaration overrides any `compilerOptions {}` configured at [top level](multiplatform-dsl-reference.md#top-level-blocks). To use it, add the following opt-in: `@OptIn(ExperimentalKotlinGradlePluginApi::class)` |
Expand Down Expand Up @@ -161,17 +170,35 @@ kotlin {
}
```

### JavaScript targets
### Web targets

The `js {}` block describes the configuration of JavaScript targets. It can contain one of two blocks depending on the target execution environment:
The `js {}` block describes the configuration of Kotlin/JS targets, and the `wasmJs {}` block describes the configuration of
Kotlin/Wasm targets interoperable with JavaScript. They can contain one of two blocks depending on the target execution
environment:

| **Name** | **Description** |
|-----------|--------------------------------------|
| `browser` | Configuration of the browser target. |
| `nodejs` | Configuration of the Node.js target. |
| **Name** | **Description** |
|-----------------------|--------------------------------------|
| [`browser`](#browser) | Configuration of the browser target. |
| [`nodejs`](#node-js) | Configuration of the Node.js target. |

Learn more about [configuring Kotlin/JS projects](js-project-setup.md).

A separate `wasmWasi {}` block describes the configuration of Kotlin/Wasm targets that support the WASI system interface.
Here, only the [`nodejs`](#node-js) execution environment is available:

```kotlin
kotlin {
wasmWasi {
nodejs()
binaries.executable()
}
}
```

All the web targets, `js`, `wasmJs`, and `wasmWasi`, also support the `binaries.executable()` call. It explicitly
instructs the Kotlin compiler to emit executable files. For more information, see [Execution environments](js-project-setup.md#execution-environments)
in the Kotlin/JS documentation.

#### Browser

`browser {}` can contain the following configuration blocks:
Expand Down
Loading