peachsim 0.1.2793 → 0.1.2795

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 (137) 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 +1183 -1003
  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 +2 -2
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-Q5VJTSKK.mjs → acorn-75V3OBXH.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-TADAJDSF.mjs → chunk-2RTQFMA3.mjs} +1 -1
  28. package/dist-lib/esm-chunks/{chunk-PTIDPELK.mjs → chunk-3E4ZLMXW.mjs} +2 -2
  29. package/dist-lib/esm-chunks/{chunk-JMR6F3DC.mjs → chunk-5DDUQYBY.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-COIKWBXT.mjs → chunk-ASMHH2QN.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-4P3IOCZK.mjs → chunk-ATM3HZDR.mjs} +5 -5
  32. package/dist-lib/esm-chunks/{chunk-YEBPOLJT.mjs → chunk-B5Q2MKHJ.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-GVQYPMGV.mjs → chunk-BMIH6S26.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-6YRIQX2Q.mjs → chunk-CZCT5EAJ.mjs} +3 -3
  35. package/dist-lib/esm-chunks/{chunk-BEO5Q2GJ.mjs → chunk-DGXGBF5N.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-RVJCN7O6.mjs → chunk-DJXJO7YZ.mjs} +64 -21
  37. package/dist-lib/esm-chunks/{chunk-U23E4H6F.mjs → chunk-F4G4DEEZ.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-ELHDFPTV.mjs → chunk-JKYNP3NX.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-6LTBRJF4.mjs → chunk-JMGRUOXY.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-XCBOY63C.mjs → chunk-K2ZBCAZ5.mjs} +4 -4
  41. package/dist-lib/esm-chunks/{chunk-SCUA4P4G.mjs → chunk-KJEDFVG6.mjs} +1116 -1056
  42. package/dist-lib/esm-chunks/{chunk-TS7JWC6Z.mjs → chunk-LQQMXMCV.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-5LYBGU62.mjs → chunk-MNBUUJ2A.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-6HQZNAEU.mjs → chunk-N5O5BB3F.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-A2KA5HK7.mjs → chunk-OOXCOL63.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-SSZA5C37.mjs → chunk-PHBFU273.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-SQ3UKGNC.mjs → chunk-QRW6R5HX.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-2V3WPUVP.mjs → chunk-RHM2LED4.mjs} +6 -6
  49. package/dist-lib/esm-chunks/{chunk-NMSKAQXB.mjs → chunk-US5W76OK.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-ZU4TTBLM.mjs → chunk-UV2BL5ZA.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{metro-layout-parser-26WDQMLR.mjs → metro-layout-parser-72VRHWZM.mjs} +3 -3
  52. package/dist-lib/esm-chunks/{swift-package-prebuilt-DOKKJSSS.mjs → swift-package-prebuilt-ZOQMKNDR.mjs} +16 -13
  53. package/dist-lib/esm-chunks/{swift-sdk-app-module-I4OZ7CGZ.mjs → swift-sdk-app-module-XC4QIMOI.mjs} +16 -16
  54. package/dist-lib/esm-chunks/{swift-sdk-image-IPXHOUXE.mjs → swift-sdk-image-P5NS5P7F.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-producer-6P6QZQGS.mjs → swift-sdk-image-producer-7VTOFOND.mjs} +5 -5
  56. package/dist-lib/expo-swift-bundle.cjs +1124 -944
  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 +3768 -3462
  61. package/dist-lib/host/fetch-proxy-handler.cjs +122 -118
  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 +3 -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 +46 -27
  81. package/dist-lib/pdfium-raster.mjs +47 -28
  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 +87 -86
  87. package/dist-lib/public-origins-lib.json +79 -77
  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 +2061 -1747
  95. package/dist-lib/swift-compile.cjs +1056 -963
  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/dist-types/packages/peach-engine/core-abi/style/style-field-hash.d.ts +1 -1
  123. package/dist-types/packages/peach-engine/src/engine/scene-native-binding.d.ts +2 -2
  124. package/dist-types/packages/peach-engine/src/render-worker/native-hot-ops.d.ts +4 -4
  125. package/dist-types/packages/peach-engine/src/render-worker/scene-packet-feed.d.ts +2 -0
  126. package/dist-types/packages/peach-globals/src/fnv1a.d.ts +4 -0
  127. package/package.json +1 -1
  128. package/runtime-companion.json +1 -1
  129. package/src/expo-swift-host.ts +31 -9
  130. package/src/one-native-controls-package.ts +56 -54
  131. package/src/pdfium-raster.ts +1 -58
  132. package/src/swift-compile.ts +1029 -963
  133. package/src/swift-compiler-digest.ts +79 -4
  134. package/src/swift-host.ts +246 -91
  135. package/src/swift-package-prebuilt.ts +6 -3
  136. package/src/swift-sdk-surface.ts +75 -20
  137. package/src/swift-startup-split.ts +134 -12
@@ -1,10 +1,10 @@
1
- /*! peach v0.1.2793 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2795 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  import {
3
3
  acquireSwiftRootReadHold,
4
4
  hasLiveSwiftRootReaders,
5
5
  retainSwiftRootReadHold,
6
6
  withSwiftRootLock
7
- } from "./chunk-PTIDPELK.mjs";
7
+ } from "./chunk-3E4ZLMXW.mjs";
8
8
  import {
9
9
  CORE_FOUNDATION_OVERLAY_GLOBALS,
10
10
  NATIVE_GRAPH_SDK_VERSION,
@@ -18,6 +18,7 @@ import {
18
18
  caseInsensitiveHeaderOverlay,
19
19
  clangInterfaceHeader,
20
20
  clearCaseInsensitiveHeaderOverlayCache,
21
+ clearSwiftModuleDigestScope,
21
22
  clearSwiftSdkPathsCache,
22
23
  emptyMacroEnvironment,
23
24
  encodeWasmName,
@@ -64,10 +65,11 @@ import {
64
65
  wasmSections,
65
66
  weakenFoundationOverridesInArchive,
66
67
  withFrameworkCompanionImports,
68
+ withSwiftModuleDigestScope,
67
69
  withoutImportedSdkEnumForwards,
68
70
  withoutSwiftDeclarations,
69
71
  writeBuildFile
70
- } from "./chunk-RVJCN7O6.mjs";
72
+ } from "./chunk-DJXJO7YZ.mjs";
71
73
  import {
72
74
  SWIFT_AUTOLINK_LINKER,
73
75
  SWIFT_CACHE_HOLD_MARKER,
@@ -84,7 +86,7 @@ import {
84
86
  wasmThreadLinkFlags,
85
87
  windowAdmission,
86
88
  writeSwiftAutolinkLinker
87
- } from "./chunk-A2KA5HK7.mjs";
89
+ } from "./chunk-OOXCOL63.mjs";
88
90
  import {
89
91
  SWIFT_BINARY_TREES_DIR,
90
92
  SWIFT_NATIVE_INPUT_ROOT,
@@ -99,7 +101,7 @@ import {
99
101
  isSwiftResourcePath,
100
102
  isSwiftSourceLinkGraph,
101
103
  swiftProjectFilesProblems
102
- } from "./chunk-JMR6F3DC.mjs";
104
+ } from "./chunk-5DDUQYBY.mjs";
103
105
  import {
104
106
  OBJC_RESOURCE_ACCESSOR_BODY,
105
107
  OBJC_RESOURCE_ACCESSOR_HEADER,
@@ -122,43 +124,43 @@ import {
122
124
  swiftPackagePartition,
123
125
  swiftTargetModuleName,
124
126
  withoutGlogModuleMap
125
- } from "./chunk-COIKWBXT.mjs";
127
+ } from "./chunk-ASMHH2QN.mjs";
126
128
  import {
127
129
  rnxPublicBrand
128
- } from "./chunk-TS7JWC6Z.mjs";
130
+ } from "./chunk-LQQMXMCV.mjs";
129
131
  import {
130
132
  isRecord
131
- } from "./chunk-SQ3UKGNC.mjs";
133
+ } from "./chunk-QRW6R5HX.mjs";
132
134
  import {
133
135
  __publicField
134
- } from "./chunk-SSZA5C37.mjs";
136
+ } from "./chunk-PHBFU273.mjs";
135
137
 
136
138
  // src/swift-compile.ts
137
139
  import {
138
140
  spawn as spawn2,
139
141
  spawnSync as spawnSync3
140
142
  } from "node:child_process";
141
- import { createHash as createHash15, randomUUID as randomUUID4 } from "node:crypto";
143
+ import { createHash as createHash15, randomUUID as randomUUID5 } from "node:crypto";
142
144
  import {
143
145
  chmodSync as chmodSync4,
144
146
  copyFileSync as copyFileSync2,
145
147
  cpSync,
146
- existsSync as existsSync9,
148
+ existsSync as existsSync10,
147
149
  lstatSync as lstatSync2,
148
- mkdirSync as mkdirSync7,
150
+ mkdirSync as mkdirSync8,
149
151
  mkdtempSync as mkdtempSync4,
150
152
  readFileSync as readFileSync13,
151
- readdirSync as readdirSync4,
153
+ readdirSync as readdirSync5,
152
154
  readlinkSync as readlinkSync2,
153
155
  realpathSync as realpathSync6,
154
- renameSync as renameSync5,
156
+ renameSync as renameSync6,
155
157
  rmSync as rmSync7,
156
- statSync as statSync5,
158
+ statSync as statSync6,
157
159
  symlinkSync as symlinkSync3,
158
160
  utimesSync,
159
- writeFileSync as writeFileSync7
161
+ writeFileSync as writeFileSync8
160
162
  } from "node:fs";
161
- import os3 from "node:os";
163
+ import os4 from "node:os";
162
164
  import path23 from "node:path";
163
165
  import { setTimeout as delay } from "node:timers/promises";
164
166
 
@@ -2875,8 +2877,17 @@ async function withSwiftCompileBudget(compileTimeoutMs, signal, work) {
2875
2877
  }
2876
2878
 
2877
2879
  // src/swift-compiler-digest.ts
2878
- import { createHash } from "node:crypto";
2879
- import { readFileSync as readFileSync2 } from "node:fs";
2880
+ import { createHash, randomUUID as randomUUID2 } from "node:crypto";
2881
+ import {
2882
+ existsSync,
2883
+ mkdirSync,
2884
+ readdirSync,
2885
+ readFileSync as readFileSync2,
2886
+ renameSync as renameSync2,
2887
+ statSync,
2888
+ writeFileSync
2889
+ } from "node:fs";
2890
+ import os from "node:os";
2880
2891
  import path2 from "node:path";
2881
2892
  var SWIFT_DIGEST_SOURCES = [
2882
2893
  "swift-compile.ts",
@@ -2949,7 +2960,7 @@ var SWIFT_ARCHIVE_DIGEST_SOURCES = SWIFT_DIGEST_SOURCES.filter(
2949
2960
 
2950
2961
  // src/swift-darwin-records.ts
2951
2962
  import { execFileSync } from "node:child_process";
2952
- import { mkdtempSync, readdirSync, rmSync, symlinkSync } from "node:fs";
2963
+ import { mkdtempSync, readdirSync as readdirSync2, rmSync, symlinkSync } from "node:fs";
2953
2964
  import { tmpdir } from "node:os";
2954
2965
  import path3 from "node:path";
2955
2966
 
@@ -2968,7 +2979,7 @@ function compileDarwinRecords(args) {
2968
2979
  const records = path3.join(args.packageRoot, "Sources/DarwinRecords");
2969
2980
  const runtime = mkdtempSync(path3.join(tmpdir(), "peach-objc-runtime-"));
2970
2981
  symlinkSync(path3.join(args.darwin, "usr/include/objc"), path3.join(runtime, "objc"));
2971
- const objects = readdirSync(records).filter((file) => file.endsWith(".c") || file.endsWith(".m")).sort((a, b) => a < b ? -1 : a > b ? 1 : 0).map((file) => {
2982
+ const objects = readdirSync2(records).filter((file) => file.endsWith(".c") || file.endsWith(".m")).sort((a, b) => a < b ? -1 : a > b ? 1 : 0).map((file) => {
2972
2983
  const object2 = path3.join(
2973
2984
  args.out,
2974
2985
  `${DARWIN_RECORDS_PREFIX}${file.replace(/\.[cm]$/, ".o")}`
@@ -3413,22 +3424,22 @@ function designTimeDiagnostic(output, files) {
3413
3424
  }
3414
3425
 
3415
3426
  // src/swift-distribution-mirror.ts
3416
- import { randomUUID as randomUUID2 } from "node:crypto";
3427
+ import { randomUUID as randomUUID3 } from "node:crypto";
3417
3428
  import {
3418
3429
  chmodSync,
3419
3430
  constants,
3420
3431
  copyFileSync,
3421
- existsSync,
3432
+ existsSync as existsSync2,
3422
3433
  lstatSync,
3423
- mkdirSync,
3424
- readdirSync as readdirSync2,
3434
+ mkdirSync as mkdirSync2,
3435
+ readdirSync as readdirSync3,
3425
3436
  readFileSync as readFileSync3,
3426
3437
  readlinkSync,
3427
- renameSync as renameSync2,
3438
+ renameSync as renameSync3,
3428
3439
  rmSync as rmSync2,
3429
- statSync,
3440
+ statSync as statSync2,
3430
3441
  symlinkSync as symlinkSync2,
3431
- writeFileSync
3442
+ writeFileSync as writeFileSync2
3432
3443
  } from "node:fs";
3433
3444
  import path4 from "node:path";
3434
3445
 
@@ -3559,7 +3570,7 @@ function syncSwiftDistributionMirror(root, source, manifest) {
3559
3570
  const mirror = path4.join(root, SWIFT_DISTRIBUTION_MIRROR);
3560
3571
  const record = path4.join(mirror, SWIFT_DISTRIBUTION_MIRROR_RECORD);
3561
3572
  const syncingMarker = path4.join(mirror, SWIFT_DISTRIBUTION_MIRROR_SYNCING);
3562
- const previous = existsSync(syncingMarker) ? null : readRecord(record);
3573
+ const previous = existsSync2(syncingMarker) ? null : readRecord(record);
3563
3574
  if (!previous) {
3564
3575
  rmSync2(mirror, { recursive: true, force: true });
3565
3576
  rmSync2(path4.join(root, ".build"), { recursive: true, force: true });
@@ -3573,19 +3584,19 @@ function syncSwiftDistributionMirror(root, source, manifest) {
3573
3584
  throw new Error(`invalid Swift distribution path ${file}`);
3574
3585
  if (previous) invalidateDependents(root, mirror, [...changed, ...removed]);
3575
3586
  if (!previous || changed.length > 0 || removed.length > 0) {
3576
- mkdirSync(mirror, { recursive: true });
3577
- writeFileSync(syncingMarker, "1\n");
3587
+ mkdirSync2(mirror, { recursive: true });
3588
+ writeFileSync2(syncingMarker, "1\n");
3578
3589
  }
3579
3590
  for (const file of removed) rmSync2(path4.join(mirror, file), { force: true });
3580
3591
  for (const file of changed) place(path4.join(source, file), path4.join(mirror, file));
3581
3592
  const manifestFile = path4.join(mirror, SWIFT_DISTRIBUTION_MANIFEST);
3582
3593
  const manifestBytes = readFileSync3(path4.join(source, SWIFT_DISTRIBUTION_MANIFEST));
3583
- if (!existsSync(manifestFile) || !readFileSync3(manifestFile).equals(manifestBytes))
3594
+ if (!existsSync2(manifestFile) || !readFileSync3(manifestFile).equals(manifestBytes))
3584
3595
  place(path4.join(source, SWIFT_DISTRIBUTION_MANIFEST), manifestFile);
3585
3596
  if (!previous || changed.length > 0 || removed.length > 0) {
3586
- const partial = `${record}.${randomUUID2()}`;
3587
- writeFileSync(partial, JSON.stringify(manifest.files));
3588
- renameSync2(partial, record);
3597
+ const partial = `${record}.${randomUUID3()}`;
3598
+ writeFileSync2(partial, JSON.stringify(manifest.files));
3599
+ renameSync3(partial, record);
3589
3600
  if ([...changed, ...removed].some(
3590
3601
  (file) => !file.startsWith("lib/") && !file.startsWith("modules/")
3591
3602
  )) {
@@ -3614,20 +3625,20 @@ function syncSwiftSdkMirrorFromView(root, frameworkRoot, sourceView, sourceSdkId
3614
3625
  const recordFile = path4.join(mirror, SWIFT_SDK_MIRROR_RECORD);
3615
3626
  const syncingMarker = path4.join(mirror, SWIFT_SDK_MIRROR_SYNCING);
3616
3627
  const options = ["--swift-sdks-path", mirror];
3617
- const interrupted = existsSync(syncingMarker);
3628
+ const interrupted = existsSync2(syncingMarker);
3618
3629
  const previous = interrupted ? null : readSdkRecord(recordFile);
3619
3630
  const sourceTriple = resolveSdkViewTripleDir(sourceView, sourceSdkId);
3620
3631
  const catalog = path4.join(destTriple, SDK_PRODUCT_CATALOG);
3621
3632
  const sourceCatalog = path4.join(sourceTriple, SDK_PRODUCT_CATALOG);
3622
- if (previous && previous.sourceView === sourceView && previous.sourceSdkId === sourceSdkId && existsSync(bundleInfo) && existsSync(path4.join(destTriple, "swift-sdk.json")) && (!lstatSync(sourceCatalog, { throwIfNoEntry: false })?.isSymbolicLink() || lstatSync(catalog, { throwIfNoEntry: false })?.isSymbolicLink())) {
3633
+ if (previous && previous.sourceView === sourceView && previous.sourceSdkId === sourceSdkId && existsSync2(bundleInfo) && existsSync2(path4.join(destTriple, "swift-sdk.json")) && (!lstatSync(sourceCatalog, { throwIfNoEntry: false })?.isSymbolicLink() || lstatSync(catalog, { throwIfNoEntry: false })?.isSymbolicLink())) {
3623
3634
  return { id: SWIFT_SDK_MIRROR_ID, options, toolsetChanged: false };
3624
3635
  }
3625
3636
  if (!previous) {
3626
3637
  if (!interrupted) rmSync2(mirror, { recursive: true, force: true });
3627
3638
  rmSync2(path4.join(root, ".build"), { recursive: true, force: true });
3628
3639
  }
3629
- mkdirSync(mirror, { recursive: true });
3630
- writeFileSync(syncingMarker, "1\n");
3640
+ mkdirSync2(mirror, { recursive: true });
3641
+ writeFileSync2(syncingMarker, "1\n");
3631
3642
  const changed = [];
3632
3643
  const removed = [];
3633
3644
  const distributionPrefix = `${frameworkRoot}${path4.sep}`;
@@ -3646,11 +3657,11 @@ function syncSwiftSdkMirrorFromView(root, frameworkRoot, sourceView, sourceSdkId
3646
3657
  null,
3647
3658
  2
3648
3659
  ) + "\n";
3649
- if (!existsSync(bundleInfo) || readFileSync3(bundleInfo, "utf8") !== infoText) {
3650
- mkdirSync(bundle, { recursive: true });
3651
- const partial = `${bundleInfo}.${randomUUID2()}`;
3652
- writeFileSync(partial, infoText);
3653
- renameSync2(partial, bundleInfo);
3660
+ if (!existsSync2(bundleInfo) || readFileSync3(bundleInfo, "utf8") !== infoText) {
3661
+ mkdirSync2(bundle, { recursive: true });
3662
+ const partial = `${bundleInfo}.${randomUUID3()}`;
3663
+ writeFileSync2(partial, infoText);
3664
+ renameSync3(partial, bundleInfo);
3654
3665
  }
3655
3666
  const touched = [...changed, ...removed];
3656
3667
  const toolsetChanged = !previous || touched.some(
@@ -3679,14 +3690,14 @@ function syncSwiftSdkMirrorFromView(root, frameworkRoot, sourceView, sourceSdkId
3679
3690
  } else {
3680
3691
  clearCaseInsensitiveHeaderOverlayCache(mirror);
3681
3692
  }
3682
- const partialRecord = `${recordFile}.${randomUUID2()}`;
3683
- writeFileSync(partialRecord, JSON.stringify({ version: 1, sourceView, sourceSdkId }));
3684
- renameSync2(partialRecord, recordFile);
3693
+ const partialRecord = `${recordFile}.${randomUUID3()}`;
3694
+ writeFileSync2(partialRecord, JSON.stringify({ version: 1, sourceView, sourceSdkId }));
3695
+ renameSync3(partialRecord, recordFile);
3685
3696
  rmSync2(syncingMarker, { force: true });
3686
3697
  return { id: SWIFT_SDK_MIRROR_ID, options, toolsetChanged };
3687
3698
  }
3688
3699
  function readSdkRecord(file) {
3689
- if (!existsSync(file)) return null;
3700
+ if (!existsSync2(file)) return null;
3690
3701
  const value = JSON.parse(readFileSync3(file, "utf8"));
3691
3702
  if (!isRecord(value) || value.version !== 1 || typeof value.sourceView !== "string" || typeof value.sourceSdkId !== "string")
3692
3703
  return null;
@@ -3697,11 +3708,11 @@ function readSdkRecord(file) {
3697
3708
  };
3698
3709
  }
3699
3710
  function resolveSdkViewTripleDir(sourceView, sourceSdkId) {
3700
- for (const entry of readdirSync2(sourceView, { withFileTypes: true })) {
3711
+ for (const entry of readdirSync3(sourceView, { withFileTypes: true })) {
3701
3712
  if (!entry.name.endsWith(".artifactbundle")) continue;
3702
3713
  const bundleDir = path4.join(sourceView, entry.name);
3703
3714
  const infoPath = path4.join(bundleDir, "info.json");
3704
- if (!existsSync(infoPath)) continue;
3715
+ if (!existsSync2(infoPath)) continue;
3705
3716
  const info = JSON.parse(readFileSync3(infoPath, "utf8"));
3706
3717
  if (!isRecord(info) || !isRecord(info.artifacts)) continue;
3707
3718
  const artifact = info.artifacts[sourceSdkId];
@@ -3713,7 +3724,7 @@ function resolveSdkViewTripleDir(sourceView, sourceSdkId) {
3713
3724
  throw new Error(`Swift SDK ${sourceSdkId} not found in view ${sourceView}`);
3714
3725
  }
3715
3726
  function collectRemovedFiles(dir, prefix, out) {
3716
- for (const entry of readdirSync2(dir, { withFileTypes: true })) {
3727
+ for (const entry of readdirSync3(dir, { withFileTypes: true })) {
3717
3728
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
3718
3729
  const full = path4.join(dir, entry.name);
3719
3730
  if (entry.isDirectory()) collectRemovedFiles(full, rel, out);
@@ -3721,9 +3732,9 @@ function collectRemovedFiles(dir, prefix, out) {
3721
3732
  }
3722
3733
  }
3723
3734
  function syncSdkTree(sourceDir, destDir, prefix, distributionPrefix, changed, removed) {
3724
- mkdirSync(destDir, { recursive: true });
3735
+ mkdirSync2(destDir, { recursive: true });
3725
3736
  const wanted = /* @__PURE__ */ new Set();
3726
- for (const entry of readdirSync2(sourceDir, { withFileTypes: true })) {
3737
+ for (const entry of readdirSync3(sourceDir, { withFileTypes: true })) {
3727
3738
  wanted.add(entry.name);
3728
3739
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
3729
3740
  const src = path4.join(sourceDir, entry.name);
@@ -3739,7 +3750,7 @@ function syncSdkTree(sourceDir, destDir, prefix, distributionPrefix, changed, re
3739
3750
  continue;
3740
3751
  }
3741
3752
  }
3742
- const srcStat = statSync(src, { throwIfNoEntry: false });
3753
+ const srcStat = statSync2(src, { throwIfNoEntry: false });
3743
3754
  if (!srcStat) continue;
3744
3755
  if (srcStat.isDirectory()) {
3745
3756
  if (destLstat && (!destLstat.isDirectory() || destLstat.isSymbolicLink()))
@@ -3753,7 +3764,7 @@ function syncSdkTree(sourceDir, destDir, prefix, distributionPrefix, changed, re
3753
3764
  place(src, dest, (srcStat.mode & 73) !== 0 ? srcStat.mode & 511 : void 0);
3754
3765
  changed.push(rel);
3755
3766
  }
3756
- for (const entry of readdirSync2(destDir, { withFileTypes: true })) {
3767
+ for (const entry of readdirSync3(destDir, { withFileTypes: true })) {
3757
3768
  if (wanted.has(entry.name)) continue;
3758
3769
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
3759
3770
  const dest = path4.join(destDir, entry.name);
@@ -3763,7 +3774,7 @@ function syncSdkTree(sourceDir, destDir, prefix, distributionPrefix, changed, re
3763
3774
  }
3764
3775
  }
3765
3776
  function readRecord(file) {
3766
- if (!existsSync(file)) return null;
3777
+ if (!existsSync2(file)) return null;
3767
3778
  const value = JSON.parse(readFileSync3(file, "utf8"));
3768
3779
  if (!isRecord(value)) return null;
3769
3780
  const files = {};
@@ -3774,11 +3785,11 @@ function readRecord(file) {
3774
3785
  return files;
3775
3786
  }
3776
3787
  function place(from, to, mode) {
3777
- mkdirSync(path4.dirname(to), { recursive: true });
3778
- const partial = `${to}.${randomUUID2()}`;
3788
+ mkdirSync2(path4.dirname(to), { recursive: true });
3789
+ const partial = `${to}.${randomUUID3()}`;
3779
3790
  copyFileSync(from, partial, constants.COPYFILE_FICLONE);
3780
3791
  if (mode !== void 0) chmodSync(partial, mode);
3781
- renameSync2(partial, to);
3792
+ renameSync3(partial, to);
3782
3793
  }
3783
3794
  function escapeDepPath(directory) {
3784
3795
  return directory.replace(
@@ -3813,21 +3824,21 @@ function invalidateBuildDependents(root, spellings, read, headersChanged) {
3813
3824
  return false;
3814
3825
  });
3815
3826
  const scratch = path4.join(root, ".build");
3816
- if (!existsSync(scratch)) return;
3817
- for (const triple of readdirSync2(scratch, { withFileTypes: true })) {
3827
+ if (!existsSync2(scratch)) return;
3828
+ for (const triple of readdirSync3(scratch, { withFileTypes: true })) {
3818
3829
  const products = path4.join(scratch, triple.name, "release");
3819
- if (!triple.isDirectory() || !existsSync(products)) continue;
3830
+ if (!triple.isDirectory() || !existsSync2(products)) continue;
3820
3831
  const modules = path4.join(products, "Modules");
3821
- for (const target of readdirSync2(products, { withFileTypes: true })) {
3832
+ for (const target of readdirSync3(products, { withFileTypes: true })) {
3822
3833
  if (!target.isDirectory() || !target.name.endsWith(".build")) continue;
3823
3834
  const name = target.name.slice(0, -".build".length);
3824
3835
  const directory = path4.join(products, target.name);
3825
- for (const entry of readdirSync2(directory, { recursive: true, encoding: "utf8" })) {
3836
+ for (const entry of readdirSync3(directory, { recursive: true, encoding: "utf8" })) {
3826
3837
  if (!entry.endsWith(".d")) continue;
3827
3838
  const dependencies = path4.join(directory, entry);
3828
3839
  if (!names(readFileSync3(dependencies))) continue;
3829
3840
  const outputMap = path4.join(directory, "output-file-map.json");
3830
- if (existsSync(outputMap)) {
3841
+ if (existsSync2(outputMap)) {
3831
3842
  const outputs = JSON.parse(readFileSync3(outputMap, "utf8"));
3832
3843
  if (!isRecord(outputs)) throw new Error("invalid SwiftPM output file map");
3833
3844
  for (const output of Object.values(outputs)) {
@@ -3868,13 +3879,13 @@ var foundationCategoryObjects = [
3868
3879
 
3869
3880
  // src/swift-guest-compile.ts
3870
3881
  import { execFileSync as execFileSync8 } from "node:child_process";
3871
- import { chownSync, mkdirSync as mkdirSync5, mkdtempSync as mkdtempSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "node:fs";
3882
+ import { chownSync, mkdirSync as mkdirSync6, mkdtempSync as mkdtempSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync6 } from "node:fs";
3872
3883
  import path14 from "node:path";
3873
3884
 
3874
3885
  // src/swift-guest-archive.ts
3875
3886
  import { execFileSync as execFileSync4 } from "node:child_process";
3876
3887
  import { createHash as createHash3 } from "node:crypto";
3877
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, rmSync as rmSync3, writeFileSync as writeFileSync2 } from "node:fs";
3888
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync4, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
3878
3889
  import path8 from "node:path";
3879
3890
 
3880
3891
  // src/swift-wasm-prune.ts
@@ -8583,13 +8594,13 @@ function aliasGuestArchive(options) {
8583
8594
  }).trimEnd().split("\n");
8584
8595
  if (!original.length || listed.length !== original.length || original.some((member, index) => member.name !== listed[index]))
8585
8596
  throw new Error(`unsupported guest archive ${options.archive}`);
8586
- mkdirSync2(options.directory, { recursive: true });
8597
+ mkdirSync3(options.directory, { recursive: true });
8587
8598
  const counts = /* @__PURE__ */ new Map();
8588
8599
  const members = original.map((member, index) => {
8589
8600
  const ordinal = (counts.get(member.name) ?? 0) + 1;
8590
8601
  counts.set(member.name, ordinal);
8591
8602
  const alias = `member-${String(index).padStart(8, "0")}.o`;
8592
- writeFileSync2(path8.join(options.directory, alias), member.bytes);
8603
+ writeFileSync3(path8.join(options.directory, alias), member.bytes);
8593
8604
  return {
8594
8605
  alias,
8595
8606
  name: member.name,
@@ -8598,7 +8609,7 @@ function aliasGuestArchive(options) {
8598
8609
  };
8599
8610
  });
8600
8611
  const response = path8.join(options.directory, "members.rsp");
8601
- writeFileSync2(
8612
+ writeFileSync3(
8602
8613
  response,
8603
8614
  members.map((member) => JSON.stringify(path8.join(options.directory, member.alias))).join(" ")
8604
8615
  );
@@ -11716,13 +11727,13 @@ import { execFile } from "node:child_process";
11716
11727
  import {
11717
11728
  appendFileSync,
11718
11729
  closeSync as closeSync2,
11719
- existsSync as existsSync2,
11730
+ existsSync as existsSync3,
11720
11731
  fstatSync,
11721
11732
  openSync as openSync2,
11722
11733
  readFileSync as readFileSync7,
11723
11734
  readSync as readSync2,
11724
11735
  rmSync as rmSync4,
11725
- writeFileSync as writeFileSync3
11736
+ writeFileSync as writeFileSync4
11726
11737
  } from "node:fs";
11727
11738
  import { dirname, join } from "node:path";
11728
11739
  import { promisify } from "node:util";
@@ -11846,7 +11857,7 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary, sdkTableEn
11846
11857
  const tableTool = join(dirname(binary), "wasm-table-guard");
11847
11858
  try {
11848
11859
  if (wideExportsFile)
11849
- writeFileSync3(wideExportsFile, [...wideExports].join("\n") + "\n");
11860
+ writeFileSync4(wideExportsFile, [...wideExports].join("\n") + "\n");
11850
11861
  const pipelineArgs = [
11851
11862
  "--pipeline",
11852
11863
  "--in",
@@ -11890,7 +11901,7 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary, sdkTableEn
11890
11901
  const section2 = Buffer.from([0, ...encode(body.length), ...body]);
11891
11902
  if (sdkTableEnd === void 0) {
11892
11903
  const bytes = readFileSync7(output);
11893
- writeFileSync3(
11904
+ writeFileSync4(
11894
11905
  output,
11895
11906
  Buffer.concat([
11896
11907
  withWasmTableMinimum(
@@ -11915,8 +11926,8 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary, sdkTableEn
11915
11926
  if (narrowed) {
11916
11927
  const guest = `${output}.guest`;
11917
11928
  const thunks = `${output}.thunks.wat`;
11918
- writeFileSync3(guest, narrowed.module);
11919
- writeFileSync3(thunks, narrowed.thunks);
11929
+ writeFileSync4(guest, narrowed.module);
11930
+ writeFileSync4(thunks, narrowed.thunks);
11920
11931
  await runBinaryen(
11921
11932
  join(dirname(binary), "wasm-merge"),
11922
11933
  [
@@ -11931,7 +11942,7 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary, sdkTableEn
11931
11942
  ],
11932
11943
  { env: environment }
11933
11944
  );
11934
- writeFileSync3(merged, dropBoundaryExports(readFileSync7(merged)));
11945
+ writeFileSync4(merged, dropBoundaryExports(readFileSync7(merged)));
11935
11946
  rmSync4(guest);
11936
11947
  rmSync4(thunks);
11937
11948
  }
@@ -11969,7 +11980,7 @@ async function installWasmOpt() {
11969
11980
  release.sha256
11970
11981
  );
11971
11982
  const binary = join(destDir, "bin", "wasm-opt");
11972
- if (!existsSync2(binary))
11983
+ if (!existsSync3(binary))
11973
11984
  await installVerifiedTarball({
11974
11985
  url: `https://r2.rnxsim.com/peach/binaryen/${release.sha256}/${platform}.tar.zst`,
11975
11986
  digest: { algorithm: "sha256", encoding: "hex", value: release.sha256 },
@@ -13463,13 +13474,13 @@ async function linkPrunedGuestImages(options) {
13463
13474
  // src/swift-guest-source-inputs.ts
13464
13475
  import { execFileSync as execFileSync6 } from "node:child_process";
13465
13476
  import {
13466
- existsSync as existsSync3,
13467
- mkdirSync as mkdirSync3,
13477
+ existsSync as existsSync4,
13478
+ mkdirSync as mkdirSync4,
13468
13479
  readFileSync as readFileSync8,
13469
13480
  realpathSync as realpathSync2,
13470
- renameSync as renameSync3,
13471
- statSync as statSync2,
13472
- writeFileSync as writeFileSync4
13481
+ renameSync as renameSync4,
13482
+ statSync as statSync3,
13483
+ writeFileSync as writeFileSync5
13473
13484
  } from "node:fs";
13474
13485
  import path11 from "node:path";
13475
13486
 
@@ -13552,11 +13563,11 @@ Promise.all(Array.from({ length: jobs }, run))
13552
13563
  })
13553
13564
  `;
13554
13565
  function clangProducerStamp(file) {
13555
- const stat = statSync2(file, { bigint: true });
13566
+ const stat = statSync3(file, { bigint: true });
13556
13567
  return [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(":");
13557
13568
  }
13558
13569
  function clangBinaryStamp(file) {
13559
- const stat = statSync2(file, { bigint: true });
13570
+ const stat = statSync3(file, { bigint: true });
13560
13571
  return [file, stat.size, stat.mtimeNs].join(":");
13561
13572
  }
13562
13573
  function clangWrapperStamp(file) {
@@ -13604,7 +13615,7 @@ function clangArgsNeedCwd(args) {
13604
13615
  }
13605
13616
  if (includeFlags.has(arg)) {
13606
13617
  const value = args[++i] ?? "";
13607
- if (isRelativePath(value) && (value.includes("/") || existsSync3(value))) return true;
13618
+ if (isRelativePath(value) && (value.includes("/") || existsSync4(value))) return true;
13608
13619
  continue;
13609
13620
  }
13610
13621
  if (valueFlags.has(arg)) {
@@ -13618,7 +13629,7 @@ function clangArgsNeedCwd(args) {
13618
13629
  if (arg.startsWith("-")) {
13619
13630
  if (arg.startsWith("-include") && arg.length > 8) {
13620
13631
  const value = arg.slice(8);
13621
- if (isRelativePath(value) && (value.includes("/") || existsSync3(value)))
13632
+ if (isRelativePath(value) && (value.includes("/") || existsSync4(value)))
13622
13633
  return true;
13623
13634
  continue;
13624
13635
  }
@@ -13647,7 +13658,7 @@ function validateClangLinkOptions(flags) {
13647
13658
  }
13648
13659
  }
13649
13660
  function readClangLinkOptions(file, key) {
13650
- if (!existsSync3(file)) return;
13661
+ if (!existsSync4(file)) return;
13651
13662
  let receipt;
13652
13663
  try {
13653
13664
  receipt = JSON.parse(readFileSync8(file, "utf8"));
@@ -13795,12 +13806,12 @@ function sourceGuestClangLinkOptions(options) {
13795
13806
  if (replays.length === 0) return result;
13796
13807
  const plan = path11.join(options.directory, "clang-link-replays.json");
13797
13808
  const resultsPath = path11.join(options.directory, "clang-link-results.json");
13798
- writeFileSync4(
13809
+ writeFileSync5(
13799
13810
  plan,
13800
13811
  JSON.stringify(replays.map(({ compiler, args }) => [compiler, ...args]))
13801
13812
  );
13802
13813
  const script = path11.join(options.directory, "clang-link-replay.cjs");
13803
- writeFileSync4(script, PARALLEL_REPLAY);
13814
+ writeFileSync5(script, PARALLEL_REPLAY);
13804
13815
  execFileSync6(process.execPath, [script], {
13805
13816
  stdio: "inherit",
13806
13817
  env: {
@@ -13814,13 +13825,13 @@ function sourceGuestClangLinkOptions(options) {
13814
13825
  const replayMetadata = JSON.parse(readFileSync8(resultsPath, "utf8"));
13815
13826
  if (!Array.isArray(replayMetadata) || replayMetadata.length !== replays.length || !replayMetadata.every((item) => typeof item === "string"))
13816
13827
  throw new Error("invalid clang link replay results");
13817
- mkdirSync3(cacheDirectory, { recursive: true });
13828
+ mkdirSync4(cacheDirectory, { recursive: true });
13818
13829
  for (const [index, { file, cacheFile, key }] of replays.entries()) {
13819
13830
  const flags = clangIrLinkOptions(replayMetadata[index]);
13820
13831
  validateClangLinkOptions(flags);
13821
13832
  const temporary = `${cacheFile}.${process.pid}`;
13822
- writeFileSync4(temporary, JSON.stringify({ key, flags }));
13823
- renameSync3(temporary, cacheFile);
13833
+ writeFileSync5(temporary, JSON.stringify({ key, flags }));
13834
+ renameSync4(temporary, cacheFile);
13824
13835
  result.set(file, flags);
13825
13836
  }
13826
13837
  return result;
@@ -13894,7 +13905,7 @@ function readAutolinkFlags(objects, toolchainBin, responsePath) {
13894
13905
  const rawFlags = [];
13895
13906
  for (const file of objects) {
13896
13907
  if (!wasmAutolinkEntries(readFileSync8(file), rawFlags)) {
13897
- writeFileSync4(
13908
+ writeFileSync5(
13898
13909
  responsePath,
13899
13910
  objects.map((entry) => JSON.stringify(entry)).join("\n") + "\n"
13900
13911
  );
@@ -14106,13 +14117,13 @@ function logicalGuestLinkOptions(args, identities, roots) {
14106
14117
  import { execFileSync as execFileSync7 } from "node:child_process";
14107
14118
  import {
14108
14119
  chmodSync as chmodSync2,
14109
- existsSync as existsSync4,
14110
- mkdirSync as mkdirSync4,
14111
- readdirSync as readdirSync3,
14120
+ existsSync as existsSync5,
14121
+ mkdirSync as mkdirSync5,
14122
+ readdirSync as readdirSync4,
14112
14123
  readFileSync as readFileSync9,
14113
14124
  realpathSync as realpathSync3,
14114
14125
  rmSync as rmSync5,
14115
- statSync as statSync3
14126
+ statSync as statSync4
14116
14127
  } from "node:fs";
14117
14128
  import path12 from "node:path";
14118
14129
  function prepareSwiftProjectProcess(root, user) {
@@ -14120,9 +14131,9 @@ function prepareSwiftProjectProcess(root, user) {
14120
14131
  rmSync5(home, { recursive: true, force: true });
14121
14132
  const tmp = path12.join(home, "tmp");
14122
14133
  const swiftpm = path12.join(home, "swiftpm");
14123
- mkdirSync4(tmp, { recursive: true });
14134
+ mkdirSync5(tmp, { recursive: true });
14124
14135
  const caches = ["cache", "config", "security"].map((name) => path12.join(swiftpm, name));
14125
- for (const directory of caches) mkdirSync4(directory, { recursive: true });
14136
+ for (const directory of caches) mkdirSync5(directory, { recursive: true });
14126
14137
  execFileSync7("chown", ["-R", "-P", `${user.uid}:${user.gid}`, root, home]);
14127
14138
  chmodSync2(root, 448);
14128
14139
  chmodSync2(home, 448);
@@ -14154,7 +14165,7 @@ function endSwiftProjectProcesses(user) {
14154
14165
  function projectOutputFile(root, file, user) {
14155
14166
  const real = realpathSync3(file);
14156
14167
  const base = realpathSync3(root);
14157
- const stat = statSync3(real);
14168
+ const stat = statSync4(real);
14158
14169
  if (!real.startsWith(base + path12.sep) || !stat.isFile() || stat.uid !== user.uid) {
14159
14170
  throw new Error(`swift-compile: project output ${file} is not a file of its build`);
14160
14171
  }
@@ -14163,7 +14174,7 @@ function projectOutputFile(root, file, user) {
14163
14174
  function removeProjectLinks(root) {
14164
14175
  const pending = [root];
14165
14176
  for (let directory = pending.pop(); directory; directory = pending.pop()) {
14166
- for (const entry of readdirSync3(directory, { withFileTypes: true })) {
14177
+ for (const entry of readdirSync4(directory, { withFileTypes: true })) {
14167
14178
  const full = path12.join(directory, entry.name);
14168
14179
  if (directory === root && entry.name === ".build") continue;
14169
14180
  if (directory === root && entry.name.startsWith(".peach-modules-")) {
@@ -14340,7 +14351,7 @@ function version(value) {
14340
14351
  }
14341
14352
  async function compileGuestLink(options) {
14342
14353
  const directory = path14.join(options.buildDirectory, ".peach-guest-link");
14343
- mkdirSync5(directory, { recursive: true });
14354
+ mkdirSync6(directory, { recursive: true });
14344
14355
  const sdkRoot = path14.dirname(options.sysroot);
14345
14356
  refreshSwiftCacheHold(options.buildDirectory);
14346
14357
  refreshSwiftCacheHold(options.moduleRoot);
@@ -14378,7 +14389,7 @@ async function compileGuestLink(options) {
14378
14389
  ];
14379
14390
  const stubSource = path14.join(directory, "projection-discovery.c");
14380
14391
  const stub = path14.join(directory, "projection-discovery.o");
14381
- writeFileSync5(
14392
+ writeFileSync6(
14382
14393
  stubSource,
14383
14394
  '#include "guest-image-projection.h"\nconst struct peach_guest_image __peach_guest_images[] = {{0}};\nconst uint32_t __peach_guest_image_count = 0;\n'
14384
14395
  );
@@ -14437,7 +14448,7 @@ async function compileGuestLink(options) {
14437
14448
  };
14438
14449
  const sdk = options.sdkImage;
14439
14450
  const sdkCallers = sdk.sdkInterface.guestCallers;
14440
- const sdkObjects = (await import("./swift-sdk-image-IPXHOUXE.mjs")).readSwiftSdkManifestIndex(
14451
+ const sdkObjects = (await import("./swift-sdk-image-P5NS5P7F.mjs")).readSwiftSdkManifestIndex(
14441
14452
  sdk
14442
14453
  ).guestObjects;
14443
14454
  if (!sdkCallers || !sdkObjects)
@@ -14737,11 +14748,11 @@ async function compileGuestLink(options) {
14737
14748
  swiftAppModuleThunkSection,
14738
14749
  swiftSdkProjectionSpans,
14739
14750
  writeSwiftSdkAppLink
14740
- } = await import("./swift-sdk-app-module-I4OZ7CGZ.mjs");
14751
+ } = await import("./swift-sdk-app-module-XC4QIMOI.mjs");
14741
14752
  const project = options.project;
14742
14753
  const work = project ? mkdtempSync2(path14.join(directory, "app-module-")) : path14.join(directory, "app-module");
14743
14754
  if (project) chownSync(work, project.uid, project.gid);
14744
- else mkdirSync5(work, { recursive: true });
14755
+ else mkdirSync6(work, { recursive: true });
14745
14756
  const layoutMap = path14.join(work, "app.map");
14746
14757
  let appProjectionObject = projectionObject;
14747
14758
  const owners = new Map(splitInputs.appObjects).set(appProjectionObject, 0);
@@ -14765,7 +14776,7 @@ async function compileGuestLink(options) {
14765
14776
  const compileAppProjection = (source) => {
14766
14777
  const projectionSource = path14.join(work, "projection.c");
14767
14778
  const nextObject = path14.join(work, "projection.o");
14768
- writeFileSync5(projectionSource, source);
14779
+ writeFileSync6(projectionSource, source);
14769
14780
  execFileSync8(
14770
14781
  path14.join(options.toolchainBin, "clang"),
14771
14782
  [...clangOptions, "-c", projectionSource, "-o", nextObject],
@@ -14879,7 +14890,7 @@ async function compileGuestLink(options) {
14879
14890
  reserved: storage,
14880
14891
  sdkSpans
14881
14892
  });
14882
- writeFileSync5(
14893
+ writeFileSync6(
14883
14894
  options.optimized,
14884
14895
  moveGuestDyldTable(map, finalized.wasm, splitInputs.dyldSymbols, bindingRows, [
14885
14896
  swiftAppModuleThunkSection(finalized.wasm)
@@ -14887,7 +14898,7 @@ async function compileGuestLink(options) {
14887
14898
  );
14888
14899
  if (project) return binding;
14889
14900
  const replayDirectory = path14.join(options.buildDirectory, ".peach-sdk-module");
14890
- mkdirSync5(replayDirectory, { recursive: true });
14901
+ mkdirSync6(replayDirectory, { recursive: true });
14891
14902
  const directValues = new Set(link.globalValues);
14892
14903
  for (const values2 of [data, linkage.tls])
14893
14904
  for (let index = 2; index < values2.length; index += 3)
@@ -14924,14 +14935,14 @@ async function compileGuestLink(options) {
14924
14935
  import { createHash as createHash10 } from "node:crypto";
14925
14936
  import {
14926
14937
  chmodSync as chmodSync3,
14927
- existsSync as existsSync5,
14928
- mkdirSync as mkdirSync6,
14938
+ existsSync as existsSync6,
14939
+ mkdirSync as mkdirSync7,
14929
14940
  mkdtempSync as mkdtempSync3,
14930
14941
  readFileSync as readFileSync11,
14931
- renameSync as renameSync4,
14942
+ renameSync as renameSync5,
14932
14943
  rmSync as rmSync6,
14933
- statSync as statSync4,
14934
- writeFileSync as writeFileSync6
14944
+ statSync as statSync5,
14945
+ writeFileSync as writeFileSync7
14935
14946
  } from "node:fs";
14936
14947
  import { createServer } from "node:http";
14937
14948
  import path15 from "node:path";
@@ -15005,12 +15016,12 @@ function compilerCheckpoint(root, recipe, args, header) {
15005
15016
  for (const flag of args) {
15006
15017
  if (!flag.startsWith("@")) continue;
15007
15018
  const response = flag.slice(1);
15008
- if (!path15.isAbsolute(response) || !existsSync5(response)) return;
15019
+ if (!path15.isAbsolute(response) || !existsSync6(response)) return;
15009
15020
  digest.update(readFileSync11(response));
15010
15021
  }
15011
15022
  for (const file of outputs) {
15012
15023
  if (!file.startsWith(path15.join(root, ".build") + path15.sep)) return;
15013
- const stat = statSync4(file, { bigint: true, throwIfNoEntry: false });
15024
+ const stat = statSync5(file, { bigint: true, throwIfNoEntry: false });
15014
15025
  if (!stat?.isFile() || stat.size === 0n) return;
15015
15026
  digest.update(JSON.stringify([file, String(stat.size), String(stat.mtimeNs)]));
15016
15027
  }
@@ -15021,7 +15032,7 @@ async function withSwiftHeaderCompiler(root, toolchainBin, recipe, producers, bu
15021
15032
  const script = path15.join(root, ".build", "peach-swift-header.cjs");
15022
15033
  const checkpoints = path15.join(root, ".build", "peach-swift-header-checkpoints");
15023
15034
  const socketFile = path15.join(root, ".build", "peach-swift-header-socket");
15024
- mkdirSync6(checkpoints, { recursive: true });
15035
+ mkdirSync7(checkpoints, { recursive: true });
15025
15036
  const swiftc = argument(path15.join(toolchainBin, "swiftc"));
15026
15037
  const producersByJobs = /* @__PURE__ */ new Map();
15027
15038
  for (const [name, { jobs }] of producers) {
@@ -15069,7 +15080,7 @@ async function withSwiftHeaderCompiler(root, toolchainBin, recipe, producers, bu
15069
15080
  const receipt = path15.join(checkpoints, module);
15070
15081
  const fingerprint = compilerCheckpoint(root, recipe, args, producer.header);
15071
15082
  if (request.method === "PUT") {
15072
- if (!fingerprint || !existsSync5(receipt) || readFileSync11(receipt, "utf8") !== fingerprint) {
15083
+ if (!fingerprint || !existsSync6(receipt) || readFileSync11(receipt, "utf8") !== fingerprint) {
15073
15084
  response.writeHead(204).end();
15074
15085
  return;
15075
15086
  }
@@ -15081,8 +15092,8 @@ async function withSwiftHeaderCompiler(root, toolchainBin, recipe, producers, bu
15081
15092
  throw new Error("invalid Swift compiler checkpoint method");
15082
15093
  producer.publish();
15083
15094
  if (fingerprint) {
15084
- writeFileSync6(`${receipt}.partial`, fingerprint);
15085
- renameSync4(`${receipt}.partial`, receipt);
15095
+ writeFileSync7(`${receipt}.partial`, fingerprint);
15096
+ renameSync5(`${receipt}.partial`, receipt);
15086
15097
  }
15087
15098
  response.end();
15088
15099
  } catch (error) {
@@ -15094,7 +15105,7 @@ async function withSwiftHeaderCompiler(root, toolchainBin, recipe, producers, bu
15094
15105
  server.once("error", reject);
15095
15106
  server.listen(socket, resolve);
15096
15107
  });
15097
- writeFileSync6(socketFile, socket);
15108
+ writeFileSync7(socketFile, socket);
15098
15109
  return await build({ SWIFT_EXEC: wrapper });
15099
15110
  } finally {
15100
15111
  server.close();
@@ -15249,10 +15260,10 @@ function swiftHeaderDependencies(root, files, targets, nativeTargets, producers,
15249
15260
 
15250
15261
  // src/swift-icu.ts
15251
15262
  import { execFile as execFile3 } from "node:child_process";
15252
- import { createHash as createHash11, randomUUID as randomUUID3 } from "node:crypto";
15253
- import { existsSync as existsSync6, readFileSync as readFileSync12 } from "node:fs";
15263
+ import { createHash as createHash11, randomUUID as randomUUID4 } from "node:crypto";
15264
+ import { existsSync as existsSync7, readFileSync as readFileSync12 } from "node:fs";
15254
15265
  import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
15255
- import os from "node:os";
15266
+ import os2 from "node:os";
15256
15267
  import path17 from "node:path";
15257
15268
  import { promisify as promisify3 } from "node:util";
15258
15269
  import {
@@ -15332,7 +15343,7 @@ async function cachedBrotli(bytes, quality, cacheKey) {
15332
15343
  const cacheId = `${quality}:${key}`;
15333
15344
  const cached = brotliMemoryCache.get(cacheId);
15334
15345
  if (cached) return cached;
15335
- const dir = path17.join(os.homedir(), ".peach", "cache", "swift-brotli");
15346
+ const dir = path17.join(os2.homedir(), ".peach", "cache", "swift-brotli");
15336
15347
  const file = path17.join(dir, `${key}${quality === 11 ? "" : `-q${quality}`}.br`);
15337
15348
  let compressed;
15338
15349
  try {
@@ -15346,7 +15357,7 @@ async function cachedBrotli(bytes, quality, cacheKey) {
15346
15357
  });
15347
15358
  try {
15348
15359
  await mkdir(dir, { recursive: true });
15349
- const tmp = `${file}.${randomUUID3()}.tmp`;
15360
+ const tmp = `${file}.${randomUUID4()}.tmp`;
15350
15361
  await writeFile(tmp, compressed);
15351
15362
  await rename(tmp, file);
15352
15363
  } catch {
@@ -15390,7 +15401,7 @@ function swiftIcuAsset(toolchainBin, sdk) {
15390
15401
  }
15391
15402
  async function load(toolchainBin, sdk) {
15392
15403
  const swift = path17.join(toolchainBin, "swift");
15393
- if (!existsSync6(swift))
15404
+ if (!existsSync7(swift))
15394
15405
  throw new Error(`swift-icu: no swift at ${swift} for the ${sdk} SDK's icu data`);
15395
15406
  const { stdout: listed } = await run(swift, ["sdk", "list", ...swiftSdkOptions()], {
15396
15407
  env: swiftEnvironment()
@@ -15459,13 +15470,13 @@ var packedFiles = /* @__PURE__ */ new Map();
15459
15470
  function swiftIcuPacked(icu) {
15460
15471
  return memo(packedFiles, icu.sha256, async () => {
15461
15472
  const file = path17.join(
15462
- os.homedir(),
15473
+ os2.homedir(),
15463
15474
  ".peach",
15464
15475
  "cache",
15465
15476
  "swift-brotli",
15466
15477
  swiftIcuAddress(icu)
15467
15478
  );
15468
- if (existsSync6(file)) return readFile(file);
15479
+ if (existsSync7(file)) return readFile(file);
15469
15480
  const packed = Buffer.from(
15470
15481
  swiftIcuPack(
15471
15482
  await inflateGzip(icu.gzip),
@@ -15473,7 +15484,7 @@ function swiftIcuPacked(icu) {
15473
15484
  )
15474
15485
  );
15475
15486
  await mkdir(path17.dirname(file), { recursive: true });
15476
- const tmp = `${file}.${randomUUID3()}.tmp`;
15487
+ const tmp = `${file}.${randomUUID4()}.tmp`;
15477
15488
  await writeFile(tmp, packed);
15478
15489
  await rename(tmp, file);
15479
15490
  return packed;
@@ -15641,7 +15652,7 @@ var RNX_INTERNAL_CHILDREN = {
15641
15652
 
15642
15653
  // cli/self-invocation.ts
15643
15654
  import { spawnSync } from "node:child_process";
15644
- import { existsSync as existsSync7 } from "node:fs";
15655
+ import { existsSync as existsSync8 } from "node:fs";
15645
15656
  import { basename as basename2, dirname as dirname2, isAbsolute, join as join2 } from "node:path";
15646
15657
  import { fileURLToPath } from "node:url";
15647
15658
 
@@ -15652,7 +15663,7 @@ var IS_STANDALONE = typeof __SOOTSIM_STANDALONE__ !== "undefined" && __SOOTSIM_S
15652
15663
  function sourceEntryPath() {
15653
15664
  try {
15654
15665
  const candidate = join2(dirname2(fileURLToPath(import.meta.url)), "bin.ts");
15655
- return existsSync7(candidate) ? candidate : null;
15666
+ return existsSync8(candidate) ? candidate : null;
15656
15667
  } catch {
15657
15668
  return null;
15658
15669
  }
@@ -15783,13 +15794,13 @@ function swiftObjCPrebuiltCompiler(clang, root, sysroot, distribution, targets,
15783
15794
  }
15784
15795
 
15785
15796
  // src/swift-reproducible.ts
15786
- import { existsSync as existsSync8, realpathSync as realpathSync5 } from "node:fs";
15787
- import os2 from "node:os";
15797
+ import { existsSync as existsSync9, realpathSync as realpathSync5 } from "node:fs";
15798
+ import os3 from "node:os";
15788
15799
  import path20 from "node:path";
15789
15800
  function canonicalHomeDir() {
15790
- const home = os2.homedir();
15801
+ const home = os3.homedir();
15791
15802
  const dotPeach = path20.join(home, ".peach");
15792
- if (existsSync8(dotPeach)) {
15803
+ if (existsSync9(dotPeach)) {
15793
15804
  const realHome = path20.dirname(realpathSync5(dotPeach));
15794
15805
  if (home === realHome || home.startsWith(`${realHome}${path20.sep}`)) return realHome;
15795
15806
  }
@@ -16127,7 +16138,7 @@ var WASM_TRIPLE = SWIFT_WASM_TRIPLE;
16127
16138
  var SWIFTPM_PROGRESS = /^\[\d+\/\d+\] /;
16128
16139
  var SWIFTPM_NOISE = /^(?:\[\d+\/\d+\] |Building for production\.\.\.$|warning: '--build-system native' has been deprecated)/;
16129
16140
  function swiftCompilerJobs() {
16130
- return Math.min(64, swiftBuildJobs(), Math.max(1, Math.floor(os3.totalmem() / 2 ** 31)));
16141
+ return Math.min(64, swiftBuildJobs(), Math.max(1, Math.floor(os4.totalmem() / 2 ** 31)));
16131
16142
  }
16132
16143
  var SWIFT_COMPILER_ENV_KEYS = [
16133
16144
  "PATH",
@@ -16198,11 +16209,11 @@ function swiftObjCSelectorOptions(moduleRoot) {
16198
16209
  map = path23.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
16199
16210
  const content = `${JSON.stringify({ classes }, null, 2)}
16200
16211
  `;
16201
- if (!existsSync9(map) || readFileSync13(map, "utf8") !== content) {
16202
- mkdirSync7(path23.dirname(map), { recursive: true });
16203
- const partial = `${map}.${randomUUID4()}`;
16204
- writeFileSync7(partial, content);
16205
- renameSync5(partial, map);
16212
+ if (!existsSync10(map) || readFileSync13(map, "utf8") !== content) {
16213
+ mkdirSync8(path23.dirname(map), { recursive: true });
16214
+ const partial = `${map}.${randomUUID5()}`;
16215
+ writeFileSync8(partial, content);
16216
+ renameSync6(partial, map);
16206
16217
  }
16207
16218
  }
16208
16219
  return ["-Xswiftc", "-Xllvm", "-Xswiftc", `-peach-objc-selector-map=${map}`];
@@ -16215,7 +16226,7 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal, lea
16215
16226
  pluginDir,
16216
16227
  async (pluginLease) => {
16217
16228
  if (!swiftMacroPlugins(moduleRoot).stale) return;
16218
- mkdirSync7(path23.dirname(pluginDir), { recursive: true });
16229
+ mkdirSync8(path23.dirname(pluginDir), { recursive: true });
16219
16230
  const stage = mkdtempSync4(`${pluginDir}.tmp-`);
16220
16231
  try {
16221
16232
  await runCompiler(
@@ -16231,10 +16242,10 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal, lea
16231
16242
  frameworkLease: lease ? pluginLease : void 0
16232
16243
  }
16233
16244
  );
16234
- writeFileSync7(path23.join(stage, "compiler-release"), `${release}
16245
+ writeFileSync8(path23.join(stage, "compiler-release"), `${release}
16235
16246
  `);
16236
16247
  rmSync7(pluginDir, { recursive: true, force: true });
16237
- renameSync5(stage, pluginDir);
16248
+ renameSync6(stage, pluginDir);
16238
16249
  } finally {
16239
16250
  rmSync7(stage, { recursive: true, force: true });
16240
16251
  }
@@ -16415,22 +16426,22 @@ function swiftOverlayFrameworks(moduleRoot, toolchainBin) {
16415
16426
  const swiftModules = new Set(swiftPeachModules(moduleRoot));
16416
16427
  const result = /* @__PURE__ */ new Set();
16417
16428
  const include = path23.join(darwin, "usr/include");
16418
- for (const entry of readdirSync4(include))
16429
+ for (const entry of readdirSync5(include))
16419
16430
  if (entry.endsWith(".modulemap"))
16420
16431
  addSwiftOverlayFrameworks(
16421
16432
  readFileSync13(path23.join(include, entry), "utf8"),
16422
16433
  swiftModules,
16423
16434
  result
16424
16435
  );
16425
- for (const entry of readdirSync4(resources)) {
16436
+ for (const entry of readdirSync5(resources)) {
16426
16437
  const map = path23.join(resources, entry, "module.modulemap");
16427
- if (existsSync9(map))
16438
+ if (existsSync10(map))
16428
16439
  addSwiftOverlayFrameworks(readFileSync13(map, "utf8"), swiftModules, result);
16429
16440
  }
16430
16441
  for (const directory of frameworks)
16431
- for (const entry of readdirSync4(directory)) {
16442
+ for (const entry of readdirSync5(directory)) {
16432
16443
  const map = path23.join(directory, entry, "Modules/module.modulemap");
16433
- if (existsSync9(map))
16444
+ if (existsSync10(map))
16434
16445
  addSwiftOverlayFrameworks(readFileSync13(map, "utf8"), swiftModules, result);
16435
16446
  }
16436
16447
  sdkOverlayFrameworks.set(key, result);
@@ -16454,7 +16465,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
16454
16465
  })
16455
16466
  ]);
16456
16467
  for (const map of maps) {
16457
- if (!existsSync9(map)) continue;
16468
+ if (!existsSync10(map)) continue;
16458
16469
  const contents = readFileSync13(map, "utf8");
16459
16470
  for (const match of contents.matchAll(
16460
16471
  /^(?:explicit\s+)?(?:framework\s+)?module\s+([A-Za-z_]\w*)/gm
@@ -16463,13 +16474,13 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
16463
16474
  for (const match of contents.matchAll(/^\s*extern\s+module\s+\w+\s+"([^"]+)"/gm))
16464
16475
  maps.add(path23.resolve(path23.dirname(map), match[1]));
16465
16476
  }
16466
- for (const entry of readdirSync4(path23.join(resources, "wasi"))) {
16477
+ for (const entry of readdirSync5(path23.join(resources, "wasi"))) {
16467
16478
  if (entry.endsWith(".swiftmodule"))
16468
16479
  modules.add(entry.slice(0, -".swiftmodule".length));
16469
16480
  }
16470
- for (const entry of readdirSync4(resources)) {
16481
+ for (const entry of readdirSync5(resources)) {
16471
16482
  const map = path23.join(resources, entry, "module.modulemap");
16472
- if (!existsSync9(map)) continue;
16483
+ if (!existsSync10(map)) continue;
16473
16484
  for (const match of readFileSync13(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
16474
16485
  modules.add(match[1]);
16475
16486
  }
@@ -16480,7 +16491,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
16480
16491
  "usr/include"
16481
16492
  )
16482
16493
  ])
16483
- for (const entry of readdirSync4(libc)) {
16494
+ for (const entry of readdirSync5(libc)) {
16484
16495
  if (!entry.endsWith(".modulemap")) continue;
16485
16496
  for (const match of readFileSync13(path23.join(libc, entry), "utf8").matchAll(
16486
16497
  /^module\s+([A-Za-z_]\w*)/gm
@@ -16488,9 +16499,9 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
16488
16499
  modules.add(match[1]);
16489
16500
  }
16490
16501
  for (const directory of frameworks) {
16491
- for (const entry of readdirSync4(directory)) {
16502
+ for (const entry of readdirSync5(directory)) {
16492
16503
  const map = path23.join(directory, entry, "Modules/module.modulemap");
16493
- if (!existsSync9(map)) continue;
16504
+ if (!existsSync10(map)) continue;
16494
16505
  for (const match of readFileSync13(map, "utf8").matchAll(
16495
16506
  /^framework\s+module\s+([A-Za-z_]\w*)/gm
16496
16507
  ))
@@ -16590,7 +16601,7 @@ int EXUpdatesApplyBSDiffPatch(const char * _Nonnull oldFilePath,
16590
16601
  ];
16591
16602
  var CLANG_DISTRIBUTION_MODULES = ".peach-clang-modules";
16592
16603
  function distributionClangModulePresent(modules, name) {
16593
- return existsSync9(path23.join(modules, `${name}.swiftmodule`)) || existsSync9(path23.join(modules, name, "module.modulemap"));
16604
+ return existsSync10(path23.join(modules, `${name}.swiftmodule`)) || existsSync10(path23.join(modules, name, "module.modulemap"));
16594
16605
  }
16595
16606
  function distributionClangModuleMap(root, modules) {
16596
16607
  const missing = DISTRIBUTION_CLANG_MODULES.filter(
@@ -16607,7 +16618,7 @@ function distributionClangModuleMap(root, modules) {
16607
16618
  }
16608
16619
  `
16609
16620
  ).join("\n");
16610
- if (existsSync9(mapPath) && readFileSync13(mapPath, "utf8") !== map)
16621
+ if (existsSync10(mapPath) && readFileSync13(mapPath, "utf8") !== map)
16611
16622
  rmSync7(directory, { recursive: true, force: true });
16612
16623
  for (const mod of missing) writeBuildFile(path23.join(directory, mod.header), mod.source);
16613
16624
  writeBuildFile(mapPath, map);
@@ -16619,18 +16630,18 @@ function distributionClangModuleOptions(root, modules) {
16619
16630
  }
16620
16631
  function providedModulesPath(root, modules, excluded) {
16621
16632
  if (!excluded || excluded.size === 0) return modules;
16622
- const entries2 = readdirSync4(modules).filter((entry) => !excluded.has(entry.replace(/\..*$/, ""))).sort();
16633
+ const entries2 = readdirSync5(modules).filter((entry) => !excluded.has(entry.replace(/\..*$/, ""))).sort();
16623
16634
  const key = createHash15("sha256").update(JSON.stringify([modules, entries2])).update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
16624
16635
  const directory = path23.join(root, `.peach-modules-${key}`);
16625
16636
  const complete = path23.join(directory, ".complete");
16626
- if (!existsSync9(complete)) {
16627
- mkdirSync7(directory, { recursive: true });
16628
- for (const entry of readdirSync4(directory))
16637
+ if (!existsSync10(complete)) {
16638
+ mkdirSync8(directory, { recursive: true });
16639
+ for (const entry of readdirSync5(directory))
16629
16640
  rmSync7(path23.join(directory, entry), { recursive: true, force: true });
16630
16641
  for (const entry of entries2) {
16631
16642
  symlinkSync3(path23.join(modules, entry), path23.join(directory, entry));
16632
16643
  }
16633
- writeFileSync7(complete, "");
16644
+ writeFileSync8(complete, "");
16634
16645
  }
16635
16646
  return directory;
16636
16647
  }
@@ -16736,7 +16747,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
16736
16747
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
16737
16748
  var MULTI_MANIFEST_VERSION = 76;
16738
16749
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
16739
- var compilerSourceDigest = true ? "f7ecc0786fdd1632d1059f2c6c56bd5083a84c871afe2865af4bf2cf65ee6502" : swiftCompilerSourceDigest(import.meta.dirname);
16750
+ var compilerSourceDigest = true ? "0c6bac10641208c362185255fa7a630f4699656735409862a61a2e125ad2e84b" : swiftCompilerSourceDigest(import.meta.dirname);
16740
16751
  function swiftArtifactHash(input, release, moduleRoot) {
16741
16752
  return swiftCompileInputHash(input, release).update(swiftModuleDigest(moduleRoot)).digest("hex");
16742
16753
  }
@@ -16840,7 +16851,7 @@ var cxxFlagArray = (flags) => JSON.stringify([...nativeCxxCompilerFlags, ...with
16840
16851
  function swiftCrossImportFlags(moduleRoot, distribution) {
16841
16852
  const manifest = distribution ? swiftDistributionAt(moduleRoot) : null;
16842
16853
  const overlayRoot = manifest ? path23.join(moduleRoot, "modules") : path23.join(moduleRoot, "cross-import-overlays");
16843
- return readdirSync4(overlayRoot, { encoding: "utf8", recursive: true }).filter((file) => file.endsWith(".swiftoverlay")).sort((left, right) => left.localeCompare(right)).flatMap((file) => [
16854
+ return readdirSync5(overlayRoot, { encoding: "utf8", recursive: true }).filter((file) => file.endsWith(".swiftoverlay")).sort((left, right) => left.localeCompare(right)).flatMap((file) => [
16844
16855
  "-Xfrontend",
16845
16856
  "-swift-module-cross-import",
16846
16857
  "-Xfrontend",
@@ -16887,7 +16898,7 @@ function emitSwiftPackageManifest(args) {
16887
16898
  if (!flag.startsWith("-fmodule-map-file=")) return false;
16888
16899
  const file = flag.slice("-fmodule-map-file=".length).replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root);
16889
16900
  if (!file.includes("/Pods/Headers/")) return false;
16890
- const map = args.files.get(file) ?? (existsSync9(file) ? readFileSync13(file) : void 0);
16901
+ const map = args.files.get(file) ?? (existsSync10(file) ? readFileSync13(file) : void 0);
16891
16902
  const name = map === void 0 ? void 0 : moduleMapName(map.toString());
16892
16903
  return name !== void 0 && packageModules.has(name);
16893
16904
  };
@@ -17355,17 +17366,17 @@ ${declaration.replace(/,$/, "")}
17355
17366
  ].join("\n");
17356
17367
  }
17357
17368
  function syncSwiftTree(base, files, alreadySynced) {
17358
- mkdirSync7(base, { recursive: true });
17369
+ mkdirSync8(base, { recursive: true });
17359
17370
  let kept;
17360
17371
  if (process.platform !== "linux") {
17361
17372
  kept = /* @__PURE__ */ new Set();
17362
17373
  for (const file of files.keys()) {
17363
- const stat = statSync5(file, { throwIfNoEntry: false });
17374
+ const stat = statSync6(file, { throwIfNoEntry: false });
17364
17375
  if (stat) kept.add(stat.ino);
17365
17376
  }
17366
17377
  }
17367
17378
  const walk = (dir) => {
17368
- for (const entry of readdirSync4(dir, { withFileTypes: true })) {
17379
+ for (const entry of readdirSync5(dir, { withFileTypes: true })) {
17369
17380
  const full = path23.join(dir, entry.name);
17370
17381
  if (dir === base && (entry.name === ".build" || entry.name === SWIFT_CACHE_HOLD_MARKER || entry.name.startsWith(".peach-modules-") || // distribution clang maps are written beside the project, so a sync
17371
17382
  // must not remove them.
@@ -17719,6 +17730,8 @@ function swiftSourceClosure(files, roots) {
17719
17730
  return collectSwiftSourceClosure(files, roots, swiftCodeMask);
17720
17731
  }
17721
17732
  function swiftApplicationEntry(file, source) {
17733
+ if (!source.includes("@main") && !source.includes("@UIApplicationMain") && !(path23.basename(file) === "main.swift" && source.includes("UIApplicationMain")))
17734
+ return false;
17722
17735
  const code = [...swiftConditionalLines(swiftCodeMask(source))].map(({ line, active }) => active === false ? " ".repeat(line.length) : line).join("\n");
17723
17736
  const { tokens } = swiftCodeScan(code);
17724
17737
  let depth = 0;
@@ -17945,7 +17958,7 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
17945
17958
  const origins = {};
17946
17959
  const moduleMaps = [];
17947
17960
  const gather = (from) => {
17948
- for (const entry of readdirSync4(from, { withFileTypes: true })) {
17961
+ for (const entry of readdirSync5(from, { withFileTypes: true })) {
17949
17962
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
17950
17963
  continue;
17951
17964
  const file = path23.join(from, entry.name);
@@ -17958,7 +17971,7 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
17958
17971
  };
17959
17972
  gather(source);
17960
17973
  const manifest = path23.join(source, "Package.swift");
17961
- const targets = existsSync9(manifest) ? swiftManifestTargets(
17974
+ const targets = existsSync10(manifest) ? swiftManifestTargets(
17962
17975
  readFileSync13(manifest, "utf8"),
17963
17976
  [],
17964
17977
  (file) => readFileSync13(file, "utf8")
@@ -17985,15 +17998,15 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
17985
17998
  () => []
17986
17999
  );
17987
18000
  const copy = (from, to) => {
17988
- mkdirSync7(to, { recursive: true });
17989
- for (const entry of readdirSync4(from, { withFileTypes: true })) {
18001
+ mkdirSync8(to, { recursive: true });
18002
+ for (const entry of readdirSync5(from, { withFileTypes: true })) {
17990
18003
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
17991
18004
  continue;
17992
18005
  const file = path23.join(from, entry.name);
17993
18006
  const target = path23.join(to, entry.name);
17994
18007
  if (entry.isDirectory()) copy(file, target);
17995
18008
  else if (entry.isFile() && entry.name.endsWith(".swift"))
17996
- writeFileSync7(target, compiled.get(path23.relative(source, file)));
18009
+ writeFileSync8(target, compiled.get(path23.relative(source, file)));
17997
18010
  else cpSync(file, target, { verbatimSymlinks: true });
17998
18011
  }
17999
18012
  };
@@ -18074,14 +18087,14 @@ function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
18074
18087
  const directory = path23.join(layoutRoot, ".build", "peach-clang-modulemaps");
18075
18088
  return (settings.moduleMaps ?? []).flatMap((map) => {
18076
18089
  const headers = path23.join(layoutRoot, map.headers);
18077
- if (!existsSync9(headers)) return [];
18090
+ if (!existsSync10(headers)) return [];
18078
18091
  const published = path23.join(headers, "module.modulemap");
18079
- if (searched.has(map.headers) && existsSync9(published)) return [];
18080
- if (!searched.has(map.headers) && existsSync9(published))
18092
+ if (searched.has(map.headers) && existsSync10(published)) return [];
18093
+ if (!searched.has(map.headers) && existsSync10(published))
18081
18094
  return [`-fmodule-map-file=${published}`];
18082
18095
  const cached = written.get(headers);
18083
18096
  if (cached) return [cached];
18084
- mkdirSync7(directory, { recursive: true });
18097
+ mkdirSync8(directory, { recursive: true });
18085
18098
  const output = path23.join(directory, `module-${written.size}.modulemap`);
18086
18099
  writeBuildFile(
18087
18100
  output,
@@ -18176,7 +18189,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
18176
18189
  }
18177
18190
  ] : compileTargets(input);
18178
18191
  const generatedOwners = new Map(targets.map((target) => [target.name, target.name]));
18179
- const providedModules = distribution?.modules ?? (prebuilt ? readdirSync4(prebuilt.modules).filter((entry) => entry.endsWith(".swiftmodule")).map((entry) => entry.slice(0, -".swiftmodule".length)) : []);
18192
+ const providedModules = distribution?.modules ?? (prebuilt ? readdirSync5(prebuilt.modules).filter((entry) => entry.endsWith(".swiftmodule")).map((entry) => entry.slice(0, -".swiftmodule".length)) : []);
18180
18193
  const moduleExcludes = distribution || prebuilt ? /* @__PURE__ */ new Set([
18181
18194
  ...swiftSystemLibraryExclusions(input.files, targets, providedModules),
18182
18195
  ...providedModules.filter(
@@ -18253,8 +18266,8 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
18253
18266
  )
18254
18267
  );
18255
18268
  const headerDirectory = path23.join(layout2.root, ".build", "peach-cxx-headers");
18256
- if (existsSync9(headerDirectory)) {
18257
- for (const entry of readdirSync4(headerDirectory, { withFileTypes: true }))
18269
+ if (existsSync10(headerDirectory)) {
18270
+ for (const entry of readdirSync5(headerDirectory, { withFileTypes: true }))
18258
18271
  if (entry.isDirectory() && !targets.some((target) => target.name === entry.name))
18259
18272
  rmSync7(path23.join(headerDirectory, entry.name), { recursive: true, force: true });
18260
18273
  }
@@ -18751,7 +18764,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
18751
18764
  const origin = settings?.sourceDirectories[file];
18752
18765
  if (origin) {
18753
18766
  const original = path23.join(layout2.root, origin, path23.posix.basename(file));
18754
- mkdirSync7(path23.dirname(original), { recursive: true });
18767
+ mkdirSync8(path23.dirname(original), { recursive: true });
18755
18768
  stageTargetFile(target.name, original, contents, { allowExisting: true });
18756
18769
  }
18757
18770
  const source = unitSource(file);
@@ -19023,7 +19036,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19023
19036
  `extern module ${map.module} ${JSON.stringify(map.published)}
19024
19037
  `
19025
19038
  );
19026
- if (native.size > 0) mkdirSync7(headerDirectory, { recursive: true });
19039
+ if (native.size > 0) mkdirSync8(headerDirectory, { recursive: true });
19027
19040
  const headerAliasFlags = Object.keys(input.headerAliases ?? {}).length > 0 ? ["-ivfsoverlay", headerSearch.files[0]] : [];
19028
19041
  const nativeHeaderFlags = [...headerAliasFlags];
19029
19042
  const nativeSwiftHeaderMaps = /* @__PURE__ */ new Map();
@@ -19125,8 +19138,8 @@ module ${moduleName}.Swift {
19125
19138
  );
19126
19139
  stagedProducts.push(name);
19127
19140
  }
19128
- if (existsSync9(providedFrameworks)) {
19129
- for (const entry of readdirSync4(providedFrameworks))
19141
+ if (existsSync10(providedFrameworks)) {
19142
+ for (const entry of readdirSync5(providedFrameworks))
19130
19143
  if (!stagedProducts.includes(entry.replace(/\.framework$/, "")))
19131
19144
  rmSync7(path23.join(providedFrameworks, entry), { recursive: true, force: true });
19132
19145
  }
@@ -19143,7 +19156,7 @@ module ${moduleName}.Swift {
19143
19156
  ".build",
19144
19157
  "peach-framework-search.json"
19145
19158
  );
19146
- if (!existsSync9(frameworkSearchRecord) || readFileSync13(frameworkSearchRecord, "utf8") !== frameworkSearch)
19159
+ if (!existsSync10(frameworkSearchRecord) || readFileSync13(frameworkSearchRecord, "utf8") !== frameworkSearch)
19147
19160
  for (const cache of [
19148
19161
  path23.join(layout2.root, ".build", "ModuleCache"),
19149
19162
  path23.join(layout2.root, ".build", WASM_TRIPLE, "release", "ModuleCache")
@@ -19529,7 +19542,7 @@ ${entry}`);
19529
19542
  const reachesFrameworks = !distribution || swiftImportedModules.has("Foundation") || Object.entries(input.files).some(
19530
19543
  ([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
19531
19544
  ) || [...importedModules].some(
19532
- (name) => distribution.modules.includes(name) && !targets.some((target) => target.name === name) && !(clangImportedModules.has(name) && !swiftImportedModules.has(name) && existsSync9(
19545
+ (name) => distribution.modules.includes(name) && !targets.some((target) => target.name === name) && !(clangImportedModules.has(name) && !swiftImportedModules.has(name) && existsSync10(
19533
19546
  path23.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name)
19534
19547
  ))
19535
19548
  );
@@ -20081,9 +20094,9 @@ package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.
20081
20094
  syncSwiftTree(layout2.root, files, alreadySynced);
20082
20095
  if (layout2.multi)
20083
20096
  for (const target of targets)
20084
- mkdirSync7(path23.join(layout2.root, target.path), { recursive: true });
20097
+ mkdirSync8(path23.join(layout2.root, target.path), { recursive: true });
20085
20098
  const clangWrapper = path23.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
20086
- if (files.has(clangWrapper) && (statSync5(clangWrapper).mode & 4095) !== 493)
20099
+ if (files.has(clangWrapper) && (statSync6(clangWrapper).mode & 4095) !== 493)
20087
20100
  chmodSync4(clangWrapper, 493);
20088
20101
  return {
20089
20102
  ...nativePrerequisiteStageTargets.length ? { nativePrerequisiteTargets: nativePrerequisiteStageTargets } : {},
@@ -20199,21 +20212,21 @@ function readCompiledArtifact(directory, hash) {
20199
20212
  }
20200
20213
  function saveCompiledArtifact(root, artifact) {
20201
20214
  const directory = path23.join(root, "artifact");
20202
- mkdirSync7(directory, { recursive: true });
20215
+ mkdirSync8(directory, { recursive: true });
20203
20216
  const pending = mkdtempSync4(path23.join(root, ".artifact-"));
20204
20217
  try {
20205
20218
  const appLink = artifact.sdk?.binding.appLink;
20206
- if (appLink) writeFileSync7(path23.join(pending, "app-link.json.gz"), appLink);
20207
- writeFileSync7(path23.join(pending, "app.wasm"), artifact.bytes);
20208
- writeFileSync7(path23.join(pending, "icu.gz"), artifact.icu.gzip);
20219
+ if (appLink) writeFileSync8(path23.join(pending, "app-link.json.gz"), appLink);
20220
+ writeFileSync8(path23.join(pending, "app.wasm"), artifact.bytes);
20221
+ writeFileSync8(path23.join(pending, "icu.gz"), artifact.icu.gzip);
20209
20222
  if (artifact.sdk) {
20210
- writeFileSync7(path23.join(pending, "sdk-binding.bin"), artifact.sdk.binding.bytes);
20211
- writeFileSync7(
20223
+ writeFileSync8(path23.join(pending, "sdk-binding.bin"), artifact.sdk.binding.bytes);
20224
+ writeFileSync8(
20212
20225
  path23.join(pending, "sdk-live-slots.bin"),
20213
20226
  artifact.sdk.binding.liveSlots
20214
20227
  );
20215
20228
  }
20216
- writeFileSync7(
20229
+ writeFileSync8(
20217
20230
  path23.join(pending, "artifact.json"),
20218
20231
  JSON.stringify({
20219
20232
  hash: artifact.hash,
@@ -20232,7 +20245,7 @@ function saveCompiledArtifact(root, artifact) {
20232
20245
  if (artifact.sdk) outputs.push("sdk-binding.bin", "sdk-live-slots.bin");
20233
20246
  if (appLink) outputs.push("app-link.json.gz");
20234
20247
  for (const file of [...outputs, "artifact.json"]) {
20235
- renameSync5(path23.join(pending, file), path23.join(directory, file));
20248
+ renameSync6(path23.join(pending, file), path23.join(directory, file));
20236
20249
  }
20237
20250
  } finally {
20238
20251
  rmSync7(pending, { recursive: true, force: true });
@@ -20253,7 +20266,7 @@ function renewSharedArtifact(sharedRoot) {
20253
20266
  }
20254
20267
  function pruneSharedArtifacts(parent, keep) {
20255
20268
  const entries2 = [];
20256
- for (const name of readdirSync4(parent)) {
20269
+ for (const name of readdirSync5(parent)) {
20257
20270
  const directory = path23.join(parent, name);
20258
20271
  if (name.startsWith(RETIRED_PREFIX)) {
20259
20272
  reapRetiredCacheDirectory(parent, name);
@@ -20261,17 +20274,17 @@ function pruneSharedArtifacts(parent, keep) {
20261
20274
  }
20262
20275
  try {
20263
20276
  let bytes = 0;
20264
- for (const file of readdirSync4(path23.join(directory, "artifact"), {
20277
+ for (const file of readdirSync5(path23.join(directory, "artifact"), {
20265
20278
  recursive: true,
20266
20279
  encoding: "utf8"
20267
20280
  })) {
20268
20281
  try {
20269
- bytes += statSync5(path23.join(directory, "artifact", file)).size;
20282
+ bytes += statSync6(path23.join(directory, "artifact", file)).size;
20270
20283
  } catch (error) {
20271
20284
  if (!vanished(error)) throw error;
20272
20285
  }
20273
20286
  }
20274
- entries2.push({ directory, used: statSync5(directory).mtimeMs, bytes });
20287
+ entries2.push({ directory, used: statSync6(directory).mtimeMs, bytes });
20275
20288
  } catch (error) {
20276
20289
  if (!vanished(error)) throw error;
20277
20290
  }
@@ -20286,8 +20299,8 @@ function pruneSharedArtifacts(parent, keep) {
20286
20299
  `${RETIRED_PREFIX}${process.pid}-${path23.basename(entry.directory)}`
20287
20300
  );
20288
20301
  try {
20289
- if (statSync5(entry.directory).mtimeMs !== entry.used) continue;
20290
- renameSync5(entry.directory, retired);
20302
+ if (statSync6(entry.directory).mtimeMs !== entry.used) continue;
20303
+ renameSync6(entry.directory, retired);
20291
20304
  } catch (error) {
20292
20305
  if (vanished(error)) continue;
20293
20306
  throw error;
@@ -20371,7 +20384,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
20371
20384
  for (const name of reached)
20372
20385
  for (const member of libraries.get(name) ?? []) build(member);
20373
20386
  const overlays = path23.join(moduleRoot, "cross-import-overlays");
20374
- for (const directory of readdirSync4(overlays)) {
20387
+ for (const directory of readdirSync5(overlays)) {
20375
20388
  const companion = path23.basename(directory, ".swiftcrossimport");
20376
20389
  if (!built.has(companion)) continue;
20377
20390
  const declaration = path23.join(overlays, directory, "SwiftUI.swiftoverlay");
@@ -20424,12 +20437,12 @@ ${dependencies}
20424
20437
  )
20425
20438
  `;
20426
20439
  const sourceDir = path23.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
20427
- mkdirSync7(sourceDir, { recursive: true });
20440
+ mkdirSync8(sourceDir, { recursive: true });
20428
20441
  const manifestPath = path23.join(linkRoot, "Package.swift");
20429
- if (!existsSync9(manifestPath) || readFileSync13(manifestPath, "utf8") !== manifest)
20430
- writeFileSync7(manifestPath, manifest);
20442
+ if (!existsSync10(manifestPath) || readFileSync13(manifestPath, "utf8") !== manifest)
20443
+ writeFileSync8(manifestPath, manifest);
20431
20444
  const source = path23.join(sourceDir, "Link.swift");
20432
- if (!existsSync9(source)) writeFileSync7(source, "");
20445
+ if (!existsSync10(source)) writeFileSync8(source, "");
20433
20446
  }
20434
20447
  function frameworkLinkClosure(scratch, roots) {
20435
20448
  const suffix = `${WASM_TRIPLE}-release`;
@@ -20509,7 +20522,7 @@ function frameworkLinkClosure(scratch, roots) {
20509
20522
  owners.set(file, name);
20510
20523
  if (seen.has(file)) continue;
20511
20524
  seen.add(file);
20512
- if (!existsSync9(file))
20525
+ if (!existsSync10(file))
20513
20526
  throw new Error(`swift-compile: framework object ${file} was not built`);
20514
20527
  files.push(file);
20515
20528
  }
@@ -20525,9 +20538,9 @@ function frameworkLinkClosure(scratch, roots) {
20525
20538
  };
20526
20539
  }
20527
20540
  function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
20528
- if (!existsSync9(modulesDir)) return;
20541
+ if (!existsSync10(modulesDir)) return;
20529
20542
  const folded = new Set([...keep].map((name) => name.toLowerCase()));
20530
- for (const name of readdirSync4(modulesDir)) {
20543
+ for (const name of readdirSync5(modulesDir)) {
20531
20544
  const dot = name.indexOf(".");
20532
20545
  if (dot <= 0) continue;
20533
20546
  const module = name.slice(0, dot);
@@ -20549,7 +20562,7 @@ var frameworkProductsReceiptSchema = object({
20549
20562
  });
20550
20563
  function readFrameworkProductsReceipt(scratch, receiptKey, planChangedAt = 0n) {
20551
20564
  const receiptFile = path23.join(scratch, "products-ready", `${receiptKey}.json`);
20552
- const receiptStat = statSync5(receiptFile, { bigint: true, throwIfNoEntry: false });
20565
+ const receiptStat = statSync6(receiptFile, { bigint: true, throwIfNoEntry: false });
20553
20566
  if (!receiptStat || receiptStat.mtimeNs < planChangedAt) return null;
20554
20567
  let parsed;
20555
20568
  try {
@@ -20562,14 +20575,14 @@ function readFrameworkProductsReceipt(scratch, receiptKey, planChangedAt = 0n) {
20562
20575
  }
20563
20576
  const archiveRoot = path23.join(scratch, "products-lib", receiptKey);
20564
20577
  if (parsed.root !== archiveRoot) return null;
20565
- if (!existsSync9(parsed.modules)) return null;
20578
+ if (!existsSync10(parsed.modules)) return null;
20566
20579
  for (const [object2, rel] of parsed.archived) {
20567
- if (!existsSync9(object2) || !existsSync9(path23.join(archiveRoot, rel))) return null;
20580
+ if (!existsSync10(object2) || !existsSync10(path23.join(archiveRoot, rel))) return null;
20568
20581
  }
20569
- for (const file of parsed.providers) if (!existsSync9(file)) return null;
20570
- for (const file of parsed.moduleMaps) if (!existsSync9(file)) return null;
20571
- for (const file of parsed.objects) if (!existsSync9(file)) return null;
20572
- for (const file of parsed.lazyObjects) if (!existsSync9(file)) return null;
20582
+ for (const file of parsed.providers) if (!existsSync10(file)) return null;
20583
+ for (const file of parsed.moduleMaps) if (!existsSync10(file)) return null;
20584
+ for (const file of parsed.objects) if (!existsSync10(file)) return null;
20585
+ for (const file of parsed.lazyObjects) if (!existsSync10(file)) return null;
20573
20586
  return {
20574
20587
  root: parsed.root,
20575
20588
  modules: parsed.modules,
@@ -20585,8 +20598,8 @@ function readFrameworkProductsReceipt(scratch, receiptKey, planChangedAt = 0n) {
20585
20598
  function resolveBunBinary() {
20586
20599
  if (path23.basename(process.execPath).startsWith("bun")) return process.execPath;
20587
20600
  for (const candidate of [
20588
- path23.join(os3.homedir(), "builders/bun/bin/bun"),
20589
- path23.join(os3.homedir(), ".bun/bin/bun"),
20601
+ path23.join(os4.homedir(), "builders/bun/bin/bun"),
20602
+ path23.join(os4.homedir(), ".bun/bin/bun"),
20590
20603
  "/opt/homebrew/bin/bun",
20591
20604
  "/usr/local/bin/bun",
20592
20605
  "bun"
@@ -20599,8 +20612,8 @@ function resolveBunBinary() {
20599
20612
  function frameworkHeaderContext(moduleRoot, products) {
20600
20613
  const sources = path23.join(moduleRoot, "Sources");
20601
20614
  const files = [];
20602
- if (existsSync9(sources)) {
20603
- for (const entry of readdirSync4(sources, { recursive: true, withFileTypes: true })) {
20615
+ if (existsSync10(sources)) {
20616
+ for (const entry of readdirSync5(sources, { recursive: true, withFileTypes: true })) {
20604
20617
  if (!entry.isFile()) continue;
20605
20618
  const rel = path23.relative(sources, path23.join(entry.parentPath, entry.name));
20606
20619
  if (/\.(?:h|hh|hpp|hxx|inc|def|modulemap|apinotes)$/.test(rel)) files.push(rel);
@@ -20613,13 +20626,13 @@ function shellQuote(value) {
20613
20626
  }
20614
20627
  function prepareFrameworkCompileCache(scratch, moduleRoot, toolchainBin, sdkOptions, products) {
20615
20628
  const launcher = path23.join(moduleRoot, "scripts/build-cache-launcher.ts");
20616
- if (!existsSync9(launcher)) return null;
20629
+ if (!existsSync10(launcher)) return null;
20617
20630
  const bunBin = resolveBunBinary();
20618
20631
  if (!bunBin) return null;
20619
20632
  const cacheRoot = path23.join(swiftCacheDir(), "swift-distribution-compile-cache");
20620
- mkdirSync7(cacheRoot, { recursive: true });
20633
+ mkdirSync8(cacheRoot, { recursive: true });
20621
20634
  const wrapperDir = path23.join(scratch, "launch");
20622
- mkdirSync7(wrapperDir, { recursive: true });
20635
+ mkdirSync8(wrapperDir, { recursive: true });
20623
20636
  const wrapper = path23.join(wrapperDir, "swift-frontend");
20624
20637
  const statsFile = path23.join(scratch, `compile-cache-stats-${process.pid}.jsonl`);
20625
20638
  rmSync7(statsFile, { force: true });
@@ -20639,14 +20652,14 @@ function prepareFrameworkCompileCache(scratch, moduleRoot, toolchainBin, sdkOpti
20639
20652
  `exec ${shellQuote(bunBin)} ${shellQuote(launcher)} ${shellQuote(path23.join(toolchainBin, "swift-frontend"))} "$@"`,
20640
20653
  ""
20641
20654
  ].join("\n");
20642
- const partial = `${wrapper}.${process.pid}.${randomUUID4()}.partial`;
20643
- writeFileSync7(partial, script, { mode: 493 });
20655
+ const partial = `${wrapper}.${process.pid}.${randomUUID5()}.partial`;
20656
+ writeFileSync8(partial, script, { mode: 493 });
20644
20657
  chmodSync4(partial, 493);
20645
- renameSync5(partial, wrapper);
20658
+ renameSync6(partial, wrapper);
20646
20659
  return { wrapper, statsFile };
20647
20660
  }
20648
20661
  function reportFrameworkCompileCacheStats(scratch, statsFile) {
20649
- if (!existsSync9(statsFile)) return;
20662
+ if (!existsSync10(statsFile)) return;
20650
20663
  let hits = 0;
20651
20664
  let misses = 0;
20652
20665
  let savedMs = 0;
@@ -20694,8 +20707,8 @@ async function buildFrameworkProducts(scratch, args, allowWrite) {
20694
20707
  if (!allowWrite) return;
20695
20708
  const linkRoot = path23.join(scratch, "link");
20696
20709
  const manifest = path23.join(linkRoot, "Package.swift");
20697
- const manifestStat = statSync5(manifest, { bigint: true, throwIfNoEntry: false });
20698
- const planStat = statSync5(path23.join(scratch, "release.yaml"), {
20710
+ const manifestStat = statSync6(manifest, { bigint: true, throwIfNoEntry: false });
20711
+ const planStat = statSync6(path23.join(scratch, "release.yaml"), {
20699
20712
  bigint: true,
20700
20713
  throwIfNoEntry: false
20701
20714
  });
@@ -20712,7 +20725,7 @@ async function buildFrameworkProducts(scratch, args, allowWrite) {
20712
20725
  if (!reusePlan) {
20713
20726
  writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products);
20714
20727
  const frameworkTmp = path23.join(scratch, "peach-compiler-tmp");
20715
- mkdirSync7(frameworkTmp, { recursive: true });
20728
+ mkdirSync8(frameworkTmp, { recursive: true });
20716
20729
  const jobs = swiftCompilerJobs();
20717
20730
  const targetJobs = jobs >= 4 ? 2 : 1;
20718
20731
  const driverJobs = Math.max(1, Math.floor(jobs / targetJobs));
@@ -20811,9 +20824,9 @@ async function buildFrameworkProducts(scratch, args, allowWrite) {
20811
20824
  const constantsDir = path23.join(scratch, "uniform-type-constants");
20812
20825
  const constantsStamp = path23.join(constantsDir, ".complete");
20813
20826
  const object2 = path23.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
20814
- if (!existsSync9(constantsStamp) || readFileSync13(constantsStamp, "utf8") !== args.frameworkKey) {
20827
+ if (!existsSync10(constantsStamp) || readFileSync13(constantsStamp, "utf8") !== args.frameworkKey) {
20815
20828
  rmSync7(constantsDir, { recursive: true, force: true });
20816
- mkdirSync7(constantsDir);
20829
+ mkdirSync8(constantsDir);
20817
20830
  const sdkPaths = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
20818
20831
  compileUniformTypeConstants({
20819
20832
  bin: args.toolchainBin,
@@ -20823,14 +20836,14 @@ async function buildFrameworkProducts(scratch, args, allowWrite) {
20823
20836
  minimum: darwinRecordsMinimum(),
20824
20837
  out: constantsDir
20825
20838
  });
20826
- writeFileSync7(constantsStamp, args.frameworkKey);
20839
+ writeFileSync8(constantsStamp, args.frameworkKey);
20827
20840
  }
20828
20841
  objects.push(object2);
20829
20842
  linked.owners.set(object2, "UniformTypeIdentifiers");
20830
20843
  }
20831
20844
  removeCaseCollidingModuleArtifacts(path23.join(release, "Modules"), linked.modules);
20832
20845
  const response = path23.join(scratch, "autolink-objects.rsp");
20833
- writeFileSync7(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
20846
+ writeFileSync8(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
20834
20847
  const extracted = await runCompiler(
20835
20848
  path23.join(args.toolchainBin, "swift-autolink-extract"),
20836
20849
  [`@${response}`, "-o", "-"],
@@ -20849,9 +20862,9 @@ async function buildFrameworkProducts(scratch, args, allowWrite) {
20849
20862
  }
20850
20863
  const providerDir = path23.join(scratch, "darwin-records");
20851
20864
  const providerStamp = path23.join(providerDir, ".complete");
20852
- if (!existsSync9(providerStamp) || readFileSync13(providerStamp, "utf8") !== args.frameworkKey) {
20865
+ if (!existsSync10(providerStamp) || readFileSync13(providerStamp, "utf8") !== args.frameworkKey) {
20853
20866
  rmSync7(providerDir, { recursive: true, force: true });
20854
- mkdirSync7(providerDir);
20867
+ mkdirSync8(providerDir);
20855
20868
  const sdkPaths = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
20856
20869
  compileDarwinRecords({
20857
20870
  bin: args.toolchainBin,
@@ -20861,16 +20874,16 @@ async function buildFrameworkProducts(scratch, args, allowWrite) {
20861
20874
  minimum: darwinRecordsMinimum(),
20862
20875
  out: providerDir
20863
20876
  });
20864
- writeFileSync7(providerStamp, args.frameworkKey);
20877
+ writeFileSync8(providerStamp, args.frameworkKey);
20865
20878
  }
20866
- const providers = readdirSync4(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path23.join(providerDir, file));
20879
+ const providers = readdirSync5(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path23.join(providerDir, file));
20867
20880
  for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
20868
20881
  const archiveBase = path23.join(scratch, "products-lib");
20869
- mkdirSync7(archiveBase, { recursive: true });
20882
+ mkdirSync8(archiveBase, { recursive: true });
20870
20883
  const archiveRoot = path23.join(archiveBase, receiptKey);
20871
- const stagedArchiveRoot = `${archiveRoot}.tmp-${process.pid}-${randomUUID4()}`;
20884
+ const stagedArchiveRoot = `${archiveRoot}.tmp-${process.pid}-${randomUUID5()}`;
20872
20885
  const stagedArchive = path23.join(stagedArchiveRoot, "lib");
20873
- mkdirSync7(stagedArchive, { recursive: true });
20886
+ mkdirSync8(stagedArchive, { recursive: true });
20874
20887
  const archived = /* @__PURE__ */ new Map();
20875
20888
  try {
20876
20889
  for (const object2 of objects) {
@@ -20882,7 +20895,7 @@ async function buildFrameworkProducts(scratch, args, allowWrite) {
20882
20895
  archived.set(object2, `lib/${name}`);
20883
20896
  }
20884
20897
  rmSync7(archiveRoot, { recursive: true, force: true });
20885
- renameSync5(stagedArchiveRoot, archiveRoot);
20898
+ renameSync6(stagedArchiveRoot, archiveRoot);
20886
20899
  } catch (error) {
20887
20900
  rmSync7(stagedArchiveRoot, { recursive: true, force: true });
20888
20901
  throw error;
@@ -20909,10 +20922,10 @@ ${args.frameworkKey}`,
20909
20922
  objcHeaders: linked.objcHeaders
20910
20923
  };
20911
20924
  const receiptsDir = path23.join(scratch, "products-ready");
20912
- mkdirSync7(receiptsDir, { recursive: true });
20925
+ mkdirSync8(receiptsDir, { recursive: true });
20913
20926
  const receiptFile = path23.join(receiptsDir, `${receiptKey}.json`);
20914
- const partialReceipt = `${receiptFile}.${process.pid}.${randomUUID4()}`;
20915
- writeFileSync7(
20927
+ const partialReceipt = `${receiptFile}.${process.pid}.${randomUUID5()}`;
20928
+ writeFileSync8(
20916
20929
  partialReceipt,
20917
20930
  JSON.stringify({
20918
20931
  root: result.root,
@@ -20927,7 +20940,7 @@ ${args.frameworkKey}`,
20927
20940
  archived: [...archived.entries()]
20928
20941
  })
20929
20942
  );
20930
- renameSync5(partialReceipt, receiptFile);
20943
+ renameSync6(partialReceipt, receiptFile);
20931
20944
  return result;
20932
20945
  }
20933
20946
  var SWIFT_LINK_STAMP = ".peach-link-stamp";
@@ -20943,18 +20956,18 @@ var SWIFT_BUILD_ROOT_SHAPE = ".peach-build-shape";
20943
20956
  function swiftFrameworkSlotCount(unoptimized) {
20944
20957
  const base = unoptimized ? SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS : SWIFT_FRAMEWORK_SLOTS;
20945
20958
  if (process.platform === "darwin") {
20946
- const gib = os3.totalmem() / (1024 * 1024 * 1024);
20959
+ const gib = os4.totalmem() / (1024 * 1024 * 1024);
20947
20960
  if (gib >= 120) return unoptimized ? 8 : 16;
20948
20961
  if (gib >= 56) return unoptimized ? 6 : 12;
20949
20962
  return base;
20950
20963
  }
20951
20964
  if (process.platform !== "linux") return base;
20952
- const cores = os3.availableParallelism();
20965
+ const cores = os4.availableParallelism();
20953
20966
  return unoptimized ? Math.min(8, Math.max(base, Math.floor(cores / 16))) : Math.min(16, Math.max(base, Math.floor(cores / 8)));
20954
20967
  }
20955
20968
  function swiftBuildRootSlotCount() {
20956
20969
  if (process.platform !== "linux") return SWIFT_BUILD_ROOT_SLOTS;
20957
- return os3.availableParallelism() >= 64 ? 8 : SWIFT_BUILD_ROOT_SLOTS;
20970
+ return os4.availableParallelism() >= 64 ? 8 : SWIFT_BUILD_ROOT_SLOTS;
20958
20971
  }
20959
20972
  function swiftFrameworksDir(unoptimized = false) {
20960
20973
  return path23.join(
@@ -20982,13 +20995,13 @@ async function withSwiftFrameworkSlot(frameworkKey, release, moduleRoot, signal,
20982
20995
  const slotsDir = swiftFrameworksDir(unoptimized);
20983
20996
  const slots = Array.from({ length: slotCount }, (_, index) => {
20984
20997
  const slot = path23.join(slotsDir, `slot-${index}`);
20985
- mkdirSync7(slot, { recursive: true });
20998
+ mkdirSync8(slot, { recursive: true });
20986
20999
  return slot;
20987
21000
  });
20988
21001
  const own = (slot) => swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN) === moduleRoot;
20989
21002
  const slotMtimeMs = (slot) => {
20990
21003
  try {
20991
- return statSync5(slot).mtimeMs;
21004
+ return statSync6(slot).mtimeMs;
20992
21005
  } catch (error) {
20993
21006
  if (vanished(error)) return 0;
20994
21007
  throw error;
@@ -20996,7 +21009,7 @@ async function withSwiftFrameworkSlot(frameworkKey, release, moduleRoot, signal,
20996
21009
  };
20997
21010
  const handoffFile = (slot) => path23.join(slot, SWIFT_FRAMEWORK_SLOT_HANDOFF);
20998
21011
  const hasPendingForeignHandoff = (slot, now) => {
20999
- const stamp = statSync5(handoffFile(slot), { throwIfNoEntry: false });
21012
+ const stamp = statSync6(handoffFile(slot), { throwIfNoEntry: false });
21000
21013
  return stamp !== void 0 && !own(slot) && now - stamp.mtimeMs < SWIFT_FRAMEWORK_HANDOFF_MS;
21001
21014
  };
21002
21015
  const trySlot = (slot, mode, logSelection, allowPendingHandoff = true) => {
@@ -21021,7 +21034,7 @@ async function withSwiftFrameworkSlot(frameworkKey, release, moduleRoot, signal,
21021
21034
  `[swift-framework-cache] ${path23.basename(slot)} hit=products release=${release}`
21022
21035
  );
21023
21036
  const now = /* @__PURE__ */ new Date();
21024
- if (linkOnly) writeFileSync7(handoffFile(slot), "");
21037
+ if (linkOnly) writeFileSync8(handoffFile(slot), "");
21025
21038
  else rmSync7(handoffFile(slot), { force: true });
21026
21039
  utimesSync(slot, now, now);
21027
21040
  return { value };
@@ -21057,7 +21070,7 @@ async function withSwiftFrameworkSlot(frameworkKey, release, moduleRoot, signal,
21057
21070
  for (const [file, contents] of inputs) {
21058
21071
  try {
21059
21072
  const candidate = path23.join(source, file);
21060
- if (statSync5(candidate).size !== contents.length || !readFileSync13(candidate).equals(contents))
21073
+ if (statSync6(candidate).size !== contents.length || !readFileSync13(candidate).equals(contents))
21061
21074
  changes++;
21062
21075
  } catch (error) {
21063
21076
  if (!vanished(error)) throw error;
@@ -21124,7 +21137,7 @@ async function withSwiftFrameworkSlot(frameworkKey, release, moduleRoot, signal,
21124
21137
  async function withSwiftBuildRootSlot(baseRoot, exactShape, compatShape, signal, work) {
21125
21138
  const slots = Array.from({ length: swiftBuildRootSlotCount() }, (_, index) => {
21126
21139
  const slot = index === 0 ? baseRoot : `${baseRoot}-s${index}`;
21127
- mkdirSync7(slot, { recursive: true });
21140
+ mkdirSync8(slot, { recursive: true });
21128
21141
  return slot;
21129
21142
  });
21130
21143
  const runInSlot = (slot, waitStart2) => (lease) => {
@@ -21133,7 +21146,7 @@ async function withSwiftBuildRootSlot(baseRoot, exactShape, compatShape, signal,
21133
21146
  utimesSync(slot, now, now);
21134
21147
  return work(slot, lease, waitedMs);
21135
21148
  };
21136
- const built = new Map(slots.map((slot) => [slot, statSync5(slot).mtimeMs]));
21149
+ const built = new Map(slots.map((slot) => [slot, statSync6(slot).mtimeMs]));
21137
21150
  const ranked = slots.map((slot, index) => {
21138
21151
  const record = swiftFrameworkSlotRecord(slot, SWIFT_BUILD_ROOT_SHAPE);
21139
21152
  const [slotExact, slotCompat] = record ? record.split("\n") : [null, null];
@@ -21160,10 +21173,10 @@ async function withSwiftBuildRootSlot(baseRoot, exactShape, compatShape, signal,
21160
21173
  return withSwiftRootLock(nearest, runInSlot(nearest, waitStart), signal);
21161
21174
  }
21162
21175
  function mirrorTree(source, target, skip) {
21163
- mkdirSync7(target, { recursive: true });
21176
+ mkdirSync8(target, { recursive: true });
21164
21177
  const wanted = /* @__PURE__ */ new Set();
21165
21178
  let restructured = false;
21166
- for (const entry of readdirSync4(source, { withFileTypes: true })) {
21179
+ for (const entry of readdirSync5(source, { withFileTypes: true })) {
21167
21180
  if (entry.name === skip) continue;
21168
21181
  wanted.add(entry.name);
21169
21182
  const from = path23.join(source, entry.name);
@@ -21184,17 +21197,17 @@ function mirrorTree(source, target, skip) {
21184
21197
  if (existing) rmSync7(to, { recursive: true, force: true });
21185
21198
  symlinkSync3(link, to);
21186
21199
  } else {
21187
- const stat = statSync5(from);
21200
+ const stat = statSync6(from);
21188
21201
  if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs || readFileSync13(from).equals(readFileSync13(to))))
21189
21202
  continue;
21190
21203
  if (existing) rmSync7(to, { recursive: true, force: true });
21191
- const partial = `${to}.${randomUUID4()}`;
21204
+ const partial = `${to}.${randomUUID5()}`;
21192
21205
  copyFileSync2(from, partial);
21193
21206
  if (stat.mtimeMs > Date.now()) utimesSync(partial, stat.atime, stat.mtime);
21194
- renameSync5(partial, to);
21207
+ renameSync6(partial, to);
21195
21208
  }
21196
21209
  }
21197
- for (const name of readdirSync4(target))
21210
+ for (const name of readdirSync5(target))
21198
21211
  if (!wanted.has(name) && name !== skip) {
21199
21212
  rmSync7(path23.join(target, name), { recursive: true, force: true });
21200
21213
  restructured = true;
@@ -21223,8 +21236,8 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
21223
21236
  if (!file.startsWith("../")) continue;
21224
21237
  const from = path23.resolve(moduleRoot, file);
21225
21238
  const to = path23.resolve(stagedModule, file);
21226
- if (existsSync9(to) && readFileSync13(from).equals(readFileSync13(to))) continue;
21227
- mkdirSync7(path23.dirname(to), { recursive: true });
21239
+ if (existsSync10(to) && readFileSync13(from).equals(readFileSync13(to))) continue;
21240
+ mkdirSync8(path23.dirname(to), { recursive: true });
21228
21241
  copyFileSync2(from, to);
21229
21242
  }
21230
21243
  const staleInputs = swiftModuleInputFiles(stagedModule).filter(
@@ -21238,15 +21251,15 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
21238
21251
  throw new Error("Swift staged framework source differs from the caller");
21239
21252
  const modules = path23.join(staged, "node_modules");
21240
21253
  const target = realpathSync6(path23.join(moduleRoot, "../../node_modules"));
21241
- if (!existsSync9(modules) || readlinkSync2(modules) !== target) {
21254
+ if (!existsSync10(modules) || readlinkSync2(modules) !== target) {
21242
21255
  rmSync7(modules, { recursive: true, force: true });
21243
21256
  symlinkSync3(target, modules);
21244
21257
  }
21245
- writeFileSync7(path23.join(slot, SWIFT_FRAMEWORK_SLOT_RELEASE), release);
21246
- writeFileSync7(path23.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
21247
- writeFileSync7(path23.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
21258
+ writeFileSync8(path23.join(slot, SWIFT_FRAMEWORK_SLOT_RELEASE), release);
21259
+ writeFileSync8(path23.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
21260
+ writeFileSync8(path23.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
21248
21261
  } else if (swiftFrameworkSlotRelease(slot) !== release) {
21249
- writeFileSync7(path23.join(slot, SWIFT_FRAMEWORK_SLOT_RELEASE), release);
21262
+ writeFileSync8(path23.join(slot, SWIFT_FRAMEWORK_SLOT_RELEASE), release);
21250
21263
  }
21251
21264
  return stagedModule;
21252
21265
  }
@@ -21259,7 +21272,7 @@ ${args.frameworkKey}
21259
21272
  hash.update("package-host-macros\n" + JSON.stringify(args.packageHostMacros));
21260
21273
  if (!args.prebuilt) return hash.digest("hex");
21261
21274
  const statOf = (file) => {
21262
- const stat = statSync5(file, { bigint: true });
21275
+ const stat = statSync6(file, { bigint: true });
21263
21276
  return `${stat.size}:${stat.mtimeNs}`;
21264
21277
  };
21265
21278
  for (const object2 of args.prebuilt.objects)
@@ -21284,7 +21297,7 @@ ${args.prebuilt.link.join("\n")}
21284
21297
  hash.update(`modules
21285
21298
  ${args.prebuilt.modules}
21286
21299
  `);
21287
- for (const entry of readdirSync4(args.prebuilt.modules).sort())
21300
+ for (const entry of readdirSync5(args.prebuilt.modules).sort())
21288
21301
  hash.update(`${entry}
21289
21302
  ${statOf(path23.join(args.prebuilt.modules, entry))}`);
21290
21303
  return hash.digest("hex");
@@ -21303,16 +21316,16 @@ function retireSwiftLinkTargets(retired) {
21303
21316
  rmSync7(path23.join(retired, name), { recursive: true, force: true });
21304
21317
  }
21305
21318
  const releaseLink = path23.join(retired, "release");
21306
- if (!existsSync9(releaseLink)) return;
21319
+ if (!existsSync10(releaseLink)) return;
21307
21320
  const releaseDir = realpathSync6(releaseLink);
21308
- for (const entry of readdirSync4(releaseDir, { withFileTypes: true })) {
21321
+ for (const entry of readdirSync5(releaseDir, { withFileTypes: true })) {
21309
21322
  const targetPath = path23.join(releaseDir, entry.name);
21310
21323
  if (entry.name === "ModuleCache" || entry.name === "Modules" || entry.name.endsWith(".product") || entry.name.endsWith(".wasm")) {
21311
21324
  rmSync7(targetPath, { recursive: true, force: true });
21312
21325
  continue;
21313
21326
  }
21314
21327
  if (!entry.isDirectory() || !entry.name.endsWith(".build")) continue;
21315
- const hasSwift = readdirSync4(targetPath).some(
21328
+ const hasSwift = readdirSync5(targetPath).some(
21316
21329
  (file) => file === "master.swiftdeps" || file.endsWith(".swiftdeps") || file.endsWith(".swift.o") || file.endsWith(".swiftmodule")
21317
21330
  );
21318
21331
  if (hasSwift) rmSync7(targetPath, { recursive: true, force: true });
@@ -21330,15 +21343,15 @@ function retireStaleSwiftLink(root, baseStamp, stamp, preserveClangObjects = fal
21330
21343
  ${preserveClangObjects ? "swift-targets-v2\n" : ""}${stamp}`;
21331
21344
  if (previous === combined) return false;
21332
21345
  const retired = path23.join(root, ".build");
21333
- const hadBuild = existsSync9(retired);
21346
+ const hadBuild = existsSync10(retired);
21334
21347
  const [previousBase] = previous?.split("\n") ?? [];
21335
21348
  if (hadBuild) {
21336
21349
  if (preserveClangObjects && previousBase === baseStamp)
21337
21350
  retireSwiftLinkTargets(retired);
21338
21351
  else rmSync7(retired, { recursive: true, force: true });
21339
21352
  }
21340
- mkdirSync7(root, { recursive: true });
21341
- writeFileSync7(receipt, `${combined}
21353
+ mkdirSync8(root, { recursive: true });
21354
+ writeFileSync8(receipt, `${combined}
21342
21355
  `);
21343
21356
  return hadBuild;
21344
21357
  }
@@ -21353,809 +21366,856 @@ async function compileSwiftProjectUnit(input, options) {
21353
21366
  }
21354
21367
  }
21355
21368
  async function compileSwiftProjectOnce(sources, options) {
21356
- options.signal?.throwIfAborted();
21357
- assertSwiftBuildCores();
21358
- mkdirSync7(options.buildRoot, { recursive: true });
21359
- const root = realpathSync6(options.buildRoot);
21360
- refreshSwiftCacheHold(root);
21361
- const moduleRoot = path23.resolve(options.moduleRoot);
21362
- const distribution = swiftDistributionAt(moduleRoot);
21363
- const mirrorDistribution = options.linkOnly || options.project ? null : distribution;
21364
- if (distribution) refreshSwiftCacheHold(moduleRoot);
21365
- const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-DOKKJSSS.mjs")).useSwiftPackagePrebuilts(
21366
- sources,
21367
- moduleRoot,
21368
- options.toolchainBin
21369
- ) : sources;
21370
- const guestGraph = distribution ? input.sourceLinkGraph : void 0;
21371
- if (options.linkOnly && guestGraph)
21372
- throw new Error("swift-compile: link-only builds do not support guest image graphs");
21373
- const layout2 = {
21374
- root,
21375
- sources: path23.join(root, "Sources", "App"),
21376
- multi: compileTargets(input).length > 0
21377
- };
21378
- const sdkImage = options.linkOnly ? void 0 : await (await import("./swift-sdk-image-IPXHOUXE.mjs")).buildSwiftSdkImage(
21379
- moduleRoot,
21380
- !!guestGraph,
21381
- distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
21382
- { signal: options.signal }
21383
- );
21384
- const inputHash = swiftCompileInputHash(input, options.release);
21385
- const moduleDigest = swiftModuleDigest(moduleRoot);
21386
- const sourceHash = inputHash.copy().update(moduleDigest).digest("hex");
21387
- const hash = sdkImage ? swiftSdkArtifactHash(sourceHash, sdkImage.key) : sourceHash;
21388
- const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
21389
- const sharedRoot = path23.join(swiftCacheDir(), "swift-projects", hash);
21390
- const report = (message) => {
21391
- console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
21392
- options.onStage?.(message);
21393
- };
21394
- return serialize(
21395
- root,
21396
- async () => {
21397
- if (!options.intermediates) {
21398
- report("checking verified artifacts");
21399
- const retained = retainedArtifacts.get(root)?.find((old) => old.hash === hash);
21400
- if (retained) {
21401
- report("reusing memory artifact");
21402
- return retain(root, retained);
21403
- }
21404
- const cached = readCompiledArtifact(path23.join(sharedRoot, "artifact"), hash);
21405
- const previous = cached ?? (options.project ? null : readCompiledArtifact(path23.join(root, "artifact"), hash));
21406
- if (previous) {
21407
- if (cached) renewSharedArtifact(sharedRoot);
21408
- else saveSharedArtifact(sharedRoot, previous);
21409
- report("reusing verified disk artifact");
21410
- return retain(root, previous);
21411
- }
21412
- }
21413
- const baseRoot = root;
21414
- const canPoolBuildRoot = !options.intermediates && !options.project && !options.linkOnly && path23.basename(path23.dirname(baseRoot)) === "swift-builds";
21415
- const compatShapeParts = canPoolBuildRoot ? [
21416
- distribution ? options.release : frameworkKey,
21417
- compileTargets(input).map((target) => target.name).sort(),
21418
- input.oneModule === true,
21419
- input.optimize === true,
21420
- input.unoptimized === true
21421
- ] : null;
21422
- const compatShape = compatShapeParts ? createHash15("sha256").update(JSON.stringify(compatShapeParts)).digest("hex").slice(0, 16) : "";
21423
- const exactShape = compatShapeParts ? createHash15("sha256").update(
21424
- JSON.stringify([...compatShapeParts, Object.keys(input.files).sort()])
21425
- ).digest("hex").slice(0, 16) : "";
21426
- const buildShape = compatShapeParts ? `${exactShape}
21427
- ${compatShape}` : "";
21428
- return withSwiftCompileBudget(options.timeoutMs, options.signal, async (budget) => {
21429
- const stage = (message) => {
21430
- budget.progress();
21431
- report(message);
21432
- };
21433
- const runLocked = (work) => {
21434
- const runInBuildRoot = () => {
21435
- if (canPoolBuildRoot)
21436
- return withSwiftBuildRootSlot(
21437
- baseRoot,
21438
- exactShape,
21439
- compatShape,
21440
- budget.signal,
21441
- work
21442
- );
21443
- const waitStart = Date.now();
21444
- return withSwiftRootLock(
21445
- baseRoot,
21446
- (lease) => work(baseRoot, lease, Date.now() - waitStart),
21447
- budget.signal
21448
- );
21449
- };
21450
- if (options.intermediates || baseRoot === sharedRoot) return runInBuildRoot();
21451
- return withSwiftRootLock(
21452
- sharedRoot,
21453
- async () => {
21454
- const built = readCompiledArtifact(path23.join(sharedRoot, "artifact"), hash);
21455
- if (built) {
21456
- renewSharedArtifact(sharedRoot);
21457
- stage("reusing verified disk artifact");
21458
- return retain(baseRoot, built);
21459
- }
21460
- return runInBuildRoot();
21461
- },
21462
- budget.signal
21463
- );
21464
- };
21465
- return runLocked(async (slotRoot, lease, waitedMs) => {
21466
- const root2 = slotRoot;
21467
- const layout3 = {
21468
- root: root2,
21469
- sources: path23.join(root2, "Sources", "App"),
21470
- multi: compileTargets(input).length > 0
21471
- };
21472
- if (!options.intermediates) {
21473
- const built = readCompiledArtifact(path23.join(sharedRoot, "artifact"), hash);
21474
- if (built) {
21475
- stage("reusing verified disk artifact");
21476
- return retain(baseRoot, built);
21477
- }
21478
- }
21479
- if (waitedMs >= 1e3)
21480
- report(`acquired build root ${path23.basename(root2)} after ${waitedMs}ms`);
21481
- if (canPoolBuildRoot) {
21482
- refreshSwiftCacheHold(root2);
21483
- writeFileSync7(path23.join(root2, SWIFT_BUILD_ROOT_SHAPE), buildShape);
21369
+ return withSwiftModuleDigestScope(async () => {
21370
+ options.signal?.throwIfAborted();
21371
+ mkdirSync8(options.buildRoot, { recursive: true });
21372
+ const root = realpathSync6(options.buildRoot);
21373
+ refreshSwiftCacheHold(root);
21374
+ const moduleRoot = path23.resolve(options.moduleRoot);
21375
+ const distribution = swiftDistributionAt(moduleRoot);
21376
+ const mirrorDistribution = options.linkOnly || options.project ? null : distribution;
21377
+ if (distribution) refreshSwiftCacheHold(moduleRoot);
21378
+ let resolvedToolchainBin = options.toolchainBin;
21379
+ const resolveToolchainBin = () => {
21380
+ if (resolvedToolchainBin) return resolvedToolchainBin;
21381
+ if (!options.resolveToolchain)
21382
+ throw new Error("swift-compile: missing toolchainBin");
21383
+ resolvedToolchainBin = options.resolveToolchain();
21384
+ return resolvedToolchainBin;
21385
+ };
21386
+ const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-ZOQMKNDR.mjs")).useSwiftPackagePrebuilts(
21387
+ sources,
21388
+ moduleRoot,
21389
+ resolveToolchainBin
21390
+ ) : sources;
21391
+ const guestGraph = distribution ? input.sourceLinkGraph : void 0;
21392
+ if (options.linkOnly && guestGraph)
21393
+ throw new Error("swift-compile: link-only builds do not support guest image graphs");
21394
+ const layout2 = {
21395
+ root,
21396
+ sources: path23.join(root, "Sources", "App"),
21397
+ multi: compileTargets(input).length > 0
21398
+ };
21399
+ const sdkImage = options.linkOnly ? void 0 : await (await import("./swift-sdk-image-P5NS5P7F.mjs")).buildSwiftSdkImage(
21400
+ moduleRoot,
21401
+ !!guestGraph,
21402
+ distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
21403
+ { signal: options.signal }
21404
+ );
21405
+ const inputHash = swiftCompileInputHash(input, options.release);
21406
+ const moduleDigest = swiftModuleDigest(moduleRoot);
21407
+ const sourceHash = inputHash.copy().update(moduleDigest).digest("hex");
21408
+ const hash = sdkImage ? swiftSdkArtifactHash(sourceHash, sdkImage.key) : sourceHash;
21409
+ const sharedRoot = path23.join(swiftCacheDir(), "swift-projects", hash);
21410
+ const report = (message) => {
21411
+ console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
21412
+ options.onStage?.(message);
21413
+ };
21414
+ return serialize(
21415
+ root,
21416
+ async () => {
21417
+ if (!options.intermediates) {
21418
+ report("checking verified artifacts");
21419
+ const retained = retainedArtifacts.get(root)?.find((old) => old.hash === hash);
21420
+ if (retained) {
21421
+ report("reusing memory artifact");
21422
+ return retain(root, retained);
21484
21423
  }
21485
- const swift = path23.join(options.toolchainBin, "swift");
21486
- if (!existsSync9(swift)) {
21487
- throw new Error(
21488
- `swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
21489
- );
21424
+ const cached = readCompiledArtifact(path23.join(sharedRoot, "artifact"), hash);
21425
+ const previous = cached ?? (options.project ? null : readCompiledArtifact(path23.join(root, "artifact"), hash));
21426
+ if (previous) {
21427
+ if (cached) renewSharedArtifact(sharedRoot);
21428
+ else saveSharedArtifact(sharedRoot, previous);
21429
+ report("reusing verified disk artifact");
21430
+ return retain(root, previous);
21490
21431
  }
21491
- const unoptimized = input.unoptimized === true;
21492
- const baseBuildEnv = options.project?.env ? {
21493
- ...options.project.env,
21494
- // shipped host plugins resolve against the selected compiler's runtime.
21495
- ...process.platform === "linux" ? {
21496
- LD_LIBRARY_PATH: [
21497
- path23.resolve(options.toolchainBin, "../lib/swift/linux"),
21498
- path23.resolve(options.toolchainBin, "../lib/swift/host"),
21499
- process.env.LD_LIBRARY_PATH
21500
- ].filter(Boolean).join(":")
21501
- } : {},
21502
- PEACH_DEFER_WASM_LINK: "1"
21503
- } : swiftCompilerBaseEnv(options.toolchainBin, process.env);
21504
- const prepareFrameworks = async (slot, frameworkLease, allowWrite = true) => {
21505
- if (allowWrite) budget.startCompile();
21506
- const frameworkRoot2 = mirrorDistribution ? syncSwiftDistributionMirror(root2, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(moduleRoot, slot, frameworkKey, options.release);
21507
- if (!swiftModuleDigest(frameworkRoot2).equals(moduleDigest))
21508
- throw new Error("Swift staged project source differs from the caller");
21509
- if (!allowWrite && swiftMacroPlugins(frameworkRoot2).stale) return;
21510
- if (allowWrite) stage("preparing compiler plugins");
21511
- const macroPlugins2 = await ensureMacroPlugins(
21512
- frameworkRoot2,
21513
- options.toolchainBin,
21514
- options.release,
21515
- budget.signal,
21516
- frameworkLease
21517
- );
21518
- const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
21519
- const sdk = swiftModuleSdk(frameworkRoot2).wasmSdkId;
21520
- const compileSdk2 = mirrorDistribution ? syncSwiftSdkMirror(root2, frameworkRoot2, options.toolchainBin, sdk) : {
21521
- id: sdk,
21522
- options: swiftCompileSdkOptions(frameworkRoot2, options.toolchainBin),
21523
- toolsetChanged: false
21432
+ }
21433
+ assertSwiftBuildCores();
21434
+ const toolchainBin = resolveToolchainBin();
21435
+ await options.beforeCompile?.(toolchainBin);
21436
+ clearSwiftModuleDigestScope(moduleRoot);
21437
+ const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
21438
+ const baseRoot = root;
21439
+ const canPoolBuildRoot = !options.intermediates && !options.project && !options.linkOnly && path23.basename(path23.dirname(baseRoot)) === "swift-builds";
21440
+ const compatShapeParts = canPoolBuildRoot ? [
21441
+ distribution ? options.release : frameworkKey,
21442
+ compileTargets(input).map((target) => target.name).sort(),
21443
+ input.oneModule === true,
21444
+ input.optimize === true,
21445
+ input.unoptimized === true
21446
+ ] : null;
21447
+ const compatShape = compatShapeParts ? createHash15("sha256").update(JSON.stringify(compatShapeParts)).digest("hex").slice(0, 16) : "";
21448
+ const exactShape = compatShapeParts ? createHash15("sha256").update(
21449
+ JSON.stringify([...compatShapeParts, Object.keys(input.files).sort()])
21450
+ ).digest("hex").slice(0, 16) : "";
21451
+ const buildShape = compatShapeParts ? `${exactShape}
21452
+ ${compatShape}` : "";
21453
+ return withSwiftCompileBudget(
21454
+ options.timeoutMs,
21455
+ options.signal,
21456
+ async (budget) => {
21457
+ const stage = (message) => {
21458
+ budget.progress();
21459
+ report(message);
21524
21460
  };
21525
- if (mirrorDistribution && compileSdk2.toolsetChanged)
21526
- clearSwiftSdkPathsCache(path23.join(root2, SWIFT_SDK_MIRROR));
21527
- const icu2 = options.linkOnly ? null : swiftIcuAsset(options.toolchainBin, sdk);
21528
- let prebuilt2;
21529
- if (!distribution) {
21530
- if (allowWrite) stage("compiling framework products");
21531
- prebuilt2 = await buildFrameworkProducts(
21532
- slot,
21533
- {
21534
- moduleRoot: frameworkRoot2,
21535
- frameworkKey,
21536
- input,
21537
- swift,
21538
- sdk,
21539
- toolchainBin: options.toolchainBin,
21540
- plugins: macroPlugins2,
21541
- buildOptions: {
21542
- env: baseBuildEnv,
21543
- maxBuffer: 64 * 1024 * 1024,
21544
- signal: budget.signal,
21545
- onOutput: budget.progress,
21546
- lease,
21547
- frameworkLease
21461
+ const runLocked = (work) => {
21462
+ const runInBuildRoot = () => {
21463
+ if (canPoolBuildRoot)
21464
+ return withSwiftBuildRootSlot(
21465
+ baseRoot,
21466
+ exactShape,
21467
+ compatShape,
21468
+ budget.signal,
21469
+ work
21470
+ );
21471
+ const waitStart = Date.now();
21472
+ return withSwiftRootLock(
21473
+ baseRoot,
21474
+ (lease) => work(baseRoot, lease, Date.now() - waitStart),
21475
+ budget.signal
21476
+ );
21477
+ };
21478
+ if (options.intermediates || baseRoot === sharedRoot)
21479
+ return runInBuildRoot();
21480
+ return withSwiftRootLock(
21481
+ sharedRoot,
21482
+ async () => {
21483
+ const built = readCompiledArtifact(
21484
+ path23.join(sharedRoot, "artifact"),
21485
+ hash
21486
+ );
21487
+ if (built) {
21488
+ renewSharedArtifact(sharedRoot);
21489
+ stage("reusing verified disk artifact");
21490
+ return retain(baseRoot, built);
21548
21491
  }
21492
+ return runInBuildRoot();
21549
21493
  },
21550
- allowWrite
21494
+ budget.signal
21551
21495
  );
21552
- if (!prebuilt2) return;
21553
- if (!allowWrite) {
21554
- budget.startCompile();
21555
- stage("reusing verified framework products");
21556
- }
21557
- }
21558
- const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
21559
- return {
21560
- frameworkRoot: frameworkRoot2,
21561
- compileFrameworkRoot: compileFrameworkRoot2,
21562
- macroPlugins: macroPlugins2,
21563
- sdk,
21564
- compileSdk: compileSdk2,
21565
- icu: icu2,
21566
- prebuilt: prebuilt2,
21567
- readHold: readHold2
21568
21496
  };
21569
- };
21570
- const frameworks = distribution ? await prepareFrameworks(null) : await withSwiftFrameworkSlot(
21571
- frameworkKey,
21572
- options.release,
21573
- moduleRoot,
21574
- budget.signal,
21575
- prepareFrameworks,
21576
- unoptimized,
21577
- options.linkOnly === true
21578
- );
21579
- if (!frameworks)
21580
- throw new Error("Swift distribution did not provide its frameworks");
21581
- const {
21582
- frameworkRoot,
21583
- compileFrameworkRoot,
21584
- macroPlugins,
21585
- compileSdk,
21586
- icu,
21587
- prebuilt
21588
- } = frameworks;
21589
- let readHold = frameworks.readHold;
21590
- const buildOptions = {
21591
- env: baseBuildEnv,
21592
- maxBuffer: 64 * 1024 * 1024,
21593
- signal: budget.signal,
21594
- onOutput: budget.progress,
21595
- lease
21596
- };
21597
- try {
21598
- if (options.project) removeProjectLinks(root2);
21599
- const packageHostMacros = process.platform === "linux" ? input.packageHostMacros : void 0;
21600
- if (retireStaleSwiftLink(
21601
- root2,
21602
- swiftLinkStamp({
21603
- frameworkKey: mirrorDistribution ? `${options.release}\0mirror` : `${options.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
21604
- packageHostMacros
21605
- }),
21606
- swiftLinkStamp({
21607
- // mirrored distributions and their WASI SDK mirror invalidate
21608
- // dependents per changed file instead of wiping every Clang object.
21609
- frameworkKey: mirrorDistribution ? `${options.release}\0mirror` : distribution ? `${options.release}\0${distribution.wasmSdkChecksum}` : frameworkKey,
21610
- prebuilt,
21611
- packageHostMacros
21612
- }),
21613
- Boolean(options.linkOnly)
21614
- ))
21615
- stage("framework revision changed; rebuilding the app link");
21616
- const nativeToolset = needsNativeToolset(input, prebuilt);
21617
- const preparation = writeSwiftProject(
21618
- layout3,
21619
- input,
21620
- frameworkRoot,
21621
- prebuilt,
21622
- !options.project,
21623
- options.project ? false : options.objcPrebuiltStage ?? (options.intermediates ? false : void 0),
21624
- compileSdk
21625
- );
21626
- const productFile = path23.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
21627
- writeSwiftAutolinkLinker(
21628
- root2,
21629
- options.toolchainBin,
21630
- existsSync9(productFile) ? [
21631
- parse(
21632
- swiftFrameworkProductSchema,
21633
- JSON.parse(readFileSync13(productFile, "utf8"))
21634
- ).product.name
21635
- ] : []
21636
- );
21637
- const compiler = preparation.targetToolset ? { CC: path23.join(root2, CLANG_TARGET_MODULE_WRAPPER) } : {};
21638
- if (packageHostMacros?.length) {
21639
- const swiftc = path23.join(root2, SWIFT_HOST_COMPILER_WRAPPER);
21640
- writeBuildFile(
21641
- swiftc,
21642
- [
21643
- "#!/bin/sh",
21644
- "target=",
21645
- "module=",
21646
- "compile=",
21647
- "previous=",
21648
- "for argument do",
21649
- ' case "$previous" in -target) target=$argument ;; -module-name) module=$argument ;; esac',
21650
- ' case "$argument" in -c|-emit-module|-scan-dependencies|-typecheck) compile=1 ;; esac',
21651
- " previous=$argument",
21652
- "done",
21653
- 'case "$target/$compile" in',
21654
- " *-*-linux*/1)",
21655
- ' case ",$PEACH_SWIFT_HOST_MACROS," in',
21656
- ' *",$module,"*) set -- "$@" -Xfrontend -import-module -Xfrontend Foundation ;;',
21657
- " esac ;;",
21658
- "esac",
21659
- 'exec "$PEACH_SWIFTC" "$@"',
21660
- ""
21661
- ].join("\n")
21662
- );
21663
- chmodSync4(swiftc, 493);
21664
- compiler.SWIFT_EXEC = swiftc;
21665
- compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
21666
- compiler.PEACH_SWIFTC = path23.join(options.toolchainBin, "swiftc");
21667
- }
21668
- const projectProcess = options.project ? prepareSwiftProjectProcess(root2, options.project) : void 0;
21669
- const temporaryDirectory = projectProcess ? void 0 : path23.join(root2, ".build", "peach-compiler-tmp");
21670
- const appOptions = projectProcess ? {
21671
- ...buildOptions,
21672
- uid: projectProcess.uid,
21673
- gid: projectProcess.gid,
21674
- confined: { ...projectProcess.env, ...compiler }
21675
- } : {
21676
- ...buildOptions,
21677
- temporaryDirectory,
21678
- env: {
21679
- ...buildOptions.env,
21680
- ...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
21681
- ...compiler
21682
- }
21683
- };
21684
- const unprepared = preparation.targetFailures.map(
21685
- (failure) => `error: target ${failure}`
21686
- );
21687
- const forwarders = /* @__PURE__ */ new Map();
21688
- for (const [file, text2] of Object.entries(input.files)) {
21689
- const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text2)?.[1];
21690
- if (!parents) continue;
21691
- const directory = path23.posix.dirname(file);
21692
- forwarders.set(
21693
- `${path23.join(root2, directory)}/${parents.slice(0, -1)}`,
21694
- path23.posix.join("build", directory, parents).replace(/\/$/, "")
21695
- );
21696
- }
21697
- const jobs = swiftCompilerJobs();
21698
- const incrementalPreview = sdkImage !== void 0 && !guestGraph && !options.project && !input.optimize && !input.unoptimized;
21699
- const batchGuest = guestGraph !== void 0 && !options.project && !input.unoptimized;
21700
- const guestDriverJobs = Math.min(8, jobs);
21701
- const singleProducerJobs = Math.min(16, Math.floor(jobs / 2));
21702
- const batch = incrementalPreview || batchGuest;
21703
- const perFile = input.unoptimized || batch;
21704
- const reproducibleFrameworkRoot = mirrorDistribution ? frameworkRoot : compileFrameworkRoot;
21705
- const buildArgs = [
21706
- "build",
21707
- ...projectProcess?.cacheOptions ?? swiftPackageCacheOptions(),
21708
- "--build-system",
21709
- "native",
21710
- "-j",
21711
- String(jobs),
21712
- "--package-path",
21713
- root2,
21714
- ...compileSdk.options,
21715
- ...swiftObjCSelectorOptions(frameworkRoot),
21716
- "--swift-sdk",
21717
- compileSdk.id,
21718
- ...preparation.targetToolset ? ["--toolset", path23.join(root2, ".peach-target-toolset.json")] : [],
21719
- "-c",
21720
- "release",
21721
- ...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
21722
- ...perFile ? [
21723
- "-Xswiftc",
21724
- "-no-whole-module-optimization",
21725
- "-Xswiftc",
21726
- "-j",
21727
- "-Xswiftc",
21728
- String(batchGuest ? guestDriverJobs : jobs)
21729
- ] : [],
21730
- // optimized batches can move specialized definitions between objects.
21731
- ...incrementalPreview ? ["-Xswiftc", "-incremental"] : [],
21732
- ...batch ? ["-Xswiftc", "-enable-batch-mode"] : [],
21733
- // the mirror finds a changed sdk header's readers in their
21734
- // dependency files, which omit system headers by default
21735
- ...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
21736
- // the link strips debug info, so none is generated (as for the framework).
21737
- // keep -num-threads fixed across caller core caps so llbuild does not
21738
- // rebuild every target when callers alternate --cores, and bound backend
21739
- // fan-out under high -j.
21740
- "-Xswiftc",
21741
- "-gnone",
21742
- "-Xcc",
21743
- "-g0",
21744
- "-Xcxx",
21745
- "-g0",
21746
- ...batch ? [] : [
21747
- "-Xswiftc",
21748
- "-num-threads",
21749
- "-Xswiftc",
21750
- String(perFile ? 1 : Math.min(8, os3.availableParallelism()))
21751
- ],
21752
- ...swiftReproducibleBuildFlags([
21753
- [path23.dirname(options.toolchainBin), "toolchain"],
21754
- [reproducibleFrameworkRoot, "framework"],
21755
- [root2, "build"],
21756
- ...forwarders
21757
- ]).flatMap((flag, index, flags) => {
21758
- if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
21759
- return [flag];
21760
- const toolchainDir = path23.dirname(options.toolchainBin);
21761
- let mapped = flag;
21762
- for (const [dir, target] of [
21763
- [root2, "/peach/build"],
21764
- [reproducibleFrameworkRoot, "/peach/framework"],
21765
- [realpathSync6(reproducibleFrameworkRoot), "/peach/framework"],
21766
- [toolchainDir, "/peach/toolchain"],
21767
- [realpathSync6(toolchainDir), "/peach/toolchain"]
21768
- ]) {
21769
- mapped = mapped.replaceAll(dir, target);
21497
+ return runLocked(async (slotRoot, lease, waitedMs) => {
21498
+ const root2 = slotRoot;
21499
+ const layout3 = {
21500
+ root: root2,
21501
+ sources: path23.join(root2, "Sources", "App"),
21502
+ multi: compileTargets(input).length > 0
21503
+ };
21504
+ if (!options.intermediates) {
21505
+ const built = readCompiledArtifact(
21506
+ path23.join(sharedRoot, "artifact"),
21507
+ hash
21508
+ );
21509
+ if (built) {
21510
+ stage("reusing verified disk artifact");
21511
+ return retain(baseRoot, built);
21770
21512
  }
21771
- const [, from, to] = /^-ffile-prefix-map=([^=]+)=(.+)$/.exec(mapped) ?? [];
21772
- const tool = flags[index - 1];
21773
- return mapped !== flag && from !== to ? [flag, tool, mapped] : [flag];
21774
- }),
21775
- ...macroPlugins.libraries.flatMap((plugin) => [
21776
- "-Xswiftc",
21777
- "-load-plugin-library",
21778
- "-Xswiftc",
21779
- plugin
21780
- ]),
21781
- ...macroPlugins.executables.flatMap((plugin) => [
21782
- "-Xswiftc",
21783
- "-load-plugin-executable",
21784
- "-Xswiftc",
21785
- `${plugin}#ExpoModulesMacros`
21786
- ])
21787
- ];
21788
- const linked = builtArtifact(layout3);
21789
- rmSync7(path23.join(root2, ".peach-link.rsp"), { force: true });
21790
- if (options.linkOnly || existsSync9(linked) && statSync5(linked).size <= 8)
21791
- rmSync7(linked, { force: true });
21792
- stage("compiling and linking Swift modules");
21793
- const frameworkInterfaces = /* @__PURE__ */ new Map();
21794
- const compileSdkPaths = swiftSdkPaths(
21795
- frameworkRoot,
21796
- options.toolchainBin,
21797
- compileSdk.options,
21798
- compileSdk.id
21799
- );
21800
- const sdkFrameworks = path23.join(
21801
- compileSdkPaths.darwin,
21802
- "System/Library/Frameworks"
21803
- );
21804
- const generatedInterface = (source) => withoutImportedSdkEnumForwards(
21805
- clangInterfaceHeader(readFileSync13(source, "utf8"), frameworkRoot),
21806
- sdkObjCDeclarationOwners(sdkFrameworks)
21807
- );
21808
- const nativeDeclarations = /* @__PURE__ */ new Map();
21809
- const nativeHeaders = Object.entries(input.files).filter(([name]) => name.endsWith(".h") && !name.endsWith("-Swift.h")).map(([, source]) => source);
21810
- for (const [file, contents] of Object.entries(input.files)) {
21811
- if (!file.endsWith(".modulemap")) continue;
21812
- const name = moduleMapName(contents);
21813
- const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents)?.[1];
21814
- if (!name || !umbrella) continue;
21815
- const header = input.files[path23.posix.join(path23.posix.dirname(file), umbrella)];
21816
- if (header === void 0) continue;
21817
- const included = new Set(
21818
- [
21819
- ...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
21820
- ].map((match) => path23.posix.basename(match[1]))
21821
- );
21822
- const declarations = nativeDeclarations.get(name) ?? /* @__PURE__ */ new Set();
21823
- for (const declaration of swiftInterfaceDeclarations(header))
21824
- declarations.add(declaration);
21825
- for (const [candidate, source] of Object.entries(input.files))
21826
- if (included.has(path23.posix.basename(candidate)))
21827
- for (const declaration of swiftInterfaceDeclarations(source))
21828
- declarations.add(declaration);
21829
- nativeDeclarations.set(name, declarations);
21830
- }
21831
- const frameworkInterface = (name) => {
21832
- if (frameworkInterfaces.has(name)) return frameworkInterfaces.get(name);
21833
- const source = distribution ? path23.join(frameworkRoot, "modules", `${name}-Swift.h`) : prebuilt.objcHeaders.get(name);
21834
- if (!source || !existsSync9(source)) {
21835
- frameworkInterfaces.set(name, null);
21836
- return null;
21837
21513
  }
21838
- const headers = path23.join(sdkFrameworks, `${name}.framework/Headers`);
21839
- const declared = /* @__PURE__ */ new Set();
21840
- if (existsSync9(headers)) {
21841
- for (const file of readdirSync4(headers, {
21842
- recursive: true,
21843
- encoding: "utf8"
21844
- }))
21845
- if (file.endsWith(".h"))
21846
- for (const name2 of swiftInterfaceDeclarations(
21847
- readFileSync13(path23.join(headers, file), "utf8")
21848
- ))
21849
- declared.add(name2);
21514
+ if (waitedMs >= 1e3)
21515
+ report(`acquired build root ${path23.basename(root2)} after ${waitedMs}ms`);
21516
+ if (canPoolBuildRoot) {
21517
+ refreshSwiftCacheHold(root2);
21518
+ writeFileSync8(path23.join(root2, SWIFT_BUILD_ROOT_SHAPE), buildShape);
21850
21519
  }
21851
- for (const declaration of nativeDeclarations.get(name) ?? [])
21852
- declared.add(declaration);
21853
- const own = withoutSwiftDeclarations(
21854
- generatedInterface(source),
21855
- declared,
21856
- nativeDeclarations.has(name) ? `@import ${name};` : `#import <${name}/${name}.h>`
21857
- );
21858
- const owners = sdkObjCDeclarationOwners(sdkFrameworks);
21859
- const foreign = /* @__PURE__ */ new Map();
21860
- for (const declaration of [
21861
- ...swiftInterfaceDeclarations(own),
21862
- ...objcEnumerations(own),
21863
- ...[...own.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
21864
- (match) => match[1]
21865
- )
21866
- ]) {
21867
- const owner = owners.get(declaration);
21868
- if (owner && owner !== name) foreign.set(declaration, owner);
21520
+ const swift = path23.join(toolchainBin, "swift");
21521
+ if (!existsSync10(swift)) {
21522
+ throw new Error(
21523
+ `swift-compile: no swift.org toolchain at ${toolchainBin}; install ${options.release} and its matching wasm sdk`
21524
+ );
21869
21525
  }
21870
- const header = foreign.size ? withoutSwiftDeclarations(
21871
- own,
21872
- new Set(foreign.keys()),
21873
- [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
21874
- ) : own;
21875
- const value = {
21876
- file: path23.join(root2, ".build/peach-framework-objc", `${name}-Swift.h`),
21877
- header,
21878
- module: existsSync9(headers)
21526
+ const unoptimized = input.unoptimized === true;
21527
+ const baseBuildEnv = options.project?.env ? {
21528
+ ...options.project.env,
21529
+ // shipped host plugins resolve against the selected compiler's runtime.
21530
+ ...process.platform === "linux" ? {
21531
+ LD_LIBRARY_PATH: [
21532
+ path23.resolve(toolchainBin, "../lib/swift/linux"),
21533
+ path23.resolve(toolchainBin, "../lib/swift/host"),
21534
+ process.env.LD_LIBRARY_PATH
21535
+ ].filter(Boolean).join(":")
21536
+ } : {},
21537
+ PEACH_DEFER_WASM_LINK: "1"
21538
+ } : swiftCompilerBaseEnv(toolchainBin, process.env);
21539
+ const prepareFrameworks = async (slot, frameworkLease, allowWrite = true) => {
21540
+ if (allowWrite) budget.startCompile();
21541
+ const frameworkRoot2 = mirrorDistribution ? syncSwiftDistributionMirror(root2, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(
21542
+ moduleRoot,
21543
+ slot,
21544
+ frameworkKey,
21545
+ options.release
21546
+ );
21547
+ if (!swiftModuleDigest(frameworkRoot2).equals(moduleDigest))
21548
+ throw new Error("Swift staged project source differs from the caller");
21549
+ if (!allowWrite && swiftMacroPlugins(frameworkRoot2).stale) return;
21550
+ if (allowWrite) stage("preparing compiler plugins");
21551
+ const macroPlugins2 = await ensureMacroPlugins(
21552
+ frameworkRoot2,
21553
+ toolchainBin,
21554
+ options.release,
21555
+ budget.signal,
21556
+ frameworkLease
21557
+ );
21558
+ const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
21559
+ const sdk = swiftModuleSdk(frameworkRoot2).wasmSdkId;
21560
+ const compileSdk2 = mirrorDistribution ? syncSwiftSdkMirror(root2, frameworkRoot2, toolchainBin, sdk) : {
21561
+ id: sdk,
21562
+ options: swiftCompileSdkOptions(frameworkRoot2, toolchainBin),
21563
+ toolsetChanged: false
21564
+ };
21565
+ if (mirrorDistribution && compileSdk2.toolsetChanged)
21566
+ clearSwiftSdkPathsCache(path23.join(root2, SWIFT_SDK_MIRROR));
21567
+ const icu2 = options.linkOnly ? null : swiftIcuAsset(toolchainBin, sdk);
21568
+ let prebuilt2;
21569
+ if (!distribution) {
21570
+ if (allowWrite) stage("compiling framework products");
21571
+ prebuilt2 = await buildFrameworkProducts(
21572
+ slot,
21573
+ {
21574
+ moduleRoot: frameworkRoot2,
21575
+ frameworkKey,
21576
+ input,
21577
+ swift,
21578
+ sdk,
21579
+ toolchainBin,
21580
+ plugins: macroPlugins2,
21581
+ buildOptions: {
21582
+ env: baseBuildEnv,
21583
+ maxBuffer: 64 * 1024 * 1024,
21584
+ signal: budget.signal,
21585
+ onOutput: budget.progress,
21586
+ lease,
21587
+ frameworkLease
21588
+ }
21589
+ },
21590
+ allowWrite
21591
+ );
21592
+ if (!prebuilt2) return;
21593
+ if (!allowWrite) {
21594
+ budget.startCompile();
21595
+ stage("reusing verified framework products");
21596
+ }
21597
+ }
21598
+ const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
21599
+ return {
21600
+ frameworkRoot: frameworkRoot2,
21601
+ compileFrameworkRoot: compileFrameworkRoot2,
21602
+ macroPlugins: macroPlugins2,
21603
+ sdk,
21604
+ compileSdk: compileSdk2,
21605
+ icu: icu2,
21606
+ prebuilt: prebuilt2,
21607
+ readHold: readHold2
21608
+ };
21879
21609
  };
21880
- frameworkInterfaces.set(name, value);
21881
- writeBuildFile(
21882
- value.file,
21883
- (existsSync9(path23.join(headers, `${name}.h`)) ? `#import <${name}/${name}.h>
21884
- ` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
21885
- );
21886
- return value;
21887
- };
21888
- const headerPaths = (producer) => {
21889
- const stem = path23.join(
21890
- root2,
21891
- ".build",
21892
- "peach-cxx-headers",
21893
- `${producer}-Swift`
21894
- );
21895
- return { producer, original: `${stem}.original.h`, emitted: `${stem}.h` };
21896
- };
21897
- const publishHeader = ({
21898
- producer,
21899
- original,
21900
- emitted
21901
- }) => {
21902
- const generated = generatedInterface(original);
21903
- writeBuildFile(
21904
- emitted,
21905
- withoutSwiftDeclarations(
21906
- swiftHeaderWithSuperclassImports(generated, frameworkInterface),
21907
- /* @__PURE__ */ new Set([
21908
- ...preparation.nativeHeaderDeclarations[producer] ?? [],
21909
- ...nativelyDeclaredFunctions(generated, nativeHeaders)
21910
- ]),
21911
- `#import <${producer}/${producer}.h>`
21912
- )
21610
+ const frameworks = distribution ? await prepareFrameworks(null) : await withSwiftFrameworkSlot(
21611
+ frameworkKey,
21612
+ options.release,
21613
+ moduleRoot,
21614
+ budget.signal,
21615
+ prepareFrameworks,
21616
+ unoptimized,
21617
+ options.linkOnly === true
21913
21618
  );
21914
- };
21915
- const recipe = inputHash.copy().update(
21916
- distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
21917
- ).update(readFileSync13(path23.join(root2, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
21918
- const runApp = async (compiler2) => {
21919
- const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
21920
- const stages = [
21921
- ...(preparation.nativePrerequisiteTargets ?? []).map((target) => ({
21922
- target,
21923
- producers: []
21924
- })),
21925
- ...preparation.headerBuilds,
21926
- ...(preparation.nativeProductTargets ?? []).map((target) => ({
21927
- target,
21928
- producers: []
21929
- }))
21930
- ];
21931
- const checkpoints = path23.join(root2, ".build", "peach-product-checkpoints");
21932
- const buildDbExists = existsSync9(path23.join(root2, ".build", "build.db"));
21933
- const releaseDir = path23.dirname(linked);
21934
- for (const { target, producers } of stages) {
21935
- if (!options.project && producers.length === 0 && buildDbExists) {
21936
- const expectedObjects = preparation.nativeStageObjects.get(target);
21937
- if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
21938
- (relative) => statSync5(path23.join(releaseDir, relative), {
21939
- throwIfNoEntry: false
21940
- })?.isFile()
21941
- ))
21942
- continue;
21943
- }
21944
- const receipt = path23.join(
21945
- checkpoints,
21946
- createHash15("sha256").update(target).digest("hex")
21619
+ if (!frameworks)
21620
+ throw new Error("Swift distribution did not provide its frameworks");
21621
+ const {
21622
+ frameworkRoot,
21623
+ compileFrameworkRoot,
21624
+ macroPlugins,
21625
+ compileSdk,
21626
+ icu,
21627
+ prebuilt
21628
+ } = frameworks;
21629
+ let readHold = frameworks.readHold;
21630
+ const buildOptions = {
21631
+ env: baseBuildEnv,
21632
+ maxBuffer: 64 * 1024 * 1024,
21633
+ signal: budget.signal,
21634
+ onOutput: budget.progress,
21635
+ lease
21636
+ };
21637
+ try {
21638
+ if (options.project) removeProjectLinks(root2);
21639
+ const packageHostMacros = process.platform === "linux" ? input.packageHostMacros : void 0;
21640
+ if (retireStaleSwiftLink(
21641
+ root2,
21642
+ swiftLinkStamp({
21643
+ frameworkKey: mirrorDistribution ? `${options.release}\0mirror` : `${options.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
21644
+ packageHostMacros
21645
+ }),
21646
+ swiftLinkStamp({
21647
+ // mirrored distributions and their WASI SDK mirror invalidate
21648
+ // dependents per changed file instead of wiping every Clang object.
21649
+ frameworkKey: mirrorDistribution ? `${options.release}\0mirror` : distribution ? `${options.release}\0${distribution.wasmSdkChecksum}` : frameworkKey,
21650
+ prebuilt,
21651
+ packageHostMacros
21652
+ }),
21653
+ Boolean(options.linkOnly)
21654
+ ))
21655
+ stage("framework revision changed; rebuilding the app link");
21656
+ const nativeToolset = needsNativeToolset(input, prebuilt);
21657
+ const preparation = writeSwiftProject(
21658
+ layout3,
21659
+ input,
21660
+ frameworkRoot,
21661
+ prebuilt,
21662
+ !options.project,
21663
+ options.project ? false : options.objcPrebuiltStage ?? (options.intermediates ? false : void 0),
21664
+ compileSdk
21947
21665
  );
21948
- const headers = producers.map(headerPaths);
21949
- for (const header of headers)
21950
- if (existsSync9(header.original)) publishHeader(header);
21951
- const fingerprint = () => {
21952
- const digest = createHash15("sha256").update(recipe);
21953
- for (const { original, emitted } of headers) {
21954
- if (!existsSync9(original) || !existsSync9(emitted)) return;
21955
- digest.update(
21956
- createHash15("sha256").update(readFileSync13(emitted)).digest()
21957
- );
21666
+ const productFile = path23.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
21667
+ writeSwiftAutolinkLinker(
21668
+ root2,
21669
+ toolchainBin,
21670
+ existsSync10(productFile) ? [
21671
+ parse(
21672
+ swiftFrameworkProductSchema,
21673
+ JSON.parse(readFileSync13(productFile, "utf8"))
21674
+ ).product.name
21675
+ ] : []
21676
+ );
21677
+ const compiler = preparation.targetToolset ? { CC: path23.join(root2, CLANG_TARGET_MODULE_WRAPPER) } : {};
21678
+ if (packageHostMacros?.length) {
21679
+ const swiftc = path23.join(root2, SWIFT_HOST_COMPILER_WRAPPER);
21680
+ writeBuildFile(
21681
+ swiftc,
21682
+ [
21683
+ "#!/bin/sh",
21684
+ "target=",
21685
+ "module=",
21686
+ "compile=",
21687
+ "previous=",
21688
+ "for argument do",
21689
+ ' case "$previous" in -target) target=$argument ;; -module-name) module=$argument ;; esac',
21690
+ ' case "$argument" in -c|-emit-module|-scan-dependencies|-typecheck) compile=1 ;; esac',
21691
+ " previous=$argument",
21692
+ "done",
21693
+ 'case "$target/$compile" in',
21694
+ " *-*-linux*/1)",
21695
+ ' case ",$PEACH_SWIFT_HOST_MACROS," in',
21696
+ ' *",$module,"*) set -- "$@" -Xfrontend -import-module -Xfrontend Foundation ;;',
21697
+ " esac ;;",
21698
+ "esac",
21699
+ 'exec "$PEACH_SWIFTC" "$@"',
21700
+ ""
21701
+ ].join("\n")
21702
+ );
21703
+ chmodSync4(swiftc, 493);
21704
+ compiler.SWIFT_EXEC = swiftc;
21705
+ compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
21706
+ compiler.PEACH_SWIFTC = path23.join(toolchainBin, "swiftc");
21707
+ }
21708
+ const projectProcess = options.project ? prepareSwiftProjectProcess(root2, options.project) : void 0;
21709
+ const temporaryDirectory = projectProcess ? void 0 : path23.join(root2, ".build", "peach-compiler-tmp");
21710
+ const appOptions = projectProcess ? {
21711
+ ...buildOptions,
21712
+ uid: projectProcess.uid,
21713
+ gid: projectProcess.gid,
21714
+ confined: { ...projectProcess.env, ...compiler }
21715
+ } : {
21716
+ ...buildOptions,
21717
+ temporaryDirectory,
21718
+ env: {
21719
+ ...buildOptions.env,
21720
+ ...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
21721
+ ...compiler
21958
21722
  }
21959
- return digest.digest("hex");
21960
21723
  };
21961
- if (!options.project && existsSync9(receipt) && readFileSync13(receipt, "utf8") === fingerprint())
21962
- continue;
21963
- if (!options.project) rmSync7(receipt, { force: true });
21964
- for (const header of headers) {
21965
- if (!existsSync9(header.original))
21966
- rmSync7(
21967
- path23.join(
21968
- path23.dirname(linked),
21969
- "Modules",
21970
- `${swiftTargetModuleName(header.producer)}.swiftmodule`
21971
- ),
21972
- { force: true }
21973
- );
21724
+ const unprepared = preparation.targetFailures.map(
21725
+ (failure) => `error: target ${failure}`
21726
+ );
21727
+ const forwarders = /* @__PURE__ */ new Map();
21728
+ for (const [file, text2] of Object.entries(input.files)) {
21729
+ const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text2)?.[1];
21730
+ if (!parents) continue;
21731
+ const directory = path23.posix.dirname(file);
21732
+ forwarders.set(
21733
+ `${path23.join(root2, directory)}/${parents.slice(0, -1)}`,
21734
+ path23.posix.join("build", directory, parents).replace(/\/$/, "")
21735
+ );
21974
21736
  }
21975
- await runCompiler(
21976
- swift,
21977
- [...buildArgs, "--target", target],
21978
- optionsWithCompiler,
21979
- /^(?:\[swift-prebuilt\]|\[\d+\/\d+\] )/,
21980
- SWIFTPM_NOISE
21737
+ const jobs = swiftCompilerJobs();
21738
+ const incrementalPreview = sdkImage !== void 0 && !guestGraph && !options.project && !input.optimize && !input.unoptimized;
21739
+ const batchGuest = guestGraph !== void 0 && !options.project && !input.unoptimized;
21740
+ const guestDriverJobs = Math.min(8, jobs);
21741
+ const singleProducerJobs = Math.min(16, Math.floor(jobs / 2));
21742
+ const batch = incrementalPreview || batchGuest;
21743
+ const perFile = input.unoptimized || batch;
21744
+ const reproducibleFrameworkRoot = mirrorDistribution ? frameworkRoot : compileFrameworkRoot;
21745
+ const buildArgs = [
21746
+ "build",
21747
+ ...projectProcess?.cacheOptions ?? swiftPackageCacheOptions(),
21748
+ "--build-system",
21749
+ "native",
21750
+ "-j",
21751
+ String(jobs),
21752
+ "--package-path",
21753
+ root2,
21754
+ ...compileSdk.options,
21755
+ ...swiftObjCSelectorOptions(frameworkRoot),
21756
+ "--swift-sdk",
21757
+ compileSdk.id,
21758
+ ...preparation.targetToolset ? ["--toolset", path23.join(root2, ".peach-target-toolset.json")] : [],
21759
+ "-c",
21760
+ "release",
21761
+ ...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
21762
+ ...perFile ? [
21763
+ "-Xswiftc",
21764
+ "-no-whole-module-optimization",
21765
+ "-Xswiftc",
21766
+ "-j",
21767
+ "-Xswiftc",
21768
+ String(batchGuest ? guestDriverJobs : jobs)
21769
+ ] : [],
21770
+ // optimized batches can move specialized definitions between objects.
21771
+ ...incrementalPreview ? ["-Xswiftc", "-incremental"] : [],
21772
+ ...batch ? ["-Xswiftc", "-enable-batch-mode"] : [],
21773
+ // the mirror finds a changed sdk header's readers in their
21774
+ // dependency files, which omit system headers by default
21775
+ ...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
21776
+ // the link strips debug info, so none is generated (as for the framework).
21777
+ // keep -num-threads fixed across caller core caps so llbuild does not
21778
+ // rebuild every target when callers alternate --cores, and bound backend
21779
+ // fan-out under high -j.
21780
+ "-Xswiftc",
21781
+ "-gnone",
21782
+ "-Xcc",
21783
+ "-g0",
21784
+ "-Xcxx",
21785
+ "-g0",
21786
+ ...batch ? [] : [
21787
+ "-Xswiftc",
21788
+ "-num-threads",
21789
+ "-Xswiftc",
21790
+ String(perFile ? 1 : Math.min(8, os4.availableParallelism()))
21791
+ ],
21792
+ ...swiftReproducibleBuildFlags([
21793
+ [path23.dirname(toolchainBin), "toolchain"],
21794
+ [reproducibleFrameworkRoot, "framework"],
21795
+ [root2, "build"],
21796
+ ...forwarders
21797
+ ]).flatMap((flag, index, flags) => {
21798
+ if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
21799
+ return [flag];
21800
+ const toolchainDir = path23.dirname(toolchainBin);
21801
+ let mapped = flag;
21802
+ for (const [dir, target] of [
21803
+ [root2, "/peach/build"],
21804
+ [reproducibleFrameworkRoot, "/peach/framework"],
21805
+ [realpathSync6(reproducibleFrameworkRoot), "/peach/framework"],
21806
+ [toolchainDir, "/peach/toolchain"],
21807
+ [realpathSync6(toolchainDir), "/peach/toolchain"]
21808
+ ]) {
21809
+ mapped = mapped.replaceAll(dir, target);
21810
+ }
21811
+ const [, from, to] = /^-ffile-prefix-map=([^=]+)=(.+)$/.exec(mapped) ?? [];
21812
+ const tool = flags[index - 1];
21813
+ return mapped !== flag && from !== to ? [flag, tool, mapped] : [flag];
21814
+ }),
21815
+ ...macroPlugins.libraries.flatMap((plugin) => [
21816
+ "-Xswiftc",
21817
+ "-load-plugin-library",
21818
+ "-Xswiftc",
21819
+ plugin
21820
+ ]),
21821
+ ...macroPlugins.executables.flatMap((plugin) => [
21822
+ "-Xswiftc",
21823
+ "-load-plugin-executable",
21824
+ "-Xswiftc",
21825
+ `${plugin}#ExpoModulesMacros`
21826
+ ])
21827
+ ];
21828
+ const linked = builtArtifact(layout3);
21829
+ rmSync7(path23.join(root2, ".peach-link.rsp"), { force: true });
21830
+ if (options.linkOnly || existsSync10(linked) && statSync6(linked).size <= 8)
21831
+ rmSync7(linked, { force: true });
21832
+ stage("compiling and linking Swift modules");
21833
+ const frameworkInterfaces = /* @__PURE__ */ new Map();
21834
+ const compileSdkPaths = swiftSdkPaths(
21835
+ frameworkRoot,
21836
+ toolchainBin,
21837
+ compileSdk.options,
21838
+ compileSdk.id
21839
+ );
21840
+ const sdkFrameworks = path23.join(
21841
+ compileSdkPaths.darwin,
21842
+ "System/Library/Frameworks"
21843
+ );
21844
+ const generatedInterface = (source) => withoutImportedSdkEnumForwards(
21845
+ clangInterfaceHeader(readFileSync13(source, "utf8"), frameworkRoot),
21846
+ sdkObjCDeclarationOwners(sdkFrameworks)
21981
21847
  );
21982
- if (!compiler2) for (const header of headers) publishHeader(header);
21983
- if (!options.project) {
21984
- const checkpoint = fingerprint();
21985
- if (checkpoint === void 0)
21986
- throw new Error(`missing Swift headers after building ${target}`);
21987
- mkdirSync7(checkpoints, { recursive: true });
21988
- writeFileSync7(`${receipt}.partial`, checkpoint);
21989
- renameSync5(`${receipt}.partial`, receipt);
21848
+ const nativeDeclarations = /* @__PURE__ */ new Map();
21849
+ const nativeHeaders = Object.entries(input.files).filter(([name]) => name.endsWith(".h") && !name.endsWith("-Swift.h")).map(([, source]) => source);
21850
+ for (const [file, contents] of Object.entries(input.files)) {
21851
+ if (!file.endsWith(".modulemap")) continue;
21852
+ const name = moduleMapName(contents);
21853
+ const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents)?.[1];
21854
+ if (!name || !umbrella) continue;
21855
+ const header = input.files[path23.posix.join(path23.posix.dirname(file), umbrella)];
21856
+ if (header === void 0) continue;
21857
+ const included = new Set(
21858
+ [
21859
+ ...header.matchAll(
21860
+ /^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm
21861
+ )
21862
+ ].map((match) => path23.posix.basename(match[1]))
21863
+ );
21864
+ const declarations = nativeDeclarations.get(name) ?? /* @__PURE__ */ new Set();
21865
+ for (const declaration of swiftInterfaceDeclarations(header))
21866
+ declarations.add(declaration);
21867
+ for (const [candidate, source] of Object.entries(input.files))
21868
+ if (included.has(path23.posix.basename(candidate)))
21869
+ for (const declaration of swiftInterfaceDeclarations(source))
21870
+ declarations.add(declaration);
21871
+ nativeDeclarations.set(name, declarations);
21990
21872
  }
21991
- }
21992
- await runCompiler(
21993
- swift,
21994
- buildArgs,
21995
- optionsWithCompiler,
21996
- SWIFTPM_PROGRESS,
21997
- SWIFTPM_NOISE
21998
- );
21999
- };
22000
- const compileApp = () => preparation.headerCompiler ? withSwiftHeaderCompiler(
22001
- root2,
22002
- options.toolchainBin,
22003
- recipe,
22004
- new Map(
22005
- preparation.headerBuilds.flatMap(({ producers }) => {
22006
- const driverJobs = batchGuest && producers.length === 1 && singleProducerJobs > guestDriverJobs ? singleProducerJobs : void 0;
22007
- return producers.map((producer) => {
22008
- const paths = headerPaths(producer);
22009
- return [
22010
- swiftTargetModuleName(producer),
22011
- {
22012
- header: paths.original,
22013
- publish: () => publishHeader(paths),
22014
- jobs: driverJobs
21873
+ const frameworkInterface = (name) => {
21874
+ if (frameworkInterfaces.has(name)) return frameworkInterfaces.get(name);
21875
+ const source = distribution ? path23.join(frameworkRoot, "modules", `${name}-Swift.h`) : prebuilt.objcHeaders.get(name);
21876
+ if (!source || !existsSync10(source)) {
21877
+ frameworkInterfaces.set(name, null);
21878
+ return null;
21879
+ }
21880
+ const headers = path23.join(sdkFrameworks, `${name}.framework/Headers`);
21881
+ const declared = /* @__PURE__ */ new Set();
21882
+ if (existsSync10(headers)) {
21883
+ for (const file of readdirSync5(headers, {
21884
+ recursive: true,
21885
+ encoding: "utf8"
21886
+ }))
21887
+ if (file.endsWith(".h"))
21888
+ for (const name2 of swiftInterfaceDeclarations(
21889
+ readFileSync13(path23.join(headers, file), "utf8")
21890
+ ))
21891
+ declared.add(name2);
21892
+ }
21893
+ for (const declaration of nativeDeclarations.get(name) ?? [])
21894
+ declared.add(declaration);
21895
+ const own = withoutSwiftDeclarations(
21896
+ generatedInterface(source),
21897
+ declared,
21898
+ nativeDeclarations.has(name) ? `@import ${name};` : `#import <${name}/${name}.h>`
21899
+ );
21900
+ const owners = sdkObjCDeclarationOwners(sdkFrameworks);
21901
+ const foreign = /* @__PURE__ */ new Map();
21902
+ for (const declaration of [
21903
+ ...swiftInterfaceDeclarations(own),
21904
+ ...objcEnumerations(own),
21905
+ ...[...own.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
21906
+ (match) => match[1]
21907
+ )
21908
+ ]) {
21909
+ const owner = owners.get(declaration);
21910
+ if (owner && owner !== name) foreign.set(declaration, owner);
21911
+ }
21912
+ const header = foreign.size ? withoutSwiftDeclarations(
21913
+ own,
21914
+ new Set(foreign.keys()),
21915
+ [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
21916
+ ) : own;
21917
+ const value = {
21918
+ file: path23.join(
21919
+ root2,
21920
+ ".build/peach-framework-objc",
21921
+ `${name}-Swift.h`
21922
+ ),
21923
+ header,
21924
+ module: existsSync10(headers)
21925
+ };
21926
+ frameworkInterfaces.set(name, value);
21927
+ writeBuildFile(
21928
+ value.file,
21929
+ (existsSync10(path23.join(headers, `${name}.h`)) ? `#import <${name}/${name}.h>
21930
+ ` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
21931
+ );
21932
+ return value;
21933
+ };
21934
+ const headerPaths = (producer) => {
21935
+ const stem = path23.join(
21936
+ root2,
21937
+ ".build",
21938
+ "peach-cxx-headers",
21939
+ `${producer}-Swift`
21940
+ );
21941
+ return {
21942
+ producer,
21943
+ original: `${stem}.original.h`,
21944
+ emitted: `${stem}.h`
21945
+ };
21946
+ };
21947
+ const publishHeader = ({
21948
+ producer,
21949
+ original,
21950
+ emitted
21951
+ }) => {
21952
+ const generated = generatedInterface(original);
21953
+ writeBuildFile(
21954
+ emitted,
21955
+ withoutSwiftDeclarations(
21956
+ swiftHeaderWithSuperclassImports(generated, frameworkInterface),
21957
+ /* @__PURE__ */ new Set([
21958
+ ...preparation.nativeHeaderDeclarations[producer] ?? [],
21959
+ ...nativelyDeclaredFunctions(generated, nativeHeaders)
21960
+ ]),
21961
+ `#import <${producer}/${producer}.h>`
21962
+ )
21963
+ );
21964
+ };
21965
+ const recipe = inputHash.copy().update(
21966
+ distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
21967
+ ).update(readFileSync13(path23.join(root2, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
21968
+ const runApp = async (compiler2) => {
21969
+ const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
21970
+ const stages = [
21971
+ ...(preparation.nativePrerequisiteTargets ?? []).map((target) => ({
21972
+ target,
21973
+ producers: []
21974
+ })),
21975
+ ...preparation.headerBuilds,
21976
+ ...(preparation.nativeProductTargets ?? []).map((target) => ({
21977
+ target,
21978
+ producers: []
21979
+ }))
21980
+ ];
21981
+ const checkpoints = path23.join(
21982
+ root2,
21983
+ ".build",
21984
+ "peach-product-checkpoints"
21985
+ );
21986
+ const buildDbExists = existsSync10(path23.join(root2, ".build", "build.db"));
21987
+ const releaseDir = path23.dirname(linked);
21988
+ for (const { target, producers } of stages) {
21989
+ if (!options.project && producers.length === 0 && buildDbExists) {
21990
+ const expectedObjects = preparation.nativeStageObjects.get(target);
21991
+ if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
21992
+ (relative) => statSync6(path23.join(releaseDir, relative), {
21993
+ throwIfNoEntry: false
21994
+ })?.isFile()
21995
+ ))
21996
+ continue;
21997
+ }
21998
+ const receipt = path23.join(
21999
+ checkpoints,
22000
+ createHash15("sha256").update(target).digest("hex")
22001
+ );
22002
+ const headers = producers.map(headerPaths);
22003
+ for (const header of headers)
22004
+ if (existsSync10(header.original)) publishHeader(header);
22005
+ const fingerprint = () => {
22006
+ const digest = createHash15("sha256").update(recipe);
22007
+ for (const { original, emitted } of headers) {
22008
+ if (!existsSync10(original) || !existsSync10(emitted)) return;
22009
+ digest.update(
22010
+ createHash15("sha256").update(readFileSync13(emitted)).digest()
22011
+ );
22015
22012
  }
22016
- ];
22017
- });
22018
- })
22019
- ),
22020
- runApp
22021
- ) : runApp();
22022
- try {
22023
- if (temporaryDirectory) mkdirSync7(temporaryDirectory, { recursive: true });
22024
- await compileApp();
22025
- } catch (error) {
22026
- const output2 = outputOf(error);
22027
- const moduleCache = path23.join(
22028
- root2,
22029
- ".build",
22030
- WASM_TRIPLE,
22031
- "release",
22032
- "ModuleCache"
22033
- );
22034
- if (output2.includes("was compiled with module cache path") && existsSync9(moduleCache)) {
22035
- rmSync7(moduleCache, { recursive: true, force: true });
22013
+ return digest.digest("hex");
22014
+ };
22015
+ if (!options.project && existsSync10(receipt) && readFileSync13(receipt, "utf8") === fingerprint())
22016
+ continue;
22017
+ if (!options.project) rmSync7(receipt, { force: true });
22018
+ for (const header of headers) {
22019
+ if (!existsSync10(header.original))
22020
+ rmSync7(
22021
+ path23.join(
22022
+ path23.dirname(linked),
22023
+ "Modules",
22024
+ `${swiftTargetModuleName(header.producer)}.swiftmodule`
22025
+ ),
22026
+ { force: true }
22027
+ );
22028
+ }
22029
+ await runCompiler(
22030
+ swift,
22031
+ [...buildArgs, "--target", target],
22032
+ optionsWithCompiler,
22033
+ /^(?:\[swift-prebuilt\]|\[\d+\/\d+\] )/,
22034
+ SWIFTPM_NOISE
22035
+ );
22036
+ if (!compiler2) for (const header of headers) publishHeader(header);
22037
+ if (!options.project) {
22038
+ const checkpoint = fingerprint();
22039
+ if (checkpoint === void 0)
22040
+ throw new Error(`missing Swift headers after building ${target}`);
22041
+ mkdirSync8(checkpoints, { recursive: true });
22042
+ writeFileSync8(`${receipt}.partial`, checkpoint);
22043
+ renameSync6(`${receipt}.partial`, receipt);
22044
+ }
22045
+ }
22046
+ await runCompiler(
22047
+ swift,
22048
+ buildArgs,
22049
+ optionsWithCompiler,
22050
+ SWIFTPM_PROGRESS,
22051
+ SWIFTPM_NOISE
22052
+ );
22053
+ };
22054
+ const compileApp = () => preparation.headerCompiler ? withSwiftHeaderCompiler(
22055
+ root2,
22056
+ toolchainBin,
22057
+ recipe,
22058
+ new Map(
22059
+ preparation.headerBuilds.flatMap(({ producers }) => {
22060
+ const driverJobs = batchGuest && producers.length === 1 && singleProducerJobs > guestDriverJobs ? singleProducerJobs : void 0;
22061
+ return producers.map((producer) => {
22062
+ const paths = headerPaths(producer);
22063
+ return [
22064
+ swiftTargetModuleName(producer),
22065
+ {
22066
+ header: paths.original,
22067
+ publish: () => publishHeader(paths),
22068
+ jobs: driverJobs
22069
+ }
22070
+ ];
22071
+ });
22072
+ })
22073
+ ),
22074
+ runApp
22075
+ ) : runApp();
22036
22076
  try {
22077
+ if (temporaryDirectory)
22078
+ mkdirSync8(temporaryDirectory, { recursive: true });
22037
22079
  await compileApp();
22038
- } catch (retryError) {
22080
+ } catch (error) {
22081
+ const output2 = outputOf(error);
22082
+ const moduleCache = path23.join(
22083
+ root2,
22084
+ ".build",
22085
+ WASM_TRIPLE,
22086
+ "release",
22087
+ "ModuleCache"
22088
+ );
22089
+ if (output2.includes("was compiled with module cache path") && existsSync10(moduleCache)) {
22090
+ rmSync7(moduleCache, { recursive: true, force: true });
22091
+ try {
22092
+ await compileApp();
22093
+ } catch (retryError) {
22094
+ throw new Error(
22095
+ [
22096
+ ...unprepared,
22097
+ projectDiagnostic(outputOf(retryError), layout3, input.files)
22098
+ ].join("\n"),
22099
+ { cause: retryError }
22100
+ );
22101
+ }
22102
+ } else {
22103
+ throw new Error(
22104
+ [
22105
+ ...unprepared,
22106
+ projectDiagnostic(output2, layout3, input.files)
22107
+ ].join("\n"),
22108
+ { cause: error }
22109
+ );
22110
+ }
22111
+ } finally {
22112
+ if (temporaryDirectory)
22113
+ rmSync7(temporaryDirectory, { recursive: true, force: true });
22114
+ if (options.project) endSwiftProjectProcesses(options.project);
22115
+ }
22116
+ if (unprepared.length) throw new Error(unprepared.join("\n"));
22117
+ if (!existsSync10(linked)) {
22118
+ const binDir = path23.dirname(linked);
22119
+ const found = existsSync10(binDir) ? readdirSync5(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
22039
22120
  throw new Error(
22040
- [
22041
- ...unprepared,
22042
- projectDiagnostic(outputOf(retryError), layout3, input.files)
22043
- ].join("\n"),
22044
- { cause: retryError }
22121
+ `swift-compile: the build produced no ${path23.basename(linked)} (found: ${found.join(", ") || "none"})`
22045
22122
  );
22046
22123
  }
22047
- } else {
22048
- throw new Error(
22049
- [...unprepared, projectDiagnostic(output2, layout3, input.files)].join(
22050
- "\n"
22051
- ),
22052
- { cause: error }
22124
+ if (options.project) removeProjectLinks(root2);
22125
+ const resourceReferences = Object.values(input.resources ?? {}).map(
22126
+ (value) => Buffer.from(value, "base64")
22053
22127
  );
22054
- }
22055
- } finally {
22056
- if (temporaryDirectory)
22057
- rmSync7(temporaryDirectory, { recursive: true, force: true });
22058
- if (options.project) endSwiftProjectProcesses(options.project);
22059
- }
22060
- if (unprepared.length) throw new Error(unprepared.join("\n"));
22061
- if (!existsSync9(linked)) {
22062
- const binDir = path23.dirname(linked);
22063
- const found = existsSync9(binDir) ? readdirSync4(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
22064
- throw new Error(
22065
- `swift-compile: the build produced no ${path23.basename(linked)} (found: ${found.join(", ") || "none"})`
22066
- );
22067
- }
22068
- if (options.project) removeProjectLinks(root2);
22069
- const resourceReferences = Object.values(input.resources ?? {}).map(
22070
- (value) => Buffer.from(value, "base64")
22071
- );
22072
- if (!guestGraph)
22073
- pruneSwiftWasmLink(
22074
- root2,
22075
- options.toolchainBin,
22076
- prebuilt?.root ?? frameworkRoot,
22077
- input.staticClangTargets,
22078
- options.project,
22079
- void 0,
22080
- resourceReferences
22081
- );
22082
- if (options.linkOnly) {
22083
- if (statSync5(linked).size <= 8)
22084
- throw new Error("swift-compile: deferred linker produced no executable");
22085
- stage("project link verified");
22086
- if (readHold && retainSwiftRootReadHold(readHold)) readHold = void 0;
22087
- return;
22088
- }
22089
- const output = options.project ? projectOutputFile(root2, linked, options.project) : linked;
22090
- const optimized = `${output}.optimized`;
22091
- if (!sdkImage) throw new Error("swift-compile: missing shared SDK image");
22092
- if (options.project) rmSync7(optimized, { force: true });
22093
- let sdkAsset;
22094
- stage("linking the app image");
22095
- if (guestGraph) {
22096
- const binding = await compileGuestLink({
22097
- graph: guestGraph,
22098
- buildDirectory: root2,
22099
- releaseDirectory: path23.dirname(linked),
22100
- moduleRoot: frameworkRoot,
22101
- toolchainBin: options.toolchainBin,
22102
- swiftCompiler: preparation.headerCompiler ? path23.join(root2, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? path23.join(options.toolchainBin, "swiftc"),
22103
- sysroot: compileSdkPaths.sysroot,
22104
- sdk: swiftModuleSdk(frameworkRoot),
22105
- sdkImage,
22106
- compilerDigest: compilerSourceDigest,
22107
- project: options.project && {
22108
- ...options.project,
22109
- env: { ...options.project.env, ...projectProcess?.env }
22110
- },
22111
- staticClangTargets: input.staticClangTargets ?? [],
22112
- resourceReferences,
22113
- resourceBundles: input.resourceBundles ?? [],
22114
- generatedOwners: preparation.generatedOwners,
22115
- output,
22116
- optimized,
22117
- optimize: input.optimize === true,
22118
- jobs: swiftBuildJobs(),
22119
- onStage: stage
22120
- });
22121
- sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
22122
- } else {
22123
- const { buildSwiftAppModule } = await import("./swift-sdk-app-module-I4OZ7CGZ.mjs");
22124
- const binding = await buildSwiftAppModule({
22125
- buildRoot: root2,
22126
- toolchainBin: options.toolchainBin,
22127
- sdk: sdkImage,
22128
- output: optimized,
22129
- optimize: input.optimize === true,
22130
- project: options.project && {
22131
- ...options.project,
22132
- env: { ...options.project.env, ...projectProcess?.env },
22133
- sdkRoot: path23.dirname(compileSdkPaths.sysroot),
22134
- linked: output
22128
+ if (!guestGraph)
22129
+ pruneSwiftWasmLink(
22130
+ root2,
22131
+ toolchainBin,
22132
+ prebuilt?.root ?? frameworkRoot,
22133
+ input.staticClangTargets,
22134
+ options.project,
22135
+ void 0,
22136
+ resourceReferences
22137
+ );
22138
+ if (options.linkOnly) {
22139
+ if (statSync6(linked).size <= 8)
22140
+ throw new Error(
22141
+ "swift-compile: deferred linker produced no executable"
22142
+ );
22143
+ stage("project link verified");
22144
+ if (readHold && retainSwiftRootReadHold(readHold)) readHold = void 0;
22145
+ return;
22135
22146
  }
22136
- });
22137
- sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
22138
- }
22139
- const artifact = {
22140
- hash,
22141
- bytes: readFileSync13(optimized),
22142
- icu: await icu,
22143
- sdk: sdkAsset
22144
- };
22145
- if (artifact.bytes.length <= 8)
22146
- throw new Error("swift-compile: deferred linker produced no executable");
22147
- if (!options.project) saveCompiledArtifact(root2, artifact);
22148
- saveSharedArtifact(sharedRoot, artifact);
22149
- stage("compiled artifact verified");
22150
- return retain(baseRoot, artifact);
22151
- } finally {
22152
- readHold?.release();
22147
+ const output = options.project ? projectOutputFile(root2, linked, options.project) : linked;
22148
+ const optimized = `${output}.optimized`;
22149
+ if (!sdkImage) throw new Error("swift-compile: missing shared SDK image");
22150
+ if (options.project) rmSync7(optimized, { force: true });
22151
+ let sdkAsset;
22152
+ stage("linking the app image");
22153
+ if (guestGraph) {
22154
+ const binding = await compileGuestLink({
22155
+ graph: guestGraph,
22156
+ buildDirectory: root2,
22157
+ releaseDirectory: path23.dirname(linked),
22158
+ moduleRoot: frameworkRoot,
22159
+ toolchainBin,
22160
+ swiftCompiler: preparation.headerCompiler ? path23.join(root2, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? path23.join(toolchainBin, "swiftc"),
22161
+ sysroot: compileSdkPaths.sysroot,
22162
+ sdk: swiftModuleSdk(frameworkRoot),
22163
+ sdkImage,
22164
+ compilerDigest: compilerSourceDigest,
22165
+ project: options.project && {
22166
+ ...options.project,
22167
+ env: { ...options.project.env, ...projectProcess?.env }
22168
+ },
22169
+ staticClangTargets: input.staticClangTargets ?? [],
22170
+ resourceReferences,
22171
+ resourceBundles: input.resourceBundles ?? [],
22172
+ generatedOwners: preparation.generatedOwners,
22173
+ output,
22174
+ optimized,
22175
+ optimize: input.optimize === true,
22176
+ jobs: swiftBuildJobs(),
22177
+ onStage: stage
22178
+ });
22179
+ sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
22180
+ } else {
22181
+ const { buildSwiftAppModule } = await import("./swift-sdk-app-module-XC4QIMOI.mjs");
22182
+ const binding = await buildSwiftAppModule({
22183
+ buildRoot: root2,
22184
+ toolchainBin,
22185
+ sdk: sdkImage,
22186
+ output: optimized,
22187
+ optimize: input.optimize === true,
22188
+ project: options.project && {
22189
+ ...options.project,
22190
+ env: { ...options.project.env, ...projectProcess?.env },
22191
+ sdkRoot: path23.dirname(compileSdkPaths.sysroot),
22192
+ linked: output
22193
+ }
22194
+ });
22195
+ sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
22196
+ }
22197
+ const artifact = {
22198
+ hash,
22199
+ bytes: readFileSync13(optimized),
22200
+ icu: await icu,
22201
+ sdk: sdkAsset
22202
+ };
22203
+ if (artifact.bytes.length <= 8)
22204
+ throw new Error("swift-compile: deferred linker produced no executable");
22205
+ if (!options.project) saveCompiledArtifact(root2, artifact);
22206
+ saveSharedArtifact(sharedRoot, artifact);
22207
+ stage("compiled artifact verified");
22208
+ return retain(baseRoot, artifact);
22209
+ } finally {
22210
+ readHold?.release();
22211
+ }
22212
+ });
22153
22213
  }
22154
- });
22155
- });
22156
- },
22157
- options.signal
22158
- );
22214
+ );
22215
+ },
22216
+ options.signal
22217
+ );
22218
+ });
22159
22219
  }
22160
22220
 
22161
22221
  export {