peachsim 0.1.1815 → 0.1.1818

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/cli/commands/agent-indicator-mode.ts +2 -1
  2. package/cli/commands/coverage-swift.ts +4 -3
  3. package/cli/commands/flow.ts +7 -0
  4. package/cli/commands/inspect/core.ts +1 -1
  5. package/cli/commands/maestro-compare.ts +7 -0
  6. package/cli/commands/package.ts +87 -31
  7. package/cli/commands/screenshot-mode.ts +2 -1
  8. package/cli/commands/shell-boolean-mode.ts +7 -3
  9. package/cli/commands/shell-url.ts +4 -0
  10. package/cli/commands/show-touches-mode.ts +2 -1
  11. package/cli/commands/test.ts +3 -2
  12. package/cli/commands/three-mode.ts +2 -1
  13. package/cli/outbound-endpoints.ts +1 -1
  14. package/cli/packaged-app-launcher.ts +6 -1
  15. package/dist-lib/agent-daemon-client.cjs +1 -1
  16. package/dist-lib/agent-events.cjs +1 -1
  17. package/dist-lib/attached-projects.cjs +1 -1
  18. package/dist-lib/auth/shared-session.cjs +1 -1
  19. package/dist-lib/backend-origin.cjs +1 -1
  20. package/dist-lib/beta.cjs +1 -1
  21. package/dist-lib/beta.mjs +1 -1
  22. package/dist-lib/bridge-constants.cjs +1 -1
  23. package/dist-lib/bridge-contract-input.cjs +1 -1
  24. package/dist-lib/bridge-contract-input.mjs +1 -1
  25. package/dist-lib/bridge-contract.cjs +1 -1
  26. package/dist-lib/bridge-contract.mjs +1 -1
  27. package/dist-lib/bundle-channel.cjs +5728 -7551
  28. package/dist-lib/capture-contract.cjs +1 -1
  29. package/dist-lib/capture-contract.mjs +1 -1
  30. package/dist-lib/cloud-contract.cjs +1 -1
  31. package/dist-lib/cloud-contract.mjs +1 -1
  32. package/dist-lib/cloud-test-args.cjs +1 -1
  33. package/dist-lib/cloud-test-args.mjs +1 -1
  34. package/dist-lib/cloud.cjs +1 -1
  35. package/dist-lib/cloud.mjs +1 -1
  36. package/dist-lib/config.cjs +1 -1
  37. package/dist-lib/config.mjs +1 -1
  38. package/dist-lib/detox/index.cjs +13 -4
  39. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  40. package/dist-lib/expo-swift-bundle.cjs +5234 -5704
  41. package/dist-lib/expo-swift-metadata.cjs +1 -1
  42. package/dist-lib/expo-swift-metadata.mjs +1 -1
  43. package/dist-lib/home-paths.cjs +1 -1
  44. package/dist-lib/host/bridge-host.cjs +4913 -6811
  45. package/dist-lib/host/fetch-proxy-handler.cjs +13 -4
  46. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  47. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  48. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  49. package/dist-lib/host/websocket-proxy.cjs +1 -1
  50. package/dist-lib/index.cjs +40 -30
  51. package/dist-lib/jump-to-source-babel.cjs +1 -1
  52. package/dist-lib/jump-to-source-native.cjs +1 -1
  53. package/dist-lib/kotlin-host.cjs +1 -1
  54. package/dist-lib/menu.cjs +1 -1
  55. package/dist-lib/menu.mjs +1 -1
  56. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  57. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  58. package/dist-lib/metro-production-bundle.cjs +1 -1
  59. package/dist-lib/metro-production-bundle.mjs +1 -1
  60. package/dist-lib/metro.cjs +39 -29
  61. package/dist-lib/native-app-identity-project.cjs +31 -26
  62. package/dist-lib/native-app-identity-project.mjs +295 -279
  63. package/dist-lib/native-app-identity.cjs +1 -1
  64. package/dist-lib/native-app-identity.mjs +1 -1
  65. package/dist-lib/native-firebase-metadata.cjs +1 -1
  66. package/dist-lib/native-firebase-metadata.mjs +1 -1
  67. package/dist-lib/pdfium-raster.cjs +1 -1
  68. package/dist-lib/pdfium-raster.mjs +1 -1
  69. package/dist-lib/plist.cjs +1 -1
  70. package/dist-lib/plist.mjs +1 -1
  71. package/dist-lib/profiles.cjs +1 -1
  72. package/dist-lib/public-brand.cjs +1 -1
  73. package/dist-lib/public-origins-lib-esm.json +29 -24
  74. package/dist-lib/public-origins-lib.json +121 -93
  75. package/dist-lib/react-native-host-modules.cjs +1 -1
  76. package/dist-lib/react-native-host-modules.mjs +1 -1
  77. package/dist-lib/reap-browser.cjs +1 -1
  78. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  79. package/dist-lib/sdk.cjs +2 -2
  80. package/dist-lib/sdk.mjs +2 -2
  81. package/dist-lib/skills.cjs +64622 -66476
  82. package/dist-lib/swift-compile.cjs +328 -265
  83. package/dist-lib/swift-compile.mjs +335 -270
  84. package/dist-lib/swift-package.cjs +1 -1
  85. package/dist-lib/swift-package.mjs +1 -1
  86. package/dist-lib/swift-submit.cjs +1 -1
  87. package/dist-lib/swift-submit.mjs +1 -1
  88. package/dist-lib/swift-toolchain.cjs +52 -6
  89. package/dist-lib/swift.cjs +1 -1
  90. package/dist-lib/vite-swift.cjs +2405 -2262
  91. package/dist-lib/vite.cjs +13 -4
  92. package/dist-lib/worklet-executable.cjs +1 -1
  93. package/dist-lib/worklet-executable.mjs +1 -1
  94. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +5 -0
  95. package/dist-types/packages/peach-engine/src/render-worker/map-command-channel.d.ts +41 -0
  96. package/dist-types/packages/peach-engine/src/render-worker/mapServicesContract.d.ts +45 -0
  97. package/package.json +2 -1
  98. package/runtime-companion.json +1 -1
  99. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes +1 -1
  100. package/sdk/ios/usr/include/module.modulemap +3 -0
  101. package/sdk/ios/usr/include/notify.modulemap +9 -0
  102. package/sdk/ios/usr/lib/swift/Darwin.swiftmodule/arm64-apple-ios-simulator.swiftinterface +4 -0
  103. package/sdk/ios/usr/lib/swift/Dispatch.swiftmodule/arm64-apple-ios-simulator.swiftinterface +1 -1
  104. package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +7 -1
  105. package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +1 -0
  106. package/sdk/ios/usr/lib/swift/SwiftUI.swiftmodule/arm64-apple-ios-simulator.swiftinterface +21 -0
  107. package/sdk/ios/usr/lib/swift/SwiftUICore.swiftmodule/arm64-apple-ios-simulator.swiftinterface +6 -1
  108. package/sdk/ios/wasm/include/__header_time.h +4 -0
  109. package/sdk/ios/wasm/include/pthread.h +2 -0
  110. package/sdk/ios/wasm/include/sys/mman.h +1 -1
  111. package/sdk/ios/wasm/include/sys/resource.h +31 -0
  112. package/sdk/ios/wasm/include/unistd.h +4 -0
  113. package/src/answeredNativePackages.ts +43 -0
  114. package/src/cli-runtime.ts +2 -9
  115. package/src/expo-discovery-cache.ts +71 -52
  116. package/src/expo-kotlin-host.ts +11 -9
  117. package/src/expo-swift-host.ts +55 -13
  118. package/src/installed-native-libraries.ts +103 -20
  119. package/src/native-static-libraries.ts +69 -33
  120. package/src/nitro-adapter.ts +0 -9
  121. package/src/nitro-bundle.ts +8 -6
  122. package/src/nitro-compile.ts +45 -16
  123. package/src/nitro-compiler-digest.ts +2 -4
  124. package/src/nitro-superset.lock.json +19 -251
  125. package/src/nitro-superset.ts +63 -68
  126. package/src/plist-bytes.ts +9 -0
  127. package/src/portable-expo-workspace.ts +4 -3
  128. package/src/react-native-bridge-modules.ts +13 -19
  129. package/src/swift-compile.ts +379 -269
  130. package/src/swift-cxx-reachable.ts +13 -0
  131. package/src/swift-distribution.ts +3 -4
  132. package/src/swift-host.ts +5 -3
  133. package/src/swift-installed-targets.ts +32 -14
  134. package/src/swift-native-pin.ts +45 -0
  135. package/src/swift-objc-compile.ts +23 -1
  136. package/src/swift-objc-standin.ts +14 -7
  137. package/src/swift-package-manifest.ts +2 -2
  138. package/src/swift-root-lock.ts +4 -3
  139. package/src/swift-standins.ts +41 -38
  140. package/src/swift-toolchain.ts +69 -12
  141. package/src/swift-wasm-prune.ts +1 -0
  142. package/src/swift-xcframework.ts +23 -12
  143. package/src/swiftContract.ts +2 -0
  144. package/src/swiftNativePinContract.ts +68 -0
  145. package/src/turbo-bundle.ts +14 -6
  146. package/src/turbo-compile.ts +76 -11
  147. package/src/turbo-source.ts +93 -18
