peachsim 0.1.2223 → 0.1.2225
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/internal-child.ts +4 -2
- 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 +875 -468
- 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 +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +2 -2
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +811 -404
- 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 +870 -463
- package/dist-lib/host/fetch-proxy-handler.cjs +55 -12
- 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 +60 -16
- 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 +1 -1
- 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 +60 -16
- package/dist-lib/native-app-identity-project.cjs +53 -9
- package/dist-lib/native-app-identity-project.mjs +84 -37
- 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 +26 -24
- package/dist-lib/public-origins-lib.json +65 -54
- 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 +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +919 -511
- package/dist-lib/swift-compile.cjs +491 -119
- package/dist-lib/swift-compile.mjs +629 -257
- 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 +38 -2
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1665 -1217
- package/dist-lib/vite.cjs +55 -12
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/glass-material.d.ts +4 -0
- package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +3 -6
- package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/types.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/preview/preview-room-contract.d.ts +6 -0
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +12 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCGTypes.h +0 -6
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSCharacterSet.h +1 -1
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSURL.h +1 -1
- package/sdk/ios/usr/include/AvailabilityInternal.h +2 -2
- package/sdk/ios/usr/include/peach/pthread.h +1 -7
- package/sdk/ios/wasm/include/TargetConditionals.h +2 -3
- package/sdk/ios/wasm/include/__struct_timeval.h +15 -0
- package/sdk/ios/wasm/include/__typedef_suseconds_t.h +9 -0
- package/sdk/ios/wasm/include/limits.h +1 -1
- package/sdk/ios/wasm/include/machine/_types.h +1 -1
- package/sdk/ios/wasm/include/machine/limits.h +1 -1
- package/sdk/ios/wasm/include/machine/param.h +2 -2
- package/sdk/ios/wasm/include/math.h +13 -0
- package/sdk/ios/wasm/include/pthread.h +1 -13
- package/sdk/ios/wasm/include/sys/resource.h +3 -0
- package/sdk/ios/wasm/include/sys/socket.h +0 -10
- package/sdk/ios/wasm/include/sys/stat.h +5 -2
- package/sdk/ios/wasm/include/sys/time.h +16 -3
- package/sdk/ios/wasm/include/sys/types.h +4 -1
- package/sdk/ios/wasm/include/time.h +2 -0
- package/sdk/ios/wasm/storage-include/TargetConditionals.h +2 -3
- package/sdk/native-hashes.json +14 -14
- package/src/conformance-comparison-contract.ts +9 -9
- package/src/native-slices.ts +3 -2
- package/src/native-static-libraries.ts +23 -23
- package/src/native-swift-slices.ts +2 -2
- package/src/nitro-adapter.lock.json +288 -288
- package/src/nitro-compiler-digest.ts +0 -1
- package/src/nitro-dependencies.ts +8 -9
- package/src/nitro-superset.lock.json +4 -4
- package/src/react-native-core-build.ts +2 -2
- package/src/swift-compile.ts +132 -45
- package/src/swift-compiler-digest.ts +2 -0
- package/src/swift-cxx-standin.ts +1 -1
- package/src/swift-darwin-records.ts +4 -4
- package/src/swift-distribution-contract.ts +2 -2
- package/src/swift-distribution.lock.json +13 -12
- package/src/swift-guest-compile.ts +6 -5
- package/src/swift-guest-image-ledger.ts +5 -5
- package/src/swift-guest-link.ts +1 -1
- package/src/swift-guest-linked-spans.ts +7 -4
- package/src/swift-guest-manifest.ts +2 -2
- package/src/swift-guest-source-inputs.ts +16 -5
- package/src/swift-host.ts +33 -31
- package/src/swift-icu.ts +1 -1
- package/src/swift-objc-compile.ts +9 -4
- package/src/swift-objc-standin.ts +1 -4
- package/src/swift-package-manifest.ts +5 -1
- package/src/swift-packages.ts +2 -2
- package/src/swift-shared-sdk.ts +1 -1
- package/src/swift-standin-emit.ts +2 -16
- package/src/swift-standins.ts +111 -87
- package/src/swift-toolchain.ts +37 -1
- package/src/swift-uniform-type-constants.ts +1 -1
- package/src/swift-wasm-prune.ts +17 -12
- package/src/swiftGuestImageContract.ts +4 -4
- package/src/swiftNativePinContract.ts +1 -1
- package/src/swiftRuntimeProductContract.ts +1 -1
- package/src/turbo-runtime.lock.json +28 -28
- package/src/vite-plugin.ts +6 -1
- package/src/wasm-narrow-boundary.ts +296 -0
- package/src/wasm-optimize.ts +59 -14
- package/src/xcode-project.ts +6 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2225 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
|
|
3
3
|
// src/swift-compile.ts
|
|
4
4
|
import {
|
|
@@ -7,22 +7,23 @@ import {
|
|
|
7
7
|
} from "node:child_process";
|
|
8
8
|
import { createHash as createHash13, randomUUID as randomUUID5 } from "node:crypto";
|
|
9
9
|
import {
|
|
10
|
+
chmodSync as chmodSync2,
|
|
10
11
|
copyFileSync,
|
|
11
12
|
cpSync,
|
|
12
13
|
existsSync as existsSync5,
|
|
13
14
|
lstatSync,
|
|
14
|
-
mkdirSync as
|
|
15
|
+
mkdirSync as mkdirSync7,
|
|
15
16
|
mkdtempSync as mkdtempSync3,
|
|
16
|
-
readFileSync as
|
|
17
|
+
readFileSync as readFileSync17,
|
|
17
18
|
readdirSync as readdirSync8,
|
|
18
19
|
readlinkSync,
|
|
19
20
|
realpathSync as realpathSync5,
|
|
20
21
|
renameSync as renameSync2,
|
|
21
|
-
rmSync as
|
|
22
|
+
rmSync as rmSync7,
|
|
22
23
|
statSync as statSync2,
|
|
23
24
|
symlinkSync as symlinkSync2,
|
|
24
25
|
utimesSync,
|
|
25
|
-
writeFileSync as
|
|
26
|
+
writeFileSync as writeFileSync8
|
|
26
27
|
} from "node:fs";
|
|
27
28
|
import os6 from "node:os";
|
|
28
29
|
import path27 from "node:path";
|
|
@@ -2621,6 +2622,42 @@ function swiftSdkOptions() {
|
|
|
2621
2622
|
var SWIFT_HOST_COMPILER_RELEASE = "swift-6.4.0-RELEASE-custom-81b2c791c27276bf";
|
|
2622
2623
|
var SWIFT_HOST_COMPILER_ID = "81b2c791c27276bf";
|
|
2623
2624
|
var compilerArchives = {
|
|
2625
|
+
"swift-6.4.0-RELEASE-custom-fb42d2535739dfd2": {
|
|
2626
|
+
identity: "fb42d2535739dfd2",
|
|
2627
|
+
archive: "tar.zst",
|
|
2628
|
+
hosts: {
|
|
2629
|
+
"darwin-arm64": {
|
|
2630
|
+
checksum: "5e417d415ca74a435755e298a1d2d19ec47637fd03479de7a7d958eb382941f1",
|
|
2631
|
+
manifest: "eb5a0356aebabe89c7b2780f8809e13d6e2ad6f342fed87cf99f9a5834344363"
|
|
2632
|
+
},
|
|
2633
|
+
"linux-arm64": {
|
|
2634
|
+
checksum: "8ac7ad97f3d68bf485423001d1ce3cd92a8d4625313c47c8071867a9aeed3af9",
|
|
2635
|
+
manifest: "6126266dd65b43c43d719e4dc4d33c4ea6a3267f99f34e3638637439a995af2e"
|
|
2636
|
+
},
|
|
2637
|
+
"linux-x64": {
|
|
2638
|
+
checksum: "7d76463079619ba822123d250601bd35f6744ed5f8054a657ce472ce4dac76c8",
|
|
2639
|
+
manifest: "f1a6c0c61d15eddb2ecfa4c3a72a5154621881ac2f0c413162ff1d0f4343bd0e"
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
},
|
|
2643
|
+
"swift-6.4.0-RELEASE-custom-44ecd25f163bb359": {
|
|
2644
|
+
identity: "44ecd25f163bb359",
|
|
2645
|
+
archive: "tar.zst",
|
|
2646
|
+
hosts: {
|
|
2647
|
+
"darwin-arm64": {
|
|
2648
|
+
checksum: "d06dda4435f99d8376179cc7a3804907aa7305513135ece6288fd8e6d4695ae6",
|
|
2649
|
+
manifest: "bc0d8b955f923f096dda2aa8bbb1d56176a73f3d4a4df4cc9a1f59d31417061a"
|
|
2650
|
+
},
|
|
2651
|
+
"linux-x64": {
|
|
2652
|
+
checksum: "f95b56440693c5de7995f10ea14c57fc7e659a161018a17f17a74b61a98e88a4",
|
|
2653
|
+
manifest: "c18a60b14d5c89a8b2e1dbb2b4b52342c5fb92c7f3069fdc55c985bce61683a7"
|
|
2654
|
+
},
|
|
2655
|
+
"linux-arm64": {
|
|
2656
|
+
checksum: "afb74ae60df2b5bd7792bfbcf29bcea03675a5c814b758dd6cb91a760c220cd2",
|
|
2657
|
+
manifest: "ac037f6b0fdc4a6ae582eebc22bcf811fa2becdc30d083057137fc857f3c456a"
|
|
2658
|
+
}
|
|
2659
|
+
}
|
|
2660
|
+
},
|
|
2624
2661
|
"swift-6.4.0-RELEASE-custom-11345d60dca47496": {
|
|
2625
2662
|
identity: "11345d60dca47496",
|
|
2626
2663
|
archive: "tar.zst",
|
|
@@ -3028,7 +3065,7 @@ function validateSwiftSdkIdentity(sdk) {
|
|
|
3028
3065
|
function swiftSdkBundle(swift, id, options) {
|
|
3029
3066
|
const configuration = execFileSync(
|
|
3030
3067
|
swift,
|
|
3031
|
-
["sdk", "configure", ...options, "--show-configuration", id, "
|
|
3068
|
+
["sdk", "configure", ...options, "--show-configuration", id, "wasm64-unknown-wasip1"],
|
|
3032
3069
|
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
3033
3070
|
);
|
|
3034
3071
|
const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim();
|
|
@@ -3834,14 +3871,11 @@ function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
|
|
|
3834
3871
|
return [
|
|
3835
3872
|
...swiftObjCPlatformFlags(toolchainBin, minimum),
|
|
3836
3873
|
// AvailabilityInternal.h derives these through __is_target_os(ios), which
|
|
3837
|
-
// is false for
|
|
3874
|
+
// is false for wasm64. the maximum is the sdk the headers come from, as
|
|
3838
3875
|
// xcode defines it, so `#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_26_0`
|
|
3839
3876
|
// sources see the members the sdk declares instead of a 17.0 default.
|
|
3840
3877
|
`-D__IPHONE_OS_VERSION_MIN_REQUIRED=${minimum}`,
|
|
3841
3878
|
`-D__IPHONE_OS_VERSION_MAX_ALLOWED=__IPHONE_${NATIVE_GRAPH_SDK_VERSION.replace(".", "_")}`,
|
|
3842
|
-
// apple's build setting for a 32-bit target to keep NSInteger and
|
|
3843
|
-
// NSUInteger long, the nominal types they have on arm64.
|
|
3844
|
-
"-DNS_BUILD_32_LIKE_64=1",
|
|
3845
3879
|
// the installed libc's default feature set otherwise defines
|
|
3846
3880
|
// _XOPEN_SOURCE, which darwin's sys/cdefs.h turns into a strict posix
|
|
3847
3881
|
// level; iOS compiles at darwin's full level with neither defined.
|
|
@@ -4111,7 +4145,7 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
|
|
|
4111
4145
|
...swiftSdkOptions(),
|
|
4112
4146
|
"--show-configuration",
|
|
4113
4147
|
sdk,
|
|
4114
|
-
"
|
|
4148
|
+
"wasm64-unknown-wasip1"
|
|
4115
4149
|
],
|
|
4116
4150
|
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
4117
4151
|
);
|
|
@@ -4248,7 +4282,7 @@ function compileDarwinRecords(args) {
|
|
|
4248
4282
|
execFileSync4(
|
|
4249
4283
|
path9.join(args.bin, "clang"),
|
|
4250
4284
|
[
|
|
4251
|
-
"--target=
|
|
4285
|
+
"--target=wasm64-unknown-wasip1",
|
|
4252
4286
|
`--sysroot=${args.sysroot}`,
|
|
4253
4287
|
"-Oz",
|
|
4254
4288
|
"-g0",
|
|
@@ -4259,7 +4293,7 @@ function compileDarwinRecords(args) {
|
|
|
4259
4293
|
`-ffile-prefix-map=${records}${path9.sep}=DarwinRecords/`,
|
|
4260
4294
|
// apple's headers select on the ios identity original units compile
|
|
4261
4295
|
// with, and TargetConditionals.h refuses a compiler without it
|
|
4262
|
-
...file.endsWith(".m") ? objcSdkIntakeFlags(args.darwin, args.bin, args.minimum) : [
|
|
4296
|
+
...file === "sysctl.c" || file.endsWith(".m") ? objcSdkIntakeFlags(args.darwin, args.bin, args.minimum) : [
|
|
4263
4297
|
...swiftObjCPlatformFlags(args.bin, args.minimum),
|
|
4264
4298
|
...WASI_EMULATION_FLAGS,
|
|
4265
4299
|
// the sdk build compiles these with libobjc2's headers in
|
|
@@ -4727,7 +4761,7 @@ var foundationCategoryObjects = [
|
|
|
4727
4761
|
|
|
4728
4762
|
// src/swift-guest-compile.ts
|
|
4729
4763
|
import { execFileSync as execFileSync9 } from "node:child_process";
|
|
4730
|
-
import { mkdirSync as
|
|
4764
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync12, writeFileSync as writeFileSync5 } from "node:fs";
|
|
4731
4765
|
import path19 from "node:path";
|
|
4732
4766
|
|
|
4733
4767
|
// src/swift-guest-archive.ts
|
|
@@ -4785,7 +4819,7 @@ var swiftSdkProductSchema = v.pipe(
|
|
|
4785
4819
|
v.object({
|
|
4786
4820
|
id: v.string(),
|
|
4787
4821
|
installName: v.string(),
|
|
4788
|
-
target: v.literal("
|
|
4822
|
+
target: v.literal("wasm64-unknown-wasip1"),
|
|
4789
4823
|
linkNames: v.array(v.string()),
|
|
4790
4824
|
// absent records declare no framework namespace, even when a library name matches.
|
|
4791
4825
|
frameworkAliases: v.optional(
|
|
@@ -4894,7 +4928,8 @@ function encodeULEB(val) {
|
|
|
4894
4928
|
} while (val !== 0);
|
|
4895
4929
|
return out;
|
|
4896
4930
|
}
|
|
4897
|
-
var HAS_ADDEND = /* @__PURE__ */ new Set([3, 4, 5, 8, 9, 11,
|
|
4931
|
+
var HAS_ADDEND = /* @__PURE__ */ new Set([3, 4, 5, 8, 9, 11, 14, 15, 16, 17, 21, 22, 23, 25]);
|
|
4932
|
+
var WIDE_DATA_RELOCS = /* @__PURE__ */ new Set([16, 19, 22]);
|
|
4898
4933
|
var ROOT_SEG_PREFIXES = [
|
|
4899
4934
|
".init_array",
|
|
4900
4935
|
"__objc_init_func",
|
|
@@ -5790,7 +5825,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
5790
5825
|
} else {
|
|
5791
5826
|
lazyBuildObjects.set(t, parseWasmObjectCached(t, false, false));
|
|
5792
5827
|
}
|
|
5793
|
-
} else if (!inStartLib && t.endsWith(".a") && !t.endsWith("libclang_rt.builtins-
|
|
5828
|
+
} else if (!inStartLib && t.endsWith(".a") && !t.endsWith("libclang_rt.builtins-wasm64.a") && fs4.existsSync(t)) {
|
|
5794
5829
|
const members = readArMembers(new Uint8Array(fs4.readFileSync(t)));
|
|
5795
5830
|
for (const m of members) {
|
|
5796
5831
|
extraArchiveObjs.push(parseWasmObjectBytes(`${t}(${m.name})`, m.bytes, false));
|
|
@@ -6272,7 +6307,11 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6272
6307
|
}
|
|
6273
6308
|
}
|
|
6274
6309
|
const keptDataRelocBytes = [];
|
|
6275
|
-
const
|
|
6310
|
+
const zeroDataRelocs = [];
|
|
6311
|
+
const zeroDataReloc = (r) => zeroDataRelocs.push({
|
|
6312
|
+
ro: r.ro,
|
|
6313
|
+
width: WIDE_DATA_RELOCS.has(r.rawBytes[0]) ? 8 : 4
|
|
6314
|
+
});
|
|
6276
6315
|
const usedSyms = /* @__PURE__ */ new Set();
|
|
6277
6316
|
for (const r of keptCodeRelocs) if (r.rawBytes[0] !== 6) usedSyms.add(r.rs);
|
|
6278
6317
|
for (const r of obj.dataRelocList) {
|
|
@@ -6283,7 +6322,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6283
6322
|
keptDataRelocBytes.push(r.rawBytes);
|
|
6284
6323
|
usedSyms.add(r.rs);
|
|
6285
6324
|
} else if (sName === "__objc_classes") {
|
|
6286
|
-
|
|
6325
|
+
zeroDataReloc(r);
|
|
6287
6326
|
} else {
|
|
6288
6327
|
const repl = firstLiveInSpecialSeg.get(r.segIdx);
|
|
6289
6328
|
const roBytes = encodeULEB(r.ro);
|
|
@@ -6296,17 +6335,17 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6296
6335
|
} else if (r.ownerSymIdx !== -1) {
|
|
6297
6336
|
if (dLive.has(r.ownerSymIdx)) {
|
|
6298
6337
|
if (obj.isDist && dropsReflection(obj, obj.symNames[r.rs])) {
|
|
6299
|
-
|
|
6338
|
+
zeroDataReloc(r);
|
|
6300
6339
|
} else {
|
|
6301
6340
|
keptDataRelocBytes.push(r.rawBytes);
|
|
6302
6341
|
usedSyms.add(r.rs);
|
|
6303
6342
|
}
|
|
6304
6343
|
} else if (sName === "__objc_class_refs") {
|
|
6305
|
-
|
|
6344
|
+
zeroDataReloc(r);
|
|
6306
6345
|
}
|
|
6307
6346
|
} else if (sLive[r.segIdx] === 1) {
|
|
6308
6347
|
if (obj.isDist && obj.symNames[r.rs]?.startsWith("l__swift5_reflection_descriptor") && dropsReflection(obj, obj.symNames[r.rs])) {
|
|
6309
|
-
|
|
6348
|
+
zeroDataReloc(r);
|
|
6310
6349
|
} else {
|
|
6311
6350
|
keptDataRelocBytes.push(r.rawBytes);
|
|
6312
6351
|
usedSyms.add(r.rs);
|
|
@@ -6489,11 +6528,8 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6489
6528
|
outChunks.push(buf.subarray(secStart, end));
|
|
6490
6529
|
}
|
|
6491
6530
|
} else {
|
|
6492
|
-
if (id === 11
|
|
6493
|
-
for (const ro of
|
|
6494
|
-
buf.fill(0, p + ro, p + ro + 4);
|
|
6495
|
-
}
|
|
6496
|
-
}
|
|
6531
|
+
if (id === 11)
|
|
6532
|
+
for (const { ro, width } of zeroDataRelocs) buf.fill(0, p + ro, p + ro + width);
|
|
6497
6533
|
outChunks.push(buf.subarray(secStart, end));
|
|
6498
6534
|
}
|
|
6499
6535
|
pos = end;
|
|
@@ -6669,7 +6705,7 @@ function readNumber(bytes, position) {
|
|
|
6669
6705
|
let value = 0;
|
|
6670
6706
|
let shift = 0;
|
|
6671
6707
|
for (; ; ) {
|
|
6672
|
-
if (position >= bytes.length || shift >
|
|
6708
|
+
if (position >= bytes.length || shift > 63) throw new Error("invalid wasm integer");
|
|
6673
6709
|
const byte = bytes[position++];
|
|
6674
6710
|
value += (byte & 127) * 2 ** shift;
|
|
6675
6711
|
if (!(byte & 128)) return [value, position];
|
|
@@ -6716,7 +6752,7 @@ var OBJC_INIT_RECORD = ".objc_init";
|
|
|
6716
6752
|
function rewriteObject(bytes, names, callerAlias, bindings, instrumentDynamicLookups, preserveCanonical) {
|
|
6717
6753
|
if (Buffer.from(bytes.subarray(0, 8)).toString("hex") !== "0061736d01000000")
|
|
6718
6754
|
throw new Error("expected wasm object");
|
|
6719
|
-
const
|
|
6755
|
+
const sections2 = [Buffer.from(bytes.subarray(0, 8))];
|
|
6720
6756
|
const types = [];
|
|
6721
6757
|
const functionTypes = [];
|
|
6722
6758
|
const definitions = [];
|
|
@@ -6773,12 +6809,12 @@ function rewriteObject(bytes, names, callerAlias, bindings, instrumentDynamicLoo
|
|
|
6773
6809
|
if (referenceType !== 112 && referenceType !== 111)
|
|
6774
6810
|
throw new Error("unsupported table type");
|
|
6775
6811
|
const flags = number3();
|
|
6776
|
-
if (flags & ~
|
|
6812
|
+
if (flags & ~7) throw new Error("unsupported table limits");
|
|
6777
6813
|
number3();
|
|
6778
6814
|
if (flags & 1) number3();
|
|
6779
6815
|
} else if (kind === 2) {
|
|
6780
6816
|
const flags = number3();
|
|
6781
|
-
if (flags & ~
|
|
6817
|
+
if (flags & ~7) throw new Error("unsupported memory limits");
|
|
6782
6818
|
number3();
|
|
6783
6819
|
if (flags & 1) number3();
|
|
6784
6820
|
} else if (kind === 3) offset += 2;
|
|
@@ -6791,7 +6827,7 @@ function rewriteObject(bytes, names, callerAlias, bindings, instrumentDynamicLoo
|
|
|
6791
6827
|
if (module === "env" && names.has(name2)) usedSymbols.add(name2);
|
|
6792
6828
|
if (isDlsym || isDlerror) {
|
|
6793
6829
|
const type = types[functionType];
|
|
6794
|
-
const expected = isDlsym ? "
|
|
6830
|
+
const expected = isDlsym ? "126,126:126" : ":126";
|
|
6795
6831
|
if (!type || `${type.parameters.join(",")}:${type.results.join(",")}` !== expected)
|
|
6796
6832
|
throw new Error(`unexpected ${name2} import type`);
|
|
6797
6833
|
}
|
|
@@ -6933,10 +6969,10 @@ function rewriteObject(bytes, names, callerAlias, bindings, instrumentDynamicLoo
|
|
|
6933
6969
|
section = Buffer.concat(parts);
|
|
6934
6970
|
}
|
|
6935
6971
|
}
|
|
6936
|
-
|
|
6972
|
+
sections2.push(Buffer.from([id]), encodeNumber(section.length), section);
|
|
6937
6973
|
}
|
|
6938
6974
|
return {
|
|
6939
|
-
bytes: Buffer.concat(
|
|
6975
|
+
bytes: Buffer.concat(sections2),
|
|
6940
6976
|
definitions,
|
|
6941
6977
|
usesDlsym,
|
|
6942
6978
|
usedSymbols: [...usedSymbols]
|
|
@@ -7103,7 +7139,7 @@ function createGuestImageLedger(input) {
|
|
|
7103
7139
|
return [...bytes].map((byte) => `\\${byte.toString(16).padStart(2, "0")}`).join("");
|
|
7104
7140
|
}).join("");
|
|
7105
7141
|
const ir = [
|
|
7106
|
-
'target triple = "
|
|
7142
|
+
'target triple = "wasm64-unknown-wasip1"',
|
|
7107
7143
|
`@.names = private constant [${nameSize} x i8] c"${nameContents}"`
|
|
7108
7144
|
];
|
|
7109
7145
|
for (const definition of exported.values()) {
|
|
@@ -7222,8 +7258,8 @@ function selectedGuestManifestInputs(plan, selection, identities) {
|
|
|
7222
7258
|
}
|
|
7223
7259
|
function createGuestImageManifest(image) {
|
|
7224
7260
|
const target = {
|
|
7225
|
-
triple: "
|
|
7226
|
-
pointerWidth:
|
|
7261
|
+
triple: "wasm64-unknown-wasip1",
|
|
7262
|
+
pointerWidth: 64,
|
|
7227
7263
|
byteOrder: "little",
|
|
7228
7264
|
cpuType: -1,
|
|
7229
7265
|
cpuSubtype: 0
|
|
@@ -7283,6 +7319,7 @@ function number2(bytes, start) {
|
|
|
7283
7319
|
shift += 7;
|
|
7284
7320
|
}
|
|
7285
7321
|
}
|
|
7322
|
+
var constant = (opcode) => opcode === 65 || opcode === 66;
|
|
7286
7323
|
function signedAddress(bytes, start) {
|
|
7287
7324
|
const [value, end] = number2(bytes, start);
|
|
7288
7325
|
const bits = (end - start) * 7;
|
|
@@ -7292,16 +7329,16 @@ function signedAddress(bytes, start) {
|
|
|
7292
7329
|
function layout(bytes) {
|
|
7293
7330
|
if (Buffer.from(bytes.subarray(0, 8)).toString("hex") !== "0061736d01000000")
|
|
7294
7331
|
throw new Error("expected linked wasm module");
|
|
7295
|
-
const
|
|
7332
|
+
const sections2 = /* @__PURE__ */ new Map();
|
|
7296
7333
|
let offset = 8;
|
|
7297
7334
|
while (offset < bytes.length) {
|
|
7298
7335
|
const id = bytes[offset++];
|
|
7299
7336
|
const [size, start] = number2(bytes, offset);
|
|
7300
7337
|
if (start + size > bytes.length) throw new Error("invalid wasm section");
|
|
7301
|
-
if (id)
|
|
7338
|
+
if (id) sections2.set(id, [start, start + size]);
|
|
7302
7339
|
offset = start + size;
|
|
7303
7340
|
}
|
|
7304
|
-
const exports =
|
|
7341
|
+
const exports = sections2.get(7);
|
|
7305
7342
|
if (!exports) throw new Error("guest wasm does not export memory and table");
|
|
7306
7343
|
let exportPosition = exports[0];
|
|
7307
7344
|
const readExport = () => {
|
|
@@ -7322,7 +7359,7 @@ function layout(bytes) {
|
|
|
7322
7359
|
throw new Error("guest wasm does not export memory and table");
|
|
7323
7360
|
let imports = 0;
|
|
7324
7361
|
let memoryPages;
|
|
7325
|
-
const section =
|
|
7362
|
+
const section = sections2.get(2);
|
|
7326
7363
|
if (section) {
|
|
7327
7364
|
let pos = section[0];
|
|
7328
7365
|
const read = () => {
|
|
@@ -7337,7 +7374,7 @@ function layout(bytes) {
|
|
|
7337
7374
|
};
|
|
7338
7375
|
const limits = () => {
|
|
7339
7376
|
const flags = read();
|
|
7340
|
-
if (flags & ~
|
|
7377
|
+
if (flags & ~7) throw new Error("unsupported wasm limits");
|
|
7341
7378
|
const minimum = read();
|
|
7342
7379
|
if (flags & 1) read();
|
|
7343
7380
|
return minimum;
|
|
@@ -7365,7 +7402,7 @@ function layout(bytes) {
|
|
|
7365
7402
|
}
|
|
7366
7403
|
if (pos !== section[1]) throw new Error("invalid wasm imports");
|
|
7367
7404
|
}
|
|
7368
|
-
const memory =
|
|
7405
|
+
const memory = sections2.get(5);
|
|
7369
7406
|
if (memory) {
|
|
7370
7407
|
let pos = memory[0];
|
|
7371
7408
|
const read = () => {
|
|
@@ -7376,14 +7413,14 @@ function layout(bytes) {
|
|
|
7376
7413
|
if (read() !== 1 || memoryPages !== void 0)
|
|
7377
7414
|
throw new Error("unsupported wasm memories");
|
|
7378
7415
|
const flags = read();
|
|
7379
|
-
if (flags & ~
|
|
7416
|
+
if (flags & ~7) throw new Error("unsupported wasm memory limits");
|
|
7380
7417
|
memoryPages = read();
|
|
7381
7418
|
if (flags & 1) read();
|
|
7382
7419
|
if (pos !== memory[1]) throw new Error("invalid wasm memory section");
|
|
7383
7420
|
}
|
|
7384
7421
|
if (memoryPages === void 0) throw new Error("guest wasm has no memory");
|
|
7385
7422
|
const functionsByCodeOffset = /* @__PURE__ */ new Map();
|
|
7386
|
-
const code =
|
|
7423
|
+
const code = sections2.get(10);
|
|
7387
7424
|
if (code) {
|
|
7388
7425
|
let pos = code[0];
|
|
7389
7426
|
let count;
|
|
@@ -7399,7 +7436,7 @@ function layout(bytes) {
|
|
|
7399
7436
|
if (pos !== code[1]) throw new Error("invalid wasm code section");
|
|
7400
7437
|
}
|
|
7401
7438
|
const functionsByTableSlot = /* @__PURE__ */ new Map();
|
|
7402
|
-
const elements =
|
|
7439
|
+
const elements = sections2.get(9);
|
|
7403
7440
|
if (elements) {
|
|
7404
7441
|
let pos = elements[0];
|
|
7405
7442
|
const read = () => {
|
|
@@ -7413,7 +7450,7 @@ function layout(bytes) {
|
|
|
7413
7450
|
if (flags !== 0 && flags !== 2)
|
|
7414
7451
|
throw new Error(`unsupported wasm element segment ${flags}`);
|
|
7415
7452
|
if (flags === 2 && read() !== 0) throw new Error("unsupported wasm table index");
|
|
7416
|
-
if (bytes[pos++]
|
|
7453
|
+
if (!constant(bytes[pos++])) throw new Error("nonconstant wasm table offset");
|
|
7417
7454
|
let base;
|
|
7418
7455
|
[base, pos] = signedAddress(bytes, pos);
|
|
7419
7456
|
if (bytes[pos++] !== 11) throw new Error("invalid wasm table offset");
|
|
@@ -7430,7 +7467,7 @@ function layout(bytes) {
|
|
|
7430
7467
|
if (pos !== elements[1]) throw new Error("invalid wasm element section");
|
|
7431
7468
|
}
|
|
7432
7469
|
const data = [];
|
|
7433
|
-
const dataSection =
|
|
7470
|
+
const dataSection = sections2.get(11);
|
|
7434
7471
|
if (dataSection) {
|
|
7435
7472
|
let pos = dataSection[0];
|
|
7436
7473
|
const read = () => {
|
|
@@ -7444,7 +7481,7 @@ function layout(bytes) {
|
|
|
7444
7481
|
if (flags !== 0 && flags !== 2)
|
|
7445
7482
|
throw new Error(`unsupported wasm data segment ${flags}`);
|
|
7446
7483
|
if (flags === 2 && read() !== 0) throw new Error("unsupported wasm memory index");
|
|
7447
|
-
if (bytes[pos++]
|
|
7484
|
+
if (!constant(bytes[pos++])) throw new Error("nonconstant wasm data offset");
|
|
7448
7485
|
let address;
|
|
7449
7486
|
[address, pos] = signedAddress(bytes, pos);
|
|
7450
7487
|
if (bytes[pos++] !== 11) throw new Error("invalid wasm data offset");
|
|
@@ -7566,7 +7603,7 @@ function isSwiftGuestImageManifest(value) {
|
|
|
7566
7603
|
const text2 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
|
|
7567
7604
|
const name2 = (value2) => text2(value2) && new TextEncoder().encode(value2).length <= 16;
|
|
7568
7605
|
const version2 = (value2) => isRecord(value2) && uint(value2.major, 65535) && uint(value2.minor, 255) && uint(value2.patch, 255);
|
|
7569
|
-
if (!isRecord(value) || value.version !== 1 || !text2(value.id) || !text2(value.installName) || value.fileType !== "executable" && value.fileType !== "dylib" || !isRecord(value.target) || value.target.triple !== "
|
|
7606
|
+
if (!isRecord(value) || value.version !== 1 || !text2(value.id) || !text2(value.installName) || value.fileType !== "executable" && value.fileType !== "dylib" || !isRecord(value.target) || value.target.triple !== "wasm64-unknown-wasip1" || value.target.pointerWidth !== 64 || value.target.byteOrder !== "little" || value.target.cpuType !== -1 || value.target.cpuSubtype !== 0 || typeof value.inputsSha256 !== "string" || !/^[a-f0-9]{64}$/.test(value.inputsSha256) || value.uuid !== value.inputsSha256.slice(0, 32) || !isRecord(value.buildVersion) || !uint(value.buildVersion.platform, 4294967295) || !version2(value.buildVersion.minimum) || !version2(value.buildVersion.sdk) || !Array.isArray(value.regions))
|
|
7570
7607
|
return false;
|
|
7571
7608
|
return value.regions.every((region) => {
|
|
7572
7609
|
if (!isRecord(region) || !name2(region.name) || region.space !== "linear-memory" && region.space !== "function-table" || !uint(region.address, 4294967295) || !uint(region.length, 4294967295) || region.address + region.length > 4294967296 || !uint(region.initialProtection, 7) || !uint(region.maximumProtection, 7) || (region.initialProtection & region.maximumProtection) !== region.initialProtection || !Array.isArray(region.sections))
|
|
@@ -8999,7 +9036,7 @@ function linkGuestImages(options) {
|
|
|
8999
9036
|
fs5.writeFileSync(irPath, ledger.llvmIR);
|
|
9000
9037
|
execFileSync7(
|
|
9001
9038
|
clang,
|
|
9002
|
-
["--target=
|
|
9039
|
+
["--target=wasm64-unknown-wasip1", "-c", irPath, "-o", ledgerObject],
|
|
9003
9040
|
{ stdio: "pipe" }
|
|
9004
9041
|
);
|
|
9005
9042
|
linkedOwners.set(ledgerObject, options.ledgerDataImage);
|
|
@@ -9641,7 +9678,7 @@ function linkPrunedGuestImages(options) {
|
|
|
9641
9678
|
// src/swift-guest-source-inputs.ts
|
|
9642
9679
|
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
9643
9680
|
import { createHash as createHash10 } from "node:crypto";
|
|
9644
|
-
import { readFileSync as readFileSync10, realpathSync as realpathSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
9681
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, realpathSync as realpathSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
9645
9682
|
import path15 from "node:path";
|
|
9646
9683
|
function clangIrLinkOptions(ir) {
|
|
9647
9684
|
const list = /^!llvm\.linker\.options = !\{([^\n]*)\}$/m.exec(ir);
|
|
@@ -9672,6 +9709,7 @@ function clangIrLinkOptions(ir) {
|
|
|
9672
9709
|
}
|
|
9673
9710
|
return result;
|
|
9674
9711
|
}
|
|
9712
|
+
var CLANG_TARGET_MODULE_WRAPPER = ".peach-clang";
|
|
9675
9713
|
function sourceGuestClangLinkOptions(options) {
|
|
9676
9714
|
const wanted = new Set(options.objects.map((file) => path15.resolve(file)));
|
|
9677
9715
|
const commands = /* @__PURE__ */ new Map();
|
|
@@ -9714,10 +9752,16 @@ function sourceGuestClangLinkOptions(options) {
|
|
|
9714
9752
|
throw new Error(`unsupported source object producer ${file}`);
|
|
9715
9753
|
continue;
|
|
9716
9754
|
}
|
|
9717
|
-
|
|
9755
|
+
const compiler = command.args[0] ? realpathSync2(command.args[0]) : "";
|
|
9756
|
+
if (command.tool !== "clang" || compiler !== realpathSync2(path15.join(options.toolchainBin, "clang")) && compiler !== realpathSync2(path15.join(options.buildDirectory, CLANG_TARGET_MODULE_WRAPPER)))
|
|
9718
9757
|
throw new Error(`unsupported source object producer ${file}`);
|
|
9719
9758
|
const args = command.args.slice(1).filter((arg) => arg !== "-c");
|
|
9720
|
-
const
|
|
9759
|
+
const outputDirectory = path15.join(
|
|
9760
|
+
options.directory,
|
|
9761
|
+
path15.basename(path15.dirname(file))
|
|
9762
|
+
);
|
|
9763
|
+
mkdirSync2(outputDirectory, { recursive: true });
|
|
9764
|
+
const output = path15.join(outputDirectory, `clang-link-${index}.ll`);
|
|
9721
9765
|
for (const flag of ["-o", "-MF"]) {
|
|
9722
9766
|
const index2 = args.lastIndexOf(flag);
|
|
9723
9767
|
if (index2 < 0 || index2 + 1 >= args.length)
|
|
@@ -9957,8 +10001,10 @@ function logicalGuestLinkOptions(args, identities, roots) {
|
|
|
9957
10001
|
}
|
|
9958
10002
|
|
|
9959
10003
|
// src/wasm-optimize.ts
|
|
9960
|
-
import {
|
|
9961
|
-
import {
|
|
10004
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
10005
|
+
import { existsSync, readFileSync as readFileSync11, rmSync as rmSync4, writeFileSync as writeFileSync4 } from "node:fs";
|
|
10006
|
+
import { dirname, join as join2 } from "node:path";
|
|
10007
|
+
import { promisify as promisify2 } from "node:util";
|
|
9962
10008
|
|
|
9963
10009
|
// ../contrast-runtime-delivery/src/index.ts
|
|
9964
10010
|
import { spawn as spawn3 } from "node:child_process";
|
|
@@ -10196,8 +10242,244 @@ function rnxHomeDir() {
|
|
|
10196
10242
|
}
|
|
10197
10243
|
var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
|
|
10198
10244
|
|
|
10245
|
+
// src/wasm-narrow-boundary.ts
|
|
10246
|
+
var I64 = 126;
|
|
10247
|
+
var VALUE_TYPES = /* @__PURE__ */ new Map([
|
|
10248
|
+
[127, "i32"],
|
|
10249
|
+
[I64, "i64"],
|
|
10250
|
+
[125, "f32"],
|
|
10251
|
+
[124, "f64"],
|
|
10252
|
+
[123, "v128"],
|
|
10253
|
+
[112, "funcref"],
|
|
10254
|
+
[111, "externref"]
|
|
10255
|
+
]);
|
|
10256
|
+
var GUEST = "guest";
|
|
10257
|
+
var BOUNDARY = "boundary";
|
|
10258
|
+
var WIDE = "$wide.";
|
|
10259
|
+
var NARROW = "$narrow.";
|
|
10260
|
+
function encodeNumber2(value) {
|
|
10261
|
+
const bytes = [];
|
|
10262
|
+
for (let rest = value; ; ) {
|
|
10263
|
+
const byte = rest % 128;
|
|
10264
|
+
rest = Math.floor(rest / 128);
|
|
10265
|
+
if (rest === 0) return [...bytes, byte];
|
|
10266
|
+
bytes.push(byte | 128);
|
|
10267
|
+
}
|
|
10268
|
+
}
|
|
10269
|
+
function encodeName(name2) {
|
|
10270
|
+
const bytes = [...Buffer.from(name2)];
|
|
10271
|
+
return [...encodeNumber2(bytes.length), ...bytes];
|
|
10272
|
+
}
|
|
10273
|
+
function reader(bytes, start, end) {
|
|
10274
|
+
let at = start;
|
|
10275
|
+
const number3 = () => {
|
|
10276
|
+
let value = 0;
|
|
10277
|
+
for (let shift = 0; ; shift += 7) {
|
|
10278
|
+
if (at >= end || shift > 63) throw new Error("invalid wasm integer");
|
|
10279
|
+
const byte = bytes[at++];
|
|
10280
|
+
value += (byte & 127) * 2 ** shift;
|
|
10281
|
+
if (!(byte & 128)) return value;
|
|
10282
|
+
}
|
|
10283
|
+
};
|
|
10284
|
+
return {
|
|
10285
|
+
number: number3,
|
|
10286
|
+
byte: () => {
|
|
10287
|
+
if (at >= end) throw new Error("truncated wasm section");
|
|
10288
|
+
return bytes[at++];
|
|
10289
|
+
},
|
|
10290
|
+
name: () => {
|
|
10291
|
+
const length = number3();
|
|
10292
|
+
at += length;
|
|
10293
|
+
if (at > end) throw new Error("truncated wasm name");
|
|
10294
|
+
return Buffer.from(bytes.subarray(at - length, at)).toString();
|
|
10295
|
+
},
|
|
10296
|
+
position: () => at,
|
|
10297
|
+
done: () => at === end
|
|
10298
|
+
};
|
|
10299
|
+
}
|
|
10300
|
+
function sections(bytes) {
|
|
10301
|
+
if (Buffer.from(bytes.subarray(0, 8)).toString("hex") !== "0061736d01000000")
|
|
10302
|
+
throw new Error("not a wasm module");
|
|
10303
|
+
const found = [];
|
|
10304
|
+
for (let at = 8; at < bytes.length; ) {
|
|
10305
|
+
const header = reader(bytes, at, bytes.length);
|
|
10306
|
+
const id = header.byte();
|
|
10307
|
+
const size = header.number();
|
|
10308
|
+
const start = header.position();
|
|
10309
|
+
found.push({ id, start, end: start + size });
|
|
10310
|
+
at = start + size;
|
|
10311
|
+
}
|
|
10312
|
+
return found;
|
|
10313
|
+
}
|
|
10314
|
+
function withSections(bytes, layout2, replacements) {
|
|
10315
|
+
const parts = [bytes.subarray(0, 8)];
|
|
10316
|
+
let at = 8;
|
|
10317
|
+
for (const section of layout2) {
|
|
10318
|
+
const body = replacements.get(section.id);
|
|
10319
|
+
parts.push(
|
|
10320
|
+
body ? Uint8Array.from([section.id, ...encodeNumber2(body.length), ...body]) : bytes.subarray(at, section.end)
|
|
10321
|
+
);
|
|
10322
|
+
at = section.end;
|
|
10323
|
+
}
|
|
10324
|
+
return Buffer.concat(parts);
|
|
10325
|
+
}
|
|
10326
|
+
var quoted = (name2) => `"${[...Buffer.from(name2)].map((byte) => `\\${byte.toString(16).padStart(2, "0")}`).join("")}"`;
|
|
10327
|
+
var signature = (types, keyword, narrow) => types.length === 0 ? "" : ` (${keyword} ${types.map((type) => {
|
|
10328
|
+
const name2 = VALUE_TYPES.get(narrow && type === I64 ? 127 : type);
|
|
10329
|
+
if (!name2) throw new Error(`unsupported wasm boundary type ${type}`);
|
|
10330
|
+
return name2;
|
|
10331
|
+
}).join(" ")})`;
|
|
10332
|
+
var wide = (type) => type.parameters.includes(I64) || type.results.includes(I64);
|
|
10333
|
+
function narrowWasmBoundary(bytes) {
|
|
10334
|
+
const layout2 = sections(bytes);
|
|
10335
|
+
const section = (id) => {
|
|
10336
|
+
const found = layout2.find((entry) => entry.id === id);
|
|
10337
|
+
return found && reader(bytes, found.start, found.end);
|
|
10338
|
+
};
|
|
10339
|
+
const types = [];
|
|
10340
|
+
const typeSection = section(1);
|
|
10341
|
+
if (typeSection) {
|
|
10342
|
+
for (let count = typeSection.number(); count > 0; count--) {
|
|
10343
|
+
if (typeSection.byte() !== 96) throw new Error("unsupported wasm type");
|
|
10344
|
+
const values = () => Array.from({ length: typeSection.number() }, () => typeSection.byte());
|
|
10345
|
+
types.push({ parameters: values(), results: values() });
|
|
10346
|
+
}
|
|
10347
|
+
}
|
|
10348
|
+
const typeAt = (index) => {
|
|
10349
|
+
const type = types[index];
|
|
10350
|
+
if (!type) throw new Error("invalid wasm type index");
|
|
10351
|
+
return type;
|
|
10352
|
+
};
|
|
10353
|
+
const thunks = [];
|
|
10354
|
+
const functionTypes = [];
|
|
10355
|
+
const importBody = [];
|
|
10356
|
+
const importSection = section(2);
|
|
10357
|
+
if (importSection) {
|
|
10358
|
+
const count = importSection.number();
|
|
10359
|
+
importBody.push(...encodeNumber2(count));
|
|
10360
|
+
for (let index = 0; index < count; index++) {
|
|
10361
|
+
const module = importSection.name();
|
|
10362
|
+
const name2 = importSection.name();
|
|
10363
|
+
const start = importSection.position();
|
|
10364
|
+
const kind = importSection.byte();
|
|
10365
|
+
const limits = () => {
|
|
10366
|
+
const flags = importSection.number();
|
|
10367
|
+
importSection.number();
|
|
10368
|
+
if (flags & 1) importSection.number();
|
|
10369
|
+
};
|
|
10370
|
+
let type;
|
|
10371
|
+
if (kind === 0) {
|
|
10372
|
+
type = typeAt(importSection.number());
|
|
10373
|
+
functionTypes.push(type);
|
|
10374
|
+
} else if (kind === 1) {
|
|
10375
|
+
importSection.byte();
|
|
10376
|
+
limits();
|
|
10377
|
+
} else if (kind === 2) limits();
|
|
10378
|
+
else if (kind === 3) {
|
|
10379
|
+
importSection.byte();
|
|
10380
|
+
importSection.byte();
|
|
10381
|
+
} else if (kind === 4) {
|
|
10382
|
+
importSection.byte();
|
|
10383
|
+
importSection.number();
|
|
10384
|
+
} else throw new Error("unsupported wasm import");
|
|
10385
|
+
const scalar64 = (parameter) => module === "wasi_snapshot_preview1" && (!name2.startsWith("peach_") || name2 === "peach_fs_path_birthtime_set" && parameter === 2) || module === "peach" && name2 === "hw_memsize" && parameter === null || module === "peach_notify" && name2 === "set" && parameter === 1;
|
|
10386
|
+
const parameters = type?.parameters.map(
|
|
10387
|
+
(value, index2) => value === I64 && !scalar64(index2) ? 127 : value
|
|
10388
|
+
);
|
|
10389
|
+
const results = type?.results.map(
|
|
10390
|
+
(value) => value === I64 && !scalar64(null) ? 127 : value
|
|
10391
|
+
);
|
|
10392
|
+
if (type && parameters && results && (parameters.some((value, index2) => value !== type.parameters[index2]) || results.some((value, index2) => value !== type.results[index2]))) {
|
|
10393
|
+
if (type.results.length > 1)
|
|
10394
|
+
throw new Error(`import ${module}.${name2} returns several values`);
|
|
10395
|
+
const id = thunks.length;
|
|
10396
|
+
const call = `(call $host${id}${type.parameters.map(
|
|
10397
|
+
(value, at) => value !== parameters[at] ? ` (i32.wrap_i64 (local.get ${at}))` : ` (local.get ${at})`
|
|
10398
|
+
).join("")})`;
|
|
10399
|
+
thunks.push(
|
|
10400
|
+
`(import ${quoted(module)} ${quoted(name2)} (func $host${id}${signature(parameters, "param", false)}${signature(results, "result", false)}))`,
|
|
10401
|
+
`(func (export "${NARROW}${id}")${signature(type.parameters, "param", false)}${signature(type.results, "result", false)} ${type.results[0] !== results[0] ? `(i64.extend_i32_u ${call})` : call})`
|
|
10402
|
+
);
|
|
10403
|
+
importBody.push(...encodeName(BOUNDARY), ...encodeName(`${NARROW}${id}`));
|
|
10404
|
+
} else importBody.push(...encodeName(module), ...encodeName(name2));
|
|
10405
|
+
importBody.push(...bytes.subarray(start, importSection.position()));
|
|
10406
|
+
}
|
|
10407
|
+
if (!importSection.done()) throw new Error("invalid wasm imports");
|
|
10408
|
+
}
|
|
10409
|
+
const functionSection = section(3);
|
|
10410
|
+
if (functionSection)
|
|
10411
|
+
for (let count = functionSection.number(); count > 0; count--)
|
|
10412
|
+
functionTypes.push(typeAt(functionSection.number()));
|
|
10413
|
+
const exportBody = [];
|
|
10414
|
+
const exportSection = section(7);
|
|
10415
|
+
if (exportSection) {
|
|
10416
|
+
const count = exportSection.number();
|
|
10417
|
+
exportBody.push(...encodeNumber2(count));
|
|
10418
|
+
for (let index = 0; index < count; index++) {
|
|
10419
|
+
const name2 = exportSection.name();
|
|
10420
|
+
const kind = exportSection.byte();
|
|
10421
|
+
const target = exportSection.number();
|
|
10422
|
+
const type = kind === 0 ? functionTypes[target] : void 0;
|
|
10423
|
+
if (kind === 0 && !type) throw new Error("invalid wasm export");
|
|
10424
|
+
if (type && wide(type)) {
|
|
10425
|
+
if (type.results.length > 1)
|
|
10426
|
+
throw new Error(`export ${name2} returns several values`);
|
|
10427
|
+
const id = thunks.length;
|
|
10428
|
+
const call = `(call $guest${id}${type.parameters.map(
|
|
10429
|
+
(value, at) => value === I64 ? ` (i64.extend_i32_u (local.get ${at}))` : ` (local.get ${at})`
|
|
10430
|
+
).join("")})`;
|
|
10431
|
+
thunks.push(
|
|
10432
|
+
`(import "${GUEST}" "${WIDE}${id}" (func $guest${id}${signature(type.parameters, "param", false)}${signature(type.results, "result", false)}))`,
|
|
10433
|
+
`(func (export ${quoted(name2)})${signature(type.parameters, "param", true)}${signature(type.results, "result", true)} ${type.results[0] === I64 ? `(i32.wrap_i64 ${call})` : call})`
|
|
10434
|
+
);
|
|
10435
|
+
exportBody.push(...encodeName(`${WIDE}${id}`));
|
|
10436
|
+
} else exportBody.push(...encodeName(name2));
|
|
10437
|
+
exportBody.push(kind, ...encodeNumber2(target));
|
|
10438
|
+
}
|
|
10439
|
+
if (!exportSection.done()) throw new Error("invalid wasm exports");
|
|
10440
|
+
}
|
|
10441
|
+
if (thunks.length === 0) return void 0;
|
|
10442
|
+
const imports = thunks.filter((line) => line.startsWith("(import"));
|
|
10443
|
+
const functions = thunks.filter((line) => !line.startsWith("(import"));
|
|
10444
|
+
return {
|
|
10445
|
+
module: withSections(
|
|
10446
|
+
bytes,
|
|
10447
|
+
layout2,
|
|
10448
|
+
/* @__PURE__ */ new Map([
|
|
10449
|
+
[2, importBody],
|
|
10450
|
+
[7, exportBody]
|
|
10451
|
+
])
|
|
10452
|
+
),
|
|
10453
|
+
thunks: `(module
|
|
10454
|
+
${[...imports, ...functions].join("\n")}
|
|
10455
|
+
)
|
|
10456
|
+
`
|
|
10457
|
+
};
|
|
10458
|
+
}
|
|
10459
|
+
var NARROW_MERGE_NAMES = { guest: GUEST, boundary: BOUNDARY };
|
|
10460
|
+
function dropBoundaryExports(bytes) {
|
|
10461
|
+
const layout2 = sections(bytes);
|
|
10462
|
+
const found = layout2.find((entry) => entry.id === 7);
|
|
10463
|
+
if (!found) throw new Error("merged module has no exports");
|
|
10464
|
+
const exportSection = reader(bytes, found.start, found.end);
|
|
10465
|
+
const kept = [];
|
|
10466
|
+
for (let count = exportSection.number(); count > 0; count--) {
|
|
10467
|
+
const name2 = exportSection.name();
|
|
10468
|
+
const kind = exportSection.byte();
|
|
10469
|
+
const target = exportSection.number();
|
|
10470
|
+
if (!name2.startsWith(WIDE) && !name2.startsWith(NARROW))
|
|
10471
|
+
kept.push([...encodeName(name2), kind, ...encodeNumber2(target)]);
|
|
10472
|
+
}
|
|
10473
|
+
return withSections(
|
|
10474
|
+
bytes,
|
|
10475
|
+
layout2,
|
|
10476
|
+
/* @__PURE__ */ new Map([[7, [...encodeNumber2(kept.length), ...kept.flat()]]])
|
|
10477
|
+
);
|
|
10478
|
+
}
|
|
10479
|
+
|
|
10199
10480
|
// src/wasm-optimize.ts
|
|
10200
10481
|
var FEATURES = [
|
|
10482
|
+
"memory64",
|
|
10201
10483
|
"threads",
|
|
10202
10484
|
"bulk-memory",
|
|
10203
10485
|
"bulk-memory-opt",
|
|
@@ -10210,7 +10492,8 @@ var FEATURES = [
|
|
|
10210
10492
|
"sign-ext"
|
|
10211
10493
|
];
|
|
10212
10494
|
var KEEP_WASM_NAMES = process.env.PEACH_SWIFT_NAMES === "1";
|
|
10213
|
-
var
|
|
10495
|
+
var LOWERING = ["--memory64-lowering", "--table64-lowering"];
|
|
10496
|
+
var WASM_LOWER_IDENTITY = `binaryen ${BINARYEN_VERSION} narrow ${LOWERING.join(" ")} ${FEATURES.join(",")} unoptimized-names`;
|
|
10214
10497
|
var PINNED_BINARYEN_VERSION = "132";
|
|
10215
10498
|
var BINARYEN_RELEASES = /* @__PURE__ */ new Map([
|
|
10216
10499
|
[
|
|
@@ -10235,7 +10518,7 @@ var BINARYEN_RELEASES = /* @__PURE__ */ new Map([
|
|
|
10235
10518
|
}
|
|
10236
10519
|
]
|
|
10237
10520
|
]);
|
|
10238
|
-
async function runWasmOpt(file, output, skipPasses, binary) {
|
|
10521
|
+
async function runWasmOpt(file, output, optimize, skipPasses, binary) {
|
|
10239
10522
|
const admittedCores = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
|
|
10240
10523
|
const requestedCores = Number(process.env.BINARYEN_CORES);
|
|
10241
10524
|
const environment = { ...process.env, WASM_OPT_PATH: binary };
|
|
@@ -10243,18 +10526,43 @@ async function runWasmOpt(file, output, skipPasses, binary) {
|
|
|
10243
10526
|
environment.BINARYEN_CORES = String(
|
|
10244
10527
|
Number.isInteger(requestedCores) && requestedCores > 0 ? Math.min(admittedCores, requestedCores) : admittedCores
|
|
10245
10528
|
);
|
|
10529
|
+
const features = FEATURES.map((feature) => `--enable-${feature}`);
|
|
10530
|
+
const names = optimize && !KEEP_WASM_NAMES ? [] : ["-g"];
|
|
10531
|
+
const narrowed = narrowWasmBoundary(readFileSync11(file));
|
|
10532
|
+
const merged = `${output}.narrowed`;
|
|
10533
|
+
if (narrowed) {
|
|
10534
|
+
const guest = `${output}.guest`;
|
|
10535
|
+
const thunks = `${output}.thunks.wat`;
|
|
10536
|
+
writeFileSync4(guest, narrowed.module);
|
|
10537
|
+
writeFileSync4(thunks, narrowed.thunks);
|
|
10538
|
+
await promisify2(execFile2)(join2(dirname(binary), "wasm-merge"), [
|
|
10539
|
+
...features,
|
|
10540
|
+
...names,
|
|
10541
|
+
guest,
|
|
10542
|
+
NARROW_MERGE_NAMES.guest,
|
|
10543
|
+
thunks,
|
|
10544
|
+
NARROW_MERGE_NAMES.boundary,
|
|
10545
|
+
"-o",
|
|
10546
|
+
merged
|
|
10547
|
+
]);
|
|
10548
|
+
writeFileSync4(merged, dropBoundaryExports(readFileSync11(merged)));
|
|
10549
|
+
rmSync4(guest);
|
|
10550
|
+
rmSync4(thunks);
|
|
10551
|
+
}
|
|
10246
10552
|
const result = await wasmOpt(
|
|
10247
10553
|
[
|
|
10248
|
-
|
|
10249
|
-
...
|
|
10554
|
+
...LOWERING,
|
|
10555
|
+
...optimize ? ["-Oz"] : [],
|
|
10556
|
+
...names,
|
|
10250
10557
|
...skipPasses.flatMap((pass) => ["--skip-pass", pass]),
|
|
10251
|
-
...
|
|
10252
|
-
file,
|
|
10558
|
+
...features,
|
|
10559
|
+
narrowed ? merged : file,
|
|
10253
10560
|
"-o",
|
|
10254
10561
|
output
|
|
10255
10562
|
],
|
|
10256
10563
|
{ env: environment }
|
|
10257
10564
|
);
|
|
10565
|
+
if (narrowed) rmSync4(merged);
|
|
10258
10566
|
if (result.status !== 0)
|
|
10259
10567
|
throw new Error(`wasm-opt exited ${result.status}: ${result.stderr}`);
|
|
10260
10568
|
}
|
|
@@ -10277,8 +10585,14 @@ async function installWasmOpt() {
|
|
|
10277
10585
|
});
|
|
10278
10586
|
return binary;
|
|
10279
10587
|
}
|
|
10280
|
-
async function
|
|
10281
|
-
await runWasmOpt(
|
|
10588
|
+
async function lowerWasm(file, output, options) {
|
|
10589
|
+
await runWasmOpt(
|
|
10590
|
+
file,
|
|
10591
|
+
output,
|
|
10592
|
+
options.optimize,
|
|
10593
|
+
options.skipPasses ?? [],
|
|
10594
|
+
await installWasmOpt()
|
|
10595
|
+
);
|
|
10282
10596
|
}
|
|
10283
10597
|
|
|
10284
10598
|
// src/swift-guest-compile.ts
|
|
@@ -10293,7 +10607,7 @@ function version(value) {
|
|
|
10293
10607
|
}
|
|
10294
10608
|
async function compileGuestLink(options) {
|
|
10295
10609
|
const directory = path19.join(options.buildDirectory, ".peach-guest-link");
|
|
10296
|
-
|
|
10610
|
+
mkdirSync3(directory, { recursive: true });
|
|
10297
10611
|
const sdkRoot = path19.dirname(options.sysroot);
|
|
10298
10612
|
const catalogs = readGuestRuntimeCatalogs(sdkRoot, options.moduleRoot);
|
|
10299
10613
|
const sourceImages = guestSourceImages(options.graph);
|
|
@@ -10312,13 +10626,13 @@ async function compileGuestLink(options) {
|
|
|
10312
10626
|
};
|
|
10313
10627
|
const buildVersion = imageBuildVersion(entry.buildVersion);
|
|
10314
10628
|
const clangOptions = [
|
|
10315
|
-
"--target=
|
|
10629
|
+
"--target=wasm64-unknown-wasip1",
|
|
10316
10630
|
`--sysroot=${options.sysroot}`,
|
|
10317
10631
|
`-I${path19.join(options.moduleRoot, "include")}`
|
|
10318
10632
|
];
|
|
10319
10633
|
const stubSource = path19.join(directory, "preselection-projection.c");
|
|
10320
10634
|
const stub = path19.join(directory, "preselection-projection.o");
|
|
10321
|
-
|
|
10635
|
+
writeFileSync5(
|
|
10322
10636
|
stubSource,
|
|
10323
10637
|
'#include "guest-image-projection.h"\nconst struct peach_guest_image __peach_guest_images[] = {{0}};\nconst uint32_t __peach_guest_image_count = 0;\n'
|
|
10324
10638
|
);
|
|
@@ -10620,31 +10934,32 @@ async function compileGuestLink(options) {
|
|
|
10620
10934
|
}
|
|
10621
10935
|
});
|
|
10622
10936
|
if (!reserved || !projectionObject) throw new Error("guest projection was not reserved");
|
|
10623
|
-
await
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
|
|
10937
|
+
await lowerWasm(options.output, options.optimized, {
|
|
10938
|
+
optimize: true,
|
|
10939
|
+
skipPasses: ["duplicate-function-elimination"]
|
|
10940
|
+
});
|
|
10941
|
+
const map = readFileSync12(result.mapPath, "utf8");
|
|
10627
10942
|
if (!/ __peach_guest_images$/m.test(map)) return;
|
|
10628
10943
|
const finalized = finalizeGuestProjectionStorage({
|
|
10629
10944
|
map,
|
|
10630
|
-
linked:
|
|
10631
|
-
optimized:
|
|
10945
|
+
linked: readFileSync12(options.output),
|
|
10946
|
+
optimized: readFileSync12(options.optimized),
|
|
10632
10947
|
owners: result.owners,
|
|
10633
10948
|
sectionOwners: result.generatedSectionOwners,
|
|
10634
10949
|
projectionObject,
|
|
10635
10950
|
reserved
|
|
10636
10951
|
});
|
|
10637
|
-
|
|
10952
|
+
writeFileSync5(options.optimized, finalized.wasm);
|
|
10638
10953
|
}
|
|
10639
10954
|
|
|
10640
10955
|
// src/swift-icu.ts
|
|
10641
|
-
import { execFile as
|
|
10956
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
10642
10957
|
import { createHash as createHash11, randomUUID as randomUUID3 } from "node:crypto";
|
|
10643
|
-
import { existsSync as existsSync2, readFileSync as
|
|
10958
|
+
import { existsSync as existsSync2, readFileSync as readFileSync13 } from "node:fs";
|
|
10644
10959
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
10645
10960
|
import os4 from "node:os";
|
|
10646
10961
|
import path20 from "node:path";
|
|
10647
|
-
import { promisify as
|
|
10962
|
+
import { promisify as promisify3 } from "node:util";
|
|
10648
10963
|
import {
|
|
10649
10964
|
brotliCompress,
|
|
10650
10965
|
constants as zlibConstants,
|
|
@@ -10708,10 +11023,10 @@ function swiftIcuPack(blob, deflate2) {
|
|
|
10708
11023
|
}
|
|
10709
11024
|
|
|
10710
11025
|
// src/swift-icu.ts
|
|
10711
|
-
var run =
|
|
10712
|
-
var deflate =
|
|
10713
|
-
var compressBrotli =
|
|
10714
|
-
var inflateGzip =
|
|
11026
|
+
var run = promisify3(execFile3);
|
|
11027
|
+
var deflate = promisify3(gzip);
|
|
11028
|
+
var compressBrotli = promisify3(brotliCompress);
|
|
11029
|
+
var inflateGzip = promisify3(gunzip);
|
|
10715
11030
|
var ARCHIVE = "wasi/lib_FoundationICU.a";
|
|
10716
11031
|
var MEMBER = "icu_packaged_data.cpp.obj";
|
|
10717
11032
|
var raw = /* @__PURE__ */ new Map();
|
|
@@ -10792,14 +11107,14 @@ async function load(toolchainBin, sdk) {
|
|
|
10792
11107
|
...swiftSdkOptions(),
|
|
10793
11108
|
"--show-configuration",
|
|
10794
11109
|
sdk,
|
|
10795
|
-
"
|
|
11110
|
+
"wasm64-unknown-wasip1"
|
|
10796
11111
|
],
|
|
10797
11112
|
{ env: swiftEnvironment() }
|
|
10798
11113
|
);
|
|
10799
11114
|
const resources = /^swiftStaticResourcesPath: (.+)$/m.exec(stdout)?.[1]?.trim();
|
|
10800
11115
|
if (!resources) throw new Error(`swift-icu: ${sdk} names no static resources`);
|
|
10801
11116
|
return Buffer.from(
|
|
10802
|
-
icuSegment(archiveMember(
|
|
11117
|
+
icuSegment(archiveMember(readFileSync13(path20.join(resources, ARCHIVE)), MEMBER))
|
|
10803
11118
|
);
|
|
10804
11119
|
}
|
|
10805
11120
|
function archiveMember(archive, name2) {
|
|
@@ -11044,22 +11359,22 @@ import { execFileSync as execFileSync10 } from "node:child_process";
|
|
|
11044
11359
|
import {
|
|
11045
11360
|
chmodSync,
|
|
11046
11361
|
existsSync as existsSync3,
|
|
11047
|
-
mkdirSync as
|
|
11362
|
+
mkdirSync as mkdirSync4,
|
|
11048
11363
|
readdirSync as readdirSync6,
|
|
11049
|
-
readFileSync as
|
|
11364
|
+
readFileSync as readFileSync14,
|
|
11050
11365
|
realpathSync as realpathSync3,
|
|
11051
|
-
rmSync as
|
|
11366
|
+
rmSync as rmSync5,
|
|
11052
11367
|
statSync
|
|
11053
11368
|
} from "node:fs";
|
|
11054
11369
|
import path22 from "node:path";
|
|
11055
11370
|
function prepareSwiftProjectProcess(root, user) {
|
|
11056
11371
|
const home = `${root}.project-home`;
|
|
11057
|
-
|
|
11372
|
+
rmSync5(home, { recursive: true, force: true });
|
|
11058
11373
|
const tmp = path22.join(home, "tmp");
|
|
11059
11374
|
const swiftpm = path22.join(home, "swiftpm");
|
|
11060
|
-
|
|
11375
|
+
mkdirSync4(tmp, { recursive: true });
|
|
11061
11376
|
const caches = ["cache", "config", "security"].map((name2) => path22.join(swiftpm, name2));
|
|
11062
|
-
for (const directory of caches)
|
|
11377
|
+
for (const directory of caches) mkdirSync4(directory, { recursive: true });
|
|
11063
11378
|
execFileSync10("chown", ["-R", "-P", `${user.uid}:${user.gid}`, root, home]);
|
|
11064
11379
|
chmodSync(root, 448);
|
|
11065
11380
|
chmodSync(home, 448);
|
|
@@ -11104,8 +11419,8 @@ function removeProjectLinks(root) {
|
|
|
11104
11419
|
const full = path22.join(directory, entry.name);
|
|
11105
11420
|
if (directory === root && entry.name === ".build") continue;
|
|
11106
11421
|
if (directory === root && entry.name.startsWith(".peach-modules-")) {
|
|
11107
|
-
|
|
11108
|
-
} else if (entry.isSymbolicLink())
|
|
11422
|
+
rmSync5(full, { recursive: true, force: true });
|
|
11423
|
+
} else if (entry.isSymbolicLink()) rmSync5(full);
|
|
11109
11424
|
else if (entry.isDirectory()) pending.push(full);
|
|
11110
11425
|
}
|
|
11111
11426
|
}
|
|
@@ -11136,11 +11451,11 @@ import {
|
|
|
11136
11451
|
import { createHash as createHash12, randomUUID as randomUUID4 } from "node:crypto";
|
|
11137
11452
|
import {
|
|
11138
11453
|
linkSync,
|
|
11139
|
-
mkdirSync as
|
|
11454
|
+
mkdirSync as mkdirSync5,
|
|
11140
11455
|
readdirSync as readdirSync7,
|
|
11141
|
-
readFileSync as
|
|
11142
|
-
rmSync as
|
|
11143
|
-
writeFileSync as
|
|
11456
|
+
readFileSync as readFileSync15,
|
|
11457
|
+
rmSync as rmSync6,
|
|
11458
|
+
writeFileSync as writeFileSync6
|
|
11144
11459
|
} from "node:fs";
|
|
11145
11460
|
import { homedir as homedir2 } from "node:os";
|
|
11146
11461
|
import path23 from "node:path";
|
|
@@ -11209,7 +11524,7 @@ function generationNumbers(directory) {
|
|
|
11209
11524
|
function readGeneration(directory, number3) {
|
|
11210
11525
|
let owner;
|
|
11211
11526
|
try {
|
|
11212
|
-
owner =
|
|
11527
|
+
owner = readFileSync15(path23.join(directory, name(number3, "owner")), "utf8");
|
|
11213
11528
|
} catch (error) {
|
|
11214
11529
|
if (errorCode(error) === "ENOENT") return null;
|
|
11215
11530
|
throw error;
|
|
@@ -11222,7 +11537,7 @@ function readGeneration(directory, number3) {
|
|
|
11222
11537
|
}
|
|
11223
11538
|
function readChildren(directory, number3) {
|
|
11224
11539
|
const prefix = name(number3, "child.");
|
|
11225
|
-
return readdirSync7(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(
|
|
11540
|
+
return readdirSync7(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(readFileSync15(path23.join(directory, entry), "utf8")));
|
|
11226
11541
|
}
|
|
11227
11542
|
function groupAlive(table, leader) {
|
|
11228
11543
|
const row = table.find((candidate) => candidate.pid === leader.pid);
|
|
@@ -11237,7 +11552,7 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
11237
11552
|
swiftRootLocksDir(),
|
|
11238
11553
|
createHash12("sha256").update(root).digest("hex").slice(0, 32)
|
|
11239
11554
|
);
|
|
11240
|
-
|
|
11555
|
+
mkdirSync5(directory, { recursive: true });
|
|
11241
11556
|
const token = randomUUID4();
|
|
11242
11557
|
const ownRow = (await processTableWithRetry(process.pid, signal)).find(
|
|
11243
11558
|
(candidate) => candidate.pid === process.pid && !candidate.zombie
|
|
@@ -11268,18 +11583,18 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
11268
11583
|
}
|
|
11269
11584
|
}
|
|
11270
11585
|
}
|
|
11271
|
-
|
|
11586
|
+
writeFileSync6(pending, owner);
|
|
11272
11587
|
try {
|
|
11273
11588
|
linkSync(pending, path23.join(directory, name(newest + 1, "owner")));
|
|
11274
11589
|
} catch (error) {
|
|
11275
11590
|
if (errorCode(error) === "EEXIST") continue;
|
|
11276
11591
|
throw error;
|
|
11277
11592
|
} finally {
|
|
11278
|
-
|
|
11593
|
+
rmSync6(pending, { force: true });
|
|
11279
11594
|
}
|
|
11280
11595
|
const numbers = generationNumbers(directory);
|
|
11281
11596
|
if (numbers.at(-1) !== newest + 1) {
|
|
11282
|
-
|
|
11597
|
+
rmSync6(path23.join(directory, name(newest + 1, "owner")), { force: true });
|
|
11283
11598
|
continue;
|
|
11284
11599
|
}
|
|
11285
11600
|
held = newest + 1;
|
|
@@ -11287,7 +11602,7 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
11287
11602
|
if (number3 < held) {
|
|
11288
11603
|
for (const entry of readdirSync7(directory))
|
|
11289
11604
|
if (entry.startsWith(name(number3, "")))
|
|
11290
|
-
|
|
11605
|
+
rmSync6(path23.join(directory, entry), { force: true });
|
|
11291
11606
|
}
|
|
11292
11607
|
break;
|
|
11293
11608
|
}
|
|
@@ -11298,10 +11613,10 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
11298
11613
|
if (child.pid === void 0) throw new Error("could not register compiler process");
|
|
11299
11614
|
const childPending = `${pending}.child.${index}`;
|
|
11300
11615
|
try {
|
|
11301
|
-
|
|
11616
|
+
writeFileSync6(childPending, JSON.stringify(ownIdentity(child.pid)));
|
|
11302
11617
|
linkSync(childPending, path23.join(directory, name(held, `child.${index}`)));
|
|
11303
11618
|
} finally {
|
|
11304
|
-
|
|
11619
|
+
rmSync6(childPending, { force: true });
|
|
11305
11620
|
}
|
|
11306
11621
|
},
|
|
11307
11622
|
spawn(command, args, options, companion) {
|
|
@@ -11332,7 +11647,7 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
11332
11647
|
return await work(lease);
|
|
11333
11648
|
} finally {
|
|
11334
11649
|
await Promise.all(children.map((child) => terminateProcessGroup(child, "SIGKILL", 0)));
|
|
11335
|
-
|
|
11650
|
+
writeFileSync6(path23.join(directory, name(held, "released")), "");
|
|
11336
11651
|
}
|
|
11337
11652
|
}
|
|
11338
11653
|
|
|
@@ -11345,7 +11660,7 @@ function compileUniformTypeConstants(args) {
|
|
|
11345
11660
|
execFileSync11(
|
|
11346
11661
|
path24.join(args.bin, "clang"),
|
|
11347
11662
|
[
|
|
11348
|
-
"--target=
|
|
11663
|
+
"--target=wasm64-unknown-wasip1",
|
|
11349
11664
|
`--sysroot=${args.sysroot}`,
|
|
11350
11665
|
"-Oz",
|
|
11351
11666
|
"-g0",
|
|
@@ -11525,13 +11840,13 @@ function isSwiftResourceBundles(value) {
|
|
|
11525
11840
|
}
|
|
11526
11841
|
|
|
11527
11842
|
// src/write-build-file.ts
|
|
11528
|
-
import { existsSync as existsSync4, mkdirSync as
|
|
11843
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync6, readFileSync as readFileSync16, writeFileSync as writeFileSync7 } from "node:fs";
|
|
11529
11844
|
import path25 from "node:path";
|
|
11530
11845
|
function writeBuildFile(file, contents) {
|
|
11531
|
-
if (existsSync4(file) && (typeof contents === "string" ?
|
|
11846
|
+
if (existsSync4(file) && (typeof contents === "string" ? readFileSync16(file, "utf8") === contents : readFileSync16(file).equals(contents)))
|
|
11532
11847
|
return;
|
|
11533
|
-
|
|
11534
|
-
|
|
11848
|
+
mkdirSync6(path25.dirname(file), { recursive: true });
|
|
11849
|
+
writeFileSync7(file, contents);
|
|
11535
11850
|
}
|
|
11536
11851
|
|
|
11537
11852
|
// src/xcode-header-search.ts
|
|
@@ -11718,7 +12033,7 @@ async function runCompiler(command, args, options, stream = false, quiet) {
|
|
|
11718
12033
|
await stopping;
|
|
11719
12034
|
}
|
|
11720
12035
|
}
|
|
11721
|
-
var WASM_TRIPLE = "
|
|
12036
|
+
var WASM_TRIPLE = "wasm64-unknown-wasip1";
|
|
11722
12037
|
var SWIFTPM_PROGRESS = /^\[\d+\/\d+\] /;
|
|
11723
12038
|
var SWIFTPM_NOISE = /^(?:\[\d+\/\d+\] |Building for production\.\.\.$|warning: '--build-system native' has been deprecated)/;
|
|
11724
12039
|
function swiftBuildJobs() {
|
|
@@ -11737,7 +12052,7 @@ function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
|
|
|
11737
12052
|
function swiftDistributionAt(root) {
|
|
11738
12053
|
const file = path27.join(root, SWIFT_DISTRIBUTION_MANIFEST);
|
|
11739
12054
|
if (!existsSync5(file)) return null;
|
|
11740
|
-
return parseSwiftDistributionManifest(JSON.parse(
|
|
12055
|
+
return parseSwiftDistributionManifest(JSON.parse(readFileSync17(file, "utf8")));
|
|
11741
12056
|
}
|
|
11742
12057
|
function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
|
|
11743
12058
|
if (swiftDistributionAt(moduleRoot)) {
|
|
@@ -11746,7 +12061,7 @@ function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
|
|
|
11746
12061
|
`${name2}-Swift.h`
|
|
11747
12062
|
);
|
|
11748
12063
|
if (!existsSync5(file)) return null;
|
|
11749
|
-
const header = clangInterfaceHeader(
|
|
12064
|
+
const header = clangInterfaceHeader(readFileSync17(file, "utf8"));
|
|
11750
12065
|
return { declared: swiftInterfaceDeclarations(header), header };
|
|
11751
12066
|
}
|
|
11752
12067
|
const sources = path27.join(moduleRoot, "Sources", name2);
|
|
@@ -11755,7 +12070,7 @@ function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
|
|
|
11755
12070
|
const declared = /* @__PURE__ */ new Set();
|
|
11756
12071
|
for (const file of readdirSync8(sources, { recursive: true, encoding: "utf8" }))
|
|
11757
12072
|
if (file.endsWith(".swift"))
|
|
11758
|
-
for (const [, objc, subclass] of
|
|
12073
|
+
for (const [, objc, subclass] of readFileSync17(
|
|
11759
12074
|
path27.join(sources, file),
|
|
11760
12075
|
"utf8"
|
|
11761
12076
|
).matchAll(
|
|
@@ -11763,7 +12078,7 @@ function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
|
|
|
11763
12078
|
))
|
|
11764
12079
|
declared.add(objc ?? subclass);
|
|
11765
12080
|
if (declared.size === 0) return null;
|
|
11766
|
-
return { declared, header: clangInterfaceHeader(
|
|
12081
|
+
return { declared, header: clangInterfaceHeader(readFileSync17(built, "utf8")) };
|
|
11767
12082
|
}
|
|
11768
12083
|
var clangInterfaceHeader = (header) => header.replace(/^@import (?:UIKitCore|UIKitText);$/gm, "@import UIKit;").replace(
|
|
11769
12084
|
/^@import (?:CoreFoundation|FoundationNetworking);$/gm,
|
|
@@ -11836,7 +12151,7 @@ function swiftObjCSelectorOptions(moduleRoot) {
|
|
|
11836
12151
|
for (const framework of ["UIKitCore", "WebKit"])
|
|
11837
12152
|
for (const [name2, members] of Object.entries(
|
|
11838
12153
|
JSON.parse(
|
|
11839
|
-
|
|
12154
|
+
readFileSync17(
|
|
11840
12155
|
path27.join(moduleRoot, "Sources", framework, "ObjCSelectors.json"),
|
|
11841
12156
|
"utf8"
|
|
11842
12157
|
)
|
|
@@ -11844,9 +12159,9 @@ function swiftObjCSelectorOptions(moduleRoot) {
|
|
|
11844
12159
|
))
|
|
11845
12160
|
classes[name2] = [...classes[name2] ?? [], ...members];
|
|
11846
12161
|
map = path27.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
|
|
11847
|
-
|
|
12162
|
+
mkdirSync7(path27.dirname(map), { recursive: true });
|
|
11848
12163
|
const partial = `${map}.${randomUUID5()}`;
|
|
11849
|
-
|
|
12164
|
+
writeFileSync8(partial, `${JSON.stringify({ classes }, null, 2)}
|
|
11850
12165
|
`);
|
|
11851
12166
|
renameSync2(partial, map);
|
|
11852
12167
|
}
|
|
@@ -11905,7 +12220,7 @@ function swiftMacroPlugins(moduleRoot, dir = path27.join(moduleRoot, ".build/hos
|
|
|
11905
12220
|
stale: false
|
|
11906
12221
|
};
|
|
11907
12222
|
const release = JSON.parse(
|
|
11908
|
-
|
|
12223
|
+
readFileSync17(path27.join(moduleRoot, "toolchain.json"), "utf8")
|
|
11909
12224
|
).release;
|
|
11910
12225
|
const compilerStamp = path27.join(dir, "compiler-release");
|
|
11911
12226
|
const pluginScript = path27.join(moduleRoot, "scripts/build-preview-plugin.sh");
|
|
@@ -11934,7 +12249,7 @@ function swiftMacroPlugins(moduleRoot, dir = path27.join(moduleRoot, ".build/hos
|
|
|
11934
12249
|
return {
|
|
11935
12250
|
libraries: plugins.map(({ library }) => library),
|
|
11936
12251
|
executables: [expoPlugin],
|
|
11937
|
-
stale: !existsSync5(compilerStamp) || !existsSync5(expoPlugin) || statSync2(pluginScript).mtimeMs > statSync2(expoPlugin).mtimeMs ||
|
|
12252
|
+
stale: !existsSync5(compilerStamp) || !existsSync5(expoPlugin) || statSync2(pluginScript).mtimeMs > statSync2(expoPlugin).mtimeMs || readFileSync17(compilerStamp, "utf8").trim() !== release || plugins.some(
|
|
11938
12253
|
({ library, sources }) => !existsSync5(library) || sources.some((source) => statSync2(source).mtimeMs > statSync2(library).mtimeMs)
|
|
11939
12254
|
)
|
|
11940
12255
|
};
|
|
@@ -11951,7 +12266,7 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal, lea
|
|
|
11951
12266
|
],
|
|
11952
12267
|
{ signal, lease }
|
|
11953
12268
|
);
|
|
11954
|
-
|
|
12269
|
+
writeFileSync8(
|
|
11955
12270
|
path27.join(path27.dirname(libraries[0]), "compiler-release"),
|
|
11956
12271
|
`${release}
|
|
11957
12272
|
`
|
|
@@ -11984,7 +12299,7 @@ function swiftModuleDigest(root) {
|
|
|
11984
12299
|
`${createHash13("sha256").update(root).digest("hex")}.json`
|
|
11985
12300
|
);
|
|
11986
12301
|
if (existsSync5(record)) {
|
|
11987
|
-
const saved = JSON.parse(
|
|
12302
|
+
const saved = JSON.parse(readFileSync17(record, "utf8"));
|
|
11988
12303
|
if (saved && typeof saved === "object" && Reflect.get(saved, "stamp") === stamp && typeof Reflect.get(saved, "digest") === "string") {
|
|
11989
12304
|
const digest2 = Buffer.from(String(Reflect.get(saved, "digest")), "hex");
|
|
11990
12305
|
linkedModuleDigests.set(root, { stamp, digest: digest2 });
|
|
@@ -11995,14 +12310,14 @@ function swiftModuleDigest(root) {
|
|
|
11995
12310
|
for (const file of files) {
|
|
11996
12311
|
hash.update(createHash13("sha256").update(file).digest());
|
|
11997
12312
|
hash.update(
|
|
11998
|
-
createHash13("sha256").update(
|
|
12313
|
+
createHash13("sha256").update(readFileSync17(path27.join(root, file))).digest()
|
|
11999
12314
|
);
|
|
12000
12315
|
}
|
|
12001
12316
|
const digest = hash.digest();
|
|
12002
12317
|
linkedModuleDigests.set(root, { stamp, digest });
|
|
12003
|
-
|
|
12318
|
+
mkdirSync7(path27.dirname(record), { recursive: true });
|
|
12004
12319
|
const partial = `${record}.${process.pid}.${randomUUID5()}`;
|
|
12005
|
-
|
|
12320
|
+
writeFileSync8(partial, JSON.stringify({ stamp, digest: digest.toString("hex") }));
|
|
12006
12321
|
renameSync2(partial, record);
|
|
12007
12322
|
return digest;
|
|
12008
12323
|
}
|
|
@@ -12146,10 +12461,11 @@ function swiftCondition(text2, available) {
|
|
|
12146
12461
|
const call = /^(\w+)\s*\(\s*([^,()]*?)\s*(?:,[^()]*)?\)$/.exec(token ?? "");
|
|
12147
12462
|
if (!call) return void 0;
|
|
12148
12463
|
const [, name2, argument] = call;
|
|
12149
|
-
if (name2 === "os") return argument === "iOS"
|
|
12150
|
-
if (name2 === "canImport")
|
|
12464
|
+
if (name2 === "os") return argument === "iOS";
|
|
12465
|
+
if (name2 === "canImport")
|
|
12466
|
+
return argument !== "FoundationNetworking" && available?.has(argument);
|
|
12151
12467
|
if (name2 === "targetEnvironment") return argument === "simulator";
|
|
12152
|
-
if (name2 === "arch") return argument === "
|
|
12468
|
+
if (name2 === "arch") return argument === "wasm64";
|
|
12153
12469
|
return void 0;
|
|
12154
12470
|
};
|
|
12155
12471
|
const both = () => {
|
|
@@ -12208,7 +12524,7 @@ function swiftImportNames(contents, available) {
|
|
|
12208
12524
|
function swiftPeachModules(moduleRoot) {
|
|
12209
12525
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
12210
12526
|
return distribution ? distribution.modules : swiftManifestDeclarations(
|
|
12211
|
-
|
|
12527
|
+
readFileSync17(path27.join(moduleRoot, "Package.swift"), "utf8")
|
|
12212
12528
|
).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
|
|
12213
12529
|
}
|
|
12214
12530
|
var sdkPaths = /* @__PURE__ */ new Map();
|
|
@@ -12226,7 +12542,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
12226
12542
|
...options,
|
|
12227
12543
|
"--show-configuration",
|
|
12228
12544
|
sdk,
|
|
12229
|
-
"
|
|
12545
|
+
"wasm64-unknown-wasip1"
|
|
12230
12546
|
],
|
|
12231
12547
|
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
12232
12548
|
);
|
|
@@ -12244,7 +12560,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
12244
12560
|
if (!Array.isArray(toolsets) || !toolsets.every((value) => typeof value === "string"))
|
|
12245
12561
|
throw new Error(`swift sdk ${sdk} reports invalid toolset paths`);
|
|
12246
12562
|
for (const toolset of toolsets) {
|
|
12247
|
-
const config = JSON.parse(
|
|
12563
|
+
const config = JSON.parse(readFileSync17(toolset, "utf8"));
|
|
12248
12564
|
if (!config || typeof config !== "object" || !("swiftCompiler" in config)) continue;
|
|
12249
12565
|
const compiler = config.swiftCompiler;
|
|
12250
12566
|
if (!compiler || typeof compiler !== "object" || !("extraCLIOptions" in compiler))
|
|
@@ -12309,20 +12625,20 @@ function swiftOverlayFrameworks(moduleRoot, toolchainBin) {
|
|
|
12309
12625
|
for (const entry of readdirSync8(include))
|
|
12310
12626
|
if (entry.endsWith(".modulemap"))
|
|
12311
12627
|
addSwiftOverlayFrameworks(
|
|
12312
|
-
|
|
12628
|
+
readFileSync17(path27.join(include, entry), "utf8"),
|
|
12313
12629
|
swiftModules,
|
|
12314
12630
|
result
|
|
12315
12631
|
);
|
|
12316
12632
|
for (const entry of readdirSync8(resources)) {
|
|
12317
12633
|
const map = path27.join(resources, entry, "module.modulemap");
|
|
12318
12634
|
if (existsSync5(map))
|
|
12319
|
-
addSwiftOverlayFrameworks(
|
|
12635
|
+
addSwiftOverlayFrameworks(readFileSync17(map, "utf8"), swiftModules, result);
|
|
12320
12636
|
}
|
|
12321
12637
|
for (const directory of frameworks)
|
|
12322
12638
|
for (const entry of readdirSync8(directory)) {
|
|
12323
12639
|
const map = path27.join(directory, entry, "Modules/module.modulemap");
|
|
12324
12640
|
if (existsSync5(map))
|
|
12325
|
-
addSwiftOverlayFrameworks(
|
|
12641
|
+
addSwiftOverlayFrameworks(readFileSync17(map, "utf8"), swiftModules, result);
|
|
12326
12642
|
}
|
|
12327
12643
|
sdkOverlayFrameworks.set(key, result);
|
|
12328
12644
|
return result;
|
|
@@ -12346,7 +12662,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
12346
12662
|
]);
|
|
12347
12663
|
for (const map of maps) {
|
|
12348
12664
|
if (!existsSync5(map)) continue;
|
|
12349
|
-
const contents =
|
|
12665
|
+
const contents = readFileSync17(map, "utf8");
|
|
12350
12666
|
for (const match of contents.matchAll(
|
|
12351
12667
|
/^(?:explicit\s+)?(?:framework\s+)?module\s+([A-Za-z_]\w*)/gm
|
|
12352
12668
|
))
|
|
@@ -12361,7 +12677,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
12361
12677
|
for (const entry of readdirSync8(resources)) {
|
|
12362
12678
|
const map = path27.join(resources, entry, "module.modulemap");
|
|
12363
12679
|
if (!existsSync5(map)) continue;
|
|
12364
|
-
for (const match of
|
|
12680
|
+
for (const match of readFileSync17(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
|
|
12365
12681
|
modules.add(match[1]);
|
|
12366
12682
|
}
|
|
12367
12683
|
for (const libc of [
|
|
@@ -12373,7 +12689,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
12373
12689
|
])
|
|
12374
12690
|
for (const entry of readdirSync8(libc)) {
|
|
12375
12691
|
if (!entry.endsWith(".modulemap")) continue;
|
|
12376
|
-
for (const match of
|
|
12692
|
+
for (const match of readFileSync17(path27.join(libc, entry), "utf8").matchAll(
|
|
12377
12693
|
/^module\s+([A-Za-z_]\w*)/gm
|
|
12378
12694
|
))
|
|
12379
12695
|
modules.add(match[1]);
|
|
@@ -12382,7 +12698,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
12382
12698
|
for (const entry of readdirSync8(directory)) {
|
|
12383
12699
|
const map = path27.join(directory, entry, "Modules/module.modulemap");
|
|
12384
12700
|
if (!existsSync5(map)) continue;
|
|
12385
|
-
for (const match of
|
|
12701
|
+
for (const match of readFileSync17(map, "utf8").matchAll(
|
|
12386
12702
|
/^framework\s+module\s+([A-Za-z_]\w*)/gm
|
|
12387
12703
|
))
|
|
12388
12704
|
modules.add(match[1]);
|
|
@@ -12491,12 +12807,12 @@ function distributionClangModuleMap(root, modules) {
|
|
|
12491
12807
|
const directory = path27.join(root, `.peach-clang-modules-${key}`);
|
|
12492
12808
|
const mapPath = path27.join(directory, "module.modulemap");
|
|
12493
12809
|
if (!existsSync5(mapPath)) {
|
|
12494
|
-
|
|
12810
|
+
mkdirSync7(directory, { recursive: true });
|
|
12495
12811
|
const parts = [];
|
|
12496
12812
|
for (const mod of missing) {
|
|
12497
12813
|
const destination = path27.join(directory, mod.header);
|
|
12498
|
-
|
|
12499
|
-
|
|
12814
|
+
mkdirSync7(path27.dirname(destination), { recursive: true });
|
|
12815
|
+
writeFileSync8(destination, mod.source);
|
|
12500
12816
|
parts.push(
|
|
12501
12817
|
`module ${mod.name} {
|
|
12502
12818
|
requires objc
|
|
@@ -12506,7 +12822,7 @@ function distributionClangModuleMap(root, modules) {
|
|
|
12506
12822
|
`
|
|
12507
12823
|
);
|
|
12508
12824
|
}
|
|
12509
|
-
|
|
12825
|
+
writeFileSync8(mapPath, parts.join("\n"));
|
|
12510
12826
|
}
|
|
12511
12827
|
return mapPath;
|
|
12512
12828
|
}
|
|
@@ -12521,13 +12837,13 @@ function providedModulesPath(root, modules, excluded) {
|
|
|
12521
12837
|
const directory = path27.join(root, `.peach-modules-${key}`);
|
|
12522
12838
|
const complete = path27.join(directory, ".complete");
|
|
12523
12839
|
if (!existsSync5(complete)) {
|
|
12524
|
-
|
|
12840
|
+
mkdirSync7(directory, { recursive: true });
|
|
12525
12841
|
for (const entry of readdirSync8(directory))
|
|
12526
|
-
|
|
12842
|
+
rmSync7(path27.join(directory, entry), { recursive: true, force: true });
|
|
12527
12843
|
for (const entry of entries) {
|
|
12528
12844
|
symlinkSync2(path27.join(modules, entry), path27.join(directory, entry));
|
|
12529
12845
|
}
|
|
12530
|
-
|
|
12846
|
+
writeFileSync8(complete, "");
|
|
12531
12847
|
}
|
|
12532
12848
|
return directory;
|
|
12533
12849
|
}
|
|
@@ -12599,6 +12915,14 @@ var FOUNDATION_IMPLICIT_MODULES = [
|
|
|
12599
12915
|
"PeachFoundationCombine",
|
|
12600
12916
|
"Darwin"
|
|
12601
12917
|
];
|
|
12918
|
+
var PRECONCURRENCY_FOUNDATION_IMPORT = /^[ \t]*@preconcurrency[ \t]+(?:(?:public|package|internal|fileprivate|private)[ \t]+)?import[ \t]+(?:Foundation|UIKit|SwiftUI)[ \t]*(?:\/\/.*)?$/m;
|
|
12919
|
+
function withPreconcurrencyFoundationModules(source) {
|
|
12920
|
+
if (!PRECONCURRENCY_FOUNDATION_IMPORT.test(source)) return source;
|
|
12921
|
+
return `${source}${source.endsWith("\n") ? "" : "\n"}#if canImport(PeachObjC)
|
|
12922
|
+
${["ObjectiveC", ...FOUNDATION_IMPLICIT_MODULES].map((module) => `@preconcurrency import ${module}
|
|
12923
|
+
`).join("")}#endif
|
|
12924
|
+
`;
|
|
12925
|
+
}
|
|
12602
12926
|
var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
|
|
12603
12927
|
(module) => `, "-Xfrontend", "-import-module", "-Xfrontend", "${module}"`
|
|
12604
12928
|
).join("");
|
|
@@ -12614,11 +12938,11 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
|
12614
12938
|
"-Xlinker", "--wrap=swift_udata_open",
|
|
12615
12939
|
"-Xlinker", "--wrap=swift_udata_openChoice",
|
|
12616
12940
|
`;
|
|
12617
|
-
var darwinRecordsRegion = (
|
|
12941
|
+
var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...quoted2, "-Wl,--end-lib"] : [];
|
|
12618
12942
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
12619
12943
|
var MULTI_MANIFEST_VERSION = 68;
|
|
12620
12944
|
var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
12621
|
-
var compilerSourceDigest = true ? "
|
|
12945
|
+
var compilerSourceDigest = true ? "645b0e6bc4e374f7c82da4d402e0ec9ddedfc49d6e5a74b73284852f1fbd4efc" : swiftCompilerSourceDigest(import.meta.dirname);
|
|
12622
12946
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
12623
12947
|
const hash = createHash13("sha256");
|
|
12624
12948
|
hash.update(`swift-compile
|
|
@@ -12628,9 +12952,10 @@ ${release}
|
|
|
12628
12952
|
if (input.oneModule) hash.update("one-module\n");
|
|
12629
12953
|
if (KEEP_WASM_NAMES) hash.update("names\n");
|
|
12630
12954
|
hash.update(swiftModuleDigest(moduleRoot));
|
|
12631
|
-
|
|
12632
|
-
${
|
|
12955
|
+
hash.update(`lower
|
|
12956
|
+
${WASM_LOWER_IDENTITY}
|
|
12633
12957
|
`);
|
|
12958
|
+
if (input.optimize) hash.update("optimize\n");
|
|
12634
12959
|
for (const file of Object.keys(input.files).sort()) {
|
|
12635
12960
|
hash.update(createHash13("sha256").update(file).digest());
|
|
12636
12961
|
hash.update(createHash13("sha256").update(input.files[file]).digest());
|
|
@@ -12740,6 +13065,7 @@ function toolsetOrdersLibcxxBeforeDarwinOverlay(options) {
|
|
|
12740
13065
|
const overlay = options.indexOf("=/darwin/wasm/include");
|
|
12741
13066
|
return libcxx >= 0 && overlay > libcxx;
|
|
12742
13067
|
}
|
|
13068
|
+
var SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET = "12.0";
|
|
12743
13069
|
function emitSwiftPackageManifest(args) {
|
|
12744
13070
|
const {
|
|
12745
13071
|
targets,
|
|
@@ -12759,7 +13085,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
12759
13085
|
if (!flag.startsWith("-fmodule-map-file=")) return false;
|
|
12760
13086
|
const file = flag.slice("-fmodule-map-file=".length).replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root);
|
|
12761
13087
|
if (!file.includes("/Pods/Headers/")) return false;
|
|
12762
|
-
const map = args.files.get(file) ?? (existsSync5(file) ?
|
|
13088
|
+
const map = args.files.get(file) ?? (existsSync5(file) ? readFileSync17(file) : void 0);
|
|
12763
13089
|
const name2 = map === void 0 ? void 0 : moduleMapName(map.toString());
|
|
12764
13090
|
return name2 !== void 0 && packageModules.has(name2);
|
|
12765
13091
|
};
|
|
@@ -12791,7 +13117,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
12791
13117
|
const product = v5.parse(
|
|
12792
13118
|
swiftFrameworkProductSchema,
|
|
12793
13119
|
JSON.parse(
|
|
12794
|
-
|
|
13120
|
+
readFileSync17(path27.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
|
|
12795
13121
|
)
|
|
12796
13122
|
);
|
|
12797
13123
|
const replacedObjects = new Set(
|
|
@@ -12805,7 +13131,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
12805
13131
|
(name2) => !object3.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
|
|
12806
13132
|
)
|
|
12807
13133
|
);
|
|
12808
|
-
const
|
|
13134
|
+
const quoted2 = (object3) => `"${path27.join(moduleRoot, object3).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
12809
13135
|
const categoryObjects = new Set(
|
|
12810
13136
|
foundationCategoryObjects.map((name2) => `lib/Foundation-${name2}.o`)
|
|
12811
13137
|
);
|
|
@@ -12814,11 +13140,11 @@ function emitSwiftPackageManifest(args) {
|
|
|
12814
13140
|
objects.filter((object3) => roots.has(object3) || categoryObjects.has(object3))
|
|
12815
13141
|
);
|
|
12816
13142
|
const list = [
|
|
12817
|
-
...[...eager].map(
|
|
13143
|
+
...[...eager].map(quoted2),
|
|
12818
13144
|
"-Wl,--start-lib",
|
|
12819
|
-
...available.filter((object3) => !eager.has(object3)).map(
|
|
13145
|
+
...available.filter((object3) => !eager.has(object3)).map(quoted2),
|
|
12820
13146
|
"-Wl,--end-lib",
|
|
12821
|
-
...darwinRecordsRegion(distribution.objects.filter(isProvider).map(
|
|
13147
|
+
...darwinRecordsRegion(distribution.objects.filter(isProvider).map(quoted2))
|
|
12822
13148
|
].join("\n") + "\n";
|
|
12823
13149
|
distributionLinkPath = distributionLink.path.replace(
|
|
12824
13150
|
/\.rsp$/,
|
|
@@ -12940,7 +13266,8 @@ function emitSwiftPackageManifest(args) {
|
|
|
12940
13266
|
(value) => value.late?.producers.includes(target.name)
|
|
12941
13267
|
)) ? `, "-emit-objc-header-path", ${JSON.stringify(path27.join(args.headerDirectory, `${target.name}-Swift${args.nativeHeaderDeclarations?.[target.name] ? ".original" : ""}.h`))}` : "";
|
|
12942
13268
|
const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
|
|
12943
|
-
const
|
|
13269
|
+
const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
|
|
13270
|
+
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}]`)})]`;
|
|
12944
13271
|
const deps = [
|
|
12945
13272
|
.../* @__PURE__ */ new Set([
|
|
12946
13273
|
...(target.dependencies ?? []).flatMap(
|
|
@@ -13106,7 +13433,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13106
13433
|
].join("\n");
|
|
13107
13434
|
}
|
|
13108
13435
|
function syncSwiftTree(base, files) {
|
|
13109
|
-
|
|
13436
|
+
mkdirSync7(base, { recursive: true });
|
|
13110
13437
|
const walk = (dir) => {
|
|
13111
13438
|
for (const entry of readdirSync8(dir, { withFileTypes: true })) {
|
|
13112
13439
|
const full = path27.join(dir, entry.name);
|
|
@@ -13115,7 +13442,7 @@ function syncSwiftTree(base, files) {
|
|
|
13115
13442
|
entry.name.startsWith(".peach-clang-modules-") || entry.name === SWIFT_LINK_STAMP))
|
|
13116
13443
|
continue;
|
|
13117
13444
|
if (entry.isDirectory()) walk(full);
|
|
13118
|
-
else if (!files.has(full))
|
|
13445
|
+
else if (!files.has(full)) rmSync7(full, { force: true });
|
|
13119
13446
|
}
|
|
13120
13447
|
};
|
|
13121
13448
|
walk(base);
|
|
@@ -13125,6 +13452,7 @@ function syncSwiftTree(base, files) {
|
|
|
13125
13452
|
}
|
|
13126
13453
|
var DIRECTIVE = /^[ \t]*#(?:if|elseif)\b/;
|
|
13127
13454
|
var OS_IOS = /\b(?:os\(\s*iOS\s*\)|targetEnvironment\(\s*simulator\s*\))/g;
|
|
13455
|
+
var NOT_ON_IOS = /\b(?:os\(\s*WASI\s*\)|canImport\(\s*FoundationNetworking\s*\))/g;
|
|
13128
13456
|
var DELEGATE_CLASS = /^class\s+[A-Za-z_]\w*\s*(?:<[^>{]*>)?\s*:[^{]*\b(?:UIApplicationDelegate|UISceneDelegate|UIWindowSceneDelegate)\b[^{]*\{/;
|
|
13129
13457
|
function compiledSwiftSources(files, targets, overlayFrameworks) {
|
|
13130
13458
|
const ordered = [...targets].sort((a, b) => b.path.length - a.path.length);
|
|
@@ -13139,14 +13467,14 @@ function compiledSwiftSources(files, targets, overlayFrameworks) {
|
|
|
13139
13467
|
);
|
|
13140
13468
|
});
|
|
13141
13469
|
const manifest = /(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file);
|
|
13142
|
-
|
|
13143
|
-
file,
|
|
13144
|
-
|
|
13145
|
-
|
|
13146
|
-
|
|
13147
|
-
|
|
13148
|
-
|
|
13149
|
-
];
|
|
13470
|
+
if (manifest && (!owner || /^Package(?:@swift-[\d.]+)?\.swift$/.test(file)))
|
|
13471
|
+
return [file, source];
|
|
13472
|
+
const ios = swiftSourceAsIOS(
|
|
13473
|
+
source,
|
|
13474
|
+
overlayFrameworks,
|
|
13475
|
+
owner?.defines?.includes(SWIFT_XCODE_BUILD_CONDITION) && !owner.defines.includes("SWIFT_PACKAGE") ? false : void 0
|
|
13476
|
+
);
|
|
13477
|
+
return [file, withPreconcurrencyFoundationModules(ios)];
|
|
13150
13478
|
})
|
|
13151
13479
|
);
|
|
13152
13480
|
}
|
|
@@ -13797,16 +14125,22 @@ function foundationOwnerOf(name2) {
|
|
|
13797
14125
|
return "PeachFoundation";
|
|
13798
14126
|
return void 0;
|
|
13799
14127
|
}
|
|
13800
|
-
function
|
|
13801
|
-
|
|
14128
|
+
function swiftPackageSourceAsIOS(source) {
|
|
14129
|
+
return swiftConditionsAsIOS(source, swiftCodeScan(source).lineStarts);
|
|
14130
|
+
}
|
|
14131
|
+
function swiftConditionsAsIOS(source, lineStarts, swiftPackage) {
|
|
13802
14132
|
let offset = 0;
|
|
13803
|
-
|
|
14133
|
+
return source.split("\n").map((line) => {
|
|
13804
14134
|
const start = offset;
|
|
13805
14135
|
offset += line.length + 1;
|
|
13806
14136
|
if (!lineStarts.has(start) || !DIRECTIVE.test(line)) return line;
|
|
13807
|
-
const platform = line.replace(OS_IOS, (match) => "true".padEnd(match.length));
|
|
14137
|
+
const platform = line.replace(OS_IOS, (match) => "true".padEnd(match.length)).replace(NOT_ON_IOS, (match) => "false".padEnd(match.length));
|
|
13808
14138
|
return swiftPackage === false ? platform.replace(/\bSWIFT_PACKAGE\b/g, (match) => "false".padEnd(match.length)) : platform;
|
|
13809
14139
|
}).join("\n");
|
|
14140
|
+
}
|
|
14141
|
+
function swiftSourceAsIOS(source, overlayFrameworks, swiftPackage) {
|
|
14142
|
+
const { lineStarts, tokens } = swiftCodeScan(source);
|
|
14143
|
+
const conditioned = swiftConditionsAsIOS(source, lineStarts, swiftPackage);
|
|
13810
14144
|
let out = "";
|
|
13811
14145
|
let copied = 0;
|
|
13812
14146
|
const sceneLifecycleBodies = /* @__PURE__ */ new Set();
|
|
@@ -14263,7 +14597,7 @@ var wasmMacroEnvironment = {
|
|
|
14263
14597
|
...emptyMacroEnvironment,
|
|
14264
14598
|
defines: /* @__PURE__ */ new Map([
|
|
14265
14599
|
["__wasm__", "1"],
|
|
14266
|
-
["
|
|
14600
|
+
["__wasm64__", "1"],
|
|
14267
14601
|
["__wasi__", "1"]
|
|
14268
14602
|
])
|
|
14269
14603
|
};
|
|
@@ -14427,7 +14761,7 @@ function swiftCodeScan(source) {
|
|
|
14427
14761
|
return { lineStarts: starts, tokens };
|
|
14428
14762
|
}
|
|
14429
14763
|
function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
14430
|
-
|
|
14764
|
+
rmSync7(destination, { recursive: true, force: true });
|
|
14431
14765
|
const origins = {};
|
|
14432
14766
|
const moduleMaps = [];
|
|
14433
14767
|
const gather = (from) => {
|
|
@@ -14437,14 +14771,14 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
|
14437
14771
|
const file = path27.join(from, entry.name);
|
|
14438
14772
|
if (entry.isDirectory()) gather(file);
|
|
14439
14773
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
14440
|
-
origins[path27.relative(source, file)] =
|
|
14774
|
+
origins[path27.relative(source, file)] = readFileSync17(file, "utf8");
|
|
14441
14775
|
else if (entry.isFile() && entry.name.endsWith(".modulemap"))
|
|
14442
|
-
moduleMaps.push(
|
|
14776
|
+
moduleMaps.push(readFileSync17(file, "utf8"));
|
|
14443
14777
|
}
|
|
14444
14778
|
};
|
|
14445
14779
|
gather(source);
|
|
14446
14780
|
const manifest = path27.join(source, "Package.swift");
|
|
14447
|
-
const targets = existsSync5(manifest) ? swiftManifestTargets(
|
|
14781
|
+
const targets = existsSync5(manifest) ? swiftManifestTargets(readFileSync17(manifest, "utf8")) : [];
|
|
14448
14782
|
let dependencyOverlays;
|
|
14449
14783
|
const compiled = compiledSwiftSources(origins, targets, () => {
|
|
14450
14784
|
if (dependencyOverlays) return dependencyOverlays;
|
|
@@ -14462,7 +14796,7 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
|
14462
14796
|
return dependencyOverlays;
|
|
14463
14797
|
});
|
|
14464
14798
|
const copy = (from, to) => {
|
|
14465
|
-
|
|
14799
|
+
mkdirSync7(to, { recursive: true });
|
|
14466
14800
|
for (const entry of readdirSync8(from, { withFileTypes: true })) {
|
|
14467
14801
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
14468
14802
|
continue;
|
|
@@ -14470,7 +14804,7 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
|
14470
14804
|
const target = path27.join(to, entry.name);
|
|
14471
14805
|
if (entry.isDirectory()) copy(file, target);
|
|
14472
14806
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
14473
|
-
|
|
14807
|
+
writeFileSync8(target, compiled.get(path27.relative(source, file)));
|
|
14474
14808
|
else cpSync(file, target, { verbatimSymlinks: true });
|
|
14475
14809
|
}
|
|
14476
14810
|
};
|
|
@@ -14502,7 +14836,7 @@ function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
|
|
|
14502
14836
|
return [`-fmodule-map-file=${published}`];
|
|
14503
14837
|
const cached = written.get(headers);
|
|
14504
14838
|
if (cached) return [cached];
|
|
14505
|
-
|
|
14839
|
+
mkdirSync7(directory, { recursive: true });
|
|
14506
14840
|
const output = path27.join(directory, `module-${written.size}.modulemap`);
|
|
14507
14841
|
writeBuildFile(
|
|
14508
14842
|
output,
|
|
@@ -14630,12 +14964,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
14630
14964
|
if (existsSync5(headerDirectory)) {
|
|
14631
14965
|
for (const entry of readdirSync8(headerDirectory, { withFileTypes: true }))
|
|
14632
14966
|
if (entry.isDirectory() && !targets.some((target) => target.name === entry.name))
|
|
14633
|
-
|
|
14967
|
+
rmSync7(path27.join(headerDirectory, entry.name), { recursive: true, force: true });
|
|
14634
14968
|
}
|
|
14635
14969
|
let checkedToolchain;
|
|
14636
14970
|
const nativeToolchain = () => {
|
|
14637
14971
|
if (checkedToolchain) return checkedToolchain;
|
|
14638
|
-
const pin = distribution ?? JSON.parse(
|
|
14972
|
+
const pin = distribution ?? JSON.parse(readFileSync17(path27.join(moduleRoot, "toolchain.json"), "utf8"));
|
|
14639
14973
|
checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
|
|
14640
14974
|
return checkedToolchain;
|
|
14641
14975
|
};
|
|
@@ -15056,7 +15390,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15056
15390
|
const origin = settings?.sourceDirectories[file];
|
|
15057
15391
|
if (origin) {
|
|
15058
15392
|
const original = path27.join(layout2.root, origin, path27.posix.basename(file));
|
|
15059
|
-
|
|
15393
|
+
mkdirSync7(path27.dirname(original), { recursive: true });
|
|
15060
15394
|
stageTargetFile(target.name, original, contents, { allowExisting: true });
|
|
15061
15395
|
}
|
|
15062
15396
|
const source = unitSource(file);
|
|
@@ -15294,7 +15628,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15294
15628
|
`extern module ${map.module} ${JSON.stringify(map.published)}
|
|
15295
15629
|
`
|
|
15296
15630
|
);
|
|
15297
|
-
if (native.size > 0)
|
|
15631
|
+
if (native.size > 0) mkdirSync7(headerDirectory, { recursive: true });
|
|
15298
15632
|
const headerAliasFlags = Object.keys(input.headerAliases ?? {}).length > 0 ? ["-ivfsoverlay", headerSearch.files[0]] : [];
|
|
15299
15633
|
const nativeHeaderFlags = [...headerAliasFlags];
|
|
15300
15634
|
const nativeSwiftHeaderMaps = /* @__PURE__ */ new Map();
|
|
@@ -15360,7 +15694,7 @@ module ${moduleName}.Swift {
|
|
|
15360
15694
|
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
15361
15695
|
);
|
|
15362
15696
|
if (!distribution) {
|
|
15363
|
-
modulePlan.update(
|
|
15697
|
+
modulePlan.update(readFileSync17(path27.join(moduleRoot, "Package.swift")));
|
|
15364
15698
|
}
|
|
15365
15699
|
modulePlan.update(
|
|
15366
15700
|
Object.keys(input.files).filter((file) => file.endsWith(".swift")).sort().join("\n")
|
|
@@ -15569,7 +15903,7 @@ module ${moduleName}.Swift {
|
|
|
15569
15903
|
if (file === "Package.swift") continue;
|
|
15570
15904
|
files.set(path27.join(layout2.sources, file), compiled.get(file) ?? contents);
|
|
15571
15905
|
}
|
|
15572
|
-
let manifest =
|
|
15906
|
+
let manifest = readFileSync17(
|
|
15573
15907
|
path27.join(moduleRoot, "scripts/contrast-app-Package.swift"),
|
|
15574
15908
|
"utf8"
|
|
15575
15909
|
).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
|
|
@@ -15756,8 +16090,15 @@ module ${moduleName}.Swift {
|
|
|
15756
16090
|
}) + moduleFiles
|
|
15757
16091
|
);
|
|
15758
16092
|
}
|
|
15759
|
-
for (const [file, bytes] of Object.entries(input.packageFiles ?? {}))
|
|
15760
|
-
|
|
16093
|
+
for (const [file, bytes] of Object.entries(input.packageFiles ?? {})) {
|
|
16094
|
+
const contents = Buffer.from(bytes, "base64");
|
|
16095
|
+
files.set(
|
|
16096
|
+
path27.join(layout2.root, file),
|
|
16097
|
+
file.endsWith(".swift") && !/(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file) ? withPreconcurrencyFoundationModules(
|
|
16098
|
+
swiftPackageSourceAsIOS(contents.toString("utf8"))
|
|
16099
|
+
) : contents
|
|
16100
|
+
);
|
|
16101
|
+
}
|
|
15761
16102
|
for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
|
|
15762
16103
|
const destination = path27.join(layout2.root, file);
|
|
15763
16104
|
if (files.has(destination)) continue;
|
|
@@ -15774,14 +16115,36 @@ module ${moduleName}.Swift {
|
|
|
15774
16115
|
)
|
|
15775
16116
|
] : []
|
|
15776
16117
|
];
|
|
16118
|
+
const clangWrapper2 = path27.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
|
|
16119
|
+
files.set(
|
|
16120
|
+
clangWrapper2,
|
|
16121
|
+
[
|
|
16122
|
+
"#!/bin/sh",
|
|
16123
|
+
"name=",
|
|
16124
|
+
"prev=",
|
|
16125
|
+
'for arg in "$@"; do',
|
|
16126
|
+
' if [ "$prev" = -o ]; then name=${arg%/*}; name=${name##*/}; fi',
|
|
16127
|
+
" prev=$arg",
|
|
16128
|
+
"done",
|
|
16129
|
+
"case $name in",
|
|
16130
|
+
` *.build) exec '${path27.join(nativeToolchain(), "clang")}' "-fmodule-name=\${name%.build}" "$@" ;;`,
|
|
16131
|
+
` *) exec '${path27.join(nativeToolchain(), "clang")}' "$@" ;;`,
|
|
16132
|
+
"esac",
|
|
16133
|
+
""
|
|
16134
|
+
].join("\n")
|
|
16135
|
+
);
|
|
15777
16136
|
files.set(
|
|
15778
16137
|
path27.join(layout2.root, ".peach-target-toolset.json"),
|
|
15779
16138
|
JSON.stringify({
|
|
15780
16139
|
schemaVersion: "1.0",
|
|
15781
|
-
|
|
15782
|
-
|
|
15783
|
-
|
|
15784
|
-
|
|
16140
|
+
cCompiler: {
|
|
16141
|
+
extraCLIOptions: [
|
|
16142
|
+
...nativeToolsetFlags,
|
|
16143
|
+
"-fmodules",
|
|
16144
|
+
`-fmodules-cache-path=${path27.join(layout2.root, ".build", "ModuleCache")}`
|
|
16145
|
+
]
|
|
16146
|
+
},
|
|
16147
|
+
...nativeToolsetFlags.length > 0 ? { cxxCompiler: { extraCLIOptions: nativeToolsetFlags } } : {},
|
|
15785
16148
|
swiftCompiler: {
|
|
15786
16149
|
extraCLIOptions: [
|
|
15787
16150
|
...headerAliasFlags.flatMap((flag) => ["-Xcc", flag]),
|
|
@@ -15862,9 +16225,11 @@ module ${moduleName}.Swift {
|
|
|
15862
16225
|
"// dependency targets emit their native compatibility headers.\n"
|
|
15863
16226
|
);
|
|
15864
16227
|
syncSwiftTree(layout2.root, files);
|
|
16228
|
+
const clangWrapper = path27.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
|
|
16229
|
+
if (files.has(clangWrapper)) chmodSync2(clangWrapper, 493);
|
|
15865
16230
|
const dependencies = new Map(
|
|
15866
16231
|
swiftManifestTargets(
|
|
15867
|
-
|
|
16232
|
+
readFileSync17(path27.join(layout2.root, "Package.swift"), "utf8")
|
|
15868
16233
|
).map((target) => [
|
|
15869
16234
|
target.name,
|
|
15870
16235
|
(target.dependencies ?? []).flatMap(
|
|
@@ -15919,7 +16284,7 @@ function outputOf(error) {
|
|
|
15919
16284
|
}
|
|
15920
16285
|
function builtArtifact(layout2) {
|
|
15921
16286
|
const binDir = path27.join(layout2.root, ".build", WASM_TRIPLE, "release");
|
|
15922
|
-
const manifest =
|
|
16287
|
+
const manifest = readFileSync17(path27.join(layout2.root, "Package.swift"), "utf8");
|
|
15923
16288
|
const executable = swiftManifestTargets(manifest).find((target) => target.executable);
|
|
15924
16289
|
if (executable === void 0) {
|
|
15925
16290
|
throw new Error("swift-compile: the written manifest names no executable target");
|
|
@@ -15964,12 +16329,12 @@ function serialize(root, work, signal) {
|
|
|
15964
16329
|
function readCompiledArtifact(directory, hash) {
|
|
15965
16330
|
try {
|
|
15966
16331
|
const receipt = JSON.parse(
|
|
15967
|
-
|
|
16332
|
+
readFileSync17(path27.join(directory, "artifact.json"), "utf8")
|
|
15968
16333
|
);
|
|
15969
16334
|
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")
|
|
15970
16335
|
return null;
|
|
15971
|
-
const bytes =
|
|
15972
|
-
const gzip2 =
|
|
16336
|
+
const bytes = readFileSync17(path27.join(directory, "app.wasm"));
|
|
16337
|
+
const gzip2 = readFileSync17(path27.join(directory, "icu.gz"));
|
|
15973
16338
|
if (createHash13("sha256").update(bytes).digest("hex") !== receipt.wasm || createHash13("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length <= 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
|
|
15974
16339
|
return null;
|
|
15975
16340
|
return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 } };
|
|
@@ -15981,12 +16346,12 @@ function readCompiledArtifact(directory, hash) {
|
|
|
15981
16346
|
}
|
|
15982
16347
|
function saveCompiledArtifact(root, artifact) {
|
|
15983
16348
|
const directory = path27.join(root, "artifact");
|
|
15984
|
-
|
|
16349
|
+
mkdirSync7(directory, { recursive: true });
|
|
15985
16350
|
const pending = mkdtempSync3(path27.join(root, ".artifact-"));
|
|
15986
16351
|
try {
|
|
15987
|
-
|
|
15988
|
-
|
|
15989
|
-
|
|
16352
|
+
writeFileSync8(path27.join(pending, "app.wasm"), artifact.bytes);
|
|
16353
|
+
writeFileSync8(path27.join(pending, "icu.gz"), artifact.icu.gzip);
|
|
16354
|
+
writeFileSync8(
|
|
15990
16355
|
path27.join(pending, "artifact.json"),
|
|
15991
16356
|
JSON.stringify({
|
|
15992
16357
|
hash: artifact.hash,
|
|
@@ -15998,7 +16363,7 @@ function saveCompiledArtifact(root, artifact) {
|
|
|
15998
16363
|
renameSync2(path27.join(pending, file), path27.join(directory, file));
|
|
15999
16364
|
}
|
|
16000
16365
|
} finally {
|
|
16001
|
-
|
|
16366
|
+
rmSync7(pending, { recursive: true, force: true });
|
|
16002
16367
|
}
|
|
16003
16368
|
}
|
|
16004
16369
|
var SHARED_ARTIFACT_BUDGET_BYTES = 4 * 1024 ** 3;
|
|
@@ -16087,7 +16452,7 @@ function frameworkLibraryTargets(manifest) {
|
|
|
16087
16452
|
}
|
|
16088
16453
|
function linkedFrameworkTargets(moduleRoot, input) {
|
|
16089
16454
|
const libraries = frameworkLibraryTargets(
|
|
16090
|
-
|
|
16455
|
+
readFileSync17(path27.join(moduleRoot, "Package.swift"), "utf8")
|
|
16091
16456
|
);
|
|
16092
16457
|
const targets = compileTargets(input);
|
|
16093
16458
|
const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
|
|
@@ -16110,7 +16475,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
16110
16475
|
for (const name2 of [...siblings.values()].flat())
|
|
16111
16476
|
if (libraries.has(name2) && !planning.some((target) => target.name === name2))
|
|
16112
16477
|
reach(name2);
|
|
16113
|
-
const manifest =
|
|
16478
|
+
const manifest = readFileSync17(path27.join(moduleRoot, "Package.swift"), "utf8");
|
|
16114
16479
|
const targetDependencies = /* @__PURE__ */ new Map();
|
|
16115
16480
|
for (const match of manifest.matchAll(
|
|
16116
16481
|
/\.target\(\s*name:\s*"([^"]+)"\s*,\s*dependencies:\s*\[([^\]]*)\]/g
|
|
@@ -16132,7 +16497,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
16132
16497
|
const companion = path27.basename(directory, ".swiftcrossimport");
|
|
16133
16498
|
if (!built.has(companion)) continue;
|
|
16134
16499
|
const declaration = path27.join(overlays, directory, "SwiftUI.swiftoverlay");
|
|
16135
|
-
for (const match of
|
|
16500
|
+
for (const match of readFileSync17(declaration, "utf8").matchAll(
|
|
16136
16501
|
/^\s*- name: ([A-Za-z_]\w*)\s*$/gm
|
|
16137
16502
|
))
|
|
16138
16503
|
reach(match[1]);
|
|
@@ -16181,12 +16546,12 @@ ${dependencies}
|
|
|
16181
16546
|
)
|
|
16182
16547
|
`;
|
|
16183
16548
|
const sourceDir = path27.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
|
|
16184
|
-
|
|
16549
|
+
mkdirSync7(sourceDir, { recursive: true });
|
|
16185
16550
|
const manifestPath = path27.join(linkRoot, "Package.swift");
|
|
16186
|
-
if (!existsSync5(manifestPath) ||
|
|
16187
|
-
|
|
16551
|
+
if (!existsSync5(manifestPath) || readFileSync17(manifestPath, "utf8") !== manifest)
|
|
16552
|
+
writeFileSync8(manifestPath, manifest);
|
|
16188
16553
|
const source = path27.join(sourceDir, "Link.swift");
|
|
16189
|
-
if (!existsSync5(source))
|
|
16554
|
+
if (!existsSync5(source)) writeFileSync8(source, "");
|
|
16190
16555
|
}
|
|
16191
16556
|
function frameworkLinkClosure(scratch2, roots) {
|
|
16192
16557
|
const suffix = `${WASM_TRIPLE}-release`;
|
|
@@ -16197,7 +16562,7 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
16197
16562
|
const moduleMaps = /* @__PURE__ */ new Map();
|
|
16198
16563
|
let pending = null;
|
|
16199
16564
|
let compiling = null;
|
|
16200
|
-
for (const line of
|
|
16565
|
+
for (const line of readFileSync17(path27.join(scratch2, "release.yaml"), "utf8").split(
|
|
16201
16566
|
"\n"
|
|
16202
16567
|
)) {
|
|
16203
16568
|
const phony = phonyHeader.exec(line);
|
|
@@ -16278,7 +16643,7 @@ function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
|
|
|
16278
16643
|
if (dot <= 0) continue;
|
|
16279
16644
|
const module = name2.slice(0, dot);
|
|
16280
16645
|
if (keep.has(module) || !folded.has(module.toLowerCase())) continue;
|
|
16281
|
-
|
|
16646
|
+
rmSync7(path27.join(modulesDir, name2), { recursive: true, force: true });
|
|
16282
16647
|
}
|
|
16283
16648
|
}
|
|
16284
16649
|
async function buildFrameworkProducts(scratch2, args) {
|
|
@@ -16308,6 +16673,9 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
16308
16673
|
"release",
|
|
16309
16674
|
"-Xswiftc",
|
|
16310
16675
|
"-Osize",
|
|
16676
|
+
// the release link strips all debug info, so none is generated
|
|
16677
|
+
"-Xswiftc",
|
|
16678
|
+
"-gnone",
|
|
16311
16679
|
"-Xswiftc",
|
|
16312
16680
|
"-num-threads",
|
|
16313
16681
|
"-Xswiftc",
|
|
@@ -16345,9 +16713,9 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
16345
16713
|
const constantsDir = path27.join(scratch2, "uniform-type-constants");
|
|
16346
16714
|
const constantsStamp = path27.join(constantsDir, ".complete");
|
|
16347
16715
|
const object3 = path27.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
|
|
16348
|
-
if (!existsSync5(constantsStamp) ||
|
|
16349
|
-
|
|
16350
|
-
|
|
16716
|
+
if (!existsSync5(constantsStamp) || readFileSync17(constantsStamp, "utf8") !== args.frameworkKey) {
|
|
16717
|
+
rmSync7(constantsDir, { recursive: true, force: true });
|
|
16718
|
+
mkdirSync7(constantsDir);
|
|
16351
16719
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
16352
16720
|
compileUniformTypeConstants({
|
|
16353
16721
|
bin: args.toolchainBin,
|
|
@@ -16357,20 +16725,20 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
16357
16725
|
minimum: darwinRecordsMinimum(),
|
|
16358
16726
|
out: constantsDir
|
|
16359
16727
|
});
|
|
16360
|
-
|
|
16728
|
+
writeFileSync8(constantsStamp, args.frameworkKey);
|
|
16361
16729
|
}
|
|
16362
16730
|
objects.push(object3);
|
|
16363
16731
|
linked.owners.set(object3, "UniformTypeIdentifiers");
|
|
16364
16732
|
}
|
|
16365
16733
|
removeCaseCollidingModuleArtifacts(path27.join(release, "Modules"), linked.modules);
|
|
16366
16734
|
const response = path27.join(scratch2, "autolink-objects.rsp");
|
|
16367
|
-
|
|
16735
|
+
writeFileSync8(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
|
|
16368
16736
|
const extracted = await runCompiler(
|
|
16369
16737
|
path27.join(args.toolchainBin, "swift-autolink-extract"),
|
|
16370
16738
|
[`@${response}`, "-o", "-"],
|
|
16371
16739
|
args.buildOptions
|
|
16372
16740
|
);
|
|
16373
|
-
|
|
16741
|
+
rmSync7(response, { force: true });
|
|
16374
16742
|
const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
|
|
16375
16743
|
if (link.includes("-lFoundation"))
|
|
16376
16744
|
for (const name2 of foundationCategoryObjects) {
|
|
@@ -16383,9 +16751,9 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
16383
16751
|
}
|
|
16384
16752
|
const providerDir = path27.join(scratch2, "darwin-records");
|
|
16385
16753
|
const providerStamp = path27.join(providerDir, ".complete");
|
|
16386
|
-
if (!existsSync5(providerStamp) ||
|
|
16387
|
-
|
|
16388
|
-
|
|
16754
|
+
if (!existsSync5(providerStamp) || readFileSync17(providerStamp, "utf8") !== args.frameworkKey) {
|
|
16755
|
+
rmSync7(providerDir, { recursive: true, force: true });
|
|
16756
|
+
mkdirSync7(providerDir);
|
|
16389
16757
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
16390
16758
|
compileDarwinRecords({
|
|
16391
16759
|
bin: args.toolchainBin,
|
|
@@ -16395,13 +16763,13 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
16395
16763
|
minimum: darwinRecordsMinimum(),
|
|
16396
16764
|
out: providerDir
|
|
16397
16765
|
});
|
|
16398
|
-
|
|
16766
|
+
writeFileSync8(providerStamp, args.frameworkKey);
|
|
16399
16767
|
}
|
|
16400
16768
|
const providers = readdirSync8(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path27.join(providerDir, file));
|
|
16401
16769
|
for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
|
|
16402
16770
|
const archive = path27.join(scratch2, "lib");
|
|
16403
|
-
|
|
16404
|
-
|
|
16771
|
+
rmSync7(archive, { recursive: true, force: true });
|
|
16772
|
+
mkdirSync7(archive);
|
|
16405
16773
|
const archived = /* @__PURE__ */ new Map();
|
|
16406
16774
|
for (const object3 of objects) {
|
|
16407
16775
|
const target = linked.owners.get(object3);
|
|
@@ -16442,7 +16810,7 @@ function swiftFrameworkScratch(frameworkKey) {
|
|
|
16442
16810
|
}
|
|
16443
16811
|
function swiftFrameworkSlotRecord(slot, record) {
|
|
16444
16812
|
try {
|
|
16445
|
-
return
|
|
16813
|
+
return readFileSync17(path27.join(slot, record), "utf8").trim();
|
|
16446
16814
|
} catch (error) {
|
|
16447
16815
|
if (!vanished(error)) throw error;
|
|
16448
16816
|
return null;
|
|
@@ -16454,7 +16822,7 @@ function swiftFrameworkSlotKey(slot) {
|
|
|
16454
16822
|
async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
16455
16823
|
const slots = Array.from({ length: SWIFT_FRAMEWORK_SLOTS }, (_, index) => {
|
|
16456
16824
|
const slot = path27.join(swiftFrameworksDir(), `slot-${index}`);
|
|
16457
|
-
|
|
16825
|
+
mkdirSync7(slot, { recursive: true });
|
|
16458
16826
|
return slot;
|
|
16459
16827
|
});
|
|
16460
16828
|
const run2 = (slot) => (lease) => {
|
|
@@ -16487,7 +16855,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
|
16487
16855
|
return withSwiftRootLock(oldest[0], run2(oldest[0]), signal);
|
|
16488
16856
|
}
|
|
16489
16857
|
function mirrorTree2(source, target, skip) {
|
|
16490
|
-
|
|
16858
|
+
mkdirSync7(target, { recursive: true });
|
|
16491
16859
|
const wanted = /* @__PURE__ */ new Set();
|
|
16492
16860
|
let restructured = false;
|
|
16493
16861
|
for (const entry of readdirSync8(source, { withFileTypes: true })) {
|
|
@@ -16503,18 +16871,18 @@ function mirrorTree2(source, target, skip) {
|
|
|
16503
16871
|
}
|
|
16504
16872
|
if (!existing) restructured = true;
|
|
16505
16873
|
if (entry.isDirectory()) {
|
|
16506
|
-
if (existing && !existing.isDirectory())
|
|
16874
|
+
if (existing && !existing.isDirectory()) rmSync7(to, { force: true });
|
|
16507
16875
|
if (mirrorTree2(from, to)) restructured = true;
|
|
16508
16876
|
} else if (entry.isSymbolicLink()) {
|
|
16509
16877
|
const link = readlinkSync(from);
|
|
16510
16878
|
if (existing?.isSymbolicLink() && readlinkSync(to) === link) continue;
|
|
16511
|
-
if (existing)
|
|
16879
|
+
if (existing) rmSync7(to, { recursive: true, force: true });
|
|
16512
16880
|
symlinkSync2(link, to);
|
|
16513
16881
|
} else {
|
|
16514
16882
|
const stat = statSync2(from);
|
|
16515
|
-
if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs ||
|
|
16883
|
+
if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs || readFileSync17(from).equals(readFileSync17(to))))
|
|
16516
16884
|
continue;
|
|
16517
|
-
if (existing)
|
|
16885
|
+
if (existing) rmSync7(to, { recursive: true, force: true });
|
|
16518
16886
|
const partial = `${to}.${randomUUID5()}`;
|
|
16519
16887
|
copyFileSync(from, partial);
|
|
16520
16888
|
utimesSync(partial, stat.atime, stat.mtime);
|
|
@@ -16523,7 +16891,7 @@ function mirrorTree2(source, target, skip) {
|
|
|
16523
16891
|
}
|
|
16524
16892
|
for (const name2 of readdirSync8(target))
|
|
16525
16893
|
if (!wanted.has(name2) && name2 !== skip) {
|
|
16526
|
-
|
|
16894
|
+
rmSync7(path27.join(target, name2), { recursive: true, force: true });
|
|
16527
16895
|
restructured = true;
|
|
16528
16896
|
}
|
|
16529
16897
|
return restructured;
|
|
@@ -16533,22 +16901,22 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
|
16533
16901
|
const staged = path27.join(slot, "source");
|
|
16534
16902
|
const stagedModule = path27.join(staged, "packages", path27.basename(moduleRoot));
|
|
16535
16903
|
if (swiftFrameworkSlotKey(slot) !== frameworkKey) {
|
|
16536
|
-
|
|
16904
|
+
rmSync7(path27.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
|
|
16537
16905
|
const moduleRestructured = mirrorTree2(moduleRoot, stagedModule, ".build");
|
|
16538
16906
|
const sdkRestructured = mirrorTree2(
|
|
16539
16907
|
swiftSharedSdkRoot(moduleRoot, false),
|
|
16540
16908
|
path27.join(staged, "packages/peachsim/sdk/ios")
|
|
16541
16909
|
);
|
|
16542
16910
|
if (moduleRestructured || sdkRestructured) {
|
|
16543
|
-
|
|
16544
|
-
|
|
16911
|
+
rmSync7(path27.join(slot, "release.yaml"), { force: true });
|
|
16912
|
+
rmSync7(path27.join(slot, "release", "description.json"), { force: true });
|
|
16545
16913
|
}
|
|
16546
16914
|
for (const file of swiftModuleInputFiles(moduleRoot)) {
|
|
16547
16915
|
if (!file.startsWith("../")) continue;
|
|
16548
16916
|
const from = path27.resolve(moduleRoot, file);
|
|
16549
16917
|
const to = path27.resolve(stagedModule, file);
|
|
16550
|
-
if (existsSync5(to) &&
|
|
16551
|
-
|
|
16918
|
+
if (existsSync5(to) && readFileSync17(from).equals(readFileSync17(to))) continue;
|
|
16919
|
+
mkdirSync7(path27.dirname(to), { recursive: true });
|
|
16552
16920
|
copyFileSync(from, to);
|
|
16553
16921
|
}
|
|
16554
16922
|
if (swiftProjectBuildKey(stagedModule, release) !== frameworkKey)
|
|
@@ -16556,11 +16924,11 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
|
16556
16924
|
const modules = path27.join(staged, "node_modules");
|
|
16557
16925
|
const target = realpathSync5(path27.join(moduleRoot, "../../node_modules"));
|
|
16558
16926
|
if (!existsSync5(modules) || readlinkSync(modules) !== target) {
|
|
16559
|
-
|
|
16927
|
+
rmSync7(modules, { recursive: true, force: true });
|
|
16560
16928
|
symlinkSync2(target, modules);
|
|
16561
16929
|
}
|
|
16562
|
-
|
|
16563
|
-
|
|
16930
|
+
writeFileSync8(path27.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
|
|
16931
|
+
writeFileSync8(path27.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
|
|
16564
16932
|
}
|
|
16565
16933
|
return stagedModule;
|
|
16566
16934
|
}
|
|
@@ -16605,15 +16973,15 @@ function retireStaleSwiftLink(root, stamp) {
|
|
|
16605
16973
|
const receipt = path27.join(root, SWIFT_LINK_STAMP);
|
|
16606
16974
|
let previous = null;
|
|
16607
16975
|
try {
|
|
16608
|
-
previous =
|
|
16976
|
+
previous = readFileSync17(receipt, "utf8").trim();
|
|
16609
16977
|
} catch (error) {
|
|
16610
16978
|
if (!vanished(error)) throw error;
|
|
16611
16979
|
}
|
|
16612
|
-
|
|
16980
|
+
writeFileSync8(receipt, `${stamp}
|
|
16613
16981
|
`);
|
|
16614
16982
|
const retired = path27.join(root, ".build");
|
|
16615
16983
|
if (previous === stamp || !existsSync5(retired)) return false;
|
|
16616
|
-
|
|
16984
|
+
rmSync7(retired, { recursive: true, force: true });
|
|
16617
16985
|
return true;
|
|
16618
16986
|
}
|
|
16619
16987
|
async function compileSwiftProjectUnit(input, options) {
|
|
@@ -16628,7 +16996,7 @@ async function compileSwiftProjectUnit(input, options) {
|
|
|
16628
16996
|
}
|
|
16629
16997
|
function compileSwiftProjectOnce(input, options) {
|
|
16630
16998
|
options.signal?.throwIfAborted();
|
|
16631
|
-
|
|
16999
|
+
mkdirSync7(options.buildRoot, { recursive: true });
|
|
16632
17000
|
const root = realpathSync5(options.buildRoot);
|
|
16633
17001
|
const moduleRoot = path27.resolve(options.moduleRoot);
|
|
16634
17002
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
@@ -16667,7 +17035,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
16667
17035
|
const requestRoot = mkdtempSync3(`${root}.builder-request-`);
|
|
16668
17036
|
const output = path27.join(requestRoot, "output");
|
|
16669
17037
|
const request = path27.join(requestRoot, "request.json");
|
|
16670
|
-
|
|
17038
|
+
writeFileSync8(
|
|
16671
17039
|
request,
|
|
16672
17040
|
JSON.stringify({
|
|
16673
17041
|
input,
|
|
@@ -16713,7 +17081,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
16713
17081
|
report("builder artifact verified");
|
|
16714
17082
|
return retain(root, artifact);
|
|
16715
17083
|
} finally {
|
|
16716
|
-
|
|
17084
|
+
rmSync7(requestRoot, { recursive: true, force: true });
|
|
16717
17085
|
}
|
|
16718
17086
|
}
|
|
16719
17087
|
return withSwiftRootLock(
|
|
@@ -16803,17 +17171,18 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
16803
17171
|
existsSync5(productFile) ? [
|
|
16804
17172
|
v5.parse(
|
|
16805
17173
|
swiftFrameworkProductSchema,
|
|
16806
|
-
JSON.parse(
|
|
17174
|
+
JSON.parse(readFileSync17(productFile, "utf8"))
|
|
16807
17175
|
).product.name
|
|
16808
17176
|
] : []
|
|
16809
17177
|
);
|
|
16810
17178
|
const projectProcess = options.project ? prepareSwiftProjectProcess(root, options.project) : void 0;
|
|
17179
|
+
const compiler = preparation.targetToolset ? { CC: path27.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
|
|
16811
17180
|
const appOptions = projectProcess ? {
|
|
16812
17181
|
...buildOptions,
|
|
16813
17182
|
uid: projectProcess.uid,
|
|
16814
17183
|
gid: projectProcess.gid,
|
|
16815
|
-
confined: projectProcess.env
|
|
16816
|
-
} : buildOptions;
|
|
17184
|
+
confined: { ...projectProcess.env, ...compiler }
|
|
17185
|
+
} : { ...buildOptions, env: { ...buildOptions.env, ...compiler } };
|
|
16817
17186
|
const unprepared = preparation.targetFailures.map(
|
|
16818
17187
|
(failure) => `error: target ${failure}`
|
|
16819
17188
|
);
|
|
@@ -16843,6 +17212,9 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
16843
17212
|
...preparation.targetToolset ? ["--toolset", path27.join(root, ".peach-target-toolset.json")] : [],
|
|
16844
17213
|
"-c",
|
|
16845
17214
|
"release",
|
|
17215
|
+
// the link strips debug info, so none is generated (as for the framework)
|
|
17216
|
+
"-Xswiftc",
|
|
17217
|
+
"-gnone",
|
|
16846
17218
|
"-Xswiftc",
|
|
16847
17219
|
"-num-threads",
|
|
16848
17220
|
"-Xswiftc",
|
|
@@ -16872,9 +17244,9 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
16872
17244
|
])
|
|
16873
17245
|
];
|
|
16874
17246
|
const linked = builtArtifact(layout2);
|
|
16875
|
-
|
|
17247
|
+
rmSync7(path27.join(root, ".peach-link.rsp"), { force: true });
|
|
16876
17248
|
if (existsSync5(linked) && statSync2(linked).size <= 8)
|
|
16877
|
-
|
|
17249
|
+
rmSync7(linked, { force: true });
|
|
16878
17250
|
report("compiling and linking Swift modules");
|
|
16879
17251
|
try {
|
|
16880
17252
|
const headerBuilds = preparation.headerProductTarget ? [
|
|
@@ -16903,7 +17275,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
16903
17275
|
writeBuildFile(
|
|
16904
17276
|
emitted,
|
|
16905
17277
|
withoutSwiftDeclarations(
|
|
16906
|
-
clangInterfaceHeader(
|
|
17278
|
+
clangInterfaceHeader(readFileSync17(original, "utf8")),
|
|
16907
17279
|
new Set(preparation.nativeHeaderDeclarations[producer]),
|
|
16908
17280
|
`#import <${producer}/${producer}.h>`
|
|
16909
17281
|
)
|
|
@@ -16914,9 +17286,9 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
16914
17286
|
root,
|
|
16915
17287
|
".build",
|
|
16916
17288
|
"peach-native-targets",
|
|
16917
|
-
createHash13("sha256").update(
|
|
17289
|
+
createHash13("sha256").update(readFileSync17(path27.join(root, "Package.swift"))).digest("hex")
|
|
16918
17290
|
);
|
|
16919
|
-
|
|
17291
|
+
mkdirSync7(checkpoints, { recursive: true });
|
|
16920
17292
|
for (const target of /* @__PURE__ */ new Set([
|
|
16921
17293
|
...input.staticClangTargets ?? [],
|
|
16922
17294
|
...preparation.nativeBuildTargets
|
|
@@ -16933,7 +17305,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
16933
17305
|
SWIFTPM_PROGRESS,
|
|
16934
17306
|
SWIFTPM_NOISE
|
|
16935
17307
|
);
|
|
16936
|
-
|
|
17308
|
+
writeFileSync8(checkpoint, "");
|
|
16937
17309
|
}
|
|
16938
17310
|
await runCompiler(
|
|
16939
17311
|
swift,
|
|
@@ -16952,7 +17324,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
16952
17324
|
"ModuleCache"
|
|
16953
17325
|
);
|
|
16954
17326
|
if (output2.includes("was compiled with module cache path") && existsSync5(moduleCache)) {
|
|
16955
|
-
|
|
17327
|
+
rmSync7(moduleCache, { recursive: true, force: true });
|
|
16956
17328
|
try {
|
|
16957
17329
|
await runCompiler(
|
|
16958
17330
|
swift,
|
|
@@ -17020,16 +17392,15 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
17020
17392
|
output,
|
|
17021
17393
|
optimized
|
|
17022
17394
|
});
|
|
17023
|
-
else
|
|
17024
|
-
const executable = input.optimize ? optimized : output;
|
|
17395
|
+
else await lowerWasm(output, optimized, { optimize: input.optimize === true });
|
|
17025
17396
|
await runCompiler(
|
|
17026
17397
|
path27.join(options.toolchainBin, "llvm-objcopy"),
|
|
17027
|
-
["--remove-section=.swift1_autolink_entries",
|
|
17398
|
+
["--remove-section=.swift1_autolink_entries", optimized],
|
|
17028
17399
|
buildOptions
|
|
17029
17400
|
);
|
|
17030
17401
|
const artifact = {
|
|
17031
17402
|
hash,
|
|
17032
|
-
bytes:
|
|
17403
|
+
bytes: readFileSync17(optimized),
|
|
17033
17404
|
icu: await icu
|
|
17034
17405
|
};
|
|
17035
17406
|
if (artifact.bytes.length <= 8)
|
|
@@ -17103,6 +17474,7 @@ export {
|
|
|
17103
17474
|
swiftTypedApplicationEntry,
|
|
17104
17475
|
syncSwiftTree,
|
|
17105
17476
|
withNativeSourceGlue,
|
|
17477
|
+
withPreconcurrencyFoundationModules,
|
|
17106
17478
|
withoutSwiftDeclarations,
|
|
17107
17479
|
wrapUIApplicationMainEntry,
|
|
17108
17480
|
writeSwiftProject
|