peachsim 0.1.1815 → 0.1.1818
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/agent-indicator-mode.ts +2 -1
- package/cli/commands/coverage-swift.ts +4 -3
- package/cli/commands/flow.ts +7 -0
- package/cli/commands/inspect/core.ts +1 -1
- package/cli/commands/maestro-compare.ts +7 -0
- package/cli/commands/package.ts +87 -31
- package/cli/commands/screenshot-mode.ts +2 -1
- package/cli/commands/shell-boolean-mode.ts +7 -3
- package/cli/commands/shell-url.ts +4 -0
- package/cli/commands/show-touches-mode.ts +2 -1
- package/cli/commands/test.ts +3 -2
- package/cli/commands/three-mode.ts +2 -1
- 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 +5728 -7551
- 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 +13 -4
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +5234 -5704
- 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 +4913 -6811
- package/dist-lib/host/fetch-proxy-handler.cjs +13 -4
- 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 +40 -30
- 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 +39 -29
- package/dist-lib/native-app-identity-project.cjs +31 -26
- package/dist-lib/native-app-identity-project.mjs +295 -279
- 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 +29 -24
- package/dist-lib/public-origins-lib.json +121 -93
- 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 +2 -2
- package/dist-lib/sdk.mjs +2 -2
- package/dist-lib/skills.cjs +64622 -66476
- package/dist-lib/swift-compile.cjs +328 -265
- package/dist-lib/swift-compile.mjs +335 -270
- 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 +52 -6
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +2405 -2262
- package/dist-lib/vite.cjs +13 -4
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +5 -0
- package/dist-types/packages/peach-engine/src/render-worker/map-command-channel.d.ts +41 -0
- package/dist-types/packages/peach-engine/src/render-worker/mapServicesContract.d.ts +45 -0
- package/package.json +2 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes +1 -1
- package/sdk/ios/usr/include/module.modulemap +3 -0
- package/sdk/ios/usr/include/notify.modulemap +9 -0
- package/sdk/ios/usr/lib/swift/Darwin.swiftmodule/arm64-apple-ios-simulator.swiftinterface +4 -0
- package/sdk/ios/usr/lib/swift/Dispatch.swiftmodule/arm64-apple-ios-simulator.swiftinterface +1 -1
- package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +7 -1
- package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +1 -0
- package/sdk/ios/usr/lib/swift/SwiftUI.swiftmodule/arm64-apple-ios-simulator.swiftinterface +21 -0
- package/sdk/ios/usr/lib/swift/SwiftUICore.swiftmodule/arm64-apple-ios-simulator.swiftinterface +6 -1
- package/sdk/ios/wasm/include/__header_time.h +4 -0
- package/sdk/ios/wasm/include/pthread.h +2 -0
- package/sdk/ios/wasm/include/sys/mman.h +1 -1
- package/sdk/ios/wasm/include/sys/resource.h +31 -0
- package/sdk/ios/wasm/include/unistd.h +4 -0
- package/src/answeredNativePackages.ts +43 -0
- package/src/cli-runtime.ts +2 -9
- package/src/expo-discovery-cache.ts +71 -52
- package/src/expo-kotlin-host.ts +11 -9
- package/src/expo-swift-host.ts +55 -13
- package/src/installed-native-libraries.ts +103 -20
- package/src/native-static-libraries.ts +69 -33
- package/src/nitro-adapter.ts +0 -9
- package/src/nitro-bundle.ts +8 -6
- package/src/nitro-compile.ts +45 -16
- package/src/nitro-compiler-digest.ts +2 -4
- package/src/nitro-superset.lock.json +19 -251
- package/src/nitro-superset.ts +63 -68
- package/src/plist-bytes.ts +9 -0
- package/src/portable-expo-workspace.ts +4 -3
- package/src/react-native-bridge-modules.ts +13 -19
- package/src/swift-compile.ts +379 -269
- package/src/swift-cxx-reachable.ts +13 -0
- package/src/swift-distribution.ts +3 -4
- package/src/swift-host.ts +5 -3
- package/src/swift-installed-targets.ts +32 -14
- package/src/swift-native-pin.ts +45 -0
- package/src/swift-objc-compile.ts +23 -1
- package/src/swift-objc-standin.ts +14 -7
- package/src/swift-package-manifest.ts +2 -2
- package/src/swift-root-lock.ts +4 -3
- package/src/swift-standins.ts +41 -38
- package/src/swift-toolchain.ts +69 -12
- package/src/swift-wasm-prune.ts +1 -0
- package/src/swift-xcframework.ts +23 -12
- package/src/swiftContract.ts +2 -0
- package/src/swiftNativePinContract.ts +68 -0
- package/src/turbo-bundle.ts +14 -6
- package/src/turbo-compile.ts +76 -11
- package/src/turbo-source.ts +93 -18
|
@@ -54,6 +54,19 @@ export async function xcodeCxxReachable(
|
|
|
54
54
|
)
|
|
55
55
|
)
|
|
56
56
|
return [...binaries]
|
|
57
|
+
// only a binary whose headers sit in one directory has C++ headers to find.
|
|
58
|
+
// preparing the original units compiles dependency Swift against the raw
|
|
59
|
+
// binaries before their stand-ins exist, so skip it when nothing needs it.
|
|
60
|
+
const staged = remoteSwiftCheckouts(app.rootDir)
|
|
61
|
+
if (
|
|
62
|
+
!binaries.some(
|
|
63
|
+
(binary) =>
|
|
64
|
+
binary.publicHeaders === undefined &&
|
|
65
|
+
binary.placeholder === undefined &&
|
|
66
|
+
binaryHeaderSearchPaths(binary, staged).headers.length === 1,
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
return [...binaries]
|
|
57
70
|
const hash = createHash('sha256')
|
|
58
71
|
hash.update(
|
|
59
72
|
JSON.stringify([
|
|
@@ -13,12 +13,11 @@ import { ensureLinuxBrowserLibraries } from '../cli/drivers/linux-browser-libs'
|
|
|
13
13
|
import { rnxHomeDir } from './home-paths'
|
|
14
14
|
import { swiftDistributionAt, swiftModuleSdk } from './swift-compile'
|
|
15
15
|
import {
|
|
16
|
-
parseSwiftDistributionLock,
|
|
17
16
|
SWIFT_DISTRIBUTION_MANIFEST,
|
|
18
17
|
swiftDistributionHost,
|
|
19
18
|
swiftDistributionKey,
|
|
20
19
|
} from './swift-distribution-contract'
|
|
21
|
-
import
|
|
20
|
+
import { swiftNativePin } from './swift-native-pin'
|
|
22
21
|
import {
|
|
23
22
|
confineSwiftScratch,
|
|
24
23
|
ensureSwiftLinuxRuntime,
|
|
@@ -71,7 +70,7 @@ const installs = new Map<
|
|
|
71
70
|
* that runs swift before any module compile. */
|
|
72
71
|
export async function ensureSwiftToolchain(signal?: AbortSignal): Promise<void> {
|
|
73
72
|
if (privateSwiftDistributionRoot()) return
|
|
74
|
-
const lock =
|
|
73
|
+
const lock = swiftNativePin().distribution
|
|
75
74
|
await installSwiftToolchain(lock.release, lock, signal, true)
|
|
76
75
|
}
|
|
77
76
|
|
|
@@ -120,7 +119,7 @@ export async function swiftDistributionRoot(signal?: AbortSignal): Promise<strin
|
|
|
120
119
|
return privateRoot
|
|
121
120
|
}
|
|
122
121
|
const endpoint = swiftEndpoint()
|
|
123
|
-
const lock =
|
|
122
|
+
const lock = swiftNativePin().distribution
|
|
124
123
|
// the archive is useless without its compiler, so the toolchain installs
|
|
125
124
|
// or fails before the download
|
|
126
125
|
await installSwiftToolchain(lock.release, lock, signal)
|
package/src/swift-host.ts
CHANGED
|
@@ -150,7 +150,9 @@ import type { ServerResponse } from 'node:http'
|
|
|
150
150
|
const ARTIFACT_PATH = '/__peach/swift/'
|
|
151
151
|
const RESOURCE_PATH = '/__peach/swift-res/'
|
|
152
152
|
const ICU_PATH = '/__peach/swift-icu/'
|
|
153
|
-
|
|
153
|
+
// a javascript project around the package keeps its outputs at the root; a
|
|
154
|
+
// target compiles every visible file below it, a build or types directory too.
|
|
155
|
+
const SKIP_ROOT_DIRS = new Set(['dist', 'types', 'build', 'ios', 'android'])
|
|
154
156
|
const NATIVE_DESCRIPTOR = '.one-native-source.json'
|
|
155
157
|
const NATIVE_GLUE = '.one-native-source.swift.txt'
|
|
156
158
|
|
|
@@ -1442,10 +1444,10 @@ function sourceTreeFiles(dir: string, canonicalRoot: string): string[] {
|
|
|
1442
1444
|
(entry.name.startsWith('.') &&
|
|
1443
1445
|
entry.name !== NATIVE_DESCRIPTOR &&
|
|
1444
1446
|
entry.name !== NATIVE_GLUE) ||
|
|
1445
|
-
|
|
1447
|
+
entry.name === 'node_modules' ||
|
|
1446
1448
|
// platform project wrappers are excluded only at the package root;
|
|
1447
1449
|
// native target sources can contain upstream ios/android directories.
|
|
1448
|
-
(dir === canonicalRoot && (entry.name
|
|
1450
|
+
(dir === canonicalRoot && SKIP_ROOT_DIRS.has(entry.name))
|
|
1449
1451
|
)
|
|
1450
1452
|
continue
|
|
1451
1453
|
const full = path.join(dir, entry.name)
|
|
@@ -57,6 +57,9 @@ export function applyInstalledSwiftTargets(
|
|
|
57
57
|
source.file,
|
|
58
58
|
]),
|
|
59
59
|
)
|
|
60
|
+
const originalSources = new Map(
|
|
61
|
+
collection.sources.map((source) => [source.file, source.source]),
|
|
62
|
+
)
|
|
60
63
|
const viewComponents = new Set(
|
|
61
64
|
[...(collection.viewComponentSources ?? [])].map((file) =>
|
|
62
65
|
projectSourceKey(sourceRoots, file),
|
|
@@ -139,14 +142,32 @@ export function applyInstalledSwiftTargets(
|
|
|
139
142
|
})
|
|
140
143
|
// a header the installed search paths already supply, and its module covers,
|
|
141
144
|
// must not also reach the target as a second textual copy
|
|
145
|
+
const prefix = `${generated.path}/include/`
|
|
146
|
+
const supplied = new Map<string, Set<string>>()
|
|
147
|
+
for (const [key, content] of Object.entries(snapshot.input.files)) {
|
|
148
|
+
if (!native.headerSearchPaths.includes(path.posix.dirname(key))) continue
|
|
149
|
+
const name = path.posix.basename(key)
|
|
150
|
+
supplied.set(name, (supplied.get(name) ?? new Set()).add(content))
|
|
151
|
+
}
|
|
152
|
+
// a module map resolves its headers beside itself, so the ones it names stay
|
|
153
|
+
const moduleHeaders = new Set(
|
|
154
|
+
[
|
|
155
|
+
...(collection.files[`${prefix}module.modulemap`] ?? '').matchAll(
|
|
156
|
+
/\bheader\s+"([^"]+)"/g,
|
|
157
|
+
),
|
|
158
|
+
].map((match) => path.posix.join(prefix, match[1]!)),
|
|
159
|
+
)
|
|
142
160
|
for (const file of Object.keys(collection.files)) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
(
|
|
161
|
+
if (!file.startsWith(prefix) || moduleHeaders.has(file)) continue
|
|
162
|
+
const target = /^#\s*include "([^"]+)"/m.exec(collection.files[file]!)?.[1]
|
|
163
|
+
const source =
|
|
164
|
+
target &&
|
|
165
|
+
originalSources.get(
|
|
166
|
+
path.posix.normalize(path.posix.join(path.posix.dirname(file), target)),
|
|
149
167
|
)
|
|
168
|
+
if (
|
|
169
|
+
source &&
|
|
170
|
+
supplied.get(path.posix.basename(file))?.has(fs.readFileSync(source, 'utf8'))
|
|
150
171
|
)
|
|
151
172
|
delete collection.files[file]
|
|
152
173
|
}
|
|
@@ -171,18 +192,15 @@ export function applyInstalledSwiftTargets(
|
|
|
171
192
|
const original = snapshot.sourcePaths[file]
|
|
172
193
|
if (original && viewComponents.has(projectSourceKey(sourceRoots, original)))
|
|
173
194
|
continue
|
|
195
|
+
const previous =
|
|
196
|
+
original && originalKeys.get(projectSourceKey(sourceRoots, original))
|
|
197
|
+
if (!previous) continue
|
|
174
198
|
const output = `${target.path}/native/${file}`
|
|
175
199
|
collection.files[output] = snapshot.input.files[file]!
|
|
176
200
|
sourceDirectories[output] = directory
|
|
177
201
|
fileFlags[output] = native.fileFlags[file] ?? []
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (previous) {
|
|
181
|
-
delete collection.files[previous]
|
|
182
|
-
collection.sources = collection.sources.filter(
|
|
183
|
-
(source) => source.file !== previous,
|
|
184
|
-
)
|
|
185
|
-
}
|
|
202
|
+
delete collection.files[previous]
|
|
203
|
+
collection.sources = collection.sources.filter((source) => source.file !== previous)
|
|
186
204
|
}
|
|
187
205
|
collection.nativeTargets ??= []
|
|
188
206
|
collection.nativeTargets.push({
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// the Swift distribution, compiler and adapter archives this process compiles
|
|
2
|
+
// with. an installed CLI reads them from the runtime it serves
|
|
3
|
+
// (swiftNativePinContract.ts); source scripts, the build container and
|
|
4
|
+
// Contrast's server read this checkout's locks.
|
|
5
|
+
import { readPeachRuntimeJson } from './answeredNativePackages'
|
|
6
|
+
import nitroLockJson from './nitro-adapter.lock.json' with { type: 'json' }
|
|
7
|
+
import { parseAdapterLock } from './nitroAdapterContract'
|
|
8
|
+
import { parseSwiftDistributionLock } from './swift-distribution-contract'
|
|
9
|
+
import lockJson from './swift-distribution.lock.json' with { type: 'json' }
|
|
10
|
+
import { registerSwiftHostCompiler, swiftHostCompilerPin } from './swift-toolchain'
|
|
11
|
+
import {
|
|
12
|
+
parseSwiftNativePin,
|
|
13
|
+
SWIFT_NATIVE_PIN_PATH,
|
|
14
|
+
SWIFT_NATIVE_PIN_SCHEMA,
|
|
15
|
+
type SwiftNativePin,
|
|
16
|
+
} from './swiftNativePinContract'
|
|
17
|
+
import turboLockJson from './turbo-runtime.lock.json' with { type: 'json' }
|
|
18
|
+
|
|
19
|
+
declare const __PEACH_RUNTIME_SWIFT_PIN__: boolean | undefined
|
|
20
|
+
|
|
21
|
+
export function repoSwiftNativePin(): SwiftNativePin {
|
|
22
|
+
const distribution = parseSwiftDistributionLock(lockJson)
|
|
23
|
+
return {
|
|
24
|
+
schema: SWIFT_NATIVE_PIN_SCHEMA,
|
|
25
|
+
distribution,
|
|
26
|
+
compiler: swiftHostCompilerPin(distribution.release),
|
|
27
|
+
adapters: {
|
|
28
|
+
nitro: parseAdapterLock('nitro', nitroLockJson),
|
|
29
|
+
turbo: parseAdapterLock('turbo', turboLockJson),
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let pin: SwiftNativePin | undefined
|
|
35
|
+
|
|
36
|
+
export function swiftNativePin(): SwiftNativePin {
|
|
37
|
+
if (pin) return pin
|
|
38
|
+
if (typeof __PEACH_RUNTIME_SWIFT_PIN__ === 'boolean') {
|
|
39
|
+
pin = parseSwiftNativePin(readPeachRuntimeJson(SWIFT_NATIVE_PIN_PATH))
|
|
40
|
+
registerSwiftHostCompiler(pin.distribution.release, pin.compiler)
|
|
41
|
+
} else {
|
|
42
|
+
pin = repoSwiftNativePin()
|
|
43
|
+
}
|
|
44
|
+
return pin
|
|
45
|
+
}
|
|
@@ -228,6 +228,26 @@ export async function xcodeObjCInputsAsync(
|
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
+
// installed packages a project resolves: its own node_modules, its ancestors'
|
|
232
|
+
// (a monorepo hoists them), and the targets of workspace-linked entries.
|
|
233
|
+
function installedPackageDirs(root: string): string[] {
|
|
234
|
+
const dirs: string[] = []
|
|
235
|
+
for (let dir = root; ; dir = path.dirname(dir)) {
|
|
236
|
+
const modules = path.join(dir, 'node_modules')
|
|
237
|
+
if (fs.existsSync(modules)) {
|
|
238
|
+
dirs.push(fs.realpathSync.native(modules))
|
|
239
|
+
if (dir === root)
|
|
240
|
+
for (const entry of fs.readdirSync(modules, { withFileTypes: true })) {
|
|
241
|
+
const target = path.join(modules, entry.name)
|
|
242
|
+
if (entry.isSymbolicLink() && fs.existsSync(target))
|
|
243
|
+
dirs.push(fs.realpathSync.native(target))
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (dir === path.dirname(dir)) break
|
|
247
|
+
}
|
|
248
|
+
return dirs.filter((directory) => relativeInside(root, directory) === null)
|
|
249
|
+
}
|
|
250
|
+
|
|
231
251
|
function* xcodeObjCInputSteps(
|
|
232
252
|
app: XcodeAppTarget,
|
|
233
253
|
binaries: readonly SwiftPackageBinary[],
|
|
@@ -252,6 +272,8 @@ function* xcodeObjCInputSteps(
|
|
|
252
272
|
.map((directory) => fs.realpathSync.native(directory)),
|
|
253
273
|
),
|
|
254
274
|
].filter((directory) => relativeInside(sourceRoot, directory) === null)
|
|
275
|
+
// installed packages (hoisted or workspace-linked) own the headers pods link to.
|
|
276
|
+
const installedDirs = installedPackageDirs(sourceRoot)
|
|
255
277
|
const generated = new Map(
|
|
256
278
|
products?.files.map(({ path: declared, file }) => [declared, file]),
|
|
257
279
|
)
|
|
@@ -278,7 +300,7 @@ function* xcodeObjCInputSteps(
|
|
|
278
300
|
const resolved = header ? fs.realpathSync.native(file) : file
|
|
279
301
|
if (resolved !== file) links[file] = resolved
|
|
280
302
|
// the project's installed framework directory is its own read boundary.
|
|
281
|
-
const external = externalFrameworkDirs.find(
|
|
303
|
+
const external = [...externalFrameworkDirs, ...installedDirs].find(
|
|
282
304
|
(directory) => relativeInside(directory, resolved) !== null,
|
|
283
305
|
)
|
|
284
306
|
const bytes = readPackageFile(
|
|
@@ -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}-`)
|
|
@@ -305,6 +309,9 @@ export function objcSdkIntakeFlags(
|
|
|
305
309
|
path.join(headers, 'System/Library/Frameworks'),
|
|
306
310
|
'-isystem',
|
|
307
311
|
path.join(headers, 'wasm/include'),
|
|
312
|
+
// compiler intrinsics an arm64 unit includes, ahead of clang's arm-only ones.
|
|
313
|
+
'-isystem',
|
|
314
|
+
path.join(headers, 'wasm/intrinsics'),
|
|
308
315
|
// libxml2 headers sit one level deeper, as in the iOS sdk: a unit
|
|
309
316
|
// includes <libxml/parser.h> through usr/include/libxml2, never the parent.
|
|
310
317
|
'-I',
|
|
@@ -738,7 +745,7 @@ export function objcView(
|
|
|
738
745
|
}
|
|
739
746
|
// clang's module import, or a swift interface's
|
|
740
747
|
const module = /^module '(\w+)' not found$/.exec(message!)
|
|
741
|
-
const swiftModule = /^no such module '(\w+)
|
|
748
|
+
const swiftModule = /^no such module '(\w+)'$/.exec(message!)
|
|
742
749
|
if (module || swiftModule) {
|
|
743
750
|
if (stubModule((module ?? swiftModule)![1]!, !module)) progress = true
|
|
744
751
|
continue
|
|
@@ -18,7 +18,7 @@ import path from 'node:path'
|
|
|
18
18
|
import { promisify } from 'node:util'
|
|
19
19
|
import { cacheDir as peachCacheDir } from './home-paths'
|
|
20
20
|
import { ensureSwiftToolchain, swiftModuleCompiler } from './swift-distribution'
|
|
21
|
-
import
|
|
21
|
+
import { swiftNativePin } from './swift-native-pin'
|
|
22
22
|
import {
|
|
23
23
|
isSwiftNativeTranslationUnit,
|
|
24
24
|
swiftPackageIdentity,
|
|
@@ -169,7 +169,7 @@ function swiftCommand(): string {
|
|
|
169
169
|
const privateRoot = privateSwiftDistributionRoot()
|
|
170
170
|
if (privateRoot)
|
|
171
171
|
return path.join(swiftModuleCompiler(privateRoot).toolchainBin, 'swift')
|
|
172
|
-
return path.join(swiftToolchainBin(
|
|
172
|
+
return path.join(swiftToolchainBin(swiftNativePin().distribution.release), 'swift')
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
function swiftPackageFailure(error: unknown): string {
|
package/src/swift-root-lock.ts
CHANGED
|
@@ -257,12 +257,13 @@ export async function withSwiftRootLock<T>(
|
|
|
257
257
|
const children: ChildProcess[] = []
|
|
258
258
|
const lease: SwiftRootLease = {
|
|
259
259
|
register(child) {
|
|
260
|
-
children.push(child)
|
|
260
|
+
const index = children.push(child)
|
|
261
261
|
if (child.pid === undefined) throw new Error('could not register compiler process')
|
|
262
|
-
|
|
262
|
+
// a long hold outlives the pid space, so a pid can name two children.
|
|
263
|
+
const childPending = `${pending}.child.${index}`
|
|
263
264
|
try {
|
|
264
265
|
writeFileSync(childPending, JSON.stringify(ownIdentity(child.pid)))
|
|
265
|
-
linkSync(childPending, path.join(directory, name(held, `child.${
|
|
266
|
+
linkSync(childPending, path.join(directory, name(held, `child.${index}`)))
|
|
266
267
|
} finally {
|
|
267
268
|
rmSync(childPending, { force: true })
|
|
268
269
|
}
|
package/src/swift-standins.ts
CHANGED
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
} from './swift-compile'
|
|
36
36
|
import { emitCxxStandin } from './swift-cxx-standin'
|
|
37
37
|
import {
|
|
38
|
-
|
|
38
|
+
iosSdkId,
|
|
39
39
|
WASI_EMULATION,
|
|
40
40
|
WASI_EMULATION_FLAGS,
|
|
41
41
|
moduleMapHeaders,
|
|
@@ -66,7 +66,7 @@ import {
|
|
|
66
66
|
swiftEnvironment,
|
|
67
67
|
swiftPackageCacheOptions,
|
|
68
68
|
} from './swift-toolchain'
|
|
69
|
-
import {
|
|
69
|
+
import { simulatorNativeLibrary } from './swift-xcframework'
|
|
70
70
|
import type { SwiftPackageBinary } from './swift-packages'
|
|
71
71
|
|
|
72
72
|
const TRIPLE = 'wasm32-unknown-wasip1'
|
|
@@ -456,7 +456,11 @@ export function binaryHeaderSearchPaths(
|
|
|
456
456
|
// the interface header's bytes change with the module, so the staged
|
|
457
457
|
// directory names the declarations and imports it was cut by, and the
|
|
458
458
|
// header is written into it on every call. framework identity is relative
|
|
459
|
-
// to the artifact so the host's cache location never enters staged paths
|
|
459
|
+
// to the artifact so the host's cache location never enters staged paths.
|
|
460
|
+
// each staged tree is immutable and named by its bytes: clang units name it
|
|
461
|
+
// in their flags, so a stand-in revision that stages the same headers keeps
|
|
462
|
+
// a warm build root's objects, and a concurrent reader never sees a rewrite.
|
|
463
|
+
// a per-revision record finds the tree without restaging.
|
|
460
464
|
const declaredDigest = createHash('sha256')
|
|
461
465
|
for (const [framework, { declared: names, imports, sdkHeader }] of declared)
|
|
462
466
|
declaredDigest
|
|
@@ -465,16 +469,16 @@ export function binaryHeaderSearchPaths(
|
|
|
465
469
|
.update('\n')
|
|
466
470
|
.update([...imports].sort().join('\0'))
|
|
467
471
|
.update(sdkHeader ?? '')
|
|
468
|
-
const
|
|
472
|
+
const staging = path.join(
|
|
469
473
|
root,
|
|
470
|
-
'peach-binary-
|
|
471
|
-
STANDIN_SOURCE_DIGEST.slice(0, 32),
|
|
474
|
+
'peach-binary-trees',
|
|
472
475
|
declared.size
|
|
473
476
|
? `${artifact.digest.slice(0, 32)}-${declaredDigest.digest('hex').slice(0, 16)}`
|
|
474
477
|
: artifact.digest.slice(0, 32),
|
|
475
478
|
)
|
|
476
|
-
|
|
477
|
-
|
|
479
|
+
const revision = path.join(staging, 'revisions', STANDIN_SOURCE_DIGEST.slice(0, 32))
|
|
480
|
+
const stageTree = (): string => {
|
|
481
|
+
const pending = path.join(staging, `pending.${process.pid}`)
|
|
478
482
|
fs.rmSync(pending, { recursive: true, force: true })
|
|
479
483
|
for (const framework of frameworks) {
|
|
480
484
|
const swift = declared.get(framework)
|
|
@@ -510,13 +514,31 @@ export function binaryHeaderSearchPaths(
|
|
|
510
514
|
}
|
|
511
515
|
: {}),
|
|
512
516
|
})
|
|
517
|
+
const contents = createHash('sha256')
|
|
518
|
+
for (const relative of fs
|
|
519
|
+
.readdirSync(pending, { recursive: true, encoding: 'utf8' })
|
|
520
|
+
.sort()) {
|
|
521
|
+
const file = path.join(pending, relative)
|
|
522
|
+
contents.update(`${relative}\0`)
|
|
523
|
+
if (fs.statSync(file).isFile()) contents.update(fs.readFileSync(file))
|
|
524
|
+
}
|
|
525
|
+
const name = contents.digest('hex').slice(0, 32)
|
|
513
526
|
try {
|
|
514
|
-
fs.renameSync(pending,
|
|
527
|
+
fs.renameSync(pending, path.join(staging, name))
|
|
515
528
|
} catch (error) {
|
|
516
529
|
fs.rmSync(pending, { recursive: true, force: true })
|
|
517
|
-
if (!fs.existsSync(
|
|
530
|
+
if (!fs.existsSync(path.join(staging, name))) throw error
|
|
518
531
|
}
|
|
532
|
+
fs.mkdirSync(path.dirname(revision), { recursive: true })
|
|
533
|
+
const record = `${revision}.${process.pid}`
|
|
534
|
+
fs.writeFileSync(record, name)
|
|
535
|
+
fs.renameSync(record, revision)
|
|
536
|
+
return name
|
|
519
537
|
}
|
|
538
|
+
const search = path.join(
|
|
539
|
+
staging,
|
|
540
|
+
fs.existsSync(revision) ? fs.readFileSync(revision, 'utf8') : stageTree(),
|
|
541
|
+
)
|
|
520
542
|
for (const [framework, { header }] of declared) {
|
|
521
543
|
if (header === null) continue
|
|
522
544
|
const name = path.basename(framework, '.framework')
|
|
@@ -527,8 +549,10 @@ export function binaryHeaderSearchPaths(
|
|
|
527
549
|
'Headers',
|
|
528
550
|
`${name}-Swift.h`,
|
|
529
551
|
)
|
|
530
|
-
if (!fs.existsSync(staged) || fs.readFileSync(staged, 'utf8') !== header)
|
|
531
|
-
fs.writeFileSync(staged
|
|
552
|
+
if (!fs.existsSync(staged) || fs.readFileSync(staged, 'utf8') !== header) {
|
|
553
|
+
fs.writeFileSync(`${staged}.${process.pid}`, header)
|
|
554
|
+
fs.renameSync(`${staged}.${process.pid}`, staged)
|
|
555
|
+
}
|
|
532
556
|
}
|
|
533
557
|
return {
|
|
534
558
|
frameworks: frameworks.length ? [path.join(search, 'frameworks')] : [],
|
|
@@ -645,27 +669,6 @@ function surfaces(
|
|
|
645
669
|
const module = moduleMapName(fs.readFileSync(modulemap, 'utf8'))
|
|
646
670
|
if (module) found.push(headerSurface(module, modulemap, path.dirname(modulemap)))
|
|
647
671
|
}
|
|
648
|
-
// a library slice shipped for header search paths has no modulemap (Xcode
|
|
649
|
-
// copies its headers into the build products and a bridging header or
|
|
650
|
-
// objective-c unit includes them). its top-level headers form the module
|
|
651
|
-
// xcode's swift would see through them, named for the framework.
|
|
652
|
-
const roots =
|
|
653
|
-
found.length === 0 && !plain ? files(headers, (name) => name.endsWith('.h')) : []
|
|
654
|
-
if (roots.length > 0) {
|
|
655
|
-
const module = swiftTargetModuleName(path.basename(xcframeworkDir, '.xcframework'))
|
|
656
|
-
const text = `module ${module} {\n${roots.map((file) => ` header "${file}"`).join('\n')}\n export *\n}\n`
|
|
657
|
-
const modulemap = path.join(
|
|
658
|
-
cacheDir,
|
|
659
|
-
'modulemaps',
|
|
660
|
-
key(headers, text),
|
|
661
|
-
'module.modulemap',
|
|
662
|
-
)
|
|
663
|
-
if (!fs.existsSync(modulemap)) {
|
|
664
|
-
fs.mkdirSync(path.dirname(modulemap), { recursive: true })
|
|
665
|
-
fs.writeFileSync(modulemap, text)
|
|
666
|
-
}
|
|
667
|
-
found.push(headerSurface(module, modulemap, headers))
|
|
668
|
-
}
|
|
669
672
|
return found
|
|
670
673
|
}
|
|
671
674
|
|
|
@@ -2008,8 +2011,8 @@ export function standinLibrary(
|
|
|
2008
2011
|
): string | null {
|
|
2009
2012
|
if (binary.publicHeaders !== undefined) return null
|
|
2010
2013
|
const dir = xcframework(binary).dir
|
|
2011
|
-
const native =
|
|
2012
|
-
const library = native?.name
|
|
2014
|
+
const native = simulatorNativeLibrary(dir)
|
|
2015
|
+
const library = native?.kind === 'archive' ? native.name : null
|
|
2013
2016
|
const supplied = path.join(dir, RUST_TARGET)
|
|
2014
2017
|
if (fs.existsSync(supplied)) {
|
|
2015
2018
|
const found = fs.readdirSync(supplied).filter((name) => name.endsWith('.a'))
|
|
@@ -2021,11 +2024,11 @@ export function standinLibrary(
|
|
|
2021
2024
|
)
|
|
2022
2025
|
return path.join(supplied, chosen)
|
|
2023
2026
|
}
|
|
2024
|
-
if (!library) return null
|
|
2025
2027
|
if (native && toolchain && fs.existsSync(native.file)) {
|
|
2026
2028
|
const recipe = nativeStaticLibraryRecipe(fs.readFileSync(native.file))
|
|
2027
2029
|
if (recipe) return nativeStaticLibrary(native.file, recipe, toolchain.moduleRoot)
|
|
2028
2030
|
}
|
|
2031
|
+
if (!library) return null
|
|
2029
2032
|
for (const [name, recipe] of Object.entries(NATIVE_SLICE_RECIPES)) {
|
|
2030
2033
|
if (name !== path.basename(dir, '.xcframework') || !toolchain) continue
|
|
2031
2034
|
const pin = path.join(path.dirname(dir), recipe.pinFile)
|
|
@@ -2380,7 +2383,7 @@ export function standinGenerationInputs(
|
|
|
2380
2383
|
sdk.wasmSdkChecksum,
|
|
2381
2384
|
swiftModuleDigest(moduleRoot).toString('hex'),
|
|
2382
2385
|
`sources/${digest}`,
|
|
2383
|
-
`ios-sdk/${
|
|
2386
|
+
`ios-sdk/${iosSdkId()}`,
|
|
2384
2387
|
]
|
|
2385
2388
|
const modules = new Set(
|
|
2386
2389
|
binaries.flatMap((binary) => {
|
|
@@ -2784,7 +2787,7 @@ export async function swiftStandins(
|
|
|
2784
2787
|
siblings.get(binary)!,
|
|
2785
2788
|
)
|
|
2786
2789
|
console.error(
|
|
2787
|
-
`[swift-standins] ${binary.target} ${typeof result === 'string' ?
|
|
2790
|
+
`[swift-standins] ${binary.target} ${typeof result === 'string' ? `gap: ${result}` : 'ready'} in ${Date.now() - started}ms`,
|
|
2788
2791
|
)
|
|
2789
2792
|
if (typeof result === 'string') {
|
|
2790
2793
|
gaps.set(binary.target, result)
|