peachsim 0.1.2610 → 0.1.2611
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-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +2 -2
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +5 -5
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +3 -3
- package/dist-lib/bundle-channel.cjs +10 -5
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +3 -3
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +3 -3
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +2 -2
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +7 -7
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +5 -5
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-L2SFCOHG.mjs → acorn-BKODFARF.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-WZHEW7Z7.mjs → chunk-3JA6XLP4.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-N3M5KT33.mjs → chunk-45CENTIY.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ZZB2LFYV.mjs → chunk-4C3LKD3A.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-73NIGS7D.mjs → chunk-4CJMDUKF.mjs} +14 -14
- package/dist-lib/esm-chunks/{chunk-YYGSN3BN.mjs → chunk-52XQJZ6O.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-42NDD4R7.mjs → chunk-7L5LUPZA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-YVLXYLNV.mjs → chunk-A6GNAMLP.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-MJP4WOSX.mjs → chunk-C4BW35N7.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-FP447MCW.mjs → chunk-CAFNSCPD.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-CUBTZPSZ.mjs → chunk-CWLKT7TD.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-MK4DOEDN.mjs → chunk-FWUDTM5Y.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-YLUD2UET.mjs → chunk-H2JPB73X.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-EU5WMP5O.mjs → chunk-HWMD7II5.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-KTAGV5U6.mjs → chunk-J6N5KKMZ.mjs} +6 -6
- package/dist-lib/esm-chunks/{chunk-EYSNLE5V.mjs → chunk-JWA5AIJM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-W3LNUIUA.mjs → chunk-KOT7HREP.mjs} +6 -6
- package/dist-lib/esm-chunks/{chunk-HMTSU22Q.mjs → chunk-LDV2MZFL.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-VDLPNJ6P.mjs → chunk-LNZNCA7M.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WBQFHIGS.mjs → chunk-NUISME6Y.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-N7XU2WWO.mjs → chunk-SFDNE5S2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-2LJTZ2KG.mjs → chunk-SKW2UNWS.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-XN74REO2.mjs → chunk-SNMPI3I2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-RN73P2DY.mjs → chunk-XSRZQWH5.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-X74N3K5N.mjs → chunk-YFSTB4CX.mjs} +4 -4
- package/dist-lib/esm-chunks/{metro-layout-parser-VDPXJ7LW.mjs → metro-layout-parser-BMN3E2RD.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-HRPDLN2P.mjs → swift-package-prebuilt-VMBB763C.mjs} +12 -12
- package/dist-lib/esm-chunks/{swift-sdk-app-module-5DOGMU3M.mjs → swift-sdk-app-module-SJ6OZAVA.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-W3UU4H4L.mjs → swift-sdk-image-U53EKCZW.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-OJWD6ZOH.mjs → swift-sdk-image-producer-TQQ33C3G.mjs} +5 -5
- package/dist-lib/expo-swift-bundle.cjs +10 -5
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +7 -7
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +10 -5
- package/dist-lib/host/fetch-proxy-handler.cjs +2 -2
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +3 -3
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +3 -3
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +4 -4
- package/dist-lib/native-app-identity-project.cjs +1 -1
- package/dist-lib/native-app-identity-project.mjs +15 -15
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +6 -6
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +3 -3
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +2 -2
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +3 -3
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +85 -85
- package/dist-lib/public-origins-lib.json +64 -64
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +2 -2
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +8 -8
- package/dist-lib/skills.cjs +10 -5
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +12 -12
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +3 -3
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +6 -6
- package/dist-lib/swift-svg-raster.cjs +1 -1
- package/dist-lib/swift-svg-raster.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
- package/dist-lib/vendor/acorn.cjs +1 -1
- package/dist-lib/vendor/magic-string.cjs +1 -1
- package/dist-lib/vendor/stream-json.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
- package/dist-lib/vendor/sucrase.cjs +1 -1
- package/dist-lib/vendor/terser.cjs +1 -1
- package/dist-lib/vendor/valibot.cjs +1 -1
- package/dist-lib/vendor/ws.cjs +1 -1
- package/dist-lib/vendor/zod.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +3 -3
- package/package.json +1 -1
- package/src/gitignore.ts +8 -3
- package/src/kotlin-library-sources.ts +320 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { spawn, type StdioOptions } from 'node:child_process'
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { isRecord } from './is-record'
|
|
5
|
+
import { kotlinToolCommand, runKotlinTool } from './kotlin-toolchain'
|
|
6
|
+
import type { KotlinToolchainInstallation } from './kotlinSdkContract'
|
|
7
|
+
|
|
8
|
+
function runCompiler(
|
|
9
|
+
file: string,
|
|
10
|
+
args: readonly string[],
|
|
11
|
+
options: { stdio: StdioOptions; env?: NodeJS.ProcessEnv },
|
|
12
|
+
operation: string,
|
|
13
|
+
): Promise<void> {
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
const child = spawn(file, args, options)
|
|
16
|
+
child.once('error', reject)
|
|
17
|
+
child.once('close', (code, signal) => {
|
|
18
|
+
if (code === 0) resolve()
|
|
19
|
+
else reject(new Error(operation + ' stopped with ' + (code ?? signal)))
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type KotlinLibrarySource =
|
|
25
|
+
| { kind: 'files'; java: readonly string[]; kotlin: readonly string[] }
|
|
26
|
+
| { kind: 'resources'; archive: string }
|
|
27
|
+
|
|
28
|
+
function kotlinFragmentFlags(
|
|
29
|
+
filename: string,
|
|
30
|
+
kotlinSources: readonly string[],
|
|
31
|
+
translatedSources: readonly string[],
|
|
32
|
+
): string[] {
|
|
33
|
+
const input: unknown = JSON.parse(fs.readFileSync(filename, 'utf8'))
|
|
34
|
+
if (!Array.isArray(input) || !input.length)
|
|
35
|
+
throw new Error('Kotlin fragments must be a nonempty array')
|
|
36
|
+
const fragments = input.map(
|
|
37
|
+
(
|
|
38
|
+
fragment: unknown,
|
|
39
|
+
): {
|
|
40
|
+
name: string
|
|
41
|
+
sources: string[]
|
|
42
|
+
refines: string[]
|
|
43
|
+
java: boolean
|
|
44
|
+
} => {
|
|
45
|
+
if (
|
|
46
|
+
!isRecord(fragment) ||
|
|
47
|
+
typeof fragment.name !== 'string' ||
|
|
48
|
+
!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(fragment.name) ||
|
|
49
|
+
!Array.isArray(fragment.sources) ||
|
|
50
|
+
!fragment.sources.every((source: unknown) => typeof source === 'string') ||
|
|
51
|
+
!Array.isArray(fragment.refines) ||
|
|
52
|
+
!fragment.refines.every((parent: unknown) => typeof parent === 'string') ||
|
|
53
|
+
(fragment.java !== undefined && typeof fragment.java !== 'boolean')
|
|
54
|
+
)
|
|
55
|
+
throw new Error(
|
|
56
|
+
'Each Kotlin fragment needs a name, source paths and refined fragments',
|
|
57
|
+
)
|
|
58
|
+
return {
|
|
59
|
+
name: fragment.name,
|
|
60
|
+
sources: fragment.sources.map((source: string) => path.resolve(source)),
|
|
61
|
+
refines: fragment.refines,
|
|
62
|
+
java: fragment.java === true,
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
)
|
|
66
|
+
const names = new Set(fragments.map(({ name }) => name))
|
|
67
|
+
const refined = new Set(fragments.flatMap(({ refines }) => refines))
|
|
68
|
+
const [platform, ...otherPlatforms] = [...names].filter((name) => !refined.has(name))
|
|
69
|
+
const javaFragments = fragments.filter(({ java }) => java)
|
|
70
|
+
if (
|
|
71
|
+
names.size !== fragments.length ||
|
|
72
|
+
[...refined].some((name) => !names.has(name)) ||
|
|
73
|
+
!platform ||
|
|
74
|
+
otherPlatforms.length ||
|
|
75
|
+
javaFragments.length > 1
|
|
76
|
+
)
|
|
77
|
+
throw new Error(
|
|
78
|
+
'Kotlin fragments need unique names, known parents, one platform fragment and at most one Java source fragment',
|
|
79
|
+
)
|
|
80
|
+
const sources = fragments.flatMap(({ sources }) => sources)
|
|
81
|
+
const selected = new Set(kotlinSources)
|
|
82
|
+
if (
|
|
83
|
+
sources.length !== selected.size ||
|
|
84
|
+
new Set(sources).size !== sources.length ||
|
|
85
|
+
sources.some((source) => !selected.has(source)) ||
|
|
86
|
+
[...sources, ...translatedSources].some((source) => source.includes(','))
|
|
87
|
+
)
|
|
88
|
+
throw new Error('Each Kotlin library source must belong to exactly one fragment')
|
|
89
|
+
const mappings = fragments.flatMap(({ name, sources }) =>
|
|
90
|
+
sources.map((source) => `${name}:${source}`),
|
|
91
|
+
)
|
|
92
|
+
const javaFragment = javaFragments[0]?.name ?? platform
|
|
93
|
+
mappings.push(...translatedSources.map((source) => `${javaFragment}:${source}`))
|
|
94
|
+
const edges = fragments.flatMap(({ name, refines }) =>
|
|
95
|
+
refines.map((parent) => `${name}:${parent}`),
|
|
96
|
+
)
|
|
97
|
+
return [
|
|
98
|
+
'-Xmulti-platform',
|
|
99
|
+
`-Xfragments=${[...names].join(',')}`,
|
|
100
|
+
...(edges.length ? [`-Xfragment-refines=${edges.join(',')}`] : []),
|
|
101
|
+
`-Xfragment-sources=${mappings.join(',')}`,
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function compileKotlinLibrarySources(input: {
|
|
106
|
+
ready: KotlinToolchainInstallation
|
|
107
|
+
sdkRoot: string
|
|
108
|
+
libraries: readonly string[]
|
|
109
|
+
source: KotlinLibrarySource
|
|
110
|
+
javaClasspath: readonly string[]
|
|
111
|
+
kotlinJvmAbi?: string
|
|
112
|
+
dependencyJvmAbi?: string
|
|
113
|
+
release: string
|
|
114
|
+
processorPath?: string
|
|
115
|
+
kotlinLanguage?: string
|
|
116
|
+
kotlinOptIns?: readonly string[]
|
|
117
|
+
commonSources?: readonly string[]
|
|
118
|
+
kotlinFragments?: string
|
|
119
|
+
dependencies: readonly string[]
|
|
120
|
+
output: string
|
|
121
|
+
}): Promise<void> {
|
|
122
|
+
const output = path.resolve(input.output)
|
|
123
|
+
const name = path.basename(output, '.klib')
|
|
124
|
+
if (
|
|
125
|
+
!name ||
|
|
126
|
+
!output.endsWith('.klib') ||
|
|
127
|
+
(input.source.kind === 'files' &&
|
|
128
|
+
!input.source.java.length &&
|
|
129
|
+
!input.source.kotlin.length)
|
|
130
|
+
)
|
|
131
|
+
throw new Error('Android library compilation requires sources and a KLIB output')
|
|
132
|
+
const { ready, sdkRoot, libraries } = input
|
|
133
|
+
const parent = path.dirname(output)
|
|
134
|
+
fs.mkdirSync(parent, { recursive: true })
|
|
135
|
+
const work = fs.mkdtempSync(path.join(parent, '.android-library-'))
|
|
136
|
+
try {
|
|
137
|
+
const compileLibraries = [...libraries, ...input.dependencies]
|
|
138
|
+
let javaSources: readonly string[]
|
|
139
|
+
if (input.source.kind === 'resources') {
|
|
140
|
+
const generated = path.join(work, 'resources')
|
|
141
|
+
await runKotlinTool(
|
|
142
|
+
ready,
|
|
143
|
+
sdkRoot,
|
|
144
|
+
'dev.peach.tools.platform.AndroidResourceClassesKt',
|
|
145
|
+
[path.resolve(input.source.archive), generated],
|
|
146
|
+
)
|
|
147
|
+
javaSources = fs
|
|
148
|
+
.readdirSync(generated, { recursive: true, encoding: 'utf8' })
|
|
149
|
+
.filter((file) => file.endsWith('.java'))
|
|
150
|
+
.sort()
|
|
151
|
+
.map((file) => path.join(generated, file))
|
|
152
|
+
} else {
|
|
153
|
+
javaSources = input.source.java
|
|
154
|
+
}
|
|
155
|
+
const kotlinSources =
|
|
156
|
+
input.source.kind === 'files'
|
|
157
|
+
? input.source.kotlin.map((file) => path.resolve(file))
|
|
158
|
+
: []
|
|
159
|
+
const commonSources = (input.commonSources ?? []).map((file) => path.resolve(file))
|
|
160
|
+
if (commonSources.length && input.kotlinFragments)
|
|
161
|
+
throw new Error('Choose common sources or a Kotlin fragment graph')
|
|
162
|
+
if (commonSources.some((file) => file.includes(',') || !kotlinSources.includes(file)))
|
|
163
|
+
throw new Error('Common Kotlin sources must be included in the library source list')
|
|
164
|
+
const kotlinJvmAbi = input.kotlinJvmAbi && path.resolve(input.kotlinJvmAbi)
|
|
165
|
+
if (
|
|
166
|
+
kotlinJvmAbi &&
|
|
167
|
+
(!javaSources.length ||
|
|
168
|
+
!kotlinSources.length ||
|
|
169
|
+
!kotlinJvmAbi.endsWith('.jar') ||
|
|
170
|
+
!input.javaClasspath.some((file) => path.resolve(file) === kotlinJvmAbi))
|
|
171
|
+
)
|
|
172
|
+
throw new Error(
|
|
173
|
+
'The Kotlin JVM ABI must be a JAR on the mixed library’s Java classpath',
|
|
174
|
+
)
|
|
175
|
+
const dependencyAbiFlags: string[] = []
|
|
176
|
+
if (input.dependencyJvmAbi) {
|
|
177
|
+
const dependencyPaths = new Set(
|
|
178
|
+
input.dependencies.map((file) => path.resolve(file)),
|
|
179
|
+
)
|
|
180
|
+
const classpathPaths = new Set(
|
|
181
|
+
input.javaClasspath.map((file) => path.resolve(file)),
|
|
182
|
+
)
|
|
183
|
+
const value: unknown = JSON.parse(fs.readFileSync(input.dependencyJvmAbi, 'utf8'))
|
|
184
|
+
if (!Array.isArray(value) || !value.length || !javaSources.length)
|
|
185
|
+
throw new Error(
|
|
186
|
+
'Dependency JVM ABIs require Java sources and a nonempty array of KLIB/JAR pairs',
|
|
187
|
+
)
|
|
188
|
+
for (const pair of value) {
|
|
189
|
+
if (
|
|
190
|
+
!isRecord(pair) ||
|
|
191
|
+
typeof pair.klib !== 'string' ||
|
|
192
|
+
typeof pair.jar !== 'string'
|
|
193
|
+
)
|
|
194
|
+
throw new Error('Each dependency JVM ABI requires a klib and a jar path')
|
|
195
|
+
const klib = path.resolve(pair.klib)
|
|
196
|
+
const jar = path.resolve(pair.jar)
|
|
197
|
+
if (
|
|
198
|
+
!klib.endsWith('.klib') ||
|
|
199
|
+
!dependencyPaths.has(klib) ||
|
|
200
|
+
!jar.endsWith('.jar') ||
|
|
201
|
+
!classpathPaths.has(jar) ||
|
|
202
|
+
jar === kotlinJvmAbi
|
|
203
|
+
)
|
|
204
|
+
throw new Error(
|
|
205
|
+
'Dependency JVM ABI pairs must refer to a dependency KLIB and its Java classpath JAR',
|
|
206
|
+
)
|
|
207
|
+
dependencyAbiFlags.push('--dependency-jvm-abi', klib, jar)
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
let translatedSources: string[] = []
|
|
211
|
+
if (javaSources.length) {
|
|
212
|
+
const platform = path.join(work, 'platform.txt')
|
|
213
|
+
const members = kotlinToolCommand(
|
|
214
|
+
ready,
|
|
215
|
+
sdkRoot,
|
|
216
|
+
'dev.peach.tools.platform.KlibClassesKt',
|
|
217
|
+
[
|
|
218
|
+
...compileLibraries.map((file) => path.resolve(file)),
|
|
219
|
+
...(kotlinJvmAbi ? ['--same-library-jvm-abi', kotlinJvmAbi] : []),
|
|
220
|
+
...dependencyAbiFlags,
|
|
221
|
+
],
|
|
222
|
+
)
|
|
223
|
+
const fd = fs.openSync(platform, 'w')
|
|
224
|
+
try {
|
|
225
|
+
await runCompiler(
|
|
226
|
+
members.file,
|
|
227
|
+
members.args,
|
|
228
|
+
{ stdio: ['ignore', fd, 'inherit'] },
|
|
229
|
+
'Android library ' + name + ' metadata read',
|
|
230
|
+
)
|
|
231
|
+
} finally {
|
|
232
|
+
fs.closeSync(fd)
|
|
233
|
+
}
|
|
234
|
+
const sourceList = path.join(work, 'sources.txt')
|
|
235
|
+
fs.writeFileSync(
|
|
236
|
+
sourceList,
|
|
237
|
+
javaSources.map((file) => path.resolve(file)).join('\n'),
|
|
238
|
+
)
|
|
239
|
+
const translated = path.join(work, 'translated')
|
|
240
|
+
const diagnostics = await runKotlinTool(
|
|
241
|
+
ready,
|
|
242
|
+
sdkRoot,
|
|
243
|
+
'dev.peach.tools.java.JavaTranslatorKt',
|
|
244
|
+
[
|
|
245
|
+
'--target',
|
|
246
|
+
'wasm',
|
|
247
|
+
'--release',
|
|
248
|
+
input.release,
|
|
249
|
+
'--classpath',
|
|
250
|
+
input.javaClasspath.map((file) => path.resolve(file)).join(path.delimiter),
|
|
251
|
+
'--platform',
|
|
252
|
+
platform,
|
|
253
|
+
...(input.processorPath ? ['--processorpath', input.processorPath] : []),
|
|
254
|
+
'--out',
|
|
255
|
+
translated,
|
|
256
|
+
`@${sourceList}`,
|
|
257
|
+
],
|
|
258
|
+
)
|
|
259
|
+
if (/^refuses /m.test(diagnostics))
|
|
260
|
+
throw new Error(
|
|
261
|
+
`Android library ${name} requires unsupported platform members:\n${diagnostics.trimEnd()}`,
|
|
262
|
+
)
|
|
263
|
+
translatedSources = input.kotlinFragments
|
|
264
|
+
? fs
|
|
265
|
+
.readdirSync(translated, { recursive: true, encoding: 'utf8' })
|
|
266
|
+
.filter((file) => file.endsWith('.kt'))
|
|
267
|
+
.sort()
|
|
268
|
+
.map((file) => path.join(translated, file))
|
|
269
|
+
: [translated]
|
|
270
|
+
}
|
|
271
|
+
const multiplatform = input.kotlinFragments
|
|
272
|
+
? kotlinFragmentFlags(input.kotlinFragments, kotlinSources, translatedSources)
|
|
273
|
+
: commonSources.length
|
|
274
|
+
? ['-Xmulti-platform', `-Xcommon-sources=${commonSources.join(',')}`]
|
|
275
|
+
: []
|
|
276
|
+
const language = input.kotlinLanguage ?? '2.1'
|
|
277
|
+
const raw = path.join(work, 'raw')
|
|
278
|
+
await runCompiler(
|
|
279
|
+
ready.kotlinc,
|
|
280
|
+
[
|
|
281
|
+
'-J-Xmx4g',
|
|
282
|
+
'-Xwasm-target=js',
|
|
283
|
+
'-nowarn',
|
|
284
|
+
`-Xplugin=${path.join(sdkRoot, 'plugin.jar')}`,
|
|
285
|
+
'-P',
|
|
286
|
+
'plugin:dev.peach.jni:android=true',
|
|
287
|
+
'-language-version',
|
|
288
|
+
language,
|
|
289
|
+
'-api-version',
|
|
290
|
+
language,
|
|
291
|
+
...(input.kotlinOptIns ?? []).map((marker) => `-opt-in=${marker}`),
|
|
292
|
+
...multiplatform,
|
|
293
|
+
'-libraries',
|
|
294
|
+
compileLibraries.join(path.delimiter),
|
|
295
|
+
'-ir-output-dir',
|
|
296
|
+
raw,
|
|
297
|
+
'-ir-output-name',
|
|
298
|
+
name,
|
|
299
|
+
...kotlinSources,
|
|
300
|
+
...translatedSources,
|
|
301
|
+
],
|
|
302
|
+
{ stdio: 'inherit', env: { ...process.env, JAVA_HOME: ready.javaHome } },
|
|
303
|
+
'Android library ' + name + ' compilation',
|
|
304
|
+
)
|
|
305
|
+
const compiled = path.join(raw, `${name}.klib`)
|
|
306
|
+
if (!javaSources.length) {
|
|
307
|
+
fs.renameSync(compiled, output)
|
|
308
|
+
return
|
|
309
|
+
}
|
|
310
|
+
const normalized = path.join(work, 'normalized.klib')
|
|
311
|
+
await runKotlinTool(ready, sdkRoot, 'dev.peach.tools.platform.JavaPlatformTypesKt', [
|
|
312
|
+
compiled,
|
|
313
|
+
normalized,
|
|
314
|
+
'--java-classes',
|
|
315
|
+
])
|
|
316
|
+
fs.renameSync(normalized, output)
|
|
317
|
+
} finally {
|
|
318
|
+
fs.rmSync(work, { recursive: true, force: true })
|
|
319
|
+
}
|
|
320
|
+
}
|