peachsim 0.1.1815 → 0.1.1817
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/cli/commands/package.ts +82 -31
- package/cli/outbound-endpoints.ts +1 -1
- package/cli/packaged-app-launcher.ts +6 -1
- 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 +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +4418 -5235
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +12 -3
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +3932 -4526
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +3289 -4175
- package/dist-lib/host/fetch-proxy-handler.cjs +12 -3
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +13 -24
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +13 -24
- package/dist-lib/native-app-identity-project.cjs +2 -22
- package/dist-lib/native-app-identity-project.mjs +2 -22
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +24 -24
- package/dist-lib/public-origins-lib.json +74 -66
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- 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 +1 -1
- package/dist-lib/skills.cjs +3793 -4671
- package/dist-lib/swift-compile.cjs +216 -242
- package/dist-lib/swift-compile.mjs +216 -242
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +251 -236
- package/dist-lib/vite.cjs +12 -3
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/package.json +1 -1
- package/src/answeredNativePackages.ts +41 -0
- package/src/cli-runtime.ts +2 -9
- package/src/expo-discovery-cache.ts +2 -0
- package/src/expo-kotlin-host.ts +11 -9
- package/src/expo-swift-host.ts +10 -6
- package/src/nitro-bundle.ts +8 -6
- package/src/nitro-compiler-digest.ts +2 -4
- package/src/nitro-superset.lock.json +19 -251
- package/src/nitro-superset.ts +59 -63
- package/src/react-native-bridge-modules.ts +2 -4
- package/src/swift-compile.ts +258 -254
- package/src/swift-objc-standin.ts +10 -6
- package/src/swift-standins.ts +36 -12
- package/src/turbo-source.ts +2 -3
package/src/swift-compile.ts
CHANGED
|
@@ -6351,284 +6351,288 @@ export function compileSwiftProjectUnit(
|
|
|
6351
6351
|
`swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`,
|
|
6352
6352
|
)
|
|
6353
6353
|
}
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6354
|
+
// a distribution is immutable and builds no framework products, so app
|
|
6355
|
+
// roots compiling against it overlap and only its plugin check queues.
|
|
6356
|
+
const frameworkScratch = swiftFrameworkScratch(frameworkKey)
|
|
6357
|
+
const withFrameworkLock = <T>(
|
|
6358
|
+
work: (frameworkLease?: SwiftRootLease) => Promise<T>,
|
|
6359
|
+
) =>
|
|
6360
|
+
distribution
|
|
6361
|
+
? work()
|
|
6362
|
+
: withSwiftRootLock(frameworkScratch, work, options.signal)
|
|
6363
|
+
return withFrameworkLock(async (frameworkLease) => {
|
|
6364
|
+
const frameworkRoot = stageFrameworkSource(moduleRoot, frameworkKey)
|
|
6365
|
+
report('preparing compiler plugins')
|
|
6366
|
+
const pluginsFor = (pluginLease?: SwiftRootLease) =>
|
|
6367
|
+
ensureMacroPlugins(
|
|
6360
6368
|
frameworkRoot,
|
|
6361
6369
|
options.toolchainBin,
|
|
6362
6370
|
options.release,
|
|
6363
6371
|
options.signal,
|
|
6364
|
-
|
|
6372
|
+
pluginLease,
|
|
6365
6373
|
)
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
toolchainBin: options.toolchainBin,
|
|
6403
|
-
plugins: macroPlugins,
|
|
6404
|
-
buildOptions,
|
|
6405
|
-
})
|
|
6406
|
-
await pruneFrameworkScratches(frameworkKey)
|
|
6407
|
-
}
|
|
6408
|
-
if (options.project) removeProjectLinks(root)
|
|
6409
|
-
if (
|
|
6410
|
-
retireStaleSwiftLink(
|
|
6411
|
-
root,
|
|
6412
|
-
swiftLinkStamp({
|
|
6413
|
-
frameworkKey,
|
|
6414
|
-
prebuilt,
|
|
6415
|
-
}),
|
|
6416
|
-
)
|
|
6417
|
-
)
|
|
6418
|
-
report('framework revision changed; rebuilding the app link')
|
|
6419
|
-
const preparation = writeSwiftProject(
|
|
6420
|
-
layout,
|
|
6374
|
+
const macroPlugins = distribution
|
|
6375
|
+
? await withSwiftRootLock(frameworkScratch, pluginsFor, options.signal)
|
|
6376
|
+
: await pluginsFor(frameworkLease)
|
|
6377
|
+
// memoized per toolchain, so only a process's first build waits on it,
|
|
6378
|
+
// and that one reads and gzips it while swift builds
|
|
6379
|
+
const sdk = swiftModuleSdk(frameworkRoot).wasmSdkId
|
|
6380
|
+
const icu = swiftIcuAsset(options.toolchainBin, sdk)
|
|
6381
|
+
const buildOptions = {
|
|
6382
|
+
env: {
|
|
6383
|
+
...(options.project?.env ?? process.env),
|
|
6384
|
+
// shipped host plugins resolve against the selected compiler's runtime.
|
|
6385
|
+
...(process.platform === 'linux'
|
|
6386
|
+
? {
|
|
6387
|
+
LD_LIBRARY_PATH: [
|
|
6388
|
+
path.resolve(options.toolchainBin, '../lib/swift/linux'),
|
|
6389
|
+
path.resolve(options.toolchainBin, '../lib/swift/host'),
|
|
6390
|
+
process.env.LD_LIBRARY_PATH,
|
|
6391
|
+
]
|
|
6392
|
+
.filter(Boolean)
|
|
6393
|
+
.join(':'),
|
|
6394
|
+
}
|
|
6395
|
+
: {}),
|
|
6396
|
+
...(input.lazyDistribution ? { PEACH_DEFER_WASM_LINK: '1' } : {}),
|
|
6397
|
+
},
|
|
6398
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
6399
|
+
timeout: options.timeoutMs,
|
|
6400
|
+
signal: options.signal,
|
|
6401
|
+
lease,
|
|
6402
|
+
frameworkLease,
|
|
6403
|
+
}
|
|
6404
|
+
let prebuilt: SwiftFrameworkProducts | undefined
|
|
6405
|
+
if (!distribution) {
|
|
6406
|
+
report('compiling framework products')
|
|
6407
|
+
prebuilt = await compileFrameworkProducts({
|
|
6408
|
+
moduleRoot: frameworkRoot,
|
|
6409
|
+
frameworkKey,
|
|
6421
6410
|
input,
|
|
6422
|
-
|
|
6423
|
-
|
|
6411
|
+
swift,
|
|
6412
|
+
sdk,
|
|
6413
|
+
toolchainBin: options.toolchainBin,
|
|
6414
|
+
plugins: macroPlugins,
|
|
6415
|
+
buildOptions,
|
|
6416
|
+
})
|
|
6417
|
+
await pruneFrameworkScratches(frameworkKey)
|
|
6418
|
+
}
|
|
6419
|
+
if (options.project) removeProjectLinks(root)
|
|
6420
|
+
if (
|
|
6421
|
+
retireStaleSwiftLink(
|
|
6422
|
+
root,
|
|
6423
|
+
swiftLinkStamp({
|
|
6424
|
+
frameworkKey,
|
|
6425
|
+
prebuilt,
|
|
6426
|
+
}),
|
|
6424
6427
|
)
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6428
|
+
)
|
|
6429
|
+
report('framework revision changed; rebuilding the app link')
|
|
6430
|
+
const preparation = writeSwiftProject(layout, input, frameworkRoot, prebuilt)
|
|
6431
|
+
writeSwiftAutolinkLinker(root, options.toolchainBin)
|
|
6432
|
+
const projectProcess = options.project
|
|
6433
|
+
? prepareSwiftProjectProcess(root, options.project)
|
|
6434
|
+
: undefined
|
|
6435
|
+
const appOptions = projectProcess
|
|
6436
|
+
? {
|
|
6437
|
+
...buildOptions,
|
|
6438
|
+
uid: projectProcess.uid,
|
|
6439
|
+
gid: projectProcess.gid,
|
|
6440
|
+
confined: projectProcess.env,
|
|
6441
|
+
}
|
|
6442
|
+
: buildOptions
|
|
6443
|
+
const unprepared = preparation.targetFailures.map(
|
|
6444
|
+
(failure) => `error: target ${failure}`,
|
|
6445
|
+
)
|
|
6446
|
+
// a forwarder header (`#include "../../x.hpp"`) reaches its target
|
|
6447
|
+
// through `..`, which clang keeps in __FILE__, while the header
|
|
6448
|
+
// alias overlay names the same file directly. mapping each
|
|
6449
|
+
// forwarder spelling to the directory it reaches makes a debug
|
|
6450
|
+
// assert expand alike in every module that includes the header.
|
|
6451
|
+
const forwarders = new Map<string, string>()
|
|
6452
|
+
for (const [file, text] of Object.entries(input.files)) {
|
|
6453
|
+
const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text)?.[1]
|
|
6454
|
+
if (!parents) continue
|
|
6455
|
+
const directory = path.posix.dirname(file)
|
|
6456
|
+
forwarders.set(
|
|
6457
|
+
`${path.join(root, directory)}/${parents.slice(0, -1)}`,
|
|
6458
|
+
path.posix.join('build', directory, parents).replace(/\/$/, ''),
|
|
6439
6459
|
)
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6460
|
+
}
|
|
6461
|
+
const buildArgs = [
|
|
6462
|
+
'build',
|
|
6463
|
+
...(projectProcess?.cacheOptions ?? swiftPackageCacheOptions()),
|
|
6464
|
+
'--build-system',
|
|
6465
|
+
'native',
|
|
6466
|
+
'-j',
|
|
6467
|
+
BUILD_JOBS,
|
|
6468
|
+
'--package-path',
|
|
6469
|
+
root,
|
|
6470
|
+
...swiftCompileSdkOptions(frameworkRoot, options.toolchainBin),
|
|
6471
|
+
'--swift-sdk',
|
|
6472
|
+
sdk,
|
|
6473
|
+
...(input.packageFiles || prebuilt
|
|
6474
|
+
? ['--toolset', path.join(root, '.peach-target-toolset.json')]
|
|
6475
|
+
: []),
|
|
6476
|
+
'-c',
|
|
6477
|
+
'release',
|
|
6478
|
+
'-Xswiftc',
|
|
6479
|
+
'-num-threads',
|
|
6480
|
+
'-Xswiftc',
|
|
6481
|
+
BUILD_JOBS,
|
|
6482
|
+
...swiftReproducibleBuildFlags([
|
|
6483
|
+
[path.dirname(options.toolchainBin), 'toolchain'],
|
|
6484
|
+
[frameworkRoot, 'framework'],
|
|
6485
|
+
[root, 'build'],
|
|
6486
|
+
...forwarders,
|
|
6487
|
+
]),
|
|
6488
|
+
...macroPlugins.libraries.flatMap((plugin) => [
|
|
6489
|
+
'-Xswiftc',
|
|
6490
|
+
'-load-plugin-library',
|
|
6491
|
+
'-Xswiftc',
|
|
6492
|
+
plugin,
|
|
6493
|
+
]),
|
|
6494
|
+
...macroPlugins.executables.flatMap((plugin) => [
|
|
6495
|
+
'-Xswiftc',
|
|
6496
|
+
'-load-plugin-executable',
|
|
6497
|
+
'-Xswiftc',
|
|
6498
|
+
`${plugin}#ExpoModulesMacros`,
|
|
6499
|
+
]),
|
|
6500
|
+
]
|
|
6501
|
+
const linked = builtArtifact(layout)
|
|
6502
|
+
if (input.lazyDistribution) {
|
|
6503
|
+
rmSync(path.join(root, '.peach-link.rsp'), { force: true })
|
|
6504
|
+
if (existsSync(linked) && statSync(linked).size <= 8)
|
|
6505
|
+
rmSync(linked, { force: true })
|
|
6506
|
+
}
|
|
6507
|
+
report('compiling and linking Swift modules')
|
|
6508
|
+
try {
|
|
6509
|
+
// clang consumes the real emitted headers after swift finishes.
|
|
6510
|
+
// swiftpm's transitive swift module maps are not C declarations:
|
|
6511
|
+
// importing them would shadow SDK modules such as ObjectiveC.
|
|
6512
|
+
const headerBuilds = preparation.headerProductTarget
|
|
6513
|
+
? [
|
|
6514
|
+
...Object.keys(preparation.nativeHeaderDeclarations),
|
|
6515
|
+
preparation.headerProductTarget,
|
|
6516
|
+
]
|
|
6517
|
+
: preparation.headerProducers
|
|
6518
|
+
for (const build of headerBuilds) {
|
|
6519
|
+
await runCompiler(
|
|
6520
|
+
swift,
|
|
6521
|
+
[...buildArgs, '--target', build],
|
|
6522
|
+
appOptions,
|
|
6523
|
+
SWIFTPM_PROGRESS,
|
|
6524
|
+
SWIFTPM_NOISE,
|
|
6453
6525
|
)
|
|
6526
|
+
for (const producer of build === preparation.headerProductTarget
|
|
6527
|
+
? preparation.headerProducers
|
|
6528
|
+
: [build]) {
|
|
6529
|
+
const emitted = path.join(
|
|
6530
|
+
root,
|
|
6531
|
+
'.build',
|
|
6532
|
+
'peach-cxx-headers',
|
|
6533
|
+
`${producer}-Swift.h`,
|
|
6534
|
+
)
|
|
6535
|
+
const original = preparation.nativeHeaderDeclarations[producer]
|
|
6536
|
+
? emitted.replace(/-Swift\.h$/, '-Swift.original.h')
|
|
6537
|
+
: emitted
|
|
6538
|
+
if (existsSync(original))
|
|
6539
|
+
writeBuildFile(
|
|
6540
|
+
emitted,
|
|
6541
|
+
withoutSwiftDeclarations(
|
|
6542
|
+
clangInterfaceHeader(readFileSync(original, 'utf8')),
|
|
6543
|
+
new Set(preparation.nativeHeaderDeclarations[producer]),
|
|
6544
|
+
`#import <${producer}/${producer}.h>`,
|
|
6545
|
+
),
|
|
6546
|
+
)
|
|
6547
|
+
}
|
|
6454
6548
|
}
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6549
|
+
await runCompiler(
|
|
6550
|
+
swift,
|
|
6551
|
+
buildArgs,
|
|
6552
|
+
appOptions,
|
|
6553
|
+
SWIFTPM_PROGRESS,
|
|
6554
|
+
SWIFTPM_NOISE,
|
|
6555
|
+
)
|
|
6556
|
+
} catch (error) {
|
|
6557
|
+
const output = outputOf(error)
|
|
6558
|
+
const moduleCache = path.join(
|
|
6463
6559
|
root,
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
sdk,
|
|
6467
|
-
...(input.packageFiles || prebuilt
|
|
6468
|
-
? ['--toolset', path.join(root, '.peach-target-toolset.json')]
|
|
6469
|
-
: []),
|
|
6470
|
-
'-c',
|
|
6560
|
+
'.build',
|
|
6561
|
+
WASM_TRIPLE,
|
|
6471
6562
|
'release',
|
|
6472
|
-
'
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
...forwarders,
|
|
6481
|
-
]),
|
|
6482
|
-
...macroPlugins.libraries.flatMap((plugin) => [
|
|
6483
|
-
'-Xswiftc',
|
|
6484
|
-
'-load-plugin-library',
|
|
6485
|
-
'-Xswiftc',
|
|
6486
|
-
plugin,
|
|
6487
|
-
]),
|
|
6488
|
-
...macroPlugins.executables.flatMap((plugin) => [
|
|
6489
|
-
'-Xswiftc',
|
|
6490
|
-
'-load-plugin-executable',
|
|
6491
|
-
'-Xswiftc',
|
|
6492
|
-
`${plugin}#ExpoModulesMacros`,
|
|
6493
|
-
]),
|
|
6494
|
-
]
|
|
6495
|
-
const linked = builtArtifact(layout)
|
|
6496
|
-
if (input.lazyDistribution) {
|
|
6497
|
-
rmSync(path.join(root, '.peach-link.rsp'), { force: true })
|
|
6498
|
-
if (existsSync(linked) && statSync(linked).size <= 8)
|
|
6499
|
-
rmSync(linked, { force: true })
|
|
6500
|
-
}
|
|
6501
|
-
report('compiling and linking Swift modules')
|
|
6502
|
-
try {
|
|
6503
|
-
// clang consumes the real emitted headers after swift finishes.
|
|
6504
|
-
// swiftpm's transitive swift module maps are not C declarations:
|
|
6505
|
-
// importing them would shadow SDK modules such as ObjectiveC.
|
|
6506
|
-
const headerBuilds = preparation.headerProductTarget
|
|
6507
|
-
? [
|
|
6508
|
-
...Object.keys(preparation.nativeHeaderDeclarations),
|
|
6509
|
-
preparation.headerProductTarget,
|
|
6510
|
-
]
|
|
6511
|
-
: preparation.headerProducers
|
|
6512
|
-
for (const build of headerBuilds) {
|
|
6563
|
+
'ModuleCache',
|
|
6564
|
+
)
|
|
6565
|
+
if (
|
|
6566
|
+
output.includes('was compiled with module cache path') &&
|
|
6567
|
+
existsSync(moduleCache)
|
|
6568
|
+
) {
|
|
6569
|
+
rmSync(moduleCache, { recursive: true, force: true })
|
|
6570
|
+
try {
|
|
6513
6571
|
await runCompiler(
|
|
6514
6572
|
swift,
|
|
6515
|
-
|
|
6573
|
+
buildArgs,
|
|
6516
6574
|
appOptions,
|
|
6517
6575
|
SWIFTPM_PROGRESS,
|
|
6518
6576
|
SWIFTPM_NOISE,
|
|
6519
6577
|
)
|
|
6520
|
-
|
|
6521
|
-
? preparation.headerProducers
|
|
6522
|
-
: [build]) {
|
|
6523
|
-
const emitted = path.join(
|
|
6524
|
-
root,
|
|
6525
|
-
'.build',
|
|
6526
|
-
'peach-cxx-headers',
|
|
6527
|
-
`${producer}-Swift.h`,
|
|
6528
|
-
)
|
|
6529
|
-
const original = preparation.nativeHeaderDeclarations[producer]
|
|
6530
|
-
? emitted.replace(/-Swift\.h$/, '-Swift.original.h')
|
|
6531
|
-
: emitted
|
|
6532
|
-
if (existsSync(original))
|
|
6533
|
-
writeBuildFile(
|
|
6534
|
-
emitted,
|
|
6535
|
-
withoutSwiftDeclarations(
|
|
6536
|
-
clangInterfaceHeader(readFileSync(original, 'utf8')),
|
|
6537
|
-
new Set(preparation.nativeHeaderDeclarations[producer]),
|
|
6538
|
-
`#import <${producer}/${producer}.h>`,
|
|
6539
|
-
),
|
|
6540
|
-
)
|
|
6541
|
-
}
|
|
6542
|
-
}
|
|
6543
|
-
await runCompiler(
|
|
6544
|
-
swift,
|
|
6545
|
-
buildArgs,
|
|
6546
|
-
appOptions,
|
|
6547
|
-
SWIFTPM_PROGRESS,
|
|
6548
|
-
SWIFTPM_NOISE,
|
|
6549
|
-
)
|
|
6550
|
-
} catch (error) {
|
|
6551
|
-
const output = outputOf(error)
|
|
6552
|
-
const moduleCache = path.join(
|
|
6553
|
-
root,
|
|
6554
|
-
'.build',
|
|
6555
|
-
WASM_TRIPLE,
|
|
6556
|
-
'release',
|
|
6557
|
-
'ModuleCache',
|
|
6558
|
-
)
|
|
6559
|
-
if (
|
|
6560
|
-
output.includes('was compiled with module cache path') &&
|
|
6561
|
-
existsSync(moduleCache)
|
|
6562
|
-
) {
|
|
6563
|
-
rmSync(moduleCache, { recursive: true, force: true })
|
|
6564
|
-
try {
|
|
6565
|
-
await runCompiler(
|
|
6566
|
-
swift,
|
|
6567
|
-
buildArgs,
|
|
6568
|
-
appOptions,
|
|
6569
|
-
SWIFTPM_PROGRESS,
|
|
6570
|
-
SWIFTPM_NOISE,
|
|
6571
|
-
)
|
|
6572
|
-
} catch (retryError) {
|
|
6573
|
-
throw new Error(
|
|
6574
|
-
[
|
|
6575
|
-
...unprepared,
|
|
6576
|
-
projectDiagnostic(outputOf(retryError), layout, input.files),
|
|
6577
|
-
].join('\n'),
|
|
6578
|
-
{ cause: retryError },
|
|
6579
|
-
)
|
|
6580
|
-
}
|
|
6581
|
-
} else {
|
|
6578
|
+
} catch (retryError) {
|
|
6582
6579
|
throw new Error(
|
|
6583
|
-
[
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6580
|
+
[
|
|
6581
|
+
...unprepared,
|
|
6582
|
+
projectDiagnostic(outputOf(retryError), layout, input.files),
|
|
6583
|
+
].join('\n'),
|
|
6584
|
+
{ cause: retryError },
|
|
6587
6585
|
)
|
|
6588
6586
|
}
|
|
6589
|
-
}
|
|
6590
|
-
// a manifest, macro or build tool can leave processes behind that
|
|
6591
|
-
// outlive the compiler's own group; none runs once the host reads.
|
|
6592
|
-
if (options.project) endSwiftProjectProcesses(options.project)
|
|
6593
|
-
}
|
|
6594
|
-
if (unprepared.length) throw new Error(unprepared.join('\n'))
|
|
6595
|
-
if (!existsSync(linked)) {
|
|
6596
|
-
const binDir = path.dirname(linked)
|
|
6597
|
-
const found = existsSync(binDir)
|
|
6598
|
-
? readdirSync(binDir)
|
|
6599
|
-
.filter((name) => name.endsWith('.wasm'))
|
|
6600
|
-
.sort()
|
|
6601
|
-
: []
|
|
6587
|
+
} else {
|
|
6602
6588
|
throw new Error(
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
const output = options.project
|
|
6608
|
-
? projectOutputFile(root, linked, options.project)
|
|
6609
|
-
: linked
|
|
6610
|
-
const optimized = `${output}.optimized`
|
|
6611
|
-
if (input.lazyDistribution) {
|
|
6612
|
-
pruneSwiftWasmLink(
|
|
6613
|
-
root,
|
|
6614
|
-
options.toolchainBin,
|
|
6615
|
-
frameworkRoot,
|
|
6616
|
-
input.staticClangTargets,
|
|
6589
|
+
[...unprepared, projectDiagnostic(output, layout, input.files)].join(
|
|
6590
|
+
'\n',
|
|
6591
|
+
),
|
|
6592
|
+
{ cause: error },
|
|
6617
6593
|
)
|
|
6618
|
-
await optimizeWasm(output, optimized)
|
|
6619
|
-
}
|
|
6620
|
-
const artifact = {
|
|
6621
|
-
hash,
|
|
6622
|
-
bytes: readFileSync(input.lazyDistribution ? optimized : output),
|
|
6623
|
-
icu: await icu,
|
|
6624
6594
|
}
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
}
|
|
6630
|
-
|
|
6631
|
-
|
|
6595
|
+
} finally {
|
|
6596
|
+
// a manifest, macro or build tool can leave processes behind that
|
|
6597
|
+
// outlive the compiler's own group; none runs once the host reads.
|
|
6598
|
+
if (options.project) endSwiftProjectProcesses(options.project)
|
|
6599
|
+
}
|
|
6600
|
+
if (unprepared.length) throw new Error(unprepared.join('\n'))
|
|
6601
|
+
if (!existsSync(linked)) {
|
|
6602
|
+
const binDir = path.dirname(linked)
|
|
6603
|
+
const found = existsSync(binDir)
|
|
6604
|
+
? readdirSync(binDir)
|
|
6605
|
+
.filter((name) => name.endsWith('.wasm'))
|
|
6606
|
+
.sort()
|
|
6607
|
+
: []
|
|
6608
|
+
throw new Error(
|
|
6609
|
+
`swift-compile: the build produced no ${path.basename(linked)} (found: ${found.join(', ') || 'none'})`,
|
|
6610
|
+
)
|
|
6611
|
+
}
|
|
6612
|
+
if (options.project) removeProjectLinks(root)
|
|
6613
|
+
const output = options.project
|
|
6614
|
+
? projectOutputFile(root, linked, options.project)
|
|
6615
|
+
: linked
|
|
6616
|
+
const optimized = `${output}.optimized`
|
|
6617
|
+
if (input.lazyDistribution) {
|
|
6618
|
+
pruneSwiftWasmLink(
|
|
6619
|
+
root,
|
|
6620
|
+
options.toolchainBin,
|
|
6621
|
+
frameworkRoot,
|
|
6622
|
+
input.staticClangTargets,
|
|
6623
|
+
)
|
|
6624
|
+
await optimizeWasm(output, optimized)
|
|
6625
|
+
}
|
|
6626
|
+
const artifact = {
|
|
6627
|
+
hash,
|
|
6628
|
+
bytes: readFileSync(input.lazyDistribution ? optimized : output),
|
|
6629
|
+
icu: await icu,
|
|
6630
|
+
}
|
|
6631
|
+
if (!options.project) saveCompiledArtifact(root, artifact)
|
|
6632
|
+
saveSharedArtifact(sharedRoot, artifact)
|
|
6633
|
+
report('compiled artifact verified')
|
|
6634
|
+
return retain(root, artifact)
|
|
6635
|
+
})
|
|
6632
6636
|
},
|
|
6633
6637
|
options.signal,
|
|
6634
6638
|
)
|
|
@@ -242,16 +242,20 @@ function iosSdkEntries(): (readonly [string, string])[] {
|
|
|
242
242
|
return [...headers, ...overlays].sort(([a], [b]) => (a < b ? -1 : 1))
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
.
|
|
248
|
-
|
|
249
|
-
|
|
245
|
+
let sdkId: string | undefined
|
|
246
|
+
/** the sdk's content digest, which keys every stand-in read through it. taken on first
|
|
247
|
+
* use: it reads every header, and the cli's service boot imports this module. */
|
|
248
|
+
export function iosSdkId(): string {
|
|
249
|
+
return (sdkId ??= createHash('sha256')
|
|
250
|
+
.update(JSON.stringify(iosSdkEntries()))
|
|
251
|
+
.digest('hex')
|
|
252
|
+
.slice(0, 16))
|
|
253
|
+
}
|
|
250
254
|
|
|
251
255
|
// the sdk, written once per content under the cache directory so the module
|
|
252
256
|
// cache keyed by its paths stays warm across stand-ins.
|
|
253
257
|
export function materializeObjcSdk(cacheDir: string): string {
|
|
254
|
-
const sdk = path.join(cacheDir, 'ios-sdk',
|
|
258
|
+
const sdk = path.join(cacheDir, 'ios-sdk', iosSdkId())
|
|
255
259
|
if (fs.existsSync(sdk)) return sdk
|
|
256
260
|
fs.mkdirSync(path.dirname(sdk), { recursive: true })
|
|
257
261
|
const staging = fs.mkdtempSync(`${sdk}-`)
|