@napi-rs/cli 3.0.0-alpha.97 → 3.0.0-alpha.99
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/dist/cli.js +28 -16
- package/dist/index.cjs +28 -16
- package/dist/index.js +28 -16
- package/dist/utils/target.d.ts +2 -2
- package/package.json +2 -2
- package/src/api/build.ts +1 -1
- package/src/api/templates/js-binding.ts +11 -10
- package/src/utils/__tests__/__snapshots__/target.spec.ts.md +21 -0
- package/src/utils/__tests__/__snapshots__/target.spec.ts.snap +0 -0
- package/src/utils/target.ts +15 -1
package/dist/utils/target.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export type Platform = NodeJS.Platform | 'wasm' | 'wasi' | '
|
|
1
|
+
export type Platform = NodeJS.Platform | 'wasm' | 'wasi' | 'openharmony';
|
|
2
2
|
export declare const UNIVERSAL_TARGETS: {
|
|
3
3
|
readonly 'universal-apple-darwin': readonly ["aarch64-apple-darwin", "x86_64-apple-darwin"];
|
|
4
4
|
};
|
|
5
|
-
export declare const AVAILABLE_TARGETS: readonly ["aarch64-apple-darwin", "aarch64-linux-android", "aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl", "aarch64-pc-windows-msvc", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-freebsd", "i686-pc-windows-msvc", "armv7-unknown-linux-gnueabihf", "armv7-unknown-linux-musleabihf", "armv7-linux-androideabi", "universal-apple-darwin", "riscv64gc-unknown-linux-gnu", "powerpc64le-unknown-linux-gnu", "s390x-unknown-linux-gnu", "wasm32-wasi-preview1-threads"];
|
|
5
|
+
export declare const AVAILABLE_TARGETS: readonly ["aarch64-apple-darwin", "aarch64-linux-android", "aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl", "aarch64-unknown-linux-ohos", "aarch64-pc-windows-msvc", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-linux-ohos", "x86_64-unknown-freebsd", "i686-pc-windows-msvc", "armv7-unknown-linux-gnueabihf", "armv7-unknown-linux-musleabihf", "armv7-linux-androideabi", "universal-apple-darwin", "riscv64gc-unknown-linux-gnu", "powerpc64le-unknown-linux-gnu", "s390x-unknown-linux-gnu", "wasm32-wasi-preview1-threads", "wasm32-wasip1-threads"];
|
|
6
6
|
export type TargetTriple = (typeof AVAILABLE_TARGETS)[number];
|
|
7
7
|
export declare const DEFAULT_TARGETS: readonly ["x86_64-apple-darwin", "aarch64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu"];
|
|
8
8
|
export declare const TARGET_LINKER: Record<string, string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@napi-rs/cli",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.99",
|
|
4
4
|
"description": "Cli tools for napi-rs",
|
|
5
5
|
"author": "LongYinan <lynweklm@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/napi-rs/napi-rs",
|
|
@@ -132,5 +132,5 @@
|
|
|
132
132
|
"e2e/**/*.spec.ts"
|
|
133
133
|
]
|
|
134
134
|
},
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "5ae583f73b48eaf1b4eb15f399a9079b502e1b69"
|
|
136
136
|
}
|
package/src/api/build.ts
CHANGED
|
@@ -50,8 +50,7 @@ ${identLow}try {
|
|
|
50
50
|
${ident}return require('${pkgName}-${tuple}')
|
|
51
51
|
${identLow}} catch (e) {
|
|
52
52
|
${ident}loadErrors.push(e)
|
|
53
|
-
${identLow}}
|
|
54
|
-
`
|
|
53
|
+
${identLow}}`
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
return `const { readFileSync } = require('node:fs')
|
|
@@ -72,8 +71,6 @@ const isMusl = () => {
|
|
|
72
71
|
return musl
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
const isOpenHarmony = process.platform === 'openharmony'
|
|
76
|
-
|
|
77
74
|
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
78
75
|
|
|
79
76
|
const isMuslFromFilesystem = () => {
|
|
@@ -159,24 +156,18 @@ function requireNative() {
|
|
|
159
156
|
if (process.arch === 'x64') {
|
|
160
157
|
if (isMusl()) {
|
|
161
158
|
${requireTuple('linux-x64-musl', 10)}
|
|
162
|
-
} else if (isOpenHarmony) {
|
|
163
|
-
${requireTuple('linux-x64-ohos', 10)}
|
|
164
159
|
} else {
|
|
165
160
|
${requireTuple('linux-x64-gnu', 10)}
|
|
166
161
|
}
|
|
167
162
|
} else if (process.arch === 'arm64') {
|
|
168
163
|
if (isMusl()) {
|
|
169
164
|
${requireTuple('linux-arm64-musl', 10)}
|
|
170
|
-
} else if (isOpenHarmony) {
|
|
171
|
-
${requireTuple('linux-arm64-ohos', 10)}
|
|
172
165
|
} else {
|
|
173
166
|
${requireTuple('linux-arm64-gnu', 10)}
|
|
174
167
|
}
|
|
175
168
|
} else if (process.arch === 'arm') {
|
|
176
169
|
if (isMusl()) {
|
|
177
170
|
${requireTuple('linux-arm-musleabihf', 10)}
|
|
178
|
-
} else if (isOpenHarmony) {
|
|
179
|
-
${requireTuple('linux-arm-ohos', 10)}
|
|
180
171
|
} else {
|
|
181
172
|
${requireTuple('linux-arm-gnueabihf', 10)}
|
|
182
173
|
}
|
|
@@ -193,6 +184,16 @@ function requireNative() {
|
|
|
193
184
|
} else {
|
|
194
185
|
loadErrors.push(new Error(\`Unsupported architecture on Linux: \${process.arch}\`))
|
|
195
186
|
}
|
|
187
|
+
} else if (process.platform === 'openharmony') {
|
|
188
|
+
if (process.arch === 'arm64') {
|
|
189
|
+
${requireTuple('linux-arm64-ohos')}
|
|
190
|
+
} else if (process.arch === 'x64') {
|
|
191
|
+
${requireTuple('linux-x64-ohos')}
|
|
192
|
+
} else if (process.arch === 'arm') {
|
|
193
|
+
${requireTuple('linux-arm-ohos')}
|
|
194
|
+
} else {
|
|
195
|
+
loadErrors.push(new Error(\`Unsupported architecture on OpenHarmony: \${process.arch}\`))
|
|
196
|
+
}
|
|
196
197
|
} else {
|
|
197
198
|
loadErrors.push(new Error(\`Unsupported OS: \${process.platform}, architecture: \${process.arch}\`))
|
|
198
199
|
}
|
|
@@ -37,6 +37,13 @@ Generated by [AVA](https://avajs.dev).
|
|
|
37
37
|
platformArchABI: 'linux-arm64-musl',
|
|
38
38
|
triple: 'aarch64-unknown-linux-musl',
|
|
39
39
|
},
|
|
40
|
+
{
|
|
41
|
+
abi: null,
|
|
42
|
+
arch: 'arm64',
|
|
43
|
+
platform: 'openharmony',
|
|
44
|
+
platformArchABI: 'linux-arm64-ohos',
|
|
45
|
+
triple: 'aarch64-unknown-linux-ohos',
|
|
46
|
+
},
|
|
40
47
|
{
|
|
41
48
|
abi: 'msvc',
|
|
42
49
|
arch: 'arm64',
|
|
@@ -72,6 +79,13 @@ Generated by [AVA](https://avajs.dev).
|
|
|
72
79
|
platformArchABI: 'linux-x64-musl',
|
|
73
80
|
triple: 'x86_64-unknown-linux-musl',
|
|
74
81
|
},
|
|
82
|
+
{
|
|
83
|
+
abi: null,
|
|
84
|
+
arch: 'x64',
|
|
85
|
+
platform: 'openharmony',
|
|
86
|
+
platformArchABI: 'linux-x64-ohos',
|
|
87
|
+
triple: 'x86_64-unknown-linux-ohos',
|
|
88
|
+
},
|
|
75
89
|
{
|
|
76
90
|
abi: null,
|
|
77
91
|
arch: 'x64',
|
|
@@ -142,4 +156,11 @@ Generated by [AVA](https://avajs.dev).
|
|
|
142
156
|
platformArchABI: 'wasm32-wasi',
|
|
143
157
|
triple: 'wasm32-wasi-preview1-threads',
|
|
144
158
|
},
|
|
159
|
+
{
|
|
160
|
+
abi: 'wasi',
|
|
161
|
+
arch: 'wasm32',
|
|
162
|
+
platform: 'wasi',
|
|
163
|
+
platformArchABI: 'wasm32-wasi',
|
|
164
|
+
triple: 'wasm32-wasip1-threads',
|
|
165
|
+
},
|
|
145
166
|
]
|
|
Binary file
|
package/src/utils/target.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process'
|
|
2
2
|
|
|
3
|
-
export type Platform = NodeJS.Platform | 'wasm' | 'wasi' | '
|
|
3
|
+
export type Platform = NodeJS.Platform | 'wasm' | 'wasi' | 'openharmony'
|
|
4
4
|
|
|
5
5
|
export const UNIVERSAL_TARGETS = {
|
|
6
6
|
'universal-apple-darwin': ['aarch64-apple-darwin', 'x86_64-apple-darwin'],
|
|
@@ -11,11 +11,13 @@ export const AVAILABLE_TARGETS = [
|
|
|
11
11
|
'aarch64-linux-android',
|
|
12
12
|
'aarch64-unknown-linux-gnu',
|
|
13
13
|
'aarch64-unknown-linux-musl',
|
|
14
|
+
'aarch64-unknown-linux-ohos',
|
|
14
15
|
'aarch64-pc-windows-msvc',
|
|
15
16
|
'x86_64-apple-darwin',
|
|
16
17
|
'x86_64-pc-windows-msvc',
|
|
17
18
|
'x86_64-unknown-linux-gnu',
|
|
18
19
|
'x86_64-unknown-linux-musl',
|
|
20
|
+
'x86_64-unknown-linux-ohos',
|
|
19
21
|
'x86_64-unknown-freebsd',
|
|
20
22
|
'i686-pc-windows-msvc',
|
|
21
23
|
'armv7-unknown-linux-gnueabihf',
|
|
@@ -26,6 +28,7 @@ export const AVAILABLE_TARGETS = [
|
|
|
26
28
|
'powerpc64le-unknown-linux-gnu',
|
|
27
29
|
's390x-unknown-linux-gnu',
|
|
28
30
|
'wasm32-wasi-preview1-threads',
|
|
31
|
+
'wasm32-wasip1-threads',
|
|
29
32
|
] as const
|
|
30
33
|
|
|
31
34
|
export type TargetTriple = (typeof AVAILABLE_TARGETS)[number]
|
|
@@ -84,6 +87,7 @@ const SysToNodePlatform: Record<string, Platform> = {
|
|
|
84
87
|
freebsd: 'freebsd',
|
|
85
88
|
darwin: 'darwin',
|
|
86
89
|
windows: 'win32',
|
|
90
|
+
ohos: 'openharmony',
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
export const UniArchsByPlatform: Partial<Record<Platform, NodeJSArch[]>> = {
|
|
@@ -143,6 +147,16 @@ export function parseTriple(rawTriple: string): Target {
|
|
|
143
147
|
|
|
144
148
|
const platform = SysToNodePlatform[sys] ?? (sys as Platform)
|
|
145
149
|
const arch = CpuToNodeArch[cpu] ?? (cpu as NodeJSArch)
|
|
150
|
+
|
|
151
|
+
if (rawTriple.includes('ohos')) {
|
|
152
|
+
return {
|
|
153
|
+
triple: rawTriple,
|
|
154
|
+
platformArchABI: `linux-${arch}-ohos`,
|
|
155
|
+
platform: 'openharmony',
|
|
156
|
+
arch,
|
|
157
|
+
abi: null,
|
|
158
|
+
}
|
|
159
|
+
}
|
|
146
160
|
return {
|
|
147
161
|
triple: rawTriple,
|
|
148
162
|
platformArchABI: abi ? `${platform}-${arch}-${abi}` : `${platform}-${arch}`,
|