peachsim 0.1.2412 → 0.1.2422
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/cli/catalog/content.ts +6 -3
- package/cli/catalog/meta.ts +63 -17
- package/cli/catalog/routes.ts +4 -0
- package/cli/cloud-box-artifact.ts +45 -24
- package/cli/cloud-client.ts +6 -2
- package/cli/command-registry.ts +3 -1
- package/cli/commands/control.ts +74 -55
- package/cli/commands/desktop.ts +3 -3
- package/cli/commands/electron.ts +7 -5
- package/cli/commands/kotlin.ts +8 -1
- package/cli/commands/platform.ts +5 -7
- package/cli/commands/profile.ts +2 -2
- package/cli/commands/settings.ts +90 -0
- package/cli/commands/shell-url.ts +18 -10
- package/cli/commands/swift.ts +3 -1
- package/cli/main.ts +6 -0
- package/cli/outbound-endpoints.ts +17 -15
- package/cli/settings-flags.ts +115 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +6683 -4510
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +3 -7
- package/dist-lib/config.mjs +3 -7
- package/dist-lib/detox/index.cjs +4 -4
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +19780 -17646
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +63968 -62664
- package/dist-lib/host/fetch-proxy-handler.cjs +1619 -211
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +2734 -1222
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +972 -246
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +1758 -246
- package/dist-lib/native-app-identity-project.cjs +35 -203
- package/dist-lib/native-app-identity-project.mjs +264 -413
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +32 -25
- package/dist-lib/public-origins-lib.json +222 -120
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +24600 -23060
- package/dist-lib/swift-compile.cjs +1396 -1203
- package/dist-lib/swift-compile.mjs +1351 -1148
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -199
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +2832 -2588
- package/dist-lib/vite.cjs +5254 -3781
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/config.d.ts +1 -4
- package/dist-types/packages/peach-engine/src/engine/native-layout.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +0 -10
- package/dist-types/packages/peach-engine/src/render-worker/compositor-runtime/layer-claims.d.ts +2 -1
- package/kotlin/README.md +4 -3
- package/kotlin/sdk.tar.gz +0 -0
- package/kotlin/toolchain.json +3 -6
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CALayer.h +1 -43
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CALayerContents.h +55 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Modules/module.modulemap +3 -3
- package/sdk/ios/usr/include/ObjectiveC.apinotes +0 -24
- package/sdk/ios/usr/include/grp.h +93 -0
- package/sdk/ios/usr/include/netinet/tcp.h +299 -0
- package/sdk/ios/wasm/include/netinet/tcp.h +6 -0
- package/sdk/ios/wasm/include/stdlib.h +1 -0
- package/sdk/ios/wasm/include/unistd.h +2 -0
- package/skills/contrast/SKILL.md +1 -0
- package/skills/peach-setup/SKILL.md +11 -1
- package/src/android-bridge-dependencies.ts +1 -1
- package/src/app-config.ts +7 -0
- package/src/binaryen.lock.json +21 -0
- package/src/cocoapods-trunk.ts +52 -0
- package/src/config.ts +21 -31
- package/src/expo-kotlin-bundle.ts +1 -1
- package/src/kotlin-host.ts +1 -1
- package/src/kotlin-sdk.ts +7 -7
- package/src/kotlin-toolchain.ts +28 -24
- package/src/kotlinSdkContract.ts +2 -2
- package/src/native-bundles.ts +5 -2
- package/src/native-static-libraries.ts +85 -5
- package/src/podfile-cocoapods.ts +1473 -0
- package/src/podspec-cocoapods.ts +331 -106
- package/src/podspec-ruby-stdlib.ts +134 -19
- package/src/podspec-ruby.ts +199 -46
- package/src/settingsContract.ts +74 -0
- package/src/swift-compile.ts +185 -108
- package/src/swift-compiler-digest.ts +3 -0
- package/src/swift-guest-compile.ts +2 -0
- package/src/swift-guest-source-inputs.ts +2 -2
- package/src/swift-header-compiler.ts +185 -0
- package/src/swift-header-dependencies.ts +174 -0
- package/src/swift-host.ts +32 -7
- package/src/swift-objc-compile.ts +18 -24
- package/src/swift-packages.ts +35 -6
- package/src/swift-shared-sdk.ts +19 -0
- package/src/swift-toolchain.ts +2 -201
- package/src/turbo-source.ts +7 -37
- package/src/wasm-optimize.ts +4 -27
- package/src/xcode-project.ts +6 -1
- package/dist-types/packages/peach-engine/src/render-worker/accessibilityHostContract.d.ts +0 -65
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2422 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -8,28 +8,28 @@ import {
|
|
|
8
8
|
spawn as spawn5,
|
|
9
9
|
execFileSync as execFileSync12
|
|
10
10
|
} from "node:child_process";
|
|
11
|
-
import { createHash as
|
|
11
|
+
import { createHash as createHash15, randomUUID as randomUUID5 } from "node:crypto";
|
|
12
12
|
import {
|
|
13
|
-
chmodSync as
|
|
13
|
+
chmodSync as chmodSync3,
|
|
14
14
|
copyFileSync,
|
|
15
15
|
cpSync,
|
|
16
|
-
existsSync as
|
|
16
|
+
existsSync as existsSync7,
|
|
17
17
|
lstatSync,
|
|
18
|
-
mkdirSync as
|
|
19
|
-
mkdtempSync as
|
|
20
|
-
readFileSync as
|
|
18
|
+
mkdirSync as mkdirSync8,
|
|
19
|
+
mkdtempSync as mkdtempSync4,
|
|
20
|
+
readFileSync as readFileSync18,
|
|
21
21
|
readdirSync as readdirSync8,
|
|
22
22
|
readlinkSync,
|
|
23
23
|
realpathSync as realpathSync6,
|
|
24
|
-
renameSync as
|
|
25
|
-
rmSync as
|
|
26
|
-
statSync as
|
|
24
|
+
renameSync as renameSync3,
|
|
25
|
+
rmSync as rmSync8,
|
|
26
|
+
statSync as statSync3,
|
|
27
27
|
symlinkSync as symlinkSync2,
|
|
28
28
|
utimesSync,
|
|
29
|
-
writeFileSync as
|
|
29
|
+
writeFileSync as writeFileSync9
|
|
30
30
|
} from "node:fs";
|
|
31
31
|
import os5 from "node:os";
|
|
32
|
-
import
|
|
32
|
+
import path30 from "node:path";
|
|
33
33
|
import * as v5 from "valibot";
|
|
34
34
|
|
|
35
35
|
// src/admitted-mac-build.ts
|
|
@@ -2697,24 +2697,6 @@ var compilerArchives = {
|
|
|
2697
2697
|
}
|
|
2698
2698
|
}
|
|
2699
2699
|
},
|
|
2700
|
-
"swift-6.4.0-RELEASE-custom-44ecd25f163bb359": {
|
|
2701
|
-
identity: "44ecd25f163bb359",
|
|
2702
|
-
archive: "tar.zst",
|
|
2703
|
-
hosts: {
|
|
2704
|
-
"darwin-arm64": {
|
|
2705
|
-
checksum: "d06dda4435f99d8376179cc7a3804907aa7305513135ece6288fd8e6d4695ae6",
|
|
2706
|
-
manifest: "bc0d8b955f923f096dda2aa8bbb1d56176a73f3d4a4df4cc9a1f59d31417061a"
|
|
2707
|
-
},
|
|
2708
|
-
"linux-x64": {
|
|
2709
|
-
checksum: "f95b56440693c5de7995f10ea14c57fc7e659a161018a17f17a74b61a98e88a4",
|
|
2710
|
-
manifest: "c18a60b14d5c89a8b2e1dbb2b4b52342c5fb92c7f3069fdc55c985bce61683a7"
|
|
2711
|
-
},
|
|
2712
|
-
"linux-arm64": {
|
|
2713
|
-
checksum: "afb74ae60df2b5bd7792bfbcf29bcea03675a5c814b758dd6cb91a760c220cd2",
|
|
2714
|
-
manifest: "ac037f6b0fdc4a6ae582eebc22bcf811fa2becdc30d083057137fc857f3c456a"
|
|
2715
|
-
}
|
|
2716
|
-
}
|
|
2717
|
-
},
|
|
2718
2700
|
"swift-6.4.0-RELEASE-custom-11345d60dca47496": {
|
|
2719
2701
|
identity: "11345d60dca47496",
|
|
2720
2702
|
archive: "tar.zst",
|
|
@@ -2733,186 +2715,6 @@ var compilerArchives = {
|
|
|
2733
2715
|
}
|
|
2734
2716
|
}
|
|
2735
2717
|
},
|
|
2736
|
-
"swift-6.4.0-RELEASE-custom-45bb46301c86fe73": {
|
|
2737
|
-
identity: "45bb46301c86fe73",
|
|
2738
|
-
archive: "tar.gz",
|
|
2739
|
-
hosts: {
|
|
2740
|
-
"darwin-arm64": {
|
|
2741
|
-
checksum: "102dfbbb7b451be0685763b7a427284b75a8078874543f091b1c4b3db86e6565",
|
|
2742
|
-
manifest: "fb6c4d75ef6f4b3c094ae5a4d5d1e6bdfd85431f3fe25d514f3e7a0b4add60ef"
|
|
2743
|
-
},
|
|
2744
|
-
"linux-x64": {
|
|
2745
|
-
checksum: "d3c040e042e12ff787b64bfde1d85238254365036ce093f3b20ff86e8ff996f0",
|
|
2746
|
-
manifest: "7c7144be591692e563396fe3c987c5aa56fbaea4faacaad62283c0c6e5c04ae2"
|
|
2747
|
-
},
|
|
2748
|
-
"linux-arm64": {
|
|
2749
|
-
checksum: "604e6fc5fc0f5a93cee3ca6dfa9616244a2a49ef517caa3155a12ae4a0ecf72b",
|
|
2750
|
-
manifest: "075fd53d03ecf099954f1d023bb4bb67a5c5ee946537466d6c105022bdf8ecde"
|
|
2751
|
-
}
|
|
2752
|
-
}
|
|
2753
|
-
},
|
|
2754
|
-
"swift-6.4.0-RELEASE-custom-0b2d0a9011c88e66": {
|
|
2755
|
-
identity: "0b2d0a9011c88e66",
|
|
2756
|
-
archive: "tar.gz",
|
|
2757
|
-
hosts: {
|
|
2758
|
-
"darwin-arm64": {
|
|
2759
|
-
checksum: "dc6a494227297ea657e8e5f7c5b4a861cb5e142bdbcfcb028ace2aeb19db90cc",
|
|
2760
|
-
manifest: "d8e9eee0fb9b847f1e9350525d6c68606df46101745f553332309ed026b3c26a"
|
|
2761
|
-
},
|
|
2762
|
-
"linux-x64": {
|
|
2763
|
-
checksum: "85c04b4496aea1657c21a47f448e01d6ccc1c7920d130a566db37fb8350a7be2",
|
|
2764
|
-
manifest: "8451659e74235ad53b700c1afbe293512197900eb98cb1f79e36df2f5c85d511"
|
|
2765
|
-
},
|
|
2766
|
-
"linux-arm64": {
|
|
2767
|
-
checksum: "196606ed62c5c926d18e6ef0769cb1ab21c9943f9084070ddf14a7bc696768b8",
|
|
2768
|
-
manifest: "85fb8d5b6527bd75003a6dbd25b68b22540665cf9df9b13f41f82e5d8acdbf1d"
|
|
2769
|
-
}
|
|
2770
|
-
}
|
|
2771
|
-
},
|
|
2772
|
-
"swift-6.4.0-RELEASE-custom-f7c03c3f59ec5d83": {
|
|
2773
|
-
identity: "f7c03c3f59ec5d83",
|
|
2774
|
-
archive: "tar.gz",
|
|
2775
|
-
hosts: {
|
|
2776
|
-
"darwin-arm64": {
|
|
2777
|
-
checksum: "8946a2d4716d3b0784cef7a85a35f66537bd319c4c5a48c63457d607260df5c5",
|
|
2778
|
-
manifest: "2a7754e6e365bf71ae6b6aefbbd810123795c73d43fb902a8a972d009d72790f"
|
|
2779
|
-
},
|
|
2780
|
-
"linux-x64": {
|
|
2781
|
-
checksum: "5ffa3b54d54583c1d6a38b708693072db4d088ba4bf5966b17014c068b2db641",
|
|
2782
|
-
manifest: "1b23ea52c5570de4697481a54bd0b0a0bcd6b54feccb7b0bb940d3643dec82cb"
|
|
2783
|
-
},
|
|
2784
|
-
"linux-arm64": {
|
|
2785
|
-
checksum: "29b0b97b7b0db4475dbe55f7011e57f493fed9f3482a6705becebd8b68c90bab",
|
|
2786
|
-
manifest: "3fdab1132715f5899de1bb1d7ddcd52cf540295ab86586c72f49502f37a403a1"
|
|
2787
|
-
}
|
|
2788
|
-
}
|
|
2789
|
-
},
|
|
2790
|
-
"swift-6.4.0-RELEASE-custom-3e3dca8fd1d82975": {
|
|
2791
|
-
identity: "3e3dca8fd1d82975",
|
|
2792
|
-
archive: "tar.gz",
|
|
2793
|
-
hosts: {
|
|
2794
|
-
"darwin-arm64": {
|
|
2795
|
-
checksum: "dfad56454f5e1e465071ff708bf485be65b438cf55d02b04d26d17d26df9f54a",
|
|
2796
|
-
manifest: "82c35e43ed81101bea500100356a555d8266e1987d5ca7605aaa4df747c38f81"
|
|
2797
|
-
},
|
|
2798
|
-
"linux-x64": {
|
|
2799
|
-
checksum: "d3f5908d097fdc1337ff979114e605bcc758052e32f9d5d760574153d58ce6db",
|
|
2800
|
-
manifest: "a03caf181177f3d68a45b5246d0f0a26d8a5fa9ff33cf44c44e6942b73363bae"
|
|
2801
|
-
},
|
|
2802
|
-
"linux-arm64": {
|
|
2803
|
-
checksum: "8fceafca152dd0692aa6bb51236fc362a4caeeef37fc22cb5ef6aa3d0d5b3df3",
|
|
2804
|
-
manifest: "3115bc496fd8e907a16992dfc5c85b3e0798d3b58ddf1d6dace63842aed8e53b"
|
|
2805
|
-
}
|
|
2806
|
-
}
|
|
2807
|
-
},
|
|
2808
|
-
"swift-6.4.0-RELEASE-custom-b082ac5437336790": {
|
|
2809
|
-
identity: "b082ac5437336790",
|
|
2810
|
-
archive: "tar.gz",
|
|
2811
|
-
hosts: {
|
|
2812
|
-
"darwin-arm64": {
|
|
2813
|
-
checksum: "85e601982321d3a6f81f05928bc9bbe7a61bc75b27ce24508e79f6b5b537254d",
|
|
2814
|
-
manifest: "c889a70c6bba48eb0e5e218a5c0077eb557082fed5c5c58d10f07a941975080e"
|
|
2815
|
-
},
|
|
2816
|
-
"linux-x64": {
|
|
2817
|
-
checksum: "54c7988622d201e4ba6c83ca75e7b28c658b39cf1ea8b95ea88807afe33aa465",
|
|
2818
|
-
manifest: "bfd725c3b07a3624bb44c8e3a1b7ddf1eddde4fc9565e23740a9cee832c94583"
|
|
2819
|
-
},
|
|
2820
|
-
"linux-arm64": {
|
|
2821
|
-
checksum: "bd729fd73dc9953306eafd87eda79462b836b3cb127c73108327d7256b15f501",
|
|
2822
|
-
manifest: "e7f8827cca0f249a5b4a4750f6324f75633b374985fa0b93e650ee8bfcabeb39"
|
|
2823
|
-
}
|
|
2824
|
-
}
|
|
2825
|
-
},
|
|
2826
|
-
"swift-6.4.0-RELEASE-custom-9cdaffdb6b37fb47": {
|
|
2827
|
-
identity: "9cdaffdb6b37fb47",
|
|
2828
|
-
archive: "tar.gz",
|
|
2829
|
-
hosts: {
|
|
2830
|
-
"darwin-arm64": {
|
|
2831
|
-
checksum: "fdd3f88cf76a8dc2083275d4253255030068a25b5ba68acbf59e0407c45677dd",
|
|
2832
|
-
manifest: "f50c68faf91f7d2a6ea5bcd4da4573a49dd00ad9f334b27d3f9ddb08b65e46cc"
|
|
2833
|
-
},
|
|
2834
|
-
"linux-x64": {
|
|
2835
|
-
checksum: "f29f9efc598b17f33d802467676ba282441a8c3c6fa67e307c4a1e6130509d73",
|
|
2836
|
-
manifest: "f907727c5a4af58ccad7ccbb043a21289d7eb37d166536a90b3c3848f95df816"
|
|
2837
|
-
},
|
|
2838
|
-
"linux-arm64": {
|
|
2839
|
-
checksum: "7d4a8a1f90dd6c86804ceb43f8b9cf680b9778d4640a2eb6da5cb333a599f23a",
|
|
2840
|
-
manifest: "a3224cd5c09a92f66cacd0395058b2c43fa103a92bb168280132bbd0febd1575"
|
|
2841
|
-
}
|
|
2842
|
-
}
|
|
2843
|
-
},
|
|
2844
|
-
"swift-6.4.0-RELEASE-custom-bd49e2f77434e7b1": {
|
|
2845
|
-
identity: "bd49e2f77434e7b1",
|
|
2846
|
-
archive: "tar.gz",
|
|
2847
|
-
hosts: {
|
|
2848
|
-
"darwin-arm64": {
|
|
2849
|
-
checksum: "e815b06394566e8125475afc8f1807f7f465318c845549c5831043cdc28eca64",
|
|
2850
|
-
manifest: "6e3ae00102c67f2f9761b1462aab63580f2ca010469300a7c4a620765573e4e0"
|
|
2851
|
-
},
|
|
2852
|
-
"linux-x64": {
|
|
2853
|
-
checksum: "9336e0b0aefaa0171799d4b5d4215c711a24c79ac9e91baa362ba100fc22534f",
|
|
2854
|
-
manifest: "3802c631f593eda1d79dc4af55a8667356eece954d2ea59b62b1f8f981fa538e"
|
|
2855
|
-
},
|
|
2856
|
-
"linux-arm64": {
|
|
2857
|
-
checksum: "851b5a756472ad53d833e8f0ab3ae55c05d3e6b49871bb982c977b7582cc117f",
|
|
2858
|
-
manifest: "4162656192a2881e5ccc763e3e66ce46646a84ff42cdf2de50bd6424ebac5e34"
|
|
2859
|
-
}
|
|
2860
|
-
}
|
|
2861
|
-
},
|
|
2862
|
-
"swift-6.4.0-RELEASE-custom-13450179a7e01c81": {
|
|
2863
|
-
identity: "13450179a7e01c81",
|
|
2864
|
-
archive: "tar.gz",
|
|
2865
|
-
hosts: {
|
|
2866
|
-
"darwin-arm64": {
|
|
2867
|
-
checksum: "a29be6b722f15c7aafac26ba5703a7392f49ce7ea5e1c56548846b7e458290f7",
|
|
2868
|
-
manifest: "9d89bc39d80d13c8bdb93ad5c306bb87e83bac34090f9bcec57476fd90a6a115"
|
|
2869
|
-
},
|
|
2870
|
-
"linux-x64": {
|
|
2871
|
-
checksum: "b9e9e3ed855f6a8c85f5fe24016b83792a0088e2d0ea632482426c4dc6031b98",
|
|
2872
|
-
manifest: "5de3bb6bf131e68862539195fbb4fce9d4de2b528fa882495b27fd4bdd02e5ab"
|
|
2873
|
-
},
|
|
2874
|
-
"linux-arm64": {
|
|
2875
|
-
checksum: "844f5ead2854d4ac2d1fc9fb13c366450a2ed4b8fa641719822d74f9150575b4",
|
|
2876
|
-
manifest: "1fcfb353679186a3e631b83085e5e8c3dde8cb32d25052b3c8b7896339a4378b"
|
|
2877
|
-
}
|
|
2878
|
-
}
|
|
2879
|
-
},
|
|
2880
|
-
"swift-6.4.0-RELEASE-custom-f6868fa6054e83d6": {
|
|
2881
|
-
identity: "f6868fa6054e83d6",
|
|
2882
|
-
archive: "tar.gz",
|
|
2883
|
-
hosts: {
|
|
2884
|
-
"darwin-arm64": {
|
|
2885
|
-
checksum: "bd80c2f35864ec29883dd22001d0165821e80d78002fc12f92406c3c708694a4",
|
|
2886
|
-
manifest: "daad0da2a296084307769b59719dbe83e45755871438fad129b20421b111657b"
|
|
2887
|
-
},
|
|
2888
|
-
"linux-x64": {
|
|
2889
|
-
checksum: "39707ef599835ae2d9ce5aea026b7a96d43e51b4c4dcd2ca62d5fc11c520e871",
|
|
2890
|
-
manifest: "065405edd9b02a84ce01c09e68531834dbe190232e6387b056a481354c44fe81"
|
|
2891
|
-
},
|
|
2892
|
-
"linux-arm64": {
|
|
2893
|
-
checksum: "a91f2947d560b49b56334938d0efdcb22286557da63d65389129030b2a4e146d",
|
|
2894
|
-
manifest: "4dfbc167c96f30c7de19cc280948786fb79a888b666ca200b0788803902361ce"
|
|
2895
|
-
}
|
|
2896
|
-
}
|
|
2897
|
-
},
|
|
2898
|
-
"swift-6.4.0-RELEASE-custom-a560ff35bf882b5c": {
|
|
2899
|
-
identity: "a560ff35bf882b5c",
|
|
2900
|
-
archive: "tar.zst",
|
|
2901
|
-
hosts: {
|
|
2902
|
-
"darwin-arm64": {
|
|
2903
|
-
checksum: "36c50bcdfba88a4c0989af0bd60371497eb4403aa7b80644b479fa509a2187a9",
|
|
2904
|
-
manifest: "253e891527d2213f54eace768b902de89de5e9495a3c5f4018de1985516bd553"
|
|
2905
|
-
},
|
|
2906
|
-
"linux-x64": {
|
|
2907
|
-
checksum: "ba25da9182314fc7b7dd2fc041280e1c7b409f80a1fbccdfa5c342669d164c8e",
|
|
2908
|
-
manifest: "6f951cc4071dd0d6054d85711a7c5fe272273658847831b477a8b24be7254ca0"
|
|
2909
|
-
},
|
|
2910
|
-
"linux-arm64": {
|
|
2911
|
-
checksum: "5f0f4456e9fe22b5486025db9f679c865841660797d71761245291c2c6811c20",
|
|
2912
|
-
manifest: "b6f62fca2ec37593e274ee5bac474f21ffc5db14cd82f492ccbc774f8e9b75d8"
|
|
2913
|
-
}
|
|
2914
|
-
}
|
|
2915
|
-
},
|
|
2916
2718
|
[SWIFT_HOST_COMPILER_RELEASE]: {
|
|
2917
2719
|
identity: SWIFT_HOST_COMPILER_ID,
|
|
2918
2720
|
archive: "tar.gz",
|
|
@@ -3851,7 +3653,7 @@ function swiftManifestTargets(manifest, resourcePaths = [], readArguments) {
|
|
|
3851
3653
|
const targets = [];
|
|
3852
3654
|
const packageCall = manifestCalls(manifest, ["Package"])[0];
|
|
3853
3655
|
const platformArgument = packageCall ? splitManifestArguments(packageCall.call.slice(0, -1)).find(
|
|
3854
|
-
(
|
|
3656
|
+
(argument2) => /^platforms\s*:/.test(argument2)
|
|
3855
3657
|
) : void 0;
|
|
3856
3658
|
const platformList = /^platforms\s*:\s*\[([\s\S]*)\]$/.exec(platformArgument ?? "")?.[1];
|
|
3857
3659
|
const iosPlatforms = [
|
|
@@ -3892,7 +3694,7 @@ function swiftManifestTargets(manifest, resourcePaths = [], readArguments) {
|
|
|
3892
3694
|
);
|
|
3893
3695
|
const targetArguments = splitManifestArguments(call.slice(0, -1));
|
|
3894
3696
|
const sourceArgument = targetArguments.find(
|
|
3895
|
-
(
|
|
3697
|
+
(argument2) => /^sources\s*:/.test(argument2)
|
|
3896
3698
|
);
|
|
3897
3699
|
const sourceList = sourceArgument?.replace(/^sources\s*:\s*/, "").trim();
|
|
3898
3700
|
if (sourceList && sourceList !== "nil" && !(sourceList.startsWith("[") && sourceList.endsWith("]")))
|
|
@@ -3906,7 +3708,7 @@ function swiftManifestTargets(manifest, resourcePaths = [], readArguments) {
|
|
|
3906
3708
|
return swiftStringValue(literal2[1], `a source of target ${name2}`).replace(/^\.\//, "").replace(/\/+$/, "");
|
|
3907
3709
|
}) : void 0;
|
|
3908
3710
|
const dependencyArgument = targetArguments.find(
|
|
3909
|
-
(
|
|
3711
|
+
(argument2) => /^dependencies\s*:/.test(argument2)
|
|
3910
3712
|
);
|
|
3911
3713
|
const dependencyList = dependencyArgument?.replace(/^dependencies\s*:\s*/, "").trim();
|
|
3912
3714
|
const dependencies = [];
|
|
@@ -4317,6 +4119,7 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
|
|
|
4317
4119
|
);
|
|
4318
4120
|
const overlay = path10.join(swiftSharedSdkRoot(moduleRoot, distribution), "wasm/include");
|
|
4319
4121
|
const overlayFiles = readdirSync4(overlay, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path10.join(entry.parentPath, entry.name)).sort();
|
|
4122
|
+
const hasDarwinTcp = overlayFiles.includes(path10.join(overlay, "netinet/tcp.h"));
|
|
4320
4123
|
const key = JSON.stringify([
|
|
4321
4124
|
// bump the recipe when the transformation changes; bundling changes function text.
|
|
4322
4125
|
"v25",
|
|
@@ -4325,7 +4128,8 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
|
|
|
4325
4128
|
sdk,
|
|
4326
4129
|
frameworks,
|
|
4327
4130
|
overlayFiles,
|
|
4328
|
-
swiftSdkOptions()
|
|
4131
|
+
swiftSdkOptions(),
|
|
4132
|
+
...hasDarwinTcp ? ["darwin-tcp-module"] : []
|
|
4329
4133
|
]);
|
|
4330
4134
|
const cached = sdkViews.get(key);
|
|
4331
4135
|
if (cached && fs4.existsSync(cached.manifest)) return touchSdkView(cached.options);
|
|
@@ -4425,6 +4229,22 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
|
|
|
4425
4229
|
fs4.mkdirSync(path10.dirname(destination), { recursive: true });
|
|
4426
4230
|
fs4.symlinkSync(shared, destination);
|
|
4427
4231
|
}
|
|
4232
|
+
if (hasDarwinTcp) {
|
|
4233
|
+
const moduleMap = path10.join(
|
|
4234
|
+
staging,
|
|
4235
|
+
path10.relative(realRoot, sysroot),
|
|
4236
|
+
"darwin/wasm/include/module.modulemap"
|
|
4237
|
+
);
|
|
4238
|
+
const original = fs4.readFileSync(moduleMap, "utf8");
|
|
4239
|
+
const updated = original.replace(
|
|
4240
|
+
'"../../../include/wasm64-wasip1/netinet/tcp.h"',
|
|
4241
|
+
'"netinet/tcp.h"'
|
|
4242
|
+
);
|
|
4243
|
+
if (updated !== original) {
|
|
4244
|
+
fs4.unlinkSync(moduleMap);
|
|
4245
|
+
fs4.writeFileSync(moduleMap, updated);
|
|
4246
|
+
}
|
|
4247
|
+
}
|
|
4428
4248
|
const foundationArchive = path10.join(
|
|
4429
4249
|
path10.dirname(sysroot),
|
|
4430
4250
|
"swift.xctoolchain/usr/lib/swift_static/wasi/libFoundation.a"
|
|
@@ -4865,9 +4685,9 @@ var EXCERPT = /^(\s*)(\d+)( \| )(.*)$/;
|
|
|
4865
4685
|
var MARKER = /^(\s*)( \| )(.*)$/;
|
|
4866
4686
|
function designTimeDiagnostic(output, files) {
|
|
4867
4687
|
const rewritten = /* @__PURE__ */ new Map();
|
|
4868
|
-
const linesOf = (
|
|
4688
|
+
const linesOf = (path31) => {
|
|
4869
4689
|
const file = Object.keys(files).find(
|
|
4870
|
-
(name2) => name2.endsWith(".swift") && (
|
|
4690
|
+
(name2) => name2.endsWith(".swift") && (path31 === name2 || path31.endsWith(`/${name2}`))
|
|
4871
4691
|
);
|
|
4872
4692
|
if (file === void 0) return null;
|
|
4873
4693
|
let lines = rewritten.get(file);
|
|
@@ -9501,7 +9321,7 @@ function linkGuestImages(options) {
|
|
|
9501
9321
|
const trace = path16.join(directory, `${name2}-inputs.txt`);
|
|
9502
9322
|
fs6.writeFileSync(
|
|
9503
9323
|
response,
|
|
9504
|
-
[...arguments_, "--trace"].map((
|
|
9324
|
+
[...arguments_, "--trace"].map((argument2) => JSON.stringify(argument2)).join(" ")
|
|
9505
9325
|
);
|
|
9506
9326
|
const output = fs6.openSync(trace, "w");
|
|
9507
9327
|
try {
|
|
@@ -10379,7 +10199,7 @@ function sourceGuestClangLinkOptions(options) {
|
|
|
10379
10199
|
const command = commands.get(file);
|
|
10380
10200
|
if (!command) throw new Error(`missing source object producer ${file}`);
|
|
10381
10201
|
if (command.tool === "shell") {
|
|
10382
|
-
if (!command.args.length || realpathSync2(command.args[0]) !== realpathSync2(
|
|
10202
|
+
if (!command.args.length || realpathSync2(command.args[0]) !== realpathSync2(options.swiftCompiler))
|
|
10383
10203
|
throw new Error(`unsupported source object producer ${file}`);
|
|
10384
10204
|
continue;
|
|
10385
10205
|
}
|
|
@@ -10922,6 +10742,29 @@ async function runExtractor(command, args, signal, input) {
|
|
|
10922
10742
|
}
|
|
10923
10743
|
}
|
|
10924
10744
|
|
|
10745
|
+
// src/binaryen.lock.json
|
|
10746
|
+
var binaryen_lock_default = {
|
|
10747
|
+
version: "132",
|
|
10748
|
+
licenseSha256: "64c0d02491e16eced74826440ecd2bcf7722d37fa586faf457b2494293afbffe",
|
|
10749
|
+
platforms: {
|
|
10750
|
+
"linux-x64": {
|
|
10751
|
+
asset: "x86_64-linux",
|
|
10752
|
+
upstreamSha256: "195ddc94f9bc89f45abdabb0b9eea86023d727ba90eac8b35b80f2544fc30572",
|
|
10753
|
+
sha256: "0396b1a540e9f97f30eb6a378d829305c218c821a0bd88c74e83d3d6923dad0b"
|
|
10754
|
+
},
|
|
10755
|
+
"linux-arm64": {
|
|
10756
|
+
asset: "aarch64-linux",
|
|
10757
|
+
upstreamSha256: "c58562417836c5d0493d89bdefc434933bdc097db641b483df86bcfa557a107f",
|
|
10758
|
+
sha256: "25e3747f19614b0281a28b9a909ddc602b546ccdfacebc8cae2f7165665328fa"
|
|
10759
|
+
},
|
|
10760
|
+
"darwin-arm64": {
|
|
10761
|
+
asset: "arm64-macos",
|
|
10762
|
+
upstreamSha256: "98aad827847af7ef990ed7098d885725c8e5b5aae75073403635617ae4e259aa",
|
|
10763
|
+
sha256: "34281566fe32df71337aaf0b60aa265dc853587d92bda0b5b1fac8aed8c2f8ab"
|
|
10764
|
+
}
|
|
10765
|
+
}
|
|
10766
|
+
};
|
|
10767
|
+
|
|
10925
10768
|
// src/home-paths.ts
|
|
10926
10769
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
10927
10770
|
import fs9 from "node:fs";
|
|
@@ -11188,32 +11031,10 @@ var FEATURES = [
|
|
|
11188
11031
|
];
|
|
11189
11032
|
var KEEP_WASM_NAMES = process.env.PEACH_SWIFT_NAMES === "1";
|
|
11190
11033
|
var LOWERING = ["--memory64-lowering", "--table64-lowering"];
|
|
11191
|
-
var BINARYEN_VERSION =
|
|
11034
|
+
var BINARYEN_VERSION = binaryen_lock_default.version;
|
|
11192
11035
|
var runBinaryen = promisify2(execFile2);
|
|
11193
11036
|
var WASM_LOWER_IDENTITY = `binaryen ${BINARYEN_VERSION} narrow ${LOWERING.join(" ")} ${FEATURES.join(",")} unoptimized-names`;
|
|
11194
|
-
var BINARYEN_RELEASES =
|
|
11195
|
-
[
|
|
11196
|
-
"linux-x64",
|
|
11197
|
-
{
|
|
11198
|
-
asset: "x86_64-linux",
|
|
11199
|
-
sha256: "195ddc94f9bc89f45abdabb0b9eea86023d727ba90eac8b35b80f2544fc30572"
|
|
11200
|
-
}
|
|
11201
|
-
],
|
|
11202
|
-
[
|
|
11203
|
-
"linux-arm64",
|
|
11204
|
-
{
|
|
11205
|
-
asset: "aarch64-linux",
|
|
11206
|
-
sha256: "c58562417836c5d0493d89bdefc434933bdc097db641b483df86bcfa557a107f"
|
|
11207
|
-
}
|
|
11208
|
-
],
|
|
11209
|
-
[
|
|
11210
|
-
"darwin-arm64",
|
|
11211
|
-
{
|
|
11212
|
-
asset: "arm64-macos",
|
|
11213
|
-
sha256: "98aad827847af7ef990ed7098d885725c8e5b5aae75073403635617ae4e259aa"
|
|
11214
|
-
}
|
|
11215
|
-
]
|
|
11216
|
-
]);
|
|
11037
|
+
var BINARYEN_RELEASES = new Map(Object.entries(binaryen_lock_default.platforms));
|
|
11217
11038
|
async function runWasmOpt(file, output, optimize, skipPasses, binary) {
|
|
11218
11039
|
const admittedCores = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
|
|
11219
11040
|
const requestedCores = Number(process.env.BINARYEN_CORES);
|
|
@@ -11276,11 +11097,10 @@ async function installWasmOpt() {
|
|
|
11276
11097
|
const binary = join2(destDir, "bin", "wasm-opt");
|
|
11277
11098
|
if (!existsSync2(binary))
|
|
11278
11099
|
await installVerifiedTarball({
|
|
11279
|
-
url: `https://
|
|
11100
|
+
url: `https://r2.rnxsim.com/peach/binaryen/${release.sha256}/${platform}.tar.gz`,
|
|
11280
11101
|
digest: { algorithm: "sha256", encoding: "hex", value: release.sha256 },
|
|
11281
11102
|
destDir,
|
|
11282
11103
|
installedMarker: "bin/wasm-opt",
|
|
11283
|
-
stripComponents: 1,
|
|
11284
11104
|
label: `Binaryen ${BINARYEN_VERSION}`
|
|
11285
11105
|
});
|
|
11286
11106
|
return binary;
|
|
@@ -11481,6 +11301,7 @@ async function compileGuestLink(options) {
|
|
|
11481
11301
|
buildDirectory: options.buildDirectory,
|
|
11482
11302
|
directory,
|
|
11483
11303
|
toolchainBin: options.toolchainBin,
|
|
11304
|
+
swiftCompiler: options.swiftCompiler,
|
|
11484
11305
|
objects: selectedSource.map((artifact) => artifact.path)
|
|
11485
11306
|
});
|
|
11486
11307
|
const links = sourceGuestRuntimeLinks({
|
|
@@ -11673,93 +11494,562 @@ async function compileGuestLink(options) {
|
|
|
11673
11494
|
writeFileSync6(options.optimized, finalized.wasm);
|
|
11674
11495
|
}
|
|
11675
11496
|
|
|
11676
|
-
// src/swift-
|
|
11677
|
-
import {
|
|
11678
|
-
import { createHash as createHash12, randomUUID as randomUUID3 } from "node:crypto";
|
|
11679
|
-
import { existsSync as existsSync3, readFileSync as readFileSync14 } from "node:fs";
|
|
11680
|
-
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
11681
|
-
import os3 from "node:os";
|
|
11682
|
-
import path22 from "node:path";
|
|
11683
|
-
import { promisify as promisify3 } from "node:util";
|
|
11497
|
+
// src/swift-header-compiler.ts
|
|
11498
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
11684
11499
|
import {
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11500
|
+
chmodSync,
|
|
11501
|
+
existsSync as existsSync3,
|
|
11502
|
+
mkdirSync as mkdirSync5,
|
|
11503
|
+
mkdtempSync as mkdtempSync3,
|
|
11504
|
+
readFileSync as readFileSync14,
|
|
11505
|
+
renameSync as renameSync2,
|
|
11506
|
+
rmSync as rmSync5,
|
|
11507
|
+
statSync,
|
|
11508
|
+
writeFileSync as writeFileSync7
|
|
11509
|
+
} from "node:fs";
|
|
11510
|
+
import { createServer } from "node:http";
|
|
11511
|
+
import path22 from "node:path";
|
|
11691
11512
|
|
|
11692
|
-
//
|
|
11693
|
-
var
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
var
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
const
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
11708
|
-
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
const
|
|
11735
|
-
|
|
11513
|
+
// src/forked-script-contract.ts
|
|
11514
|
+
var PEACH_FORKED_SCRIPT_ENV = "PEACH_RUNS_FORKED_SCRIPTS";
|
|
11515
|
+
|
|
11516
|
+
// src/swift-header-compiler.ts
|
|
11517
|
+
var SWIFT_HEADER_COMPILER_WRAPPER = ".build/peach-swiftc";
|
|
11518
|
+
var argument = (value) => `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
11519
|
+
var client = `const { request } = require('node:http')
|
|
11520
|
+
const { spawnSync } = require('node:child_process')
|
|
11521
|
+
const { existsSync } = require('node:fs')
|
|
11522
|
+
const [socketPath, moduleName, swiftc, receipt, ...args] = process.argv.slice(2)
|
|
11523
|
+
const body = JSON.stringify(args)
|
|
11524
|
+
const notify = (method) => new Promise((resolve, reject) => {
|
|
11525
|
+
const req = request({ socketPath, path: '/' + moduleName, method }, response => {
|
|
11526
|
+
let message = ''
|
|
11527
|
+
response.setEncoding('utf8').on('data', data => { message += data })
|
|
11528
|
+
response.on('end', () => {
|
|
11529
|
+
if (response.statusCode === 200 || response.statusCode === 204) resolve(response.statusCode === 200)
|
|
11530
|
+
else reject(new Error(message))
|
|
11531
|
+
})
|
|
11532
|
+
response.on('error', reject)
|
|
11533
|
+
})
|
|
11534
|
+
req.on('error', reject)
|
|
11535
|
+
req.end(body)
|
|
11536
|
+
})
|
|
11537
|
+
async function compile() {
|
|
11538
|
+
if (existsSync(receipt) && await notify('PUT')) return
|
|
11539
|
+
const result = spawnSync(swiftc, args, { stdio: 'inherit' })
|
|
11540
|
+
if (result.error) throw result.error
|
|
11541
|
+
if (result.status !== 0) { process.exitCode = result.status ?? 1; return }
|
|
11542
|
+
await notify('POST')
|
|
11543
|
+
}
|
|
11544
|
+
compile().catch(error => {
|
|
11545
|
+
process.stderr.write(String(error) + '\\n')
|
|
11546
|
+
process.exitCode = 1
|
|
11547
|
+
})
|
|
11548
|
+
`;
|
|
11549
|
+
function compilerCheckpoint(root, recipe, args, header) {
|
|
11550
|
+
const value = (flag) => {
|
|
11551
|
+
const index = args.lastIndexOf(flag);
|
|
11552
|
+
return index < 0 ? void 0 : args[index + 1];
|
|
11553
|
+
};
|
|
11554
|
+
const outputMap = value("-output-file-map");
|
|
11555
|
+
const module = value("-emit-module-path");
|
|
11556
|
+
if (!outputMap || !module || !args.includes("-whole-module-optimization")) return;
|
|
11557
|
+
const mapText = readFileSync14(outputMap, "utf8");
|
|
11558
|
+
const map = JSON.parse(mapText);
|
|
11559
|
+
if (!isRecord(map) || !isRecord(map[""]) || typeof map[""].dependencies !== "string")
|
|
11560
|
+
return;
|
|
11561
|
+
const objects = [];
|
|
11562
|
+
for (const [source, outputs2] of Object.entries(map)) {
|
|
11563
|
+
if (!source) continue;
|
|
11564
|
+
if (!isRecord(outputs2) || typeof outputs2.object !== "string") return;
|
|
11565
|
+
objects.push(outputs2.object);
|
|
11566
|
+
}
|
|
11567
|
+
if (!objects.length) return;
|
|
11568
|
+
const outputs = [module, header, map[""].dependencies, ...objects];
|
|
11569
|
+
const digest = createHash12("sha256").update(recipe).update(JSON.stringify(args)).update(mapText);
|
|
11570
|
+
for (const flag of args) {
|
|
11571
|
+
if (!flag.startsWith("@")) continue;
|
|
11572
|
+
const response = flag.slice(1);
|
|
11573
|
+
if (!path22.isAbsolute(response) || !existsSync3(response)) return;
|
|
11574
|
+
digest.update(readFileSync14(response));
|
|
11575
|
+
}
|
|
11576
|
+
for (const file of outputs) {
|
|
11577
|
+
if (!file.startsWith(path22.join(root, ".build") + path22.sep)) return;
|
|
11578
|
+
const stat = statSync(file, { bigint: true, throwIfNoEntry: false });
|
|
11579
|
+
if (!stat?.isFile() || stat.size === 0n) return;
|
|
11580
|
+
digest.update(JSON.stringify([file, String(stat.size), String(stat.mtimeNs)]));
|
|
11581
|
+
}
|
|
11582
|
+
return digest.digest("hex");
|
|
11583
|
+
}
|
|
11584
|
+
async function withSwiftHeaderCompiler(root, toolchainBin, recipe, producers, build) {
|
|
11585
|
+
const wrapper = path22.join(root, SWIFT_HEADER_COMPILER_WRAPPER);
|
|
11586
|
+
const script = path22.join(root, ".build", "peach-swift-header.cjs");
|
|
11587
|
+
const checkpoints = path22.join(root, ".build", "peach-swift-header-checkpoints");
|
|
11588
|
+
mkdirSync5(checkpoints, { recursive: true });
|
|
11589
|
+
const swiftc = argument(path22.join(toolchainBin, "swiftc"));
|
|
11590
|
+
writeBuildFile(script, client);
|
|
11591
|
+
writeBuildFile(
|
|
11592
|
+
wrapper,
|
|
11593
|
+
[
|
|
11594
|
+
"#!/bin/sh",
|
|
11595
|
+
"module=; compile=; previous=",
|
|
11596
|
+
'for flag in "$@"; do',
|
|
11597
|
+
' if [ "$previous" = -module-name ]; then module=$flag; fi',
|
|
11598
|
+
' if [ "$flag" = -c ]; then compile=1; fi',
|
|
11599
|
+
" previous=$flag",
|
|
11600
|
+
"done",
|
|
11601
|
+
'case "$compile:$module" in',
|
|
11602
|
+
` ${[...producers.keys()].map((name2) => argument(`1:${name2}`)).join("|")})`,
|
|
11603
|
+
` ${PEACH_FORKED_SCRIPT_ENV}=1 exec ${argument(process.execPath)} ${argument(script)} "$PEACH_SWIFT_HEADER_SOCKET" "$module" ${swiftc} ${argument(checkpoints)}/"$module" "$@" ;;`,
|
|
11604
|
+
"esac",
|
|
11605
|
+
`exec ${swiftc} "$@"`,
|
|
11606
|
+
""
|
|
11607
|
+
].join("\n")
|
|
11736
11608
|
);
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11609
|
+
chmodSync(wrapper, 493);
|
|
11610
|
+
const directory = mkdtempSync3("/tmp/peach-headers-");
|
|
11611
|
+
const socket = path22.join(directory, "compile");
|
|
11612
|
+
const server = createServer(async (request, response) => {
|
|
11613
|
+
const module = request.url?.slice(1) ?? "";
|
|
11614
|
+
const producer = producers.get(module);
|
|
11615
|
+
if (!producer) {
|
|
11616
|
+
response.writeHead(404).end("unknown Swift header producer");
|
|
11617
|
+
return;
|
|
11618
|
+
}
|
|
11619
|
+
try {
|
|
11620
|
+
const chunks = [];
|
|
11621
|
+
for await (const chunk of request) chunks.push(chunk);
|
|
11622
|
+
const args = JSON.parse(Buffer.concat(chunks).toString());
|
|
11623
|
+
if (!Array.isArray(args) || !args.every((arg) => typeof arg === "string"))
|
|
11624
|
+
throw new Error("invalid Swift compiler arguments");
|
|
11625
|
+
const receipt = path22.join(checkpoints, module);
|
|
11626
|
+
const fingerprint = compilerCheckpoint(root, recipe, args, producer.header);
|
|
11627
|
+
if (request.method === "PUT") {
|
|
11628
|
+
if (!fingerprint || !existsSync3(receipt) || readFileSync14(receipt, "utf8") !== fingerprint) {
|
|
11629
|
+
response.writeHead(204).end();
|
|
11630
|
+
return;
|
|
11631
|
+
}
|
|
11632
|
+
producer.publish();
|
|
11633
|
+
response.end();
|
|
11634
|
+
return;
|
|
11635
|
+
}
|
|
11636
|
+
if (request.method !== "POST")
|
|
11637
|
+
throw new Error("invalid Swift compiler checkpoint method");
|
|
11638
|
+
producer.publish();
|
|
11639
|
+
if (fingerprint) {
|
|
11640
|
+
writeFileSync7(`${receipt}.partial`, fingerprint);
|
|
11641
|
+
renameSync2(`${receipt}.partial`, receipt);
|
|
11642
|
+
}
|
|
11643
|
+
response.end();
|
|
11644
|
+
} catch (error) {
|
|
11645
|
+
response.writeHead(500).end(String(error));
|
|
11646
|
+
}
|
|
11647
|
+
});
|
|
11648
|
+
try {
|
|
11649
|
+
await new Promise((resolve, reject) => {
|
|
11650
|
+
server.once("error", reject);
|
|
11651
|
+
server.listen(socket, resolve);
|
|
11652
|
+
});
|
|
11653
|
+
return await build({ SWIFT_EXEC: wrapper, PEACH_SWIFT_HEADER_SOCKET: socket });
|
|
11654
|
+
} finally {
|
|
11655
|
+
server.close();
|
|
11656
|
+
server.closeAllConnections();
|
|
11657
|
+
rmSync5(directory, { recursive: true, force: true });
|
|
11742
11658
|
}
|
|
11743
|
-
return packed;
|
|
11744
11659
|
}
|
|
11745
11660
|
|
|
11746
|
-
// src/swift-
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
const
|
|
11758
|
-
|
|
11759
|
-
|
|
11661
|
+
// src/swift-header-dependencies.ts
|
|
11662
|
+
import path23 from "node:path";
|
|
11663
|
+
|
|
11664
|
+
// src/swiftContract.ts
|
|
11665
|
+
function isSwiftSourceLinkGraph(value) {
|
|
11666
|
+
if (!value || typeof value !== "object") return false;
|
|
11667
|
+
const text2 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
|
|
11668
|
+
const entry = Reflect.get(value, "entry");
|
|
11669
|
+
const targets = Reflect.get(value, "targets");
|
|
11670
|
+
if (!text2(entry) || !Array.isArray(targets) || targets.length > 1024) return false;
|
|
11671
|
+
const ids = /* @__PURE__ */ new Set();
|
|
11672
|
+
for (const target of targets) {
|
|
11673
|
+
if (!target || typeof target !== "object") return false;
|
|
11674
|
+
const id = Reflect.get(target, "id");
|
|
11675
|
+
const source = Reflect.get(target, "sourceTarget");
|
|
11676
|
+
const flags = Reflect.get(target, "linkerFlags");
|
|
11677
|
+
const dependencies = Reflect.get(target, "dependencies");
|
|
11678
|
+
const build = Reflect.get(target, "buildVersion");
|
|
11679
|
+
const nullableText = (value2) => value2 === null || text2(value2);
|
|
11680
|
+
if (!text2(id) || ids.has(id) || !(source === null || text2(source)) || !text2(Reflect.get(target, "productName")) || !text2(Reflect.get(target, "productType")) || !nullableText(Reflect.get(target, "installName")) || !build || typeof build !== "object" || !["platform", "minimumOS", "sdk"].every(
|
|
11681
|
+
(key) => nullableText(Reflect.get(build, key))
|
|
11682
|
+
) || !(Reflect.get(target, "machOType") === null || text2(Reflect.get(target, "machOType"))) || !Array.isArray(flags) || !flags.every(text2) || !Array.isArray(dependencies) || !dependencies.every(
|
|
11683
|
+
(link) => link && typeof link === "object" && text2(Reflect.get(link, "target")) && Array.isArray(Reflect.get(link, "attributes")) && Reflect.get(link, "attributes").every(text2)
|
|
11684
|
+
))
|
|
11685
|
+
return false;
|
|
11686
|
+
ids.add(id);
|
|
11687
|
+
}
|
|
11688
|
+
return ids.has(entry) && targets.every(
|
|
11689
|
+
(target) => Reflect.get(target, "dependencies").every(
|
|
11690
|
+
(link) => ids.has(link.target)
|
|
11691
|
+
)
|
|
11692
|
+
);
|
|
11693
|
+
}
|
|
11694
|
+
var SWIFT_REMOTE_PACKAGES_DIR = "__packages__";
|
|
11695
|
+
var SWIFT_LOCAL_PACKAGES_DIR = "__local_packages__";
|
|
11696
|
+
var SWIFT_XCODE_BUILD_CONDITION = "__PEACH_XCODE_BUILD";
|
|
11697
|
+
function isBase64Bytes(value) {
|
|
11698
|
+
return value.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}(?![\s\S])/.test(value);
|
|
11699
|
+
}
|
|
11700
|
+
function isSwiftPackageFiles(value) {
|
|
11701
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
11702
|
+
([file, bytes]) => isSwiftResourcePath(file) && (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`)) && typeof bytes === "string" && isBase64Bytes(bytes)
|
|
11703
|
+
);
|
|
11704
|
+
}
|
|
11705
|
+
function swiftProjectFileProblem(file) {
|
|
11706
|
+
if (!isSwiftResourcePath(file)) return "not a relative path of plain segments";
|
|
11707
|
+
if (file === "Package.swift") return "would replace the generated manifest";
|
|
11708
|
+
if (file.split("/").includes(".build")) return "is build output (.build)";
|
|
11709
|
+
if (file.startsWith(".")) return 'starts with "." (hidden file or peach output)';
|
|
11710
|
+
if (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`))
|
|
11711
|
+
return "collides with a transported package checkout";
|
|
11712
|
+
return void 0;
|
|
11713
|
+
}
|
|
11714
|
+
function swiftProjectEntryProblem(file, bytes) {
|
|
11715
|
+
return swiftProjectFileProblem(file) ?? (typeof bytes === "string" && isBase64Bytes(bytes) ? void 0 : "bytes are not base64");
|
|
11716
|
+
}
|
|
11717
|
+
function isSwiftProjectFiles(value) {
|
|
11718
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
11719
|
+
([file, bytes]) => swiftProjectEntryProblem(file, bytes) === void 0
|
|
11720
|
+
);
|
|
11721
|
+
}
|
|
11722
|
+
function swiftProjectFilesProblems(value) {
|
|
11723
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
11724
|
+
return ["projectFiles is not an object"];
|
|
11725
|
+
return Object.entries(value).flatMap(([file, bytes]) => {
|
|
11726
|
+
const problem = swiftProjectEntryProblem(file, bytes);
|
|
11727
|
+
return problem ? [`${file}: ${problem}`] : [];
|
|
11728
|
+
});
|
|
11729
|
+
}
|
|
11730
|
+
var SWIFT_NATIVE_INPUT_ROOT = "$(PEACH_INPUT_ROOT)";
|
|
11731
|
+
var SWIFT_NATIVE_SDK_INCLUDE = "$(PEACH_SDK_INCLUDE)";
|
|
11732
|
+
function isSwiftHeaderAliases(value) {
|
|
11733
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
11734
|
+
([alias, file]) => isSwiftResourcePath(alias) && isSwiftResourcePath(file)
|
|
11735
|
+
);
|
|
11736
|
+
}
|
|
11737
|
+
function isSwiftNativeTargets(value) {
|
|
11738
|
+
return swiftNativeTargetsRefusal(value) === null;
|
|
11739
|
+
}
|
|
11740
|
+
function swiftNativeTargetsRefusal(value) {
|
|
11741
|
+
const strings = (value2) => Array.isArray(value2) && value2.every((item) => typeof item === "string" && !item.includes("\0"));
|
|
11742
|
+
const paths = (value2) => strings(value2) && value2.every(isSwiftResourcePath);
|
|
11743
|
+
if (!Array.isArray(value)) return "nativeTargets";
|
|
11744
|
+
if (value.length > 128) return "nativeTargets:length";
|
|
11745
|
+
for (const target of value) {
|
|
11746
|
+
if (!target || typeof target !== "object") return "nativeTargets:shape";
|
|
11747
|
+
const field = (name3) => Reflect.get(target, name3);
|
|
11748
|
+
const name2 = typeof field("name") === "string" ? String(field("name")) : "?";
|
|
11749
|
+
const at = (shape) => `nativeTargets:${name2}:${shape}`;
|
|
11750
|
+
const nullablePath = (key) => field(key) === null || isSwiftResourcePath(field(key));
|
|
11751
|
+
const perFile = field("fileFlags");
|
|
11752
|
+
const directories = field("sourceDirectories");
|
|
11753
|
+
const searches = field("headerSearchPaths");
|
|
11754
|
+
const userSearches = field("userHeaderSearchPaths");
|
|
11755
|
+
const frameworks = field("frameworkSearchPaths");
|
|
11756
|
+
const maps = field("headerMaps");
|
|
11757
|
+
const products = field("productHeaders");
|
|
11758
|
+
const inputPath = (value2) => typeof value2 === "string" && value2.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) && isSwiftResourcePath(value2.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1));
|
|
11759
|
+
const deployment = field("deploymentTarget");
|
|
11760
|
+
const targetName = field("name");
|
|
11761
|
+
if (typeof targetName !== "string" || targetName.length === 0 || targetName.length > 4096 || targetName.includes("\0") || targetName.includes("/") || targetName.includes("\\") || targetName === "." || targetName === "..")
|
|
11762
|
+
return at("name");
|
|
11763
|
+
if (!(deployment === null || typeof deployment === "string" && /^\d+(?:\.\d+){0,2}$/.test(deployment)))
|
|
11764
|
+
return at("deploymentTarget");
|
|
11765
|
+
if (!paths(field("headers"))) return at("headers");
|
|
11766
|
+
if (!paths(field("publicHeaders"))) return at("publicHeaders");
|
|
11767
|
+
if (typeof field("flattensPublicHeaders") !== "boolean")
|
|
11768
|
+
return at("flattensPublicHeaders");
|
|
11769
|
+
if (!nullablePath("bridgingHeader")) return at("bridgingHeader");
|
|
11770
|
+
if (!nullablePath("prefixHeader")) return at("prefixHeader");
|
|
11771
|
+
if (!strings(searches) || !searches.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
11772
|
+
return at("headerSearchPaths");
|
|
11773
|
+
const moduleMaps = field("moduleMaps");
|
|
11774
|
+
if (moduleMaps !== void 0 && (!Array.isArray(moduleMaps) || moduleMaps.length > 128 || !moduleMaps.every((map) => {
|
|
11775
|
+
if (!map || typeof map !== "object") return false;
|
|
11776
|
+
const module = Reflect.get(map, "module");
|
|
11777
|
+
const headers = Reflect.get(map, "headers");
|
|
11778
|
+
return typeof module === "string" && module.length > 0 && module.length <= 4096 && !module.includes("\0") && (headers === "." || isSwiftResourcePath(headers));
|
|
11779
|
+
})))
|
|
11780
|
+
return at("moduleMaps");
|
|
11781
|
+
if (!strings(userSearches) || !userSearches.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
11782
|
+
return at("userHeaderSearchPaths");
|
|
11783
|
+
if (!strings(frameworks) || !frameworks.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
11784
|
+
return at("frameworkSearchPaths");
|
|
11785
|
+
if (!Array.isArray(maps) || !maps.every((map) => {
|
|
11786
|
+
if (!map || typeof map !== "object") return false;
|
|
11787
|
+
const flag = Reflect.get(map, "flag");
|
|
11788
|
+
const entries = Reflect.get(map, "entries");
|
|
11789
|
+
return (flag === "-I" || flag === "-iquote") && Array.isArray(entries) && entries.every(
|
|
11790
|
+
(entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && !entry[0].includes("\0") && (inputPath(entry[1]) || isSwiftResourcePath(entry[1]))
|
|
11791
|
+
);
|
|
11792
|
+
}))
|
|
11793
|
+
return at("headerMaps");
|
|
11794
|
+
if (!products || typeof products !== "object" || Array.isArray(products) || !Object.entries(products).every(
|
|
11795
|
+
([product, file]) => isSwiftResourcePath(product) && isSwiftResourcePath(file)
|
|
11796
|
+
))
|
|
11797
|
+
return at("productHeaders");
|
|
11798
|
+
if (!strings(field("flags"))) return at("flags");
|
|
11799
|
+
if (!strings(field("importerFlags"))) return at("importerFlags");
|
|
11800
|
+
if (!strings(field("cxxFlags"))) return at("cxxFlags");
|
|
11801
|
+
if (!perFile || typeof perFile !== "object" || Array.isArray(perFile) || !Object.entries(perFile).every(
|
|
11802
|
+
([file, flags]) => isSwiftResourcePath(file) && strings(flags)
|
|
11803
|
+
))
|
|
11804
|
+
return at("fileFlags");
|
|
11805
|
+
if (!directories || typeof directories !== "object" || Array.isArray(directories) || !Object.entries(directories).every(
|
|
11806
|
+
([file, directory]) => isSwiftResourcePath(file) && (directory === "." || isSwiftResourcePath(directory))
|
|
11807
|
+
))
|
|
11808
|
+
return at("sourceDirectories");
|
|
11809
|
+
}
|
|
11810
|
+
return null;
|
|
11811
|
+
}
|
|
11812
|
+
function isSwiftResourcePath(value) {
|
|
11813
|
+
return typeof value === "string" && value.length <= 4096 && !value.startsWith("/") && !value.includes("\\") && !value.includes("\0") && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
11814
|
+
}
|
|
11815
|
+
function isSwiftBundlePath(value) {
|
|
11816
|
+
return typeof value === "string" && (value === "." || isSwiftResourcePath(value) && /\.(bundle|framework)$/.test(value));
|
|
11817
|
+
}
|
|
11818
|
+
function isSwiftResourceBundles(value) {
|
|
11819
|
+
return Array.isArray(value) && value.every(
|
|
11820
|
+
(bundle) => typeof bundle === "object" && bundle !== null && typeof bundle.target === "string" && /^[A-Za-z_][A-Za-z0-9_-]*$/.test(bundle.target) && (bundle.sourcePath === "." || isSwiftResourcePath(bundle.sourcePath)) && isSwiftBundlePath(bundle.path)
|
|
11821
|
+
) && new Set(value.map((bundle) => bundle.target)).size === value.length && new Set(value.map((bundle) => bundle.path)).size === value.length;
|
|
11822
|
+
}
|
|
11823
|
+
|
|
11824
|
+
// src/swift-header-dependencies.ts
|
|
11825
|
+
function* nativeHeaderIncludes(source) {
|
|
11826
|
+
for (const match of source.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/^\s*#\s*(?:include|import)\s*[<"]([^>"]+)[>"]/gm))
|
|
11827
|
+
yield match[1];
|
|
11828
|
+
}
|
|
11829
|
+
function swiftHeaderDependencies(root, files, targets, nativeTargets, producers, aliases) {
|
|
11830
|
+
const headers = /* @__PURE__ */ new Map();
|
|
11831
|
+
for (const file of files.keys())
|
|
11832
|
+
if (/\.(?:h|hh|hpp|hxx|inc|inl|ipp|def|modulemap)$/.test(file))
|
|
11833
|
+
headers.set(file, /* @__PURE__ */ new Set());
|
|
11834
|
+
const byDirectory = /* @__PURE__ */ new Map();
|
|
11835
|
+
for (const target of targets) {
|
|
11836
|
+
const directory = path23.resolve(root, target.path);
|
|
11837
|
+
const owners = byDirectory.get(directory) ?? /* @__PURE__ */ new Set();
|
|
11838
|
+
owners.add(target.name);
|
|
11839
|
+
byDirectory.set(directory, owners);
|
|
11840
|
+
}
|
|
11841
|
+
const settings = new Map(nativeTargets.map((native) => [native.name, native]));
|
|
11842
|
+
const physicalHeaders = new Map(
|
|
11843
|
+
Object.entries(aliases).map(([alias, file]) => [
|
|
11844
|
+
path23.resolve(root, alias),
|
|
11845
|
+
path23.resolve(root, file)
|
|
11846
|
+
])
|
|
11847
|
+
);
|
|
11848
|
+
const lookup = new Map(
|
|
11849
|
+
targets.map((target) => {
|
|
11850
|
+
const native = settings.get(target.name);
|
|
11851
|
+
const directory = path23.resolve(root, target.path);
|
|
11852
|
+
const inputPrefix = `${SWIFT_NATIVE_INPUT_ROOT}/`;
|
|
11853
|
+
const flags = native?.importerFlags ?? [];
|
|
11854
|
+
const search = [
|
|
11855
|
+
path23.resolve(directory, target.publicHeadersPath ?? "include"),
|
|
11856
|
+
...(native?.userHeaderSearchPaths ?? []).map((file) => path23.resolve(root, file)),
|
|
11857
|
+
...(native?.headerSearchPaths ?? []).map((file) => path23.resolve(root, file)),
|
|
11858
|
+
...(target.clangSettings ?? []).flatMap(
|
|
11859
|
+
(setting) => "headerSearchPath" in setting ? [path23.resolve(directory, setting.headerSearchPath)] : []
|
|
11860
|
+
),
|
|
11861
|
+
...flags.flatMap(
|
|
11862
|
+
(flag, index) => (flags[index - 1] === "-I" || flags[index - 1] === "-iquote") && flag.startsWith(inputPrefix) ? [path23.resolve(root, flag.slice(inputPrefix.length))] : []
|
|
11863
|
+
)
|
|
11864
|
+
];
|
|
11865
|
+
const mapped = /* @__PURE__ */ new Map();
|
|
11866
|
+
const map = (include, file) => {
|
|
11867
|
+
const key = include.toLowerCase();
|
|
11868
|
+
const files2 = mapped.get(key) ?? [];
|
|
11869
|
+
files2.push(path23.resolve(root, file));
|
|
11870
|
+
mapped.set(key, files2);
|
|
11871
|
+
};
|
|
11872
|
+
for (const headerMap2 of native?.headerMaps ?? []) {
|
|
11873
|
+
for (const [alias, file] of headerMap2.entries) {
|
|
11874
|
+
if (file.startsWith(inputPrefix)) map(alias, file.slice(inputPrefix.length));
|
|
11875
|
+
else {
|
|
11876
|
+
const product = native?.productHeaders[file];
|
|
11877
|
+
if (product) map(alias, product);
|
|
11878
|
+
}
|
|
11879
|
+
}
|
|
11880
|
+
}
|
|
11881
|
+
for (const [alias, file] of Object.entries(native?.productHeaders ?? {}))
|
|
11882
|
+
map(alias, file);
|
|
11883
|
+
if (native?.flattensPublicHeaders)
|
|
11884
|
+
for (const file of native.publicHeaders)
|
|
11885
|
+
map(`${target.name}/${path23.basename(file)}`, file);
|
|
11886
|
+
return [target.name, { search, mapped }];
|
|
11887
|
+
})
|
|
11888
|
+
);
|
|
11889
|
+
const headersByTarget = /* @__PURE__ */ new Map();
|
|
11890
|
+
const ownersOf = (file) => {
|
|
11891
|
+
for (let directory = path23.dirname(file); ; directory = path23.dirname(directory)) {
|
|
11892
|
+
const owners = byDirectory.get(directory);
|
|
11893
|
+
if (owners) return owners;
|
|
11894
|
+
if (directory === root || !directory.startsWith(root + path23.sep)) break;
|
|
11895
|
+
}
|
|
11896
|
+
return /* @__PURE__ */ new Set();
|
|
11897
|
+
};
|
|
11898
|
+
const includers = /* @__PURE__ */ new Map();
|
|
11899
|
+
const enqueue = [];
|
|
11900
|
+
for (const [file, edges] of headers) {
|
|
11901
|
+
const source = files.get(file).toString();
|
|
11902
|
+
const owners = ownersOf(file);
|
|
11903
|
+
for (const owner of owners) {
|
|
11904
|
+
const files2 = headersByTarget.get(owner) ?? /* @__PURE__ */ new Set();
|
|
11905
|
+
files2.add(file);
|
|
11906
|
+
headersByTarget.set(owner, files2);
|
|
11907
|
+
}
|
|
11908
|
+
const moduleMap = file.endsWith(".modulemap");
|
|
11909
|
+
const tokens = moduleMap ? moduleMapTokens(source) : [];
|
|
11910
|
+
const includes = moduleMap ? tokens.flatMap(
|
|
11911
|
+
(token, index) => tokens[index - 1] === "header" && tokens[index - 2] !== "exclude" && token.startsWith('"') ? [token.slice(1, -1)] : []
|
|
11912
|
+
) : nativeHeaderIncludes(source);
|
|
11913
|
+
for (const include of includes) {
|
|
11914
|
+
const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include)?.[1];
|
|
11915
|
+
if (producer && producers.has(producer)) edges.add(producer);
|
|
11916
|
+
const local = path23.resolve(path23.dirname(file), include);
|
|
11917
|
+
const frameworkHeader = moduleMap && /\.framework\/Modules\//.test(file) ? ["../Headers", "../PrivateHeaders"].map(
|
|
11918
|
+
(directory) => path23.resolve(path23.dirname(file), directory, include)
|
|
11919
|
+
) : [];
|
|
11920
|
+
const searchPaths = [...owners].flatMap((owner) => {
|
|
11921
|
+
const { search, mapped } = lookup.get(owner);
|
|
11922
|
+
return [
|
|
11923
|
+
...search.map((directory) => path23.resolve(directory, include)),
|
|
11924
|
+
...mapped.get(include.toLowerCase()) ?? []
|
|
11925
|
+
];
|
|
11926
|
+
});
|
|
11927
|
+
for (const qualified of [local, ...frameworkHeader, ...searchPaths]) {
|
|
11928
|
+
const candidate = physicalHeaders.get(qualified) ?? qualified;
|
|
11929
|
+
if (!headers.has(candidate)) continue;
|
|
11930
|
+
const parents = includers.get(candidate) ?? /* @__PURE__ */ new Set();
|
|
11931
|
+
parents.add(file);
|
|
11932
|
+
includers.set(candidate, parents);
|
|
11933
|
+
}
|
|
11934
|
+
}
|
|
11935
|
+
if (edges.size) enqueue.push(file);
|
|
11936
|
+
}
|
|
11937
|
+
for (let index = 0; index < enqueue.length; index++) {
|
|
11938
|
+
const file = enqueue[index];
|
|
11939
|
+
for (const parent of includers.get(file) ?? []) {
|
|
11940
|
+
const edges = headers.get(parent);
|
|
11941
|
+
const before = edges.size;
|
|
11942
|
+
for (const producer of headers.get(file)) edges.add(producer);
|
|
11943
|
+
if (edges.size > before) enqueue.push(parent);
|
|
11944
|
+
}
|
|
11945
|
+
}
|
|
11946
|
+
return new Map(
|
|
11947
|
+
targets.map((target) => {
|
|
11948
|
+
const native = settings.get(target.name);
|
|
11949
|
+
const publicHeaders = [
|
|
11950
|
+
...native?.headers ?? [],
|
|
11951
|
+
...native?.publicHeaders ?? [],
|
|
11952
|
+
...Object.values(native?.productHeaders ?? {}),
|
|
11953
|
+
...native?.bridgingHeader ? [native.bridgingHeader] : [],
|
|
11954
|
+
...native?.prefixHeader ? [native.prefixHeader] : []
|
|
11955
|
+
].map((file) => path23.resolve(root, file));
|
|
11956
|
+
return [
|
|
11957
|
+
target.name,
|
|
11958
|
+
new Set(
|
|
11959
|
+
[...headersByTarget.get(target.name) ?? [], ...publicHeaders].flatMap((file) => [...headers.get(file) ?? []]).filter((producer) => producer !== target.name)
|
|
11960
|
+
)
|
|
11961
|
+
];
|
|
11962
|
+
})
|
|
11963
|
+
);
|
|
11964
|
+
}
|
|
11965
|
+
|
|
11966
|
+
// src/swift-icu.ts
|
|
11967
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
11968
|
+
import { createHash as createHash13, randomUUID as randomUUID3 } from "node:crypto";
|
|
11969
|
+
import { existsSync as existsSync4, readFileSync as readFileSync15 } from "node:fs";
|
|
11970
|
+
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
11971
|
+
import os3 from "node:os";
|
|
11972
|
+
import path24 from "node:path";
|
|
11973
|
+
import { promisify as promisify3 } from "node:util";
|
|
11974
|
+
import {
|
|
11975
|
+
brotliCompress,
|
|
11976
|
+
constants as zlibConstants,
|
|
11977
|
+
deflateRawSync,
|
|
11978
|
+
gunzip,
|
|
11979
|
+
gzip
|
|
11980
|
+
} from "node:zlib";
|
|
11981
|
+
|
|
11982
|
+
// ../sootsim-swift/src/icuData.ts
|
|
11983
|
+
var PACK_BYTES = 64 * 1024;
|
|
11984
|
+
var MAGIC = 1430473040;
|
|
11985
|
+
var VERSION = 1;
|
|
11986
|
+
var SWIFT_ICU_PACKED = `picu${VERSION}`;
|
|
11987
|
+
function swiftIcuLayout(head, blobBytes) {
|
|
11988
|
+
const view = new DataView(head.buffer, head.byteOffset, head.byteLength);
|
|
11989
|
+
const toc = view.getUint16(0, true);
|
|
11990
|
+
if (head[2] !== 218 || head[3] !== 39)
|
|
11991
|
+
throw new Error("swift icu data has no icu header");
|
|
11992
|
+
const count = view.getUint32(toc, true);
|
|
11993
|
+
const names = [];
|
|
11994
|
+
const offsets = new Uint32Array(count + 1);
|
|
11995
|
+
const decoder = new TextDecoder("latin1");
|
|
11996
|
+
for (let index = 0; index < count; index++) {
|
|
11997
|
+
const name2 = toc + view.getUint32(toc + 4 + index * 8, true);
|
|
11998
|
+
offsets[index] = toc + view.getUint32(toc + 8 + index * 8, true);
|
|
11999
|
+
names.push(decoder.decode(head.subarray(name2, head.indexOf(0, name2))));
|
|
12000
|
+
}
|
|
12001
|
+
offsets[count] = blobBytes;
|
|
12002
|
+
const packOf = new Uint32Array(count);
|
|
12003
|
+
const packs = [];
|
|
12004
|
+
for (let index = 0; index < count; index++) {
|
|
12005
|
+
const last = packs[packs.length - 1];
|
|
12006
|
+
if (last && offsets[index + 1] - last[0] <= PACK_BYTES) last[1] = offsets[index + 1];
|
|
12007
|
+
else packs.push([offsets[index], offsets[index + 1]]);
|
|
12008
|
+
packOf[index] = packs.length - 1;
|
|
12009
|
+
}
|
|
12010
|
+
return { headBytes: offsets[0], names, packOf, packs };
|
|
12011
|
+
}
|
|
12012
|
+
function swiftIcuPack(blob, deflate2) {
|
|
12013
|
+
const layout2 = swiftIcuLayout(blob, blob.byteLength);
|
|
12014
|
+
const parts = [
|
|
12015
|
+
deflate2(blob.subarray(0, layout2.headBytes)),
|
|
12016
|
+
...layout2.packs.map(([start, end]) => deflate2(blob.subarray(start, end)))
|
|
12017
|
+
];
|
|
12018
|
+
const index = new DataView(new ArrayBuffer(16 + parts.length * 4));
|
|
12019
|
+
index.setUint32(0, MAGIC, true);
|
|
12020
|
+
index.setUint32(4, VERSION, true);
|
|
12021
|
+
index.setUint32(8, blob.byteLength, true);
|
|
12022
|
+
index.setUint32(12, layout2.packs.length, true);
|
|
12023
|
+
parts.forEach((part, at2) => index.setUint32(16 + at2 * 4, part.byteLength, true));
|
|
12024
|
+
const packed = new Uint8Array(
|
|
12025
|
+
index.byteLength + parts.reduce((total, part) => total + part.byteLength, 0)
|
|
12026
|
+
);
|
|
12027
|
+
packed.set(new Uint8Array(index.buffer));
|
|
12028
|
+
let at = index.byteLength;
|
|
12029
|
+
for (const part of parts) {
|
|
12030
|
+
packed.set(part, at);
|
|
12031
|
+
at += part.byteLength;
|
|
12032
|
+
}
|
|
12033
|
+
return packed;
|
|
12034
|
+
}
|
|
12035
|
+
|
|
12036
|
+
// src/swift-icu.ts
|
|
12037
|
+
var run = promisify3(execFile3);
|
|
12038
|
+
var deflate = promisify3(gzip);
|
|
12039
|
+
var compressBrotli = promisify3(brotliCompress);
|
|
12040
|
+
var inflateGzip = promisify3(gunzip);
|
|
12041
|
+
var ARCHIVE = "wasi/lib_FoundationICU.a";
|
|
12042
|
+
var MEMBER = "icu_packaged_data.cpp.obj";
|
|
12043
|
+
var raw = /* @__PURE__ */ new Map();
|
|
12044
|
+
var assets = /* @__PURE__ */ new Map();
|
|
12045
|
+
var brotliMemoryCache = /* @__PURE__ */ new Map();
|
|
12046
|
+
async function cachedBrotli(bytes, quality, cacheKey) {
|
|
12047
|
+
const key = cacheKey && /^[a-f0-9]{64}$/.test(cacheKey) ? cacheKey : createHash13("sha256").update(bytes).digest("hex");
|
|
12048
|
+
const cacheId = `${quality}:${key}`;
|
|
12049
|
+
const cached = brotliMemoryCache.get(cacheId);
|
|
11760
12050
|
if (cached) return cached;
|
|
11761
|
-
const dir =
|
|
11762
|
-
const file =
|
|
12051
|
+
const dir = path24.join(os3.homedir(), ".peach", "cache", "swift-brotli");
|
|
12052
|
+
const file = path24.join(dir, `${key}${quality === 11 ? "" : "-q4"}.br`);
|
|
11763
12053
|
let compressed;
|
|
11764
12054
|
try {
|
|
11765
12055
|
compressed = await readFile(file);
|
|
@@ -11807,13 +12097,13 @@ function swiftIcuAsset(toolchainBin, sdk) {
|
|
|
11807
12097
|
JSON.stringify([toolchainBin, sdk, swiftSdkOptions()]),
|
|
11808
12098
|
async () => {
|
|
11809
12099
|
const zipped = await deflate(await swiftIcuData(toolchainBin, sdk));
|
|
11810
|
-
return { sha256:
|
|
12100
|
+
return { sha256: createHash13("sha256").update(zipped).digest("hex"), gzip: zipped };
|
|
11811
12101
|
}
|
|
11812
12102
|
);
|
|
11813
12103
|
}
|
|
11814
12104
|
async function load(toolchainBin, sdk) {
|
|
11815
|
-
const swift =
|
|
11816
|
-
if (!
|
|
12105
|
+
const swift = path24.join(toolchainBin, "swift");
|
|
12106
|
+
if (!existsSync4(swift))
|
|
11817
12107
|
throw new Error(`swift-icu: no swift at ${swift} for the ${sdk} SDK's icu data`);
|
|
11818
12108
|
const { stdout: listed } = await run(swift, ["sdk", "list", ...swiftSdkOptions()], {
|
|
11819
12109
|
env: swiftEnvironment()
|
|
@@ -11835,7 +12125,7 @@ async function load(toolchainBin, sdk) {
|
|
|
11835
12125
|
const resources = /^swiftStaticResourcesPath: (.+)$/m.exec(stdout)?.[1]?.trim();
|
|
11836
12126
|
if (!resources) throw new Error(`swift-icu: ${sdk} names no static resources`);
|
|
11837
12127
|
return Buffer.from(
|
|
11838
|
-
icuSegment(archiveMember(
|
|
12128
|
+
icuSegment(archiveMember(readFileSync15(path24.join(resources, ARCHIVE)), MEMBER))
|
|
11839
12129
|
);
|
|
11840
12130
|
}
|
|
11841
12131
|
function archiveMember(archive, name2) {
|
|
@@ -11895,21 +12185,21 @@ function swiftIcuAddress(icu) {
|
|
|
11895
12185
|
var packedFiles = /* @__PURE__ */ new Map();
|
|
11896
12186
|
function swiftIcuPacked(icu) {
|
|
11897
12187
|
return memo(packedFiles, icu.sha256, async () => {
|
|
11898
|
-
const file =
|
|
12188
|
+
const file = path24.join(
|
|
11899
12189
|
os3.homedir(),
|
|
11900
12190
|
".peach",
|
|
11901
12191
|
"cache",
|
|
11902
12192
|
"swift-brotli",
|
|
11903
12193
|
swiftIcuAddress(icu)
|
|
11904
12194
|
);
|
|
11905
|
-
if (
|
|
12195
|
+
if (existsSync4(file)) return readFile(file);
|
|
11906
12196
|
const packed = Buffer.from(
|
|
11907
12197
|
swiftIcuPack(
|
|
11908
12198
|
await inflateGzip(icu.gzip),
|
|
11909
12199
|
(bytes) => deflateRawSync(bytes, { level: 9 })
|
|
11910
12200
|
)
|
|
11911
12201
|
);
|
|
11912
|
-
await mkdir(
|
|
12202
|
+
await mkdir(path24.dirname(file), { recursive: true });
|
|
11913
12203
|
const tmp = `${file}.${randomUUID3()}.tmp`;
|
|
11914
12204
|
await writeFile(tmp, packed);
|
|
11915
12205
|
await rename(tmp, file);
|
|
@@ -11926,7 +12216,7 @@ async function swiftIcuBundleAsset(icu) {
|
|
|
11926
12216
|
|
|
11927
12217
|
// src/swift-link-roots.ts
|
|
11928
12218
|
import fs10 from "node:fs";
|
|
11929
|
-
import
|
|
12219
|
+
import path25 from "node:path";
|
|
11930
12220
|
var leb = (bytes, at) => {
|
|
11931
12221
|
let value = 0;
|
|
11932
12222
|
let scale = 1;
|
|
@@ -12021,7 +12311,7 @@ function swiftObjcRootObjects(id, root, objects) {
|
|
|
12021
12311
|
const cached = rootsByDistribution.get(id);
|
|
12022
12312
|
if (cached) return cached;
|
|
12023
12313
|
const measured = objects.map(
|
|
12024
|
-
(object3) => [object3, objcRootInfo(fs10.readFileSync(
|
|
12314
|
+
(object3) => [object3, objcRootInfo(fs10.readFileSync(path25.join(root, object3)))]
|
|
12025
12315
|
);
|
|
12026
12316
|
const roots = new Set(
|
|
12027
12317
|
measured.filter(
|
|
@@ -12149,41 +12439,41 @@ function swiftObjCModuleMap(module, headers, submodules = /* @__PURE__ */ new Se
|
|
|
12149
12439
|
// src/swift-project-user.ts
|
|
12150
12440
|
import { execFileSync as execFileSync10 } from "node:child_process";
|
|
12151
12441
|
import {
|
|
12152
|
-
chmodSync,
|
|
12153
|
-
existsSync as
|
|
12154
|
-
mkdirSync as
|
|
12442
|
+
chmodSync as chmodSync2,
|
|
12443
|
+
existsSync as existsSync5,
|
|
12444
|
+
mkdirSync as mkdirSync6,
|
|
12155
12445
|
readdirSync as readdirSync6,
|
|
12156
|
-
readFileSync as
|
|
12446
|
+
readFileSync as readFileSync16,
|
|
12157
12447
|
realpathSync as realpathSync3,
|
|
12158
|
-
rmSync as
|
|
12159
|
-
statSync
|
|
12448
|
+
rmSync as rmSync6,
|
|
12449
|
+
statSync as statSync2
|
|
12160
12450
|
} from "node:fs";
|
|
12161
|
-
import
|
|
12451
|
+
import path26 from "node:path";
|
|
12162
12452
|
function prepareSwiftProjectProcess(root, user) {
|
|
12163
12453
|
const home = `${root}.project-home`;
|
|
12164
|
-
|
|
12165
|
-
const tmp =
|
|
12166
|
-
const swiftpm =
|
|
12167
|
-
|
|
12168
|
-
const caches = ["cache", "config", "security"].map((name2) =>
|
|
12169
|
-
for (const directory of caches)
|
|
12454
|
+
rmSync6(home, { recursive: true, force: true });
|
|
12455
|
+
const tmp = path26.join(home, "tmp");
|
|
12456
|
+
const swiftpm = path26.join(home, "swiftpm");
|
|
12457
|
+
mkdirSync6(tmp, { recursive: true });
|
|
12458
|
+
const caches = ["cache", "config", "security"].map((name2) => path26.join(swiftpm, name2));
|
|
12459
|
+
for (const directory of caches) mkdirSync6(directory, { recursive: true });
|
|
12170
12460
|
execFileSync10("chown", ["-R", "-P", `${user.uid}:${user.gid}`, root, home]);
|
|
12171
|
-
|
|
12172
|
-
|
|
12461
|
+
chmodSync2(root, 448);
|
|
12462
|
+
chmodSync2(home, 448);
|
|
12173
12463
|
return {
|
|
12174
12464
|
uid: user.uid,
|
|
12175
12465
|
gid: user.gid,
|
|
12176
12466
|
env: {
|
|
12177
12467
|
HOME: home,
|
|
12178
12468
|
TMPDIR: tmp,
|
|
12179
|
-
XDG_CONFIG_HOME:
|
|
12180
|
-
XDG_CACHE_HOME:
|
|
12181
|
-
XDG_DATA_HOME:
|
|
12469
|
+
XDG_CONFIG_HOME: path26.join(home, ".config"),
|
|
12470
|
+
XDG_CACHE_HOME: path26.join(home, ".cache"),
|
|
12471
|
+
XDG_DATA_HOME: path26.join(home, ".local", "share")
|
|
12182
12472
|
},
|
|
12183
12473
|
cacheOptions: [
|
|
12184
12474
|
...["cache", "config", "security"].flatMap((name2) => [
|
|
12185
12475
|
`--${name2}-path`,
|
|
12186
|
-
|
|
12476
|
+
path26.join(swiftpm, name2)
|
|
12187
12477
|
]),
|
|
12188
12478
|
"--disable-keychain"
|
|
12189
12479
|
]
|
|
@@ -12198,8 +12488,8 @@ function endSwiftProjectProcesses(user) {
|
|
|
12198
12488
|
function projectOutputFile(root, file, user) {
|
|
12199
12489
|
const real = realpathSync3(file);
|
|
12200
12490
|
const base = realpathSync3(root);
|
|
12201
|
-
const stat =
|
|
12202
|
-
if (!real.startsWith(base +
|
|
12491
|
+
const stat = statSync2(real);
|
|
12492
|
+
if (!real.startsWith(base + path26.sep) || !stat.isFile() || stat.uid !== user.uid) {
|
|
12203
12493
|
throw new Error(`swift-compile: project output ${file} is not a file of its build`);
|
|
12204
12494
|
}
|
|
12205
12495
|
return real;
|
|
@@ -12208,11 +12498,11 @@ function removeProjectLinks(root) {
|
|
|
12208
12498
|
const pending = [root];
|
|
12209
12499
|
for (let directory = pending.pop(); directory; directory = pending.pop()) {
|
|
12210
12500
|
for (const entry of readdirSync6(directory, { withFileTypes: true })) {
|
|
12211
|
-
const full =
|
|
12501
|
+
const full = path26.join(directory, entry.name);
|
|
12212
12502
|
if (directory === root && entry.name === ".build") continue;
|
|
12213
12503
|
if (directory === root && entry.name.startsWith(".peach-modules-")) {
|
|
12214
|
-
|
|
12215
|
-
} else if (entry.isSymbolicLink())
|
|
12504
|
+
rmSync6(full, { recursive: true, force: true });
|
|
12505
|
+
} else if (entry.isSymbolicLink()) rmSync6(full);
|
|
12216
12506
|
else if (entry.isDirectory()) pending.push(full);
|
|
12217
12507
|
}
|
|
12218
12508
|
}
|
|
@@ -12240,19 +12530,19 @@ function swiftReproducibleBuildFlags(roots) {
|
|
|
12240
12530
|
import {
|
|
12241
12531
|
spawn as spawn4
|
|
12242
12532
|
} from "node:child_process";
|
|
12243
|
-
import { createHash as
|
|
12533
|
+
import { createHash as createHash14, randomUUID as randomUUID4 } from "node:crypto";
|
|
12244
12534
|
import {
|
|
12245
|
-
existsSync as
|
|
12535
|
+
existsSync as existsSync6,
|
|
12246
12536
|
linkSync,
|
|
12247
|
-
mkdirSync as
|
|
12537
|
+
mkdirSync as mkdirSync7,
|
|
12248
12538
|
readdirSync as readdirSync7,
|
|
12249
|
-
readFileSync as
|
|
12539
|
+
readFileSync as readFileSync17,
|
|
12250
12540
|
realpathSync as realpathSync5,
|
|
12251
|
-
rmSync as
|
|
12252
|
-
writeFileSync as
|
|
12541
|
+
rmSync as rmSync7,
|
|
12542
|
+
writeFileSync as writeFileSync8
|
|
12253
12543
|
} from "node:fs";
|
|
12254
12544
|
import { homedir as homedir2 } from "node:os";
|
|
12255
|
-
import
|
|
12545
|
+
import path27 from "node:path";
|
|
12256
12546
|
var POLL_MS = 250;
|
|
12257
12547
|
var INSPECT_ATTEMPTS = 5;
|
|
12258
12548
|
var START_TOLERANCE_MS = 2e3;
|
|
@@ -12318,7 +12608,7 @@ function generationNumbers(directory) {
|
|
|
12318
12608
|
function readGeneration(directory, number3) {
|
|
12319
12609
|
let owner;
|
|
12320
12610
|
try {
|
|
12321
|
-
owner =
|
|
12611
|
+
owner = readFileSync17(path27.join(directory, name(number3, "owner")), "utf8");
|
|
12322
12612
|
} catch (error) {
|
|
12323
12613
|
if (errorCode(error) === "ENOENT") return null;
|
|
12324
12614
|
throw error;
|
|
@@ -12331,7 +12621,7 @@ function readGeneration(directory, number3) {
|
|
|
12331
12621
|
}
|
|
12332
12622
|
function readChildren(directory, number3) {
|
|
12333
12623
|
const prefix = name(number3, "child.");
|
|
12334
|
-
return readdirSync7(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(
|
|
12624
|
+
return readdirSync7(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(readFileSync17(path27.join(directory, entry), "utf8")));
|
|
12335
12625
|
}
|
|
12336
12626
|
function groupAlive(table, leader) {
|
|
12337
12627
|
const row = table.find((candidate) => candidate.pid === leader.pid);
|
|
@@ -12339,30 +12629,30 @@ function groupAlive(table, leader) {
|
|
|
12339
12629
|
return table.some((candidate) => candidate.pgid === leader.pid && !candidate.zombie);
|
|
12340
12630
|
}
|
|
12341
12631
|
function canonicalRoot(root) {
|
|
12342
|
-
let existing =
|
|
12632
|
+
let existing = path27.resolve(root);
|
|
12343
12633
|
const missing = [];
|
|
12344
|
-
while (!
|
|
12345
|
-
missing.unshift(
|
|
12346
|
-
existing =
|
|
12634
|
+
while (!existsSync6(existing) && path27.dirname(existing) !== existing) {
|
|
12635
|
+
missing.unshift(path27.basename(existing));
|
|
12636
|
+
existing = path27.dirname(existing);
|
|
12347
12637
|
}
|
|
12348
|
-
return
|
|
12638
|
+
return path27.join(realpathSync5(existing), ...missing);
|
|
12349
12639
|
}
|
|
12350
12640
|
function swiftRootLocksDir() {
|
|
12351
|
-
return
|
|
12641
|
+
return path27.join(homedir2(), ".peach", "cache", "swift-root-locks");
|
|
12352
12642
|
}
|
|
12353
12643
|
async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
12354
|
-
const directory =
|
|
12644
|
+
const directory = path27.join(
|
|
12355
12645
|
swiftRootLocksDir(),
|
|
12356
|
-
|
|
12646
|
+
createHash14("sha256").update(canonicalRoot(root)).digest("hex").slice(0, 32)
|
|
12357
12647
|
);
|
|
12358
|
-
|
|
12648
|
+
mkdirSync7(directory, { recursive: true });
|
|
12359
12649
|
const token = randomUUID4();
|
|
12360
12650
|
const ownRow = (await processTableWithRetry(process.pid, signal)).find(
|
|
12361
12651
|
(candidate) => candidate.pid === process.pid && !candidate.zombie
|
|
12362
12652
|
);
|
|
12363
12653
|
if (!ownRow) throw new Error(`swift root lock cannot find process ${process.pid}`);
|
|
12364
12654
|
const owner = JSON.stringify({ pid: process.pid, start: ownRow.start });
|
|
12365
|
-
const pending =
|
|
12655
|
+
const pending = path27.join(directory, `pending.${token}`);
|
|
12366
12656
|
let held = 0;
|
|
12367
12657
|
let announced = 0;
|
|
12368
12658
|
let current = null;
|
|
@@ -12401,18 +12691,18 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
12401
12691
|
}
|
|
12402
12692
|
}
|
|
12403
12693
|
}
|
|
12404
|
-
|
|
12694
|
+
writeFileSync8(pending, owner);
|
|
12405
12695
|
try {
|
|
12406
|
-
linkSync(pending,
|
|
12696
|
+
linkSync(pending, path27.join(directory, name(newest + 1, "owner")));
|
|
12407
12697
|
} catch (error) {
|
|
12408
12698
|
if (errorCode(error) === "EEXIST") continue;
|
|
12409
12699
|
throw error;
|
|
12410
12700
|
} finally {
|
|
12411
|
-
|
|
12701
|
+
rmSync7(pending, { force: true });
|
|
12412
12702
|
}
|
|
12413
12703
|
const numbers = generationNumbers(directory);
|
|
12414
12704
|
if (numbers.at(-1) !== newest + 1) {
|
|
12415
|
-
|
|
12705
|
+
rmSync7(path27.join(directory, name(newest + 1, "owner")), { force: true });
|
|
12416
12706
|
continue;
|
|
12417
12707
|
}
|
|
12418
12708
|
held = newest + 1;
|
|
@@ -12420,7 +12710,7 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
12420
12710
|
if (number3 < held) {
|
|
12421
12711
|
for (const entry of readdirSync7(directory))
|
|
12422
12712
|
if (entry.startsWith(name(number3, "")))
|
|
12423
|
-
|
|
12713
|
+
rmSync7(path27.join(directory, entry), { force: true });
|
|
12424
12714
|
}
|
|
12425
12715
|
break;
|
|
12426
12716
|
}
|
|
@@ -12431,10 +12721,10 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
12431
12721
|
if (child.pid === void 0) throw new Error("could not register compiler process");
|
|
12432
12722
|
const childPending = `${pending}.child.${index}`;
|
|
12433
12723
|
try {
|
|
12434
|
-
|
|
12435
|
-
linkSync(childPending,
|
|
12724
|
+
writeFileSync8(childPending, JSON.stringify(ownIdentity(child.pid)));
|
|
12725
|
+
linkSync(childPending, path27.join(directory, name(held, `child.${index}`)));
|
|
12436
12726
|
} finally {
|
|
12437
|
-
|
|
12727
|
+
rmSync7(childPending, { force: true });
|
|
12438
12728
|
}
|
|
12439
12729
|
},
|
|
12440
12730
|
spawn(command, args, options, companion) {
|
|
@@ -12464,18 +12754,18 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
12464
12754
|
return await work(lease);
|
|
12465
12755
|
} finally {
|
|
12466
12756
|
await Promise.all(children.map((child) => terminateProcessGroup(child, "SIGKILL", 0)));
|
|
12467
|
-
|
|
12757
|
+
writeFileSync8(path27.join(directory, name(held, "released")), "");
|
|
12468
12758
|
}
|
|
12469
12759
|
}
|
|
12470
12760
|
|
|
12471
12761
|
// src/swift-uniform-type-constants.ts
|
|
12472
12762
|
import { execFileSync as execFileSync11 } from "node:child_process";
|
|
12473
|
-
import
|
|
12763
|
+
import path28 from "node:path";
|
|
12474
12764
|
function compileUniformTypeConstants(args) {
|
|
12475
|
-
const source =
|
|
12476
|
-
const object3 =
|
|
12765
|
+
const source = path28.join(args.packageRoot, "runtime/UniformTypeIdentifiersConstants.m");
|
|
12766
|
+
const object3 = path28.join(args.out, "UniformTypeIdentifiers-NativeConstants.o");
|
|
12477
12767
|
execFileSync11(
|
|
12478
|
-
|
|
12768
|
+
path28.join(args.bin, "clang"),
|
|
12479
12769
|
[
|
|
12480
12770
|
"--target=wasm64-unknown-wasip1",
|
|
12481
12771
|
`--sysroot=${args.sysroot}`,
|
|
@@ -12484,7 +12774,7 @@ function compileUniformTypeConstants(args) {
|
|
|
12484
12774
|
...swiftObjCRuntimeFlags,
|
|
12485
12775
|
"-fwasm-exceptions",
|
|
12486
12776
|
"-F",
|
|
12487
|
-
|
|
12777
|
+
path28.resolve(args.packageRoot, "../peachsim/sdk/ios/System/Library/Frameworks"),
|
|
12488
12778
|
...objcSdkIntakeFlags(args.darwin, args.bin, args.minimum),
|
|
12489
12779
|
"-c",
|
|
12490
12780
|
source,
|
|
@@ -12496,174 +12786,14 @@ function compileUniformTypeConstants(args) {
|
|
|
12496
12786
|
return object3;
|
|
12497
12787
|
}
|
|
12498
12788
|
|
|
12499
|
-
// src/swiftContract.ts
|
|
12500
|
-
function isSwiftSourceLinkGraph(value) {
|
|
12501
|
-
if (!value || typeof value !== "object") return false;
|
|
12502
|
-
const text2 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
|
|
12503
|
-
const entry = Reflect.get(value, "entry");
|
|
12504
|
-
const targets = Reflect.get(value, "targets");
|
|
12505
|
-
if (!text2(entry) || !Array.isArray(targets) || targets.length > 1024) return false;
|
|
12506
|
-
const ids = /* @__PURE__ */ new Set();
|
|
12507
|
-
for (const target of targets) {
|
|
12508
|
-
if (!target || typeof target !== "object") return false;
|
|
12509
|
-
const id = Reflect.get(target, "id");
|
|
12510
|
-
const source = Reflect.get(target, "sourceTarget");
|
|
12511
|
-
const flags = Reflect.get(target, "linkerFlags");
|
|
12512
|
-
const dependencies = Reflect.get(target, "dependencies");
|
|
12513
|
-
const build = Reflect.get(target, "buildVersion");
|
|
12514
|
-
const nullableText = (value2) => value2 === null || text2(value2);
|
|
12515
|
-
if (!text2(id) || ids.has(id) || !(source === null || text2(source)) || !text2(Reflect.get(target, "productName")) || !text2(Reflect.get(target, "productType")) || !nullableText(Reflect.get(target, "installName")) || !build || typeof build !== "object" || !["platform", "minimumOS", "sdk"].every(
|
|
12516
|
-
(key) => nullableText(Reflect.get(build, key))
|
|
12517
|
-
) || !(Reflect.get(target, "machOType") === null || text2(Reflect.get(target, "machOType"))) || !Array.isArray(flags) || !flags.every(text2) || !Array.isArray(dependencies) || !dependencies.every(
|
|
12518
|
-
(link) => link && typeof link === "object" && text2(Reflect.get(link, "target")) && Array.isArray(Reflect.get(link, "attributes")) && Reflect.get(link, "attributes").every(text2)
|
|
12519
|
-
))
|
|
12520
|
-
return false;
|
|
12521
|
-
ids.add(id);
|
|
12522
|
-
}
|
|
12523
|
-
return ids.has(entry) && targets.every(
|
|
12524
|
-
(target) => Reflect.get(target, "dependencies").every(
|
|
12525
|
-
(link) => ids.has(link.target)
|
|
12526
|
-
)
|
|
12527
|
-
);
|
|
12528
|
-
}
|
|
12529
|
-
var SWIFT_REMOTE_PACKAGES_DIR = "__packages__";
|
|
12530
|
-
var SWIFT_LOCAL_PACKAGES_DIR = "__local_packages__";
|
|
12531
|
-
var SWIFT_XCODE_BUILD_CONDITION = "__PEACH_XCODE_BUILD";
|
|
12532
|
-
function isBase64Bytes(value) {
|
|
12533
|
-
return value.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}(?![\s\S])/.test(value);
|
|
12534
|
-
}
|
|
12535
|
-
function isSwiftPackageFiles(value) {
|
|
12536
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
12537
|
-
([file, bytes]) => isSwiftResourcePath(file) && (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`)) && typeof bytes === "string" && isBase64Bytes(bytes)
|
|
12538
|
-
);
|
|
12539
|
-
}
|
|
12540
|
-
function swiftProjectFileProblem(file) {
|
|
12541
|
-
if (!isSwiftResourcePath(file)) return "not a relative path of plain segments";
|
|
12542
|
-
if (file === "Package.swift") return "would replace the generated manifest";
|
|
12543
|
-
if (file.split("/").includes(".build")) return "is build output (.build)";
|
|
12544
|
-
if (file.startsWith(".")) return 'starts with "." (hidden file or peach output)';
|
|
12545
|
-
if (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`))
|
|
12546
|
-
return "collides with a transported package checkout";
|
|
12547
|
-
return void 0;
|
|
12548
|
-
}
|
|
12549
|
-
function swiftProjectEntryProblem(file, bytes) {
|
|
12550
|
-
return swiftProjectFileProblem(file) ?? (typeof bytes === "string" && isBase64Bytes(bytes) ? void 0 : "bytes are not base64");
|
|
12551
|
-
}
|
|
12552
|
-
function isSwiftProjectFiles(value) {
|
|
12553
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
12554
|
-
([file, bytes]) => swiftProjectEntryProblem(file, bytes) === void 0
|
|
12555
|
-
);
|
|
12556
|
-
}
|
|
12557
|
-
function swiftProjectFilesProblems(value) {
|
|
12558
|
-
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
12559
|
-
return ["projectFiles is not an object"];
|
|
12560
|
-
return Object.entries(value).flatMap(([file, bytes]) => {
|
|
12561
|
-
const problem = swiftProjectEntryProblem(file, bytes);
|
|
12562
|
-
return problem ? [`${file}: ${problem}`] : [];
|
|
12563
|
-
});
|
|
12564
|
-
}
|
|
12565
|
-
var SWIFT_NATIVE_INPUT_ROOT = "$(PEACH_INPUT_ROOT)";
|
|
12566
|
-
var SWIFT_NATIVE_SDK_INCLUDE = "$(PEACH_SDK_INCLUDE)";
|
|
12567
|
-
function isSwiftHeaderAliases(value) {
|
|
12568
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
12569
|
-
([alias, file]) => isSwiftResourcePath(alias) && isSwiftResourcePath(file)
|
|
12570
|
-
);
|
|
12571
|
-
}
|
|
12572
|
-
function isSwiftNativeTargets(value) {
|
|
12573
|
-
return swiftNativeTargetsRefusal(value) === null;
|
|
12574
|
-
}
|
|
12575
|
-
function swiftNativeTargetsRefusal(value) {
|
|
12576
|
-
const strings = (value2) => Array.isArray(value2) && value2.every((item) => typeof item === "string" && !item.includes("\0"));
|
|
12577
|
-
const paths = (value2) => strings(value2) && value2.every(isSwiftResourcePath);
|
|
12578
|
-
if (!Array.isArray(value)) return "nativeTargets";
|
|
12579
|
-
if (value.length > 128) return "nativeTargets:length";
|
|
12580
|
-
for (const target of value) {
|
|
12581
|
-
if (!target || typeof target !== "object") return "nativeTargets:shape";
|
|
12582
|
-
const field = (name3) => Reflect.get(target, name3);
|
|
12583
|
-
const name2 = typeof field("name") === "string" ? String(field("name")) : "?";
|
|
12584
|
-
const at = (shape) => `nativeTargets:${name2}:${shape}`;
|
|
12585
|
-
const nullablePath = (key) => field(key) === null || isSwiftResourcePath(field(key));
|
|
12586
|
-
const perFile = field("fileFlags");
|
|
12587
|
-
const directories = field("sourceDirectories");
|
|
12588
|
-
const searches = field("headerSearchPaths");
|
|
12589
|
-
const userSearches = field("userHeaderSearchPaths");
|
|
12590
|
-
const frameworks = field("frameworkSearchPaths");
|
|
12591
|
-
const maps = field("headerMaps");
|
|
12592
|
-
const products = field("productHeaders");
|
|
12593
|
-
const inputPath = (value2) => typeof value2 === "string" && value2.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) && isSwiftResourcePath(value2.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1));
|
|
12594
|
-
const deployment = field("deploymentTarget");
|
|
12595
|
-
const targetName = field("name");
|
|
12596
|
-
if (typeof targetName !== "string" || targetName.length === 0 || targetName.length > 4096 || targetName.includes("\0") || targetName.includes("/") || targetName.includes("\\") || targetName === "." || targetName === "..")
|
|
12597
|
-
return at("name");
|
|
12598
|
-
if (!(deployment === null || typeof deployment === "string" && /^\d+(?:\.\d+){0,2}$/.test(deployment)))
|
|
12599
|
-
return at("deploymentTarget");
|
|
12600
|
-
if (!paths(field("headers"))) return at("headers");
|
|
12601
|
-
if (!paths(field("publicHeaders"))) return at("publicHeaders");
|
|
12602
|
-
if (typeof field("flattensPublicHeaders") !== "boolean")
|
|
12603
|
-
return at("flattensPublicHeaders");
|
|
12604
|
-
if (!nullablePath("bridgingHeader")) return at("bridgingHeader");
|
|
12605
|
-
if (!nullablePath("prefixHeader")) return at("prefixHeader");
|
|
12606
|
-
if (!strings(searches) || !searches.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
12607
|
-
return at("headerSearchPaths");
|
|
12608
|
-
const moduleMaps = field("moduleMaps");
|
|
12609
|
-
if (moduleMaps !== void 0 && (!Array.isArray(moduleMaps) || moduleMaps.length > 128 || !moduleMaps.every((map) => {
|
|
12610
|
-
if (!map || typeof map !== "object") return false;
|
|
12611
|
-
const module = Reflect.get(map, "module");
|
|
12612
|
-
const headers = Reflect.get(map, "headers");
|
|
12613
|
-
return typeof module === "string" && module.length > 0 && module.length <= 4096 && !module.includes("\0") && (headers === "." || isSwiftResourcePath(headers));
|
|
12614
|
-
})))
|
|
12615
|
-
return at("moduleMaps");
|
|
12616
|
-
if (!strings(userSearches) || !userSearches.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
12617
|
-
return at("userHeaderSearchPaths");
|
|
12618
|
-
if (!strings(frameworks) || !frameworks.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
12619
|
-
return at("frameworkSearchPaths");
|
|
12620
|
-
if (!Array.isArray(maps) || !maps.every((map) => {
|
|
12621
|
-
if (!map || typeof map !== "object") return false;
|
|
12622
|
-
const flag = Reflect.get(map, "flag");
|
|
12623
|
-
const entries = Reflect.get(map, "entries");
|
|
12624
|
-
return (flag === "-I" || flag === "-iquote") && Array.isArray(entries) && entries.every(
|
|
12625
|
-
(entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && !entry[0].includes("\0") && (inputPath(entry[1]) || isSwiftResourcePath(entry[1]))
|
|
12626
|
-
);
|
|
12627
|
-
}))
|
|
12628
|
-
return at("headerMaps");
|
|
12629
|
-
if (!products || typeof products !== "object" || Array.isArray(products) || !Object.entries(products).every(
|
|
12630
|
-
([product, file]) => isSwiftResourcePath(product) && isSwiftResourcePath(file)
|
|
12631
|
-
))
|
|
12632
|
-
return at("productHeaders");
|
|
12633
|
-
if (!strings(field("flags"))) return at("flags");
|
|
12634
|
-
if (!strings(field("importerFlags"))) return at("importerFlags");
|
|
12635
|
-
if (!strings(field("cxxFlags"))) return at("cxxFlags");
|
|
12636
|
-
if (!perFile || typeof perFile !== "object" || Array.isArray(perFile) || !Object.entries(perFile).every(
|
|
12637
|
-
([file, flags]) => isSwiftResourcePath(file) && strings(flags)
|
|
12638
|
-
))
|
|
12639
|
-
return at("fileFlags");
|
|
12640
|
-
if (!directories || typeof directories !== "object" || Array.isArray(directories) || !Object.entries(directories).every(
|
|
12641
|
-
([file, directory]) => isSwiftResourcePath(file) && (directory === "." || isSwiftResourcePath(directory))
|
|
12642
|
-
))
|
|
12643
|
-
return at("sourceDirectories");
|
|
12644
|
-
}
|
|
12645
|
-
return null;
|
|
12646
|
-
}
|
|
12647
|
-
function isSwiftResourcePath(value) {
|
|
12648
|
-
return typeof value === "string" && value.length <= 4096 && !value.startsWith("/") && !value.includes("\\") && !value.includes("\0") && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
12649
|
-
}
|
|
12650
|
-
function isSwiftBundlePath(value) {
|
|
12651
|
-
return typeof value === "string" && (value === "." || isSwiftResourcePath(value) && /\.(bundle|framework)$/.test(value));
|
|
12652
|
-
}
|
|
12653
|
-
function isSwiftResourceBundles(value) {
|
|
12654
|
-
return Array.isArray(value) && value.every(
|
|
12655
|
-
(bundle) => typeof bundle === "object" && bundle !== null && typeof bundle.target === "string" && /^[A-Za-z_][A-Za-z0-9_-]*$/.test(bundle.target) && (bundle.sourcePath === "." || isSwiftResourcePath(bundle.sourcePath)) && isSwiftBundlePath(bundle.path)
|
|
12656
|
-
) && new Set(value.map((bundle) => bundle.target)).size === value.length && new Set(value.map((bundle) => bundle.path)).size === value.length;
|
|
12657
|
-
}
|
|
12658
|
-
|
|
12659
12789
|
// src/xcode-header-search.ts
|
|
12660
12790
|
import fs11 from "node:fs";
|
|
12661
|
-
import
|
|
12791
|
+
import path29 from "node:path";
|
|
12662
12792
|
function coalescibleHeaderOverlays(files) {
|
|
12663
12793
|
const aliases = /* @__PURE__ */ new Map();
|
|
12664
12794
|
const key = (file) => file.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
|
|
12665
12795
|
const index = (directory, entry) => {
|
|
12666
|
-
const name2 =
|
|
12796
|
+
const name2 = path29.resolve(directory, entry.name);
|
|
12667
12797
|
if (entry.type === "directory")
|
|
12668
12798
|
return entry.contents.every((child) => index(name2, child));
|
|
12669
12799
|
const source = entry["external-contents"];
|
|
@@ -12674,11 +12804,11 @@ function coalescibleHeaderOverlays(files) {
|
|
|
12674
12804
|
};
|
|
12675
12805
|
for (const file of files) {
|
|
12676
12806
|
const overlay = JSON.parse(fs11.readFileSync(file, "utf8"));
|
|
12677
|
-
if (!overlay.roots.every((entry) => index(
|
|
12807
|
+
if (!overlay.roots.every((entry) => index(path29.dirname(file), entry)))
|
|
12678
12808
|
return /* @__PURE__ */ new Set();
|
|
12679
12809
|
}
|
|
12680
12810
|
for (const file of [...files, ...aliases.values()]) {
|
|
12681
|
-
const source = aliases.get(key(
|
|
12811
|
+
const source = aliases.get(key(path29.normalize(file)));
|
|
12682
12812
|
if (source !== void 0 && source !== file) return /* @__PURE__ */ new Set();
|
|
12683
12813
|
}
|
|
12684
12814
|
return files;
|
|
@@ -12738,11 +12868,11 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}) {
|
|
|
12738
12868
|
seen.add(file);
|
|
12739
12869
|
file = headerAliases[file];
|
|
12740
12870
|
}
|
|
12741
|
-
const listed = productDirectories.get(
|
|
12742
|
-
productDirectories.set(
|
|
12743
|
-
listed.push({ name:
|
|
12871
|
+
const listed = productDirectories.get(path29.dirname(product)) ?? [];
|
|
12872
|
+
productDirectories.set(path29.dirname(product), listed);
|
|
12873
|
+
listed.push({ name: path29.basename(product), file });
|
|
12744
12874
|
}
|
|
12745
|
-
const overlay =
|
|
12875
|
+
const overlay = path29.join(directory, "all-product-headers.yaml");
|
|
12746
12876
|
writeBuildFile(
|
|
12747
12877
|
overlay,
|
|
12748
12878
|
JSON.stringify({
|
|
@@ -12762,7 +12892,7 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}) {
|
|
|
12762
12892
|
const files = [overlay];
|
|
12763
12893
|
const flags = targets.map((target, index) => {
|
|
12764
12894
|
const maps = target.headerMaps.map((map, order) => {
|
|
12765
|
-
const file =
|
|
12895
|
+
const file = path29.join(directory, `${index}-${order}.hmap`);
|
|
12766
12896
|
writeBuildFile(file, headerMap(map.entries));
|
|
12767
12897
|
files.push(file);
|
|
12768
12898
|
return { flag: map.flag, file };
|
|
@@ -12882,37 +13012,37 @@ function swiftBuildJobs() {
|
|
|
12882
13012
|
);
|
|
12883
13013
|
}
|
|
12884
13014
|
function swiftDistributionAt(root) {
|
|
12885
|
-
const file =
|
|
12886
|
-
if (!
|
|
12887
|
-
return parseSwiftDistributionManifest(JSON.parse(
|
|
13015
|
+
const file = path30.join(root, SWIFT_DISTRIBUTION_MANIFEST);
|
|
13016
|
+
if (!existsSync7(file)) return null;
|
|
13017
|
+
return parseSwiftDistributionManifest(JSON.parse(readFileSync18(file, "utf8")));
|
|
12888
13018
|
}
|
|
12889
13019
|
var REACH_STAGED_FRAMEWORKS = /* @__PURE__ */ new Set(["React"]);
|
|
12890
13020
|
function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
|
|
12891
13021
|
if (REACH_STAGED_FRAMEWORKS.has(name2)) return null;
|
|
12892
13022
|
if (swiftDistributionAt(moduleRoot)) {
|
|
12893
|
-
const file =
|
|
12894
|
-
interfaceRoot ??
|
|
13023
|
+
const file = path30.join(
|
|
13024
|
+
interfaceRoot ?? path30.join(moduleRoot, "modules"),
|
|
12895
13025
|
`${name2}-Swift.h`
|
|
12896
13026
|
);
|
|
12897
|
-
if (!
|
|
12898
|
-
const header = clangInterfaceHeader(
|
|
13027
|
+
if (!existsSync7(file)) return null;
|
|
13028
|
+
const header = clangInterfaceHeader(readFileSync18(file, "utf8"));
|
|
12899
13029
|
return { declared: swiftInterfaceDeclarations(header), header };
|
|
12900
13030
|
}
|
|
12901
|
-
const sources =
|
|
12902
|
-
const built =
|
|
12903
|
-
if (!
|
|
13031
|
+
const sources = path30.join(moduleRoot, "Sources", name2);
|
|
13032
|
+
const built = path30.join(moduleRoot, ".build/host", `${name2}-Swift.h`);
|
|
13033
|
+
if (!existsSync7(sources) || !existsSync7(built)) return null;
|
|
12904
13034
|
const declared = /* @__PURE__ */ new Set();
|
|
12905
13035
|
for (const file of readdirSync8(sources, { recursive: true, encoding: "utf8" }))
|
|
12906
13036
|
if (file.endsWith(".swift"))
|
|
12907
|
-
for (const [, objc, subclass] of
|
|
12908
|
-
|
|
13037
|
+
for (const [, objc, subclass] of readFileSync18(
|
|
13038
|
+
path30.join(sources, file),
|
|
12909
13039
|
"utf8"
|
|
12910
13040
|
).matchAll(
|
|
12911
13041
|
/@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s|^(?:public|open)\s+(?:final\s+)?class\s+(\w+)\s*:\s*NSObject\b/gm
|
|
12912
13042
|
))
|
|
12913
13043
|
declared.add(objc ?? subclass);
|
|
12914
13044
|
if (declared.size === 0) return null;
|
|
12915
|
-
return { declared, header: clangInterfaceHeader(
|
|
13045
|
+
return { declared, header: clangInterfaceHeader(readFileSync18(built, "utf8")) };
|
|
12916
13046
|
}
|
|
12917
13047
|
var clangInterfaceHeader = (header) => header.replace(/^@import (?:UIKitCore|UIKitText);$/gm, "@import UIKit;").replace(
|
|
12918
13048
|
/^@import (?:CoreFoundation|FoundationNetworking);$/gm,
|
|
@@ -12945,11 +13075,11 @@ function sdkObjCDeclarationOwners(frameworks) {
|
|
|
12945
13075
|
const owners = /* @__PURE__ */ new Map();
|
|
12946
13076
|
for (const framework of readdirSync8(frameworks))
|
|
12947
13077
|
if (framework.endsWith(".framework")) {
|
|
12948
|
-
const headers =
|
|
12949
|
-
if (
|
|
13078
|
+
const headers = path30.join(frameworks, framework, "Headers");
|
|
13079
|
+
if (existsSync7(headers)) {
|
|
12950
13080
|
for (const file of readdirSync8(headers, { recursive: true, encoding: "utf8" }))
|
|
12951
13081
|
if (file.endsWith(".h")) {
|
|
12952
|
-
const header =
|
|
13082
|
+
const header = readFileSync18(path30.join(headers, file), "utf8");
|
|
12953
13083
|
for (const name2 of [
|
|
12954
13084
|
...swiftInterfaceDeclarations(header),
|
|
12955
13085
|
...objcEnumerations(header),
|
|
@@ -13045,25 +13175,25 @@ function swiftCompileSdkOptions(moduleRoot, toolchainBin) {
|
|
|
13045
13175
|
);
|
|
13046
13176
|
}
|
|
13047
13177
|
function swiftObjCSelectorOptions(moduleRoot) {
|
|
13048
|
-
let map =
|
|
13178
|
+
let map = path30.join(moduleRoot, SWIFT_DISTRIBUTION_OBJC_SELECTORS);
|
|
13049
13179
|
if (!swiftDistributionAt(moduleRoot)) {
|
|
13050
13180
|
const classes = {};
|
|
13051
13181
|
for (const framework of ["UIKitCore", "WebKit"])
|
|
13052
13182
|
for (const [name2, members] of Object.entries(
|
|
13053
13183
|
JSON.parse(
|
|
13054
|
-
|
|
13055
|
-
|
|
13184
|
+
readFileSync18(
|
|
13185
|
+
path30.join(moduleRoot, "Sources", framework, "ObjCSelectors.json"),
|
|
13056
13186
|
"utf8"
|
|
13057
13187
|
)
|
|
13058
13188
|
).classes
|
|
13059
13189
|
))
|
|
13060
13190
|
classes[name2] = [...classes[name2] ?? [], ...members];
|
|
13061
|
-
map =
|
|
13062
|
-
|
|
13191
|
+
map = path30.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
|
|
13192
|
+
mkdirSync8(path30.dirname(map), { recursive: true });
|
|
13063
13193
|
const partial = `${map}.${randomUUID5()}`;
|
|
13064
|
-
|
|
13194
|
+
writeFileSync9(partial, `${JSON.stringify({ classes }, null, 2)}
|
|
13065
13195
|
`);
|
|
13066
|
-
|
|
13196
|
+
renameSync3(partial, map);
|
|
13067
13197
|
}
|
|
13068
13198
|
return ["-Xswiftc", "-Xllvm", "-Xswiftc", `-peach-objc-selector-map=${map}`];
|
|
13069
13199
|
}
|
|
@@ -13097,7 +13227,7 @@ function swiftModuleInputFiles(root) {
|
|
|
13097
13227
|
"toolchain.json"
|
|
13098
13228
|
];
|
|
13099
13229
|
const walk = (dir) => {
|
|
13100
|
-
for (const entry of readdirSync8(
|
|
13230
|
+
for (const entry of readdirSync8(path30.join(root, dir), {
|
|
13101
13231
|
withFileTypes: true
|
|
13102
13232
|
})) {
|
|
13103
13233
|
const relative = `${dir}/${entry.name}`;
|
|
@@ -13111,46 +13241,46 @@ function swiftModuleInputFiles(root) {
|
|
|
13111
13241
|
walk("ios-simulator-stdlib");
|
|
13112
13242
|
return files.sort();
|
|
13113
13243
|
}
|
|
13114
|
-
function swiftMacroPlugins(moduleRoot, dir =
|
|
13244
|
+
function swiftMacroPlugins(moduleRoot, dir = path30.join(moduleRoot, ".build/host/RnxPreviewMacros")) {
|
|
13115
13245
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
13116
13246
|
if (distribution)
|
|
13117
13247
|
return {
|
|
13118
|
-
libraries: distribution.plugins.filter((plugin) =>
|
|
13119
|
-
executables: distribution.plugins.filter((plugin) =>
|
|
13248
|
+
libraries: distribution.plugins.filter((plugin) => path30.basename(plugin) !== "ExpoModulesMacros").map((plugin) => path30.join(moduleRoot, plugin)),
|
|
13249
|
+
executables: distribution.plugins.filter((plugin) => path30.basename(plugin) === "ExpoModulesMacros").map((plugin) => path30.join(moduleRoot, plugin)),
|
|
13120
13250
|
stale: false
|
|
13121
13251
|
};
|
|
13122
13252
|
const release = JSON.parse(
|
|
13123
|
-
|
|
13253
|
+
readFileSync18(path30.join(moduleRoot, "toolchain.json"), "utf8")
|
|
13124
13254
|
).release;
|
|
13125
|
-
const compilerStamp =
|
|
13126
|
-
const pluginScript =
|
|
13127
|
-
const expoPlugin =
|
|
13255
|
+
const compilerStamp = path30.join(dir, "compiler-release");
|
|
13256
|
+
const pluginScript = path30.join(moduleRoot, "scripts/build-preview-plugin.sh");
|
|
13257
|
+
const expoPlugin = path30.join(dir, "ExpoModulesMacros");
|
|
13128
13258
|
const ext = process.platform === "darwin" ? "dylib" : "so";
|
|
13129
13259
|
const plugins = [
|
|
13130
13260
|
{
|
|
13131
|
-
library:
|
|
13132
|
-
sources: [
|
|
13261
|
+
library: path30.join(dir, `libRnxPreviewMacros.${ext}`),
|
|
13262
|
+
sources: [path30.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
|
|
13133
13263
|
},
|
|
13134
13264
|
{
|
|
13135
|
-
library:
|
|
13265
|
+
library: path30.join(dir, `libFoundationMacros.${ext}`),
|
|
13136
13266
|
sources: [
|
|
13137
|
-
|
|
13138
|
-
|
|
13267
|
+
path30.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
|
|
13268
|
+
path30.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
|
|
13139
13269
|
]
|
|
13140
13270
|
},
|
|
13141
13271
|
{
|
|
13142
|
-
library:
|
|
13272
|
+
library: path30.join(dir, `libTipKitMacros.${ext}`),
|
|
13143
13273
|
sources: [
|
|
13144
|
-
|
|
13145
|
-
|
|
13274
|
+
path30.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
|
|
13275
|
+
path30.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
|
|
13146
13276
|
]
|
|
13147
13277
|
}
|
|
13148
13278
|
];
|
|
13149
13279
|
return {
|
|
13150
13280
|
libraries: plugins.map(({ library }) => library),
|
|
13151
13281
|
executables: [expoPlugin],
|
|
13152
|
-
stale: !
|
|
13153
|
-
({ library, sources }) => !
|
|
13282
|
+
stale: !existsSync7(compilerStamp) || !existsSync7(expoPlugin) || statSync3(pluginScript).mtimeMs > statSync3(expoPlugin).mtimeMs || readFileSync18(compilerStamp, "utf8").trim() !== release || plugins.some(
|
|
13283
|
+
({ library, sources }) => !existsSync7(library) || sources.some((source) => statSync3(source).mtimeMs > statSync3(library).mtimeMs)
|
|
13154
13284
|
)
|
|
13155
13285
|
};
|
|
13156
13286
|
}
|
|
@@ -13160,14 +13290,14 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal, lea
|
|
|
13160
13290
|
await runCompiler(
|
|
13161
13291
|
"sh",
|
|
13162
13292
|
[
|
|
13163
|
-
|
|
13293
|
+
path30.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
13164
13294
|
toolchainBin,
|
|
13165
13295
|
libraries[0]
|
|
13166
13296
|
],
|
|
13167
13297
|
{ signal, lease }
|
|
13168
13298
|
);
|
|
13169
|
-
|
|
13170
|
-
|
|
13299
|
+
writeFileSync9(
|
|
13300
|
+
path30.join(path30.dirname(libraries[0]), "compiler-release"),
|
|
13171
13301
|
`${release}
|
|
13172
13302
|
`
|
|
13173
13303
|
);
|
|
@@ -13181,9 +13311,9 @@ function clearLinkedModuleDigests(root) {
|
|
|
13181
13311
|
}
|
|
13182
13312
|
function swiftModuleDigest(root) {
|
|
13183
13313
|
const files = swiftModuleInputFiles(root);
|
|
13184
|
-
const stampHash =
|
|
13314
|
+
const stampHash = createHash15("sha256");
|
|
13185
13315
|
for (const file of files) {
|
|
13186
|
-
const stat =
|
|
13316
|
+
const stat = statSync3(path30.join(root, file), { bigint: true });
|
|
13187
13317
|
stampHash.update(file);
|
|
13188
13318
|
stampHash.update(
|
|
13189
13319
|
`${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
|
|
@@ -13193,36 +13323,36 @@ function swiftModuleDigest(root) {
|
|
|
13193
13323
|
const stamp = stampHash.digest("hex");
|
|
13194
13324
|
const cached = linkedModuleDigests.get(root);
|
|
13195
13325
|
if (cached?.stamp === stamp) return cached.digest;
|
|
13196
|
-
const record =
|
|
13326
|
+
const record = path30.join(
|
|
13197
13327
|
swiftCacheDir(),
|
|
13198
13328
|
"swift-module-digests",
|
|
13199
|
-
`${
|
|
13329
|
+
`${createHash15("sha256").update(root).digest("hex")}.json`
|
|
13200
13330
|
);
|
|
13201
|
-
if (
|
|
13202
|
-
const saved = JSON.parse(
|
|
13331
|
+
if (existsSync7(record)) {
|
|
13332
|
+
const saved = JSON.parse(readFileSync18(record, "utf8"));
|
|
13203
13333
|
if (saved && typeof saved === "object" && Reflect.get(saved, "stamp") === stamp && typeof Reflect.get(saved, "digest") === "string") {
|
|
13204
13334
|
const digest2 = Buffer.from(String(Reflect.get(saved, "digest")), "hex");
|
|
13205
13335
|
linkedModuleDigests.set(root, { stamp, digest: digest2 });
|
|
13206
13336
|
return digest2;
|
|
13207
13337
|
}
|
|
13208
13338
|
}
|
|
13209
|
-
const hash =
|
|
13339
|
+
const hash = createHash15("sha256");
|
|
13210
13340
|
for (const file of files) {
|
|
13211
|
-
hash.update(
|
|
13341
|
+
hash.update(createHash15("sha256").update(file).digest());
|
|
13212
13342
|
hash.update(
|
|
13213
|
-
|
|
13343
|
+
createHash15("sha256").update(readFileSync18(path30.join(root, file))).digest()
|
|
13214
13344
|
);
|
|
13215
13345
|
}
|
|
13216
13346
|
const digest = hash.digest();
|
|
13217
13347
|
linkedModuleDigests.set(root, { stamp, digest });
|
|
13218
|
-
|
|
13348
|
+
mkdirSync8(path30.dirname(record), { recursive: true });
|
|
13219
13349
|
const partial = `${record}.${process.pid}.${randomUUID5()}`;
|
|
13220
|
-
|
|
13221
|
-
|
|
13350
|
+
writeFileSync9(partial, JSON.stringify({ stamp, digest: digest.toString("hex") }));
|
|
13351
|
+
renameSync3(partial, record);
|
|
13222
13352
|
return digest;
|
|
13223
13353
|
}
|
|
13224
13354
|
function swiftProjectBuildKey(moduleRoot, release) {
|
|
13225
|
-
return
|
|
13355
|
+
return createHash15("sha256").update(`swift-framework/v2\0${release}\0${swiftModuleSdk(moduleRoot).wasmSdkId}`).update(swiftModuleDigest(moduleRoot)).digest("hex").slice(0, 32);
|
|
13226
13356
|
}
|
|
13227
13357
|
var SYSTEM_MODULE_LIBRARIES = {
|
|
13228
13358
|
"sqlite3.h": "sqlite3",
|
|
@@ -13269,7 +13399,7 @@ function withNativeSourceGlue(input, glue) {
|
|
|
13269
13399
|
...input,
|
|
13270
13400
|
files: {
|
|
13271
13401
|
...input.files,
|
|
13272
|
-
[
|
|
13402
|
+
[path30.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
|
|
13273
13403
|
},
|
|
13274
13404
|
oneModule: true
|
|
13275
13405
|
};
|
|
@@ -13361,12 +13491,12 @@ function swiftCondition(text2, available) {
|
|
|
13361
13491
|
if (token === "false") return false;
|
|
13362
13492
|
const call = /^(\w+)\s*\(\s*([^,()]*?)\s*(?:,[^()]*)?\)$/.exec(token ?? "");
|
|
13363
13493
|
if (!call) return void 0;
|
|
13364
|
-
const [, name2,
|
|
13365
|
-
if (name2 === "os") return
|
|
13494
|
+
const [, name2, argument2] = call;
|
|
13495
|
+
if (name2 === "os") return argument2 === "iOS";
|
|
13366
13496
|
if (name2 === "canImport")
|
|
13367
|
-
return
|
|
13368
|
-
if (name2 === "targetEnvironment") return
|
|
13369
|
-
if (name2 === "arch") return
|
|
13497
|
+
return argument2 !== "FoundationNetworking" && available?.has(argument2);
|
|
13498
|
+
if (name2 === "targetEnvironment") return argument2 === "simulator";
|
|
13499
|
+
if (name2 === "arch") return argument2 === "wasm64" || argument2 === "arm64";
|
|
13370
13500
|
return void 0;
|
|
13371
13501
|
};
|
|
13372
13502
|
const both = () => {
|
|
@@ -13425,7 +13555,7 @@ function swiftImportNames(contents2, available) {
|
|
|
13425
13555
|
function swiftPeachModules(moduleRoot) {
|
|
13426
13556
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
13427
13557
|
return distribution ? distribution.modules : swiftManifestDeclarations(
|
|
13428
|
-
|
|
13558
|
+
readFileSync18(path30.join(moduleRoot, "Package.swift"), "utf8")
|
|
13429
13559
|
).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
|
|
13430
13560
|
}
|
|
13431
13561
|
var sdkPaths = /* @__PURE__ */ new Map();
|
|
@@ -13436,7 +13566,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
13436
13566
|
const cached = sdkPaths.get(key);
|
|
13437
13567
|
if (cached) return cached;
|
|
13438
13568
|
const configuration = execFileSync12(
|
|
13439
|
-
|
|
13569
|
+
path30.join(toolchainBin, "swift"),
|
|
13440
13570
|
[
|
|
13441
13571
|
"sdk",
|
|
13442
13572
|
"configure",
|
|
@@ -13461,7 +13591,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
13461
13591
|
if (!Array.isArray(toolsets) || !toolsets.every((value) => typeof value === "string"))
|
|
13462
13592
|
throw new Error(`swift sdk ${sdk} reports invalid toolset paths`);
|
|
13463
13593
|
for (const toolset of toolsets) {
|
|
13464
|
-
const config = JSON.parse(
|
|
13594
|
+
const config = JSON.parse(readFileSync18(toolset, "utf8"));
|
|
13465
13595
|
if (!config || typeof config !== "object" || !("swiftCompiler" in config)) continue;
|
|
13466
13596
|
const compiler = config.swiftCompiler;
|
|
13467
13597
|
if (!compiler || typeof compiler !== "object" || !("extraCLIOptions" in compiler))
|
|
@@ -13477,7 +13607,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
13477
13607
|
if (flag !== "-fwasm-exceptions") cFlags.push(flag);
|
|
13478
13608
|
if (flag === "-iframeworkwithsysroot" && options2[index + 2] === "-Xcc" && typeof options2[index + 3] === "string") {
|
|
13479
13609
|
cFlags.push(options2[index + 3]);
|
|
13480
|
-
frameworks.push(
|
|
13610
|
+
frameworks.push(path30.join(sysroot, options2[index + 3]));
|
|
13481
13611
|
index += 3;
|
|
13482
13612
|
continue;
|
|
13483
13613
|
}
|
|
@@ -13494,7 +13624,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
13494
13624
|
}
|
|
13495
13625
|
const paths = {
|
|
13496
13626
|
sysroot,
|
|
13497
|
-
darwin:
|
|
13627
|
+
darwin: path30.join(sysroot, "darwin"),
|
|
13498
13628
|
resources: field("swiftResourcesPath"),
|
|
13499
13629
|
frameworks,
|
|
13500
13630
|
cFlags
|
|
@@ -13522,24 +13652,24 @@ function swiftOverlayFrameworks(moduleRoot, toolchainBin) {
|
|
|
13522
13652
|
const { darwin, resources, frameworks } = swiftSdkPaths(moduleRoot, toolchainBin);
|
|
13523
13653
|
const swiftModules = new Set(swiftPeachModules(moduleRoot));
|
|
13524
13654
|
const result = /* @__PURE__ */ new Set();
|
|
13525
|
-
const include =
|
|
13655
|
+
const include = path30.join(darwin, "usr/include");
|
|
13526
13656
|
for (const entry of readdirSync8(include))
|
|
13527
13657
|
if (entry.endsWith(".modulemap"))
|
|
13528
13658
|
addSwiftOverlayFrameworks(
|
|
13529
|
-
|
|
13659
|
+
readFileSync18(path30.join(include, entry), "utf8"),
|
|
13530
13660
|
swiftModules,
|
|
13531
13661
|
result
|
|
13532
13662
|
);
|
|
13533
13663
|
for (const entry of readdirSync8(resources)) {
|
|
13534
|
-
const map =
|
|
13535
|
-
if (
|
|
13536
|
-
addSwiftOverlayFrameworks(
|
|
13664
|
+
const map = path30.join(resources, entry, "module.modulemap");
|
|
13665
|
+
if (existsSync7(map))
|
|
13666
|
+
addSwiftOverlayFrameworks(readFileSync18(map, "utf8"), swiftModules, result);
|
|
13537
13667
|
}
|
|
13538
13668
|
for (const directory of frameworks)
|
|
13539
13669
|
for (const entry of readdirSync8(directory)) {
|
|
13540
|
-
const map =
|
|
13541
|
-
if (
|
|
13542
|
-
addSwiftOverlayFrameworks(
|
|
13670
|
+
const map = path30.join(directory, entry, "Modules/module.modulemap");
|
|
13671
|
+
if (existsSync7(map))
|
|
13672
|
+
addSwiftOverlayFrameworks(readFileSync18(map, "utf8"), swiftModules, result);
|
|
13543
13673
|
}
|
|
13544
13674
|
sdkOverlayFrameworks.set(key, result);
|
|
13545
13675
|
return result;
|
|
@@ -13555,51 +13685,51 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
13555
13685
|
toolchainBin
|
|
13556
13686
|
);
|
|
13557
13687
|
const maps = /* @__PURE__ */ new Set([
|
|
13558
|
-
|
|
13688
|
+
path30.join(darwin, "usr/include/module.modulemap"),
|
|
13559
13689
|
...cFlags.filter((flag) => flag.startsWith("-fmodule-map-file=")).map((flag) => {
|
|
13560
13690
|
const file = flag.slice("-fmodule-map-file=".length);
|
|
13561
|
-
return file.startsWith("=") ?
|
|
13691
|
+
return file.startsWith("=") ? path30.join(sysroot, file.slice(1)) : file;
|
|
13562
13692
|
})
|
|
13563
13693
|
]);
|
|
13564
13694
|
for (const map of maps) {
|
|
13565
|
-
if (!
|
|
13566
|
-
const contents2 =
|
|
13695
|
+
if (!existsSync7(map)) continue;
|
|
13696
|
+
const contents2 = readFileSync18(map, "utf8");
|
|
13567
13697
|
for (const match of contents2.matchAll(
|
|
13568
13698
|
/^(?:explicit\s+)?(?:framework\s+)?module\s+([A-Za-z_]\w*)/gm
|
|
13569
13699
|
))
|
|
13570
13700
|
modules.add(match[1]);
|
|
13571
13701
|
for (const match of contents2.matchAll(/^\s*extern\s+module\s+\w+\s+"([^"]+)"/gm))
|
|
13572
|
-
maps.add(
|
|
13702
|
+
maps.add(path30.resolve(path30.dirname(map), match[1]));
|
|
13573
13703
|
}
|
|
13574
|
-
for (const entry of readdirSync8(
|
|
13704
|
+
for (const entry of readdirSync8(path30.join(resources, "wasi"))) {
|
|
13575
13705
|
if (entry.endsWith(".swiftmodule"))
|
|
13576
13706
|
modules.add(entry.slice(0, -".swiftmodule".length));
|
|
13577
13707
|
}
|
|
13578
13708
|
for (const entry of readdirSync8(resources)) {
|
|
13579
|
-
const map =
|
|
13580
|
-
if (!
|
|
13581
|
-
for (const match of
|
|
13709
|
+
const map = path30.join(resources, entry, "module.modulemap");
|
|
13710
|
+
if (!existsSync7(map)) continue;
|
|
13711
|
+
for (const match of readFileSync18(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
|
|
13582
13712
|
modules.add(match[1]);
|
|
13583
13713
|
}
|
|
13584
13714
|
for (const libc of [
|
|
13585
|
-
|
|
13586
|
-
|
|
13715
|
+
path30.join(darwin, "usr/include"),
|
|
13716
|
+
path30.join(
|
|
13587
13717
|
swiftSharedSdkRoot(moduleRoot, swiftDistributionAt(moduleRoot) !== null),
|
|
13588
13718
|
"usr/include"
|
|
13589
13719
|
)
|
|
13590
13720
|
])
|
|
13591
13721
|
for (const entry of readdirSync8(libc)) {
|
|
13592
13722
|
if (!entry.endsWith(".modulemap")) continue;
|
|
13593
|
-
for (const match of
|
|
13723
|
+
for (const match of readFileSync18(path30.join(libc, entry), "utf8").matchAll(
|
|
13594
13724
|
/^module\s+([A-Za-z_]\w*)/gm
|
|
13595
13725
|
))
|
|
13596
13726
|
modules.add(match[1]);
|
|
13597
13727
|
}
|
|
13598
13728
|
for (const directory of frameworks) {
|
|
13599
13729
|
for (const entry of readdirSync8(directory)) {
|
|
13600
|
-
const map =
|
|
13601
|
-
if (!
|
|
13602
|
-
for (const match of
|
|
13730
|
+
const map = path30.join(directory, entry, "Modules/module.modulemap");
|
|
13731
|
+
if (!existsSync7(map)) continue;
|
|
13732
|
+
for (const match of readFileSync18(map, "utf8").matchAll(
|
|
13603
13733
|
/^framework\s+module\s+([A-Za-z_]\w*)/gm
|
|
13604
13734
|
))
|
|
13605
13735
|
modules.add(match[1]);
|
|
@@ -13697,23 +13827,23 @@ int EXUpdatesApplyBSDiffPatch(const char * _Nonnull oldFilePath,
|
|
|
13697
13827
|
}
|
|
13698
13828
|
];
|
|
13699
13829
|
function distributionClangModulePresent(modules, name2) {
|
|
13700
|
-
return
|
|
13830
|
+
return existsSync7(path30.join(modules, `${name2}.swiftmodule`)) || existsSync7(path30.join(modules, name2, "module.modulemap"));
|
|
13701
13831
|
}
|
|
13702
13832
|
function distributionClangModuleMap(root, modules) {
|
|
13703
13833
|
const missing = DISTRIBUTION_CLANG_MODULES.filter(
|
|
13704
13834
|
(mod) => !distributionClangModulePresent(modules, mod.name)
|
|
13705
13835
|
);
|
|
13706
13836
|
if (missing.length === 0) return null;
|
|
13707
|
-
const key =
|
|
13708
|
-
const directory =
|
|
13709
|
-
const mapPath =
|
|
13710
|
-
if (!
|
|
13711
|
-
|
|
13837
|
+
const key = createHash15("sha256").update(modules).update(missing.map((mod) => `${mod.name}\0${mod.source}`).join("\0")).digest("hex").slice(0, 16);
|
|
13838
|
+
const directory = path30.join(root, `.peach-clang-modules-${key}`);
|
|
13839
|
+
const mapPath = path30.join(directory, "module.modulemap");
|
|
13840
|
+
if (!existsSync7(mapPath)) {
|
|
13841
|
+
mkdirSync8(directory, { recursive: true });
|
|
13712
13842
|
const parts = [];
|
|
13713
13843
|
for (const mod of missing) {
|
|
13714
|
-
const destination =
|
|
13715
|
-
|
|
13716
|
-
|
|
13844
|
+
const destination = path30.join(directory, mod.header);
|
|
13845
|
+
mkdirSync8(path30.dirname(destination), { recursive: true });
|
|
13846
|
+
writeFileSync9(destination, mod.source);
|
|
13717
13847
|
parts.push(
|
|
13718
13848
|
`module ${mod.name} {
|
|
13719
13849
|
requires objc
|
|
@@ -13723,7 +13853,7 @@ function distributionClangModuleMap(root, modules) {
|
|
|
13723
13853
|
`
|
|
13724
13854
|
);
|
|
13725
13855
|
}
|
|
13726
|
-
|
|
13856
|
+
writeFileSync9(mapPath, parts.join("\n"));
|
|
13727
13857
|
}
|
|
13728
13858
|
return mapPath;
|
|
13729
13859
|
}
|
|
@@ -13734,17 +13864,17 @@ function distributionClangModuleOptions(root, modules) {
|
|
|
13734
13864
|
function providedModulesPath(root, modules, excluded) {
|
|
13735
13865
|
if (!excluded || excluded.size === 0) return modules;
|
|
13736
13866
|
const entries = readdirSync8(modules).filter((entry) => !excluded.has(entry.replace(/\..*$/, ""))).sort();
|
|
13737
|
-
const key =
|
|
13738
|
-
const directory =
|
|
13739
|
-
const complete =
|
|
13740
|
-
if (!
|
|
13741
|
-
|
|
13867
|
+
const key = createHash15("sha256").update(JSON.stringify([modules, entries])).update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
|
|
13868
|
+
const directory = path30.join(root, `.peach-modules-${key}`);
|
|
13869
|
+
const complete = path30.join(directory, ".complete");
|
|
13870
|
+
if (!existsSync7(complete)) {
|
|
13871
|
+
mkdirSync8(directory, { recursive: true });
|
|
13742
13872
|
for (const entry of readdirSync8(directory))
|
|
13743
|
-
|
|
13873
|
+
rmSync8(path30.join(directory, entry), { recursive: true, force: true });
|
|
13744
13874
|
for (const entry of entries) {
|
|
13745
|
-
symlinkSync2(
|
|
13875
|
+
symlinkSync2(path30.join(modules, entry), path30.join(directory, entry));
|
|
13746
13876
|
}
|
|
13747
|
-
|
|
13877
|
+
writeFileSync9(complete, "");
|
|
13748
13878
|
}
|
|
13749
13879
|
return directory;
|
|
13750
13880
|
}
|
|
@@ -13756,7 +13886,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
|
|
|
13756
13886
|
);
|
|
13757
13887
|
const names = /* @__PURE__ */ new Set([...frameworks, ...targets.map((target) => target.name)]);
|
|
13758
13888
|
const entriesByPrefix = new Map(
|
|
13759
|
-
targets.map(({ path:
|
|
13889
|
+
targets.map(({ path: path31 }) => [path31 === "." ? "" : `${path31}/`, []])
|
|
13760
13890
|
);
|
|
13761
13891
|
for (const entry of Object.entries(files)) {
|
|
13762
13892
|
const [file] = entry;
|
|
@@ -13791,7 +13921,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
|
|
|
13791
13921
|
(excluded) => relative === excluded || relative.startsWith(`${excluded}/`)
|
|
13792
13922
|
))
|
|
13793
13923
|
continue;
|
|
13794
|
-
if (nested.some((
|
|
13924
|
+
if (nested.some((path31) => file.startsWith(path31))) continue;
|
|
13795
13925
|
const imports = file.endsWith(".swift") ? swiftImportNames(contents2) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents2, ownsHeader) : [];
|
|
13796
13926
|
for (const name2 of imports) {
|
|
13797
13927
|
if (names.has(name2) && name2 !== target.name && !(target.dependencies !== void 0 && localNames.has(name2)))
|
|
@@ -13829,7 +13959,7 @@ var PRECONCURRENCY_FOUNDATION_IMPORT = /^[ \t]*@preconcurrency[ \t]+(?:(?:public
|
|
|
13829
13959
|
function withPreconcurrencyFoundationModules(source) {
|
|
13830
13960
|
if (!PRECONCURRENCY_FOUNDATION_IMPORT.test(source)) return source;
|
|
13831
13961
|
return `${source}${source.endsWith("\n") ? "" : "\n"}#if canImport(PeachObjC)
|
|
13832
|
-
${["ObjectiveC", ...FOUNDATION_IMPLICIT_MODULES].map((module) => `@preconcurrency import ${module}
|
|
13962
|
+
${["CoreFoundation", "ObjectiveC", ...FOUNDATION_IMPLICIT_MODULES].map((module) => `@preconcurrency import ${module}
|
|
13833
13963
|
`).join("")}#endif
|
|
13834
13964
|
`;
|
|
13835
13965
|
}
|
|
@@ -13838,7 +13968,7 @@ var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
|
|
|
13838
13968
|
).join("");
|
|
13839
13969
|
var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
13840
13970
|
var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
13841
|
-
"-Xclang-linker", ${JSON.stringify(`-fuse-ld=${
|
|
13971
|
+
"-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path30.join(root, SWIFT_AUTOLINK_LINKER)}`)},
|
|
13842
13972
|
"-Xlinker", "-z", "-Xlinker", "stack-size=8372224",
|
|
13843
13973
|
"-Xlinker", "--stack-first",
|
|
13844
13974
|
"-Xlinker", "--global-base=8372224",
|
|
@@ -13852,11 +13982,11 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
|
13852
13982
|
`;
|
|
13853
13983
|
var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...quoted2, "-Wl,--end-lib"] : [];
|
|
13854
13984
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
13855
|
-
var MULTI_MANIFEST_VERSION =
|
|
13985
|
+
var MULTI_MANIFEST_VERSION = 72;
|
|
13856
13986
|
var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
13857
|
-
var compilerSourceDigest = true ? "
|
|
13987
|
+
var compilerSourceDigest = true ? "63f37c4a87253305166cb52435207eb3f74394734f1a77e562d79ab7d5d7dfc1" : swiftCompilerSourceDigest(import.meta.dirname);
|
|
13858
13988
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
13859
|
-
const hash =
|
|
13989
|
+
const hash = createHash15("sha256");
|
|
13860
13990
|
hash.update(`swift-compile
|
|
13861
13991
|
${release}
|
|
13862
13992
|
`);
|
|
@@ -13869,32 +13999,32 @@ ${WASM_LOWER_IDENTITY}
|
|
|
13869
13999
|
`);
|
|
13870
14000
|
if (input.optimize) hash.update("optimize\n");
|
|
13871
14001
|
for (const file of Object.keys(input.files).sort()) {
|
|
13872
|
-
hash.update(
|
|
13873
|
-
hash.update(
|
|
14002
|
+
hash.update(createHash15("sha256").update(file).digest());
|
|
14003
|
+
hash.update(createHash15("sha256").update(input.files[file]).digest());
|
|
13874
14004
|
}
|
|
13875
14005
|
for (const file of Object.keys(input.metalSources ?? {}).sort()) {
|
|
13876
14006
|
hash.update("metal-source\n");
|
|
13877
|
-
hash.update(
|
|
14007
|
+
hash.update(createHash15("sha256").update(file).digest());
|
|
13878
14008
|
hash.update(
|
|
13879
|
-
|
|
14009
|
+
createHash15("sha256").update(input.metalSources?.[file] ?? "").digest()
|
|
13880
14010
|
);
|
|
13881
14011
|
}
|
|
13882
14012
|
for (const base of Object.keys(input.resources ?? {}).sort()) {
|
|
13883
|
-
hash.update(
|
|
14013
|
+
hash.update(createHash15("sha256").update(base).digest());
|
|
13884
14014
|
hash.update(
|
|
13885
|
-
|
|
14015
|
+
createHash15("sha256").update(input.resources?.[base] ?? "").digest()
|
|
13886
14016
|
);
|
|
13887
14017
|
}
|
|
13888
14018
|
for (const name2 of Object.keys(input.images ?? {}).sort()) {
|
|
13889
14019
|
const image = input.images?.[name2];
|
|
13890
14020
|
if (!image) continue;
|
|
13891
|
-
hash.update(
|
|
13892
|
-
hash.update(
|
|
13893
|
-
hash.update(
|
|
14021
|
+
hash.update(createHash15("sha256").update(name2).digest());
|
|
14022
|
+
hash.update(createHash15("sha256").update(image.file).digest());
|
|
14023
|
+
hash.update(createHash15("sha256").update(image.data).digest());
|
|
13894
14024
|
}
|
|
13895
14025
|
for (const file of [...new Set(input.resourcePaths ?? [])].sort()) {
|
|
13896
14026
|
hash.update("resource-path\n");
|
|
13897
|
-
hash.update(
|
|
14027
|
+
hash.update(createHash15("sha256").update(file).digest());
|
|
13898
14028
|
}
|
|
13899
14029
|
hash.update(
|
|
13900
14030
|
JSON.stringify(
|
|
@@ -13912,18 +14042,18 @@ ${input.defaultLocalization}
|
|
|
13912
14042
|
`);
|
|
13913
14043
|
for (const file of Object.keys(input.packageFiles ?? {}).sort()) {
|
|
13914
14044
|
hash.update(`package-file\0${file}\0`);
|
|
13915
|
-
hash.update(
|
|
14045
|
+
hash.update(createHash15("sha256").update(input.packageFiles[file]).digest());
|
|
13916
14046
|
}
|
|
13917
14047
|
for (const file of Object.keys(input.projectFiles ?? {}).sort()) {
|
|
13918
14048
|
hash.update(`project-file\0${file}\0`);
|
|
13919
|
-
hash.update(
|
|
14049
|
+
hash.update(createHash15("sha256").update(input.projectFiles[file]).digest());
|
|
13920
14050
|
}
|
|
13921
14051
|
for (const target of Object.keys(input.libraries ?? {}).sort()) {
|
|
13922
14052
|
hash.update(`library
|
|
13923
14053
|
${target}
|
|
13924
14054
|
`);
|
|
13925
14055
|
hash.update(
|
|
13926
|
-
|
|
14056
|
+
createHash15("sha256").update(input.libraries?.[target] ?? "").digest()
|
|
13927
14057
|
);
|
|
13928
14058
|
}
|
|
13929
14059
|
for (const [name2, bytes] of Object.entries(input.binaryModules ?? {}).sort())
|
|
@@ -13947,7 +14077,7 @@ var nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
|
13947
14077
|
var cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|
|
13948
14078
|
var cxxFlagArray = (flags) => JSON.stringify([...nativeCxxCompilerFlags, ...withoutGlogModuleMap(flags)]);
|
|
13949
14079
|
function swiftCrossImportFlags(moduleRoot, distribution) {
|
|
13950
|
-
const overlayRoot =
|
|
14080
|
+
const overlayRoot = path30.join(
|
|
13951
14081
|
moduleRoot,
|
|
13952
14082
|
distribution ? "modules" : "cross-import-overlays"
|
|
13953
14083
|
);
|
|
@@ -13955,9 +14085,9 @@ function swiftCrossImportFlags(moduleRoot, distribution) {
|
|
|
13955
14085
|
"-Xfrontend",
|
|
13956
14086
|
"-swift-module-cross-import",
|
|
13957
14087
|
"-Xfrontend",
|
|
13958
|
-
|
|
14088
|
+
path30.basename(path30.dirname(file), ".swiftcrossimport"),
|
|
13959
14089
|
"-Xfrontend",
|
|
13960
|
-
|
|
14090
|
+
path30.join(overlayRoot, file)
|
|
13961
14091
|
]);
|
|
13962
14092
|
}
|
|
13963
14093
|
function withoutWasmOverlayIsystem(flags) {
|
|
@@ -13997,7 +14127,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13997
14127
|
if (!flag.startsWith("-fmodule-map-file=")) return false;
|
|
13998
14128
|
const file = flag.slice("-fmodule-map-file=".length).replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root);
|
|
13999
14129
|
if (!file.includes("/Pods/Headers/")) return false;
|
|
14000
|
-
const map = args.files.get(file) ?? (
|
|
14130
|
+
const map = args.files.get(file) ?? (existsSync7(file) ? readFileSync18(file) : void 0);
|
|
14001
14131
|
const name2 = map === void 0 ? void 0 : moduleMapName(map.toString());
|
|
14002
14132
|
return name2 !== void 0 && packageModules.has(name2);
|
|
14003
14133
|
};
|
|
@@ -14029,7 +14159,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
14029
14159
|
const product = v5.parse(
|
|
14030
14160
|
swiftFrameworkProductSchema,
|
|
14031
14161
|
JSON.parse(
|
|
14032
|
-
|
|
14162
|
+
readFileSync18(path30.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
|
|
14033
14163
|
)
|
|
14034
14164
|
);
|
|
14035
14165
|
const replacedObjects = new Set(
|
|
@@ -14043,7 +14173,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
14043
14173
|
(name2) => !object3.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
|
|
14044
14174
|
)
|
|
14045
14175
|
);
|
|
14046
|
-
const quoted2 = (object3) => `"${
|
|
14176
|
+
const quoted2 = (object3) => `"${path30.join(moduleRoot, object3).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
14047
14177
|
const categoryObjects = new Set(
|
|
14048
14178
|
foundationCategoryObjects.map((name2) => `lib/Foundation-${name2}.o`)
|
|
14049
14179
|
);
|
|
@@ -14060,7 +14190,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
14060
14190
|
].join("\n") + "\n";
|
|
14061
14191
|
distributionLinkPath = distributionLink.path.replace(
|
|
14062
14192
|
/\.rsp$/,
|
|
14063
|
-
`-${
|
|
14193
|
+
`-${createHash15("sha256").update(list).digest("hex").slice(0, 12)}.rsp`
|
|
14064
14194
|
);
|
|
14065
14195
|
distributionLink.files.set(distributionLinkPath, list);
|
|
14066
14196
|
}
|
|
@@ -14077,8 +14207,8 @@ function emitSwiftPackageManifest(args) {
|
|
|
14077
14207
|
const macroSettings = (values) => (values ?? []).map((value) => ` ${clangMacroSetting(value)},`).join("");
|
|
14078
14208
|
const flagArray = (literal2) => {
|
|
14079
14209
|
const content = literal2.replace(/,\s*]$/, "]");
|
|
14080
|
-
const digest =
|
|
14081
|
-
const file =
|
|
14210
|
+
const digest = createHash15("sha256").update(content).digest("hex");
|
|
14211
|
+
const file = path30.join(args.root, ".peach-manifest-arguments", `${digest}.json`);
|
|
14082
14212
|
args.files.set(file, content);
|
|
14083
14213
|
return `peachCompilerArguments(${JSON.stringify(file)})`;
|
|
14084
14214
|
};
|
|
@@ -14089,8 +14219,8 @@ function emitSwiftPackageManifest(args) {
|
|
|
14089
14219
|
const macros = compactSwiftClangDefines(flags);
|
|
14090
14220
|
const compact = args.coalescibleOverlays ? compactSwiftClangOverlays(macros, args.coalescibleOverlays) : macros;
|
|
14091
14221
|
const content = compact.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
|
|
14092
|
-
const digest =
|
|
14093
|
-
const file =
|
|
14222
|
+
const digest = createHash15("sha256").update(content).digest("hex");
|
|
14223
|
+
const file = path30.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
|
|
14094
14224
|
args.files.set(file, content);
|
|
14095
14225
|
return JSON.stringify([`@${file}`]);
|
|
14096
14226
|
};
|
|
@@ -14102,7 +14232,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
14102
14232
|
owner?.publicHeadersPath ?? ""
|
|
14103
14233
|
);
|
|
14104
14234
|
return [
|
|
14105
|
-
...owner && framework ? [
|
|
14235
|
+
...owner && framework ? [path30.posix.join(args.root, owner.path, framework[1])] : [],
|
|
14106
14236
|
...frameworkDirectories(dependency, seen)
|
|
14107
14237
|
];
|
|
14108
14238
|
});
|
|
@@ -14124,7 +14254,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
14124
14254
|
const stanza = (target) => {
|
|
14125
14255
|
const native = args.native?.get(target.name);
|
|
14126
14256
|
if (target.systemLibrary || native?.clang?.sources.length === 0)
|
|
14127
|
-
return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ?
|
|
14257
|
+
return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? path30.posix.dirname(native.clang.modulemap) : target.path)}),`;
|
|
14128
14258
|
const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
|
|
14129
14259
|
const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
|
|
14130
14260
|
const defines = (target.defines ?? []).map((name2) => ` .define(${JSON.stringify(name2)}),`).join("");
|
|
@@ -14137,10 +14267,10 @@ function emitSwiftPackageManifest(args) {
|
|
|
14137
14267
|
const imports = binaryImports + (distribution ? `, "-Isystem", ${JSON.stringify(
|
|
14138
14268
|
providedModulesPath(
|
|
14139
14269
|
args.root,
|
|
14140
|
-
|
|
14270
|
+
path30.join(moduleRoot, "modules"),
|
|
14141
14271
|
args.moduleExcludes
|
|
14142
14272
|
)
|
|
14143
|
-
)}${distributionClangModuleOptions(args.root,
|
|
14273
|
+
)}${distributionClangModuleOptions(args.root, path30.join(moduleRoot, "modules")).map((flag) => `, ${JSON.stringify(flag)}`).join("")}` : prebuilt ? `, "-Isystem", ${JSON.stringify(providedModulesPath(args.root, prebuilt.modules, args.moduleExcludes))}${prebuilt.moduleMaps.map((map) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map}`)}`).join("")}` : "");
|
|
14144
14274
|
const nativeFlags = [
|
|
14145
14275
|
...args.nativeFlags?.get(target.name) ?? [],
|
|
14146
14276
|
...args.nativeHeaderFlags ?? []
|
|
@@ -14179,7 +14309,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
14179
14309
|
].map((flag) => `, ${JSON.stringify(flag)}`).join("");
|
|
14180
14310
|
const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || [...args.native?.values() ?? []].some(
|
|
14181
14311
|
(value) => value.late?.producers.includes(target.name)
|
|
14182
|
-
)) ? `, "-emit-objc-header-path", ${JSON.stringify(
|
|
14312
|
+
)) ? `, "-emit-objc-header-path", ${JSON.stringify(path30.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
|
|
14183
14313
|
const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
|
|
14184
14314
|
const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
|
|
14185
14315
|
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}${deployment}${upstream}]`)})]`;
|
|
@@ -14348,19 +14478,19 @@ function emitSwiftPackageManifest(args) {
|
|
|
14348
14478
|
].join("\n");
|
|
14349
14479
|
}
|
|
14350
14480
|
function syncSwiftTree(base, files) {
|
|
14351
|
-
|
|
14481
|
+
mkdirSync8(base, { recursive: true });
|
|
14352
14482
|
const kept = /* @__PURE__ */ new Set();
|
|
14353
|
-
for (const file of files.keys()) if (
|
|
14483
|
+
for (const file of files.keys()) if (existsSync7(file)) kept.add(statSync3(file).ino);
|
|
14354
14484
|
const walk = (dir) => {
|
|
14355
14485
|
for (const entry of readdirSync8(dir, { withFileTypes: true })) {
|
|
14356
|
-
const full =
|
|
14486
|
+
const full = path30.join(dir, entry.name);
|
|
14357
14487
|
if (dir === base && (entry.name === ".build" || entry.name.startsWith(".peach-modules-") || // distribution clang maps are written beside the project and named
|
|
14358
14488
|
// from the compiler flags, so a sync must not remove them.
|
|
14359
14489
|
entry.name.startsWith(".peach-clang-modules-") || entry.name === SWIFT_LINK_STAMP))
|
|
14360
14490
|
continue;
|
|
14361
14491
|
if (entry.isDirectory()) walk(full);
|
|
14362
14492
|
else if (!files.has(full) && !kept.has(lstatSync(full).ino))
|
|
14363
|
-
|
|
14493
|
+
rmSync8(full, { force: true });
|
|
14364
14494
|
}
|
|
14365
14495
|
};
|
|
14366
14496
|
walk(base);
|
|
@@ -14508,7 +14638,7 @@ function compiledSwiftSources(files, targets, overlayFrameworks, headers, native
|
|
|
14508
14638
|
const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
|
|
14509
14639
|
return new Map(
|
|
14510
14640
|
[...owners].map(([file, { source, owner }]) => {
|
|
14511
|
-
if (nativeSourceGlue &&
|
|
14641
|
+
if (nativeSourceGlue && path30.posix.basename(file) === "OneNativeSource.generated.swift")
|
|
14512
14642
|
return [file, source];
|
|
14513
14643
|
const manifest = /(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file);
|
|
14514
14644
|
if (manifest && (!owner || /^Package(?:@swift-[\d.]+)?\.swift$/.test(file)))
|
|
@@ -14728,7 +14858,6 @@ var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
|
|
|
14728
14858
|
]);
|
|
14729
14859
|
var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
14730
14860
|
"CFBridgingRetain",
|
|
14731
|
-
"NSASCIIStringEncoding",
|
|
14732
14861
|
"NSAllHashTableObjects",
|
|
14733
14862
|
"NSAllMapTableKeys",
|
|
14734
14863
|
"NSAllMapTableValues",
|
|
@@ -14807,21 +14936,16 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14807
14936
|
"NSHashTableWeakMemory",
|
|
14808
14937
|
"NSHebrewCalendar",
|
|
14809
14938
|
"NSHostByteOrder",
|
|
14810
|
-
"NSISO2022JPStringEncoding",
|
|
14811
14939
|
"NSISO8601Calendar",
|
|
14812
|
-
"NSISOLatin1StringEncoding",
|
|
14813
|
-
"NSISOLatin2StringEncoding",
|
|
14814
14940
|
"NSIndianCalendar",
|
|
14815
14941
|
"NSIslamicCalendar",
|
|
14816
14942
|
"NSIslamicCivilCalendar",
|
|
14817
14943
|
"NSItemProviderPreferredImageSizeKey",
|
|
14818
14944
|
"NSJapaneseCalendar",
|
|
14819
|
-
"NSJapaneseEUCStringEncoding",
|
|
14820
14945
|
"NSLoadedClasses",
|
|
14821
14946
|
"NSLocalizedFailureErrorKey",
|
|
14822
14947
|
"NSLogPageSize",
|
|
14823
14948
|
"NSMACHOperatingSystem",
|
|
14824
|
-
"NSMacOSRomanStringEncoding",
|
|
14825
14949
|
"NSMapGet",
|
|
14826
14950
|
"NSMapInsert",
|
|
14827
14951
|
"NSMapInsertIfAbsent",
|
|
@@ -14833,10 +14957,8 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14833
14957
|
"NSMapTableStrongMemory",
|
|
14834
14958
|
"NSMapTableWeakMemory",
|
|
14835
14959
|
"NSMultipleUnderlyingErrorsKey",
|
|
14836
|
-
"NSNEXTSTEPStringEncoding",
|
|
14837
14960
|
"NSNextHashEnumeratorItem",
|
|
14838
14961
|
"NSNextMapEnumeratorPair",
|
|
14839
|
-
"NSNonLossyASCIIStringEncoding",
|
|
14840
14962
|
"NSNonOwnedPointerHashCallBacks",
|
|
14841
14963
|
"NSNonOwnedPointerMapKeyCallBacks",
|
|
14842
14964
|
"NSNonOwnedPointerMapValueCallBacks",
|
|
@@ -14858,12 +14980,10 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14858
14980
|
"NSPointerToStructHashCallBacks",
|
|
14859
14981
|
"NSPropertyListErrorMaximum",
|
|
14860
14982
|
"NSPropertyListErrorMinimum",
|
|
14861
|
-
"NSProprietaryStringEncoding",
|
|
14862
14983
|
"NSProtocolFromString",
|
|
14863
14984
|
"NSRepublicOfChinaCalendar",
|
|
14864
14985
|
"NSResetHashTable",
|
|
14865
14986
|
"NSResetMapTable",
|
|
14866
|
-
"NSShiftJISStringEncoding",
|
|
14867
14987
|
"NSSolarisOperatingSystem",
|
|
14868
14988
|
"NSStringFromHashTable",
|
|
14869
14989
|
"NSStringFromMapTable",
|
|
@@ -14899,7 +15019,6 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14899
15019
|
"NSSwapLong",
|
|
14900
15020
|
"NSSwapLongLong",
|
|
14901
15021
|
"NSSwapShort",
|
|
14902
|
-
"NSSymbolStringEncoding",
|
|
14903
15022
|
"NSTextCheckingAllCustomTypes",
|
|
14904
15023
|
"NSTextCheckingAllSystemTypes",
|
|
14905
15024
|
"NSTextCheckingAllTypes",
|
|
@@ -14917,13 +15036,6 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14917
15036
|
"NSURLProtectionSpaceHTTPSProxy",
|
|
14918
15037
|
"NSURLProtectionSpaceSOCKSProxy",
|
|
14919
15038
|
"NSURLSessionUploadTaskResumeData",
|
|
14920
|
-
"NSUTF16BigEndianStringEncoding",
|
|
14921
|
-
"NSUTF16LittleEndianStringEncoding",
|
|
14922
|
-
"NSUTF16StringEncoding",
|
|
14923
|
-
"NSUTF32BigEndianStringEncoding",
|
|
14924
|
-
"NSUTF32LittleEndianStringEncoding",
|
|
14925
|
-
"NSUTF32StringEncoding",
|
|
14926
|
-
"NSUTF8StringEncoding",
|
|
14927
15039
|
"NSUbiquitousFileErrorMaximum",
|
|
14928
15040
|
"NSUbiquitousFileErrorMinimum",
|
|
14929
15041
|
"NSUbiquitousKeyValueStoreAccountChange",
|
|
@@ -14935,17 +15047,11 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14935
15047
|
"NSUndefinedDateComponent",
|
|
14936
15048
|
"NSUndoCloseGroupingRunLoopOrdering",
|
|
14937
15049
|
"NSUndoManagerGroupIsDiscardableKey",
|
|
14938
|
-
"NSUnicodeStringEncoding",
|
|
14939
15050
|
"NSUserActivityErrorMaximum",
|
|
14940
15051
|
"NSUserActivityErrorMinimum",
|
|
14941
15052
|
"NSValidationErrorMaximum",
|
|
14942
15053
|
"NSValidationErrorMinimum",
|
|
14943
15054
|
"NSWindows95OperatingSystem",
|
|
14944
|
-
"NSWindowsCP1250StringEncoding",
|
|
14945
|
-
"NSWindowsCP1251StringEncoding",
|
|
14946
|
-
"NSWindowsCP1252StringEncoding",
|
|
14947
|
-
"NSWindowsCP1253StringEncoding",
|
|
14948
|
-
"NSWindowsCP1254StringEncoding",
|
|
14949
15055
|
"NSWindowsNTOperatingSystem",
|
|
14950
15056
|
"NSWrapCalendarComponents",
|
|
14951
15057
|
"NSXPCConnectionCodeSigningRequirementFailure",
|
|
@@ -15266,7 +15372,7 @@ function swiftApplicationEntry(file, source) {
|
|
|
15266
15372
|
else if (source[at] === "}") depth--;
|
|
15267
15373
|
else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
|
|
15268
15374
|
return true;
|
|
15269
|
-
else if (depth === 0 &&
|
|
15375
|
+
else if (depth === 0 && path30.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
|
|
15270
15376
|
return true;
|
|
15271
15377
|
}
|
|
15272
15378
|
return false;
|
|
@@ -15381,11 +15487,11 @@ function objcApplicationMainCall(source) {
|
|
|
15381
15487
|
if (principal === null || delegate === null) return null;
|
|
15382
15488
|
return { principal, delegate };
|
|
15383
15489
|
}
|
|
15384
|
-
function objcMainCallArgument(
|
|
15385
|
-
if (/^(?:nil|NULL|Nil)$/.test(
|
|
15386
|
-
const literal2 = /^@"((?:[^"\\]|\\.)*)"$/.exec(
|
|
15490
|
+
function objcMainCallArgument(argument2) {
|
|
15491
|
+
if (/^(?:nil|NULL|Nil)$/.test(argument2)) return "nil";
|
|
15492
|
+
const literal2 = /^@"((?:[^"\\]|\\.)*)"$/.exec(argument2);
|
|
15387
15493
|
if (literal2) return `"${literal2[1]}"`;
|
|
15388
|
-
const name2 = /^NSStringFromClass\(\[([A-Za-z_]\w*) class\]\)$/.exec(
|
|
15494
|
+
const name2 = /^NSStringFromClass\(\[([A-Za-z_]\w*) class\]\)$/.exec(argument2);
|
|
15389
15495
|
if (name2) return `"${name2[1]}"`;
|
|
15390
15496
|
return null;
|
|
15391
15497
|
}
|
|
@@ -15654,6 +15760,18 @@ function swiftCMainEntry(file, source, env = emptyMacroEnvironment) {
|
|
|
15654
15760
|
}
|
|
15655
15761
|
return false;
|
|
15656
15762
|
}
|
|
15763
|
+
var SWIFT_SCAN_KEYWORDS = {
|
|
15764
|
+
c: "class",
|
|
15765
|
+
e: "extension",
|
|
15766
|
+
o: "override",
|
|
15767
|
+
i: "import",
|
|
15768
|
+
f: "func",
|
|
15769
|
+
U: "UIApplicationMain",
|
|
15770
|
+
F: "Foundation",
|
|
15771
|
+
C: "CoreFoundation",
|
|
15772
|
+
O: "ObjectiveC",
|
|
15773
|
+
_: "_LocationEssentials"
|
|
15774
|
+
};
|
|
15657
15775
|
function swiftCodeScan(source) {
|
|
15658
15776
|
const starts = /* @__PURE__ */ new Set();
|
|
15659
15777
|
const tokens = [];
|
|
@@ -15736,8 +15854,8 @@ function swiftCodeScan(source) {
|
|
|
15736
15854
|
else top.parens--;
|
|
15737
15855
|
i++;
|
|
15738
15856
|
} else {
|
|
15739
|
-
const keyword =
|
|
15740
|
-
if (keyword && !/[\w$]/.test(source[i - 1] ?? "") && !/[\w$]/.test(source[i + keyword.length] ?? "")) {
|
|
15857
|
+
const keyword = SWIFT_SCAN_KEYWORDS[char];
|
|
15858
|
+
if (keyword && source.startsWith(keyword, i) && !/[\w$]/.test(source[i - 1] ?? "") && !/[\w$]/.test(source[i + keyword.length] ?? "")) {
|
|
15741
15859
|
tokens.push(i);
|
|
15742
15860
|
i += keyword.length;
|
|
15743
15861
|
} else {
|
|
@@ -15749,27 +15867,27 @@ function swiftCodeScan(source) {
|
|
|
15749
15867
|
return { lineStarts: starts, tokens };
|
|
15750
15868
|
}
|
|
15751
15869
|
function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
15752
|
-
|
|
15870
|
+
rmSync8(destination, { recursive: true, force: true });
|
|
15753
15871
|
const origins = {};
|
|
15754
15872
|
const moduleMaps = [];
|
|
15755
15873
|
const gather = (from) => {
|
|
15756
15874
|
for (const entry of readdirSync8(from, { withFileTypes: true })) {
|
|
15757
15875
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
15758
15876
|
continue;
|
|
15759
|
-
const file =
|
|
15877
|
+
const file = path30.join(from, entry.name);
|
|
15760
15878
|
if (entry.isDirectory()) gather(file);
|
|
15761
15879
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
15762
|
-
origins[
|
|
15880
|
+
origins[path30.relative(source, file)] = readFileSync18(file, "utf8");
|
|
15763
15881
|
else if (entry.isFile() && entry.name.endsWith(".modulemap"))
|
|
15764
|
-
moduleMaps.push(
|
|
15882
|
+
moduleMaps.push(readFileSync18(file, "utf8"));
|
|
15765
15883
|
}
|
|
15766
15884
|
};
|
|
15767
15885
|
gather(source);
|
|
15768
|
-
const manifest =
|
|
15769
|
-
const targets =
|
|
15770
|
-
|
|
15886
|
+
const manifest = path30.join(source, "Package.swift");
|
|
15887
|
+
const targets = existsSync7(manifest) ? swiftManifestTargets(
|
|
15888
|
+
readFileSync18(manifest, "utf8"),
|
|
15771
15889
|
[],
|
|
15772
|
-
(file) =>
|
|
15890
|
+
(file) => readFileSync18(file, "utf8")
|
|
15773
15891
|
) : [];
|
|
15774
15892
|
let dependencyOverlays;
|
|
15775
15893
|
const compiled = compiledSwiftSources(
|
|
@@ -15793,15 +15911,15 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
|
15793
15911
|
() => []
|
|
15794
15912
|
);
|
|
15795
15913
|
const copy = (from, to) => {
|
|
15796
|
-
|
|
15914
|
+
mkdirSync8(to, { recursive: true });
|
|
15797
15915
|
for (const entry of readdirSync8(from, { withFileTypes: true })) {
|
|
15798
15916
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
15799
15917
|
continue;
|
|
15800
|
-
const file =
|
|
15801
|
-
const target =
|
|
15918
|
+
const file = path30.join(from, entry.name);
|
|
15919
|
+
const target = path30.join(to, entry.name);
|
|
15802
15920
|
if (entry.isDirectory()) copy(file, target);
|
|
15803
15921
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
15804
|
-
|
|
15922
|
+
writeFileSync9(target, compiled.get(path30.relative(source, file)));
|
|
15805
15923
|
else cpSync(file, target, { verbatimSymlinks: true });
|
|
15806
15924
|
}
|
|
15807
15925
|
};
|
|
@@ -15823,18 +15941,18 @@ function swiftWholeFileArm64Guard(source) {
|
|
|
15823
15941
|
}
|
|
15824
15942
|
function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
|
|
15825
15943
|
const searched = new Set(settings.headerSearchPaths);
|
|
15826
|
-
const directory =
|
|
15944
|
+
const directory = path30.join(layoutRoot, ".build", "peach-clang-modulemaps");
|
|
15827
15945
|
return (settings.moduleMaps ?? []).flatMap((map) => {
|
|
15828
|
-
const headers =
|
|
15829
|
-
if (!
|
|
15830
|
-
const published =
|
|
15831
|
-
if (searched.has(map.headers) &&
|
|
15832
|
-
if (!searched.has(map.headers) &&
|
|
15946
|
+
const headers = path30.join(layoutRoot, map.headers);
|
|
15947
|
+
if (!existsSync7(headers)) return [];
|
|
15948
|
+
const published = path30.join(headers, "module.modulemap");
|
|
15949
|
+
if (searched.has(map.headers) && existsSync7(published)) return [];
|
|
15950
|
+
if (!searched.has(map.headers) && existsSync7(published))
|
|
15833
15951
|
return [`-fmodule-map-file=${published}`];
|
|
15834
15952
|
const cached = written.get(headers);
|
|
15835
15953
|
if (cached) return [cached];
|
|
15836
|
-
|
|
15837
|
-
const output =
|
|
15954
|
+
mkdirSync8(directory, { recursive: true });
|
|
15955
|
+
const output = path30.join(directory, `module-${written.size}.modulemap`);
|
|
15838
15956
|
writeBuildFile(
|
|
15839
15957
|
output,
|
|
15840
15958
|
swiftPackageClangModuleMap(swiftTargetModuleName(map.module), {
|
|
@@ -15868,7 +15986,7 @@ function needsNativeToolset(input, prebuilt) {
|
|
|
15868
15986
|
input.packageFiles || prebuilt || Object.keys(input.files).some(isSwiftNativeTranslationUnit)
|
|
15869
15987
|
);
|
|
15870
15988
|
}
|
|
15871
|
-
function writeSwiftProject(layout2, input, moduleRoot, prebuilt) {
|
|
15989
|
+
function writeSwiftProject(layout2, input, moduleRoot, prebuilt, allowHeaderCompiler = false) {
|
|
15872
15990
|
const nativeToolset = needsNativeToolset(input, prebuilt);
|
|
15873
15991
|
if (input.headerAliases !== void 0 && !isSwiftHeaderAliases(input.headerAliases))
|
|
15874
15992
|
throw new Error("swift compile input has invalid original header aliases");
|
|
@@ -15899,7 +16017,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15899
16017
|
const targets = distribution && compileTargets(input).length === 0 ? [
|
|
15900
16018
|
{
|
|
15901
16019
|
name: "App",
|
|
15902
|
-
path:
|
|
16020
|
+
path: path30.relative(layout2.root, layout2.sources),
|
|
15903
16021
|
executable: true,
|
|
15904
16022
|
languageMode: 5,
|
|
15905
16023
|
mainActorIsolation: false,
|
|
@@ -15925,12 +16043,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15925
16043
|
if (!file.endsWith(".swift")) continue;
|
|
15926
16044
|
const target = bySourcePath.find(
|
|
15927
16045
|
(candidate) => (candidate.path === "." || file.startsWith(`${candidate.path}/`)) && (candidate.sources === void 0 || candidate.sources.some((source) => {
|
|
15928
|
-
const selected =
|
|
16046
|
+
const selected = path30.posix.join(candidate.path, source);
|
|
15929
16047
|
return file === selected || file.startsWith(`${selected}/`);
|
|
15930
16048
|
}))
|
|
15931
16049
|
);
|
|
15932
16050
|
const excluded = target?.exclude?.some(
|
|
15933
|
-
(name2) => file ===
|
|
16051
|
+
(name2) => file === path30.posix.join(target.path, name2)
|
|
15934
16052
|
);
|
|
15935
16053
|
if (target && !excluded) swiftTargets.add(target.name);
|
|
15936
16054
|
}
|
|
@@ -15956,24 +16074,24 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15956
16074
|
([file, contents2]) => file.endsWith(".swift") ? [contents2] : []
|
|
15957
16075
|
)
|
|
15958
16076
|
);
|
|
15959
|
-
const headerDirectory =
|
|
16077
|
+
const headerDirectory = path30.join(layout2.root, ".build", "peach-cxx-headers");
|
|
15960
16078
|
const flattenedHeaders = /* @__PURE__ */ new Set();
|
|
15961
|
-
if (
|
|
16079
|
+
if (existsSync7(headerDirectory)) {
|
|
15962
16080
|
for (const entry of readdirSync8(headerDirectory, { withFileTypes: true }))
|
|
15963
16081
|
if (entry.isDirectory() && !targets.some((target) => target.name === entry.name))
|
|
15964
|
-
|
|
16082
|
+
rmSync8(path30.join(headerDirectory, entry.name), { recursive: true, force: true });
|
|
15965
16083
|
}
|
|
15966
16084
|
let checkedToolchain;
|
|
15967
16085
|
const nativeToolchain = () => {
|
|
15968
16086
|
if (checkedToolchain) return checkedToolchain;
|
|
15969
|
-
const pin = distribution ?? JSON.parse(
|
|
16087
|
+
const pin = distribution ?? JSON.parse(readFileSync18(path30.join(moduleRoot, "toolchain.json"), "utf8"));
|
|
15970
16088
|
checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
|
|
15971
16089
|
return checkedToolchain;
|
|
15972
16090
|
};
|
|
15973
16091
|
const deploymentTarget = (name2) => input.nativeTargets?.find((value) => value.name === name2)?.deploymentTarget ?? targets.find((value) => value.name === name2)?.iosDeploymentTarget ?? null;
|
|
15974
16092
|
const targetStagedFiles = /* @__PURE__ */ new Map();
|
|
15975
16093
|
const stageTargetFile = (target, file, contents2, options) => {
|
|
15976
|
-
const relative =
|
|
16094
|
+
const relative = path30.relative(layout2.root, file).split(path30.sep).join(path30.posix.sep);
|
|
15977
16095
|
const prior = files.has(file) ? files.get(file) : Object.hasOwn(input.files, relative) ? input.files[relative] : void 0;
|
|
15978
16096
|
if (!options?.allowExisting && prior !== void 0)
|
|
15979
16097
|
throw new Error(`target ${target} already contains generated output ${relative}`);
|
|
@@ -15986,7 +16104,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15986
16104
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
15987
16105
|
return Object.entries(input.files).filter(
|
|
15988
16106
|
([file]) => file.startsWith(prefix) && (target.sources === void 0 || !(file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) || target.sources.some((source) => {
|
|
15989
|
-
const selected =
|
|
16107
|
+
const selected = path30.posix.join(prefix, source);
|
|
15990
16108
|
return file === selected || file.startsWith(`${selected}/`);
|
|
15991
16109
|
})) && !target.exclude?.some(
|
|
15992
16110
|
(excluded) => file === `${prefix}${excluded}` || file.startsWith(`${prefix}${excluded}/`)
|
|
@@ -16007,7 +16125,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16007
16125
|
targetStagedFiles.delete(target.name);
|
|
16008
16126
|
if (entries.some(([file]) => isSwiftNativeTranslationUnit(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name))) {
|
|
16009
16127
|
if (!swift) {
|
|
16010
|
-
const unprepared =
|
|
16128
|
+
const unprepared = path30.join(
|
|
16011
16129
|
layout2.root,
|
|
16012
16130
|
target.path,
|
|
16013
16131
|
"PeachUnprepared.generated.swift"
|
|
@@ -16022,7 +16140,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16022
16140
|
native.set(target.name, {
|
|
16023
16141
|
mixed: true,
|
|
16024
16142
|
path: target.path,
|
|
16025
|
-
includeDirectory:
|
|
16143
|
+
includeDirectory: path30.join(layout2.root, target.path, "include"),
|
|
16026
16144
|
sources: [],
|
|
16027
16145
|
lateSources: [],
|
|
16028
16146
|
exclude: entries.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length))
|
|
@@ -16044,15 +16162,15 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16044
16162
|
file
|
|
16045
16163
|
)?.[1];
|
|
16046
16164
|
if (owner)
|
|
16047
|
-
podHeaders.set(
|
|
16048
|
-
...podHeaders.get(
|
|
16165
|
+
podHeaders.set(path30.basename(file), [
|
|
16166
|
+
...podHeaders.get(path30.basename(file)) ?? [],
|
|
16049
16167
|
{ owner, content: input.files[file] }
|
|
16050
16168
|
]);
|
|
16051
16169
|
}
|
|
16052
|
-
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(
|
|
16170
|
+
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(path30.basename(file))?.find((header) => header.content === content)?.owner;
|
|
16053
16171
|
for (const settings of input.nativeTargets ?? []) {
|
|
16054
16172
|
for (const file of settings.headers) {
|
|
16055
|
-
const destination =
|
|
16173
|
+
const destination = path30.join(layout2.root, file);
|
|
16056
16174
|
if (files.has(destination)) continue;
|
|
16057
16175
|
const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
|
|
16058
16176
|
const frameworkHeader = !interfaceModule && /(?:^|\/)(\w+)\.framework\/Headers\/[\w+.-]+\.h$/.exec(file)?.[1];
|
|
@@ -16071,10 +16189,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16071
16189
|
}
|
|
16072
16190
|
if (settings.flattensPublicHeaders)
|
|
16073
16191
|
for (const header of settings.publicHeaders) {
|
|
16074
|
-
const destination =
|
|
16192
|
+
const destination = path30.join(
|
|
16075
16193
|
headerDirectory,
|
|
16076
16194
|
settings.name,
|
|
16077
|
-
|
|
16195
|
+
path30.basename(header)
|
|
16078
16196
|
);
|
|
16079
16197
|
if (flattenedHeaders.has(destination))
|
|
16080
16198
|
throw new Error(`duplicate product header ${destination}`);
|
|
@@ -16082,9 +16200,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16082
16200
|
}
|
|
16083
16201
|
}
|
|
16084
16202
|
const nativeTargets = input.nativeTargets ?? [];
|
|
16085
|
-
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ?
|
|
16203
|
+
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path30.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
|
|
16086
16204
|
const headerSearch = writeXcodeHeaderSearch(
|
|
16087
|
-
|
|
16205
|
+
path30.join(layout2.root, ".build", "peach-xcode-headers"),
|
|
16088
16206
|
nativeTargets.map((settings) => ({
|
|
16089
16207
|
headerMaps: settings.headerMaps.map((map) => ({
|
|
16090
16208
|
flag: map.flag,
|
|
@@ -16095,26 +16213,26 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16095
16213
|
})),
|
|
16096
16214
|
productHeaders: Object.fromEntries([
|
|
16097
16215
|
...Object.entries(settings.productHeaders).map(([product, file]) => [
|
|
16098
|
-
|
|
16099
|
-
|
|
16216
|
+
path30.join(layout2.root, product),
|
|
16217
|
+
path30.join(layout2.root, file)
|
|
16100
16218
|
]),
|
|
16101
16219
|
...settings.flattensPublicHeaders ? settings.publicHeaders.map((header) => [
|
|
16102
|
-
|
|
16103
|
-
|
|
16220
|
+
path30.join(headerDirectory, settings.name, path30.basename(header)),
|
|
16221
|
+
path30.join(layout2.root, header)
|
|
16104
16222
|
]) : []
|
|
16105
16223
|
]),
|
|
16106
16224
|
userHeaderSearchPaths: settings.userHeaderSearchPaths.map(
|
|
16107
|
-
(directory) =>
|
|
16225
|
+
(directory) => path30.join(layout2.root, directory)
|
|
16108
16226
|
),
|
|
16109
16227
|
searchDirectories: [
|
|
16110
16228
|
...settings.headerSearchPaths,
|
|
16111
16229
|
...settings.frameworkSearchPaths
|
|
16112
|
-
].map((directory) =>
|
|
16230
|
+
].map((directory) => path30.join(layout2.root, directory))
|
|
16113
16231
|
})),
|
|
16114
16232
|
Object.fromEntries(
|
|
16115
16233
|
Object.entries(input.headerAliases ?? {}).map(([alias, file]) => [
|
|
16116
|
-
|
|
16117
|
-
|
|
16234
|
+
path30.join(layout2.root, alias),
|
|
16235
|
+
path30.join(layout2.root, file)
|
|
16118
16236
|
])
|
|
16119
16237
|
)
|
|
16120
16238
|
);
|
|
@@ -16143,16 +16261,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16143
16261
|
for (const [file, contents2] of entries) {
|
|
16144
16262
|
const producers2 = /* @__PURE__ */ new Set();
|
|
16145
16263
|
const source = contents2.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
16146
|
-
for (const
|
|
16147
|
-
/^\s*#\s*(?:include|import)\s*[<"]([^>"]+)[>"]/gm
|
|
16148
|
-
)) {
|
|
16149
|
-
const include = match[1];
|
|
16264
|
+
for (const include of nativeHeaderIncludes(contents2)) {
|
|
16150
16265
|
const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include)?.[1];
|
|
16151
16266
|
if (producer && swiftTargets.has(producer)) producers2.add(producer);
|
|
16152
16267
|
const local = [
|
|
16153
|
-
|
|
16268
|
+
path30.posix.join(path30.posix.dirname(file), include),
|
|
16154
16269
|
`${includes}${include}`,
|
|
16155
|
-
...searchRoots.map((root) =>
|
|
16270
|
+
...searchRoots.map((root) => path30.posix.join(root, include))
|
|
16156
16271
|
].find((candidate) => input.files[candidate] !== void 0);
|
|
16157
16272
|
if (local) {
|
|
16158
16273
|
reverse.set(local, [...reverse.get(local) ?? [], file]);
|
|
@@ -16183,7 +16298,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16183
16298
|
);
|
|
16184
16299
|
const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : entries.some(([file]) => file.endsWith(".swift")) || importedModules.has(swiftTargetModuleName(target.name)) ? settings.publicHeaders : [];
|
|
16185
16300
|
const search = [.../* @__PURE__ */ new Set([...settings?.headerSearchPaths ?? []])].flatMap(
|
|
16186
|
-
(dir) => ["-I",
|
|
16301
|
+
(dir) => ["-I", path30.join(layout2.root, dir)]
|
|
16187
16302
|
);
|
|
16188
16303
|
const toolchainBin = nativeToolchain();
|
|
16189
16304
|
const stageFlags = (flags2, sdkInclude2) => flags2.map(
|
|
@@ -16195,7 +16310,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16195
16310
|
...search,
|
|
16196
16311
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
16197
16312
|
"-F",
|
|
16198
|
-
|
|
16313
|
+
path30.join(layout2.root, dir)
|
|
16199
16314
|
]),
|
|
16200
16315
|
"-I",
|
|
16201
16316
|
headerDirectory
|
|
@@ -16206,7 +16321,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16206
16321
|
...search,
|
|
16207
16322
|
...settings.frameworkSearchPaths.flatMap((dir) => [
|
|
16208
16323
|
"-F",
|
|
16209
|
-
|
|
16324
|
+
path30.join(layout2.root, dir)
|
|
16210
16325
|
]),
|
|
16211
16326
|
"-I",
|
|
16212
16327
|
headerDirectory
|
|
@@ -16216,13 +16331,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16216
16331
|
const flag = settings.importerFlags[index];
|
|
16217
16332
|
if (flag === "-I" || flag === "-iquote") {
|
|
16218
16333
|
const directory = settings.importerFlags[index + 1];
|
|
16219
|
-
if (directory === void 0 || !
|
|
16334
|
+
if (directory === void 0 || !path30.isAbsolute(directory)) {
|
|
16220
16335
|
index++;
|
|
16221
16336
|
continue;
|
|
16222
16337
|
}
|
|
16223
16338
|
}
|
|
16224
16339
|
const joined = /^-(?:I|iquote)(.+)$/.exec(flag);
|
|
16225
|
-
if (joined && !
|
|
16340
|
+
if (joined && !path30.isAbsolute(joined[1])) continue;
|
|
16226
16341
|
kept.push(flag);
|
|
16227
16342
|
}
|
|
16228
16343
|
return [
|
|
@@ -16231,13 +16346,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16231
16346
|
...search,
|
|
16232
16347
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
16233
16348
|
"-F",
|
|
16234
|
-
|
|
16349
|
+
path30.join(layout2.root, dir)
|
|
16235
16350
|
]),
|
|
16236
16351
|
"-I",
|
|
16237
16352
|
headerDirectory
|
|
16238
16353
|
];
|
|
16239
16354
|
})();
|
|
16240
|
-
const sdkInclude =
|
|
16355
|
+
const sdkInclude = path30.join(
|
|
16241
16356
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
16242
16357
|
"darwin/usr/include"
|
|
16243
16358
|
);
|
|
@@ -16252,7 +16367,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16252
16367
|
...dependencyModuleMaps,
|
|
16253
16368
|
...target.defines?.includes(SWIFT_XCODE_BUILD_CONDITION) && !target.defines.includes("SWIFT_PACKAGE") ? ["-USWIFT_PACKAGE"] : []
|
|
16254
16369
|
];
|
|
16255
|
-
const prefixHeader = settings?.prefixHeader ? ["-include",
|
|
16370
|
+
const prefixHeader = settings?.prefixHeader ? ["-include", path30.join(layout2.root, settings.prefixHeader)] : [];
|
|
16256
16371
|
const bundleName = entries.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
|
|
16257
16372
|
target: target.name,
|
|
16258
16373
|
path: target.path,
|
|
@@ -16263,7 +16378,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16263
16378
|
bundles: input.resourceBundles
|
|
16264
16379
|
});
|
|
16265
16380
|
const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
|
|
16266
|
-
const accessorHeader =
|
|
16381
|
+
const accessorHeader = path30.join(
|
|
16267
16382
|
layout2.root,
|
|
16268
16383
|
target.path,
|
|
16269
16384
|
OBJC_RESOURCE_ACCESSOR_HEADER
|
|
@@ -16274,7 +16389,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16274
16389
|
const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
|
|
16275
16390
|
const unitSource = (file) => {
|
|
16276
16391
|
const relative = file.slice(prefix.length);
|
|
16277
|
-
return relative.split("/").some((part) => part.startsWith(".")) ?
|
|
16392
|
+
return relative.split("/").some((part) => part.startsWith(".")) ? path30.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
|
|
16278
16393
|
};
|
|
16279
16394
|
const accessorFlags = accessor ? ["-include", accessorHeader] : [];
|
|
16280
16395
|
const nativeC = !entries.some(([file]) => file.endsWith(".swift"));
|
|
@@ -16304,20 +16419,20 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16304
16419
|
)
|
|
16305
16420
|
].sort();
|
|
16306
16421
|
const topHeaders = settings.publicHeaders.filter(
|
|
16307
|
-
(file) =>
|
|
16422
|
+
(file) => path30.posix.dirname(file) === headerDir
|
|
16308
16423
|
);
|
|
16309
16424
|
if (input.files[custom] !== void 0) {
|
|
16310
16425
|
swiftpmModuleMap = { path: custom, contents: input.files[custom] };
|
|
16311
16426
|
} else if (input.files[umbrella] !== void 0) {
|
|
16312
16427
|
if (siblingDirs.length > 0)
|
|
16313
16428
|
throw new Error(
|
|
16314
|
-
`target ${target.name} has invalid header layout: umbrella header found at '${
|
|
16429
|
+
`target ${target.name} has invalid header layout: umbrella header found at '${path30.join(layout2.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name2) => path30.join(layout2.root, headerDir, name2)).join(", ")}; consider removing them`
|
|
16315
16430
|
);
|
|
16316
16431
|
swiftpmModuleMap = {
|
|
16317
16432
|
path: custom,
|
|
16318
16433
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
16319
16434
|
kind: "header",
|
|
16320
|
-
path:
|
|
16435
|
+
path: path30.join(layout2.root, umbrella)
|
|
16321
16436
|
})
|
|
16322
16437
|
};
|
|
16323
16438
|
} else if (input.files[nestedUmbrella] !== void 0 && siblingDirs.length === 1 && siblingDirs[0] === moduleName && topHeaders.length === 0) {
|
|
@@ -16325,7 +16440,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16325
16440
|
path: custom,
|
|
16326
16441
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
16327
16442
|
kind: "header",
|
|
16328
|
-
path:
|
|
16443
|
+
path: path30.join(layout2.root, nestedUmbrella)
|
|
16329
16444
|
})
|
|
16330
16445
|
};
|
|
16331
16446
|
} else {
|
|
@@ -16333,12 +16448,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16333
16448
|
path: custom,
|
|
16334
16449
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
16335
16450
|
kind: "directory",
|
|
16336
|
-
path:
|
|
16451
|
+
path: path30.join(layout2.root, headerDir)
|
|
16337
16452
|
})
|
|
16338
16453
|
};
|
|
16339
16454
|
}
|
|
16340
16455
|
}
|
|
16341
|
-
const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ??
|
|
16456
|
+
const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? path30.posix.join(
|
|
16342
16457
|
".build",
|
|
16343
16458
|
"peach-objc-originals",
|
|
16344
16459
|
target.name,
|
|
@@ -16346,79 +16461,79 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16346
16461
|
);
|
|
16347
16462
|
const moduleContents = originalModuleMap ? input.files[originalModuleMap[1]] : swiftpmModuleMap?.contents ?? packageModuleMap?.[1] ?? swiftObjCModuleMap(
|
|
16348
16463
|
swiftTargetModuleName(target.name),
|
|
16349
|
-
roots2.map((file) =>
|
|
16464
|
+
roots2.map((file) => path30.join(layout2.root, file)),
|
|
16350
16465
|
submoduleImports.get(swiftTargetModuleName(target.name))
|
|
16351
16466
|
);
|
|
16352
16467
|
if (moduleContents === void 0)
|
|
16353
16468
|
throw new Error("missing original module map " + modulemap);
|
|
16354
|
-
stageTargetFile(target.name,
|
|
16469
|
+
stageTargetFile(target.name, path30.join(layout2.root, modulemap), moduleContents, {
|
|
16355
16470
|
allowExisting: true
|
|
16356
16471
|
});
|
|
16357
16472
|
sourceModuleMaps.set(swiftTargetModuleName(target.name), {
|
|
16358
|
-
path:
|
|
16473
|
+
path: path30.join(layout2.root, modulemap),
|
|
16359
16474
|
contents: moduleContents.toString()
|
|
16360
16475
|
});
|
|
16361
16476
|
if (modulemap.endsWith("/Modules/module.modulemap")) {
|
|
16362
|
-
const framework =
|
|
16477
|
+
const framework = path30.posix.dirname(path30.posix.dirname(modulemap));
|
|
16363
16478
|
for (const [, header] of moduleContents.toString().matchAll(/\bheader\s+"([^"]+)"/g))
|
|
16364
16479
|
for (const folder of ["Headers", "PrivateHeaders"]) {
|
|
16365
|
-
const source = settings.productHeaders[
|
|
16480
|
+
const source = settings.productHeaders[path30.posix.join(framework, folder, header)];
|
|
16366
16481
|
const contents2 = source === void 0 ? void 0 : input.files[source];
|
|
16367
16482
|
if (contents2 !== void 0)
|
|
16368
16483
|
stageTargetFile(
|
|
16369
16484
|
target.name,
|
|
16370
|
-
|
|
16485
|
+
path30.join(layout2.root, path30.posix.dirname(modulemap), folder, header),
|
|
16371
16486
|
contents2,
|
|
16372
16487
|
{ allowExisting: true }
|
|
16373
16488
|
);
|
|
16374
16489
|
}
|
|
16375
16490
|
}
|
|
16376
|
-
if (nativeC &&
|
|
16491
|
+
if (nativeC && path30.posix.basename(modulemap) !== "module.modulemap") {
|
|
16377
16492
|
stageTargetFile(
|
|
16378
16493
|
target.name,
|
|
16379
|
-
|
|
16380
|
-
`extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(
|
|
16494
|
+
path30.join(layout2.root, path30.posix.dirname(modulemap), "module.modulemap"),
|
|
16495
|
+
`extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(path30.join(layout2.root, modulemap))}
|
|
16381
16496
|
`
|
|
16382
16497
|
);
|
|
16383
16498
|
}
|
|
16384
16499
|
const importFlags = [
|
|
16385
16500
|
...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
|
|
16386
|
-
"-fmodule-map-file=" +
|
|
16501
|
+
"-fmodule-map-file=" + path30.join(layout2.root, modulemap),
|
|
16387
16502
|
...dependencyModuleMaps
|
|
16388
16503
|
];
|
|
16389
16504
|
const groups = /* @__PURE__ */ new Map();
|
|
16390
16505
|
for (const [file, contents2] of nativeUnits) {
|
|
16391
16506
|
const origin = settings?.sourceDirectories[file];
|
|
16392
16507
|
if (origin) {
|
|
16393
|
-
const original =
|
|
16394
|
-
|
|
16508
|
+
const original = path30.join(layout2.root, origin, path30.posix.basename(file));
|
|
16509
|
+
mkdirSync8(path30.dirname(original), { recursive: true });
|
|
16395
16510
|
stageTargetFile(target.name, original, contents2, { allowExisting: true });
|
|
16396
16511
|
}
|
|
16397
16512
|
const source = unitSource(file);
|
|
16398
16513
|
if (source !== file.slice(prefix.length))
|
|
16399
16514
|
stageTargetFile(
|
|
16400
16515
|
target.name,
|
|
16401
|
-
|
|
16516
|
+
path30.join(layout2.root, target.path, source),
|
|
16402
16517
|
contents2,
|
|
16403
16518
|
{
|
|
16404
16519
|
allowExisting: true
|
|
16405
16520
|
}
|
|
16406
16521
|
);
|
|
16407
|
-
const stagedDir =
|
|
16522
|
+
const stagedDir = path30.posix.dirname(file);
|
|
16408
16523
|
const quoteDirs = [
|
|
16409
16524
|
...stagedDir !== "." ? [stagedDir] : [],
|
|
16410
16525
|
...origin && origin !== stagedDir ? [origin] : []
|
|
16411
16526
|
];
|
|
16412
16527
|
const quoteFlags = quoteDirs.flatMap((dir) => [
|
|
16413
16528
|
"-iquote",
|
|
16414
|
-
|
|
16529
|
+
path30.join(layout2.root, dir)
|
|
16415
16530
|
]);
|
|
16416
16531
|
const perFile = [
|
|
16417
16532
|
...file.endsWith(".c") && swiftWholeFileArm64Guard(contents2) ? ["-D__arm64__=1"] : [],
|
|
16418
16533
|
.../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
|
|
16419
16534
|
...stageFlags(
|
|
16420
16535
|
settings?.fileFlags[file] ?? [],
|
|
16421
|
-
|
|
16536
|
+
path30.join(
|
|
16422
16537
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
16423
16538
|
"darwin/usr/include"
|
|
16424
16539
|
)
|
|
@@ -16426,7 +16541,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16426
16541
|
];
|
|
16427
16542
|
const cxx = /\.(?:cc|cpp|cxx|mm)$/.test(file);
|
|
16428
16543
|
const moduleFlag = perFile.some((flag) => flag.startsWith("-fmodule-name=")) ? [] : [`-fmodule-name=${swiftTargetModuleName(target.name)}`];
|
|
16429
|
-
const identity =
|
|
16544
|
+
const identity = createHash15("sha256").update(
|
|
16430
16545
|
JSON.stringify([
|
|
16431
16546
|
cxx,
|
|
16432
16547
|
quoteFlags,
|
|
@@ -16435,12 +16550,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16435
16550
|
])
|
|
16436
16551
|
).digest("hex").slice(0, 12);
|
|
16437
16552
|
const name2 = `${target.name}${nativeC ? "Native" : "Swift"}Implementation_${identity}`;
|
|
16438
|
-
const groupPath =
|
|
16439
|
-
const canonicalTargetPath =
|
|
16553
|
+
const groupPath = path30.posix.join("PeachNativeSources", name2);
|
|
16554
|
+
const canonicalTargetPath = path30.posix.join("/peach/build", target.path);
|
|
16440
16555
|
const sourceIdentity = [
|
|
16441
|
-
`-ffile-prefix-map=${
|
|
16556
|
+
`-ffile-prefix-map=${path30.join(layout2.root, groupPath)}=${canonicalTargetPath}`,
|
|
16442
16557
|
...nativeToolset ? [
|
|
16443
|
-
`-ffile-prefix-map=${
|
|
16558
|
+
`-ffile-prefix-map=${path30.posix.join("/peach/build", groupPath)}=${canonicalTargetPath}`
|
|
16444
16559
|
] : []
|
|
16445
16560
|
];
|
|
16446
16561
|
const group = groups.get(identity) ?? {
|
|
@@ -16464,7 +16579,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16464
16579
|
...accessorFlags,
|
|
16465
16580
|
...stageFlags(
|
|
16466
16581
|
cxx ? settings.cxxFlags : [],
|
|
16467
|
-
|
|
16582
|
+
path30.join(
|
|
16468
16583
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
16469
16584
|
"darwin/usr/include"
|
|
16470
16585
|
)
|
|
@@ -16475,12 +16590,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16475
16590
|
};
|
|
16476
16591
|
stageTargetFile(
|
|
16477
16592
|
target.name,
|
|
16478
|
-
|
|
16593
|
+
path30.join(layout2.root, group.path, source),
|
|
16479
16594
|
contents2
|
|
16480
16595
|
);
|
|
16481
16596
|
stageTargetFile(
|
|
16482
16597
|
target.name,
|
|
16483
|
-
|
|
16598
|
+
path30.join(layout2.root, group.path, "include/module.modulemap"),
|
|
16484
16599
|
`module ${swiftTargetModuleName(group.name)} { export * }
|
|
16485
16600
|
`,
|
|
16486
16601
|
{ allowExisting: true }
|
|
@@ -16492,7 +16607,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16492
16607
|
stageTargetFile(target.name, accessorHeader, accessor.header);
|
|
16493
16608
|
stageTargetFile(
|
|
16494
16609
|
target.name,
|
|
16495
|
-
|
|
16610
|
+
path30.join(layout2.root, accessorUnit),
|
|
16496
16611
|
accessor.body
|
|
16497
16612
|
);
|
|
16498
16613
|
}
|
|
@@ -16507,7 +16622,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16507
16622
|
].sort();
|
|
16508
16623
|
native.set(target.name, {
|
|
16509
16624
|
path: target.path,
|
|
16510
|
-
includeDirectory:
|
|
16625
|
+
includeDirectory: path30.dirname(path30.join(layout2.root, modulemap)),
|
|
16511
16626
|
importFlags,
|
|
16512
16627
|
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
16513
16628
|
lateSources: implementations.flatMap((group) => group.sources),
|
|
@@ -16530,23 +16645,23 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16530
16645
|
throw new Error(`original module map declares no module: ${modulemap}`);
|
|
16531
16646
|
stageTargetFile(
|
|
16532
16647
|
target.name,
|
|
16533
|
-
|
|
16534
|
-
`extern module ${exportedModule} ${JSON.stringify(
|
|
16648
|
+
path30.join(layout2.root, owner.path, "include/module.modulemap"),
|
|
16649
|
+
`extern module ${exportedModule} ${JSON.stringify(path30.join(layout2.root, modulemap))}
|
|
16535
16650
|
`,
|
|
16536
16651
|
{ allowExisting: true }
|
|
16537
16652
|
);
|
|
16538
16653
|
}
|
|
16539
16654
|
continue;
|
|
16540
16655
|
}
|
|
16541
|
-
const implementationHeaders =
|
|
16656
|
+
const implementationHeaders = path30.posix.join(
|
|
16542
16657
|
".build",
|
|
16543
16658
|
"peach-objc-implementations",
|
|
16544
16659
|
target.name
|
|
16545
16660
|
);
|
|
16546
|
-
const include =
|
|
16661
|
+
const include = path30.join(layout2.root, implementationHeaders);
|
|
16547
16662
|
stageTargetFile(
|
|
16548
16663
|
target.name,
|
|
16549
|
-
|
|
16664
|
+
path30.join(include, "module.modulemap"),
|
|
16550
16665
|
`module ${target.name}ImplementationDeclarations { export * }
|
|
16551
16666
|
`
|
|
16552
16667
|
);
|
|
@@ -16556,7 +16671,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16556
16671
|
includeDirectory: include,
|
|
16557
16672
|
importFlags,
|
|
16558
16673
|
swiftFlags: [
|
|
16559
|
-
...settings.bridgingHeader ? ["-import-objc-header",
|
|
16674
|
+
...settings.bridgingHeader ? ["-import-objc-header", path30.join(layout2.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
|
|
16560
16675
|
...importFlags.flatMap((flag) => ["-Xcc", flag])
|
|
16561
16676
|
],
|
|
16562
16677
|
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
@@ -16586,7 +16701,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16586
16701
|
}
|
|
16587
16702
|
native.set(target.name, {
|
|
16588
16703
|
path: target.path,
|
|
16589
|
-
includeDirectory:
|
|
16704
|
+
includeDirectory: path30.join(layout2.root, includes),
|
|
16590
16705
|
sources: units.map(([file]) => file.slice(prefix.length)),
|
|
16591
16706
|
lateSources: late.map(([file]) => file.slice(prefix.length)),
|
|
16592
16707
|
...late.length > 0 ? {
|
|
@@ -16600,7 +16715,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16600
16715
|
});
|
|
16601
16716
|
if (late.length > 0)
|
|
16602
16717
|
files.set(
|
|
16603
|
-
|
|
16718
|
+
path30.join(layout2.root, target.path, "PeachSwiftImplementation/module.modulemap"),
|
|
16604
16719
|
`module ${swiftTargetModuleName(`${target.name}SwiftImplementation`)} { export * }
|
|
16605
16720
|
`
|
|
16606
16721
|
);
|
|
@@ -16612,7 +16727,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16612
16727
|
([file]) => file.startsWith(includes) && /\.(?:h|hpp|hh|hxx)$/.test(file) && consumers.get(file).size === 0
|
|
16613
16728
|
);
|
|
16614
16729
|
files.set(
|
|
16615
|
-
|
|
16730
|
+
path30.join(layout2.root, includes, "module.modulemap"),
|
|
16616
16731
|
[
|
|
16617
16732
|
`module ${target.name} {`,
|
|
16618
16733
|
...roots.map(
|
|
@@ -16627,14 +16742,14 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16627
16742
|
for (const map of generatedModuleMaps)
|
|
16628
16743
|
if (files.has(map.published) || Object.hasOwn(
|
|
16629
16744
|
input.files,
|
|
16630
|
-
|
|
16745
|
+
path30.relative(layout2.root, map.published).split(path30.sep).join(path30.posix.sep)
|
|
16631
16746
|
))
|
|
16632
16747
|
writeBuildFile(
|
|
16633
16748
|
map.output,
|
|
16634
16749
|
`extern module ${map.module} ${JSON.stringify(map.published)}
|
|
16635
16750
|
`
|
|
16636
16751
|
);
|
|
16637
|
-
if (native.size > 0)
|
|
16752
|
+
if (native.size > 0) mkdirSync8(headerDirectory, { recursive: true });
|
|
16638
16753
|
const headerAliasFlags = Object.keys(input.headerAliases ?? {}).length > 0 ? ["-ivfsoverlay", headerSearch.files[0]] : [];
|
|
16639
16754
|
const nativeHeaderFlags = [...headerAliasFlags];
|
|
16640
16755
|
const nativeSwiftHeaderMaps = /* @__PURE__ */ new Map();
|
|
@@ -16656,10 +16771,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16656
16771
|
[...native.values()].flatMap((value) => value.late?.producers ?? [])
|
|
16657
16772
|
)) {
|
|
16658
16773
|
files.set(
|
|
16659
|
-
|
|
16774
|
+
path30.join(headerDirectory, name2, name2 + "-Swift.h"),
|
|
16660
16775
|
'#include "../' + name2 + '-Swift.h"\n'
|
|
16661
16776
|
);
|
|
16662
|
-
const modulemap =
|
|
16777
|
+
const modulemap = path30.join(
|
|
16663
16778
|
layout2.root,
|
|
16664
16779
|
".build",
|
|
16665
16780
|
"peach-objc-swift-headers",
|
|
@@ -16669,7 +16784,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16669
16784
|
const moduleName = swiftTargetModuleName(name2);
|
|
16670
16785
|
const originalMap = originalMaps.get(moduleName);
|
|
16671
16786
|
const stagedMap = sourceModuleMaps.get(moduleName);
|
|
16672
|
-
const originalPath = stagedMap?.path ?? (originalMap ?
|
|
16787
|
+
const originalPath = stagedMap?.path ?? (originalMap ? path30.join(layout2.root, originalMap) : void 0);
|
|
16673
16788
|
const originalContents = stagedMap?.contents ?? (originalMap && input.files[originalMap]);
|
|
16674
16789
|
const originalTokens = originalContents ? moduleMapTokens(originalContents) : [];
|
|
16675
16790
|
if (originalPath && originalTokens.some(
|
|
@@ -16683,29 +16798,29 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16683
16798
|
modulemap,
|
|
16684
16799
|
originalPath ? `extern module ${moduleName} ${JSON.stringify(originalPath)}
|
|
16685
16800
|
module ${moduleName}.Swift {
|
|
16686
|
-
header ${JSON.stringify(
|
|
16801
|
+
header ${JSON.stringify(path30.join(headerDirectory, name2 + "-Swift.h"))}
|
|
16687
16802
|
requires objc
|
|
16688
16803
|
}
|
|
16689
16804
|
` : swiftObjCModuleMap(
|
|
16690
16805
|
moduleName,
|
|
16691
|
-
(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) =>
|
|
16806
|
+
(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) => path30.join(layout2.root, header)),
|
|
16692
16807
|
submoduleImports.get(moduleName),
|
|
16693
|
-
|
|
16808
|
+
path30.join(headerDirectory, name2 + "-Swift.h")
|
|
16694
16809
|
)
|
|
16695
16810
|
);
|
|
16696
16811
|
nativeHeaderFlags.push("-fmodule-map-file=" + modulemap);
|
|
16697
16812
|
nativeSwiftHeaderMaps.set(name2, modulemap);
|
|
16698
16813
|
}
|
|
16699
|
-
const modulePlan =
|
|
16814
|
+
const modulePlan = createHash15("sha256").update(
|
|
16700
16815
|
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
16701
16816
|
);
|
|
16702
16817
|
if (!distribution) {
|
|
16703
|
-
modulePlan.update(
|
|
16818
|
+
modulePlan.update(readFileSync18(path30.join(moduleRoot, "Package.swift")));
|
|
16704
16819
|
}
|
|
16705
16820
|
modulePlan.update(
|
|
16706
16821
|
Object.keys(input.files).filter((file) => file.endsWith(".swift")).sort().join("\n")
|
|
16707
16822
|
);
|
|
16708
|
-
const resourcePlan =
|
|
16823
|
+
const resourcePlan = createHash15("sha256").update(
|
|
16709
16824
|
JSON.stringify(
|
|
16710
16825
|
resourceTargets.filter((target) => target.resources).map((target) => [
|
|
16711
16826
|
target.name,
|
|
@@ -16755,7 +16870,7 @@ module ${moduleName}.Swift {
|
|
|
16755
16870
|
(target) => {
|
|
16756
16871
|
const native2 = input.nativeTargets?.find(({ name: name2 }) => name2 === target.name);
|
|
16757
16872
|
if (native2) return native2.publicHeaders.map((file) => input.files[file] ?? "");
|
|
16758
|
-
const directory =
|
|
16873
|
+
const directory = path30.posix.join(
|
|
16759
16874
|
target.path,
|
|
16760
16875
|
target.publicHeadersPath ?? "include"
|
|
16761
16876
|
);
|
|
@@ -16791,7 +16906,7 @@ module ${moduleName}.Swift {
|
|
|
16791
16906
|
`;
|
|
16792
16907
|
} else if (mains.length === 0) {
|
|
16793
16908
|
const procedural = entries.filter(
|
|
16794
|
-
([file, source]) =>
|
|
16909
|
+
([file, source]) => path30.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
|
|
16795
16910
|
);
|
|
16796
16911
|
const wrapped = procedural.length === 1 ? wrapUIApplicationMainEntry(procedural[0][1]) : null;
|
|
16797
16912
|
if (wrapped) {
|
|
@@ -16812,7 +16927,7 @@ module ${moduleName}.Swift {
|
|
|
16812
16927
|
`mixed executable ${target.name} requires one typed Swift application entry`
|
|
16813
16928
|
);
|
|
16814
16929
|
files.set(
|
|
16815
|
-
|
|
16930
|
+
path30.join(layout2.root, nativeMains[0][0]),
|
|
16816
16931
|
neutralizedNativeMain(nativeMains[0][1])
|
|
16817
16932
|
);
|
|
16818
16933
|
nativeEntry = true;
|
|
@@ -16824,9 +16939,9 @@ module ${moduleName}.Swift {
|
|
|
16824
16939
|
}
|
|
16825
16940
|
if (!nativeEntry) {
|
|
16826
16941
|
compiled.set(entryFile, entrySource);
|
|
16827
|
-
if (
|
|
16828
|
-
const libraryEntry =
|
|
16829
|
-
|
|
16942
|
+
if (path30.basename(entryFile) === "main.swift") {
|
|
16943
|
+
const libraryEntry = path30.posix.join(
|
|
16944
|
+
path30.posix.dirname(entryFile),
|
|
16830
16945
|
"PeachApplicationEntry.generated.swift"
|
|
16831
16946
|
);
|
|
16832
16947
|
if (Object.hasOwn(input.files, libraryEntry))
|
|
@@ -16850,7 +16965,7 @@ module ${moduleName}.Swift {
|
|
|
16850
16965
|
exclude: []
|
|
16851
16966
|
});
|
|
16852
16967
|
files.set(
|
|
16853
|
-
|
|
16968
|
+
path30.join(layout2.root, `PeachApplication/${name2}/Entry.swift`),
|
|
16854
16969
|
!nativeEntry ? `import ${swiftTargetModuleName(target.name)}
|
|
16855
16970
|
@main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }
|
|
16856
16971
|
` : `import ${swiftTargetModuleName(target.name)}
|
|
@@ -16882,7 +16997,7 @@ module ${moduleName}.Swift {
|
|
|
16882
16997
|
);
|
|
16883
16998
|
if (nativeFlags) {
|
|
16884
16999
|
const toolchainBin = nativeToolchain();
|
|
16885
|
-
const headers =
|
|
17000
|
+
const headers = path30.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
|
|
16886
17001
|
const dependencies2 = swiftTargetDependencies(input.files, targets);
|
|
16887
17002
|
const reachesNative = (name2, seen = /* @__PURE__ */ new Set()) => {
|
|
16888
17003
|
if (native.has(name2)) return true;
|
|
@@ -16927,10 +17042,10 @@ module ${moduleName}.Swift {
|
|
|
16927
17042
|
if (targets.length === 0 && !prebuilt) {
|
|
16928
17043
|
for (const [file, contents2] of Object.entries(input.files)) {
|
|
16929
17044
|
if (file === "Package.swift") continue;
|
|
16930
|
-
files.set(
|
|
17045
|
+
files.set(path30.join(layout2.sources, file), compiled.get(file) ?? contents2);
|
|
16931
17046
|
}
|
|
16932
|
-
let manifest2 =
|
|
16933
|
-
|
|
17047
|
+
let manifest2 = readFileSync18(
|
|
17048
|
+
path30.join(moduleRoot, "scripts/contrast-app-Package.swift"),
|
|
16934
17049
|
"utf8"
|
|
16935
17050
|
).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
|
|
16936
17051
|
const reactor = ` ${REACTOR_FLAG}`;
|
|
@@ -16977,35 +17092,35 @@ module ${moduleName}.Swift {
|
|
|
16977
17092
|
[anchor, ...games.map((name2) => `${gameProduct(name2)},`)].join("\n ")
|
|
16978
17093
|
);
|
|
16979
17094
|
}
|
|
16980
|
-
files.set(
|
|
17095
|
+
files.set(path30.join(layout2.root, "Package.swift"), manifest2 + moduleFiles);
|
|
16981
17096
|
} else {
|
|
16982
17097
|
const base = layout2.multi ? layout2.root : layout2.sources;
|
|
16983
17098
|
const libraries = /* @__PURE__ */ new Map();
|
|
16984
|
-
const binaryModules =
|
|
17099
|
+
const binaryModules = path30.join(layout2.root, ".peach-binary-modules");
|
|
16985
17100
|
for (const [name2, data] of Object.entries(input.binaryModules ?? {})) {
|
|
16986
17101
|
if (!/^[A-Za-z_]\w*$/.test(name2) || !input.libraries?.[name2])
|
|
16987
17102
|
throw new Error(`invalid native Swift module ${name2}: its library is required`);
|
|
16988
17103
|
files.set(
|
|
16989
|
-
|
|
17104
|
+
path30.join(binaryModules, `${name2}.swiftmodule`),
|
|
16990
17105
|
Buffer.from(data, "base64")
|
|
16991
17106
|
);
|
|
16992
17107
|
}
|
|
16993
17108
|
for (const [target, data] of Object.entries(input.libraries ?? {})) {
|
|
16994
17109
|
const bytes = Buffer.from(data, "base64");
|
|
16995
|
-
const digest =
|
|
16996
|
-
const file =
|
|
17110
|
+
const digest = createHash15("sha256").update(bytes).digest("hex");
|
|
17111
|
+
const file = path30.join(layout2.root, ".peach-libraries", `lib${target}-${digest}.a`);
|
|
16997
17112
|
files.set(file, bytes);
|
|
16998
17113
|
libraries.set(target, file);
|
|
16999
17114
|
}
|
|
17000
17115
|
for (const [file, contents2] of Object.entries(input.files)) {
|
|
17001
17116
|
if (file === "Package.swift") continue;
|
|
17002
|
-
const destination =
|
|
17117
|
+
const destination = path30.join(base, libraryEntryFiles.get(file) ?? file);
|
|
17003
17118
|
const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
|
|
17004
17119
|
const localInterface = interfaceModule && swiftTargets.has(interfaceModule) ? `#include ${JSON.stringify(
|
|
17005
|
-
|
|
17006
|
-
|
|
17007
|
-
|
|
17008
|
-
).split(
|
|
17120
|
+
path30.relative(
|
|
17121
|
+
path30.dirname(destination),
|
|
17122
|
+
path30.join(headerDirectory, `${interfaceModule}-Swift.h`)
|
|
17123
|
+
).split(path30.sep).join("/")
|
|
17009
17124
|
)}
|
|
17010
17125
|
` : void 0;
|
|
17011
17126
|
files.set(
|
|
@@ -17013,10 +17128,10 @@ module ${moduleName}.Swift {
|
|
|
17013
17128
|
localInterface ?? compiled.get(file) ?? files.get(destination) ?? (interfaceModule && moduleInterface(interfaceModule)?.header) ?? contents2
|
|
17014
17129
|
);
|
|
17015
17130
|
}
|
|
17016
|
-
const
|
|
17131
|
+
const manifestTargets2 = targets.length > 0 ? targets : [
|
|
17017
17132
|
{
|
|
17018
17133
|
name: "App",
|
|
17019
|
-
path:
|
|
17134
|
+
path: path30.relative(layout2.root, layout2.sources).split(path30.sep).join("/"),
|
|
17020
17135
|
executable: true,
|
|
17021
17136
|
languageMode: 5,
|
|
17022
17137
|
mainActorIsolation: false,
|
|
@@ -17026,11 +17141,11 @@ module ${moduleName}.Swift {
|
|
|
17026
17141
|
const reachesFrameworks = !distribution || swiftImportedModules.has("Foundation") || Object.entries(input.files).some(
|
|
17027
17142
|
([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
|
|
17028
17143
|
) || [...importedModules].some(
|
|
17029
|
-
(name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2) && !(clangImportedModules.has(name2) && !swiftImportedModules.has(name2) &&
|
|
17030
|
-
|
|
17144
|
+
(name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2) && !(clangImportedModules.has(name2) && !swiftImportedModules.has(name2) && existsSync7(
|
|
17145
|
+
path30.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name2)
|
|
17031
17146
|
))
|
|
17032
17147
|
);
|
|
17033
|
-
const frameworkLink = prebuilt ?
|
|
17148
|
+
const frameworkLink = prebuilt ? path30.join(layout2.root, ".peach-framework-objects.rsp") : void 0;
|
|
17034
17149
|
if (prebuilt && frameworkLink) {
|
|
17035
17150
|
const quote = (object3) => `"${object3.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
17036
17151
|
files.set(
|
|
@@ -17046,10 +17161,10 @@ module ${moduleName}.Swift {
|
|
|
17046
17161
|
}
|
|
17047
17162
|
const moduleSiblings = swiftTargetDependencies(
|
|
17048
17163
|
input.files,
|
|
17049
|
-
layout2.multi ?
|
|
17164
|
+
layout2.multi ? manifestTargets2 : manifestTargets2.map((target) => ({ ...target, path: "." }))
|
|
17050
17165
|
);
|
|
17051
|
-
if (namesLibxml2(input) && !
|
|
17052
|
-
const executable =
|
|
17166
|
+
if (namesLibxml2(input) && !manifestTargets2.some((target) => target.name === "libxml2")) {
|
|
17167
|
+
const executable = manifestTargets2.find((target) => target.executable);
|
|
17053
17168
|
if (executable) {
|
|
17054
17169
|
const reached = moduleSiblings.get(executable.name) ?? [];
|
|
17055
17170
|
if (!reached.includes("libxml2"))
|
|
@@ -17057,15 +17172,15 @@ module ${moduleName}.Swift {
|
|
|
17057
17172
|
}
|
|
17058
17173
|
}
|
|
17059
17174
|
files.set(
|
|
17060
|
-
|
|
17175
|
+
path30.join(layout2.root, "Package.swift"),
|
|
17061
17176
|
emitSwiftPackageManifest({
|
|
17062
17177
|
root: layout2.root,
|
|
17063
17178
|
files,
|
|
17064
|
-
targets:
|
|
17179
|
+
targets: manifestTargets2.map((target) => ({
|
|
17065
17180
|
...target,
|
|
17066
17181
|
sources: target.sources?.map((source) => {
|
|
17067
|
-
const entry = libraryEntryFiles.get(
|
|
17068
|
-
return entry ?
|
|
17182
|
+
const entry = libraryEntryFiles.get(path30.posix.join(target.path, source));
|
|
17183
|
+
return entry ? path30.posix.relative(target.path, entry) : source;
|
|
17069
17184
|
})
|
|
17070
17185
|
})),
|
|
17071
17186
|
packages,
|
|
@@ -17099,7 +17214,7 @@ module ${moduleName}.Swift {
|
|
|
17099
17214
|
),
|
|
17100
17215
|
...reachesFrameworks ? {
|
|
17101
17216
|
distributionLink: {
|
|
17102
|
-
path:
|
|
17217
|
+
path: path30.join(layout2.root, ".peach-distribution-objects.rsp"),
|
|
17103
17218
|
files
|
|
17104
17219
|
}
|
|
17105
17220
|
} : {},
|
|
@@ -17120,14 +17235,14 @@ module ${moduleName}.Swift {
|
|
|
17120
17235
|
for (const [file, bytes] of Object.entries(input.packageFiles ?? {})) {
|
|
17121
17236
|
const contents2 = Buffer.from(bytes, "base64");
|
|
17122
17237
|
files.set(
|
|
17123
|
-
|
|
17238
|
+
path30.join(layout2.root, file),
|
|
17124
17239
|
file.endsWith(".swift") && !/(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file) ? withPreconcurrencyFoundationModules(
|
|
17125
17240
|
swiftPackageSourceAsIOS(contents2.toString("utf8"))
|
|
17126
17241
|
) : contents2
|
|
17127
17242
|
);
|
|
17128
17243
|
}
|
|
17129
17244
|
for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
|
|
17130
|
-
const destination =
|
|
17245
|
+
const destination = path30.join(layout2.root, file);
|
|
17131
17246
|
if (files.has(destination)) continue;
|
|
17132
17247
|
files.set(destination, Buffer.from(bytes, "base64"));
|
|
17133
17248
|
}
|
|
@@ -17136,13 +17251,13 @@ module ${moduleName}.Swift {
|
|
|
17136
17251
|
const nativeToolsetFlags = [
|
|
17137
17252
|
...headerAliasFlags,
|
|
17138
17253
|
...native.size > 0 ? [
|
|
17139
|
-
"-fmodule-map-file=" +
|
|
17254
|
+
"-fmodule-map-file=" + path30.join(
|
|
17140
17255
|
swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
|
|
17141
17256
|
"darwin/wasm/include/module.modulemap"
|
|
17142
17257
|
)
|
|
17143
17258
|
] : []
|
|
17144
17259
|
];
|
|
17145
|
-
const clangWrapper2 =
|
|
17260
|
+
const clangWrapper2 = path30.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
|
|
17146
17261
|
files.set(
|
|
17147
17262
|
clangWrapper2,
|
|
17148
17263
|
[
|
|
@@ -17183,21 +17298,21 @@ module ${moduleName}.Swift {
|
|
|
17183
17298
|
" done",
|
|
17184
17299
|
"fi",
|
|
17185
17300
|
'if [ -n "$name" ] && [ -z "$explicit" ]; then',
|
|
17186
|
-
` exec '${
|
|
17301
|
+
` exec '${path30.join(nativeToolchain(), "clang")}' "-fmodule-name=$name" "$@"`,
|
|
17187
17302
|
"fi",
|
|
17188
|
-
`exec '${
|
|
17303
|
+
`exec '${path30.join(nativeToolchain(), "clang")}' "$@"`,
|
|
17189
17304
|
""
|
|
17190
17305
|
].join("\n")
|
|
17191
17306
|
);
|
|
17192
17307
|
files.set(
|
|
17193
|
-
|
|
17308
|
+
path30.join(layout2.root, ".peach-target-toolset.json"),
|
|
17194
17309
|
JSON.stringify({
|
|
17195
17310
|
schemaVersion: "1.0",
|
|
17196
17311
|
cCompiler: {
|
|
17197
17312
|
extraCLIOptions: [
|
|
17198
17313
|
...nativeToolsetFlags,
|
|
17199
17314
|
"-fmodules",
|
|
17200
|
-
`-fmodules-cache-path=${
|
|
17315
|
+
`-fmodules-cache-path=${path30.join(layout2.root, ".build", "ModuleCache")}`
|
|
17201
17316
|
]
|
|
17202
17317
|
},
|
|
17203
17318
|
...nativeToolsetFlags.length > 0 ? { cxxCompiler: { extraCLIOptions: nativeToolsetFlags } } : {},
|
|
@@ -17207,12 +17322,12 @@ module ${moduleName}.Swift {
|
|
|
17207
17322
|
distribution || prebuilt ? "-Isystem" : "-I",
|
|
17208
17323
|
distribution ? providedModulesPath(
|
|
17209
17324
|
layout2.root,
|
|
17210
|
-
|
|
17325
|
+
path30.join(moduleRoot, "modules"),
|
|
17211
17326
|
moduleExcludes
|
|
17212
|
-
) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) :
|
|
17327
|
+
) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) : path30.join(layout2.root, ".build", WASM_TRIPLE, "release", "Modules"),
|
|
17213
17328
|
...distribution ? distributionClangModuleOptions(
|
|
17214
17329
|
layout2.root,
|
|
17215
|
-
|
|
17330
|
+
path30.join(moduleRoot, "modules")
|
|
17216
17331
|
) : [],
|
|
17217
17332
|
...prebuilt?.moduleMaps.flatMap((map) => [
|
|
17218
17333
|
"-Xcc",
|
|
@@ -17242,9 +17357,9 @@ module ${moduleName}.Swift {
|
|
|
17242
17357
|
throw new Error(
|
|
17243
17358
|
`swift resource target ${target.name} has no matching bundle assignment`
|
|
17244
17359
|
);
|
|
17245
|
-
const directory = layout2.multi ?
|
|
17360
|
+
const directory = layout2.multi ? path30.join(layout2.root, target.path) : layout2.sources;
|
|
17246
17361
|
files.set(
|
|
17247
|
-
|
|
17362
|
+
path30.join(directory, "ResourceBundleAccessor.generated.swift"),
|
|
17248
17363
|
[
|
|
17249
17364
|
"import Foundation",
|
|
17250
17365
|
"",
|
|
@@ -17261,7 +17376,7 @@ module ${moduleName}.Swift {
|
|
|
17261
17376
|
}
|
|
17262
17377
|
for (const [file, source] of compiled)
|
|
17263
17378
|
if (!Object.hasOwn(input.files, file))
|
|
17264
|
-
files.set(
|
|
17379
|
+
files.set(path30.join(layout2.multi ? layout2.root : layout2.sources, file), source);
|
|
17265
17380
|
const producers = [
|
|
17266
17381
|
.../* @__PURE__ */ new Set([...[...native.values()].flatMap((value) => value.late?.producers ?? [])])
|
|
17267
17382
|
];
|
|
@@ -17274,14 +17389,15 @@ module ${moduleName}.Swift {
|
|
|
17274
17389
|
generatedOwners.set(group.name, owner);
|
|
17275
17390
|
}
|
|
17276
17391
|
}
|
|
17277
|
-
const manifestPath =
|
|
17392
|
+
const manifestPath = path30.join(layout2.root, "Package.swift");
|
|
17278
17393
|
let manifest = files.get(manifestPath).toString();
|
|
17394
|
+
const manifestTargets = swiftManifestTargets(manifest, [], (file) => {
|
|
17395
|
+
const contents2 = files.get(file);
|
|
17396
|
+
if (contents2 === void 0) throw new Error(`missing compiler arguments ${file}`);
|
|
17397
|
+
return contents2.toString();
|
|
17398
|
+
});
|
|
17279
17399
|
const dependencies = new Map(
|
|
17280
|
-
|
|
17281
|
-
const contents2 = files.get(file);
|
|
17282
|
-
if (contents2 === void 0) throw new Error(`missing compiler arguments ${file}`);
|
|
17283
|
-
return contents2.toString();
|
|
17284
|
-
}).map((target) => [
|
|
17400
|
+
manifestTargets.map((target) => [
|
|
17285
17401
|
target.name,
|
|
17286
17402
|
(target.dependencies ?? []).flatMap(
|
|
17287
17403
|
(dependency) => dependency.kind === "target" ? [dependency.name] : []
|
|
@@ -17289,6 +17405,62 @@ module ${moduleName}.Swift {
|
|
|
17289
17405
|
])
|
|
17290
17406
|
);
|
|
17291
17407
|
const producerSet = /* @__PURE__ */ new Set([...Object.keys(nativeHeaderDeclarations), ...producers]);
|
|
17408
|
+
let headerCompiler = allowHeaderCompiler && packages.size === 0 && producerSet.size > 0;
|
|
17409
|
+
if (headerCompiler) {
|
|
17410
|
+
const clang = new Set(
|
|
17411
|
+
manifestTargets.filter(
|
|
17412
|
+
(target) => target.systemLibrary || !swiftTargets.has(target.name) && native.has(target.name)
|
|
17413
|
+
).map(({ name: name2 }) => name2)
|
|
17414
|
+
);
|
|
17415
|
+
const headers = swiftHeaderDependencies(
|
|
17416
|
+
layout2.root,
|
|
17417
|
+
files,
|
|
17418
|
+
manifestTargets,
|
|
17419
|
+
nativeTargets,
|
|
17420
|
+
producerSet,
|
|
17421
|
+
input.headerAliases ?? {}
|
|
17422
|
+
);
|
|
17423
|
+
const nativeEdges = /* @__PURE__ */ new Map();
|
|
17424
|
+
const dependsOn = (from, to, seen = /* @__PURE__ */ new Set()) => {
|
|
17425
|
+
if (from === to) return true;
|
|
17426
|
+
if (seen.has(from)) return false;
|
|
17427
|
+
seen.add(from);
|
|
17428
|
+
return [...dependencies.get(from) ?? [], ...nativeEdges.get(from) ?? []].some(
|
|
17429
|
+
(dependency) => dependsOn(dependency, to, seen)
|
|
17430
|
+
);
|
|
17431
|
+
};
|
|
17432
|
+
for (const target of manifestTargets) {
|
|
17433
|
+
if (target.systemLibrary) continue;
|
|
17434
|
+
const required = new Set(headers.get(target.name));
|
|
17435
|
+
const visited = /* @__PURE__ */ new Set();
|
|
17436
|
+
const imports = (name2) => {
|
|
17437
|
+
if (!clang.has(name2) || visited.has(name2)) return;
|
|
17438
|
+
visited.add(name2);
|
|
17439
|
+
for (const header of headers.get(name2) ?? []) required.add(header);
|
|
17440
|
+
for (const dependency of dependencies.get(name2) ?? []) imports(dependency);
|
|
17441
|
+
};
|
|
17442
|
+
for (const dependency of dependencies.get(target.name) ?? []) imports(dependency);
|
|
17443
|
+
for (const producer of required) {
|
|
17444
|
+
if (dependsOn(target.name, producer)) continue;
|
|
17445
|
+
if (dependsOn(producer, target.name)) {
|
|
17446
|
+
headerCompiler = false;
|
|
17447
|
+
break;
|
|
17448
|
+
}
|
|
17449
|
+
const edges = nativeEdges.get(target.name) ?? [];
|
|
17450
|
+
edges.push(producer);
|
|
17451
|
+
nativeEdges.set(target.name, edges);
|
|
17452
|
+
}
|
|
17453
|
+
if (!headerCompiler) break;
|
|
17454
|
+
}
|
|
17455
|
+
if (headerCompiler)
|
|
17456
|
+
for (const [target, producers2] of nativeEdges) {
|
|
17457
|
+
const additions = producers2.map((producer) => `.target(name: ${JSON.stringify(producer)})`).join(", ");
|
|
17458
|
+
manifest += `
|
|
17459
|
+
package.targets.first(where: { $0.name == ${JSON.stringify(target)} })!.dependencies += [${additions}]
|
|
17460
|
+
`;
|
|
17461
|
+
dependencies.get(target).push(...producers2);
|
|
17462
|
+
}
|
|
17463
|
+
}
|
|
17292
17464
|
const depths = /* @__PURE__ */ new Map();
|
|
17293
17465
|
const orderedProducers = [];
|
|
17294
17466
|
const depth = (name2) => {
|
|
@@ -17317,13 +17489,18 @@ module ${moduleName}.Swift {
|
|
|
17317
17489
|
if (members.length === 1) return members[0];
|
|
17318
17490
|
if (dependencies.has(name2))
|
|
17319
17491
|
throw new Error(`generated build target collides with ${name2}`);
|
|
17320
|
-
files.set(
|
|
17492
|
+
files.set(path30.join(layout2.root, name2, "Products.swift"), "");
|
|
17321
17493
|
manifest += `
|
|
17322
17494
|
package.targets += [.target(name: ${JSON.stringify(name2)}, dependencies: ${JSON.stringify(members)}, path: ${JSON.stringify(name2)}, swiftSettings: [.swiftLanguageMode(.v5)])]
|
|
17323
17495
|
`;
|
|
17324
17496
|
return name2;
|
|
17325
17497
|
};
|
|
17326
|
-
const headerBuilds =
|
|
17498
|
+
const headerBuilds = headerCompiler ? [
|
|
17499
|
+
{
|
|
17500
|
+
target: buildProduct(SWIFT_HEADER_PRODUCTS_TARGET, orderedProducers),
|
|
17501
|
+
producers: orderedProducers
|
|
17502
|
+
}
|
|
17503
|
+
] : [...stages].sort(([left], [right]) => left - right).map(([level, producers2]) => ({
|
|
17327
17504
|
target: buildProduct(`${SWIFT_HEADER_PRODUCTS_TARGET}${level}`, producers2),
|
|
17328
17505
|
producers: producers2
|
|
17329
17506
|
}));
|
|
@@ -17341,16 +17518,17 @@ package.targets += [.target(name: ${JSON.stringify(name2)}, dependencies: ${JSON
|
|
|
17341
17518
|
syncSwiftTree(layout2.root, files);
|
|
17342
17519
|
if (layout2.multi)
|
|
17343
17520
|
for (const target of targets)
|
|
17344
|
-
|
|
17345
|
-
const clangWrapper =
|
|
17346
|
-
if (files.has(clangWrapper))
|
|
17521
|
+
mkdirSync8(path30.join(layout2.root, target.path), { recursive: true });
|
|
17522
|
+
const clangWrapper = path30.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
|
|
17523
|
+
if (files.has(clangWrapper)) chmodSync3(clangWrapper, 493);
|
|
17347
17524
|
return {
|
|
17348
17525
|
headerBuilds,
|
|
17349
17526
|
nativeHeaderDeclarations,
|
|
17350
17527
|
nativeProductTarget,
|
|
17351
17528
|
targetFailures,
|
|
17352
17529
|
generatedOwners,
|
|
17353
|
-
targetToolset
|
|
17530
|
+
targetToolset,
|
|
17531
|
+
headerCompiler
|
|
17354
17532
|
};
|
|
17355
17533
|
}
|
|
17356
17534
|
function streamText(value) {
|
|
@@ -17370,21 +17548,21 @@ function outputOf(error) {
|
|
|
17370
17548
|
return error instanceof Error ? error.message : String(error);
|
|
17371
17549
|
}
|
|
17372
17550
|
function builtArtifact(layout2) {
|
|
17373
|
-
const binDir =
|
|
17374
|
-
const manifest =
|
|
17551
|
+
const binDir = path30.join(layout2.root, ".build", WASM_TRIPLE, "release");
|
|
17552
|
+
const manifest = readFileSync18(path30.join(layout2.root, "Package.swift"), "utf8");
|
|
17375
17553
|
const executable = swiftManifestTargets(
|
|
17376
17554
|
manifest,
|
|
17377
17555
|
[],
|
|
17378
|
-
(file) =>
|
|
17556
|
+
(file) => readFileSync18(file, "utf8")
|
|
17379
17557
|
).find((target) => target.executable);
|
|
17380
17558
|
if (executable === void 0) {
|
|
17381
17559
|
throw new Error("swift-compile: the written manifest names no executable target");
|
|
17382
17560
|
}
|
|
17383
|
-
return
|
|
17561
|
+
return path30.join(binDir, `${executable.name}.wasm`);
|
|
17384
17562
|
}
|
|
17385
17563
|
function projectDiagnostic(output, layout2, files) {
|
|
17386
17564
|
const base = layout2.multi ? layout2.root : layout2.sources;
|
|
17387
|
-
const prefix = `${base}${
|
|
17565
|
+
const prefix = `${base}${path30.sep}`;
|
|
17388
17566
|
return designTimeDiagnostic(output, files).split("\n").filter((line) => !SWIFTPM_NOISE.test(line)).map((line) => line.startsWith(prefix) ? line.slice(prefix.length) : line).join("\n").trim();
|
|
17389
17567
|
}
|
|
17390
17568
|
var ROOT_LOCKS = Symbol.for("peachsim.swiftCompile.rootLocks");
|
|
@@ -17420,13 +17598,13 @@ function serialize(root, work, signal) {
|
|
|
17420
17598
|
function readCompiledArtifact(directory, hash) {
|
|
17421
17599
|
try {
|
|
17422
17600
|
const receipt = JSON.parse(
|
|
17423
|
-
|
|
17601
|
+
readFileSync18(path30.join(directory, "artifact.json"), "utf8")
|
|
17424
17602
|
);
|
|
17425
17603
|
if (!receipt || typeof receipt !== "object" || !("hash" in receipt) || receipt.hash !== hash || !("icu" in receipt) || typeof receipt.icu !== "string" || !("wasm" in receipt) || typeof receipt.wasm !== "string")
|
|
17426
17604
|
return null;
|
|
17427
|
-
const bytes =
|
|
17428
|
-
const gzip2 =
|
|
17429
|
-
if (
|
|
17605
|
+
const bytes = readFileSync18(path30.join(directory, "app.wasm"));
|
|
17606
|
+
const gzip2 = readFileSync18(path30.join(directory, "icu.gz"));
|
|
17607
|
+
if (createHash15("sha256").update(bytes).digest("hex") !== receipt.wasm || createHash15("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length <= 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
|
|
17430
17608
|
return null;
|
|
17431
17609
|
return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 } };
|
|
17432
17610
|
} catch (error) {
|
|
@@ -17436,25 +17614,25 @@ function readCompiledArtifact(directory, hash) {
|
|
|
17436
17614
|
}
|
|
17437
17615
|
}
|
|
17438
17616
|
function saveCompiledArtifact(root, artifact) {
|
|
17439
|
-
const directory =
|
|
17440
|
-
|
|
17441
|
-
const pending =
|
|
17617
|
+
const directory = path30.join(root, "artifact");
|
|
17618
|
+
mkdirSync8(directory, { recursive: true });
|
|
17619
|
+
const pending = mkdtempSync4(path30.join(root, ".artifact-"));
|
|
17442
17620
|
try {
|
|
17443
|
-
|
|
17444
|
-
|
|
17445
|
-
|
|
17446
|
-
|
|
17621
|
+
writeFileSync9(path30.join(pending, "app.wasm"), artifact.bytes);
|
|
17622
|
+
writeFileSync9(path30.join(pending, "icu.gz"), artifact.icu.gzip);
|
|
17623
|
+
writeFileSync9(
|
|
17624
|
+
path30.join(pending, "artifact.json"),
|
|
17447
17625
|
JSON.stringify({
|
|
17448
17626
|
hash: artifact.hash,
|
|
17449
|
-
wasm:
|
|
17627
|
+
wasm: createHash15("sha256").update(artifact.bytes).digest("hex"),
|
|
17450
17628
|
icu: artifact.icu.sha256
|
|
17451
17629
|
})
|
|
17452
17630
|
);
|
|
17453
17631
|
for (const file of ["app.wasm", "icu.gz", "artifact.json"]) {
|
|
17454
|
-
|
|
17632
|
+
renameSync3(path30.join(pending, file), path30.join(directory, file));
|
|
17455
17633
|
}
|
|
17456
17634
|
} finally {
|
|
17457
|
-
|
|
17635
|
+
rmSync8(pending, { recursive: true, force: true });
|
|
17458
17636
|
}
|
|
17459
17637
|
}
|
|
17460
17638
|
var SHARED_ARTIFACT_BUDGET_BYTES = 4 * 1024 ** 3;
|
|
@@ -17473,21 +17651,21 @@ function renewSharedArtifact(sharedRoot) {
|
|
|
17473
17651
|
function pruneSharedArtifacts(parent, keep) {
|
|
17474
17652
|
const entries = [];
|
|
17475
17653
|
for (const name2 of readdirSync8(parent)) {
|
|
17476
|
-
const directory =
|
|
17654
|
+
const directory = path30.join(parent, name2);
|
|
17477
17655
|
if (name2.startsWith(RETIRED_PREFIX)) {
|
|
17478
17656
|
reapRetiredCacheDirectory(parent, name2);
|
|
17479
17657
|
continue;
|
|
17480
17658
|
}
|
|
17481
17659
|
try {
|
|
17482
17660
|
let bytes = 0;
|
|
17483
|
-
for (const file of readdirSync8(
|
|
17661
|
+
for (const file of readdirSync8(path30.join(directory, "artifact"))) {
|
|
17484
17662
|
try {
|
|
17485
|
-
bytes +=
|
|
17663
|
+
bytes += statSync3(path30.join(directory, "artifact", file)).size;
|
|
17486
17664
|
} catch (error) {
|
|
17487
17665
|
if (!vanished(error)) throw error;
|
|
17488
17666
|
}
|
|
17489
17667
|
}
|
|
17490
|
-
entries.push({ directory, used:
|
|
17668
|
+
entries.push({ directory, used: statSync3(directory).mtimeMs, bytes });
|
|
17491
17669
|
} catch (error) {
|
|
17492
17670
|
if (!vanished(error)) throw error;
|
|
17493
17671
|
}
|
|
@@ -17497,13 +17675,13 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
17497
17675
|
if (total <= SHARED_ARTIFACT_BUDGET_BYTES) break;
|
|
17498
17676
|
if (entry.directory === keep || Date.now() - entry.used < SHARED_ARTIFACT_GRACE_MS)
|
|
17499
17677
|
continue;
|
|
17500
|
-
const retired =
|
|
17678
|
+
const retired = path30.join(
|
|
17501
17679
|
parent,
|
|
17502
|
-
`${RETIRED_PREFIX}${process.pid}-${
|
|
17680
|
+
`${RETIRED_PREFIX}${process.pid}-${path30.basename(entry.directory)}`
|
|
17503
17681
|
);
|
|
17504
17682
|
try {
|
|
17505
|
-
if (
|
|
17506
|
-
|
|
17683
|
+
if (statSync3(entry.directory).mtimeMs !== entry.used) continue;
|
|
17684
|
+
renameSync3(entry.directory, retired);
|
|
17507
17685
|
} catch (error) {
|
|
17508
17686
|
if (vanished(error)) continue;
|
|
17509
17687
|
throw error;
|
|
@@ -17515,7 +17693,7 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
17515
17693
|
function saveSharedArtifact(sharedRoot, artifact) {
|
|
17516
17694
|
saveCompiledArtifact(sharedRoot, artifact);
|
|
17517
17695
|
renewSharedArtifact(sharedRoot);
|
|
17518
|
-
pruneSharedArtifacts(
|
|
17696
|
+
pruneSharedArtifacts(path30.dirname(sharedRoot), sharedRoot);
|
|
17519
17697
|
}
|
|
17520
17698
|
var retainedArtifacts = /* @__PURE__ */ new Map();
|
|
17521
17699
|
function retain(root, artifact) {
|
|
@@ -17543,7 +17721,7 @@ function frameworkLibraryTargets(manifest) {
|
|
|
17543
17721
|
}
|
|
17544
17722
|
function linkedFrameworkTargets(moduleRoot, input) {
|
|
17545
17723
|
const libraries = frameworkLibraryTargets(
|
|
17546
|
-
|
|
17724
|
+
readFileSync18(path30.join(moduleRoot, "Package.swift"), "utf8")
|
|
17547
17725
|
);
|
|
17548
17726
|
const targets = compileTargets(input);
|
|
17549
17727
|
const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
|
|
@@ -17566,7 +17744,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
17566
17744
|
for (const name2 of [...siblings.values()].flat())
|
|
17567
17745
|
if (libraries.has(name2) && !planning.some((target) => target.name === name2))
|
|
17568
17746
|
reach(name2);
|
|
17569
|
-
const manifest =
|
|
17747
|
+
const manifest = readFileSync18(path30.join(moduleRoot, "Package.swift"), "utf8");
|
|
17570
17748
|
const targetDependencies = /* @__PURE__ */ new Map();
|
|
17571
17749
|
for (const match of manifest.matchAll(
|
|
17572
17750
|
/\.target\(\s*name:\s*"([^"]+)"\s*,\s*dependencies:\s*\[([^\]]*)\]/g
|
|
@@ -17583,12 +17761,12 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
17583
17761
|
};
|
|
17584
17762
|
for (const name2 of reached)
|
|
17585
17763
|
for (const member of libraries.get(name2) ?? []) build(member);
|
|
17586
|
-
const overlays =
|
|
17764
|
+
const overlays = path30.join(moduleRoot, "cross-import-overlays");
|
|
17587
17765
|
for (const directory of readdirSync8(overlays)) {
|
|
17588
|
-
const companion =
|
|
17766
|
+
const companion = path30.basename(directory, ".swiftcrossimport");
|
|
17589
17767
|
if (!built.has(companion)) continue;
|
|
17590
|
-
const declaration =
|
|
17591
|
-
for (const match of
|
|
17768
|
+
const declaration = path30.join(overlays, directory, "SwiftUI.swiftoverlay");
|
|
17769
|
+
for (const match of readFileSync18(declaration, "utf8").matchAll(
|
|
17592
17770
|
/^\s*- name: ([A-Za-z_]\w*)\s*$/gm
|
|
17593
17771
|
))
|
|
17594
17772
|
reach(match[1]);
|
|
@@ -17614,7 +17792,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
17614
17792
|
return { products: linked, targets: linkedMembers };
|
|
17615
17793
|
}
|
|
17616
17794
|
function writeFrameworkLinkPackage(linkRoot, moduleRoot, products) {
|
|
17617
|
-
const identity =
|
|
17795
|
+
const identity = path30.basename(moduleRoot).toLowerCase();
|
|
17618
17796
|
const swiftString = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
17619
17797
|
const dependencies = products.map(
|
|
17620
17798
|
(name2) => ` .product(name: ${swiftString(name2)}, package: ${swiftString(identity)}),`
|
|
@@ -17636,13 +17814,13 @@ ${dependencies}
|
|
|
17636
17814
|
]
|
|
17637
17815
|
)
|
|
17638
17816
|
`;
|
|
17639
|
-
const sourceDir =
|
|
17640
|
-
|
|
17641
|
-
const manifestPath =
|
|
17642
|
-
if (!
|
|
17643
|
-
|
|
17644
|
-
const source =
|
|
17645
|
-
if (!
|
|
17817
|
+
const sourceDir = path30.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
|
|
17818
|
+
mkdirSync8(sourceDir, { recursive: true });
|
|
17819
|
+
const manifestPath = path30.join(linkRoot, "Package.swift");
|
|
17820
|
+
if (!existsSync7(manifestPath) || readFileSync18(manifestPath, "utf8") !== manifest)
|
|
17821
|
+
writeFileSync9(manifestPath, manifest);
|
|
17822
|
+
const source = path30.join(sourceDir, "Link.swift");
|
|
17823
|
+
if (!existsSync7(source)) writeFileSync9(source, "");
|
|
17646
17824
|
}
|
|
17647
17825
|
function frameworkLinkClosure(scratch2, roots) {
|
|
17648
17826
|
const suffix = `${WASM_TRIPLE}-release`;
|
|
@@ -17653,7 +17831,7 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
17653
17831
|
const moduleMaps = /* @__PURE__ */ new Map();
|
|
17654
17832
|
let pending = null;
|
|
17655
17833
|
let compiling = null;
|
|
17656
|
-
for (const line of
|
|
17834
|
+
for (const line of readFileSync18(path30.join(scratch2, "release.yaml"), "utf8").split(
|
|
17657
17835
|
"\n"
|
|
17658
17836
|
)) {
|
|
17659
17837
|
const phony = phonyHeader.exec(line);
|
|
@@ -17717,7 +17895,7 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
17717
17895
|
owners.set(file, name2);
|
|
17718
17896
|
if (seen.has(file)) continue;
|
|
17719
17897
|
seen.add(file);
|
|
17720
|
-
if (!
|
|
17898
|
+
if (!existsSync7(file))
|
|
17721
17899
|
throw new Error(`swift-compile: framework object ${file} was not built`);
|
|
17722
17900
|
files.push(file);
|
|
17723
17901
|
}
|
|
@@ -17727,19 +17905,19 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
17727
17905
|
return { objects: files, owners, modules, moduleMaps: [...maps].sort() };
|
|
17728
17906
|
}
|
|
17729
17907
|
function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
|
|
17730
|
-
if (!
|
|
17908
|
+
if (!existsSync7(modulesDir)) return;
|
|
17731
17909
|
const folded = new Set([...keep].map((name2) => name2.toLowerCase()));
|
|
17732
17910
|
for (const name2 of readdirSync8(modulesDir)) {
|
|
17733
17911
|
const dot = name2.indexOf(".");
|
|
17734
17912
|
if (dot <= 0) continue;
|
|
17735
17913
|
const module = name2.slice(0, dot);
|
|
17736
17914
|
if (keep.has(module) || !folded.has(module.toLowerCase())) continue;
|
|
17737
|
-
|
|
17915
|
+
rmSync8(path30.join(modulesDir, name2), { recursive: true, force: true });
|
|
17738
17916
|
}
|
|
17739
17917
|
}
|
|
17740
17918
|
async function buildFrameworkProducts(scratch2, args) {
|
|
17741
17919
|
const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input);
|
|
17742
|
-
const linkRoot =
|
|
17920
|
+
const linkRoot = path30.join(scratch2, "link");
|
|
17743
17921
|
writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products);
|
|
17744
17922
|
await runCompiler(
|
|
17745
17923
|
args.swift,
|
|
@@ -17772,7 +17950,7 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17772
17950
|
"-Xswiftc",
|
|
17773
17951
|
String(swiftBuildJobs()),
|
|
17774
17952
|
...swiftReproducibleBuildFlags([
|
|
17775
|
-
[
|
|
17953
|
+
[path30.dirname(args.toolchainBin), "toolchain"],
|
|
17776
17954
|
[args.moduleRoot, "framework"],
|
|
17777
17955
|
[scratch2, "framework-scratch"]
|
|
17778
17956
|
]),
|
|
@@ -17797,16 +17975,16 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17797
17975
|
).catch((error) => {
|
|
17798
17976
|
throw new Error(outputOf(error), { cause: error });
|
|
17799
17977
|
});
|
|
17800
|
-
const release =
|
|
17978
|
+
const release = path30.join(scratch2, WASM_TRIPLE, "release");
|
|
17801
17979
|
const linked = frameworkLinkClosure(scratch2, linkedTargets.targets);
|
|
17802
17980
|
const objects = linked.objects;
|
|
17803
17981
|
if (linked.modules.has("UniformTypeIdentifiers")) {
|
|
17804
|
-
const constantsDir =
|
|
17805
|
-
const constantsStamp =
|
|
17806
|
-
const object3 =
|
|
17807
|
-
if (!
|
|
17808
|
-
|
|
17809
|
-
|
|
17982
|
+
const constantsDir = path30.join(scratch2, "uniform-type-constants");
|
|
17983
|
+
const constantsStamp = path30.join(constantsDir, ".complete");
|
|
17984
|
+
const object3 = path30.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
|
|
17985
|
+
if (!existsSync7(constantsStamp) || readFileSync18(constantsStamp, "utf8") !== args.frameworkKey) {
|
|
17986
|
+
rmSync8(constantsDir, { recursive: true, force: true });
|
|
17987
|
+
mkdirSync8(constantsDir);
|
|
17810
17988
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
17811
17989
|
compileUniformTypeConstants({
|
|
17812
17990
|
bin: args.toolchainBin,
|
|
@@ -17816,35 +17994,35 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17816
17994
|
minimum: darwinRecordsMinimum(),
|
|
17817
17995
|
out: constantsDir
|
|
17818
17996
|
});
|
|
17819
|
-
|
|
17997
|
+
writeFileSync9(constantsStamp, args.frameworkKey);
|
|
17820
17998
|
}
|
|
17821
17999
|
objects.push(object3);
|
|
17822
18000
|
linked.owners.set(object3, "UniformTypeIdentifiers");
|
|
17823
18001
|
}
|
|
17824
|
-
removeCaseCollidingModuleArtifacts(
|
|
17825
|
-
const response =
|
|
17826
|
-
|
|
18002
|
+
removeCaseCollidingModuleArtifacts(path30.join(release, "Modules"), linked.modules);
|
|
18003
|
+
const response = path30.join(scratch2, "autolink-objects.rsp");
|
|
18004
|
+
writeFileSync9(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
|
|
17827
18005
|
const extracted = await runCompiler(
|
|
17828
|
-
|
|
18006
|
+
path30.join(args.toolchainBin, "swift-autolink-extract"),
|
|
17829
18007
|
[`@${response}`, "-o", "-"],
|
|
17830
18008
|
args.buildOptions
|
|
17831
18009
|
);
|
|
17832
|
-
|
|
18010
|
+
rmSync8(response, { force: true });
|
|
17833
18011
|
const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
|
|
17834
18012
|
if (link.includes("-lFoundation"))
|
|
17835
18013
|
for (const name2 of foundationCategoryObjects) {
|
|
17836
|
-
const object3 =
|
|
18014
|
+
const object3 = path30.join(
|
|
17837
18015
|
swiftSdkPaths(args.moduleRoot, args.toolchainBin).resources,
|
|
17838
18016
|
`wasi/${name2}.objc.o`
|
|
17839
18017
|
);
|
|
17840
18018
|
objects.push(object3);
|
|
17841
18019
|
linked.owners.set(object3, "Foundation");
|
|
17842
18020
|
}
|
|
17843
|
-
const providerDir =
|
|
17844
|
-
const providerStamp =
|
|
17845
|
-
if (!
|
|
17846
|
-
|
|
17847
|
-
|
|
18021
|
+
const providerDir = path30.join(scratch2, "darwin-records");
|
|
18022
|
+
const providerStamp = path30.join(providerDir, ".complete");
|
|
18023
|
+
if (!existsSync7(providerStamp) || readFileSync18(providerStamp, "utf8") !== args.frameworkKey) {
|
|
18024
|
+
rmSync8(providerDir, { recursive: true, force: true });
|
|
18025
|
+
mkdirSync8(providerDir);
|
|
17848
18026
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
17849
18027
|
compileDarwinRecords({
|
|
17850
18028
|
bin: args.toolchainBin,
|
|
@@ -17854,20 +18032,20 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17854
18032
|
minimum: darwinRecordsMinimum(),
|
|
17855
18033
|
out: providerDir
|
|
17856
18034
|
});
|
|
17857
|
-
|
|
18035
|
+
writeFileSync9(providerStamp, args.frameworkKey);
|
|
17858
18036
|
}
|
|
17859
|
-
const providers = readdirSync8(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) =>
|
|
18037
|
+
const providers = readdirSync8(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path30.join(providerDir, file));
|
|
17860
18038
|
for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
|
|
17861
|
-
const archive =
|
|
17862
|
-
|
|
17863
|
-
|
|
18039
|
+
const archive = path30.join(scratch2, "lib");
|
|
18040
|
+
rmSync8(archive, { recursive: true, force: true });
|
|
18041
|
+
mkdirSync8(archive);
|
|
17864
18042
|
const archived = /* @__PURE__ */ new Map();
|
|
17865
18043
|
for (const object3 of objects) {
|
|
17866
18044
|
const target = linked.owners.get(object3);
|
|
17867
|
-
const dir =
|
|
17868
|
-
if (!target || target === "Darwin" || !object3.startsWith(dir +
|
|
17869
|
-
const name2 = `${target}-${
|
|
17870
|
-
symlinkSync2(object3,
|
|
18045
|
+
const dir = path30.join(release, `${target}.build`);
|
|
18046
|
+
if (!target || target === "Darwin" || !object3.startsWith(dir + path30.sep)) continue;
|
|
18047
|
+
const name2 = `${target}-${path30.relative(dir, object3).replaceAll(path30.sep, "-").replace(/\.swift\.o$/, ".o")}`;
|
|
18048
|
+
symlinkSync2(object3, path30.join(archive, name2));
|
|
17871
18049
|
archived.set(object3, `lib/${name2}`);
|
|
17872
18050
|
}
|
|
17873
18051
|
const roots = swiftObjcRootObjects(`${scratch2}
|
|
@@ -17876,11 +18054,11 @@ ${args.frameworkKey}`, scratch2, [
|
|
|
17876
18054
|
]);
|
|
17877
18055
|
const linkedObjects = objects.map((object3) => {
|
|
17878
18056
|
const name2 = archived.get(object3);
|
|
17879
|
-
return name2 ? { path:
|
|
18057
|
+
return name2 ? { path: path30.join(scratch2, name2), lazy: !roots.has(name2) } : { path: object3, lazy: false };
|
|
17880
18058
|
});
|
|
17881
18059
|
return {
|
|
17882
18060
|
root: scratch2,
|
|
17883
|
-
modules:
|
|
18061
|
+
modules: path30.join(release, "Modules"),
|
|
17884
18062
|
objects: linkedObjects.filter((object3) => !object3.lazy).map((object3) => object3.path),
|
|
17885
18063
|
lazyObjects: linkedObjects.filter((object3) => object3.lazy).map((object3) => object3.path),
|
|
17886
18064
|
owners: linked.owners,
|
|
@@ -17894,14 +18072,14 @@ var SWIFT_FRAMEWORK_SLOTS = 8;
|
|
|
17894
18072
|
var SWIFT_FRAMEWORK_SLOT_KEY = ".peach-framework-key";
|
|
17895
18073
|
var SWIFT_FRAMEWORK_SLOT_ORIGIN = ".peach-framework-origin";
|
|
17896
18074
|
function swiftFrameworksDir() {
|
|
17897
|
-
return
|
|
18075
|
+
return path30.join(swiftCacheDir(), "swift-frameworks");
|
|
17898
18076
|
}
|
|
17899
18077
|
function swiftFrameworkScratch(frameworkKey) {
|
|
17900
|
-
return
|
|
18078
|
+
return path30.join(swiftFrameworksDir(), frameworkKey);
|
|
17901
18079
|
}
|
|
17902
18080
|
function swiftFrameworkSlotRecord(slot, record) {
|
|
17903
18081
|
try {
|
|
17904
|
-
return
|
|
18082
|
+
return readFileSync18(path30.join(slot, record), "utf8").trim();
|
|
17905
18083
|
} catch (error) {
|
|
17906
18084
|
if (!vanished(error)) throw error;
|
|
17907
18085
|
return null;
|
|
@@ -17912,8 +18090,8 @@ function swiftFrameworkSlotKey(slot) {
|
|
|
17912
18090
|
}
|
|
17913
18091
|
async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
17914
18092
|
const slots = Array.from({ length: SWIFT_FRAMEWORK_SLOTS }, (_, index) => {
|
|
17915
|
-
const slot =
|
|
17916
|
-
|
|
18093
|
+
const slot = path30.join(swiftFrameworksDir(), `slot-${index}`);
|
|
18094
|
+
mkdirSync8(slot, { recursive: true });
|
|
17917
18095
|
return slot;
|
|
17918
18096
|
});
|
|
17919
18097
|
const run2 = (slot) => (lease) => {
|
|
@@ -17923,21 +18101,21 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
|
17923
18101
|
};
|
|
17924
18102
|
const staged = slots.find((slot) => swiftFrameworkSlotKey(slot) === frameworkKey);
|
|
17925
18103
|
if (staged) return withSwiftRootLock(staged, run2(staged), signal);
|
|
17926
|
-
const built = new Map(slots.map((slot) => [slot,
|
|
18104
|
+
const built = new Map(slots.map((slot) => [slot, statSync3(slot).mtimeMs]));
|
|
17927
18105
|
const own = (slot) => swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN) === moduleRoot;
|
|
17928
18106
|
const inputs = new Map(
|
|
17929
18107
|
swiftModuleInputFiles(moduleRoot).map((file) => [
|
|
17930
18108
|
file,
|
|
17931
|
-
|
|
18109
|
+
readFileSync18(path30.join(moduleRoot, file))
|
|
17932
18110
|
])
|
|
17933
18111
|
);
|
|
17934
18112
|
const ranked = slots.map((slot) => {
|
|
17935
18113
|
let changes = 0;
|
|
17936
18114
|
if (swiftFrameworkSlotKey(slot) === null) return { slot, changes: Infinity };
|
|
17937
|
-
const source =
|
|
18115
|
+
const source = path30.join(slot, "source", "packages", path30.basename(moduleRoot));
|
|
17938
18116
|
for (const [file, contents2] of inputs) {
|
|
17939
18117
|
try {
|
|
17940
|
-
if (!
|
|
18118
|
+
if (!readFileSync18(path30.join(source, file)).equals(contents2)) changes++;
|
|
17941
18119
|
} catch (error) {
|
|
17942
18120
|
if (!vanished(error)) throw error;
|
|
17943
18121
|
changes++;
|
|
@@ -17952,7 +18130,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
|
17952
18130
|
slot,
|
|
17953
18131
|
async (lease) => {
|
|
17954
18132
|
console.error(
|
|
17955
|
-
`[swift-framework-cache] ${
|
|
18133
|
+
`[swift-framework-cache] ${path30.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`
|
|
17956
18134
|
);
|
|
17957
18135
|
return { value: await run2(slot)(lease) };
|
|
17958
18136
|
},
|
|
@@ -17965,14 +18143,14 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
|
17965
18143
|
return withSwiftRootLock(nearest, run2(nearest), signal);
|
|
17966
18144
|
}
|
|
17967
18145
|
function mirrorTree2(source, target, skip) {
|
|
17968
|
-
|
|
18146
|
+
mkdirSync8(target, { recursive: true });
|
|
17969
18147
|
const wanted = /* @__PURE__ */ new Set();
|
|
17970
18148
|
let restructured = false;
|
|
17971
18149
|
for (const entry of readdirSync8(source, { withFileTypes: true })) {
|
|
17972
18150
|
if (entry.name === skip) continue;
|
|
17973
18151
|
wanted.add(entry.name);
|
|
17974
|
-
const from =
|
|
17975
|
-
const to =
|
|
18152
|
+
const from = path30.join(source, entry.name);
|
|
18153
|
+
const to = path30.join(target, entry.name);
|
|
17976
18154
|
let existing = null;
|
|
17977
18155
|
try {
|
|
17978
18156
|
existing = lstatSync(to);
|
|
@@ -17981,75 +18159,75 @@ function mirrorTree2(source, target, skip) {
|
|
|
17981
18159
|
}
|
|
17982
18160
|
if (!existing) restructured = true;
|
|
17983
18161
|
if (entry.isDirectory()) {
|
|
17984
|
-
if (existing && !existing.isDirectory())
|
|
18162
|
+
if (existing && !existing.isDirectory()) rmSync8(to, { force: true });
|
|
17985
18163
|
if (mirrorTree2(from, to)) restructured = true;
|
|
17986
18164
|
} else if (entry.isSymbolicLink()) {
|
|
17987
18165
|
const link = readlinkSync(from);
|
|
17988
18166
|
if (existing?.isSymbolicLink() && readlinkSync(to) === link) continue;
|
|
17989
|
-
if (existing)
|
|
18167
|
+
if (existing) rmSync8(to, { recursive: true, force: true });
|
|
17990
18168
|
symlinkSync2(link, to);
|
|
17991
18169
|
} else {
|
|
17992
|
-
const stat =
|
|
17993
|
-
if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs ||
|
|
18170
|
+
const stat = statSync3(from);
|
|
18171
|
+
if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs || readFileSync18(from).equals(readFileSync18(to))))
|
|
17994
18172
|
continue;
|
|
17995
|
-
if (existing)
|
|
18173
|
+
if (existing) rmSync8(to, { recursive: true, force: true });
|
|
17996
18174
|
const partial = `${to}.${randomUUID5()}`;
|
|
17997
18175
|
copyFileSync(from, partial);
|
|
17998
18176
|
utimesSync(partial, stat.atime, stat.mtime);
|
|
17999
|
-
|
|
18177
|
+
renameSync3(partial, to);
|
|
18000
18178
|
}
|
|
18001
18179
|
}
|
|
18002
18180
|
for (const name2 of readdirSync8(target))
|
|
18003
18181
|
if (!wanted.has(name2) && name2 !== skip) {
|
|
18004
|
-
|
|
18182
|
+
rmSync8(path30.join(target, name2), { recursive: true, force: true });
|
|
18005
18183
|
restructured = true;
|
|
18006
18184
|
}
|
|
18007
18185
|
return restructured;
|
|
18008
18186
|
}
|
|
18009
18187
|
function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
18010
18188
|
if (!slot) return moduleRoot;
|
|
18011
|
-
const staged =
|
|
18012
|
-
const stagedModule =
|
|
18189
|
+
const staged = path30.join(slot, "source");
|
|
18190
|
+
const stagedModule = path30.join(staged, "packages", path30.basename(moduleRoot));
|
|
18013
18191
|
if (swiftFrameworkSlotKey(slot) !== frameworkKey) {
|
|
18014
|
-
|
|
18192
|
+
rmSync8(path30.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
|
|
18015
18193
|
const moduleRestructured = mirrorTree2(moduleRoot, stagedModule, ".build");
|
|
18016
18194
|
const sdkRestructured = mirrorTree2(
|
|
18017
18195
|
swiftSharedSdkRoot(moduleRoot, false),
|
|
18018
|
-
|
|
18196
|
+
path30.join(staged, "packages/peachsim/sdk/ios")
|
|
18019
18197
|
);
|
|
18020
18198
|
if (moduleRestructured || sdkRestructured) {
|
|
18021
|
-
|
|
18022
|
-
|
|
18199
|
+
rmSync8(path30.join(slot, "release.yaml"), { force: true });
|
|
18200
|
+
rmSync8(path30.join(slot, "release", "description.json"), { force: true });
|
|
18023
18201
|
}
|
|
18024
18202
|
for (const file of swiftModuleInputFiles(moduleRoot)) {
|
|
18025
18203
|
if (!file.startsWith("../")) continue;
|
|
18026
|
-
const from =
|
|
18027
|
-
const to =
|
|
18028
|
-
if (
|
|
18029
|
-
|
|
18204
|
+
const from = path30.resolve(moduleRoot, file);
|
|
18205
|
+
const to = path30.resolve(stagedModule, file);
|
|
18206
|
+
if (existsSync7(to) && readFileSync18(from).equals(readFileSync18(to))) continue;
|
|
18207
|
+
mkdirSync8(path30.dirname(to), { recursive: true });
|
|
18030
18208
|
copyFileSync(from, to);
|
|
18031
18209
|
}
|
|
18032
18210
|
if (swiftProjectBuildKey(stagedModule, release) !== frameworkKey)
|
|
18033
18211
|
throw new Error("Swift staged framework source differs from the caller");
|
|
18034
|
-
const modules =
|
|
18035
|
-
const target = realpathSync6(
|
|
18036
|
-
if (!
|
|
18037
|
-
|
|
18212
|
+
const modules = path30.join(staged, "node_modules");
|
|
18213
|
+
const target = realpathSync6(path30.join(moduleRoot, "../../node_modules"));
|
|
18214
|
+
if (!existsSync7(modules) || readlinkSync(modules) !== target) {
|
|
18215
|
+
rmSync8(modules, { recursive: true, force: true });
|
|
18038
18216
|
symlinkSync2(target, modules);
|
|
18039
18217
|
}
|
|
18040
|
-
|
|
18041
|
-
|
|
18218
|
+
writeFileSync9(path30.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
|
|
18219
|
+
writeFileSync9(path30.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
|
|
18042
18220
|
}
|
|
18043
18221
|
return stagedModule;
|
|
18044
18222
|
}
|
|
18045
18223
|
function swiftLinkStamp(args) {
|
|
18046
|
-
const hash =
|
|
18224
|
+
const hash = createHash15("sha256");
|
|
18047
18225
|
hash.update(`swift-link/v1
|
|
18048
18226
|
${args.frameworkKey}
|
|
18049
18227
|
`);
|
|
18050
18228
|
if (!args.prebuilt) return hash.digest("hex");
|
|
18051
18229
|
const statOf = (file) => {
|
|
18052
|
-
const stat =
|
|
18230
|
+
const stat = statSync3(file, { bigint: true });
|
|
18053
18231
|
return `${stat.size}:${stat.mtimeNs}`;
|
|
18054
18232
|
};
|
|
18055
18233
|
for (const object3 of args.prebuilt.objects)
|
|
@@ -18076,23 +18254,23 @@ ${args.prebuilt.modules}
|
|
|
18076
18254
|
`);
|
|
18077
18255
|
for (const entry of readdirSync8(args.prebuilt.modules).sort())
|
|
18078
18256
|
hash.update(`${entry}
|
|
18079
|
-
${statOf(
|
|
18257
|
+
${statOf(path30.join(args.prebuilt.modules, entry))}`);
|
|
18080
18258
|
return hash.digest("hex");
|
|
18081
18259
|
}
|
|
18082
18260
|
function retireStaleSwiftLink(root, stamp) {
|
|
18083
|
-
const receipt =
|
|
18261
|
+
const receipt = path30.join(root, SWIFT_LINK_STAMP);
|
|
18084
18262
|
let previous = null;
|
|
18085
18263
|
try {
|
|
18086
|
-
previous =
|
|
18264
|
+
previous = readFileSync18(receipt, "utf8").trim();
|
|
18087
18265
|
} catch (error) {
|
|
18088
18266
|
if (!vanished(error)) throw error;
|
|
18089
18267
|
}
|
|
18090
|
-
|
|
18091
|
-
|
|
18268
|
+
mkdirSync8(root, { recursive: true });
|
|
18269
|
+
writeFileSync9(receipt, `${stamp}
|
|
18092
18270
|
`);
|
|
18093
|
-
const retired =
|
|
18094
|
-
if (previous === stamp || !
|
|
18095
|
-
|
|
18271
|
+
const retired = path30.join(root, ".build");
|
|
18272
|
+
if (previous === stamp || !existsSync7(retired)) return false;
|
|
18273
|
+
rmSync8(retired, { recursive: true, force: true });
|
|
18096
18274
|
return true;
|
|
18097
18275
|
}
|
|
18098
18276
|
async function compileSwiftProjectUnit(input, options) {
|
|
@@ -18107,21 +18285,21 @@ async function compileSwiftProjectUnit(input, options) {
|
|
|
18107
18285
|
}
|
|
18108
18286
|
function compileSwiftProjectOnce(input, options) {
|
|
18109
18287
|
options.signal?.throwIfAborted();
|
|
18110
|
-
|
|
18288
|
+
mkdirSync8(options.buildRoot, { recursive: true });
|
|
18111
18289
|
const root = realpathSync6(options.buildRoot);
|
|
18112
|
-
const moduleRoot =
|
|
18290
|
+
const moduleRoot = path30.resolve(options.moduleRoot);
|
|
18113
18291
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
18114
18292
|
const guestGraph = distribution ? input.sourceLinkGraph : void 0;
|
|
18115
18293
|
if (options.linkOnly && guestGraph)
|
|
18116
18294
|
throw new Error("swift-compile: link-only builds do not support guest image graphs");
|
|
18117
18295
|
const layout2 = {
|
|
18118
18296
|
root,
|
|
18119
|
-
sources:
|
|
18297
|
+
sources: path30.join(root, "Sources", "App"),
|
|
18120
18298
|
multi: compileTargets(input).length > 0
|
|
18121
18299
|
};
|
|
18122
18300
|
const hash = swiftArtifactHash(input, options.release, moduleRoot);
|
|
18123
18301
|
const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
|
|
18124
|
-
const sharedRoot =
|
|
18302
|
+
const sharedRoot = path30.join(swiftCacheDir(), "swift-projects", hash);
|
|
18125
18303
|
const report = (message) => {
|
|
18126
18304
|
console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
|
|
18127
18305
|
options.onStage?.(message);
|
|
@@ -18136,8 +18314,8 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18136
18314
|
report("reusing memory artifact");
|
|
18137
18315
|
return retain(root, retained);
|
|
18138
18316
|
}
|
|
18139
|
-
const cached = readCompiledArtifact(
|
|
18140
|
-
const previous = cached ?? (options.project ? null : readCompiledArtifact(
|
|
18317
|
+
const cached = readCompiledArtifact(path30.join(sharedRoot, "artifact"), hash);
|
|
18318
|
+
const previous = cached ?? (options.project ? null : readCompiledArtifact(path30.join(root, "artifact"), hash));
|
|
18141
18319
|
if (previous) {
|
|
18142
18320
|
if (cached) renewSharedArtifact(sharedRoot);
|
|
18143
18321
|
else saveSharedArtifact(sharedRoot, previous);
|
|
@@ -18146,10 +18324,10 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18146
18324
|
}
|
|
18147
18325
|
}
|
|
18148
18326
|
if (!options.intermediates && process.platform === "darwin" && process.env.TM_SESSION && !windowAdmission() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
|
|
18149
|
-
const requestRoot =
|
|
18150
|
-
const output =
|
|
18151
|
-
const request =
|
|
18152
|
-
|
|
18327
|
+
const requestRoot = mkdtempSync4(`${root}.builder-request-`);
|
|
18328
|
+
const output = path30.join(requestRoot, "output");
|
|
18329
|
+
const request = path30.join(requestRoot, "request.json");
|
|
18330
|
+
writeFileSync9(
|
|
18153
18331
|
request,
|
|
18154
18332
|
JSON.stringify({
|
|
18155
18333
|
input,
|
|
@@ -18162,12 +18340,12 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18162
18340
|
})
|
|
18163
18341
|
);
|
|
18164
18342
|
try {
|
|
18165
|
-
const repo =
|
|
18343
|
+
const repo = path30.resolve(moduleRoot, "../..");
|
|
18166
18344
|
report("requesting builder admission or cached result");
|
|
18167
18345
|
await runCompiler(
|
|
18168
18346
|
"bun",
|
|
18169
18347
|
[
|
|
18170
|
-
|
|
18348
|
+
path30.join(repo, "scripts/build/swift-project.ts"),
|
|
18171
18349
|
"--request",
|
|
18172
18350
|
request,
|
|
18173
18351
|
"--output",
|
|
@@ -18195,7 +18373,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18195
18373
|
report("builder artifact verified");
|
|
18196
18374
|
return retain(root, artifact);
|
|
18197
18375
|
} finally {
|
|
18198
|
-
|
|
18376
|
+
rmSync8(requestRoot, { recursive: true, force: true });
|
|
18199
18377
|
}
|
|
18200
18378
|
}
|
|
18201
18379
|
return withSwiftCompileBudget(options.timeoutMs, options.signal, async (budget) => {
|
|
@@ -18203,14 +18381,14 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18203
18381
|
root,
|
|
18204
18382
|
async (lease) => {
|
|
18205
18383
|
if (!options.intermediates) {
|
|
18206
|
-
const built = readCompiledArtifact(
|
|
18384
|
+
const built = readCompiledArtifact(path30.join(sharedRoot, "artifact"), hash);
|
|
18207
18385
|
if (built) {
|
|
18208
18386
|
report("reusing verified disk artifact");
|
|
18209
18387
|
return retain(root, built);
|
|
18210
18388
|
}
|
|
18211
18389
|
}
|
|
18212
|
-
const swift =
|
|
18213
|
-
if (!
|
|
18390
|
+
const swift = path30.join(options.toolchainBin, "swift");
|
|
18391
|
+
if (!existsSync7(swift)) {
|
|
18214
18392
|
throw new Error(
|
|
18215
18393
|
`swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
|
|
18216
18394
|
);
|
|
@@ -18244,8 +18422,8 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18244
18422
|
// shipped host plugins resolve against the selected compiler's runtime.
|
|
18245
18423
|
...process.platform === "linux" ? {
|
|
18246
18424
|
LD_LIBRARY_PATH: [
|
|
18247
|
-
|
|
18248
|
-
|
|
18425
|
+
path30.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
18426
|
+
path30.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
18249
18427
|
process.env.LD_LIBRARY_PATH
|
|
18250
18428
|
].filter(Boolean).join(":")
|
|
18251
18429
|
} : {},
|
|
@@ -18284,21 +18462,22 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18284
18462
|
layout2,
|
|
18285
18463
|
input,
|
|
18286
18464
|
frameworkRoot,
|
|
18287
|
-
prebuilt
|
|
18465
|
+
prebuilt,
|
|
18466
|
+
!options.project
|
|
18288
18467
|
);
|
|
18289
|
-
const productFile =
|
|
18468
|
+
const productFile = path30.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
|
|
18290
18469
|
writeSwiftAutolinkLinker(
|
|
18291
18470
|
root,
|
|
18292
18471
|
options.toolchainBin,
|
|
18293
|
-
|
|
18472
|
+
existsSync7(productFile) ? [
|
|
18294
18473
|
v5.parse(
|
|
18295
18474
|
swiftFrameworkProductSchema,
|
|
18296
|
-
JSON.parse(
|
|
18475
|
+
JSON.parse(readFileSync18(productFile, "utf8"))
|
|
18297
18476
|
).product.name
|
|
18298
18477
|
] : []
|
|
18299
18478
|
);
|
|
18300
18479
|
const projectProcess = options.project ? prepareSwiftProjectProcess(root, options.project) : void 0;
|
|
18301
|
-
const compiler = preparation.targetToolset ? { CC:
|
|
18480
|
+
const compiler = preparation.targetToolset ? { CC: path30.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
|
|
18302
18481
|
const appOptions = projectProcess ? {
|
|
18303
18482
|
...buildOptions,
|
|
18304
18483
|
uid: projectProcess.uid,
|
|
@@ -18312,10 +18491,10 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18312
18491
|
for (const [file, text2] of Object.entries(input.files)) {
|
|
18313
18492
|
const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text2)?.[1];
|
|
18314
18493
|
if (!parents) continue;
|
|
18315
|
-
const directory =
|
|
18494
|
+
const directory = path30.posix.dirname(file);
|
|
18316
18495
|
forwarders.set(
|
|
18317
|
-
`${
|
|
18318
|
-
|
|
18496
|
+
`${path30.join(root, directory)}/${parents.slice(0, -1)}`,
|
|
18497
|
+
path30.posix.join("build", directory, parents).replace(/\/$/, "")
|
|
18319
18498
|
);
|
|
18320
18499
|
}
|
|
18321
18500
|
const buildArgs = [
|
|
@@ -18331,7 +18510,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18331
18510
|
...swiftObjCSelectorOptions(frameworkRoot),
|
|
18332
18511
|
"--swift-sdk",
|
|
18333
18512
|
sdk,
|
|
18334
|
-
...preparation.targetToolset ? ["--toolset",
|
|
18513
|
+
...preparation.targetToolset ? ["--toolset", path30.join(root, ".peach-target-toolset.json")] : [],
|
|
18335
18514
|
"-c",
|
|
18336
18515
|
"release",
|
|
18337
18516
|
// the link strips debug info, so none is generated (as for the framework)
|
|
@@ -18342,14 +18521,14 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18342
18521
|
"-Xswiftc",
|
|
18343
18522
|
String(swiftBuildJobs()),
|
|
18344
18523
|
...swiftReproducibleBuildFlags([
|
|
18345
|
-
[
|
|
18524
|
+
[path30.dirname(options.toolchainBin), "toolchain"],
|
|
18346
18525
|
[frameworkRoot, "framework"],
|
|
18347
18526
|
[root, "build"],
|
|
18348
18527
|
...forwarders
|
|
18349
18528
|
]).flatMap((flag, index, flags) => {
|
|
18350
18529
|
if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
|
|
18351
18530
|
return [flag];
|
|
18352
|
-
const toolchainDir =
|
|
18531
|
+
const toolchainDir = path30.dirname(options.toolchainBin);
|
|
18353
18532
|
let mapped = flag;
|
|
18354
18533
|
for (const [dir, target] of [
|
|
18355
18534
|
[root, "/peach/build"],
|
|
@@ -18378,9 +18557,9 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18378
18557
|
])
|
|
18379
18558
|
];
|
|
18380
18559
|
const linked = builtArtifact(layout2);
|
|
18381
|
-
|
|
18382
|
-
if (options.linkOnly ||
|
|
18383
|
-
|
|
18560
|
+
rmSync8(path30.join(root, ".peach-link.rsp"), { force: true });
|
|
18561
|
+
if (options.linkOnly || existsSync7(linked) && statSync3(linked).size <= 8)
|
|
18562
|
+
rmSync8(linked, { force: true });
|
|
18384
18563
|
report("compiling and linking Swift modules");
|
|
18385
18564
|
const frameworkInterfaces = /* @__PURE__ */ new Map();
|
|
18386
18565
|
const nativeDeclarations = /* @__PURE__ */ new Map();
|
|
@@ -18390,58 +18569,58 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18390
18569
|
const name2 = moduleMapName(contents2);
|
|
18391
18570
|
const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
|
|
18392
18571
|
if (!name2 || !umbrella) continue;
|
|
18393
|
-
const header = input.files[
|
|
18572
|
+
const header = input.files[path30.posix.join(path30.posix.dirname(file), umbrella)];
|
|
18394
18573
|
if (header === void 0) continue;
|
|
18395
18574
|
const included = new Set(
|
|
18396
18575
|
[
|
|
18397
18576
|
...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
|
|
18398
|
-
].map((match) =>
|
|
18577
|
+
].map((match) => path30.posix.basename(match[1]))
|
|
18399
18578
|
);
|
|
18400
18579
|
const declarations = nativeDeclarations.get(name2) ?? /* @__PURE__ */ new Set();
|
|
18401
18580
|
for (const declaration of swiftInterfaceDeclarations(header))
|
|
18402
18581
|
declarations.add(declaration);
|
|
18403
18582
|
for (const [candidate, source] of Object.entries(input.files))
|
|
18404
|
-
if (included.has(
|
|
18583
|
+
if (included.has(path30.posix.basename(candidate)))
|
|
18405
18584
|
for (const declaration of swiftInterfaceDeclarations(source))
|
|
18406
18585
|
declarations.add(declaration);
|
|
18407
18586
|
nativeDeclarations.set(name2, declarations);
|
|
18408
18587
|
}
|
|
18409
18588
|
const frameworkInterface = (name2) => {
|
|
18410
18589
|
if (frameworkInterfaces.has(name2)) return frameworkInterfaces.get(name2);
|
|
18411
|
-
const source = distribution ?
|
|
18590
|
+
const source = distribution ? path30.join(frameworkRoot, "modules", `${name2}-Swift.h`) : path30.join(
|
|
18412
18591
|
prebuilt.modules,
|
|
18413
18592
|
"..",
|
|
18414
18593
|
`${name2}.build/include/${name2}-Swift.h`
|
|
18415
18594
|
);
|
|
18416
|
-
if (!
|
|
18595
|
+
if (!existsSync7(source)) {
|
|
18417
18596
|
frameworkInterfaces.set(name2, null);
|
|
18418
18597
|
return null;
|
|
18419
18598
|
}
|
|
18420
|
-
const headers =
|
|
18599
|
+
const headers = path30.join(
|
|
18421
18600
|
swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
|
|
18422
18601
|
`System/Library/Frameworks/${name2}.framework/Headers`
|
|
18423
18602
|
);
|
|
18424
18603
|
const declared = /* @__PURE__ */ new Set();
|
|
18425
|
-
if (
|
|
18604
|
+
if (existsSync7(headers)) {
|
|
18426
18605
|
for (const file of readdirSync8(headers, {
|
|
18427
18606
|
recursive: true,
|
|
18428
18607
|
encoding: "utf8"
|
|
18429
18608
|
}))
|
|
18430
18609
|
if (file.endsWith(".h"))
|
|
18431
18610
|
for (const name3 of swiftInterfaceDeclarations(
|
|
18432
|
-
|
|
18611
|
+
readFileSync18(path30.join(headers, file), "utf8")
|
|
18433
18612
|
))
|
|
18434
18613
|
declared.add(name3);
|
|
18435
18614
|
}
|
|
18436
18615
|
for (const declaration of nativeDeclarations.get(name2) ?? [])
|
|
18437
18616
|
declared.add(declaration);
|
|
18438
18617
|
const own = withoutSwiftDeclarations(
|
|
18439
|
-
clangInterfaceHeader(
|
|
18618
|
+
clangInterfaceHeader(readFileSync18(source, "utf8")),
|
|
18440
18619
|
declared,
|
|
18441
18620
|
nativeDeclarations.has(name2) ? `@import ${name2};` : `#import <${name2}/${name2}.h>`
|
|
18442
18621
|
);
|
|
18443
18622
|
const owners = sdkObjCDeclarationOwners(
|
|
18444
|
-
|
|
18623
|
+
path30.dirname(path30.dirname(headers))
|
|
18445
18624
|
);
|
|
18446
18625
|
const foreign = /* @__PURE__ */ new Map();
|
|
18447
18626
|
for (const declaration of [
|
|
@@ -18460,117 +18639,140 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18460
18639
|
[...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
|
|
18461
18640
|
) : own;
|
|
18462
18641
|
const value = {
|
|
18463
|
-
file:
|
|
18642
|
+
file: path30.join(root, ".build/peach-framework-objc", `${name2}-Swift.h`),
|
|
18464
18643
|
header,
|
|
18465
|
-
module:
|
|
18644
|
+
module: existsSync7(headers)
|
|
18466
18645
|
};
|
|
18467
18646
|
frameworkInterfaces.set(name2, value);
|
|
18468
18647
|
writeBuildFile(
|
|
18469
18648
|
value.file,
|
|
18470
|
-
(
|
|
18649
|
+
(existsSync7(path30.join(headers, `${name2}.h`)) ? `#import <${name2}/${name2}.h>
|
|
18471
18650
|
` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
|
|
18472
18651
|
);
|
|
18473
18652
|
return value;
|
|
18474
18653
|
};
|
|
18475
|
-
const
|
|
18654
|
+
const headerPaths = (producer) => {
|
|
18655
|
+
const stem = path30.join(
|
|
18656
|
+
root,
|
|
18657
|
+
".build",
|
|
18658
|
+
"peach-cxx-headers",
|
|
18659
|
+
`${producer}-Swift`
|
|
18660
|
+
);
|
|
18661
|
+
return { producer, original: `${stem}.original.h`, emitted: `${stem}.h` };
|
|
18662
|
+
};
|
|
18663
|
+
const publishHeader = ({
|
|
18664
|
+
producer,
|
|
18665
|
+
original,
|
|
18666
|
+
emitted
|
|
18667
|
+
}) => {
|
|
18668
|
+
const generated = clangInterfaceHeader(readFileSync18(original, "utf8"));
|
|
18669
|
+
writeBuildFile(
|
|
18670
|
+
emitted,
|
|
18671
|
+
withoutSwiftDeclarations(
|
|
18672
|
+
swiftHeaderWithSuperclassImports(generated, frameworkInterface),
|
|
18673
|
+
/* @__PURE__ */ new Set([
|
|
18674
|
+
...preparation.nativeHeaderDeclarations[producer] ?? [],
|
|
18675
|
+
...nativelyDeclaredFunctions(generated, nativeHeaders)
|
|
18676
|
+
]),
|
|
18677
|
+
`#import <${producer}/${producer}.h>`
|
|
18678
|
+
)
|
|
18679
|
+
);
|
|
18680
|
+
};
|
|
18681
|
+
const recipe = createHash15("sha256").update(hash).update(readFileSync18(path30.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
|
|
18682
|
+
const runApp = async (compiler2) => {
|
|
18683
|
+
const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
|
|
18476
18684
|
const stages = [
|
|
18477
18685
|
...preparation.headerBuilds,
|
|
18478
18686
|
...preparation.nativeProductTarget ? [{ target: preparation.nativeProductTarget, producers: [] }] : []
|
|
18479
18687
|
];
|
|
18480
|
-
const checkpoints =
|
|
18481
|
-
const recipe = createHash14("sha256").update(hash).update(readFileSync17(path28.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
|
|
18688
|
+
const checkpoints = path30.join(root, ".build", "peach-product-checkpoints");
|
|
18482
18689
|
for (const { target, producers } of stages) {
|
|
18483
|
-
const receipt =
|
|
18690
|
+
const receipt = path30.join(
|
|
18484
18691
|
checkpoints,
|
|
18485
|
-
|
|
18692
|
+
createHash15("sha256").update(target).digest("hex")
|
|
18486
18693
|
);
|
|
18487
|
-
const headers = producers.map(
|
|
18488
|
-
const stem = path28.join(
|
|
18489
|
-
root,
|
|
18490
|
-
".build",
|
|
18491
|
-
"peach-cxx-headers",
|
|
18492
|
-
`${producer}-Swift`
|
|
18493
|
-
);
|
|
18494
|
-
return {
|
|
18495
|
-
producer,
|
|
18496
|
-
original: `${stem}.original.h`,
|
|
18497
|
-
emitted: `${stem}.h`
|
|
18498
|
-
};
|
|
18499
|
-
});
|
|
18694
|
+
const headers = producers.map(headerPaths);
|
|
18500
18695
|
const fingerprint = () => {
|
|
18501
|
-
const digest =
|
|
18502
|
-
for (const { emitted } of headers) {
|
|
18503
|
-
if (!
|
|
18696
|
+
const digest = createHash15("sha256").update(recipe);
|
|
18697
|
+
for (const { original, emitted } of headers) {
|
|
18698
|
+
if (!existsSync7(original) || !existsSync7(emitted)) return;
|
|
18504
18699
|
digest.update(
|
|
18505
|
-
|
|
18700
|
+
createHash15("sha256").update(readFileSync18(emitted)).digest()
|
|
18506
18701
|
);
|
|
18507
18702
|
}
|
|
18508
18703
|
return digest.digest("hex");
|
|
18509
18704
|
};
|
|
18510
|
-
if (!options.project &&
|
|
18705
|
+
if (!options.project && existsSync7(receipt) && readFileSync18(receipt, "utf8") === fingerprint())
|
|
18511
18706
|
continue;
|
|
18512
|
-
if (!options.project)
|
|
18513
|
-
for (const
|
|
18514
|
-
if (
|
|
18515
|
-
|
|
18516
|
-
|
|
18517
|
-
|
|
18518
|
-
|
|
18519
|
-
WASM_TRIPLE,
|
|
18520
|
-
"release",
|
|
18707
|
+
if (!options.project) rmSync8(receipt, { force: true });
|
|
18708
|
+
for (const header of headers) {
|
|
18709
|
+
if (compiler2 && existsSync7(header.original)) publishHeader(header);
|
|
18710
|
+
if (!existsSync7(header.original))
|
|
18711
|
+
rmSync8(
|
|
18712
|
+
path30.join(
|
|
18713
|
+
path30.dirname(linked),
|
|
18521
18714
|
"Modules",
|
|
18522
|
-
`${swiftTargetModuleName(producer)}.swiftmodule`
|
|
18715
|
+
`${swiftTargetModuleName(header.producer)}.swiftmodule`
|
|
18523
18716
|
),
|
|
18524
18717
|
{ force: true }
|
|
18525
18718
|
);
|
|
18719
|
+
}
|
|
18526
18720
|
await runCompiler(
|
|
18527
18721
|
swift,
|
|
18528
18722
|
[...buildArgs, "--target", target],
|
|
18529
|
-
|
|
18723
|
+
optionsWithCompiler,
|
|
18530
18724
|
SWIFTPM_PROGRESS,
|
|
18531
18725
|
SWIFTPM_NOISE
|
|
18532
18726
|
);
|
|
18533
|
-
for (const
|
|
18534
|
-
const generated = clangInterfaceHeader(readFileSync17(original, "utf8"));
|
|
18535
|
-
writeBuildFile(
|
|
18536
|
-
emitted,
|
|
18537
|
-
withoutSwiftDeclarations(
|
|
18538
|
-
swiftHeaderWithSuperclassImports(generated, frameworkInterface),
|
|
18539
|
-
/* @__PURE__ */ new Set([
|
|
18540
|
-
...preparation.nativeHeaderDeclarations[producer] ?? [],
|
|
18541
|
-
...nativelyDeclaredFunctions(generated, nativeHeaders)
|
|
18542
|
-
]),
|
|
18543
|
-
`#import <${producer}/${producer}.h>`
|
|
18544
|
-
)
|
|
18545
|
-
);
|
|
18546
|
-
}
|
|
18727
|
+
if (!compiler2) for (const header of headers) publishHeader(header);
|
|
18547
18728
|
if (!options.project) {
|
|
18548
|
-
|
|
18549
|
-
|
|
18550
|
-
|
|
18729
|
+
const checkpoint = fingerprint();
|
|
18730
|
+
if (checkpoint === void 0)
|
|
18731
|
+
throw new Error(`missing Swift headers after building ${target}`);
|
|
18732
|
+
mkdirSync8(checkpoints, { recursive: true });
|
|
18733
|
+
writeFileSync9(`${receipt}.partial`, checkpoint);
|
|
18734
|
+
renameSync3(`${receipt}.partial`, receipt);
|
|
18551
18735
|
}
|
|
18552
18736
|
}
|
|
18553
18737
|
await runCompiler(
|
|
18554
18738
|
swift,
|
|
18555
18739
|
buildArgs,
|
|
18556
|
-
|
|
18740
|
+
optionsWithCompiler,
|
|
18557
18741
|
SWIFTPM_PROGRESS,
|
|
18558
18742
|
SWIFTPM_NOISE
|
|
18559
18743
|
);
|
|
18560
18744
|
};
|
|
18745
|
+
const compileApp = () => preparation.headerCompiler ? withSwiftHeaderCompiler(
|
|
18746
|
+
root,
|
|
18747
|
+
options.toolchainBin,
|
|
18748
|
+
recipe,
|
|
18749
|
+
new Map(
|
|
18750
|
+
preparation.headerBuilds[0].producers.map((producer) => {
|
|
18751
|
+
const paths = headerPaths(producer);
|
|
18752
|
+
return [
|
|
18753
|
+
swiftTargetModuleName(producer),
|
|
18754
|
+
{
|
|
18755
|
+
header: paths.original,
|
|
18756
|
+
publish: () => publishHeader(paths)
|
|
18757
|
+
}
|
|
18758
|
+
];
|
|
18759
|
+
})
|
|
18760
|
+
),
|
|
18761
|
+
runApp
|
|
18762
|
+
) : runApp();
|
|
18561
18763
|
try {
|
|
18562
18764
|
await compileApp();
|
|
18563
18765
|
} catch (error) {
|
|
18564
18766
|
const output2 = outputOf(error);
|
|
18565
|
-
const moduleCache =
|
|
18767
|
+
const moduleCache = path30.join(
|
|
18566
18768
|
root,
|
|
18567
18769
|
".build",
|
|
18568
18770
|
WASM_TRIPLE,
|
|
18569
18771
|
"release",
|
|
18570
18772
|
"ModuleCache"
|
|
18571
18773
|
);
|
|
18572
|
-
if (output2.includes("was compiled with module cache path") &&
|
|
18573
|
-
|
|
18774
|
+
if (output2.includes("was compiled with module cache path") && existsSync7(moduleCache)) {
|
|
18775
|
+
rmSync8(moduleCache, { recursive: true, force: true });
|
|
18574
18776
|
try {
|
|
18575
18777
|
await compileApp();
|
|
18576
18778
|
} catch (retryError) {
|
|
@@ -18594,11 +18796,11 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18594
18796
|
if (options.project) endSwiftProjectProcesses(options.project);
|
|
18595
18797
|
}
|
|
18596
18798
|
if (unprepared.length) throw new Error(unprepared.join("\n"));
|
|
18597
|
-
if (!
|
|
18598
|
-
const binDir =
|
|
18599
|
-
const found =
|
|
18799
|
+
if (!existsSync7(linked)) {
|
|
18800
|
+
const binDir = path30.dirname(linked);
|
|
18801
|
+
const found = existsSync7(binDir) ? readdirSync8(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
|
|
18600
18802
|
throw new Error(
|
|
18601
|
-
`swift-compile: the build produced no ${
|
|
18803
|
+
`swift-compile: the build produced no ${path30.basename(linked)} (found: ${found.join(", ") || "none"})`
|
|
18602
18804
|
);
|
|
18603
18805
|
}
|
|
18604
18806
|
if (options.project) removeProjectLinks(root);
|
|
@@ -18616,7 +18818,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18616
18818
|
resourceReferences
|
|
18617
18819
|
);
|
|
18618
18820
|
if (options.linkOnly) {
|
|
18619
|
-
if (
|
|
18821
|
+
if (statSync3(linked).size <= 8)
|
|
18620
18822
|
throw new Error("swift-compile: deferred linker produced no executable");
|
|
18621
18823
|
report("project link verified");
|
|
18622
18824
|
return;
|
|
@@ -18627,9 +18829,10 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18627
18829
|
await compileGuestLink({
|
|
18628
18830
|
graph: guestGraph,
|
|
18629
18831
|
buildDirectory: root,
|
|
18630
|
-
releaseDirectory:
|
|
18832
|
+
releaseDirectory: path30.dirname(linked),
|
|
18631
18833
|
moduleRoot: frameworkRoot,
|
|
18632
18834
|
toolchainBin: options.toolchainBin,
|
|
18835
|
+
swiftCompiler: preparation.headerCompiler ? path30.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : path30.join(options.toolchainBin, "swiftc"),
|
|
18633
18836
|
sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
|
|
18634
18837
|
sdk: swiftModuleSdk(frameworkRoot),
|
|
18635
18838
|
staticClangTargets: input.staticClangTargets ?? [],
|
|
@@ -18642,13 +18845,13 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18642
18845
|
else
|
|
18643
18846
|
await lowerWasm(output, optimized, { optimize: input.optimize === true });
|
|
18644
18847
|
await runCompiler(
|
|
18645
|
-
|
|
18848
|
+
path30.join(options.toolchainBin, "llvm-objcopy"),
|
|
18646
18849
|
["--remove-section=.swift1_autolink_entries", optimized],
|
|
18647
18850
|
buildOptions
|
|
18648
18851
|
);
|
|
18649
18852
|
const artifact = {
|
|
18650
18853
|
hash,
|
|
18651
|
-
bytes:
|
|
18854
|
+
bytes: readFileSync18(optimized),
|
|
18652
18855
|
icu: await icu
|
|
18653
18856
|
};
|
|
18654
18857
|
if (artifact.bytes.length <= 8)
|