Skip to content

Commit 22932d8

Browse files
committed
fix(website): migrate to v2
1 parent 6fcad75 commit 22932d8

28 files changed

Lines changed: 753 additions & 485 deletions

pnpm-lock.yaml

Lines changed: 272 additions & 85 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/docs/api/cli/build.md

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,79 +5,106 @@ Usage: cppjs build [options]
55
compile the project that was set up using Cpp.js
66

77
Options:
8-
-p, --platform <platform> target platform (choices: "All", "WebAssembly", "Android", "iOS", default: "All")
9-
-h, --help display help for command
8+
-p, --platform <platform> target platform (choices: "wasm", "android", "ios")
9+
-a, --arch <arch> target architecture (choices: "wasm32", "wasm64", "arm64-v8a", "x86_64", "iphoneos", "iphonesimulator")
10+
-r, --runtime <runtime> target runtime (choices: "st", "mt")
11+
-b, --build-type <buildType> target build type (choices: "release", "debug")
12+
-e, --runtime-env <runtimeEnv> target runtime environment (choices: "browser", "edge", "node")
13+
-h, --help display help for command
1014
```
1115

16+
Each option accepts a comma-separated list. When an option is omitted, all valid values are selected (except `wasm64`, which is opt-in).
17+
1218
<br />
1319

1420
**Output**
21+
22+
The build outputs platform-specific artifacts under `dist/prebuilt/<platform>-<arch>-<runtime>-<buildType>/`. For each WebAssembly target, the corresponding `.js` and `.wasm` files are also emitted with the runtime environment (browser, edge, node) embedded in the file name.
23+
1524
```
1625
├── dist
17-
│ ├── mylib.wasm
18-
│ ├── mylib.browser.js
19-
│ ├── mylib.node.js
26+
│ ├── mylib-wasm-wasm32-st-release.browser.js
27+
│ ├── mylib-wasm-wasm32-st-release.browser.wasm
28+
│ ├── mylib-wasm-wasm32-st-release.edge.js
29+
│ ├── mylib-wasm-wasm32-st-release.edge.wasm
30+
│ ├── mylib-wasm-wasm32-st-release.node.js
31+
│ ├── mylib-wasm-wasm32-st-release.node.wasm
32+
│ ├── mylib-wasm-wasm32-mt-release.browser.js
33+
│ ├── mylib-wasm-wasm32-mt-release.browser.wasm
34+
│ ├── mylib-wasm-wasm32-mt-release.node.js
35+
│ ├── mylib-wasm-wasm32-mt-release.node.wasm
2036
│ └── prebuilt
21-
│ ├── Android-arm64-v8a
37+
│ ├── wasm-wasm32-st-release
2238
│ │ ├── include
2339
│ │ │ └── ...
2440
│ │ └── lib
25-
│ │ └── mylib.so
41+
│ │ └── libmylib.a
2642
│ │
27-
│ ├── Android-x86_64
43+
│ ├── wasm-wasm32-mt-release
2844
│ │ ├── include
2945
│ │ │ └── ...
3046
│ │ └── lib
31-
│ │ └── mylib.so
47+
│ │ └── libmylib.a
3248
│ │
33-
│ ├── Emscripten-x86_64
49+
│ ├── android-arm64-v8a-mt-release
3450
│ │ ├── include
3551
│ │ │ └── ...
3652
│ │ └── lib
37-
│ │ └── mylib.a
53+
│ │ └── libmylib.a
3854
│ │
39-
│ ├── iOS-iphoneos
55+
│ ├── android-x86_64-mt-release
4056
│ │ ├── include
4157
│ │ │ └── ...
4258
│ │ └── lib
43-
│ │ └── mylib.a
59+
│ │ └── libmylib.a
4460
│ │
45-
│ ├── iOS-iphonesimulator
61+
│ ├── ios-iphoneos-mt-release
4662
│ │ ├── include
4763
│ │ │ └── ...
4864
│ │ └── lib
49-
│ │ └── mylib.a
65+
│ │ └── libmylib.a
66+
│ │
67+
│ ├── ios-iphonesimulator-mt-release
68+
│ │ ├── include
69+
│ │ │ └── ...
70+
│ │ └── lib
71+
│ │ └── libmylib.a
5072
│ │
51-
│ ├── mylib.xcframework.zip
5273
│ └── CMakeLists.txt
5374
|
5475
└── mylib.xcframework
5576
├── ios-arm64_arm64e
5677
│ ├── Headers
5778
│ │ └── ...
58-
│ └── mylib.a
79+
│ └── libmylib.a
5980
60-
├── ios-arm64_arm64e_x86_64-simulator
81+
├── ios-arm64_x86_64-simulator
6182
│ ├── Headers
6283
│ │ └── ...
63-
│ └── mylib.a
84+
│ └── libmylib.a
6485
6586
└── Info.plist
66-
6787
```
6888

69-
Here is a minimal example:
89+
Here is a minimal example that builds only the WebAssembly targets:
7090

7191
```json title="package.json"
7292
{
7393
"name": "cf-worker-example",
7494
"scripts": {
75-
"build": "cppjs build -p WebAssembly"
95+
"build": "cppjs build -p wasm"
7696
}
7797
}
7898
```
7999

100+
A more targeted invocation that limits the architecture, runtime, build type, and runtime environment:
101+
102+
```sh
103+
cppjs build -p wasm -a wasm32 -r st -b release -e browser,node
104+
```
105+
80106
:::info
81-
**Create library function:** You can access the create library function from [this link](https://github.com/bugra9/cpp.js/blob/main/packages/cpp.js/src/functions/createLib.js).
82-
**Create webassembly function:** You can access the create webassembly function from [this link](https://github.com/bugra9/cpp.js/blob/main/packages/cpp.js/src/functions/createWasm.js).
107+
**Create library function:** You can access the create library function from [this link](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cpp.js/src/actions/createLib.js).
108+
**Build WebAssembly function:** You can access the build WebAssembly function from [this link](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cpp.js/src/actions/buildWasm.js).
109+
**Create XCFramework function:** You can access the create XCFramework function from [this link](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cpp.js/src/actions/createXCFramework.js).
83110
:::

website/docs/api/cli/docker.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ CMake suite maintained and supported by Kitware (kitware.com/cmake).
3333

3434
:::info
3535
**Docker Image:** You can access the docker image from [this link](https://hub.docker.com/r/bugra9/cpp.js).
36-
**Dockerfile:** You can access the dockerfile from [this link](https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-core-docker/Dockerfile).
37-
**Run Function:** You can access the run function from [this link](https://github.com/bugra9/cpp.js/blob/main/packages/cpp.js/src/functions/run.js).
36+
**Dockerfile:** You can access the dockerfile from [this link](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cppjs-core-docker/Dockerfile).
37+
**Run Function:** You can access the run function from [this link](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cpp.js/src/actions/run.js).
3838
:::

website/docs/api/cli/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ Commands:
1818
<br />
1919

2020
:::info
21-
**Binary function:** You can access the binary function from [this link](https://github.com/bugra9/cpp.js/blob/main/packages/cpp.js/src/bin.js).
21+
**Binary function:** You can access the binary function from [this link](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cpp.js/src/bin.js).
2222
:::

website/docs/api/configuration/overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
};
1313
```
1414