@@ -1,8 +1,8 @@
1
- /*! peach v0.1.1815 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1818 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/swift-compile.ts
4
4
  import {
5
- spawn as spawn3,
5
+ spawn as spawn4,
6
6
  execFileSync as execFileSync9
7
7
  } from "node:child_process";
8
8
  import { createHash as createHash8, randomUUID as randomUUID5 } from "node:crypto";
@@ -2585,13 +2585,15 @@ import { spawnSync as spawnSync4 } from "node:child_process";
2585
2585
  import path5 from "node:path";
2586
2586
 
2587
2587
  // src/swift-toolchain.ts
2588
- import { execFile, execFileSync } from "node:child_process";
2588
+ import { execFile, execFileSync, spawn as spawn2 } from "node:child_process";
2589
2589
  import { createHash as createHash2 } from "node:crypto";
2590
2590
  import fs from "node:fs";
2591
2591
  import os from "node:os";
2592
2592
  import path4 from "node:path";
2593
+ import { pipeline } from "node:stream/promises";
2593
2594
  import { fileURLToPath } from "node:url";
2594
2595
  import { promisify } from "node:util";
2596
+ import zlib from "node:zlib";
2595
2597
  function peachsimPackageRoot() {
2596
2598
  let dir = import.meta.dirname;
2597
2599
  while (!fs.existsSync(path4.join(dir, "package.json")) && dir !== path4.dirname(dir))
@@ -2620,6 +2622,7 @@ var SWIFT_HOST_COMPILER_ID = "81b2c791c27276bf";
2620
2622
  var compilerArchives = {
2621
2623
  "swift-6.4.0-RELEASE-custom-0b2d0a9011c88e66": {
2622
2624
  identity: "0b2d0a9011c88e66",
2625
+ archive: "tar.gz",
2623
2626
  hosts: {
2624
2627
  "darwin-arm64": {
2625
2628
  checksum: "dc6a494227297ea657e8e5f7c5b4a861cb5e142bdbcfcb028ace2aeb19db90cc",
@@ -2637,6 +2640,7 @@ var compilerArchives = {
2637
2640
  },
2638
2641
  "swift-6.4.0-RELEASE-custom-f7c03c3f59ec5d83": {
2639
2642
  identity: "f7c03c3f59ec5d83",
2643
+ archive: "tar.gz",
2640
2644
  hosts: {
2641
2645
  "darwin-arm64": {
2642
2646
  checksum: "8946a2d4716d3b0784cef7a85a35f66537bd319c4c5a48c63457d607260df5c5",
@@ -2654,6 +2658,7 @@ var compilerArchives = {
2654
2658
  },
2655
2659
  "swift-6.4.0-RELEASE-custom-3e3dca8fd1d82975": {
2656
2660
  identity: "3e3dca8fd1d82975",
2661
+ archive: "tar.gz",
2657
2662
  hosts: {
2658
2663
  "darwin-arm64": {
2659
2664
  checksum: "dfad56454f5e1e465071ff708bf485be65b438cf55d02b04d26d17d26df9f54a",
@@ -2671,6 +2676,7 @@ var compilerArchives = {
2671
2676
  },
2672
2677
  "swift-6.4.0-RELEASE-custom-b082ac5437336790": {
2673
2678
  identity: "b082ac5437336790",
2679
+ archive: "tar.gz",
2674
2680
  hosts: {
2675
2681
  "darwin-arm64": {
2676
2682
  checksum: "85e601982321d3a6f81f05928bc9bbe7a61bc75b27ce24508e79f6b5b537254d",
@@ -2688,6 +2694,7 @@ var compilerArchives = {
2688
2694
  },
2689
2695
  "swift-6.4.0-RELEASE-custom-9cdaffdb6b37fb47": {
2690
2696
  identity: "9cdaffdb6b37fb47",
2697
+ archive: "tar.gz",
2691
2698
  hosts: {
2692
2699
  "darwin-arm64": {
2693
2700
  checksum: "fdd3f88cf76a8dc2083275d4253255030068a25b5ba68acbf59e0407c45677dd",
@@ -2705,6 +2712,7 @@ var compilerArchives = {
2705
2712
  },
2706
2713
  "swift-6.4.0-RELEASE-custom-bd49e2f77434e7b1": {
2707
2714
  identity: "bd49e2f77434e7b1",
2715
+ archive: "tar.gz",
2708
2716
  hosts: {
2709
2717
  "darwin-arm64": {
2710
2718
  checksum: "e815b06394566e8125475afc8f1807f7f465318c845549c5831043cdc28eca64",
@@ -2722,6 +2730,7 @@ var compilerArchives = {
2722
2730
  },
2723
2731
  "swift-6.4.0-RELEASE-custom-13450179a7e01c81": {
2724
2732
  identity: "13450179a7e01c81",
2733
+ archive: "tar.gz",
2725
2734
  hosts: {
2726
2735
  "darwin-arm64": {
2727
2736
  checksum: "a29be6b722f15c7aafac26ba5703a7392f49ce7ea5e1c56548846b7e458290f7",
@@ -2739,6 +2748,7 @@ var compilerArchives = {
2739
2748
  },
2740
2749
  "swift-6.4.0-RELEASE-custom-f6868fa6054e83d6": {
2741
2750
  identity: "f6868fa6054e83d6",
2751
+ archive: "tar.gz",
2742
2752
  hosts: {
2743
2753
  "darwin-arm64": {
2744
2754
  checksum: "bd80c2f35864ec29883dd22001d0165821e80d78002fc12f92406c3c708694a4",
@@ -2756,23 +2766,25 @@ var compilerArchives = {
2756
2766
  },
2757
2767
  "swift-6.4.0-RELEASE-custom-a560ff35bf882b5c": {
2758
2768
  identity: "a560ff35bf882b5c",
2769
+ archive: "tar.zst",
2759
2770
  hosts: {
2760
2771
  "darwin-arm64": {
2761
- checksum: "ec20a41851ac558fe663d78def6b93d0d47c5a0cb69688ee270fd85de637a522",
2772
+ checksum: "36c50bcdfba88a4c0989af0bd60371497eb4403aa7b80644b479fa509a2187a9",
2762
2773
  manifest: "253e891527d2213f54eace768b902de89de5e9495a3c5f4018de1985516bd553"
2763
2774
  },
2764
2775
  "linux-x64": {
2765
- checksum: "f0126a2e63d275895036d02d75a901070da0343dbf03bf17342e10cb6f893dee",
2776
+ checksum: "ba25da9182314fc7b7dd2fc041280e1c7b409f80a1fbccdfa5c342669d164c8e",
2766
2777
  manifest: "6f951cc4071dd0d6054d85711a7c5fe272273658847831b477a8b24be7254ca0"
2767
2778
  },
2768
2779
  "linux-arm64": {
2769
- checksum: "315fa766559a6e69bfd10dcddf40e04c91155f0db3047d210d74ac87652fb7e6",
2780
+ checksum: "5f0f4456e9fe22b5486025db9f679c865841660797d71761245291c2c6811c20",
2770
2781
  manifest: "b6f62fca2ec37593e274ee5bac474f21ffc5db14cd82f492ccbc774f8e9b75d8"
2771
2782
  }
2772
2783
  }
2773
2784
  },
2774
2785
  [SWIFT_HOST_COMPILER_RELEASE]: {
2775
2786
  identity: SWIFT_HOST_COMPILER_ID,
2787
+ archive: "tar.gz",
2776
2788
  hosts: {
2777
2789
  "darwin-arm64": {
2778
2790
  checksum: "bc51b83d9e2e01c9873875326544734486d3ff3a868d650379c304045e8838d3",
@@ -2805,15 +2817,20 @@ function privateSwiftRelease() {
2805
2817
  throw new Error(`${root} holds no Swift distribution release`);
2806
2818
  return release;
2807
2819
  }
2808
- function swiftHostCompilerArchive(release, host2 = `${process.platform}-${process.arch}`) {
2820
+ function swiftHostCompilerPin(release) {
2809
2821
  const compiler = compilerArchives[release];
2810
2822
  if (!compiler) throw new Error(`unqualified host compiler ${release}`);
2823
+ return compiler;
2824
+ }
2825
+ function swiftHostCompilerArchive(release, host2 = `${process.platform}-${process.arch}`) {
2826
+ const compiler = swiftHostCompilerPin(release);
2811
2827
  const archive = compiler.hosts[host2];
2812
2828
  if (!archive) throw new Error(`unsupported Swift compiler host ${host2}`);
2813
2829
  return {
2814
2830
  ...archive,
2815
2831
  identity: compiler.identity,
2816
- url: `https://r2.sootsim.com/swift-host-compiler/${compiler.identity}/${release}-${host2}.tar.gz`
2832
+ archive: compiler.archive,
2833
+ url: `https://r2.sootsim.com/swift-host-compiler/${compiler.identity}/${archive.checksum}.${compiler.archive}`
2817
2834
  };
2818
2835
  }
2819
2836
  function swiftUpstreamRelease(release) {
@@ -3744,26 +3761,6 @@ var NATIVE_GRAPH_INPUTS = {
3744
3761
  target: IOS_SDK_TARGET
3745
3762
  };
3746
3763
  var NATIVE_GRAPH_ID = createHash3("sha256").update(JSON.stringify(NATIVE_GRAPH_INPUTS)).digest("hex");
3747
- function stripExternalSourceMarks(text2) {
3748
- return text2.split("\n").map(
3749
- (line) => line.startsWith("#define PEACH_SWIFT_CLASS(") ? line : line.replace(/PEACH_SWIFT_CLASS\(\w+\)\s*/g, "")
3750
- ).join("\n");
3751
- }
3752
- function iosSdkEntries() {
3753
- const overlays = Object.entries(IOS_SDK_OVERLAYS).map(
3754
- ([module, text2]) => [
3755
- `usr/lib/swift/${module}.swiftmodule/arm64-apple-ios-simulator.swiftinterface`,
3756
- `// swift-interface-format-version: 1.0
3757
- // swift-module-flags: -target ${IOS_SDK_TARGET} -enable-objc-interop -enable-library-evolution -module-name ${module}
3758
- ${text2}`
3759
- ]
3760
- );
3761
- const headers = Object.entries(IOS_SDK_HEADERS).map(
3762
- ([file, text2]) => [file, stripExternalSourceMarks(text2)]
3763
- );
3764
- return [...headers, ...overlays].sort(([a], [b]) => a < b ? -1 : 1);
3765
- }
3766
- var IOS_SDK_ID = createHash3("sha256").update(JSON.stringify(iosSdkEntries())).digest("hex").slice(0, 16);
3767
3764
  function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
