peachsim 0.1.2690 → 0.1.2691

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.
Files changed (124) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/attached-projects.cjs +1 -1
  4. package/dist-lib/auth/shared-session.cjs +1 -1
  5. package/dist-lib/backend-origin.cjs +1 -1
  6. package/dist-lib/beta.cjs +1 -1
  7. package/dist-lib/beta.mjs +2 -2
  8. package/dist-lib/bridge-constants.cjs +1 -1
  9. package/dist-lib/bridge-contract-input.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.mjs +5 -5
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +3 -3
  13. package/dist-lib/bundle-channel.cjs +154 -128
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +3 -3
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +3 -3
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +2 -2
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +7 -7
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +5 -5
  24. package/dist-lib/detox/index.cjs +1 -1
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-7NECUOQL.mjs → acorn-FRAAGSQN.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-YA25KY54.mjs → chunk-3P3T6XDR.mjs} +1 -1
  28. package/dist-lib/esm-chunks/{chunk-CE4CI5FU.mjs → chunk-677F6CA3.mjs} +3 -3
  29. package/dist-lib/esm-chunks/{chunk-ZK3YJNAA.mjs → chunk-6Y4USKQV.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-RPH46F3J.mjs → chunk-GHEIKIKL.mjs} +3 -16
  31. package/dist-lib/esm-chunks/{chunk-HOVIMQVO.mjs → chunk-GLMVKIM6.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-SMUFAUA2.mjs → chunk-GN3IKMG6.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-VVJ4B44L.mjs → chunk-HDZZNHQA.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-ID74LXQF.mjs → chunk-JAWBF6H2.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-GR7CUPIC.mjs → chunk-KBD22EMH.mjs} +4 -4
  36. package/dist-lib/esm-chunks/{chunk-AGEHGE4W.mjs → chunk-LDYW2OW2.mjs} +5 -5
  37. package/dist-lib/esm-chunks/{chunk-VT3KFJLL.mjs → chunk-NZXLU5VV.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-5PMTWOLF.mjs → chunk-O63LOL3D.mjs} +6 -6
  39. package/dist-lib/esm-chunks/{chunk-ZFE3NYDB.mjs → chunk-OIYXX7IL.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-TGZK7Q33.mjs → chunk-Q6JOJQEF.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-T6GYFGP3.mjs → chunk-QUF75PSG.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-TKDSXDNO.mjs → chunk-R2Y3VVPG.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-MYSQV4YK.mjs → chunk-RDBWKQEO.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-7P2EJJFY.mjs → chunk-SNPB7L3I.mjs} +140 -103
  45. package/dist-lib/esm-chunks/{chunk-OFJYTZNL.mjs → chunk-SWFEY33A.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-VZW3Z5J3.mjs → chunk-VGERVNUM.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-LO7HH7BH.mjs → chunk-WTQRJ7GJ.mjs} +6 -6
  48. package/dist-lib/esm-chunks/{chunk-2C4HDS5K.mjs → chunk-Y4AEL73Z.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{chunk-CZOPH62Q.mjs → chunk-Z6OSVLDH.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-SJQMU53M.mjs → chunk-ZPKIEF24.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{metro-layout-parser-P5M3VLPS.mjs → metro-layout-parser-6OLSOOML.mjs} +3 -3
  52. package/dist-lib/esm-chunks/{swift-package-prebuilt-LDSEGNPH.mjs → swift-package-prebuilt-5JCJ24DB.mjs} +12 -12
  53. package/dist-lib/esm-chunks/{swift-sdk-app-module-OCQEJPVW.mjs → swift-sdk-app-module-ZIJDA775.mjs} +16 -16
  54. package/dist-lib/esm-chunks/{swift-sdk-image-HCOK3M44.mjs → swift-sdk-image-JSEDATID.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-producer-M3LWXZRI.mjs → swift-sdk-image-producer-MPF3H7PU.mjs} +5 -5
  56. package/dist-lib/expo-swift-bundle.cjs +144 -118
  57. package/dist-lib/expo-swift-metadata.cjs +1 -1
  58. package/dist-lib/expo-swift-metadata.mjs +7 -7
  59. package/dist-lib/home-paths.cjs +1 -1
  60. package/dist-lib/host/bridge-host.cjs +161 -136
  61. package/dist-lib/host/fetch-proxy-handler.cjs +28 -27
  62. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  63. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  64. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  65. package/dist-lib/host/websocket-proxy.cjs +1 -1
  66. package/dist-lib/index.cjs +1 -1
  67. package/dist-lib/kotlin-host.cjs +1 -1
  68. package/dist-lib/menu.cjs +1 -1
  69. package/dist-lib/menu.mjs +3 -3
  70. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  71. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  72. package/dist-lib/metro-production-bundle.cjs +1 -1
  73. package/dist-lib/metro-production-bundle.mjs +4 -4
  74. package/dist-lib/native-app-identity-project.cjs +1 -1
  75. package/dist-lib/native-app-identity-project.mjs +15 -15
  76. package/dist-lib/native-app-identity.cjs +1 -1
  77. package/dist-lib/native-app-identity.mjs +6 -6
  78. package/dist-lib/native-firebase-metadata.cjs +1 -1
  79. package/dist-lib/native-firebase-metadata.mjs +3 -3
  80. package/dist-lib/pdfium-raster.cjs +1 -1
  81. package/dist-lib/pdfium-raster.mjs +2 -2
  82. package/dist-lib/plist.cjs +1 -1
  83. package/dist-lib/plist.mjs +3 -3
  84. package/dist-lib/profiles.cjs +1 -1
  85. package/dist-lib/public-brand.cjs +1 -1
  86. package/dist-lib/public-origins-lib-esm.json +85 -85
  87. package/dist-lib/public-origins-lib.json +64 -64
  88. package/dist-lib/react-native-host-modules.cjs +1 -1
  89. package/dist-lib/react-native-host-modules.mjs +2 -2
  90. package/dist-lib/reap-browser.cjs +1 -1
  91. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  92. package/dist-lib/sdk.cjs +1 -1
  93. package/dist-lib/sdk.mjs +8 -8
  94. package/dist-lib/skills.cjs +165 -140
  95. package/dist-lib/swift-compile.cjs +129 -103
  96. package/dist-lib/swift-compile.mjs +12 -12
  97. package/dist-lib/swift-package.cjs +1 -1
  98. package/dist-lib/swift-package.mjs +3 -3
  99. package/dist-lib/swift-submit.cjs +1 -1
  100. package/dist-lib/swift-submit.mjs +6 -6
  101. package/dist-lib/swift-svg-raster.cjs +1 -1
  102. package/dist-lib/swift-svg-raster.mjs +2 -2
  103. package/dist-lib/swift-toolchain.cjs +1 -1
  104. package/dist-lib/swift.cjs +1 -1
  105. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  106. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  107. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  108. package/dist-lib/vendor/acorn.cjs +1 -1
  109. package/dist-lib/vendor/magic-string.cjs +1 -1
  110. package/dist-lib/vendor/stream-json.cjs +1 -1
  111. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  112. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  113. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase.cjs +1 -1
  116. package/dist-lib/vendor/terser.cjs +1 -1
  117. package/dist-lib/vendor/valibot.cjs +1 -1
  118. package/dist-lib/vendor/ws.cjs +1 -1
  119. package/dist-lib/vendor/zod.cjs +1 -1
  120. package/dist-lib/worklet-executable.cjs +1 -1
  121. package/dist-lib/worklet-executable.mjs +3 -3
  122. package/package.json +1 -1
  123. package/src/swift-compile.ts +139 -95
  124. package/src/swift-root-lock.ts +1 -16
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2690 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2691 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,12 +1,12 @@
1
- /*! peach v0.1.2690 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2691 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  import {
3
3
  parse
4
- } from "./esm-chunks/chunk-HOVIMQVO.mjs";
4
+ } from "./esm-chunks/chunk-GLMVKIM6.mjs";
5
5
  import {
6
6
  __privateAdd,
7
7
  __privateGet,
8
8
  __publicField
9
- } from "./esm-chunks/chunk-2C4HDS5K.mjs";
9
+ } from "./esm-chunks/chunk-Y4AEL73Z.mjs";
10
10
 
11
11
  // src/worklet-kernel.ts
12
12
  var Unsupported = class extends Error {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peachsim",
3
- "version": "0.1.2690",
3
+ "version": "0.1.2691",
4
4
  "description": "Vite and Metro plugins, testing drivers, and SDK exports for peach.",
5
5
  "author": "Tamagui LLC",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -21,6 +21,7 @@ import {
21
21
  } from 'node:fs'
22
22
  import os from 'node:os'
23
23
  import path from 'node:path'
24
+ import { setTimeout as delay } from 'node:timers/promises'
24
25
  import * as v from 'valibot'
25
26
  import { windowAdmission } from './admitted-mac-build'
26
27
  import cPredefinesJson from './generated/swift-c-predefines.json' with { type: 'json' }
@@ -121,7 +122,6 @@ import {
121
122
  acquireSwiftRootReadHold,
122
123
  hasLiveSwiftRootReaders,
123
124
  retainSwiftRootReadHold,
124
- waitForNoSwiftRootReaders,
125
125
  withSwiftRootLock,
126
126
  type SwiftRootLease,
127
127
  type SwiftRootReadHold,
@@ -6349,7 +6349,8 @@ function readFrameworkProductsReceipt(
6349
6349
  async function buildFrameworkProducts(
6350
6350
  scratch: string,
6351
6351
  args: FrameworkBuildArgs,
6352
- ): Promise<SwiftFrameworkProducts> {
6352
+ allowWrite: boolean,
6353
+ ): Promise<SwiftFrameworkProducts | undefined> {
6353
6354
  const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input)
6354
6355
  const unoptimized = args.input.unoptimized === true
6355
6356
  const sdkOptions = swiftCompileSdkOptions(args.moduleRoot, args.toolchainBin)
@@ -6373,7 +6374,7 @@ async function buildFrameworkProducts(
6373
6374
  .slice(0, 32)
6374
6375
  const ready = readFrameworkProductsReceipt(scratch, receiptKey)
6375
6376
  if (ready) return ready
6376
- await waitForNoSwiftRootReaders(scratch, args.buildOptions.signal)
6377
+ if (!allowWrite) return
6377
6378
 
6378
6379
  const linkRoot = path.join(scratch, 'link')
6379
6380
  writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products)
@@ -6669,7 +6670,11 @@ async function withSwiftFrameworkSlot<T>(
6669
6670
  release: string,
6670
6671
  moduleRoot: string,
6671
6672
  signal: AbortSignal | undefined,
6672
- work: (slot: string, lease: SwiftRootLease) => Promise<T>,
6673
+ work: (
6674
+ slot: string,
6675
+ lease: SwiftRootLease,
6676
+ allowWrite: boolean,
6677
+ ) => Promise<T | undefined>,
6673
6678
  unoptimized = false,
6674
6679
  ): Promise<T> {
6675
6680
  const slotCount = unoptimized
@@ -6681,14 +6686,40 @@ async function withSwiftFrameworkSlot<T>(
6681
6686
  mkdirSync(slot, { recursive: true })
6682
6687
  return slot
6683
6688
  })
6684
- const run = (slot: string) => (lease: SwiftRootLease) => {
6685
- // an incremental build leaves the directory's own mtime alone, which orders reuse
6686
- const now = new Date()
6687
- utimesSync(slot, now, now)
6688
- return work(slot, lease)
6689
+ const trySlot = (
6690
+ slot: string,
6691
+ mode: 'reuse' | 'extend' | 'restage',
6692
+ logSelection?: () => void,
6693
+ ) => {
6694
+ return withSwiftRootLock(
6695
+ slot,
6696
+ async (lease) => {
6697
+ const matches = swiftFrameworkSlotKey(slot) === frameworkKey
6698
+ if (mode !== 'restage' && !matches) return
6699
+ const allowWrite = mode !== 'reuse'
6700
+ if (allowWrite && (await hasLiveSwiftRootReaders(slot, signal))) return
6701
+ if (!matches) logSelection?.()
6702
+ const value = await work(slot, lease, allowWrite)
6703
+ if (value === undefined) return
6704
+ const now = new Date()
6705
+ utimesSync(slot, now, now)
6706
+ return { value }
6707
+ },
6708
+ signal,
6709
+ false,
6710
+ )
6711
+ }
6712
+ const tryExactSlots = async () => {
6713
+ const matching = slots.filter((slot) => swiftFrameworkSlotKey(slot) === frameworkKey)
6714
+ for (const mode of ['reuse', 'extend'] satisfies ('reuse' | 'extend')[]) {
6715
+ for (const slot of matching) {
6716
+ const result = await trySlot(slot, mode)
6717
+ if (result) return result
6718
+ }
6719
+ }
6689
6720
  }
6690
- const staged = slots.find((slot) => swiftFrameworkSlotKey(slot) === frameworkKey)
6691
- if (staged) return withSwiftRootLock(staged, run(staged), signal)
6721
+ const ready = await tryExactSlots()
6722
+ if (ready) return ready.value
6692
6723
  const built = new Map(slots.map((slot) => [slot, statSync(slot).mtimeMs]))
6693
6724
  const own = (slot: string) =>
6694
6725
  swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN) === moduleRoot
@@ -6737,24 +6768,28 @@ async function withSwiftFrameworkSlot<T>(
6737
6768
  if (left.tier === 1) return left.index - right.index
6738
6769
  return (built.get(left.slot) ?? 0) - (built.get(right.slot) ?? 0)
6739
6770
  })
6740
- for (const { slot, tier, changes } of ranked) {
6741
- if (await hasLiveSwiftRootReaders(slot, signal)) continue
6742
- const result = await withSwiftRootLock(
6743
- slot,
6744
- async (lease) => {
6745
- if (await hasLiveSwiftRootReaders(slot, signal)) return undefined
6771
+ let announced = false
6772
+ for (;;) {
6773
+ signal?.throwIfAborted()
6774
+ for (const { slot, tier, changes } of ranked) {
6775
+ if (swiftFrameworkSlotKey(slot) === frameworkKey) continue
6776
+ const result = await trySlot(slot, 'restage', () => {
6746
6777
  console.error(
6747
6778
  `[swift-framework-cache] ${path.basename(slot)} release=${release} tier=${tier} changedInputs=${changes} totalInputs=${inputs.size}`,
6748
6779
  )
6749
- return { value: await run(slot)(lease) }
6750
- },
6751
- signal,
6752
- false,
6753
- )
6754
- if (result) return result.value
6780
+ })
6781
+ if (result) return result.value
6782
+ }
6783
+ if (!announced) {
6784
+ console.error(
6785
+ `[swift-framework-cache] waiting for an available slot in ${slotsDir}`,
6786
+ )
6787
+ announced = true
6788
+ }
6789
+ await delay(1_000, undefined, { signal })
6790
+ const ready = await tryExactSlots()
6791
+ if (ready) return ready.value
6755
6792
  }
6756
- const nearest = ranked[0]!.slot
6757
- return withSwiftRootLock(nearest, run(nearest), signal)
6758
6793
  }
6759
6794
 
6760
6795
  // normalized shared build roots (such as OneNativeControls) serve concurrent
@@ -7173,36 +7208,34 @@ async function compileSwiftProjectOnce(
7173
7208
  waitedMs: number,
7174
7209
  ) => Promise<SwiftCompileArtifact | void>,
7175
7210
  ) => {
7176
- if (canPoolBuildRoot) {
7177
- mkdirSync(sharedRoot, { recursive: true })
7211
+ const runInBuildRoot = () => {
7212
+ if (canPoolBuildRoot)
7213
+ return withSwiftBuildRootSlot(
7214
+ baseRoot,
7215
+ exactShape,
7216
+ compatShape,
7217
+ budget.signal,
7218
+ work,
7219
+ )
7220
+ const waitStart = Date.now()
7178
7221
  return withSwiftRootLock(
7179
- sharedRoot,
7180
- async () => {
7181
- // a concurrent caller with the exact same hash may have finished
7182
- // while we waited on sharedRoot; return before touching any slot.
7183
- const built = readCompiledArtifact(
7184
- path.join(sharedRoot, 'artifact'),
7185
- hash,
7186
- )
7187
- if (built) {
7188
- stage('reusing verified disk artifact')
7189
- return retain(baseRoot, built)
7190
- }
7191
- return withSwiftBuildRootSlot(
7192
- baseRoot,
7193
- exactShape,
7194
- compatShape,
7195
- budget.signal,
7196
- work,
7197
- )
7198
- },
7222
+ baseRoot,
7223
+ (lease) => work(baseRoot, lease, Date.now() - waitStart),
7199
7224
  budget.signal,
7200
7225
  )
7201
7226
  }
7202
- const waitStart = Date.now()
7227
+ if (options.intermediates || baseRoot === sharedRoot) return runInBuildRoot()
7203
7228
  return withSwiftRootLock(
7204
- baseRoot,
7205
- (lease) => work(baseRoot, lease, Date.now() - waitStart),
7229
+ sharedRoot,
7230
+ async () => {
7231
+ const built = readCompiledArtifact(path.join(sharedRoot, 'artifact'), hash)
7232
+ if (built) {
7233
+ renewSharedArtifact(sharedRoot)
7234
+ stage('reusing verified disk artifact')
7235
+ return retain(baseRoot, built)
7236
+ }
7237
+ return runInBuildRoot()
7238
+ },
7206
7239
  budget.signal,
7207
7240
  )
7208
7241
  }
@@ -7236,19 +7269,6 @@ async function compileSwiftProjectOnce(
7236
7269
  }
7237
7270
  // a distribution's immutable modules and host plugins need no source build.
7238
7271
  const unoptimized = input.unoptimized === true
7239
- const withFrameworkLock = <T>(
7240
- work: (slot: string | null, frameworkLease?: SwiftRootLease) => Promise<T>,
7241
- ) =>
7242
- distribution
7243
- ? work(null)
7244
- : withSwiftFrameworkSlot(
7245
- frameworkKey,
7246
- options.release,
7247
- moduleRoot,
7248
- budget.signal,
7249
- work,
7250
- unoptimized,
7251
- )
7252
7272
  const baseBuildEnv = options.project?.env
7253
7273
  ? {
7254
7274
  ...options.project.env,
@@ -7271,18 +7291,12 @@ async function compileSwiftProjectOnce(
7271
7291
  // building framework products; take a shared read hold before
7272
7292
  // releasing it so other builds on the same framework revision
7273
7293
  // compile and link their apps concurrently.
7274
- const {
7275
- frameworkRoot,
7276
- compileFrameworkRoot,
7277
- macroPlugins,
7278
- sdk,
7279
- icu,
7280
- prebuilt,
7281
- readHold: frameworkReadHold,
7282
- } = await withFrameworkLock(async (slot, frameworkLease) => {
7283
- budget.startCompile()
7284
- if (slot && swiftFrameworkSlotKey(slot) !== frameworkKey)
7285
- await waitForNoSwiftRootReaders(slot, budget.signal)
7294
+ const prepareFrameworks = async (
7295
+ slot: string | null,
7296
+ frameworkLease?: SwiftRootLease,
7297
+ allowWrite = true,
7298
+ ) => {
7299
+ if (allowWrite) budget.startCompile()
7286
7300
  // project users own their build roots; resolve their sdk outside them.
7287
7301
  const frameworkRoot = mirrorDistribution
7288
7302
  ? syncSwiftDistributionMirror(root, moduleRoot, mirrorDistribution)
@@ -7291,7 +7305,8 @@ async function compileSwiftProjectOnce(
7291
7305
  : stageFrameworkSource(moduleRoot, slot, frameworkKey, options.release)
7292
7306
  if (!swiftModuleDigest(frameworkRoot).equals(moduleDigest))
7293
7307
  throw new Error('Swift staged project source differs from the caller')
7294
- stage('preparing compiler plugins')
7308
+ if (!allowWrite && swiftMacroPlugins(frameworkRoot).stale) return
7309
+ if (allowWrite) stage('preparing compiler plugins')
7295
7310
  const macroPlugins = await ensureMacroPlugins(
7296
7311
  frameworkRoot,
7297
7312
  options.toolchainBin,
@@ -7308,24 +7323,33 @@ async function compileSwiftProjectOnce(
7308
7323
  const icu = options.linkOnly ? null : swiftIcuAsset(options.toolchainBin, sdk)
7309
7324
  let prebuilt: SwiftFrameworkProducts | undefined
7310
7325
  if (!distribution) {
7311
- stage('compiling framework products')
7312
- prebuilt = await buildFrameworkProducts(slot!, {
7313
- moduleRoot: frameworkRoot,
7314
- frameworkKey,
7315
- input,
7316
- swift,
7317
- sdk,
7318
- toolchainBin: options.toolchainBin,
7319
- plugins: macroPlugins,
7320
- buildOptions: {
7321
- env: baseBuildEnv,
7322
- maxBuffer: 64 * 1024 * 1024,
7323
- signal: budget.signal,
7324
- onOutput: budget.progress,
7325
- lease,
7326
- frameworkLease,
7326
+ if (allowWrite) stage('compiling framework products')
7327
+ prebuilt = await buildFrameworkProducts(
7328
+ slot!,
7329
+ {
7330
+ moduleRoot: frameworkRoot,
7331
+ frameworkKey,
7332
+ input,
7333
+ swift,
7334
+ sdk,
7335
+ toolchainBin: options.toolchainBin,
7336
+ plugins: macroPlugins,
7337
+ buildOptions: {
7338
+ env: baseBuildEnv,
7339
+ maxBuffer: 64 * 1024 * 1024,
7340
+ signal: budget.signal,
7341
+ onOutput: budget.progress,
7342
+ lease,
7343
+ frameworkLease,
7344
+ },
7327
7345
  },
7328
- })
7346
+ allowWrite,
7347
+ )
7348
+ if (!prebuilt) return
7349
+ if (!allowWrite) {
7350
+ budget.startCompile()
7351
+ stage('reusing verified framework products')
7352
+ }
7329
7353
  }
7330
7354
  const readHold: SwiftRootReadHold | undefined = slot
7331
7355
  ? acquireSwiftRootReadHold(slot)
@@ -7339,8 +7363,28 @@ async function compileSwiftProjectOnce(
7339
7363
  prebuilt,
7340
7364
  readHold,
7341
7365
  }
7342
- })
7343
- let readHold = frameworkReadHold
7366
+ }
7367
+ const frameworks = distribution
7368
+ ? await prepareFrameworks(null)
7369
+ : await withSwiftFrameworkSlot(
7370
+ frameworkKey,
7371
+ options.release,
7372
+ moduleRoot,
7373
+ budget.signal,
7374
+ prepareFrameworks,
7375
+ unoptimized,
7376
+ )
7377
+ if (!frameworks)
7378
+ throw new Error('Swift distribution did not provide its frameworks')
7379
+ const {
7380
+ frameworkRoot,
7381
+ compileFrameworkRoot,
7382
+ macroPlugins,
7383
+ sdk,
7384
+ icu,
7385
+ prebuilt,
7386
+ } = frameworks
7387
+ let readHold = frameworks.readHold
7344
7388
  const buildOptions = {
7345
7389
  env: baseBuildEnv,
7346
7390
  maxBuffer: 64 * 1024 * 1024,
@@ -322,21 +322,6 @@ export async function hasLiveSwiftRootReaders(
322
322
  return false
323
323
  }
324
324
 
325
- export async function waitForNoSwiftRootReaders(
326
- root: string,
327
- signal?: AbortSignal,
328
- ): Promise<void> {
329
- let announced = false
330
- while (await hasLiveSwiftRootReaders(root, signal)) {
331
- signal?.throwIfAborted()
332
- if (!announced) {
333
- announced = true
334
- process.stderr.write(`[swift-root-lock] waiting for readers of ${root}\n`)
335
- }
336
- await pause(POLL_MS, signal)
337
- }
338
- }
339
-
340
325
  export async function withSwiftRootLock<T>(
341
326
  root: string,
342
327
  work: (lease: SwiftRootLease) => Promise<T>,
@@ -392,11 +377,11 @@ export async function withSwiftRootLock<T>(
392
377
  const table = await processTableWithRetry(undefined, signal)
393
378
  const orphaned = children.filter((child) => groupAlive(table, child))
394
379
  if (orphaned.length) {
395
- if (!wait) return undefined
396
380
  // nothing reads a dead holder's compiler output, so its groups only
397
381
  // keep the root from the next build. the root stays held until they
398
382
  // are gone, and a group that refuses the kill keeps it held.
399
383
  for (const child of orphaned) killOrphanedProcessGroup(child.pid)
384
+ if (!wait) return undefined
400
385
  await waiting(
401
386
  `stopping compiler groups ${orphaned.map((child) => child.pid).join(', ')} left by dead pid ${identity.pid}`,
402
387
  )