15-
The configuration object consists of six sections. These are:
15+
The configuration object consists of the sections below. These are:
1616

1717
| Attribute | Description |
1818
| - | - |
@@ -21,10 +21,10 @@ The configuration object consists of six sections. These are:
2121
| paths | This object defines paths, such as the project path |
2222
| ext | This object specifies file extensions, including those for header files. |
2323
| export | This object includes configurations related to lib generation. |
24-
| platform | This object includes platform-specific configuration. |
24+
| targetSpecs | This array includes target-specific configuration filtered by platform/arch/runtime/buildType. |
2525

2626
<br />
2727

2828
:::tip
29-
You can find the JavaScript file that generates the configuration [here.](https://github.com/bugra9/cpp.js/blob/main/packages/cpp.js/src/utils/getConfig.js)
29+
You can find the JavaScript file that generates the configuration [here.](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cpp.js/src/state/loadConfig.js)
3030
:::
Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,45 @@
1-
# Platform
2-
This object includes platform-specific configuration.
1+
# Target Specs
2+
This array includes target-specific configuration. Each entry filters by any combination of `platform`, `arch`, `runtime`, `buildType`, and `runtimeEnv`, and applies its `specs` block to every build target that matches the filter. Omit a field to match all of its values.
33

44
Here is a minimal example:
55
```js
66
export default {
7-
platform: {
8-
'Emscripten-x86_64': {
9-
ignoreLibName: ['charset'],
10-
},
11-
'Android-arm64-v8a': {
12-
data: {
13-
'share/proj': 'proj',
7+
targetSpecs: [
8+
{
9+
platform: 'wasm',
10+
specs: {
11+
ignoreLibName: ['charset'],
1412
},
15-
env: {
16-
PROJ_LIB: '_CPPJS_DATA_PATH_/proj',
13+
},
14+
{
15+
platform: 'android',
16+
specs: {
17+
data: {
18+
'share/proj': 'proj',
19+
},
20+
env: {
21+
PROJ_LIB: '_CPPJS_DATA_PATH_/proj',
22+
},
1723
},
1824
},
19-
},
25+
],
2026
paths: {
2127
config: import.meta.url,
2228
},
2329
};
2430
```
2531

26-
### Attributes (Platforms)
32+
### Filter Fields
2733

28-
| Platforms |
29-
| ---- |
30-
| Emscripten-x86_64 |
31-
| Emscripten-x86_64-browser |
32-
| Emscripten-x86_64-node |
33-
| Android-arm64-v8a |
34-
| iOS-iphoneos |
35-
| iOS-iphonesimulator |
34+
| Field | Allowed values |
35+
| ----------- | -------------- |
36+
| platform | `wasm`, `android`, `ios` |
37+
| arch | `wasm32`, `wasm64`, `arm64-v8a`, `x86_64`, `iphoneos`, `iphonesimulator` |
38+
| runtime | `st`, `mt` |
39+
| buildType | `release`, `debug` |
40+
| runtimeEnv | `browser`, `edge`, `node` (only meaningful when `platform === 'wasm'`) |
3641

37-
### Sub-Attributes
42+
### Spec Sub-Attributes
3843

3944
| Name | Type | Description |
4045
| ---- | ---- | ----------- |
@@ -46,6 +51,6 @@ export default {
4651

4752
:::tip
4853
Below are examples demonstrating various uses of the configurations.
49-
- [**ignoreLibName:** ['charset']](https://www.npmjs.com/package/@cpp.js/package-iconv?activeTab=code)
50-
- [**data**, **env**](https://www.npmjs.com/package/@cpp.js/package-proj?activeTab=code)
54+
- [**ignoreLibName:** ['charset']](https://www.npmjs.com/package/@cpp.js/package-iconv-wasm?activeTab=code)
55+
- [**data**, **env**](https://www.npmjs.com/package/@cpp.js/package-proj-wasm?activeTab=code)
5156
:::

website/docs/api/cpp-bindings/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The table below outlines the headings discussed in this section.
1515
<br />
1616

1717
:::info
18-
[Embind](https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html) is utilized to bind C++ functions and classes to JavaScript. In WebAssembly, this functionality is provided by Emscripten. In React Native, the binding is achieved through the [@cpp.js/core-embind-jsi](https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-core-embind-jsi) project, which replaces WebAssembly bindings with JavaScript Interface (JSI).
18+
[Embind](https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html) is utilized to bind C++ functions and classes to JavaScript. In WebAssembly, this functionality is provided by Emscripten. In React Native, the binding is achieved through the [@cpp.js/core-embind-jsi](https://github.com/bugra9/cpp.js/tree/main/cppjs-core/cppjs-core-embind-jsi) project, which replaces WebAssembly bindings with JavaScript Interface (JSI).
1919

2020
The [bugra9/swig](https://github.com/bugra9/swig/tree/add-embind-support) project, a fork of the original [Swig](https://github.com/swig/swig) project adapted to support Embind, is used to create Embind definitions.
2121

website/docs/api/javascript/filesystem.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ files.forEach((fileInfo) => {
6565
<br />
6666

6767
:::info
68-
**Browser Functions:** You can access the browser functions from [this link](https://github.com/bugra9/cpp.js/blob/main/packages/cpp.js/src/assets/browser.js).
69-
**Node.js Functions:** You can access the Node.js functions from [this link](https://github.com/bugra9/cpp.js/blob/main/packages/cpp.js/src/assets/node.js).
68+
**Browser Functions:** You can access the browser functions from [this link](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cpp.js/src/assets/browser.js).
69+
**Node.js Functions:** You can access the Node.js functions from [this link](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cpp.js/src/assets/node.js).
7070
:::

website/docs/api/javascript/overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Cpp.js includes helper JavaScript functions to handle cross-platform differences
2626
<br />
2727

2828
:::info
29-
**Browser Functions:** You can access the browser functions from [this link](https://github.com/bugra9/cpp.js/blob/main/packages/cpp.js/src/assets/browser.js).
30-
**Node.js Functions:** You can access the Node.js functions from [this link](https://github.com/bugra9/cpp.js/blob/main/packages/cpp.js/src/assets/node.js).
31-
**React Native Functions:** You can access the React Native functions from [this link](https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-core-embind-jsi/js/embind.js).
29+
**Browser Functions:** You can access the browser functions from [this link](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cpp.js/src/assets/browser.js).
30+
**Node.js Functions:** You can access the Node.js functions from [this link](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cpp.js/src/assets/node.js).
31+
**React Native Functions:** You can access the React Native functions from [this link](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cppjs-core-embind-jsi/js/embind.js).
3232
:::

website/docs/api/javascript/utility-functions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const jsArray = Module.toArray(nativeArray);
1717
<br />
1818

1919
:::info
20-
**Browser Functions:** You can access the browser functions from [this link](https://github.com/bugra9/cpp.js/blob/main/packages/cpp.js/src/assets/browser.js).
21-
**Node.js Functions:** You can access the Node.js functions from [this link](https://github.com/bugra9/cpp.js/blob/main/packages/cpp.js/src/assets/node.js).
22-
**React Native Functions:** You can access the React Native functions from [this link](https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-core-embind-jsi/js/embind.js).
20+
**Browser Functions:** You can access the browser functions from [this link](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cpp.js/src/assets/browser.js).
21+
**Node.js Functions:** You can access the Node.js functions from [this link](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cpp.js/src/assets/node.js).
22+
**React Native Functions:** You can access the React Native functions from [this link](https://github.com/bugra9/cpp.js/blob/main/cppjs-core/cppjs-core-embind-jsi/js/embind.js).
2323
:::

0 commit comments

Comments
 (0)