3768
3765
  return [
3769
3766
  ...swiftObjCPlatformFlags(toolchainBin, minimum),
@@ -3791,6 +3788,9 @@ function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
3791
3788
  path7.join(headers, "System/Library/Frameworks"),
3792
3789
  "-isystem",
3793
3790
  path7.join(headers, "wasm/include"),
3791
+ // compiler intrinsics an arm64 unit includes, ahead of clang's arm-only ones.
3792
+ "-isystem",
3793
+ path7.join(headers, "wasm/intrinsics"),
3794
3794
  // libxml2 headers sit one level deeper, as in the iOS sdk: a unit
3795
3795
  // includes <libxml/parser.h> through usr/include/libxml2, never the parent.
3796
3796
  "-I",
@@ -5012,7 +5012,7 @@ function swiftReproducibleBuildFlags(roots) {
5012
5012
 
5013
5013
  // src/swift-root-lock.ts
5014
5014
  import {
5015
- spawn as spawn2
5015
+ spawn as spawn3
5016
5016
  } from "node:child_process";
5017
5017
  import { createHash as createHash6, randomUUID as randomUUID4 } from "node:crypto";
5018
5018
  import {
@@ -5176,18 +5176,18 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
5176
5176
  const children = [];
5177
5177
  const lease = {
5178
5178
  register(child) {
5179
- children.push(child);
5179
+ const index = children.push(child);
5180
5180
  if (child.pid === void 0) throw new Error("could not register compiler process");
5181
- const childPending = `${pending}.child.${child.pid}`;
5181
+ const childPending = `${pending}.child.${index}`;
5182
5182
  try {
5183
5183
  writeFileSync2(childPending, JSON.stringify(ownIdentity(child.pid)));
5184
- linkSync(childPending, path14.join(directory, name(held, `child.${child.pid}`)));
5184
+ linkSync(childPending, path14.join(directory, name(held, `child.${index}`)));
5185
5185
  } finally {
5186
5186
  rmSync4(childPending, { force: true });
5187
5187
  }
5188
5188
  },
5189
5189
  spawn(command, args, options, companion) {
5190
- const child = spawn2(
5190
+ const child = spawn3(
5191
5191
  "/bin/sh",
5192
5192
  ["-c", 'IFS= read -r go || exit 1; exec "$@" </dev/null', "sh", command, ...args],
5193
5193
  { ...options, detached: true, stdio: ["pipe", "pipe", "pipe"] }
@@ -6757,7 +6757,8 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6757
6757
  const prunedRspPath = path16.join(directory, ".peach-link.pruned.rsp");
6758
6758
  fs6.writeFileSync(prunedRspPath, outTokens.map((t) => JSON.stringify(t)).join(" "));
6759
6759
  execFileSync7(path16.join(toolchainBin, "wasm-ld"), [`@${prunedRspPath}`], {
6760
- stdio: "pipe"
6760
+ stdio: "pipe",
6761
+ maxBuffer: Infinity
6761
6762
  });
6762
6763
  fs6.rmSync(rspPath, { force: true });
6763
6764
  }
@@ -7064,7 +7065,7 @@ async function runCompiler(command, args, options, stream = false, quiet) {
7064
7065
  detached: true,
7065
7066
  stdio: ["ignore", "pipe", "pipe"]
7066
7067
  };
7067
- const child = options.lease ? options.lease.spawn(command, args, launch, options.frameworkLease) : spawn3(command, args, launch);
7068
+ const child = options.lease ? options.lease.spawn(command, args, launch, options.frameworkLease) : spawn4(command, args, launch);
7068
7069
  let stopping;
7069
7070
  try {
7070
7071
  return await new Promise((resolve, reject) => {
@@ -7281,7 +7282,7 @@ function swiftModuleInputFiles(root) {
7281
7282
  walk("ios-simulator-stdlib");
7282
7283
  return files.sort();
7283
7284
  }
7284
- function swiftMacroPlugins(moduleRoot) {
7285
+ function swiftMacroPlugins(moduleRoot, dir = path19.join(moduleRoot, ".build/host/RnxPreviewMacros")) {
7285
7286
  const distribution = swiftDistributionAt(moduleRoot);
7286
7287
  if (distribution)
7287
7288
  return {
@@ -7289,7 +7290,6 @@ function swiftMacroPlugins(moduleRoot) {
7289
7290
  executables: distribution.plugins.filter((plugin) => path19.basename(plugin) === "ExpoModulesMacros").map((plugin) => path19.join(moduleRoot, plugin)),
7290
7291
  stale: false
7291
7292
  };
7292
- const dir = path19.join(moduleRoot, ".build/host/RnxPreviewMacros");
7293
7293
  const release = JSON.parse(
7294
7294
  readFileSync11(path19.join(moduleRoot, "toolchain.json"), "utf8")
7295
7295
  ).release;
@@ -7683,14 +7683,20 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
7683
7683
  for (const match of readFileSync11(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
7684
7684
  modules.add(match[1]);
7685
7685
  }
7686
- const libc = path19.join(darwin, "usr/include");
7687
- for (const entry of readdirSync8(libc)) {
7688
- if (!entry.endsWith(".modulemap")) continue;
7689
- for (const match of readFileSync11(path19.join(libc, entry), "utf8").matchAll(
7690
- /^module\s+([A-Za-z_]\w*)/gm
7691
- ))
7692
- modules.add(match[1]);
7693
- }
7686
+ for (const libc of [
7687
+ path19.join(darwin, "usr/include"),
7688
+ path19.join(
7689
+ swiftSharedSdkRoot(moduleRoot, swiftDistributionAt(moduleRoot) !== null),
7690
+ "usr/include"
7691
+ )
7692
+ ])
7693
+ for (const entry of readdirSync8(libc)) {
7694
+ if (!entry.endsWith(".modulemap")) continue;
7695
+ for (const match of readFileSync11(path19.join(libc, entry), "utf8").matchAll(
7696
+ /^module\s+([A-Za-z_]\w*)/gm
7697
+ ))
7698
+ modules.add(match[1]);
7699
+ }
7694
7700
  for (const directory of frameworks) {
7695
7701
  for (const entry of readdirSync8(directory)) {
7696
7702
  const map = path19.join(directory, entry, "Modules/module.modulemap");
@@ -7822,7 +7828,7 @@ var darwinRecordsRegion = (quoted) => quoted.length ? ["-Wl,--start-lib", ...quo
7822
7828
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
7823
7829
  var MULTI_MANIFEST_VERSION = 65;
7824
7830
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
7825
- var compilerSourceDigest = true ? "f6bf05da9a8bbde24169c3c8ff29e36d48f13ea9f817f33a350da3c475783ddd" : swiftCompilerSourceDigest(import.meta.dirname);
7831
+ var compilerSourceDigest = true ? "f079d0f9f3d0467a52729f6950de38e5f71e1ad9017031a3ec3722aad044dac2" : swiftCompilerSourceDigest(import.meta.dirname);
7826
7832
  function swiftArtifactHash(input, release, moduleRoot) {
7827
7833
  const hash = createHash8("sha256");
7828
7834
  hash.update(`swift-compile
@@ -8019,6 +8025,14 @@ function emitSwiftPackageManifest(args) {
8019
8025
  );
8020
8026
  const macroSettings = (values) => (values ?? []).map((value) => ` ${clangMacroSetting(value)},`).join("");
8021
8027
  const flagArray = (literal) => `peachCompilerArguments(${JSON.stringify(literal.replace(/,\s*]$/, "]"))})`;
8028
+ const swiftFlagArray = (literal) => {
8029
+ const flags = JSON.parse(literal.replace(/,\s*]$/, "]"));
8030
+ const content = flags.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
8031
+ const digest = createHash8("sha256").update(content).digest("hex");
8032
+ const file = path19.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
8033
+ args.files.set(file, content);
8034
+ return JSON.stringify([`@${file}`]);
8035
+ };
8022
8036
  const declaredClangSettings = (target, tool) => clangSettingEntries(
8023
8037
  target?.clangSettings?.map(
8024
8038
  (setting) => "flags" in setting ? {
@@ -8081,7 +8095,7 @@ function emitSwiftPackageManifest(args) {
8081
8095
  (value) => value.late?.producers.includes(target.name)
8082
8096
  )) ? `, "-emit-objc-header-path", ${JSON.stringify(path19.join(args.headerDirectory, `${target.name}-Swift${args.nativeHeaderDeclarations?.[target.name] ? ".original" : ""}.h`))}` : "";
8083
8097
  const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
8084
- const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${flagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImportFlags}${objcFlags}${header}${clangMode}${upstream}]`)})]`;
8098
+ const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImportFlags}${objcFlags}${header}${clangMode}${upstream}]`)})]`;
8085
8099
  const deps = [
8086
8100
  .../* @__PURE__ */ new Set([
8087
8101
  ...(target.dependencies ?? []).flatMap(
@@ -9783,7 +9797,13 @@ function namesLibxml2(input) {
9783
9797
  }
9784
9798
  return false;
9785
9799
  }
9800
+ function needsNativeToolset(input, prebuilt) {
9801
+ return Boolean(
9802
+ input.packageFiles || prebuilt || Object.keys(input.files).some(isSwiftNativeTranslationUnit)
9803
+ );
9804
+ }
9786
9805
  function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
9806
+ const nativeToolset = needsNativeToolset(input, prebuilt);
9787
9807
  if (input.headerAliases !== void 0 && !isSwiftHeaderAliases(input.headerAliases))
9788
9808
  throw new Error("swift compile input has invalid original header aliases");
9789
9809
  if (input.nativeTargets !== void 0 && !isSwiftNativeTargets(input.nativeTargets))
@@ -10129,7 +10149,11 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
10129
10149
  importModuleMaps,
10130
10150
  generatedModuleMaps
10131
10151
  );
10132
- const flags = [...stageFlags(originalFlags, sdkInclude), ...dependencyModuleMaps];
10152
+ const flags = [
10153
+ ...stageFlags(originalFlags, sdkInclude),
10154
+ ...dependencyModuleMaps,
10155
+ ...target.defines?.includes(SWIFT_XCODE_BUILD_CONDITION) && !target.defines.includes("SWIFT_PACKAGE") ? ["-USWIFT_PACKAGE"] : []
10156
+ ];
10133
10157
  const prefixHeader = settings?.prefixHeader ? ["-include", path19.join(layout.root, settings.prefixHeader)] : [];
10134
10158
  const bundleName = entries.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
10135
10159
  target: target.name,
@@ -10285,7 +10309,8 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
10285
10309
  ).digest("hex").slice(0, 12);
10286
10310
  const name2 = `${target.name}${nativeC ? "Native" : "Swift"}Implementation_${identity}`;
10287
10311
  const groupPath = path19.posix.join("PeachNativeSources", name2);
10288
- const sourceIdentity = `-ffile-prefix-map=${path19.join(layout.root, groupPath)}=${path19.join(layout.root, target.path)}`;
10312
+ const identityRoot = nativeToolset ? "/peach/build" : layout.root;
10313
+ const sourceIdentity = `-ffile-prefix-map=${path19.join(identityRoot, groupPath)}=${path19.join(identityRoot, target.path)}`;
10289
10314
  const group = groups.get(identity) ?? {
10290
10315
  name: name2,
10291
10316
  path: groupPath,
@@ -10810,6 +10835,7 @@ module ${moduleName}.Swift {
10810
10835
  path19.join(layout.root, "Package.swift"),
10811
10836
  emitSwiftPackageManifest({
10812
10837
  root: layout.root,
10838
+ files,
10813
10839
  targets: manifestTargets,
10814
10840
  packages,
10815
10841
  native,
@@ -10864,7 +10890,7 @@ module ${moduleName}.Swift {
10864
10890
  if (files.has(destination)) continue;
10865
10891
  files.set(destination, Buffer.from(bytes, "base64"));
10866
10892
  }
10867
- if (input.packageFiles || prebuilt) {
10893
+ if (nativeToolset) {
10868
10894
  files.set(
10869
10895
  path19.join(layout.root, ".peach-target-toolset.json"),
10870
10896
  JSON.stringify({
@@ -10955,6 +10981,10 @@ module ${moduleName}.Swift {
10955
10981
  for (const producer of producers)
10956
10982
  for (const dependency of dependencies.get(producer) ?? []) include(dependency);
10957
10983
  return {
10984
+ nativeBuildTargets: [...native].flatMap(([name2, plan]) => [
10985
+ ...!plan.mixed && plan.sources.length > 0 ? [name2] : [],
10986
+ ...plan.groups?.map((group) => group.name) ?? (plan.late ? [plan.late.name] : [])
10987
+ ]),
10958
10988
  headerProducers: [
10959
10989
  .../* @__PURE__ */ new Set([
10960
10990
  ...Object.keys(nativeHeaderDeclarations),
@@ -10977,7 +11007,7 @@ function outputOf(error) {
10977
11007
  streamText(Reflect.get(error, "stdout")),
10978
11008
  streamText(Reflect.get(error, "stderr"))
10979
11009
  ].filter(Boolean);
10980
- if (error instanceof Error) streams.push(error.message);
11010
+ if (error instanceof Error) streams.unshift(error.message);
10981
11011
  if (streams.length > 0) return streams.join("\n");
10982
11012
  }
10983
11013
  return error instanceof Error ? error.message : String(error);
@@ -11526,7 +11556,17 @@ function retireStaleSwiftLink(root, stamp) {
11526
11556
  rmSync5(retired, { recursive: true, force: true });
11527
11557
  return true;
11528
11558
  }
11529
- function compileSwiftProjectUnit(input, options) {
11559
+ async function compileSwiftProjectUnit(input, options) {
11560
+ for (let attempt = 1; ; attempt++) {
11561
+ try {
11562
+ return await compileSwiftProjectOnce(input, options);
11563
+ } catch (error) {
11564
+ if (attempt >= 3 || !outputOf(error).includes("differs from the caller"))
11565
+ throw error;
11566
+ }
11567
+ }
11568
+ }
11569
+ function compileSwiftProjectOnce(input, options) {
11530
11570
  options.signal?.throwIfAborted();
11531
11571
  mkdirSync4(options.buildRoot, { recursive: true });
11532
11572
  const root = realpathSync3(options.buildRoot);
@@ -11637,245 +11677,270 @@ function compileSwiftProjectUnit(input, options) {
11637
11677
  `swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
11638
11678
  );
11639
11679
  }
11640
- return withSwiftRootLock(
11641
- swiftFrameworkScratch(frameworkKey),
11642
- async (frameworkLease) => {
11643
- const frameworkRoot = stageFrameworkSource(moduleRoot, frameworkKey);
11644
- report("preparing compiler plugins");
11645
- const macroPlugins = await ensureMacroPlugins(
11646
- frameworkRoot,
11647
- options.toolchainBin,
11648
- options.release,
11649
- options.signal,
11650
- frameworkLease
11680
+ const frameworkScratch = swiftFrameworkScratch(frameworkKey);
11681
+ const withFrameworkLock = (work) => distribution ? work() : withSwiftRootLock(frameworkScratch, work, options.signal);
11682
+ return withFrameworkLock(async (frameworkLease) => {
11683
+ const frameworkRoot = stageFrameworkSource(moduleRoot, frameworkKey);
11684
+ report("preparing compiler plugins");
11685
+ const pluginsFor = (pluginLease) => ensureMacroPlugins(
11686
+ frameworkRoot,
11687
+ options.toolchainBin,
11688
+ options.release,
11689
+ options.signal,
11690
+ pluginLease
11691
+ );
11692
+ const macroPlugins = distribution ? await withSwiftRootLock(frameworkScratch, pluginsFor, options.signal) : await pluginsFor(frameworkLease);
11693
+ const sdk = swiftModuleSdk(frameworkRoot).wasmSdkId;
11694
+ const icu = swiftIcuAsset(options.toolchainBin, sdk);
11695
+ const buildOptions = {
11696
+ env: {
11697
+ ...options.project?.env ?? process.env,
11698
+ // shipped host plugins resolve against the selected compiler's runtime.
11699
+ ...process.platform === "linux" ? {
11700
+ LD_LIBRARY_PATH: [
11701
+ path19.resolve(options.toolchainBin, "../lib/swift/linux"),
11702
+ path19.resolve(options.toolchainBin, "../lib/swift/host"),
11703
+ process.env.LD_LIBRARY_PATH
11704
+ ].filter(Boolean).join(":")
11705
+ } : {},
11706
+ ...input.lazyDistribution ? { PEACH_DEFER_WASM_LINK: "1" } : {}
11707
+ },
11708
+ maxBuffer: 64 * 1024 * 1024,
11709
+ timeout: options.timeoutMs,
11710
+ signal: options.signal,
11711
+ lease,
11712
+ frameworkLease
11713
+ };
11714
+ let prebuilt;
11715
+ if (!distribution) {
11716
+ report("compiling framework products");
11717
+ prebuilt = await compileFrameworkProducts({
11718
+ moduleRoot: frameworkRoot,
11719
+ frameworkKey,
11720
+ input,
11721
+ swift,
11722
+ sdk,
11723
+ toolchainBin: options.toolchainBin,
11724
+ plugins: macroPlugins,
11725
+ buildOptions
11726
+ });
11727
+ await pruneFrameworkScratches(frameworkKey);
11728
+ }
11729
+ if (options.project) removeProjectLinks(root);
11730
+ if (retireStaleSwiftLink(
11731
+ root,
11732
+ swiftLinkStamp({
11733
+ frameworkKey,
11734
+ prebuilt
11735
+ })
11736
+ ))
11737
+ report("framework revision changed; rebuilding the app link");
11738
+ const nativeToolset = needsNativeToolset(input, prebuilt);
11739
+ const preparation = writeSwiftProject(layout, input, frameworkRoot, prebuilt);
11740
+ writeSwiftAutolinkLinker(root, options.toolchainBin);
11741
+ const projectProcess = options.project ? prepareSwiftProjectProcess(root, options.project) : void 0;
11742
+ const appOptions = projectProcess ? {
11743
+ ...buildOptions,
11744
+ uid: projectProcess.uid,
11745
+ gid: projectProcess.gid,
11746
+ confined: projectProcess.env
11747
+ } : buildOptions;
11748
+ const unprepared = preparation.targetFailures.map(
11749
+ (failure) => `error: target ${failure}`
11750
+ );
11751
+ const forwarders = /* @__PURE__ */ new Map();
11752
+ for (const [file, text2] of Object.entries(input.files)) {
11753
+ const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text2)?.[1];
11754
+ if (!parents) continue;
11755
+ const directory = path19.posix.dirname(file);
11756
+ forwarders.set(
11757
+ `${path19.join(root, directory)}/${parents.slice(0, -1)}`,
11758
+ path19.posix.join("build", directory, parents).replace(/\/$/, "")
11651
11759
  );
11652
- const sdk = swiftModuleSdk(frameworkRoot).wasmSdkId;
11653
- const icu = swiftIcuAsset(options.toolchainBin, sdk);
11654
- const buildOptions = {
11655
- env: {
11656
- ...options.project?.env ?? process.env,
11657
- // shipped host plugins resolve against the selected compiler's runtime.
11658
- ...process.platform === "linux" ? {
11659
- LD_LIBRARY_PATH: [
11660
- path19.resolve(options.toolchainBin, "../lib/swift/linux"),
11661
- path19.resolve(options.toolchainBin, "../lib/swift/host"),
11662
- process.env.LD_LIBRARY_PATH
11663
- ].filter(Boolean).join(":")
11664
- } : {},
11665
- ...input.lazyDistribution ? { PEACH_DEFER_WASM_LINK: "1" } : {}
11666
- },
11667
- maxBuffer: 64 * 1024 * 1024,
11668
- timeout: options.timeoutMs,
11669
- signal: options.signal,
11670
- lease,
11671
- frameworkLease
11672
- };
11673
- let prebuilt;
11674
- if (!swiftDistributionAt(moduleRoot)) {
11675
- report("compiling framework products");
11676
- prebuilt = await compileFrameworkProducts({
11677
- moduleRoot: frameworkRoot,
11678
- frameworkKey,
11679
- input,
11760
+ }
11761
+ const buildArgs = [
11762
+ "build",
11763
+ ...projectProcess?.cacheOptions ?? swiftPackageCacheOptions(),
11764
+ "--build-system",
11765
+ "native",
11766
+ "-j",
11767
+ BUILD_JOBS,
11768
+ "--package-path",
11769
+ root,
11770
+ ...swiftCompileSdkOptions(frameworkRoot, options.toolchainBin),
11771
+ "--swift-sdk",
11772
+ sdk,
11773
+ ...nativeToolset ? ["--toolset", path19.join(root, ".peach-target-toolset.json")] : [],
11774
+ "-c",
11775
+ "release",
11776
+ "-Xswiftc",
11777
+ "-num-threads",
11778
+ "-Xswiftc",
11779
+ BUILD_JOBS,
11780
+ ...swiftReproducibleBuildFlags([
11781
+ [path19.dirname(options.toolchainBin), "toolchain"],
11782
+ [frameworkRoot, "framework"],
11783
+ [root, "build"],
11784
+ ...forwarders
11785
+ ]).flatMap((flag, index, flags) => {
11786
+ if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
11787
+ return [flag];
11788
+ const mapped = flag.replaceAll(root, "/peach/build").replaceAll(frameworkRoot, "/peach/framework").replaceAll(path19.dirname(options.toolchainBin), "/peach/toolchain");
11789
+ return flags[index - 1] === "-Xcc" ? [mapped, "-Xswiftc", "-Xcc", "-Xswiftc", flag] : [mapped];
11790
+ }),
11791
+ ...macroPlugins.libraries.flatMap((plugin) => [
11792
+ "-Xswiftc",
11793
+ "-load-plugin-library",
11794
+ "-Xswiftc",
11795
+ plugin
11796
+ ]),
11797
+ ...macroPlugins.executables.flatMap((plugin) => [
11798
+ "-Xswiftc",
11799
+ "-load-plugin-executable",
11800
+ "-Xswiftc",
11801
+ `${plugin}#ExpoModulesMacros`
11802
+ ])
11803
+ ];
11804
+ const linked = builtArtifact(layout);
11805
+ if (input.lazyDistribution) {
11806
+ rmSync5(path19.join(root, ".peach-link.rsp"), { force: true });
11807
+ if (existsSync4(linked) && statSync2(linked).size <= 8)
11808
+ rmSync5(linked, { force: true });
11809
+ }
11810
+ report("compiling and linking Swift modules");
11811
+ try {
11812
+ const headerBuilds = preparation.headerProductTarget ? [
11813
+ ...Object.keys(preparation.nativeHeaderDeclarations),
11814
+ preparation.headerProductTarget
11815
+ ] : preparation.headerProducers;
11816
+ for (const build of headerBuilds) {
11817
+ await runCompiler(
11680
11818
  swift,
11681
- sdk,
11682
- toolchainBin: options.toolchainBin,
11683
- plugins: macroPlugins,
11684
- buildOptions
11685
- });
11686
- await pruneFrameworkScratches(frameworkKey);
11819
+ [...buildArgs, "--target", build],
11820
+ appOptions,
11821
+ SWIFTPM_PROGRESS,
11822
+ SWIFTPM_NOISE
11823
+ );
11824
+ for (const producer of build === preparation.headerProductTarget ? preparation.headerProducers : [build]) {
11825
+ const emitted = path19.join(
11826
+ root,
11827
+ ".build",
11828
+ "peach-cxx-headers",
11829
+ `${producer}-Swift.h`
11830
+ );
11831
+ const original = preparation.nativeHeaderDeclarations[producer] ? emitted.replace(/-Swift\.h$/, "-Swift.original.h") : emitted;
11832
+ if (existsSync4(original))
11833
+ writeBuildFile(
11834
+ emitted,
11835
+ withoutSwiftDeclarations(
11836
+ clangInterfaceHeader(readFileSync11(original, "utf8")),
11837
+ new Set(preparation.nativeHeaderDeclarations[producer]),
11838
+ `#import <${producer}/${producer}.h>`
11839
+ )
11840
+ );
11841
+ }
11687
11842
  }
11688
- if (options.project) removeProjectLinks(root);
11689
- if (retireStaleSwiftLink(
11843
+ const checkpoints = path19.join(
11690
11844
  root,
11691
- swiftLinkStamp({
11692
- frameworkKey,
11693
- prebuilt
11694
- })
11695
- ))
11696
- report("framework revision changed; rebuilding the app link");
11697
- const preparation = writeSwiftProject(
11698
- layout,
11699
- input,
11700
- frameworkRoot,
11701
- prebuilt
11845
+ ".build",
11846
+ "peach-native-targets",
11847
+ createHash8("sha256").update(readFileSync11(path19.join(root, "Package.swift"))).digest("hex")
11702
11848
  );
11703
- writeSwiftAutolinkLinker(root, options.toolchainBin);
11704
- const projectProcess = options.project ? prepareSwiftProjectProcess(root, options.project) : void 0;
11705
- const appOptions = projectProcess ? {
11706
- ...buildOptions,
11707
- uid: projectProcess.uid,
11708
- gid: projectProcess.gid,
11709
- confined: projectProcess.env
11710
- } : buildOptions;
11711
- const unprepared = preparation.targetFailures.map(
11712
- (failure) => `error: target ${failure}`
11713
- );
11714
- const forwarders = /* @__PURE__ */ new Map();
11715
- for (const [file, text2] of Object.entries(input.files)) {
11716
- const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text2)?.[1];
11717
- if (!parents) continue;
11718
- const directory = path19.posix.dirname(file);
11719
- forwarders.set(
11720
- `${path19.join(root, directory)}/${parents.slice(0, -1)}`,
11721
- path19.posix.join("build", directory, parents).replace(/\/$/, "")
11849
+ mkdirSync4(checkpoints, { recursive: true });
11850
+ for (const target of /* @__PURE__ */ new Set([
11851
+ ...input.staticClangTargets ?? [],
11852
+ ...preparation.nativeBuildTargets
11853
+ ])) {
11854
+ const checkpoint = path19.join(
11855
+ checkpoints,
11856
+ createHash8("sha256").update(target).digest("hex")
11722
11857
  );
11858
+ if (existsSync4(checkpoint)) continue;
11859
+ await runCompiler(
11860
+ swift,
11861
+ [...buildArgs, "--target", target],
11862
+ appOptions,
11863
+ SWIFTPM_PROGRESS,
11864
+ SWIFTPM_NOISE
11865
+ );
11866
+ writeFileSync4(checkpoint, "");
11723
11867
  }
11724
- const buildArgs = [
11725
- "build",
11726
- ...projectProcess?.cacheOptions ?? swiftPackageCacheOptions(),
11727
- "--build-system",
11728
- "native",
11729
- "-j",
11730
- BUILD_JOBS,
11731
- "--package-path",
11868
+ await runCompiler(
11869
+ swift,
11870
+ buildArgs,
11871
+ appOptions,
11872
+ SWIFTPM_PROGRESS,
11873
+ SWIFTPM_NOISE
11874
+ );
11875
+ } catch (error) {
11876
+ const output2 = outputOf(error);
11877
+ const moduleCache = path19.join(
11732
11878
  root,
11733
- ...swiftCompileSdkOptions(frameworkRoot, options.toolchainBin),
11734
- "--swift-sdk",
11735
- sdk,
11736
- ...input.packageFiles || prebuilt ? ["--toolset", path19.join(root, ".peach-target-toolset.json")] : [],
11737
- "-c",
11879
+ ".build",
11880
+ WASM_TRIPLE,
11738
11881
  "release",
11739
- "-Xswiftc",
11740
- "-num-threads",
11741
- "-Xswiftc",
11742
- BUILD_JOBS,
11743
- ...swiftReproducibleBuildFlags([
11744
- [path19.dirname(options.toolchainBin), "toolchain"],
11745
- [frameworkRoot, "framework"],
11746
- [root, "build"],
11747
- ...forwarders
11748
- ]),
11749
- ...macroPlugins.libraries.flatMap((plugin) => [
11750
- "-Xswiftc",
11751
- "-load-plugin-library",
11752
- "-Xswiftc",
11753
- plugin
11754
- ]),
11755
- ...macroPlugins.executables.flatMap((plugin) => [
11756
- "-Xswiftc",
11757
- "-load-plugin-executable",
11758
- "-Xswiftc",
11759
- `${plugin}#ExpoModulesMacros`
11760
- ])
11761
- ];
11762
- const linked = builtArtifact(layout);
11763
- if (input.lazyDistribution) {
11764
- rmSync5(path19.join(root, ".peach-link.rsp"), { force: true });
11765
- if (existsSync4(linked) && statSync2(linked).size <= 8)
11766
- rmSync5(linked, { force: true });
11767
- }
11768
- report("compiling and linking Swift modules");
11769
- try {
11770
- const headerBuilds = preparation.headerProductTarget ? [
11771
- ...Object.keys(preparation.nativeHeaderDeclarations),
11772
- preparation.headerProductTarget
11773
- ] : preparation.headerProducers;
11774
- for (const build of headerBuilds) {
11882
+ "ModuleCache"
11883
+ );
11884
+ if (output2.includes("was compiled with module cache path") && existsSync4(moduleCache)) {
11885
+ rmSync5(moduleCache, { recursive: true, force: true });
11886
+ try {
11775
11887
  await runCompiler(
11776
11888
  swift,
11777
- [...buildArgs, "--target", build],
11889
+ buildArgs,
11778
11890
  appOptions,
11779
11891
  SWIFTPM_PROGRESS,
11780
11892
  SWIFTPM_NOISE
11781
11893
  );
11782
- for (const producer of build === preparation.headerProductTarget ? preparation.headerProducers : [build]) {
11783
- const emitted = path19.join(
11784
- root,
11785
- ".build",
11786
- "peach-cxx-headers",
11787
- `${producer}-Swift.h`
11788
- );
11789
- const original = preparation.nativeHeaderDeclarations[producer] ? emitted.replace(/-Swift\.h$/, "-Swift.original.h") : emitted;
11790
- if (existsSync4(original))
11791
- writeBuildFile(
11792
- emitted,
11793
- withoutSwiftDeclarations(
11794
- clangInterfaceHeader(readFileSync11(original, "utf8")),
11795
- new Set(preparation.nativeHeaderDeclarations[producer]),
11796
- `#import <${producer}/${producer}.h>`
11797
- )
11798
- );
11799
- }
11800
- }
11801
- await runCompiler(
11802
- swift,
11803
- buildArgs,
11804
- appOptions,
11805
- SWIFTPM_PROGRESS,
11806
- SWIFTPM_NOISE
11807
- );
11808
- } catch (error) {
11809
- const output2 = outputOf(error);
11810
- const moduleCache = path19.join(
11811
- root,
11812
- ".build",
11813
- WASM_TRIPLE,
11814
- "release",
11815
- "ModuleCache"
11816
- );
11817
- if (output2.includes("was compiled with module cache path") && existsSync4(moduleCache)) {
11818
- rmSync5(moduleCache, { recursive: true, force: true });
11819
- try {
11820
- await runCompiler(
11821
- swift,
11822
- buildArgs,
11823
- appOptions,
11824
- SWIFTPM_PROGRESS,
11825
- SWIFTPM_NOISE
11826
- );
11827
- } catch (retryError) {
11828
- throw new Error(
11829
- [
11830
- ...unprepared,
11831
- projectDiagnostic(outputOf(retryError), layout, input.files)
11832
- ].join("\n"),
11833
- { cause: retryError }
11834
- );
11835
- }
11836
- } else {
11894
+ } catch (retryError) {
11837
11895
  throw new Error(
11838
- [...unprepared, projectDiagnostic(output2, layout, input.files)].join(
11839
- "\n"
11840
- ),
11841
- { cause: error }
11896
+ [
11897
+ ...unprepared,
11898
+ projectDiagnostic(outputOf(retryError), layout, input.files)
11899
+ ].join("\n"),
11900
+ { cause: retryError }
11842
11901
  );
11843
11902
  }
11844
- } finally {
11845
- if (options.project) endSwiftProjectProcesses(options.project);
11846
- }
11847
- if (unprepared.length) throw new Error(unprepared.join("\n"));
11848
- if (!existsSync4(linked)) {
11849
- const binDir = path19.dirname(linked);
11850
- const found = existsSync4(binDir) ? readdirSync8(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
11903
+ } else {
11851
11904
  throw new Error(
11852
- `swift-compile: the build produced no ${path19.basename(linked)} (found: ${found.join(", ") || "none"})`
11905
+ [...unprepared, projectDiagnostic(output2, layout, input.files)].join(
11906
+ "\n"
11907
+ ),
11908
+ { cause: error }
11853
11909
  );
11854
11910
  }
11855
- if (options.project) removeProjectLinks(root);
11856
- const output = options.project ? projectOutputFile(root, linked, options.project) : linked;
11857
- const optimized = `${output}.optimized`;
11858
- if (input.lazyDistribution) {
11859
- pruneSwiftWasmLink(
11860
- root,
11861
- options.toolchainBin,
11862
- frameworkRoot,
11863
- input.staticClangTargets
11864
- );
11865
- await optimizeWasm(output, optimized);
11866
- }
11867
- const artifact = {
11868
- hash,
11869
- bytes: readFileSync11(input.lazyDistribution ? optimized : output),
11870
- icu: await icu
11871
- };
11872
- if (!options.project) saveCompiledArtifact(root, artifact);
11873
- saveSharedArtifact(sharedRoot, artifact);
11874
- report("compiled artifact verified");
11875
- return retain(root, artifact);
11876
- },
11877
- options.signal
11878
- );
11911
+ } finally {
11912
+ if (options.project) endSwiftProjectProcesses(options.project);
11913
+ }
11914
+ if (unprepared.length) throw new Error(unprepared.join("\n"));
11915
+ if (!existsSync4(linked)) {
11916
+ const binDir = path19.dirname(linked);
11917
+ const found = existsSync4(binDir) ? readdirSync8(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
11918
+ throw new Error(
11919
+ `swift-compile: the build produced no ${path19.basename(linked)} (found: ${found.join(", ") || "none"})`
11920
+ );
11921
+ }
11922
+ if (options.project) removeProjectLinks(root);
11923
+ const output = options.project ? projectOutputFile(root, linked, options.project) : linked;
11924
+ const optimized = `${output}.optimized`;
11925
+ if (input.lazyDistribution) {
11926
+ pruneSwiftWasmLink(
11927
+ root,
11928
+ options.toolchainBin,
11929
+ frameworkRoot,
11930
+ input.staticClangTargets
11931
+ );
11932
+ await optimizeWasm(output, optimized);
11933
+ }
11934
+ const artifact = {
11935
+ hash,
11936
+ bytes: readFileSync11(input.lazyDistribution ? optimized : output),
11937
+ icu: await icu
11938
+ };
11939
+ if (!options.project) saveCompiledArtifact(root, artifact);
11940
+ saveSharedArtifact(sharedRoot, artifact);
11941
+ report("compiled artifact verified");
11942
+ return retain(root, artifact);
11943
+ });
11879
11944
  },
11880
11945
  options.signal
11881
11946
  );