emsdk-env 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,10 +1,98 @@
1
1
  # emsdk-env
2
2
 
3
- TODO:
3
+ A Vite plugin that automatically builds WASM C/C++ source code using the Emscripten SDK.
4
+
5
+ ![emsdk-env](./images/emsdk-env-120.png)
6
+
7
+ [![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
+
10
+ ---
11
+
12
+ WIP:
4
13
 
5
14
  ## What is this?
6
15
 
7
- TODO:
16
+ This is a Vite plugin that automatically downloads and manages the Emscripten SDK, and makes it possible to automatically build WASM C/C++ code in your project.
17
+ With this plugin, you can easily set up a WASM C/C++ development environment in your Vite project.
18
+
19
+ Usage is simple. Just add this Vite plugin package to your project and initialize the plugin in `vite.config.ts` like this:
20
+
21
+ ```typescript
22
+ // `vite.config.ts`
23
+ import { defineConfig } from 'vite';
24
+
25
+ // Refer to the emsdk-env Vite plugin
26
+ import emsdkEnv from 'emsdk-env/vite';
27
+
28
+ export default defineConfig({
29
+ plugins: [
30
+ // Add as a plugin
31
+ emsdkEnv({
32
+ // Build targets
33
+ targets: {
34
+ // Generate "add.wasm"
35
+ add: {
36
+ // Compiler options
37
+ options: ['-O3', '-std=c99'],
38
+ // Linker options
39
+ linkOptions: ['-s', 'STANDALONE_WASM=1', '--no-entry'],
40
+ // Exported symbols
41
+ exports: ['_add'],
42
+ },
43
+ },
44
+ }),
45
+ ],
46
+ });
47
+ ```
48
+
49
+ If the source code changes, it will automatically rebuild and reload the page.
50
+ You can focus on writing C/C++ code just like you would TypeScript/JavaScript code!
51
+
52
+ ### Features
53
+
54
+ - Automatic setup and caching of the Emscripten SDK
55
+ - HMR support via Vite plugin (Note: C/C++ code requires a full build)
56
+ - Support for parallel builds
57
+ - Simplified specification of export symbols
58
+ - Ability to generate multiple target WASM binaries
59
+ - Customizable directory paths, compile options, and linker options
60
+
61
+ ---
62
+
63
+ ## Usage
64
+
65
+ ### Installation
66
+
67
+ Add to `devDependencies` (emsdk-env itself does not require runtime code):
68
+
69
+ ```bash
70
+ $ npm install -D emsdk-env
71
+ ```
72
+
73
+ ### C/C++ Source Code and Binary Placement
74
+
75
+ By default, C/C++ source code is placed in the `wasm/` directory under your project,
76
+ and the built WASM binaries are placed in the `src/wasm/` directory.
77
+
78
+ A typical directory structure looks like this:
79
+
80
+ ```
81
+ project/
82
+ ├── package.json
83
+ ├── vite.config.ts
84
+ ├── src/
85
+ │ └── wasm/
86
+ │ └── add.wasm
87
+ └── wasm/
88
+ └── add.c
89
+ ```
90
+
91
+ ### Documents
92
+
93
+ For more information, please visit repository and refer README: [emsdk-env](https://github.com/kekyo/emsdk-env)
94
+
95
+ ---
8
96
 
9
97
  ## License
10
98