peachsim 0.1.2609 → 0.1.2610
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/perf-native.ts +120 -6
- 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 +60485 -60177
- 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-P6Q3SN6U.mjs → acorn-L2SFCOHG.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-CJLXAXGU.mjs → chunk-2LJTZ2KG.mjs} +17 -328
- package/dist-lib/esm-chunks/{chunk-DN4RY4ZO.mjs → chunk-42NDD4R7.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-MF7HNQ5K.mjs → chunk-73NIGS7D.mjs} +1490 -3950
- package/dist-lib/esm-chunks/{chunk-LSNKOL3L.mjs → chunk-CUBTZPSZ.mjs} +1 -1
- package/dist-lib/esm-chunks/chunk-EU5WMP5O.mjs +322 -0
- package/dist-lib/esm-chunks/{chunk-7JYSTMRO.mjs → chunk-EYSNLE5V.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-UMKSCALR.mjs → chunk-FP447MCW.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-2UJG76LY.mjs → chunk-HMTSU22Q.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-GJZ2ROIK.mjs → chunk-KTAGV5U6.mjs} +14 -12
- package/dist-lib/esm-chunks/{chunk-3MJN4KBR.mjs → chunk-MJP4WOSX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3LX34QVB.mjs → chunk-MK4DOEDN.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4HCHYS5S.mjs → chunk-N3M5KT33.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-IHK4FK5A.mjs → chunk-N7XU2WWO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-D44BCQPZ.mjs → chunk-RN73P2DY.mjs} +34 -28
- package/dist-lib/esm-chunks/{chunk-62CUUMJF.mjs → chunk-VDLPNJ6P.mjs} +1 -1
- package/dist-lib/esm-chunks/chunk-W3LNUIUA.mjs +2655 -0
- package/dist-lib/esm-chunks/{chunk-T554RY2B.mjs → chunk-WBQFHIGS.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5V7JOQMI.mjs → chunk-WZHEW7Z7.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-FOM5H3FB.mjs → chunk-X74N3K5N.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-ZUBTL7EH.mjs → chunk-XN74REO2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-PKXGC5OZ.mjs → chunk-YLUD2UET.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-VHBBOWKT.mjs → chunk-YVLXYLNV.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-L4ATOCRX.mjs → chunk-YYGSN3BN.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-FIUWBFDV.mjs → chunk-ZZB2LFYV.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-7VIYXTX3.mjs → metro-layout-parser-VDPXJ7LW.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-GNRGNGKJ.mjs → swift-package-prebuilt-HRPDLN2P.mjs} +14 -11
- package/dist-lib/esm-chunks/{swift-sdk-app-module-QMYD4WKD.mjs → swift-sdk-app-module-5DOGMU3M.mjs} +16 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-LUAWELUR.mjs → swift-sdk-image-W3UU4H4L.mjs} +16 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-A4Y2EYPV.mjs → swift-sdk-image-producer-OJWD6ZOH.mjs} +8 -6
- package/dist-lib/expo-swift-bundle.cjs +42524 -42216
- 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 +43719 -43248
- package/dist-lib/host/fetch-proxy-handler.cjs +670 -645
- 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 +1499 -2889
- package/dist-lib/native-app-identity-project.mjs +317 -339
- 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 +166 -154
- package/dist-lib/public-origins-lib.json +141 -198
- 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 +38909 -38438
- package/dist-lib/swift-compile.cjs +12239 -12121
- package/dist-lib/swift-compile.mjs +36 -33
- 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/binaryen.lock.json +3 -3
- package/src/genrule-archives.ts +5 -2
- package/src/native-framework-compiler.ts +1 -1
- package/src/native-static-libraries.ts +2 -3
- package/src/native-swift-slices.ts +1 -1
- package/src/nitro-dependencies.ts +3 -7
- package/src/one-native-controls-package.ts +165 -11
- package/src/oneNativeControlsContract.ts +1 -0
- package/src/rive-runtime-dependencies.ts +1 -2
- package/src/swift-compile.ts +165 -1796
- package/src/swift-compiler-digest.ts +2 -0
- package/src/swift-distribution.ts +39 -15
- package/src/swift-objc-compile.ts +194 -32
- package/src/swift-package-manifest.ts +6 -29
- package/src/swift-packages.ts +6 -14
- package/src/swift-sdk-surface.ts +1811 -0
- package/src/swift-standin-digest.ts +28 -5
- package/src/swift-standins.ts +16 -19
- package/src/swift-wasm-archive.ts +200 -0
- package/src/swift-wasm-prune.ts +3 -93
- package/src/swift-wasm64-native-source.ts +4 -2
- package/src/swiftWasm64ConfigContract.ts +10 -0
- package/src/wasm-optimize.ts +18 -14
- package/src/xcode-project.ts +2 -4
|
@@ -11,6 +11,8 @@ import { readIosSdkTree } from './swift-objc-sdk-tree'
|
|
|
11
11
|
// digest.
|
|
12
12
|
export const SWIFT_DIGEST_SOURCES = [
|
|
13
13
|
'swift-compile.ts',
|
|
14
|
+
'swift-sdk-surface.ts',
|
|
15
|
+
'swift-wasm-archive.ts',
|
|
14
16
|
'swift-lexical.ts',
|
|
15
17
|
'swift-header-compiler.ts',
|
|
16
18
|
'swift-header-dependencies.ts',
|
|
@@ -5,22 +5,34 @@
|
|
|
5
5
|
// unset, verifies it against the lock this build carries, and unpacks it under
|
|
6
6
|
// the swift cache
|
|
7
7
|
// (docs/peach/swift/distribution.md). no path here asks Contrast to compile.
|
|
8
|
+
import { execFile } from 'node:child_process'
|
|
8
9
|
import fs from 'node:fs'
|
|
9
10
|
import os from 'node:os'
|
|
10
11
|
import path from 'node:path'
|
|
12
|
+
import { promisify } from 'node:util'
|
|
11
13
|
import { installVerifiedTarball } from '@contrast/runtime-delivery'
|
|
12
14
|
import {
|
|
13
15
|
ensureLinuxBrowserLibraries,
|
|
14
16
|
missingLinuxLibraries,
|
|
15
17
|
} from '../cli/drivers/linux-browser-libs'
|
|
16
18
|
import { rnxHomeDir } from './home-paths'
|
|
17
|
-
import { swiftDistributionAt, swiftModuleSdk } from './swift-compile'
|
|
18
19
|
import {
|
|
19
20
|
SWIFT_DISTRIBUTION_MANIFEST,
|
|
20
21
|
swiftDistributionHost,
|
|
21
22
|
swiftDistributionKey,
|
|
22
23
|
} from './swift-distribution-contract'
|
|
23
24
|
import { swiftNativePin } from './swift-native-pin'
|
|
25
|
+
import {
|
|
26
|
+
swiftManifestCommand,
|
|
27
|
+
swiftManifestResolveRequest,
|
|
28
|
+
type SwiftRemoteRequirement,
|
|
29
|
+
} from './swift-package-manifest'
|
|
30
|
+
import {
|
|
31
|
+
swiftDistributionAt,
|
|
32
|
+
swiftModuleCompiler,
|
|
33
|
+
swiftModuleSdk,
|
|
34
|
+
swiftModuleToolchain,
|
|
35
|
+
} from './swift-sdk-surface'
|
|
24
36
|
import {
|
|
25
37
|
confineSwiftScratch,
|
|
26
38
|
ensureSwiftLinuxRuntime,
|
|
@@ -372,19 +384,31 @@ export async function resolveSwiftModule({
|
|
|
372
384
|
return { root, ...swiftModuleToolchain(root) }
|
|
373
385
|
}
|
|
374
386
|
|
|
375
|
-
|
|
376
|
-
export function swiftModuleCompiler(root: string): Omit<SwiftModule, 'root'> {
|
|
377
|
-
const pin: { release: string } =
|
|
378
|
-
swiftDistributionAt(root) ??
|
|
379
|
-
JSON.parse(fs.readFileSync(path.join(root, 'toolchain.json'), 'utf8'))
|
|
380
|
-
return {
|
|
381
|
-
release: pin.release,
|
|
382
|
-
toolchainBin: swiftCompiler(pin.release),
|
|
383
|
-
}
|
|
384
|
-
}
|
|
387
|
+
export { swiftModuleCompiler, swiftModuleToolchain }
|
|
385
388
|
|
|
386
|
-
/**
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
389
|
+
/**
|
|
390
|
+
* resolves remote package requirements with swiftpm, the resolver xcode uses,
|
|
391
|
+
* and writes the graph to `destination` as Package.resolved. a project with
|
|
392
|
+
* no lock does this itself; an existing lock stays authoritative. the locked
|
|
393
|
+
* compiler is installed first, so any host resolves, and the process stays
|
|
394
|
+
* free to serve requests while swiftpm runs.
|
|
395
|
+
*/
|
|
396
|
+
export async function resolveSwiftPackageRequirementsAsync(
|
|
397
|
+
requirements: readonly SwiftRemoteRequirement[],
|
|
398
|
+
destination: string,
|
|
399
|
+
signal?: AbortSignal,
|
|
400
|
+
): Promise<void> {
|
|
401
|
+
await ensureSwiftToolchain(signal)
|
|
402
|
+
const { dir, args, options, failed, publish } =
|
|
403
|
+
swiftManifestResolveRequest(requirements)
|
|
404
|
+
try {
|
|
405
|
+
try {
|
|
406
|
+
await promisify(execFile)(swiftManifestCommand(), args, { ...options, signal })
|
|
407
|
+
} catch (error) {
|
|
408
|
+
throw failed(error)
|
|
409
|
+
}
|
|
410
|
+
publish(destination)
|
|
411
|
+
} finally {
|
|
412
|
+
fs.rmSync(dir, { recursive: true, force: true })
|
|
413
|
+
}
|
|
390
414
|
}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import { spawn, spawnSync } from 'node:child_process'
|
|
2
|
-
import { createHash } from 'node:crypto'
|
|
2
|
+
import { createHash, randomUUID } from 'node:crypto'
|
|
3
3
|
import fs from 'node:fs'
|
|
4
4
|
import path from 'node:path'
|
|
5
5
|
import { mapLimit } from '../../../src/helpers/mapLimit.ts'
|
|
6
6
|
import { cacheDir } from './home-paths'
|
|
7
7
|
import { isRecord } from './is-record'
|
|
8
|
-
import {
|
|
9
|
-
swiftBuildJobs,
|
|
10
|
-
swiftSdkPaths,
|
|
11
|
-
swiftModuleSdk,
|
|
12
|
-
swiftCompileSurfaceDigest,
|
|
13
|
-
swiftPeachModules,
|
|
14
|
-
withFrameworkCompanionImports,
|
|
15
|
-
} from './swift-compile'
|
|
16
|
-
import { swiftModuleToolchain } from './swift-distribution'
|
|
17
8
|
import { swiftClangImporterFlags } from './swift-objc-import'
|
|
18
9
|
import { swiftObjCRuntimeFlags } from './swift-objc-runtime'
|
|
19
10
|
import { iosDeploymentMinimum, objcSdkIntakeFlags } from './swift-objc-standin'
|
|
@@ -27,8 +18,14 @@ import { swiftPackageManifest, swiftTargetFiles } from './swift-package-manifest
|
|
|
27
18
|
import {
|
|
28
19
|
remoteSwiftCheckouts,
|
|
29
20
|
swiftBinaryOnDisk,
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
swiftBuildJobs,
|
|
22
|
+
swiftSdkPaths,
|
|
23
|
+
swiftModuleSdk,
|
|
24
|
+
swiftModuleToolchain,
|
|
25
|
+
swiftCompileSurfaceDigest,
|
|
26
|
+
swiftPeachModules,
|
|
27
|
+
withFrameworkCompanionImports,
|
|
28
|
+
} from './swift-sdk-surface'
|
|
32
29
|
import { readPackageFile, relativeInside, replaceRoot } from './swift-source-file'
|
|
33
30
|
import { STANDIN_SOURCE_DIGEST } from './swift-standin-digest'
|
|
34
31
|
import { binaryHeaderSearchPaths, isBinaryLibraryFile } from './swift-standins'
|
|
@@ -36,6 +33,7 @@ import { swiftEnvironment } from './swift-toolchain'
|
|
|
36
33
|
import { deriveWasm64NativeSource } from './swift-wasm64-native-source'
|
|
37
34
|
import { SWIFT_WASM_TRIPLE, wasmThreadFlags } from './swiftTargetContract.ts'
|
|
38
35
|
import { writeXcodeHeaderSearch } from './xcode-header-search'
|
|
36
|
+
import type { SwiftPackageBinary } from './swift-packages'
|
|
39
37
|
import type {
|
|
40
38
|
SwiftNativeHeaderMap,
|
|
41
39
|
SwiftObjCImplementationPreparation,
|
|
@@ -255,23 +253,175 @@ function compiledFrameworkImports(
|
|
|
255
253
|
return imports
|
|
256
254
|
}
|
|
257
255
|
|
|
256
|
+
function sha256Hex(bytes: Buffer | string): string {
|
|
257
|
+
if (typeof Bun !== 'undefined')
|
|
258
|
+
return new Bun.CryptoHasher('sha256').update(bytes).digest('hex')
|
|
259
|
+
return createHash('sha256').update(bytes).digest('hex')
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function regularFileStamp(file: string): string | null {
|
|
263
|
+
const stat = fs.lstatSync(file, { bigint: true, throwIfNoEntry: false })
|
|
264
|
+
if (!stat || !stat.isFile()) return null
|
|
265
|
+
return `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function verifyRetainedFile(
|
|
269
|
+
work: string,
|
|
270
|
+
file: string,
|
|
271
|
+
hash: unknown,
|
|
272
|
+
stamps: Record<string, unknown> | null,
|
|
273
|
+
): boolean {
|
|
274
|
+
if (typeof hash !== 'string') return false
|
|
275
|
+
const resolved = path.resolve(work, file)
|
|
276
|
+
if (relativeInside(work, resolved) === null) return false
|
|
277
|
+
const expectedStamp = stamps?.[file]
|
|
278
|
+
if (typeof expectedStamp === 'string' && regularFileStamp(resolved) === expectedStamp)
|
|
279
|
+
return true
|
|
280
|
+
if (!fs.existsSync(resolved)) return false
|
|
281
|
+
return sha256Hex(readPackageFile(work, resolved, Infinity)) === hash
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function recordRetainedStamps(
|
|
285
|
+
work: string,
|
|
286
|
+
files: readonly string[],
|
|
287
|
+
): Record<string, string> {
|
|
288
|
+
const stamps: Record<string, string> = {}
|
|
289
|
+
for (const file of files) {
|
|
290
|
+
const stamp = regularFileStamp(file)
|
|
291
|
+
if (stamp !== null) stamps[path.relative(work, file)] = stamp
|
|
292
|
+
}
|
|
293
|
+
return stamps
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const binaryFileDigests = new Map<string, { stamp: string; digest: string }>()
|
|
297
|
+
|
|
298
|
+
// clang and swift-frontend are 150-250 MB binaries hashed on every build;
|
|
299
|
+
// cache their digest by stat identity in memory and under the local cache.
|
|
300
|
+
function cachedBinaryFileDigest(file: string): string {
|
|
301
|
+
const real = fs.realpathSync(file)
|
|
302
|
+
const stat = fs.statSync(real, { bigint: true })
|
|
303
|
+
const stamp = `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`
|
|
304
|
+
const memory = binaryFileDigests.get(real)
|
|
305
|
+
if (memory?.stamp === stamp) return memory.digest
|
|
306
|
+
const dir = path.join(cacheDir(), 'swift-binary-digests')
|
|
307
|
+
const record = path.join(dir, `${sha256Hex(real)}.json`)
|
|
308
|
+
if (fs.existsSync(record)) {
|
|
309
|
+
const saved: unknown = JSON.parse(fs.readFileSync(record, 'utf8'))
|
|
310
|
+
if (isRecord(saved) && saved.stamp === stamp && typeof saved.digest === 'string') {
|
|
311
|
+
binaryFileDigests.set(real, { stamp, digest: saved.digest })
|
|
312
|
+
return saved.digest
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
const digest = sha256Hex(fs.readFileSync(real))
|
|
316
|
+
binaryFileDigests.set(real, { stamp, digest })
|
|
317
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
318
|
+
const partial = `${record}.${process.pid}.${randomUUID()}`
|
|
319
|
+
fs.writeFileSync(partial, JSON.stringify({ stamp, digest }))
|
|
320
|
+
fs.renameSync(partial, record)
|
|
321
|
+
return digest
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
type XcodeObjCInputSnapshot =
|
|
325
|
+
ReturnType<typeof xcodeObjCInputSteps> extends Generator<unknown, infer Result>
|
|
326
|
+
? Result
|
|
327
|
+
: never
|
|
328
|
+
|
|
329
|
+
interface CachedObjCInputs {
|
|
330
|
+
readonly binaries: readonly SwiftPackageBinary[]
|
|
331
|
+
readonly moduleRoot: string | null
|
|
332
|
+
readonly products: SwiftXcodeSwiftProducts | undefined
|
|
333
|
+
readonly sourceRoot: string
|
|
334
|
+
readonly snapshot: XcodeObjCInputSnapshot
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const objcInputSnapshots = new WeakMap<XcodeAppTarget, CachedObjCInputs[]>()
|
|
338
|
+
|
|
339
|
+
function cloneObjCInputSnapshot(
|
|
340
|
+
snapshot: XcodeObjCInputSnapshot,
|
|
341
|
+
): XcodeObjCInputSnapshot {
|
|
342
|
+
return {
|
|
343
|
+
sources: new Map(snapshot.sources),
|
|
344
|
+
links: { ...snapshot.links },
|
|
345
|
+
derivations: { ...snapshot.derivations },
|
|
346
|
+
targets: snapshot.targets,
|
|
347
|
+
externalFrameworkDirs: snapshot.externalFrameworkDirs,
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function sameBinaries(
|
|
352
|
+
left: readonly SwiftPackageBinary[],
|
|
353
|
+
right: readonly SwiftPackageBinary[],
|
|
354
|
+
): boolean {
|
|
355
|
+
if (left === right) return true
|
|
356
|
+
if (left.length !== right.length) return false
|
|
357
|
+
for (let i = 0; i < left.length; i++) if (left[i] !== right[i]) return false
|
|
358
|
+
return true
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function cachedObjCInputs(
|
|
362
|
+
app: XcodeAppTarget,
|
|
363
|
+
binaries: readonly SwiftPackageBinary[],
|
|
364
|
+
moduleRoot: string | null,
|
|
365
|
+
products: SwiftXcodeSwiftProducts | undefined,
|
|
366
|
+
sourceRoot: string,
|
|
367
|
+
): XcodeObjCInputSnapshot | undefined {
|
|
368
|
+
const entries = objcInputSnapshots.get(app)
|
|
369
|
+
if (!entries) return undefined
|
|
370
|
+
const hit = entries.find(
|
|
371
|
+
(entry) =>
|
|
372
|
+
entry.moduleRoot === moduleRoot &&
|
|
373
|
+
entry.products === products &&
|
|
374
|
+
entry.sourceRoot === sourceRoot &&
|
|
375
|
+
sameBinaries(entry.binaries, binaries),
|
|
376
|
+
)
|
|
377
|
+
return hit ? cloneObjCInputSnapshot(hit.snapshot) : undefined
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function recordObjCInputs(
|
|
381
|
+
app: XcodeAppTarget,
|
|
382
|
+
binaries: readonly SwiftPackageBinary[],
|
|
383
|
+
moduleRoot: string | null,
|
|
384
|
+
products: SwiftXcodeSwiftProducts | undefined,
|
|
385
|
+
sourceRoot: string,
|
|
386
|
+
snapshot: XcodeObjCInputSnapshot,
|
|
387
|
+
): XcodeObjCInputSnapshot {
|
|
388
|
+
const entries = objcInputSnapshots.get(app) ?? []
|
|
389
|
+
entries.push({
|
|
390
|
+
binaries: [...binaries],
|
|
391
|
+
moduleRoot,
|
|
392
|
+
products,
|
|
393
|
+
sourceRoot,
|
|
394
|
+
snapshot: cloneObjCInputSnapshot(snapshot),
|
|
395
|
+
})
|
|
396
|
+
objcInputSnapshots.set(app, entries)
|
|
397
|
+
return snapshot
|
|
398
|
+
}
|
|
399
|
+
|
|
258
400
|
/** one original source snapshot serves declaration import and implementation compile. */
|
|
259
401
|
export function xcodeObjCInputs(...args: Parameters<typeof xcodeObjCInputSteps>) {
|
|
402
|
+
const [app, binaries, moduleRoot, products, sourceRoot = app.rootDir] = args
|
|
403
|
+
const cached = cachedObjCInputs(app, binaries, moduleRoot, products, sourceRoot)
|
|
404
|
+
if (cached) return cached
|
|
260
405
|
const steps = xcodeObjCInputSteps(...args)
|
|
261
406
|
while (true) {
|
|
262
407
|
const step = steps.next()
|
|
263
|
-
if (step.done)
|
|
408
|
+
if (step.done)
|
|
409
|
+
return recordObjCInputs(app, binaries, moduleRoot, products, sourceRoot, step.value)
|
|
264
410
|
}
|
|
265
411
|
}
|
|
266
412
|
|
|
267
413
|
export async function xcodeObjCInputsAsync(
|
|
268
414
|
...args: Parameters<typeof xcodeObjCInputSteps>
|
|
269
415
|
) {
|
|
416
|
+
const [app, binaries, moduleRoot, products, sourceRoot = app.rootDir] = args
|
|
417
|
+
const cached = cachedObjCInputs(app, binaries, moduleRoot, products, sourceRoot)
|
|
418
|
+
if (cached) return cached
|
|
270
419
|
const steps = xcodeObjCInputSteps(...args)
|
|
271
420
|
await new Promise<void>((resolve) => setImmediate(resolve))
|
|
272
421
|
while (true) {
|
|
273
422
|
const step = steps.next()
|
|
274
|
-
if (step.done)
|
|
423
|
+
if (step.done)
|
|
424
|
+
return recordObjCInputs(app, binaries, moduleRoot, products, sourceRoot, step.value)
|
|
275
425
|
await new Promise<void>((resolve) => setImmediate(resolve))
|
|
276
426
|
}
|
|
277
427
|
}
|
|
@@ -907,8 +1057,7 @@ export function prepareXcodeSwiftProducts(
|
|
|
907
1057
|
const staged = withFrameworkCompanionImports(original)
|
|
908
1058
|
if (staged !== original) sources.set(file, Buffer.from(staged))
|
|
909
1059
|
}
|
|
910
|
-
const digest =
|
|
911
|
-
createHash('sha256').update(bytes).digest('hex')
|
|
1060
|
+
const digest = sha256Hex
|
|
912
1061
|
const providers = new Map<string, string>()
|
|
913
1062
|
for (const target of targets) {
|
|
914
1063
|
if (!supplied.has(target.moduleName)) continue
|
|
@@ -946,7 +1095,7 @@ export function prepareXcodeSwiftProducts(
|
|
|
946
1095
|
version: 5,
|
|
947
1096
|
sdk: swiftModuleSdk(moduleRoot),
|
|
948
1097
|
distribution: swiftCompileSurfaceDigest(moduleRoot).toString('hex'),
|
|
949
|
-
compiler:
|
|
1098
|
+
compiler: cachedBinaryFileDigest(frontend),
|
|
950
1099
|
toolset: digest(fs.readFileSync(toolsetFile)),
|
|
951
1100
|
targets,
|
|
952
1101
|
externalFrameworkDirs,
|
|
@@ -1021,6 +1170,8 @@ export function prepareXcodeSwiftProducts(
|
|
|
1021
1170
|
path.join(preparation.modules, `${target.moduleName}.swiftmodule`),
|
|
1022
1171
|
),
|
|
1023
1172
|
]
|
|
1173
|
+
const stamps =
|
|
1174
|
+
isRecord(retained) && isRecord(retained.stamps) ? retained.stamps : null
|
|
1024
1175
|
if (
|
|
1025
1176
|
isRecord(retained) &&
|
|
1026
1177
|
retained.key === key &&
|
|
@@ -1029,11 +1180,8 @@ export function prepareXcodeSwiftProducts(
|
|
|
1029
1180
|
(file) =>
|
|
1030
1181
|
isRecord(retained.files) && path.relative(work, file) in retained.files,
|
|
1031
1182
|
) &&
|
|
1032
|
-
Object.entries(retained.files).every(
|
|
1033
|
-
(
|
|
1034
|
-
typeof hash === 'string' &&
|
|
1035
|
-
fs.existsSync(path.join(work, file)) &&
|
|
1036
|
-
digest(fs.readFileSync(path.join(work, file))) === hash,
|
|
1183
|
+
Object.entries(retained.files).every(([file, hash]) =>
|
|
1184
|
+
verifyRetainedFile(work, file, hash, stamps),
|
|
1037
1185
|
)
|
|
1038
1186
|
)
|
|
1039
1187
|
return preparation
|
|
@@ -1281,6 +1429,7 @@ export function prepareXcodeSwiftProducts(
|
|
|
1281
1429
|
digest(fs.readFileSync(file)),
|
|
1282
1430
|
]),
|
|
1283
1431
|
),
|
|
1432
|
+
stamps: recordRetainedStamps(work, outputs),
|
|
1284
1433
|
},
|
|
1285
1434
|
null,
|
|
1286
1435
|
2,
|
|
@@ -1325,8 +1474,7 @@ async function prepareXcodeNativeInputs(
|
|
|
1325
1474
|
products,
|
|
1326
1475
|
)
|
|
1327
1476
|
const checkouts = remoteSwiftCheckouts(app.rootDir)
|
|
1328
|
-
const digest =
|
|
1329
|
-
createHash('sha256').update(bytes).digest('hex')
|
|
1477
|
+
const digest = sha256Hex
|
|
1330
1478
|
const inputs = Object.fromEntries(
|
|
1331
1479
|
[...sources].map(([file, bytes]) => [file, digest(bytes)]),
|
|
1332
1480
|
)
|
|
@@ -1348,7 +1496,7 @@ async function prepareXcodeNativeInputs(
|
|
|
1348
1496
|
intake[index] ?? [`invalid-minimum:${deploymentTarget}`],
|
|
1349
1497
|
),
|
|
1350
1498
|
release: toolchain.release,
|
|
1351
|
-
compiler:
|
|
1499
|
+
compiler: cachedBinaryFileDigest(path.join(toolchain.toolchainBin, 'clang')),
|
|
1352
1500
|
sdk: swiftModuleSdk(moduleRoot),
|
|
1353
1501
|
targets,
|
|
1354
1502
|
externalFrameworkDirs,
|
|
@@ -1409,11 +1557,9 @@ async function prepareXcodeNativeInputs(
|
|
|
1409
1557
|
!('receipt.json' in result.files)
|
|
1410
1558
|
)
|
|
1411
1559
|
throw new Error('invalid completed receipt')
|
|
1560
|
+
const stamps = record(result.stamps) ? result.stamps : null
|
|
1412
1561
|
for (const [file, hash] of Object.entries(result.files)) {
|
|
1413
|
-
if (
|
|
1414
|
-
typeof hash !== 'string' ||
|
|
1415
|
-
digest(readPackageFile(work, path.resolve(work, file), Infinity)) !== hash
|
|
1416
|
-
)
|
|
1562
|
+
if (!verifyRetainedFile(work, file, hash, stamps))
|
|
1417
1563
|
throw new Error(`retained file changed: ${file}`)
|
|
1418
1564
|
}
|
|
1419
1565
|
if (result.prepared) {
|
|
@@ -1524,8 +1670,11 @@ async function prepareXcodeNativeInputs(
|
|
|
1524
1670
|
)
|
|
1525
1671
|
const complete = (status: string, message: string, reusable = true): void => {
|
|
1526
1672
|
save(status)
|
|
1527
|
-
const
|
|
1528
|
-
|
|
1673
|
+
const stagedSources = [...sources.keys()].map((file) => ({
|
|
1674
|
+
stagedFile: staged(file),
|
|
1675
|
+
hash: inputs[file]!,
|
|
1676
|
+
}))
|
|
1677
|
+
const generatedFiles = [
|
|
1529
1678
|
...moduleMapFiles,
|
|
1530
1679
|
...headerSearch.files,
|
|
1531
1680
|
receipt,
|
|
@@ -1535,14 +1684,27 @@ async function prepareXcodeNativeInputs(
|
|
|
1535
1684
|
...(command.dependencies ? [command.dependencies] : []),
|
|
1536
1685
|
]),
|
|
1537
1686
|
]
|
|
1687
|
+
const generatedSet = new Set(generatedFiles)
|
|
1688
|
+
const knownHashes = new Map<string, string>()
|
|
1689
|
+
for (const { stagedFile, hash } of stagedSources) {
|
|
1690
|
+
if (!generatedSet.has(stagedFile)) knownHashes.set(stagedFile, hash)
|
|
1691
|
+
}
|
|
1692
|
+
const files = [
|
|
1693
|
+
...stagedSources.map(({ stagedFile }) => stagedFile),
|
|
1694
|
+
...generatedFiles,
|
|
1695
|
+
]
|
|
1538
1696
|
const result = {
|
|
1539
1697
|
key,
|
|
1540
1698
|
message,
|
|
1541
1699
|
reusable,
|
|
1542
1700
|
prepared: status === 'prepared',
|
|
1543
1701
|
files: Object.fromEntries(
|
|
1544
|
-
files.map((file) => [
|
|
1702
|
+
files.map((file) => [
|
|
1703
|
+
path.relative(work, file),
|
|
1704
|
+
knownHashes.get(file) ?? digest(fs.readFileSync(file)),
|
|
1705
|
+
]),
|
|
1545
1706
|
),
|
|
1707
|
+
stamps: recordRetainedStamps(work, files),
|
|
1546
1708
|
}
|
|
1547
1709
|
fs.writeFileSync(`${resultFile}.pending`, JSON.stringify(result, null, 2))
|
|
1548
1710
|
fs.renameSync(`${resultFile}.pending`, resultFile)
|
|
@@ -18,7 +18,6 @@ import path from 'node:path'
|
|
|
18
18
|
import { promisify } from 'node:util'
|
|
19
19
|
import { UNATTENDED_GIT_ENV } from './git-repo-env'
|
|
20
20
|
import { cacheDir as peachCacheDir } from './home-paths'
|
|
21
|
-
import { ensureSwiftToolchain, swiftModuleCompiler } from './swift-distribution'
|
|
22
21
|
import { mapSwiftConditionalLines, swiftCodeScan } from './swift-lexical'
|
|
23
22
|
import { swiftNativePin } from './swift-native-pin'
|
|
24
23
|
import {
|
|
@@ -26,6 +25,7 @@ import {
|
|
|
26
25
|
swiftPackageIdentity,
|
|
27
26
|
type SwiftTargetDependency,
|
|
28
27
|
} from './swift-package'
|
|
28
|
+
import { swiftModuleCompiler } from './swift-sdk-surface'
|
|
29
29
|
import {
|
|
30
30
|
privateSwiftDistributionRoot,
|
|
31
31
|
swiftEnvironment,
|
|
@@ -178,12 +178,13 @@ const array = (value: Json | undefined): Json[] => (Array.isArray(value) ? value
|
|
|
178
178
|
const string = (value: Json | undefined): string | undefined =>
|
|
179
179
|
typeof value === 'string' ? value : undefined
|
|
180
180
|
|
|
181
|
-
function
|
|
181
|
+
export function swiftManifestCommand(): string {
|
|
182
182
|
const privateRoot = privateSwiftDistributionRoot()
|
|
183
183
|
if (privateRoot)
|
|
184
184
|
return path.join(swiftModuleCompiler(privateRoot).toolchainBin, 'swift')
|
|
185
185
|
return path.join(swiftToolchainBin(swiftNativePin().distribution.release), 'swift')
|
|
186
186
|
}
|
|
187
|
+
const swiftCommand = swiftManifestCommand
|
|
187
188
|
|
|
188
189
|
function swiftPackageFailure(error: unknown): string {
|
|
189
190
|
if (!(error instanceof Error)) return String(error)
|
|
@@ -863,7 +864,9 @@ const requirementClause = (item: SwiftRemoteRequirement): string => {
|
|
|
863
864
|
return `.package(url: ${url}, revision: ${JSON.stringify(requirement.revision)})`
|
|
864
865
|
}
|
|
865
866
|
|
|
866
|
-
function
|
|
867
|
+
export function swiftManifestResolveRequest(
|
|
868
|
+
requirements: readonly SwiftRemoteRequirement[],
|
|
869
|
+
) {
|
|
867
870
|
const repository = (url: string) => url.replace(/(?:\.git)?\/?$/, '')
|
|
868
871
|
const chosen = new Map<string, SwiftRemoteRequirement>()
|
|
869
872
|
for (const item of requirements) {
|
|
@@ -930,32 +933,6 @@ let package = Package(
|
|
|
930
933
|
return { dir, args, options, failed, publish }
|
|
931
934
|
}
|
|
932
935
|
|
|
933
|
-
/**
|
|
934
|
-
* resolves remote package requirements with swiftpm, the resolver xcode uses,
|
|
935
|
-
* and writes the graph to `destination` as Package.resolved. a project with
|
|
936
|
-
* no lock does this itself; an existing lock stays authoritative. the locked
|
|
937
|
-
* compiler is installed first, so any host resolves, and the process stays
|
|
938
|
-
* free to serve requests while swiftpm runs.
|
|
939
|
-
*/
|
|
940
|
-
export async function resolveSwiftPackageRequirementsAsync(
|
|
941
|
-
requirements: readonly SwiftRemoteRequirement[],
|
|
942
|
-
destination: string,
|
|
943
|
-
signal?: AbortSignal,
|
|
944
|
-
): Promise<void> {
|
|
945
|
-
await ensureSwiftToolchain(signal)
|
|
946
|
-
const { dir, args, options, failed, publish } = resolveRequest(requirements)
|
|
947
|
-
try {
|
|
948
|
-
try {
|
|
949
|
-
await promisify(execFile)(swiftCommand(), args, { ...options, signal })
|
|
950
|
-
} catch (error) {
|
|
951
|
-
throw failed(error)
|
|
952
|
-
}
|
|
953
|
-
publish(destination)
|
|
954
|
-
} finally {
|
|
955
|
-
fs.rmSync(dir, { recursive: true, force: true })
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
|
|
959
936
|
/** original resource bytes are independent of the target's explicit sources. */
|
|
960
937
|
export function swiftTargetResourceFiles(
|
|
961
938
|
manifest: SwiftPackageManifest,
|
package/src/swift-packages.ts
CHANGED
|
@@ -10,17 +10,14 @@
|
|
|
10
10
|
// compile.
|
|
11
11
|
|
|
12
12
|
import { execFile } from 'node:child_process'
|
|
13
|
-
import { createHash } from 'node:crypto'
|
|
14
13
|
import fs from 'node:fs'
|
|
15
14
|
import path from 'node:path'
|
|
16
15
|
import { setTimeout as sleep } from 'node:timers/promises'
|
|
17
16
|
import { promisify } from 'node:util'
|
|
18
17
|
import { UNATTENDED_GIT_ENV, withoutGitRepositoryEnv } from './git-repo-env'
|
|
19
|
-
import { cacheDir } from './home-paths'
|
|
20
18
|
import { requireNativeGit } from './native-git'
|
|
21
19
|
import { tryAcquireNumberedLock } from './numbered-lock'
|
|
22
20
|
import { buildRiveRuntimeDependencies } from './rive-runtime-dependencies'
|
|
23
|
-
import { swiftCTakesReturnAddress } from './swift-compile'
|
|
24
21
|
import {
|
|
25
22
|
isSwiftNativeTranslationUnit,
|
|
26
23
|
swiftImplicitResourcePaths,
|
|
@@ -38,6 +35,11 @@ import {
|
|
|
38
35
|
type SwiftManifestTarget,
|
|
39
36
|
type SwiftPackageManifest,
|
|
40
37
|
} from './swift-package-manifest'
|
|
38
|
+
import {
|
|
39
|
+
remoteSwiftCheckouts,
|
|
40
|
+
swiftBinaryOnDisk,
|
|
41
|
+
swiftCTakesReturnAddress,
|
|
42
|
+
} from './swift-sdk-surface'
|
|
41
43
|
import { shippedBinaryDiffers } from './swift-shipped-binaries'
|
|
42
44
|
import type { GenruleArchiveDeclaration } from './genrule-archives'
|
|
43
45
|
import type { SwiftSourceLinkGraph } from './swiftContract'
|
|
@@ -167,8 +169,7 @@ export interface SwiftPackageBinary {
|
|
|
167
169
|
moduleSources?: { sources: string[]; flags: string[]; resources: boolean }
|
|
168
170
|
}
|
|
169
171
|
|
|
170
|
-
export
|
|
171
|
-
binary.url !== null || fs.existsSync(binary.dir)
|
|
172
|
+
export { remoteSwiftCheckouts, swiftBinaryOnDisk }
|
|
172
173
|
|
|
173
174
|
// sdks that send telemetry, by package identity, that peach's swift cannot
|
|
174
175
|
// compile yet, each with the compiler gap that forces it. their swift targets
|
|
@@ -236,15 +237,6 @@ const sourceFrameworkRecipes = new Map<
|
|
|
236
237
|
])
|
|
237
238
|
|
|
238
239
|
/** dependency checkouts belong to peach, isolated by the canonical app root. */
|
|
239
|
-
export function remoteSwiftCheckouts(root: string): string {
|
|
240
|
-
const key = createHash('sha256')
|
|
241
|
-
.update(fs.realpathSync(root))
|
|
242
|
-
.digest('hex')
|
|
243
|
-
.slice(0, 32)
|
|
244
|
-
fs.mkdirSync(cacheDir(), { recursive: true })
|
|
245
|
-
return path.join(fs.realpathSync(cacheDir()), 'swift-packages', key, 'checkouts')
|
|
246
|
-
}
|
|
247
|
-
|
|
248
240
|
// assembly requires its own target lowering; objective-c keeps its original bodies.
|
|
249
241
|
const UNSUPPORTED_NATIVE = /\.(s|S)$/
|
|
250
242
|
|