peachsim 0.1.2596 → 0.1.2598
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/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 +2 -2
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +5 -5
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +3 -3
- package/dist-lib/bundle-channel.cjs +969 -423
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +3 -3
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +3 -3
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +2 -2
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +7 -7
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +5 -5
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-WGTQK4JN.mjs → acorn-KBQ33SLR.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-ZVBBDMPW.mjs → chunk-37W5LRA3.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-DY6PUVXF.mjs → chunk-54WIQP6N.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WPX7HLFR.mjs → chunk-B2DVYADK.mjs} +7 -6
- package/dist-lib/esm-chunks/{chunk-SPKD6UYK.mjs → chunk-C4NFHNW5.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-BNXCKF2B.mjs → chunk-CQHPA2VS.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-C3C5OJG4.mjs → chunk-FKSCP3EF.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-4UUWP6NP.mjs → chunk-I7POLNK4.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-SYCOZ2CT.mjs → chunk-IB7EAJUO.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-4MMPS5YL.mjs → chunk-J2DSD5ZC.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-HZPXGVY4.mjs → chunk-J5SU2CGP.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3C2YVQZH.mjs → chunk-J6DI5ND2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-UCIOSXXU.mjs → chunk-NTVANYOL.mjs} +963 -490
- package/dist-lib/esm-chunks/{chunk-FDMS7FWE.mjs → chunk-OQYMCUNM.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-LZF4BVEY.mjs → chunk-PZDQUPFX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BAEOHCN5.mjs → chunk-QPRSUFLC.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-TNZG7SFG.mjs → chunk-SYTFW2W6.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ISZE675P.mjs → chunk-SYWNAT3Z.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-TILPABC4.mjs → chunk-T2I3EXKH.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5NZPSLS4.mjs → chunk-U3X55VHR.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4PMXT2UO.mjs → chunk-UCLJ5PDG.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-QEGUUPRI.mjs → chunk-UKE7QBBD.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-IGMABYTC.mjs → chunk-Z7BYGNNX.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-QNM3HYV7.mjs → metro-layout-parser-SOAXKW5M.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-BXXQB7Q2.mjs → swift-package-prebuilt-KK3VRVOF.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-FKL3X2ZC.mjs → swift-sdk-app-module-TEOC7LDK.mjs} +126 -56
- package/dist-lib/esm-chunks/{swift-sdk-image-CCVWDFHB.mjs → swift-sdk-image-ZBA4EYBW.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-OTMZVBDN.mjs → swift-sdk-image-producer-3VLSKMBD.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +968 -422
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +7 -7
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +969 -423
- package/dist-lib/host/fetch-proxy-handler.cjs +36 -6
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +3 -3
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +3 -3
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +4 -4
- package/dist-lib/native-app-identity-project.cjs +34 -4
- package/dist-lib/native-app-identity-project.mjs +16 -16
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +6 -6
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +3 -3
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +2 -2
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +3 -3
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +81 -81
- package/dist-lib/public-origins-lib.json +69 -69
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +2 -2
- 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 +8 -8
- package/dist-lib/skills.cjs +970 -424
- package/dist-lib/swift-compile.cjs +966 -420
- package/dist-lib/swift-compile.mjs +10 -10
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +3 -3
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +6 -6
- package/dist-lib/swift-svg-raster.cjs +1 -1
- package/dist-lib/swift-svg-raster.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
- package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
- package/dist-lib/vendor/acorn.cjs +1 -1
- package/dist-lib/vendor/bplist-parser.cjs +1 -1
- package/dist-lib/vendor/ignore.cjs +1 -1
- package/dist-lib/vendor/magic-string.cjs +1 -1
- package/dist-lib/vendor/plist.cjs +1 -1
- package/dist-lib/vendor/smol-toml.cjs +1 -1
- package/dist-lib/vendor/stream-json.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
- package/dist-lib/vendor/sucrase.cjs +1 -1
- package/dist-lib/vendor/terser.cjs +1 -1
- package/dist-lib/vendor/valibot.cjs +1 -1
- package/dist-lib/vendor/ws.cjs +1 -1
- package/dist-lib/vendor/zod.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +3 -3
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/native-hot-ops.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/nativeAnimMirrorContract.d.ts +0 -2
- package/package.json +1 -1
- package/src/swift-compile.ts +421 -175
- package/src/swift-guest-compile.ts +16 -0
- package/src/swift-guest-image-ledger.ts +65 -14
- package/src/swift-guest-link.ts +21 -0
- package/src/swift-guest-manifest.ts +27 -5
- package/src/swift-guest-source-inputs.ts +119 -14
- package/src/swift-sdk-app-module.ts +128 -55
- package/src/swift-sdk-image-wasm.ts +76 -39
- package/src/swift-sdk-image.ts +2 -1
- package/src/swift-wasm-prune.ts +282 -222
- package/src/wasm-optimize.ts +1 -1
- package/src/write-build-file.ts +9 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2598 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
import {
|
|
3
3
|
SWIFT_AUTOLINK_LINKER,
|
|
4
4
|
SWIFT_CACHE_HOLD_MARKER,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
windowAdmission,
|
|
22
22
|
withSwiftRootLock,
|
|
23
23
|
writeSwiftAutolinkLinker
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-J6DI5ND2.mjs";
|
|
25
25
|
import {
|
|
26
26
|
SWIFT_BINARY_TREES_DIR,
|
|
27
27
|
SWIFT_NATIVE_INPUT_ROOT,
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
isSwiftResourcePath,
|
|
37
37
|
isSwiftSourceLinkGraph,
|
|
38
38
|
swiftProjectFilesProblems
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-37W5LRA3.mjs";
|
|
40
40
|
import {
|
|
41
41
|
OBJC_RESOURCE_ACCESSOR_BODY,
|
|
42
42
|
OBJC_RESOURCE_ACCESSOR_HEADER,
|
|
@@ -60,16 +60,16 @@ import {
|
|
|
60
60
|
swiftPackagePartition,
|
|
61
61
|
swiftTargetModuleName,
|
|
62
62
|
withoutGlogModuleMap
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-54WIQP6N.mjs";
|
|
64
64
|
import {
|
|
65
65
|
rnxPublicBrand
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-Z7BYGNNX.mjs";
|
|
67
67
|
import {
|
|
68
68
|
isRecord
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-T2I3EXKH.mjs";
|
|
70
70
|
import {
|
|
71
71
|
__publicField
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-QPRSUFLC.mjs";
|
|
73
73
|
|
|
74
74
|
// src/swift-compile.ts
|
|
75
75
|
import {
|
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
chmodSync as chmodSync3,
|
|
83
83
|
copyFileSync as copyFileSync2,
|
|
84
84
|
cpSync,
|
|
85
|
-
existsSync as
|
|
85
|
+
existsSync as existsSync9,
|
|
86
86
|
lstatSync,
|
|
87
87
|
mkdirSync as mkdirSync8,
|
|
88
88
|
mkdtempSync as mkdtempSync4,
|
|
@@ -92,7 +92,7 @@ import {
|
|
|
92
92
|
realpathSync as realpathSync6,
|
|
93
93
|
renameSync as renameSync5,
|
|
94
94
|
rmSync as rmSync7,
|
|
95
|
-
statSync as
|
|
95
|
+
statSync as statSync5,
|
|
96
96
|
symlinkSync as symlinkSync2,
|
|
97
97
|
utimesSync,
|
|
98
98
|
writeFileSync as writeFileSync8
|
|
@@ -2885,11 +2885,17 @@ import fs from "node:fs";
|
|
|
2885
2885
|
import path6 from "node:path";
|
|
2886
2886
|
|
|
2887
2887
|
// src/write-build-file.ts
|
|
2888
|
-
import {
|
|
2888
|
+
import { mkdirSync, readFileSync as readFileSync4, statSync, writeFileSync } from "node:fs";
|
|
2889
2889
|
import path5 from "node:path";
|
|
2890
2890
|
function writeBuildFile(file, contents2) {
|
|
2891
|
-
|
|
2892
|
-
|
|
2891
|
+
const stat = statSync(file, { throwIfNoEntry: false });
|
|
2892
|
+
if (stat?.isFile()) {
|
|
2893
|
+
if (typeof contents2 === "string") {
|
|
2894
|
+
if (readFileSync4(file, "utf8") === contents2) return;
|
|
2895
|
+
} else if (stat.size === contents2.length && readFileSync4(file).equals(contents2)) {
|
|
2896
|
+
return;
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2893
2899
|
mkdirSync(path5.dirname(file), { recursive: true });
|
|
2894
2900
|
writeFileSync(file, contents2);
|
|
2895
2901
|
}
|
|
@@ -4026,7 +4032,7 @@ import { randomUUID as randomUUID2 } from "node:crypto";
|
|
|
4026
4032
|
import {
|
|
4027
4033
|
constants,
|
|
4028
4034
|
copyFileSync,
|
|
4029
|
-
existsSync
|
|
4035
|
+
existsSync,
|
|
4030
4036
|
mkdirSync as mkdirSync2,
|
|
4031
4037
|
readdirSync as readdirSync4,
|
|
4032
4038
|
readFileSync as readFileSync6,
|
|
@@ -4056,7 +4062,7 @@ function syncSwiftDistributionMirror(root, source, manifest) {
|
|
|
4056
4062
|
for (const file of changed) place(path11.join(source, file), path11.join(mirror, file));
|
|
4057
4063
|
const manifestFile = path11.join(mirror, SWIFT_DISTRIBUTION_MANIFEST);
|
|
4058
4064
|
const manifestBytes = readFileSync6(path11.join(source, SWIFT_DISTRIBUTION_MANIFEST));
|
|
4059
|
-
if (!
|
|
4065
|
+
if (!existsSync(manifestFile) || !readFileSync6(manifestFile).equals(manifestBytes))
|
|
4060
4066
|
place(path11.join(source, SWIFT_DISTRIBUTION_MANIFEST), manifestFile);
|
|
4061
4067
|
if (!previous || changed.length > 0 || removed.length > 0) {
|
|
4062
4068
|
const partial = `${record}.${randomUUID2()}`;
|
|
@@ -4066,7 +4072,7 @@ function syncSwiftDistributionMirror(root, source, manifest) {
|
|
|
4066
4072
|
return mirror;
|
|
4067
4073
|
}
|
|
4068
4074
|
function readRecord(file) {
|
|
4069
|
-
if (!
|
|
4075
|
+
if (!existsSync(file)) return null;
|
|
4070
4076
|
const value = JSON.parse(readFileSync6(file, "utf8"));
|
|
4071
4077
|
if (!isRecord(value)) return null;
|
|
4072
4078
|
const files = {};
|
|
@@ -4107,13 +4113,13 @@ function invalidateDependents(root, mirror, files) {
|
|
|
4107
4113
|
return false;
|
|
4108
4114
|
});
|
|
4109
4115
|
const scratch = path11.join(root, ".build");
|
|
4110
|
-
if (!
|
|
4116
|
+
if (!existsSync(scratch)) return;
|
|
4111
4117
|
const headersChanged = files.some(
|
|
4112
4118
|
(file) => !file.startsWith("lib/") && !file.startsWith("modules/")
|
|
4113
4119
|
);
|
|
4114
4120
|
for (const triple of readdirSync4(scratch, { withFileTypes: true })) {
|
|
4115
4121
|
const products = path11.join(scratch, triple.name, "release");
|
|
4116
|
-
if (!triple.isDirectory() || !
|
|
4122
|
+
if (!triple.isDirectory() || !existsSync(products)) continue;
|
|
4117
4123
|
const modules = path11.join(products, "Modules");
|
|
4118
4124
|
for (const target of readdirSync4(products, { withFileTypes: true })) {
|
|
4119
4125
|
if (!target.isDirectory() || !target.name.endsWith(".build")) continue;
|
|
@@ -4124,7 +4130,7 @@ function invalidateDependents(root, mirror, files) {
|
|
|
4124
4130
|
const dependencies = path11.join(directory, entry);
|
|
4125
4131
|
if (!names(readFileSync6(dependencies))) continue;
|
|
4126
4132
|
const outputMap = path11.join(directory, "output-file-map.json");
|
|
4127
|
-
if (
|
|
4133
|
+
if (existsSync(outputMap)) {
|
|
4128
4134
|
const outputs = JSON.parse(readFileSync6(outputMap, "utf8"));
|
|
4129
4135
|
if (!isRecord(outputs)) throw new Error("invalid SwiftPM output file map");
|
|
4130
4136
|
for (const output of Object.values(outputs)) {
|
|
@@ -6083,11 +6089,21 @@ var ADDEND_RELOCATIONS = /* @__PURE__ */ new Set([
|
|
|
6083
6089
|
25,
|
|
6084
6090
|
27
|
|
6085
6091
|
]);
|
|
6092
|
+
var FUNCTION_RELOC_MASK = 0;
|
|
6093
|
+
for (const type of FUNCTION_RELOCATIONS) FUNCTION_RELOC_MASK |= 1 << type;
|
|
6094
|
+
var MEMORY_RELOC_MASK = 0;
|
|
6095
|
+
for (const type of MEMORY_RELOCATIONS) MEMORY_RELOC_MASK |= 1 << type;
|
|
6096
|
+
var ADDEND_RELOC_MASK = 0;
|
|
6097
|
+
for (const type of ADDEND_RELOCATIONS) ADDEND_RELOC_MASK |= 1 << type;
|
|
6086
6098
|
function relocationEdges(bytes, segmentAddress) {
|
|
6087
6099
|
const sections = wasmSections(bytes);
|
|
6088
6100
|
const linking = sections.find((s) => s.name === "linking");
|
|
6089
6101
|
if (!linking) throw new Error("relocation link has no linking section");
|
|
6090
|
-
|
|
6102
|
+
let symKind = new Uint8Array(0);
|
|
6103
|
+
let symFlags = new Uint32Array(0);
|
|
6104
|
+
let symSegment = new Int32Array(0);
|
|
6105
|
+
let symOffset = new Int32Array(0);
|
|
6106
|
+
let symIndex = new Int32Array(0);
|
|
6091
6107
|
const segmentNames = [];
|
|
6092
6108
|
{
|
|
6093
6109
|
const r = wasmReader(bytes, linking.start);
|
|
@@ -6095,27 +6111,31 @@ function relocationEdges(bytes, segmentAddress) {
|
|
|
6095
6111
|
while (r.at < linking.end) {
|
|
6096
6112
|
const type = r.byte();
|
|
6097
6113
|
const end = r.u() + r.at;
|
|
6098
|
-
if (type === 8)
|
|
6099
|
-
|
|
6114
|
+
if (type === 8) {
|
|
6115
|
+
const count = r.u();
|
|
6116
|
+
symKind = new Uint8Array(count);
|
|
6117
|
+
symFlags = new Uint32Array(count);
|
|
6118
|
+
symSegment = new Int32Array(count).fill(-1);
|
|
6119
|
+
symOffset = new Int32Array(count);
|
|
6120
|
+
symIndex = new Int32Array(count).fill(-1);
|
|
6121
|
+
for (let i = 0; i < count; i++) {
|
|
6100
6122
|
const kind = r.byte();
|
|
6101
6123
|
const flags = r.u();
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
let index = -1;
|
|
6124
|
+
symKind[i] = kind;
|
|
6125
|
+
symFlags[i] = flags;
|
|
6105
6126
|
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
6106
|
-
|
|
6107
|
-
if (!(flags & 16) || flags & 64) r.
|
|
6127
|
+
symIndex[i] = r.u();
|
|
6128
|
+
if (!(flags & 16) || flags & 64) r.skip(r.u());
|
|
6108
6129
|
} else if (kind === 1) {
|
|
6109
|
-
r.
|
|
6130
|
+
r.skip(r.u());
|
|
6110
6131
|
if (!(flags & 16)) {
|
|
6111
|
-
|
|
6112
|
-
|
|
6132
|
+
symSegment[i] = r.u();
|
|
6133
|
+
symOffset[i] = r.u();
|
|
6113
6134
|
r.u();
|
|
6114
6135
|
}
|
|
6115
6136
|
} else if (kind === 3) r.u();
|
|
6116
|
-
symbols.push({ kind, flags, segment, offset, index });
|
|
6117
6137
|
}
|
|
6118
|
-
else if (type === 5)
|
|
6138
|
+
} else if (type === 5)
|
|
6119
6139
|
for (let n = r.u(); n > 0; n--) {
|
|
6120
6140
|
segmentNames.push(r.name());
|
|
6121
6141
|
r.u();
|
|
@@ -6154,37 +6174,66 @@ function relocationEdges(bytes, segmentAddress) {
|
|
|
6154
6174
|
const importedFunctions = readModule(bytes).importedFuncs;
|
|
6155
6175
|
const data = [];
|
|
6156
6176
|
const dataFunctions = [];
|
|
6157
|
-
const
|
|
6158
|
-
const
|
|
6177
|
+
const bodyCount = bodyStarts.length;
|
|
6178
|
+
const code = Array.from({ length: bodyCount }, () => []);
|
|
6179
|
+
const calls = Array.from({ length: bodyCount }, () => []);
|
|
6159
6180
|
for (const s of sections) {
|
|
6160
6181
|
if (!s.name?.startsWith("reloc.")) continue;
|
|
6161
|
-
|
|
6162
|
-
const
|
|
6182
|
+
let cur = s.start;
|
|
6183
|
+
const readU = () => {
|
|
6184
|
+
const b0 = bytes[cur++];
|
|
6185
|
+
if (b0 < 128) return b0;
|
|
6186
|
+
let value = b0 & 127;
|
|
6187
|
+
let shift = 7;
|
|
6188
|
+
for (; ; ) {
|
|
6189
|
+
const byte = bytes[cur++];
|
|
6190
|
+
value += (byte & 127) * 2 ** shift;
|
|
6191
|
+
if (byte < 128) return value;
|
|
6192
|
+
shift += 7;
|
|
6193
|
+
}
|
|
6194
|
+
};
|
|
6195
|
+
const readS = () => {
|
|
6196
|
+
const b0 = bytes[cur++];
|
|
6197
|
+
if (b0 < 128) return b0 & 64 ? b0 - 128 : b0;
|
|
6198
|
+
let value = b0 & 127;
|
|
6199
|
+
let shift = 7;
|
|
6200
|
+
let byte = b0;
|
|
6201
|
+
while (byte >= 128) {
|
|
6202
|
+
byte = bytes[cur++];
|
|
6203
|
+
value += (byte & 127) * 2 ** shift;
|
|
6204
|
+
shift += 7;
|
|
6205
|
+
}
|
|
6206
|
+
if (byte & 64) value -= 2 ** shift;
|
|
6207
|
+
return value;
|
|
6208
|
+
};
|
|
6209
|
+
const target = readU();
|
|
6163
6210
|
if (target !== dataIndex && target !== codeIndex) continue;
|
|
6164
6211
|
let segment = 0;
|
|
6165
6212
|
let body = 0;
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
const
|
|
6169
|
-
const
|
|
6170
|
-
const
|
|
6171
|
-
const
|
|
6172
|
-
const
|
|
6213
|
+
const isData = target === dataIndex;
|
|
6214
|
+
for (let n = readU(); n > 0; n--) {
|
|
6215
|
+
const type = bytes[cur++];
|
|
6216
|
+
const offset = readU();
|
|
6217
|
+
const index = readU();
|
|
6218
|
+
const bit = type < 32 ? 1 << type : 0;
|
|
6219
|
+
const addend = (ADDEND_RELOC_MASK & bit) !== 0 ? readS() : 0;
|
|
6220
|
+
const functionRelocation = (FUNCTION_RELOC_MASK & bit) !== 0;
|
|
6221
|
+
const memoryRelocation = (MEMORY_RELOC_MASK & bit) !== 0;
|
|
6173
6222
|
if (!functionRelocation && !memoryRelocation) continue;
|
|
6174
|
-
|
|
6175
|
-
const
|
|
6176
|
-
|
|
6177
|
-
if (!functionReference && (!memoryRelocation ||
|
|
6223
|
+
if (symFlags[index] & 16) continue;
|
|
6224
|
+
const kind = symKind[index];
|
|
6225
|
+
const functionReference = functionRelocation && kind === 0;
|
|
6226
|
+
if (!functionReference && (!memoryRelocation || kind !== 1 || symSegment[index] < 0))
|
|
6178
6227
|
continue;
|
|
6179
|
-
const to = functionReference ?
|
|
6180
|
-
if (functionReference && (to < 0 || to >=
|
|
6181
|
-
if (
|
|
6228
|
+
const to = functionReference ? symIndex[index] - importedFunctions : addresses[symSegment[index]] + symOffset[index] + addend;
|
|
6229
|
+
if (functionReference && (to < 0 || to >= bodyCount)) continue;
|
|
6230
|
+
if (isData) {
|
|
6182
6231
|
while (payloads[segment].end <= offset) segment++;
|
|
6183
6232
|
const payload = payloads[segment];
|
|
6184
6233
|
const edges = functionReference ? dataFunctions : data;
|
|
6185
6234
|
edges.push(payload.address + offset - payload.start, to);
|
|
6186
6235
|
} else {
|
|
6187
|
-
while (body + 1 <
|
|
6236
|
+
while (body + 1 < bodyCount && bodyStarts[body + 1] <= offset) body++;
|
|
6188
6237
|
const edges = functionReference ? calls : code;
|
|
6189
6238
|
edges[body].push(to);
|
|
6190
6239
|
}
|
|
@@ -6461,8 +6510,11 @@ var NEUTRALIZED_SWIFTRT_SECTIONS = /* @__PURE__ */ new Set([
|
|
|
6461
6510
|
"swift5_reflstr",
|
|
6462
6511
|
"swift5_typeref"
|
|
6463
6512
|
]);
|
|
6513
|
+
var ADDEND_RELOC_MASK2 = 0;
|
|
6514
|
+
for (const type of ADDEND_RELOCATIONS) ADDEND_RELOC_MASK2 |= 1 << type;
|
|
6464
6515
|
function decodeRelocations(buf, sections) {
|
|
6465
|
-
|
|
6516
|
+
let count = 0;
|
|
6517
|
+
for (let s = 0; s < sections.length; s++) count += sections[s].count;
|
|
6466
6518
|
const start = new Uint32Array(count);
|
|
6467
6519
|
const end = new Uint32Array(count);
|
|
6468
6520
|
const ro = new Int32Array(count);
|
|
@@ -6471,29 +6523,59 @@ function decodeRelocations(buf, sections) {
|
|
|
6471
6523
|
const spans = [];
|
|
6472
6524
|
let i = 0;
|
|
6473
6525
|
let length = 0;
|
|
6474
|
-
for (
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6526
|
+
for (let s = 0; s < sections.length; s++) {
|
|
6527
|
+
const section2 = sections[s];
|
|
6528
|
+
const baseAt = section2.at;
|
|
6529
|
+
const sectionCount = section2.count;
|
|
6530
|
+
let cur = baseAt;
|
|
6531
|
+
for (let k = 0; k < sectionCount; k++, i++) {
|
|
6532
|
+
start[i] = length + cur - baseAt;
|
|
6478
6533
|
const rType = buf[cur++];
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6534
|
+
let offset = buf[cur++];
|
|
6535
|
+
if (offset >= 128) {
|
|
6536
|
+
offset &= 127;
|
|
6537
|
+
let shift = 7;
|
|
6538
|
+
while (true) {
|
|
6539
|
+
const byte = buf[cur++];
|
|
6540
|
+
offset |= (byte & 127) << shift;
|
|
6541
|
+
if (byte < 128) break;
|
|
6542
|
+
shift += 7;
|
|
6543
|
+
}
|
|
6544
|
+
}
|
|
6545
|
+
let symbol = buf[cur++];
|
|
6546
|
+
if (symbol >= 128) {
|
|
6547
|
+
symbol &= 127;
|
|
6548
|
+
let shift = 7;
|
|
6549
|
+
while (true) {
|
|
6550
|
+
const byte = buf[cur++];
|
|
6551
|
+
symbol |= (byte & 127) << shift;
|
|
6552
|
+
if (byte < 128) break;
|
|
6553
|
+
shift += 7;
|
|
6554
|
+
}
|
|
6555
|
+
}
|
|
6556
|
+
if (rType < 32 && (ADDEND_RELOC_MASK2 & 1 << rType) !== 0) {
|
|
6557
|
+
let byte = buf[cur++];
|
|
6558
|
+
let value = byte & 127;
|
|
6559
|
+
let shift = 7;
|
|
6560
|
+
while (byte >= 128) {
|
|
6561
|
+
byte = buf[cur++];
|
|
6562
|
+
value |= (byte & 127) << shift;
|
|
6563
|
+
shift += 7;
|
|
6564
|
+
}
|
|
6565
|
+
if (shift < 32 && (byte & 64) !== 0) value |= ~0 << shift;
|
|
6484
6566
|
addend[i] = value;
|
|
6485
|
-
cur = c4;
|
|
6486
6567
|
}
|
|
6487
6568
|
ro[i] = offset;
|
|
6488
6569
|
rs[i] = symbol;
|
|
6489
|
-
end[i] = length + cur -
|
|
6570
|
+
end[i] = length + cur - baseAt;
|
|
6490
6571
|
}
|
|
6491
|
-
spans.push([
|
|
6492
|
-
length += cur -
|
|
6572
|
+
spans.push([baseAt, cur]);
|
|
6573
|
+
length += cur - baseAt;
|
|
6493
6574
|
}
|
|
6494
6575
|
const bytes = new Uint8Array(length);
|
|
6495
6576
|
let at = 0;
|
|
6496
|
-
for (
|
|
6577
|
+
for (let s = 0; s < spans.length; s++) {
|
|
6578
|
+
const [from, to] = spans[s];
|
|
6497
6579
|
bytes.set(buf.subarray(from, to), at);
|
|
6498
6580
|
at += to - from;
|
|
6499
6581
|
}
|
|
@@ -6661,6 +6743,27 @@ function patchSwiftrtObject(src) {
|
|
|
6661
6743
|
function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
6662
6744
|
const rawBuf = Buffer.isBuffer(buf) ? buf : Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
6663
6745
|
let pos = 8;
|
|
6746
|
+
let cur = 8;
|
|
6747
|
+
const readU = () => {
|
|
6748
|
+
const b0 = buf[cur++];
|
|
6749
|
+
if (b0 < 128) return b0;
|
|
6750
|
+
let res = b0 & 127;
|
|
6751
|
+
let shift = 7;
|
|
6752
|
+
while (true) {
|
|
6753
|
+
const byte = buf[cur++];
|
|
6754
|
+
res |= (byte & 127) << shift;
|
|
6755
|
+
if (byte < 128) return res;
|
|
6756
|
+
shift += 7;
|
|
6757
|
+
}
|
|
6758
|
+
};
|
|
6759
|
+
const skipU = () => {
|
|
6760
|
+
while (buf[cur++] >= 128) {
|
|
6761
|
+
}
|
|
6762
|
+
};
|
|
6763
|
+
const skipS = () => {
|
|
6764
|
+
while (buf[cur++] >= 128) {
|
|
6765
|
+
}
|
|
6766
|
+
};
|
|
6664
6767
|
let numImportFuncs = 0;
|
|
6665
6768
|
let importsDlsym = false;
|
|
6666
6769
|
const importFuncNames = [];
|
|
@@ -6689,150 +6792,122 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
6689
6792
|
const dataRelocSections = [];
|
|
6690
6793
|
while (pos < buf.length) {
|
|
6691
6794
|
const id = buf[pos++];
|
|
6692
|
-
|
|
6795
|
+
cur = pos;
|
|
6796
|
+
const sz = readU();
|
|
6797
|
+
const p = cur;
|
|
6693
6798
|
const end = p + sz;
|
|
6694
6799
|
if (id === 2) {
|
|
6695
|
-
|
|
6800
|
+
const cnt = readU();
|
|
6696
6801
|
for (let i = 0; i < cnt; i++) {
|
|
6697
|
-
const
|
|
6698
|
-
const mName = rawBuf.toString("utf8",
|
|
6699
|
-
|
|
6700
|
-
const
|
|
6701
|
-
const fName = rawBuf.toString("utf8",
|
|
6702
|
-
|
|
6703
|
-
const kind = buf[
|
|
6802
|
+
const mLen = readU();
|
|
6803
|
+
const mName = rawBuf.toString("utf8", cur, cur + mLen);
|
|
6804
|
+
cur += mLen;
|
|
6805
|
+
const fLen = readU();
|
|
6806
|
+
const fName = rawBuf.toString("utf8", cur, cur + fLen);
|
|
6807
|
+
cur += fLen;
|
|
6808
|
+
const kind = buf[cur++];
|
|
6704
6809
|
if (kind === 0) {
|
|
6705
|
-
|
|
6706
|
-
cp = c2;
|
|
6810
|
+
skipU();
|
|
6707
6811
|
importFuncNames.push(fName);
|
|
6708
6812
|
importFuncModules.push(mName);
|
|
6709
6813
|
if (mName === "env" && fName === "dlsym") importsDlsym = true;
|
|
6710
6814
|
numImportFuncs++;
|
|
6711
6815
|
} else if (kind === 1) {
|
|
6712
|
-
|
|
6713
|
-
const
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
cp = c3;
|
|
6717
|
-
if (fl & 1) {
|
|
6718
|
-
const [, c4] = readULEB2(buf, cp);
|
|
6719
|
-
cp = c4;
|
|
6720
|
-
}
|
|
6816
|
+
cur++;
|
|
6817
|
+
const fl = readU();
|
|
6818
|
+
skipU();
|
|
6819
|
+
if (fl & 1) skipU();
|
|
6721
6820
|
importTableNames.push(fName);
|
|
6722
6821
|
} else if (kind === 2) {
|
|
6723
|
-
const
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
cp = c3;
|
|
6727
|
-
if (fl & 1) {
|
|
6728
|
-
const [, c4] = readULEB2(buf, cp);
|
|
6729
|
-
cp = c4;
|
|
6730
|
-
}
|
|
6822
|
+
const fl = readU();
|
|
6823
|
+
skipU();
|
|
6824
|
+
if (fl & 1) skipU();
|
|
6731
6825
|
} else if (kind === 3) {
|
|
6732
|
-
|
|
6826
|
+
cur += 2;
|
|
6733
6827
|
importGlobalNames.push(fName);
|
|
6734
6828
|
} else if (kind === 4) {
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
cp = c2;
|
|
6829
|
+
cur++;
|
|
6830
|
+
skipU();
|
|
6738
6831
|
importEventNames.push(fName);
|
|
6739
6832
|
}
|
|
6740
6833
|
}
|
|
6741
6834
|
} else if (id === 10) {
|
|
6742
6835
|
codeStart = p;
|
|
6743
|
-
|
|
6836
|
+
const cnt = readU();
|
|
6744
6837
|
for (let i = 0; i < cnt; i++) {
|
|
6745
|
-
const st =
|
|
6746
|
-
const
|
|
6747
|
-
|
|
6838
|
+
const st = cur - codeStart;
|
|
6839
|
+
const bLen = readU();
|
|
6840
|
+
cur += bLen;
|
|
6748
6841
|
fStarts.push(st);
|
|
6749
|
-
fEnds.push(
|
|
6842
|
+
fEnds.push(cur - codeStart);
|
|
6750
6843
|
}
|
|
6751
6844
|
} else if (id === 11) {
|
|
6752
6845
|
dataStart = p;
|
|
6753
|
-
|
|
6846
|
+
const cnt = readU();
|
|
6754
6847
|
for (let i = 0; i < cnt; i++) {
|
|
6755
|
-
const st =
|
|
6756
|
-
const
|
|
6757
|
-
|
|
6758
|
-
if (mode === 2) {
|
|
6759
|
-
const [, m3] = readULEB2(buf, cp);
|
|
6760
|
-
cp = m3;
|
|
6761
|
-
}
|
|
6848
|
+
const st = cur - dataStart;
|
|
6849
|
+
const mode = readU();
|
|
6850
|
+
if (mode === 2) skipU();
|
|
6762
6851
|
if (mode === 0 || mode === 2) {
|
|
6763
|
-
const op = buf[
|
|
6764
|
-
if (op === 65 || op === 66)
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
} else if (op === 35) {
|
|
6768
|
-
const [, m4] = readULEB2(buf, cp);
|
|
6769
|
-
cp = m4;
|
|
6770
|
-
}
|
|
6771
|
-
cp++;
|
|
6852
|
+
const op = buf[cur++];
|
|
6853
|
+
if (op === 65 || op === 66) skipS();
|
|
6854
|
+
else if (op === 35) skipU();
|
|
6855
|
+
cur++;
|
|
6772
6856
|
}
|
|
6773
|
-
const
|
|
6774
|
-
sPayloadStarts.push(
|
|
6775
|
-
|
|
6857
|
+
const dLen = readU();
|
|
6858
|
+
sPayloadStarts.push(cur - dataStart);
|
|
6859
|
+
cur += dLen;
|
|
6776
6860
|
sStarts.push(st);
|
|
6777
|
-
sEnds.push(
|
|
6861
|
+
sEnds.push(cur - dataStart);
|
|
6778
6862
|
}
|
|
6779
6863
|
} else if (id === 0) {
|
|
6780
|
-
const
|
|
6781
|
-
const name = rawBuf.toString("utf8",
|
|
6782
|
-
|
|
6864
|
+
const nLen = readU();
|
|
6865
|
+
const name = rawBuf.toString("utf8", cur, cur + nLen);
|
|
6866
|
+
cur += nLen;
|
|
6783
6867
|
if (name === "linking") {
|
|
6784
|
-
|
|
6785
|
-
while (
|
|
6786
|
-
const subId = buf[
|
|
6787
|
-
const
|
|
6788
|
-
const subEnd =
|
|
6868
|
+
skipU();
|
|
6869
|
+
while (cur < end) {
|
|
6870
|
+
const subId = buf[cur++];
|
|
6871
|
+
const subLen = readU();
|
|
6872
|
+
const subEnd = cur + subLen;
|
|
6789
6873
|
if (subId === 5) {
|
|
6790
|
-
const
|
|
6791
|
-
let cur = p2;
|
|
6874
|
+
const cnt = readU();
|
|
6792
6875
|
for (let i = 0; i < cnt; i++) {
|
|
6793
|
-
const
|
|
6794
|
-
segNames.push(rawBuf.toString("utf8",
|
|
6795
|
-
cur
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
segFlags.push(fl);
|
|
6799
|
-
cur = s4;
|
|
6876
|
+
const sLen = readU();
|
|
6877
|
+
segNames.push(rawBuf.toString("utf8", cur, cur + sLen));
|
|
6878
|
+
cur += sLen;
|
|
6879
|
+
skipU();
|
|
6880
|
+
segFlags.push(readU());
|
|
6800
6881
|
}
|
|
6801
6882
|
} else if (subId === 6) {
|
|
6802
|
-
const
|
|
6803
|
-
let cur = p2;
|
|
6883
|
+
const cnt = readU();
|
|
6804
6884
|
for (let i = 0; i < cnt; i++) {
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
initFuncs.push(symIdx);
|
|
6808
|
-
cur = s3;
|
|
6885
|
+
skipU();
|
|
6886
|
+
initFuncs.push(readU());
|
|
6809
6887
|
}
|
|
6810
6888
|
} else if (subId === 8) {
|
|
6811
|
-
const
|
|
6889
|
+
const cnt = readU();
|
|
6812
6890
|
symKind = new Uint8Array(cnt);
|
|
6813
6891
|
symFlags = new Uint32Array(cnt);
|
|
6814
6892
|
symElemIdx = new Int32Array(cnt).fill(-1);
|
|
6815
|
-
symOff = new Int32Array(cnt)
|
|
6816
|
-
symSz = new Int32Array(cnt)
|
|
6817
|
-
let cur = p2;
|
|
6893
|
+
symOff = new Int32Array(cnt);
|
|
6894
|
+
symSz = new Int32Array(cnt);
|
|
6818
6895
|
for (let i = 0; i < cnt; i++) {
|
|
6819
6896
|
const kind = buf[cur++];
|
|
6820
6897
|
if (symbolFlagOffsets) symbolFlagOffsets[i] = cur;
|
|
6821
|
-
const
|
|
6822
|
-
cur = c2;
|
|
6898
|
+
const fl = readU();
|
|
6823
6899
|
symKind[i] = kind;
|
|
6824
6900
|
symFlags[i] = fl;
|
|
6825
6901
|
const isUndef = (fl & 16) !== 0;
|
|
6826
6902
|
const isExplicitName = (fl & 64) !== 0;
|
|
6827
6903
|
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
6828
|
-
const
|
|
6829
|
-
cur = c3;
|
|
6904
|
+
const el = readU();
|
|
6830
6905
|
if (!isUndef && kind === 0) symElemIdx[i] = el;
|
|
6831
6906
|
let sName = "";
|
|
6832
6907
|
if (!isUndef || isExplicitName) {
|
|
6833
|
-
const
|
|
6834
|
-
sName = rawBuf.toString("utf8",
|
|
6835
|
-
cur
|
|
6908
|
+
const sLen = readU();
|
|
6909
|
+
sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
6910
|
+
cur += sLen;
|
|
6836
6911
|
} else if (kind === 0) {
|
|
6837
6912
|
sName = importFuncNames[el] ?? "";
|
|
6838
6913
|
} else if (kind === 2) {
|
|
@@ -6846,33 +6921,28 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
6846
6921
|
hostImportNames.add(sName);
|
|
6847
6922
|
symNames.push(sName);
|
|
6848
6923
|
} else if (kind === 1) {
|
|
6849
|
-
const
|
|
6850
|
-
const sName = rawBuf.toString("utf8",
|
|
6851
|
-
cur
|
|
6924
|
+
const sLen = readU();
|
|
6925
|
+
const sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
6926
|
+
cur += sLen;
|
|
6852
6927
|
if (!isUndef) {
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
cur = c6;
|
|
6857
|
-
symElemIdx[i] = segIdx;
|
|
6858
|
-
symOff[i] = sOff;
|
|
6859
|
-
symSz[i] = sSz;
|
|
6928
|
+
symElemIdx[i] = readU();
|
|
6929
|
+
symOff[i] = readU();
|
|
6930
|
+
symSz[i] = readU();
|
|
6860
6931
|
}
|
|
6861
6932
|
symNames.push(sName);
|
|
6862
6933
|
} else if (kind === 3) {
|
|
6863
|
-
|
|
6864
|
-
cur = c3;
|
|
6934
|
+
skipU();
|
|
6865
6935
|
symNames.push("");
|
|
6866
6936
|
}
|
|
6867
6937
|
}
|
|
6868
6938
|
}
|
|
6869
|
-
|
|
6939
|
+
cur = subEnd;
|
|
6870
6940
|
}
|
|
6871
6941
|
} else if (name === "reloc.CODE" || name === "reloc.DATA") {
|
|
6872
|
-
|
|
6873
|
-
const
|
|
6942
|
+
skipU();
|
|
6943
|
+
const count = readU();
|
|
6874
6944
|
(name === "reloc.DATA" ? dataRelocSections : codeRelocSections).push({
|
|
6875
|
-
at,
|
|
6945
|
+
at: cur,
|
|
6876
6946
|
count
|
|
6877
6947
|
});
|
|
6878
6948
|
}
|
|
@@ -6925,40 +6995,63 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
6925
6995
|
segTopSyms.set(segIdx, dedupTop);
|
|
6926
6996
|
}
|
|
6927
6997
|
}
|
|
6928
|
-
const
|
|
6929
|
-
const
|
|
6998
|
+
const funcCount = fEnds.length;
|
|
6999
|
+
const funcRelocs = Array.from({ length: funcCount }, () => []);
|
|
7000
|
+
const rawCode = decodeRelocations(buf, funcCount > 0 ? codeRelocSections : []);
|
|
6930
7001
|
const codeRelocs = { ...rawCode, funcIdx: new Uint32Array(rawCode.count) };
|
|
7002
|
+
let fCursor = 0;
|
|
7003
|
+
let prevCodeRo = -1;
|
|
6931
7004
|
for (let i = 0; i < codeRelocs.count; i++) {
|
|
6932
7005
|
const ro = codeRelocs.ro[i];
|
|
6933
|
-
let lo
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
7006
|
+
let lo;
|
|
7007
|
+
if (ro >= prevCodeRo) {
|
|
7008
|
+
while (fCursor < funcCount - 1 && fEnds[fCursor] <= ro) fCursor++;
|
|
7009
|
+
lo = fCursor;
|
|
7010
|
+
} else {
|
|
7011
|
+
lo = 0;
|
|
7012
|
+
let hi = funcCount - 1;
|
|
7013
|
+
while (lo < hi) {
|
|
7014
|
+
const mid = lo + hi >> 1;
|
|
7015
|
+
if (fEnds[mid] <= ro) lo = mid + 1;
|
|
7016
|
+
else hi = mid;
|
|
7017
|
+
}
|
|
7018
|
+
fCursor = lo;
|
|
6939
7019
|
}
|
|
7020
|
+
prevCodeRo = ro;
|
|
6940
7021
|
if (codeRelocs.bytes[codeRelocs.start[i]] !== 6)
|
|
6941
7022
|
funcRelocs[lo].push(codeRelocs.rs[i]);
|
|
6942
7023
|
codeRelocs.funcIdx[i] = lo;
|
|
6943
7024
|
}
|
|
6944
|
-
const
|
|
7025
|
+
const segCount = segNames.length;
|
|
7026
|
+
const segRelocs = Array.from({ length: segCount }, () => []);
|
|
6945
7027
|
const symDataRelocs = /* @__PURE__ */ new Map();
|
|
6946
7028
|
const rawData = decodeRelocations(buf, sEnds.length > 0 ? dataRelocSections : []);
|
|
6947
7029
|
const dataSegIdx = new Uint32Array(rawData.count);
|
|
6948
7030
|
const dataOffInSeg = new Int32Array(rawData.count);
|
|
6949
7031
|
const dataOwnerSymIdx = new Int32Array(rawData.count);
|
|
6950
7032
|
let kept = 0;
|
|
7033
|
+
let sCursor = 0;
|
|
7034
|
+
let prevDataRo = -1;
|
|
7035
|
+
const sEndLast = sEnds.length - 1;
|
|
6951
7036
|
for (let i = 0; i < rawData.count; i++) {
|
|
6952
7037
|
const ro = rawData.ro[i];
|
|
6953
7038
|
const rs = rawData.rs[i];
|
|
6954
|
-
let lo
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
7039
|
+
let lo;
|
|
7040
|
+
if (ro >= prevDataRo) {
|
|
7041
|
+
while (sCursor < sEndLast && sEnds[sCursor] <= ro) sCursor++;
|
|
7042
|
+
lo = sCursor;
|
|
7043
|
+
} else {
|
|
7044
|
+
lo = 0;
|
|
7045
|
+
let hi = sEndLast;
|
|
7046
|
+
while (lo < hi) {
|
|
7047
|
+
const mid = lo + hi >> 1;
|
|
7048
|
+
if (sEnds[mid] <= ro) lo = mid + 1;
|
|
7049
|
+
else hi = mid;
|
|
7050
|
+
}
|
|
7051
|
+
sCursor = lo;
|
|
7052
|
+
}
|
|
7053
|
+
prevDataRo = ro;
|
|
7054
|
+
if (lo >= segCount) continue;
|
|
6962
7055
|
const offInSeg = ro - (sPayloadStarts[lo] ?? 0);
|
|
6963
7056
|
let ownerSymIdx = -1;
|
|
6964
7057
|
const topList = segTopSyms.get(lo);
|
|
@@ -7105,74 +7198,78 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
7105
7198
|
const conformanceProtocols = /* @__PURE__ */ new Map();
|
|
7106
7199
|
const objcCategoryTargets = [];
|
|
7107
7200
|
if (isDist) {
|
|
7108
|
-
const relocAt = /* @__PURE__ */ new Map();
|
|
7109
|
-
for (let i = 0; i < dataRelocs.count; i++) {
|
|
7110
|
-
relocAt.set(`${dataRelocs.segIdx[i]}:${dataRelocs.offInSeg[i]}`, {
|
|
7111
|
-
rs: dataRelocs.rs[i],
|
|
7112
|
-
addend: dataRelocs.addend[i]
|
|
7113
|
-
});
|
|
7114
|
-
}
|
|
7115
7201
|
const confSegs = /* @__PURE__ */ new Set();
|
|
7116
7202
|
let hasCatsSeg = false;
|
|
7117
7203
|
for (let i = 0; i < segNames.length; i++) {
|
|
7118
7204
|
if (segNames[i] === "swift5_protocol_conformances") confSegs.add(i);
|
|
7119
7205
|
else if (segNames[i] === "__objc_cats") hasCatsSeg = true;
|
|
7120
7206
|
}
|
|
7121
|
-
if (confSegs.size > 0) {
|
|
7122
|
-
const
|
|
7123
|
-
|
|
7124
|
-
if (symKind[i] === 1 && (symFlags[i] & 16) === 0 && symElemIdx[i] >= 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mp")) {
|
|
7125
|
-
segOffToMpSym.set(`${symElemIdx[i]}:${symOff[i]}`, symNames[i]);
|
|
7126
|
-
}
|
|
7127
|
-
}
|
|
7128
|
-
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
7207
|
+
if (confSegs.size > 0 || hasCatsSeg) {
|
|
7208
|
+
const relocKey = (seg, off) => seg * 4294967296 + (off >>> 0);
|
|
7209
|
+
const relocAt = /* @__PURE__ */ new Map();
|
|
7129
7210
|
for (let i = 0; i < dataRelocs.count; i++) {
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7211
|
+
relocAt.set(relocKey(dataRelocs.segIdx[i], dataRelocs.offInSeg[i]), i);
|
|
7212
|
+
}
|
|
7213
|
+
if (confSegs.size > 0) {
|
|
7214
|
+
const segOffToMpSym = /* @__PURE__ */ new Map();
|
|
7215
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
7216
|
+
if (symKind[i] === 1 && (symFlags[i] & 16) === 0 && symElemIdx[i] >= 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mp")) {
|
|
7217
|
+
segOffToMpSym.set(relocKey(symElemIdx[i], symOff[i]), symNames[i]);
|
|
7218
|
+
}
|
|
7134
7219
|
}
|
|
7135
|
-
const
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
const stripped = raw2.startsWith(".Lgot.") ? raw2.slice(6) : raw2;
|
|
7142
|
-
if (stripped.startsWith("$s") && stripped.endsWith("Mp")) {
|
|
7143
|
-
mp = stripped;
|
|
7144
|
-
} else if (symKind[pr.rs] === 3 || stripped === "") {
|
|
7145
|
-
mp = segOffToMpSym.get(`${mcSeg}:${pr.addend}`) ?? "";
|
|
7220
|
+
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
7221
|
+
for (let i = 0; i < dataRelocs.count; i++) {
|
|
7222
|
+
if (!confSegs.has(dataRelocs.segIdx[i])) continue;
|
|
7223
|
+
const mcIdx = dataRelocs.rs[i];
|
|
7224
|
+
if (symKind[mcIdx] !== 1 || (symFlags[mcIdx] & 16) !== 0 || symElemIdx[mcIdx] < 0) {
|
|
7225
|
+
continue;
|
|
7146
7226
|
}
|
|
7147
|
-
|
|
7148
|
-
const
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7227
|
+
const mcSeg = symElemIdx[mcIdx];
|
|
7228
|
+
const mcOff = symOff[mcIdx];
|
|
7229
|
+
const prIdx = relocAt.get(relocKey(mcSeg, mcOff));
|
|
7230
|
+
let mp = "";
|
|
7231
|
+
if (prIdx !== void 0) {
|
|
7232
|
+
const prRs = dataRelocs.rs[prIdx];
|
|
7233
|
+
const raw2 = symNames[prRs];
|
|
7234
|
+
const stripped = raw2.startsWith(".Lgot.") ? raw2.slice(6) : raw2;
|
|
7235
|
+
if (stripped.startsWith("$s") && stripped.endsWith("Mp")) {
|
|
7236
|
+
mp = stripped;
|
|
7237
|
+
} else if (symKind[prRs] === 3 || stripped === "") {
|
|
7238
|
+
mp = segOffToMpSym.get(relocKey(mcSeg, dataRelocs.addend[prIdx])) ?? "";
|
|
7239
|
+
}
|
|
7240
|
+
} else {
|
|
7241
|
+
const fileOff = dataStart + sPayloadStarts[mcSeg] + mcOff;
|
|
7242
|
+
if (fileOff + 4 <= buf.length) {
|
|
7243
|
+
const delta = dv.getInt32(fileOff, true);
|
|
7244
|
+
mp = segOffToMpSym.get(relocKey(mcSeg, mcOff + delta)) ?? segOffToMpSym.get(relocKey(mcSeg, mcOff + (delta & ~1))) ?? "";
|
|
7245
|
+
}
|
|
7152
7246
|
}
|
|
7247
|
+
if (mp) conformanceProtocols.set(mcIdx, mp);
|
|
7153
7248
|
}
|
|
7154
|
-
if (mp) conformanceProtocols.set(mcIdx, mp);
|
|
7155
7249
|
}
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7250
|
+
if (hasCatsSeg) {
|
|
7251
|
+
const seenClasses = /* @__PURE__ */ new Set();
|
|
7252
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
7253
|
+
if (symKind[i] !== 1 || (symFlags[i] & 16) !== 0 || symElemIdx[i] < 0 || segNames[symElemIdx[i]] !== "__objc_cats" || !symNames[i].startsWith(".objc_category_")) {
|
|
7254
|
+
continue;
|
|
7255
|
+
}
|
|
7256
|
+
const cSeg = symElemIdx[i];
|
|
7257
|
+
const cOff = symOff[i];
|
|
7258
|
+
const crIdx = relocAt.get(relocKey(cSeg, cOff + 8));
|
|
7259
|
+
if (crIdx !== void 0) {
|
|
7260
|
+
const crRs = dataRelocs.rs[crIdx];
|
|
7261
|
+
if (symKind[crRs] === 1 && (symFlags[crRs] & 16) === 0 && symElemIdx[crRs] >= 0) {
|
|
7262
|
+
const tSeg = symElemIdx[crRs];
|
|
7263
|
+
const strOff = dataStart + sPayloadStarts[tSeg] + symOff[crRs] + dataRelocs.addend[crIdx];
|
|
7264
|
+
let sEnd = strOff;
|
|
7265
|
+
while (sEnd < buf.length && buf[sEnd] !== 0) sEnd++;
|
|
7266
|
+
if (sEnd > strOff) {
|
|
7267
|
+
const clsName = rawBuf.toString("utf8", strOff, sEnd);
|
|
7268
|
+
if (!seenClasses.has(clsName)) {
|
|
7269
|
+
seenClasses.add(clsName);
|
|
7270
|
+
objcCategoryTargets.push(clsName);
|
|
7271
|
+
}
|
|
7272
|
+
}
|
|
7176
7273
|
}
|
|
7177
7274
|
}
|
|
7178
7275
|
}
|
|
@@ -8382,7 +8479,9 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
8382
8479
|
return true;
|
|
8383
8480
|
};
|
|
8384
8481
|
const writePrunedObject = (obj, outFile) => {
|
|
8385
|
-
const
|
|
8482
|
+
const cached = objectBytes.get(obj);
|
|
8483
|
+
const buf = cached ? new Uint8Array(cached) : new Uint8Array(fs5.readFileSync(obj.file));
|
|
8484
|
+
const rawBuf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
8386
8485
|
const inputSha256 = link ? createHash5("sha256").update(buf).digest("hex") : "";
|
|
8387
8486
|
const fLive = liveFuncs.get(obj);
|
|
8388
8487
|
const sLive = liveSegs.get(obj);
|
|
@@ -8474,7 +8573,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
8474
8573
|
const end = p + sz;
|
|
8475
8574
|
if (id === 0) {
|
|
8476
8575
|
const [nLen, np] = readULEB2(buf, p);
|
|
8477
|
-
const name =
|
|
8576
|
+
const name = rawBuf.toString("utf8", np, np + nLen);
|
|
8478
8577
|
const cp = np + nLen;
|
|
8479
8578
|
if (name === "linking") {
|
|
8480
8579
|
const [, lpStart] = readULEB2(buf, cp);
|
|
@@ -9211,7 +9310,7 @@ var TABLE_INDEX_RELOCATIONS = /* @__PURE__ */ new Set([1, 2, 12, 18, 19, 24]);
|
|
|
9211
9310
|
function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLookups, preserveCanonical, options = {}) {
|
|
9212
9311
|
if (!isWasmMagic(bytes)) throw new Error("expected wasm object");
|
|
9213
9312
|
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
9214
|
-
const { sdkLookupOnly, sdkProduct } = options;
|
|
9313
|
+
const { sdkLookupOnly, sdkProduct, collectRewrittenSymbols } = options;
|
|
9215
9314
|
const comdatScope = sdkProduct === void 0 ? callerAlias : `${callerAlias}:${sdkProduct}`;
|
|
9216
9315
|
const rewrite = binding !== void 0;
|
|
9217
9316
|
const sections = rewrite ? [bytes.subarray(0, 8)] : void 0;
|
|
@@ -9220,6 +9319,9 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
9220
9319
|
const definitions = [];
|
|
9221
9320
|
const functionImports = /* @__PURE__ */ new Map();
|
|
9222
9321
|
const functionImportNames = [];
|
|
9322
|
+
const tableImportNames = [];
|
|
9323
|
+
const globalImportNames = [];
|
|
9324
|
+
const eventImportNames = [];
|
|
9223
9325
|
const functionSymbols = [];
|
|
9224
9326
|
const addressTaken = /* @__PURE__ */ new Set();
|
|
9225
9327
|
let usesDlsym = false;
|
|
@@ -9341,12 +9443,18 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
9341
9443
|
if (isDlsym) usesDlsym = true;
|
|
9342
9444
|
if (isDlerror) usesDlerror = true;
|
|
9343
9445
|
if (importWriter && binding) {
|
|
9446
|
+
const rewrittenName = isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module === "env" && name !== "dlsym" && name !== "dlerror" ? binding(name) ?? name : name;
|
|
9344
9447
|
importWriter.string(module);
|
|
9345
|
-
importWriter.string(
|
|
9346
|
-
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module === "env" && name !== "dlsym" && name !== "dlerror" ? binding(name) ?? name : name
|
|
9347
|
-
);
|
|
9448
|
+
importWriter.string(rewrittenName);
|
|
9348
9449
|
importWriter.byte(kind);
|
|
9349
9450
|
importWriter.bytes(bytes, typeStart, offset);
|
|
9451
|
+
if (collectRewrittenSymbols) {
|
|
9452
|
+
if (kind === 0)
|
|
9453
|
+
functionImportNames[functionImportNames.length - 1] = rewrittenName;
|
|
9454
|
+
else if (kind === 1) tableImportNames.push(rewrittenName);
|
|
9455
|
+
else if (kind === 3) globalImportNames.push(rewrittenName);
|
|
9456
|
+
else if (kind === 4) eventImportNames.push(rewrittenName);
|
|
9457
|
+
}
|
|
9350
9458
|
}
|
|
9351
9459
|
}
|
|
9352
9460
|
if (offset !== end) throw new Error("invalid wasm import section");
|
|
@@ -9429,13 +9537,17 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
9429
9537
|
if (!rewrite && flags & 16 && symbolKind === 1 && alias)
|
|
9430
9538
|
usedSymbols.add(name);
|
|
9431
9539
|
if (entryWriter && binding) {
|
|
9540
|
+
let rewrittenSym = name;
|
|
9541
|
+
let addedCanonical;
|
|
9432
9542
|
if ((name === "dlsym" && usesDlsym || name === "dlerror" && usesDlerror) && flags & 16 && flags & 64 && symbolKind === 0) {
|
|
9543
|
+
rewrittenSym = name === "dlsym" ? callerAlias : dlerrorAlias;
|
|
9433
9544
|
entryWriter.bytes(bytes, begin, nameStart);
|
|
9434
|
-
entryWriter.string(
|
|
9545
|
+
entryWriter.string(rewrittenSym);
|
|
9435
9546
|
entryWriter.bytes(bytes, nameEnd, offset);
|
|
9436
9547
|
} else if (flags & 16 && name !== "dlsym" && name !== "dlerror" && binding(name) !== void 0) {
|
|
9548
|
+
rewrittenSym = binding(name);
|
|
9437
9549
|
entryWriter.bytes(bytes, begin, nameStart);
|
|
9438
|
-
entryWriter.string(
|
|
9550
|
+
entryWriter.string(rewrittenSym);
|
|
9439
9551
|
entryWriter.bytes(bytes, nameEnd, offset);
|
|
9440
9552
|
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
9441
9553
|
if (symbolKind !== 0 && symbolKind !== 1)
|
|
@@ -9449,7 +9561,9 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
9449
9561
|
extraWriter.string(alias);
|
|
9450
9562
|
extraWriter.bytes(bytes, nameEnd, offset);
|
|
9451
9563
|
added++;
|
|
9564
|
+
addedCanonical = alias;
|
|
9452
9565
|
} else {
|
|
9566
|
+
rewrittenSym = alias;
|
|
9453
9567
|
entryWriter.bytes(bytes, begin, nameStart);
|
|
9454
9568
|
entryWriter.string(alias);
|
|
9455
9569
|
entryWriter.bytes(bytes, nameEnd, offset);
|
|
@@ -9457,6 +9571,16 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
9457
9571
|
} else {
|
|
9458
9572
|
entryWriter.bytes(bytes, begin, offset);
|
|
9459
9573
|
}
|
|
9574
|
+
if (collectRewrittenSymbols) {
|
|
9575
|
+
if (flags & 16) {
|
|
9576
|
+
const resolved = flags & 64 || symbolKind === 1 ? rewrittenSym : symbolKind === 0 ? functionImportNames[index] ?? "" : symbolKind === 2 ? globalImportNames[index] ?? "" : symbolKind === 4 ? eventImportNames[index] ?? "" : symbolKind === 5 ? tableImportNames[index] ?? "" : "";
|
|
9577
|
+
if (resolved) collectRewrittenSymbols.referenced.add(resolved);
|
|
9578
|
+
} else if ((flags & 3) !== 2) {
|
|
9579
|
+
if (rewrittenSym) collectRewrittenSymbols.defined.add(rewrittenSym);
|
|
9580
|
+
if (addedCanonical)
|
|
9581
|
+
collectRewrittenSymbols.defined.add(addedCanonical);
|
|
9582
|
+
}
|
|
9583
|
+
}
|
|
9460
9584
|
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
9461
9585
|
if (symbolKind !== 0 && symbolKind !== 1)
|
|
9462
9586
|
throw new Error(`unsupported symbol ${name}`);
|
|
@@ -9820,6 +9944,7 @@ function createGuestImageLedger(input) {
|
|
|
9820
9944
|
sdkGlobalBindings.set(name, first.alias);
|
|
9821
9945
|
}
|
|
9822
9946
|
}
|
|
9947
|
+
const appSymbols = input.registerAppTables ? { referenced: /* @__PURE__ */ new Set(), defined: /* @__PURE__ */ new Set() } : void 0;
|
|
9823
9948
|
const objects = units.map(({ image, object: object2, aliases, functionImports }) => {
|
|
9824
9949
|
const shared = sharedLookupByImage.get(image);
|
|
9825
9950
|
const own = startup.get(object2.path);
|
|
@@ -9854,7 +9979,10 @@ function createGuestImageLedger(input) {
|
|
|
9854
9979
|
binding,
|
|
9855
9980
|
object2.instrumentDynamicLookups,
|
|
9856
9981
|
preserveCanonical,
|
|
9857
|
-
{
|
|
9982
|
+
{
|
|
9983
|
+
sdkProduct: object2.sdkProduct,
|
|
9984
|
+
collectRewrittenSymbols: object2.sdkProduct === void 0 ? appSymbols : void 0
|
|
9985
|
+
}
|
|
9858
9986
|
).bytes
|
|
9859
9987
|
};
|
|
9860
9988
|
});
|
|
@@ -9975,7 +10103,9 @@ function createGuestImageLedger(input) {
|
|
|
9975
10103
|
llvmIR: render(false, lazy),
|
|
9976
10104
|
lazyFunctions: lazy,
|
|
9977
10105
|
appLLVMIR: appLazy && render(true, appLazy),
|
|
9978
|
-
appLazyFunctions: appLazy
|
|
10106
|
+
appLazyFunctions: appLazy,
|
|
10107
|
+
appReferencedSymbols: appSymbols?.referenced,
|
|
10108
|
+
appDefinedSymbols: appSymbols?.defined
|
|
9979
10109
|
};
|
|
9980
10110
|
}
|
|
9981
10111
|
var GUEST_DYLD_VALUES_SECTION = "peach_dyld_values";
|
|
@@ -10594,6 +10724,27 @@ function selectedGuestManifestInputs(plan, selection, identities, readSelected)
|
|
|
10594
10724
|
}
|
|
10595
10725
|
return images;
|
|
10596
10726
|
}
|
|
10727
|
+
var framedLinkOptionsCache = /* @__PURE__ */ new WeakMap();
|
|
10728
|
+
function framedLinkOptions(options) {
|
|
10729
|
+
const cached = framedLinkOptionsCache.get(options);
|
|
10730
|
+
if (cached) return cached;
|
|
10731
|
+
const parts = new Array(options.length * 2 + 2);
|
|
10732
|
+
const count = Buffer.from(String(options.length), "utf8");
|
|
10733
|
+
const countSize = Buffer.allocUnsafe(8);
|
|
10734
|
+
countSize.writeBigUInt64BE(BigInt(count.byteLength));
|
|
10735
|
+
parts[0] = countSize;
|
|
10736
|
+
parts[1] = count;
|
|
10737
|
+
for (let i = 0; i < options.length; i++) {
|
|
10738
|
+
const encoded = Buffer.from(options[i], "utf8");
|
|
10739
|
+
const size = Buffer.allocUnsafe(8);
|
|
10740
|
+
size.writeBigUInt64BE(BigInt(encoded.byteLength));
|
|
10741
|
+
parts[i * 2 + 2] = size;
|
|
10742
|
+
parts[i * 2 + 3] = encoded;
|
|
10743
|
+
}
|
|
10744
|
+
const framed = Buffer.concat(parts);
|
|
10745
|
+
framedLinkOptionsCache.set(options, framed);
|
|
10746
|
+
return framed;
|
|
10747
|
+
}
|
|
10597
10748
|
function createGuestImageManifest(image) {
|
|
10598
10749
|
const target = {
|
|
10599
10750
|
triple: SWIFT_WASM_TRIPLE,
|
|
@@ -10603,10 +10754,10 @@ function createGuestImageManifest(image) {
|
|
|
10603
10754
|
cpuSubtype: 0
|
|
10604
10755
|
};
|
|
10605
10756
|
const digest = createHash9("sha256");
|
|
10757
|
+
const sizeBuf = Buffer.allocUnsafe(8);
|
|
10606
10758
|
const add = (bytes) => {
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
digest.update(size);
|
|
10759
|
+
sizeBuf.writeBigUInt64BE(BigInt(bytes.byteLength));
|
|
10760
|
+
digest.update(sizeBuf);
|
|
10610
10761
|
digest.update(bytes);
|
|
10611
10762
|
};
|
|
10612
10763
|
const text2 = (value) => add(Buffer.from(value, "utf8"));
|
|
@@ -10623,8 +10774,7 @@ function createGuestImageManifest(image) {
|
|
|
10623
10774
|
`${version2.platform}:${version2.minimum.major}:${version2.minimum.minor}:${version2.minimum.patch}`
|
|
10624
10775
|
);
|
|
10625
10776
|
text2(`${version2.sdk.major}:${version2.sdk.minor}:${version2.sdk.patch}`);
|
|
10626
|
-
|
|
10627
|
-
for (const option of image.linkOptions) text2(option);
|
|
10777
|
+
digest.update(framedLinkOptions(image.linkOptions));
|
|
10628
10778
|
text2(String(image.inputs.length));
|
|
10629
10779
|
for (const input of image.inputs) {
|
|
10630
10780
|
text2(input.identity);
|
|
@@ -11624,7 +11774,7 @@ function guestAliasedSdkArchiveArtifacts(options) {
|
|
|
11624
11774
|
import { execFile } from "node:child_process";
|
|
11625
11775
|
import {
|
|
11626
11776
|
closeSync as closeSync2,
|
|
11627
|
-
existsSync as
|
|
11777
|
+
existsSync as existsSync2,
|
|
11628
11778
|
fstatSync,
|
|
11629
11779
|
openSync as openSync2,
|
|
11630
11780
|
readFileSync as readFileSync10,
|
|
@@ -12003,7 +12153,7 @@ var RELINK_PASSES = [
|
|
|
12003
12153
|
];
|
|
12004
12154
|
var BINARYEN_VERSION = binaryen_lock_default.version;
|
|
12005
12155
|
var runBinaryen = promisify(execFile);
|
|
12006
|
-
var WASM_LOWER_IDENTITY = `binaryen ${BINARYEN_VERSION} narrow ${LOWERING.join(" ")} ${FEATURES.join(",")} shared-stack-check-v2 native-image-v1 table-reserve-v2 ${NATIVE_TABLE_ABI} unoptimized-names`;
|
|
12156
|
+
var WASM_LOWER_IDENTITY = `binaryen ${BINARYEN_VERSION} fused-pipeline-v1 narrow ${LOWERING.join(" ")} ${FEATURES.join(",")} shared-stack-check-v2 native-image-v1 table-reserve-v2 ${NATIVE_TABLE_ABI} unoptimized-names`;
|
|
12007
12157
|
var BINARYEN_RELEASES = new Map(Object.entries(binaryen_lock_default.platforms));
|
|
12008
12158
|
function readWasmMemoryFromFile(file) {
|
|
12009
12159
|
const fd = openSync2(file, "r");
|
|
@@ -12188,7 +12338,7 @@ async function installWasmOpt() {
|
|
|
12188
12338
|
release.sha256
|
|
12189
12339
|
);
|
|
12190
12340
|
const binary = join(destDir, "bin", "wasm-opt");
|
|
12191
|
-
if (!
|
|
12341
|
+
if (!existsSync2(binary))
|
|
12192
12342
|
await installVerifiedTarball({
|
|
12193
12343
|
url: `https://r2.rnxsim.com/peach/binaryen/${release.sha256}/${platform}.tar.zst`,
|
|
12194
12344
|
digest: { algorithm: "sha256", encoding: "hex", value: release.sha256 },
|
|
@@ -12650,6 +12800,7 @@ function linkGuestImages(options) {
|
|
|
12650
12800
|
const ledgerObjects = new Map(ledger.objects.map((item) => [item.path, item]));
|
|
12651
12801
|
const appObjects = /* @__PURE__ */ new Map();
|
|
12652
12802
|
const sdkObjects = /* @__PURE__ */ new Map();
|
|
12803
|
+
const finalArchives = /* @__PURE__ */ new Map();
|
|
12653
12804
|
for (const [index, artifact] of plan.artifacts.entries()) {
|
|
12654
12805
|
const prefix = `${artifact.path}(`;
|
|
12655
12806
|
if (artifact.kind === "object") {
|
|
@@ -12703,6 +12854,10 @@ function linkGuestImages(options) {
|
|
|
12703
12854
|
const response = path20.join(memberDir, "members.rsp");
|
|
12704
12855
|
fs9.writeFileSync(response, inputs.map((input) => JSON.stringify(input)).join(" "));
|
|
12705
12856
|
execFileSync7(llvmAr, ["rcs", output, `@${response}`], { stdio: "pipe" });
|
|
12857
|
+
finalArchives.set(
|
|
12858
|
+
output,
|
|
12859
|
+
members.map((member) => ({ name: member.name, bytes: new Uint8Array(0) }))
|
|
12860
|
+
);
|
|
12706
12861
|
replacements.set(artifact.path, output);
|
|
12707
12862
|
}
|
|
12708
12863
|
const compileLedger = (name, source) => {
|
|
@@ -12834,7 +12989,8 @@ function linkGuestImages(options) {
|
|
|
12834
12989
|
remapGuestLinkPlan(plan, replacements),
|
|
12835
12990
|
finalArgs,
|
|
12836
12991
|
fs9.readFileSync(finalWhy, "utf8"),
|
|
12837
|
-
finalTrace
|
|
12992
|
+
finalTrace,
|
|
12993
|
+
finalArchives
|
|
12838
12994
|
);
|
|
12839
12995
|
const original = new Map([...replacements].map(([before2, after2]) => [after2, before2]));
|
|
12840
12996
|
const key = (item) => JSON.stringify([original.get(item.artifact) ?? item.artifact, item.member]);
|
|
@@ -12867,12 +13023,25 @@ ${changed.join("\n")}`
|
|
|
12867
13023
|
])
|
|
12868
13024
|
);
|
|
12869
13025
|
appObjects.set(appLedgerObject, options.ledgerDataImage);
|
|
13026
|
+
let appReferencedSymbols;
|
|
13027
|
+
let appDefinedSymbols;
|
|
13028
|
+
if (ledger.appReferencedSymbols && ledger.appDefinedSymbols) {
|
|
13029
|
+
const referenced = new Set(ledger.appReferencedSymbols);
|
|
13030
|
+
const defined = new Set(ledger.appDefinedSymbols);
|
|
13031
|
+
const ledgerSyms = guestWasmSymbols(fs9.readFileSync(appLedgerObject));
|
|
13032
|
+
for (const name of ledgerSyms.undefined) referenced.add(name);
|
|
13033
|
+
for (const name of ledgerSyms.defined) defined.add(name);
|
|
13034
|
+
appReferencedSymbols = referenced;
|
|
13035
|
+
appDefinedSymbols = defined;
|
|
13036
|
+
}
|
|
12870
13037
|
options.onSplitInputs({
|
|
12871
13038
|
appObjects,
|
|
12872
13039
|
appSections,
|
|
12873
13040
|
sdkObjects,
|
|
12874
13041
|
lazyFunctions: ledger.appLazyFunctions ?? [],
|
|
12875
|
-
dyldSymbols: ledger.dyldSymbols
|
|
13042
|
+
dyldSymbols: ledger.dyldSymbols,
|
|
13043
|
+
appReferencedSymbols,
|
|
13044
|
+
appDefinedSymbols
|
|
12876
13045
|
});
|
|
12877
13046
|
}
|
|
12878
13047
|
return selected;
|
|
@@ -13512,12 +13681,12 @@ function linkPrunedGuestImages(options) {
|
|
|
13512
13681
|
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
13513
13682
|
import { createHash as createHash12 } from "node:crypto";
|
|
13514
13683
|
import {
|
|
13515
|
-
existsSync as
|
|
13684
|
+
existsSync as existsSync3,
|
|
13516
13685
|
mkdirSync as mkdirSync4,
|
|
13517
13686
|
readFileSync as readFileSync11,
|
|
13518
13687
|
realpathSync as realpathSync2,
|
|
13519
13688
|
renameSync as renameSync3,
|
|
13520
|
-
statSync,
|
|
13689
|
+
statSync as statSync2,
|
|
13521
13690
|
writeFileSync as writeFileSync5
|
|
13522
13691
|
} from "node:fs";
|
|
13523
13692
|
import path21 from "node:path";
|
|
@@ -13601,11 +13770,11 @@ Promise.all(Array.from({ length: jobs }, run))
|
|
|
13601
13770
|
})
|
|
13602
13771
|
`;
|
|
13603
13772
|
function clangProducerStamp(file) {
|
|
13604
|
-
const stat =
|
|
13773
|
+
const stat = statSync2(file, { bigint: true });
|
|
13605
13774
|
return [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(":");
|
|
13606
13775
|
}
|
|
13607
13776
|
function clangBinaryStamp(file) {
|
|
13608
|
-
const stat =
|
|
13777
|
+
const stat = statSync2(file, { bigint: true });
|
|
13609
13778
|
return [file, stat.size, stat.mtimeNs].join(":");
|
|
13610
13779
|
}
|
|
13611
13780
|
function clangWrapperStamp(file) {
|
|
@@ -13653,7 +13822,7 @@ function clangArgsNeedCwd(args) {
|
|
|
13653
13822
|
}
|
|
13654
13823
|
if (includeFlags.has(arg)) {
|
|
13655
13824
|
const value = args[++i] ?? "";
|
|
13656
|
-
if (isRelativePath(value) && (value.includes("/") ||
|
|
13825
|
+
if (isRelativePath(value) && (value.includes("/") || existsSync3(value))) return true;
|
|
13657
13826
|
continue;
|
|
13658
13827
|
}
|
|
13659
13828
|
if (valueFlags.has(arg)) {
|
|
@@ -13667,7 +13836,7 @@ function clangArgsNeedCwd(args) {
|
|
|
13667
13836
|
if (arg.startsWith("-")) {
|
|
13668
13837
|
if (arg.startsWith("-include") && arg.length > 8) {
|
|
13669
13838
|
const value = arg.slice(8);
|
|
13670
|
-
if (isRelativePath(value) && (value.includes("/") ||
|
|
13839
|
+
if (isRelativePath(value) && (value.includes("/") || existsSync3(value)))
|
|
13671
13840
|
return true;
|
|
13672
13841
|
continue;
|
|
13673
13842
|
}
|
|
@@ -13696,7 +13865,7 @@ function validateClangLinkOptions(flags) {
|
|
|
13696
13865
|
}
|
|
13697
13866
|
}
|
|
13698
13867
|
function readClangLinkOptions(file, key) {
|
|
13699
|
-
if (!
|
|
13868
|
+
if (!existsSync3(file)) return;
|
|
13700
13869
|
let receipt;
|
|
13701
13870
|
try {
|
|
13702
13871
|
receipt = JSON.parse(readFileSync11(file, "utf8"));
|
|
@@ -13895,6 +14064,93 @@ function sourceGuestInputIdentities(graph, buildDirectory, objects) {
|
|
|
13895
14064
|
}
|
|
13896
14065
|
return identities;
|
|
13897
14066
|
}
|
|
14067
|
+
function wasmAutolinkEntries(bytes, out) {
|
|
14068
|
+
if (bytes.length < 8) return false;
|
|
14069
|
+
if (bytes[0] === 33 && bytes[1] === 60 && bytes[2] === 97 && bytes[3] === 114 && bytes[4] === 99 && bytes[5] === 104 && bytes[6] === 62 && bytes[7] === 10) {
|
|
14070
|
+
for (const member of readArMembers(bytes)) {
|
|
14071
|
+
if (!wasmAutolinkEntries(member.bytes, out)) return false;
|
|
14072
|
+
}
|
|
14073
|
+
return true;
|
|
14074
|
+
}
|
|
14075
|
+
if (bytes[0] !== 0 || bytes[1] !== 97 || bytes[2] !== 115 || bytes[3] !== 109)
|
|
14076
|
+
return false;
|
|
14077
|
+
const raw2 = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
14078
|
+
let pos = 8;
|
|
14079
|
+
const len = bytes.length;
|
|
14080
|
+
while (pos < len) {
|
|
14081
|
+
const id = bytes[pos++];
|
|
14082
|
+
let sz = bytes[pos++];
|
|
14083
|
+
if (sz >= 128) {
|
|
14084
|
+
sz &= 127;
|
|
14085
|
+
let shift = 7;
|
|
14086
|
+
while (true) {
|
|
14087
|
+
const b = bytes[pos++];
|
|
14088
|
+
sz |= (b & 127) << shift;
|
|
14089
|
+
if (b < 128) break;
|
|
14090
|
+
shift += 7;
|
|
14091
|
+
}
|
|
14092
|
+
}
|
|
14093
|
+
const end = pos + sz;
|
|
14094
|
+
if (id === 0) {
|
|
14095
|
+
let nLen = bytes[pos++];
|
|
14096
|
+
if (nLen >= 128) {
|
|
14097
|
+
nLen &= 127;
|
|
14098
|
+
let shift = 7;
|
|
14099
|
+
while (true) {
|
|
14100
|
+
const b = bytes[pos++];
|
|
14101
|
+
nLen |= (b & 127) << shift;
|
|
14102
|
+
if (b < 128) break;
|
|
14103
|
+
shift += 7;
|
|
14104
|
+
}
|
|
14105
|
+
}
|
|
14106
|
+
if (nLen === 24 && raw2.toString("ascii", pos, pos + 24) === ".swift1_autolink_entries") {
|
|
14107
|
+
const payload = raw2.toString("utf8", pos + 24, end);
|
|
14108
|
+
for (const entry of payload.split("\0")) {
|
|
14109
|
+
const trimmed = entry.trim();
|
|
14110
|
+
if (trimmed.length > 0) out.push(trimmed);
|
|
14111
|
+
}
|
|
14112
|
+
}
|
|
14113
|
+
}
|
|
14114
|
+
pos = end;
|
|
14115
|
+
}
|
|
14116
|
+
return true;
|
|
14117
|
+
}
|
|
14118
|
+
function readAutolinkFlags(objects, toolchainBin, responsePath) {
|
|
14119
|
+
if (!objects.length) return [];
|
|
14120
|
+
const rawFlags = [];
|
|
14121
|
+
for (const file of objects) {
|
|
14122
|
+
if (!wasmAutolinkEntries(readFileSync11(file), rawFlags)) {
|
|
14123
|
+
writeFileSync5(
|
|
14124
|
+
responsePath,
|
|
14125
|
+
objects.map((entry) => JSON.stringify(entry)).join("\n") + "\n"
|
|
14126
|
+
);
|
|
14127
|
+
return execFileSync8(
|
|
14128
|
+
path21.join(toolchainBin, "swift-autolink-extract"),
|
|
14129
|
+
[`@${responsePath}`, "-o", "-"],
|
|
14130
|
+
{ encoding: "utf8" }
|
|
14131
|
+
).split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
14132
|
+
}
|
|
14133
|
+
}
|
|
14134
|
+
const seen = /* @__PURE__ */ new Set();
|
|
14135
|
+
const flags = [];
|
|
14136
|
+
for (let i = 0; i < rawFlags.length; i++) {
|
|
14137
|
+
const flag = rawFlags[i];
|
|
14138
|
+
if ((flag === "-framework" || flag === "-weak_framework" || flag === "-l" || flag === "--library") && i + 1 < rawFlags.length) {
|
|
14139
|
+
const value = rawFlags[++i];
|
|
14140
|
+
const key = `${flag}\0${value}`;
|
|
14141
|
+
if (!seen.has(key)) {
|
|
14142
|
+
seen.add(key);
|
|
14143
|
+
flags.push(flag, value);
|
|
14144
|
+
}
|
|
14145
|
+
continue;
|
|
14146
|
+
}
|
|
14147
|
+
if (!seen.has(flag)) {
|
|
14148
|
+
seen.add(flag);
|
|
14149
|
+
flags.push(flag);
|
|
14150
|
+
}
|
|
14151
|
+
}
|
|
14152
|
+
return flags;
|
|
14153
|
+
}
|
|
13898
14154
|
function sourceGuestRuntimeLinks(options) {
|
|
13899
14155
|
const aliases = /* @__PURE__ */ new Map();
|
|
13900
14156
|
const artifacts = /* @__PURE__ */ new Map();
|
|
@@ -13982,15 +14238,7 @@ function sourceGuestRuntimeLinks(options) {
|
|
|
13982
14238
|
for (const image of options.images) {
|
|
13983
14239
|
if (result.has(image.id)) throw new Error(`duplicate source image ${image.id}`);
|
|
13984
14240
|
const response = path21.join(options.directory, `image-${image.id}-autolink.rsp`);
|
|
13985
|
-
|
|
13986
|
-
response,
|
|
13987
|
-
image.objects.map((file) => JSON.stringify(file)).join("\n") + "\n"
|
|
13988
|
-
);
|
|
13989
|
-
const autolink = image.objects.length ? execFileSync8(
|
|
13990
|
-
path21.join(options.toolchainBin, "swift-autolink-extract"),
|
|
13991
|
-
[`@${response}`, "-o", "-"],
|
|
13992
|
-
{ encoding: "utf8" }
|
|
13993
|
-
).split("\n").map((line) => line.trim()).filter((line) => line.length > 0) : [];
|
|
14241
|
+
const autolink = readAutolinkFlags(image.objects, options.toolchainBin, response);
|
|
13994
14242
|
const links = [];
|
|
13995
14243
|
const requests = [];
|
|
13996
14244
|
const optionGroups = [
|
|
@@ -14084,13 +14332,13 @@ function logicalGuestLinkOptions(args, identities, roots) {
|
|
|
14084
14332
|
import { execFileSync as execFileSync9 } from "node:child_process";
|
|
14085
14333
|
import {
|
|
14086
14334
|
chmodSync,
|
|
14087
|
-
existsSync as
|
|
14335
|
+
existsSync as existsSync4,
|
|
14088
14336
|
mkdirSync as mkdirSync5,
|
|
14089
14337
|
readdirSync as readdirSync5,
|
|
14090
14338
|
readFileSync as readFileSync12,
|
|
14091
14339
|
realpathSync as realpathSync3,
|
|
14092
14340
|
rmSync as rmSync5,
|
|
14093
|
-
statSync as
|
|
14341
|
+
statSync as statSync3
|
|
14094
14342
|
} from "node:fs";
|
|
14095
14343
|
import path22 from "node:path";
|
|
14096
14344
|
function prepareSwiftProjectProcess(root, user) {
|
|
@@ -14132,7 +14380,7 @@ function endSwiftProjectProcesses(user) {
|
|
|
14132
14380
|
function projectOutputFile(root, file, user) {
|
|
14133
14381
|
const real = realpathSync3(file);
|
|
14134
14382
|
const base = realpathSync3(root);
|
|
14135
|
-
const stat =
|
|
14383
|
+
const stat = statSync3(real);
|
|
14136
14384
|
if (!real.startsWith(base + path22.sep) || !stat.isFile() || stat.uid !== user.uid) {
|
|
14137
14385
|
throw new Error(`swift-compile: project output ${file} is not a file of its build`);
|
|
14138
14386
|
}
|
|
@@ -14415,7 +14663,7 @@ async function compileGuestLink(options) {
|
|
|
14415
14663
|
};
|
|
14416
14664
|
const sdk = options.sdkImage;
|
|
14417
14665
|
const sdkCallers = sdk?.sdkInterface.guestCallers;
|
|
14418
|
-
const sdkObjects = sdk ? (await import("./swift-sdk-image-
|
|
14666
|
+
const sdkObjects = sdk ? (await import("./swift-sdk-image-ZBA4EYBW.mjs")).readSwiftSdkManifestIndex(sdk).guestObjects : void 0;
|
|
14419
14667
|
if (sdk && (!sdkCallers || !sdkObjects))
|
|
14420
14668
|
throw new Error("the SDK image has no guest link manifest");
|
|
14421
14669
|
const result = linkPrunedGuestImages({
|
|
@@ -14709,7 +14957,7 @@ async function compileGuestLink(options) {
|
|
|
14709
14957
|
linkSwiftAppModule,
|
|
14710
14958
|
readSwiftSdkUsage,
|
|
14711
14959
|
swiftSdkProjectionSpans
|
|
14712
|
-
} = await import("./swift-sdk-app-module-
|
|
14960
|
+
} = await import("./swift-sdk-app-module-TEOC7LDK.mjs");
|
|
14713
14961
|
const project = options.project;
|
|
14714
14962
|
const work = project ? mkdtempSync2(path24.join(directory, "app-module-")) : path24.join(directory, "app-module");
|
|
14715
14963
|
if (project) chownSync(work, project.uid, project.gid);
|
|
@@ -14752,6 +15000,15 @@ async function compileGuestLink(options) {
|
|
|
14752
15000
|
{ stdio: "pipe" }
|
|
14753
15001
|
);
|
|
14754
15002
|
}
|
|
15003
|
+
let precomputedSymbols;
|
|
15004
|
+
if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
|
|
15005
|
+
const referenced = new Set(splitInputs.appReferencedSymbols);
|
|
15006
|
+
const defined = new Set(splitInputs.appDefinedSymbols);
|
|
15007
|
+
const projSyms = guestWasmSymbols(readFileSync13(projectionObject));
|
|
15008
|
+
for (const name of projSyms.undefined) referenced.add(name);
|
|
15009
|
+
for (const name of projSyms.defined) defined.add(name);
|
|
15010
|
+
precomputedSymbols = { referenced, defined };
|
|
15011
|
+
}
|
|
14755
15012
|
for (; ; ) {
|
|
14756
15013
|
const link = await linkSwiftAppModule({
|
|
14757
15014
|
objects: [...owners.keys()],
|
|
@@ -14763,6 +15020,7 @@ async function compileGuestLink(options) {
|
|
|
14763
15020
|
optimize: options.optimize,
|
|
14764
15021
|
layoutMap,
|
|
14765
15022
|
project,
|
|
15023
|
+
precomputedSymbols,
|
|
14766
15024
|
loweringCache: project ? void 0 : {
|
|
14767
15025
|
file: path24.join(
|
|
14768
15026
|
options.buildDirectory,
|
|
@@ -14872,13 +15130,13 @@ async function compileGuestLink(options) {
|
|
|
14872
15130
|
import { createHash as createHash14 } from "node:crypto";
|
|
14873
15131
|
import {
|
|
14874
15132
|
chmodSync as chmodSync2,
|
|
14875
|
-
existsSync as
|
|
15133
|
+
existsSync as existsSync5,
|
|
14876
15134
|
mkdirSync as mkdirSync7,
|
|
14877
15135
|
mkdtempSync as mkdtempSync3,
|
|
14878
15136
|
readFileSync as readFileSync14,
|
|
14879
15137
|
renameSync as renameSync4,
|
|
14880
15138
|
rmSync as rmSync6,
|
|
14881
|
-
statSync as
|
|
15139
|
+
statSync as statSync4,
|
|
14882
15140
|
writeFileSync as writeFileSync7
|
|
14883
15141
|
} from "node:fs";
|
|
14884
15142
|
import { createServer } from "node:http";
|
|
@@ -14940,12 +15198,12 @@ function compilerCheckpoint(root, recipe, args, header) {
|
|
|
14940
15198
|
for (const flag of args) {
|
|
14941
15199
|
if (!flag.startsWith("@")) continue;
|
|
14942
15200
|
const response = flag.slice(1);
|
|
14943
|
-
if (!path25.isAbsolute(response) || !
|
|
15201
|
+
if (!path25.isAbsolute(response) || !existsSync5(response)) return;
|
|
14944
15202
|
digest.update(readFileSync14(response));
|
|
14945
15203
|
}
|
|
14946
15204
|
for (const file of outputs) {
|
|
14947
15205
|
if (!file.startsWith(path25.join(root, ".build") + path25.sep)) return;
|
|
14948
|
-
const stat =
|
|
15206
|
+
const stat = statSync4(file, { bigint: true, throwIfNoEntry: false });
|
|
14949
15207
|
if (!stat?.isFile() || stat.size === 0n) return;
|
|
14950
15208
|
digest.update(JSON.stringify([file, String(stat.size), String(stat.mtimeNs)]));
|
|
14951
15209
|
}
|
|
@@ -14996,7 +15254,7 @@ async function withSwiftHeaderCompiler(root, toolchainBin, recipe, producers, bu
|
|
|
14996
15254
|
const receipt = path25.join(checkpoints, module);
|
|
14997
15255
|
const fingerprint = compilerCheckpoint(root, recipe, args, producer.header);
|
|
14998
15256
|
if (request.method === "PUT") {
|
|
14999
|
-
if (!fingerprint || !
|
|
15257
|
+
if (!fingerprint || !existsSync5(receipt) || readFileSync14(receipt, "utf8") !== fingerprint) {
|
|
15000
15258
|
response.writeHead(204).end();
|
|
15001
15259
|
return;
|
|
15002
15260
|
}
|
|
@@ -15177,7 +15435,7 @@ function swiftHeaderDependencies(root, files, targets, nativeTargets, producers,
|
|
|
15177
15435
|
// src/swift-icu.ts
|
|
15178
15436
|
import { execFile as execFile2 } from "node:child_process";
|
|
15179
15437
|
import { createHash as createHash15, randomUUID as randomUUID4 } from "node:crypto";
|
|
15180
|
-
import { existsSync as
|
|
15438
|
+
import { existsSync as existsSync6, readFileSync as readFileSync15 } from "node:fs";
|
|
15181
15439
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
15182
15440
|
import os2 from "node:os";
|
|
15183
15441
|
import path27 from "node:path";
|
|
@@ -15317,7 +15575,7 @@ function swiftIcuAsset(toolchainBin, sdk) {
|
|
|
15317
15575
|
}
|
|
15318
15576
|
async function load(toolchainBin, sdk) {
|
|
15319
15577
|
const swift = path27.join(toolchainBin, "swift");
|
|
15320
|
-
if (!
|
|
15578
|
+
if (!existsSync6(swift))
|
|
15321
15579
|
throw new Error(`swift-icu: no swift at ${swift} for the ${sdk} SDK's icu data`);
|
|
15322
15580
|
const { stdout: listed } = await run(swift, ["sdk", "list", ...swiftSdkOptions()], {
|
|
15323
15581
|
env: swiftEnvironment()
|
|
@@ -15406,7 +15664,7 @@ function swiftIcuPacked(icu) {
|
|
|
15406
15664
|
"swift-brotli",
|
|
15407
15665
|
swiftIcuAddress(icu)
|
|
15408
15666
|
);
|
|
15409
|
-
if (
|
|
15667
|
+
if (existsSync6(file)) return readFile(file);
|
|
15410
15668
|
const packed = Buffer.from(
|
|
15411
15669
|
swiftIcuPack(
|
|
15412
15670
|
await inflateGzip(icu.gzip),
|
|
@@ -15698,7 +15956,7 @@ var RNX_INTERNAL_CHILDREN = {
|
|
|
15698
15956
|
|
|
15699
15957
|
// cli/self-invocation.ts
|
|
15700
15958
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
15701
|
-
import { existsSync as
|
|
15959
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
15702
15960
|
import { basename as basename2, dirname as dirname2, isAbsolute, join as join2 } from "node:path";
|
|
15703
15961
|
import { fileURLToPath } from "node:url";
|
|
15704
15962
|
|
|
@@ -15709,7 +15967,7 @@ var IS_STANDALONE = typeof __SOOTSIM_STANDALONE__ !== "undefined" && __SOOTSIM_S
|
|
|
15709
15967
|
function sourceEntryPath() {
|
|
15710
15968
|
try {
|
|
15711
15969
|
const candidate = join2(dirname2(fileURLToPath(import.meta.url)), "bin.ts");
|
|
15712
|
-
return
|
|
15970
|
+
return existsSync7(candidate) ? candidate : null;
|
|
15713
15971
|
} catch {
|
|
15714
15972
|
return null;
|
|
15715
15973
|
}
|
|
@@ -15840,13 +16098,13 @@ function swiftObjCPrebuiltCompiler(clang, root, sysroot, distribution, targets,
|
|
|
15840
16098
|
}
|
|
15841
16099
|
|
|
15842
16100
|
// src/swift-reproducible.ts
|
|
15843
|
-
import { existsSync as
|
|
16101
|
+
import { existsSync as existsSync8, realpathSync as realpathSync5 } from "node:fs";
|
|
15844
16102
|
import os3 from "node:os";
|
|
15845
16103
|
import path30 from "node:path";
|
|
15846
16104
|
function canonicalHomeDir() {
|
|
15847
16105
|
const home = os3.homedir();
|
|
15848
16106
|
const dotPeach = path30.join(home, ".peach");
|
|
15849
|
-
if (
|
|
16107
|
+
if (existsSync8(dotPeach)) {
|
|
15850
16108
|
const realHome = path30.dirname(realpathSync5(dotPeach));
|
|
15851
16109
|
if (home === realHome || home.startsWith(`${realHome}${path30.sep}`)) return realHome;
|
|
15852
16110
|
}
|
|
@@ -16180,7 +16438,48 @@ function swiftBuildJobs() {
|
|
|
16180
16438
|
return Math.min(cores, memoryJobs);
|
|
16181
16439
|
}
|
|
16182
16440
|
function swiftCompilerJobs() {
|
|
16183
|
-
return Math.min(
|
|
16441
|
+
return Math.min(32, swiftBuildJobs(), Math.max(1, Math.floor(os4.totalmem() / 2 ** 31)));
|
|
16442
|
+
}
|
|
16443
|
+
var SWIFT_COMPILER_ENV_KEYS = [
|
|
16444
|
+
"PATH",
|
|
16445
|
+
"HOME",
|
|
16446
|
+
"USER",
|
|
16447
|
+
"LOGNAME",
|
|
16448
|
+
"LANG",
|
|
16449
|
+
"LC_ALL",
|
|
16450
|
+
"LC_CTYPE",
|
|
16451
|
+
"TZ",
|
|
16452
|
+
"SDKROOT",
|
|
16453
|
+
"DEVELOPER_DIR",
|
|
16454
|
+
"DYLD_LIBRARY_PATH",
|
|
16455
|
+
"SYSTEMROOT",
|
|
16456
|
+
"COMSPEC",
|
|
16457
|
+
"SSL_CERT_FILE",
|
|
16458
|
+
"SSL_CERT_DIR",
|
|
16459
|
+
"HTTP_PROXY",
|
|
16460
|
+
"HTTPS_PROXY",
|
|
16461
|
+
"NO_PROXY",
|
|
16462
|
+
"http_proxy",
|
|
16463
|
+
"https_proxy",
|
|
16464
|
+
"no_proxy"
|
|
16465
|
+
];
|
|
16466
|
+
function swiftCompilerBaseEnv(toolchainBin, sourceEnv, includePeachHome = false) {
|
|
16467
|
+
const env = {};
|
|
16468
|
+
for (const key of SWIFT_COMPILER_ENV_KEYS) {
|
|
16469
|
+
const value = sourceEnv[key];
|
|
16470
|
+
if (value !== void 0) env[key] = value;
|
|
16471
|
+
}
|
|
16472
|
+
if (includePeachHome && sourceEnv.PEACH_HOME !== void 0)
|
|
16473
|
+
env.PEACH_HOME = sourceEnv.PEACH_HOME;
|
|
16474
|
+
if (process.platform === "linux") {
|
|
16475
|
+
env.LD_LIBRARY_PATH = [
|
|
16476
|
+
path33.resolve(toolchainBin, "../lib/swift/linux"),
|
|
16477
|
+
path33.resolve(toolchainBin, "../lib/swift/host"),
|
|
16478
|
+
sourceEnv.LD_LIBRARY_PATH
|
|
16479
|
+
].filter(Boolean).join(":");
|
|
16480
|
+
}
|
|
16481
|
+
env.PEACH_DEFER_WASM_LINK = "1";
|
|
16482
|
+
return env;
|
|
16184
16483
|
}
|
|
16185
16484
|
function assertSwiftBuildCores() {
|
|
16186
16485
|
const admitted = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
|
|
@@ -16191,7 +16490,7 @@ function assertSwiftBuildCores() {
|
|
|
16191
16490
|
}
|
|
16192
16491
|
function swiftDistributionAt(root) {
|
|
16193
16492
|
const file = path33.join(root, SWIFT_DISTRIBUTION_MANIFEST);
|
|
16194
|
-
const stat =
|
|
16493
|
+
const stat = statSync5(file, { bigint: true, throwIfNoEntry: false });
|
|
16195
16494
|
if (!stat) return null;
|
|
16196
16495
|
const identity = `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}`;
|
|
16197
16496
|
const cached = distributionManifests.get(file);
|
|
@@ -16204,13 +16503,13 @@ var distributionManifests = /* @__PURE__ */ new Map();
|
|
|
16204
16503
|
var distributionCompileViews = /* @__PURE__ */ new WeakMap();
|
|
16205
16504
|
function swiftDistributionCompileView(moduleRoot, distribution) {
|
|
16206
16505
|
let view = distributionCompileViews.get(distribution);
|
|
16207
|
-
if (!view || !
|
|
16506
|
+
if (!view || !existsSync9(view)) {
|
|
16208
16507
|
const inputs = Object.entries(distribution.files).filter(
|
|
16209
16508
|
([file]) => file.startsWith("host/") || file === SWIFT_DISTRIBUTION_OBJC_SELECTORS
|
|
16210
16509
|
).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
|
|
16211
16510
|
const digest = createHash18("sha256").update(JSON.stringify(inputs)).digest("hex");
|
|
16212
16511
|
view = path33.join(swiftCacheDir(), "swift-sdk-views", `compile-${digest}`);
|
|
16213
|
-
if (!
|
|
16512
|
+
if (!existsSync9(view)) {
|
|
16214
16513
|
mkdirSync8(path33.dirname(view), { recursive: true });
|
|
16215
16514
|
const staging = mkdtempSync4(`${view}-`);
|
|
16216
16515
|
try {
|
|
@@ -16225,7 +16524,7 @@ function swiftDistributionCompileView(moduleRoot, distribution) {
|
|
|
16225
16524
|
try {
|
|
16226
16525
|
renameSync5(staging, view);
|
|
16227
16526
|
} catch (error) {
|
|
16228
|
-
if (!
|
|
16527
|
+
if (!existsSync9(view)) throw error;
|
|
16229
16528
|
}
|
|
16230
16529
|
} finally {
|
|
16231
16530
|
rmSync7(staging, { recursive: true, force: true });
|
|
@@ -16243,13 +16542,13 @@ function swiftModuleInterface(moduleRoot, name) {
|
|
|
16243
16542
|
if (REACH_STAGED_FRAMEWORKS.has(name)) return null;
|
|
16244
16543
|
if (swiftDistributionAt(moduleRoot)) {
|
|
16245
16544
|
const file = path33.join(moduleRoot, "modules", `${name}-Swift.h`);
|
|
16246
|
-
if (!
|
|
16545
|
+
if (!existsSync9(file)) return null;
|
|
16247
16546
|
const header = clangInterfaceHeader(readFileSync16(file, "utf8"), moduleRoot);
|
|
16248
16547
|
return { declared: swiftInterfaceDeclarations(header), header };
|
|
16249
16548
|
}
|
|
16250
16549
|
const sources = path33.join(moduleRoot, "Sources", name);
|
|
16251
16550
|
const built = path33.join(moduleRoot, ".build/host", `${name}-Swift.h`);
|
|
16252
|
-
if (!
|
|
16551
|
+
if (!existsSync9(sources) || !existsSync9(built)) return null;
|
|
16253
16552
|
const declared = /* @__PURE__ */ new Set();
|
|
16254
16553
|
for (const file of readdirSync6(sources, { recursive: true, encoding: "utf8" }))
|
|
16255
16554
|
if (file.endsWith(".swift"))
|
|
@@ -16282,7 +16581,7 @@ function clangInterfaceHeader(header, moduleRoot) {
|
|
|
16282
16581
|
const imports = [`@import ${framework};`];
|
|
16283
16582
|
imported.add(framework);
|
|
16284
16583
|
const directory = distribution ? path33.join(moduleRoot, "modules", module) : path33.join(moduleRoot, "Sources", module, "include");
|
|
16285
|
-
if (!
|
|
16584
|
+
if (!existsSync9(directory)) return imports[0];
|
|
16286
16585
|
if (!references) {
|
|
16287
16586
|
references = new Set(header.match(/\b[A-Z]\w*\b/g));
|
|
16288
16587
|
for (const name of objcEnumerations(header)) references.delete(name);
|
|
@@ -16346,7 +16645,7 @@ function sdkObjCDeclarationOwners(frameworks) {
|
|
|
16346
16645
|
for (const framework of readdirSync6(frameworks))
|
|
16347
16646
|
if (framework.endsWith(".framework")) {
|
|
16348
16647
|
const headers = path33.join(frameworks, framework, "Headers");
|
|
16349
|
-
if (
|
|
16648
|
+
if (existsSync9(headers)) {
|
|
16350
16649
|
for (const file of readdirSync6(headers, { recursive: true, encoding: "utf8" }))
|
|
16351
16650
|
if (file.endsWith(".h")) {
|
|
16352
16651
|
const header = readFileSync16(path33.join(headers, file), "utf8");
|
|
@@ -16467,7 +16766,7 @@ function swiftObjCSelectorOptions(moduleRoot) {
|
|
|
16467
16766
|
map = path33.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
|
|
16468
16767
|
const content = `${JSON.stringify({ classes }, null, 2)}
|
|
16469
16768
|
`;
|
|
16470
|
-
if (!
|
|
16769
|
+
if (!existsSync9(map) || readFileSync16(map, "utf8") !== content) {
|
|
16471
16770
|
mkdirSync8(path33.dirname(map), { recursive: true });
|
|
16472
16771
|
const partial = `${map}.${randomUUID5()}`;
|
|
16473
16772
|
writeFileSync8(partial, content);
|
|
@@ -16566,8 +16865,8 @@ function swiftMacroPlugins(moduleRoot, dir = path33.join(moduleRoot, ".build/hos
|
|
|
16566
16865
|
return {
|
|
16567
16866
|
libraries: plugins.map(({ library }) => library),
|
|
16568
16867
|
executables: [expoPlugin],
|
|
16569
|
-
stale: !
|
|
16570
|
-
({ library, sources }) => !
|
|
16868
|
+
stale: !existsSync9(compilerStamp) || !existsSync9(expoPlugin) || statSync5(pluginScript).mtimeMs > statSync5(expoPlugin).mtimeMs || readFileSync16(compilerStamp, "utf8").trim() !== release || plugins.some(
|
|
16869
|
+
({ library, sources }) => !existsSync9(library) || sources.some((source) => statSync5(source).mtimeMs > statSync5(library).mtimeMs)
|
|
16571
16870
|
)
|
|
16572
16871
|
};
|
|
16573
16872
|
}
|
|
@@ -16663,7 +16962,7 @@ function swiftModuleDigest(root) {
|
|
|
16663
16962
|
const files = swiftModuleInputFiles(root);
|
|
16664
16963
|
const stampHash = createHash18("sha256");
|
|
16665
16964
|
for (const file of files) {
|
|
16666
|
-
const stat =
|
|
16965
|
+
const stat = statSync5(path33.join(root, file), { bigint: true });
|
|
16667
16966
|
stampHash.update(file);
|
|
16668
16967
|
stampHash.update(
|
|
16669
16968
|
`${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
|
|
@@ -16684,7 +16983,7 @@ function swiftModuleDigest(root) {
|
|
|
16684
16983
|
writeFileSync8(partial, body);
|
|
16685
16984
|
renameSync5(partial, target);
|
|
16686
16985
|
};
|
|
16687
|
-
if (
|
|
16986
|
+
if (existsSync9(record)) {
|
|
16688
16987
|
const saved = JSON.parse(readFileSync16(record, "utf8"));
|
|
16689
16988
|
if (saved && typeof saved === "object" && Reflect.get(saved, "stamp") === stamp && typeof Reflect.get(saved, "digest") === "string") {
|
|
16690
16989
|
const digest2 = Buffer.from(String(Reflect.get(saved, "digest")), "hex");
|
|
@@ -16694,7 +16993,7 @@ function swiftModuleDigest(root) {
|
|
|
16694
16993
|
}
|
|
16695
16994
|
const gitKey = gitCleanModuleInputsKey(root, files);
|
|
16696
16995
|
const gitRecord = gitKey ? path33.join(digestDir, `git-${gitKey}.json`) : null;
|
|
16697
|
-
if (gitRecord &&
|
|
16996
|
+
if (gitRecord && existsSync9(gitRecord)) {
|
|
16698
16997
|
const saved = JSON.parse(readFileSync16(gitRecord, "utf8"));
|
|
16699
16998
|
if (saved && typeof saved === "object" && typeof Reflect.get(saved, "digest") === "string") {
|
|
16700
16999
|
const hex2 = String(Reflect.get(saved, "digest"));
|
|
@@ -17044,13 +17343,13 @@ function swiftOverlayFrameworks(moduleRoot, toolchainBin) {
|
|
|
17044
17343
|
);
|
|
17045
17344
|
for (const entry of readdirSync6(resources)) {
|
|
17046
17345
|
const map = path33.join(resources, entry, "module.modulemap");
|
|
17047
|
-
if (
|
|
17346
|
+
if (existsSync9(map))
|
|
17048
17347
|
addSwiftOverlayFrameworks(readFileSync16(map, "utf8"), swiftModules, result);
|
|
17049
17348
|
}
|
|
17050
17349
|
for (const directory of frameworks)
|
|
17051
17350
|
for (const entry of readdirSync6(directory)) {
|
|
17052
17351
|
const map = path33.join(directory, entry, "Modules/module.modulemap");
|
|
17053
|
-
if (
|
|
17352
|
+
if (existsSync9(map))
|
|
17054
17353
|
addSwiftOverlayFrameworks(readFileSync16(map, "utf8"), swiftModules, result);
|
|
17055
17354
|
}
|
|
17056
17355
|
sdkOverlayFrameworks.set(key, result);
|
|
@@ -17074,7 +17373,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
17074
17373
|
})
|
|
17075
17374
|
]);
|
|
17076
17375
|
for (const map of maps) {
|
|
17077
|
-
if (!
|
|
17376
|
+
if (!existsSync9(map)) continue;
|
|
17078
17377
|
const contents2 = readFileSync16(map, "utf8");
|
|
17079
17378
|
for (const match of contents2.matchAll(
|
|
17080
17379
|
/^(?:explicit\s+)?(?:framework\s+)?module\s+([A-Za-z_]\w*)/gm
|
|
@@ -17089,7 +17388,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
17089
17388
|
}
|
|
17090
17389
|
for (const entry of readdirSync6(resources)) {
|
|
17091
17390
|
const map = path33.join(resources, entry, "module.modulemap");
|
|
17092
|
-
if (!
|
|
17391
|
+
if (!existsSync9(map)) continue;
|
|
17093
17392
|
for (const match of readFileSync16(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
|
|
17094
17393
|
modules.add(match[1]);
|
|
17095
17394
|
}
|
|
@@ -17110,7 +17409,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
17110
17409
|
for (const directory of frameworks) {
|
|
17111
17410
|
for (const entry of readdirSync6(directory)) {
|
|
17112
17411
|
const map = path33.join(directory, entry, "Modules/module.modulemap");
|
|
17113
|
-
if (!
|
|
17412
|
+
if (!existsSync9(map)) continue;
|
|
17114
17413
|
for (const match of readFileSync16(map, "utf8").matchAll(
|
|
17115
17414
|
/^framework\s+module\s+([A-Za-z_]\w*)/gm
|
|
17116
17415
|
))
|
|
@@ -17210,7 +17509,7 @@ int EXUpdatesApplyBSDiffPatch(const char * _Nonnull oldFilePath,
|
|
|
17210
17509
|
];
|
|
17211
17510
|
var CLANG_DISTRIBUTION_MODULES = ".peach-clang-modules";
|
|
17212
17511
|
function distributionClangModulePresent(modules, name) {
|
|
17213
|
-
return
|
|
17512
|
+
return existsSync9(path33.join(modules, `${name}.swiftmodule`)) || existsSync9(path33.join(modules, name, "module.modulemap"));
|
|
17214
17513
|
}
|
|
17215
17514
|
function distributionClangModuleMap(root, modules) {
|
|
17216
17515
|
const missing = DISTRIBUTION_CLANG_MODULES.filter(
|
|
@@ -17227,7 +17526,7 @@ function distributionClangModuleMap(root, modules) {
|
|
|
17227
17526
|
}
|
|
17228
17527
|
`
|
|
17229
17528
|
).join("\n");
|
|
17230
|
-
if (
|
|
17529
|
+
if (existsSync9(mapPath) && readFileSync16(mapPath, "utf8") !== map)
|
|
17231
17530
|
rmSync7(directory, { recursive: true, force: true });
|
|
17232
17531
|
for (const mod of missing) writeBuildFile(path33.join(directory, mod.header), mod.source);
|
|
17233
17532
|
writeBuildFile(mapPath, map);
|
|
@@ -17243,7 +17542,7 @@ function providedModulesPath(root, modules, excluded) {
|
|
|
17243
17542
|
const key = createHash18("sha256").update(JSON.stringify([modules, entries2])).update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
|
|
17244
17543
|
const directory = path33.join(root, `.peach-modules-${key}`);
|
|
17245
17544
|
const complete = path33.join(directory, ".complete");
|
|
17246
|
-
if (!
|
|
17545
|
+
if (!existsSync9(complete)) {
|
|
17247
17546
|
mkdirSync8(directory, { recursive: true });
|
|
17248
17547
|
for (const entry of readdirSync6(directory))
|
|
17249
17548
|
rmSync7(path33.join(directory, entry), { recursive: true, force: true });
|
|
@@ -17388,7 +17687,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
|
|
|
17388
17687
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
17389
17688
|
var MULTI_MANIFEST_VERSION = 76;
|
|
17390
17689
|
var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
17391
|
-
var compilerSourceDigest = true ? "
|
|
17690
|
+
var compilerSourceDigest = true ? "4d55fa7cbb29586c08e4e51867226f96047bae2103c89f4fa59d9cf3ed3862fb" : swiftCompilerSourceDigest(import.meta.dirname);
|
|
17392
17691
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
17393
17692
|
return swiftCompileInputHash(input, release).update(swiftModuleDigest(moduleRoot)).digest("hex");
|
|
17394
17693
|
}
|
|
@@ -17536,7 +17835,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17536
17835
|
if (!flag.startsWith("-fmodule-map-file=")) return false;
|
|
17537
17836
|
const file = flag.slice("-fmodule-map-file=".length).replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root);
|
|
17538
17837
|
if (!file.includes("/Pods/Headers/")) return false;
|
|
17539
|
-
const map = args.files.get(file) ?? (
|
|
17838
|
+
const map = args.files.get(file) ?? (existsSync9(file) ? readFileSync16(file) : void 0);
|
|
17540
17839
|
const name = map === void 0 ? void 0 : moduleMapName(map.toString());
|
|
17541
17840
|
return name !== void 0 && packageModules.has(name);
|
|
17542
17841
|
};
|
|
@@ -17577,10 +17876,22 @@ function emitSwiftPackageManifest(args) {
|
|
|
17577
17876
|
const available = distribution.objects.filter(
|
|
17578
17877
|
(object2) => !isProvider(object2) && !replacedObjects.has(object2)
|
|
17579
17878
|
);
|
|
17879
|
+
const targetNamesWithDash = targets.filter((target) => target.name.includes("-")).map((target) => `lib/${target.name}-`);
|
|
17880
|
+
const targetNameSet = new Set(targets.map((target) => target.name));
|
|
17881
|
+
const optionalSet = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...GAME_FAMILY, "PeachBox2D"]);
|
|
17882
|
+
const isTargetObject = (object2) => {
|
|
17883
|
+
const dash = object2.indexOf("-", 4);
|
|
17884
|
+
if (dash > 4 && targetNameSet.has(object2.slice(4, dash))) return true;
|
|
17885
|
+
return targetNamesWithDash.some((prefix) => object2.startsWith(prefix));
|
|
17886
|
+
};
|
|
17887
|
+
const isUnreachedOptional = (object2) => {
|
|
17888
|
+
const dash = object2.indexOf("-", 4);
|
|
17889
|
+
if (dash <= 4) return false;
|
|
17890
|
+
const name = object2.slice(4, dash);
|
|
17891
|
+
return optionalSet.has(name) && !reachedFrameworks.has(name);
|
|
17892
|
+
};
|
|
17580
17893
|
const objects = available.filter(
|
|
17581
|
-
(object2) => !
|
|
17582
|
-
(name) => !object2.startsWith(`lib/${name}-`) || reachedFrameworks.has(name)
|
|
17583
|
-
)
|
|
17894
|
+
(object2) => !isTargetObject(object2) && !isUnreachedOptional(object2)
|
|
17584
17895
|
);
|
|
17585
17896
|
const quoted2 = (object2) => `"${path33.join(moduleRoot, object2).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
17586
17897
|
const categoryObjects = new Set(
|
|
@@ -17661,18 +17972,53 @@ function emitSwiftPackageManifest(args) {
|
|
|
17661
17972
|
args.files.set(file, content);
|
|
17662
17973
|
return JSON.stringify([`@${file}`]);
|
|
17663
17974
|
};
|
|
17664
|
-
const
|
|
17665
|
-
|
|
17666
|
-
|
|
17667
|
-
const owner = args.targets.find((other) => other.name === dependency);
|
|
17975
|
+
const targetByName = new Map(targets.map((target) => [target.name, target]));
|
|
17976
|
+
const ownFrameworkDir = /* @__PURE__ */ new Map();
|
|
17977
|
+
for (const target of targets) {
|
|
17668
17978
|
const framework = /^(.*)\/[^/]+\.framework\/Modules$/.exec(
|
|
17669
|
-
|
|
17979
|
+
target.publicHeadersPath ?? ""
|
|
17670
17980
|
);
|
|
17671
|
-
|
|
17672
|
-
|
|
17673
|
-
|
|
17674
|
-
|
|
17675
|
-
|
|
17981
|
+
if (framework)
|
|
17982
|
+
ownFrameworkDir.set(
|
|
17983
|
+
target.name,
|
|
17984
|
+
path33.posix.join(args.root, target.path, framework[1])
|
|
17985
|
+
);
|
|
17986
|
+
}
|
|
17987
|
+
const frameworkDirectoriesCache = /* @__PURE__ */ new Map();
|
|
17988
|
+
const frameworkDirectories = (name) => {
|
|
17989
|
+
if (ownFrameworkDir.size === 0) return [];
|
|
17990
|
+
const cached = frameworkDirectoriesCache.get(name);
|
|
17991
|
+
if (cached) return cached;
|
|
17992
|
+
const dirs = [];
|
|
17993
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17994
|
+
const visit = (current) => {
|
|
17995
|
+
for (const dependency of siblings.get(current) ?? []) {
|
|
17996
|
+
if (seen.has(dependency)) continue;
|
|
17997
|
+
seen.add(dependency);
|
|
17998
|
+
const dir = ownFrameworkDir.get(dependency);
|
|
17999
|
+
if (dir) dirs.push(dir);
|
|
18000
|
+
visit(dependency);
|
|
18001
|
+
}
|
|
18002
|
+
};
|
|
18003
|
+
visit(name);
|
|
18004
|
+
frameworkDirectoriesCache.set(name, dirs);
|
|
18005
|
+
return dirs;
|
|
18006
|
+
};
|
|
18007
|
+
const targetSwiftXccFlags = /* @__PURE__ */ new Map();
|
|
18008
|
+
for (const target of targets) {
|
|
18009
|
+
const flags = target.swiftFlags;
|
|
18010
|
+
if (!flags || flags.length === 0) continue;
|
|
18011
|
+
const xcc = [];
|
|
18012
|
+
for (let index = 1; index < flags.length; index++) {
|
|
18013
|
+
if (flags[index - 1] === "-Xcc")
|
|
18014
|
+
xcc.push(flags[index].replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root));
|
|
18015
|
+
}
|
|
18016
|
+
if (xcc.length > 0) targetSwiftXccFlags.set(target.name, xcc);
|
|
18017
|
+
}
|
|
18018
|
+
const binaryImports = args.binaryModules ? `, "-I", ${JSON.stringify(args.binaryModules)}` : "";
|
|
18019
|
+
const sharedImports = binaryImports + (distributionModules ? `, "-Isystem", ${JSON.stringify(
|
|
18020
|
+
providedModulesPath(args.root, distributionModules, args.moduleExcludes)
|
|
18021
|
+
)}${distributionClangModuleOptions(args.root, distributionModules).map((flag) => `, ${JSON.stringify(flag)}`).join("")}` : prebuilt ? `, "-Isystem", ${JSON.stringify(providedModulesPath(args.root, prebuilt.modules, args.moduleExcludes))}${prebuilt.moduleMaps.map((map) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map}`)}`).join("")}` : "");
|
|
17676
18022
|
const frameworkSearchFlags = (target, tool) => frameworkDirectories(target?.name ?? "").map((directory) => ({
|
|
17677
18023
|
tool,
|
|
17678
18024
|
flags: ["-F", directory]
|
|
@@ -17721,10 +18067,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17721
18067
|
const upstream = (target.swiftFlags ?? []).map(
|
|
17722
18068
|
(flag) => `, ${JSON.stringify(flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root))}`
|
|
17723
18069
|
).join("");
|
|
17724
|
-
const
|
|
17725
|
-
const imports = binaryImports + (distributionModules ? `, "-Isystem", ${JSON.stringify(
|
|
17726
|
-
providedModulesPath(args.root, distributionModules, args.moduleExcludes)
|
|
17727
|
-
)}${distributionClangModuleOptions(args.root, distributionModules).map((flag) => `, ${JSON.stringify(flag)}`).join("")}` : prebuilt ? `, "-Isystem", ${JSON.stringify(providedModulesPath(args.root, prebuilt.modules, args.moduleExcludes))}${prebuilt.moduleMaps.map((map) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map}`)}`).join("")}` : "");
|
|
18070
|
+
const imports = sharedImports;
|
|
17728
18071
|
const nativeFlags = [
|
|
17729
18072
|
...args.nativeFlags?.get(target.name) ?? [],
|
|
17730
18073
|
...args.nativeHeaderFlags ?? []
|
|
@@ -17748,12 +18091,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17748
18091
|
return map ? ["-fmodule-map-file=" + map] : [];
|
|
17749
18092
|
}),
|
|
17750
18093
|
...[...importContext].flatMap((name) => args.native?.get(name)?.importFlags ?? []),
|
|
17751
|
-
...[...importContext].flatMap((name) =>
|
|
17752
|
-
const flags = targets.find((target2) => target2.name === name)?.swiftFlags ?? [];
|
|
17753
|
-
return flags.flatMap(
|
|
17754
|
-
(flag, index) => flags[index - 1] === "-Xcc" ? [flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root)] : []
|
|
17755
|
-
);
|
|
17756
|
-
})
|
|
18094
|
+
...[...importContext].flatMap((name) => targetSwiftXccFlags.get(name) ?? [])
|
|
17757
18095
|
];
|
|
17758
18096
|
const nativeImportFlags = [
|
|
17759
18097
|
...frameworkDirectories(target.name).flatMap((directory) => ["-F", directory]),
|
|
@@ -17768,9 +18106,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17768
18106
|
...native?.swiftFlags ?? [],
|
|
17769
18107
|
...args.objcImplementationModules?.has(target.name) ? ["-enable-experimental-feature", "ObjCImplementation"] : []
|
|
17770
18108
|
].map((flag) => `, ${JSON.stringify(flag)}`).join("");
|
|
17771
|
-
const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] ||
|
|
17772
|
-
(value) => value.late?.producers.includes(target.name)
|
|
17773
|
-
)) ? `, "-emit-objc-header-path", ${JSON.stringify(path33.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
|
|
18109
|
+
const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || lateProducers.has(target.name)) ? `, "-emit-objc-header-path", ${JSON.stringify(path33.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
|
|
17774
18110
|
const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
|
|
17775
18111
|
const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
|
|
17776
18112
|
const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImportFlags}${objcFlags}${header}${clangMode}${deployment}${upstream}]`)})]`;
|
|
@@ -17803,9 +18139,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17803
18139
|
(dependency) => clang && // textual native headers can include one another without imposing
|
|
17804
18140
|
// an object build order. the executable already links every native
|
|
17805
18141
|
// target; only generated Swift headers require producer ordering.
|
|
17806
|
-
(args.native?.get(dependency)?.clang || [
|
|
17807
|
-
(value) => value.late?.producers.includes(dependency)
|
|
17808
|
-
)) ? [] : OPTIONAL_FRAMEWORKS.has(dependency) && !targets.some((candidate) => candidate.name === dependency) ? linkedObjects ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
|
|
18142
|
+
(args.native?.get(dependency)?.clang || lateProducers.has(dependency)) ? [] : OPTIONAL_FRAMEWORKS.has(dependency) && !targetNames.has(dependency) ? linkedObjects ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
|
|
17809
18143
|
),
|
|
17810
18144
|
// a swift importer still needs the producers its clang dependencies
|
|
17811
18145
|
// reached upstream, whose edges the clang targets above dropped.
|
|
@@ -17892,7 +18226,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17892
18226
|
...args.nativeFlags?.get(name) ?? [],
|
|
17893
18227
|
...args.nativeHeaderFlags ?? []
|
|
17894
18228
|
];
|
|
17895
|
-
const owner =
|
|
18229
|
+
const owner = targetByName.get(name);
|
|
17896
18230
|
const context = /* @__PURE__ */ new Set();
|
|
17897
18231
|
const visit = (dependency) => {
|
|
17898
18232
|
if (context.has(dependency)) return;
|
|
@@ -17968,10 +18302,16 @@ ${declaration.replace(/,$/, "")}
|
|
|
17968
18302
|
""
|
|
17969
18303
|
].join("\n");
|
|
17970
18304
|
}
|
|
17971
|
-
function syncSwiftTree(base, files) {
|
|
18305
|
+
function syncSwiftTree(base, files, alreadySynced) {
|
|
17972
18306
|
mkdirSync8(base, { recursive: true });
|
|
17973
|
-
|
|
17974
|
-
|
|
18307
|
+
let kept;
|
|
18308
|
+
if (process.platform !== "linux") {
|
|
18309
|
+
kept = /* @__PURE__ */ new Set();
|
|
18310
|
+
for (const file of files.keys()) {
|
|
18311
|
+
const stat = statSync5(file, { throwIfNoEntry: false });
|
|
18312
|
+
if (stat) kept.add(stat.ino);
|
|
18313
|
+
}
|
|
18314
|
+
}
|
|
17975
18315
|
const walk = (dir) => {
|
|
17976
18316
|
for (const entry of readdirSync6(dir, { withFileTypes: true })) {
|
|
17977
18317
|
const full = path33.join(dir, entry.name);
|
|
@@ -17980,12 +18320,13 @@ function syncSwiftTree(base, files) {
|
|
|
17980
18320
|
entry.name === CLANG_DISTRIBUTION_MODULES || entry.name === SWIFT_DISTRIBUTION_MIRROR || entry.name === SWIFT_LINK_STAMP))
|
|
17981
18321
|
continue;
|
|
17982
18322
|
if (entry.isDirectory()) walk(full);
|
|
17983
|
-
else if (!files.has(full) && !kept.has(lstatSync(full).ino))
|
|
18323
|
+
else if (!files.has(full) && (!kept || !kept.has(lstatSync(full).ino)))
|
|
17984
18324
|
rmSync7(full, { force: true });
|
|
17985
18325
|
}
|
|
17986
18326
|
};
|
|
17987
18327
|
walk(base);
|
|
17988
18328
|
for (const [full, contents2] of files) {
|
|
18329
|
+
if (alreadySynced?.get(full) === contents2) continue;
|
|
17989
18330
|
writeBuildFile(full, contents2);
|
|
17990
18331
|
}
|
|
17991
18332
|
}
|
|
@@ -18109,25 +18450,59 @@ function swiftWasmCallGuards(source, unavailable) {
|
|
|
18109
18450
|
out = out.slice(0, at) + replacement + out.slice(at + width);
|
|
18110
18451
|
return out;
|
|
18111
18452
|
}
|
|
18453
|
+
function matchesPathPrefixSet(file, set) {
|
|
18454
|
+
if (set.has(file)) return true;
|
|
18455
|
+
for (let slash = file.lastIndexOf("/"); slash !== -1; slash = file.lastIndexOf("/", slash - 1)) {
|
|
18456
|
+
if (set.has(file.slice(0, slash))) return true;
|
|
18457
|
+
}
|
|
18458
|
+
return false;
|
|
18459
|
+
}
|
|
18460
|
+
function indexTargetsByDirectory(targets) {
|
|
18461
|
+
const byDir = /* @__PURE__ */ new Map();
|
|
18462
|
+
for (const target of targets) {
|
|
18463
|
+
const key = target.path === "." ? "" : target.path.replace(/\/+$/, "");
|
|
18464
|
+
let list = byDir.get(key);
|
|
18465
|
+
if (!list) byDir.set(key, list = []);
|
|
18466
|
+
list.push(target);
|
|
18467
|
+
}
|
|
18468
|
+
return byDir;
|
|
18469
|
+
}
|
|
18470
|
+
function findTargetForFile(file, byDir, predicate) {
|
|
18471
|
+
for (let slash = file.lastIndexOf("/"); slash !== -1; slash = file.lastIndexOf("/", slash - 1)) {
|
|
18472
|
+
const candidates = byDir.get(file.slice(0, slash));
|
|
18473
|
+
if (!candidates) continue;
|
|
18474
|
+
const relative = file.slice(slash + 1);
|
|
18475
|
+
for (const target of candidates) if (predicate(target, relative)) return target;
|
|
18476
|
+
}
|
|
18477
|
+
const rootCandidates = byDir.get("");
|
|
18478
|
+
if (rootCandidates) {
|
|
18479
|
+
for (const target of rootCandidates) if (predicate(target, file)) return target;
|
|
18480
|
+
}
|
|
18481
|
+
return void 0;
|
|
18482
|
+
}
|
|
18112
18483
|
function compiledSwiftSources(files, targets, overlayFrameworks, headers, nativeSourceGlue = false) {
|
|
18113
18484
|
const ordered = [...targets].sort((a, b) => b.path.length - a.path.length);
|
|
18114
|
-
const
|
|
18115
|
-
|
|
18116
|
-
|
|
18117
|
-
|
|
18118
|
-
|
|
18119
|
-
|
|
18120
|
-
|
|
18121
|
-
|
|
18122
|
-
|
|
18123
|
-
|
|
18124
|
-
return
|
|
18125
|
-
})
|
|
18126
|
-
|
|
18485
|
+
const byDir = indexTargetsByDirectory(ordered);
|
|
18486
|
+
const excludeSets = /* @__PURE__ */ new Map();
|
|
18487
|
+
for (const target of ordered) {
|
|
18488
|
+
if (target.exclude?.length) excludeSets.set(target.name, new Set(target.exclude));
|
|
18489
|
+
}
|
|
18490
|
+
const owners = /* @__PURE__ */ new Map();
|
|
18491
|
+
for (const [file, source] of Object.entries(files)) {
|
|
18492
|
+
if (!file.endsWith(".swift")) continue;
|
|
18493
|
+
const owner = findTargetForFile(file, byDir, (target, relative) => {
|
|
18494
|
+
const excluded = excludeSets.get(target.name);
|
|
18495
|
+
return !excluded || !matchesPathPrefixSet(relative, excluded);
|
|
18496
|
+
});
|
|
18497
|
+
owners.set(file, { source, owner });
|
|
18498
|
+
}
|
|
18127
18499
|
const swiftSources = /* @__PURE__ */ new Map();
|
|
18128
|
-
for (const { source, owner } of owners.values())
|
|
18129
|
-
if (owner)
|
|
18130
|
-
|
|
18500
|
+
for (const { source, owner } of owners.values()) {
|
|
18501
|
+
if (!owner) continue;
|
|
18502
|
+
let list = swiftSources.get(owner.name);
|
|
18503
|
+
if (!list) swiftSources.set(owner.name, list = []);
|
|
18504
|
+
list.push(source);
|
|
18505
|
+
}
|
|
18131
18506
|
const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
|
|
18132
18507
|
return new Map(
|
|
18133
18508
|
[...owners].map(([file, { source, owner }]) => {
|
|
@@ -19158,7 +19533,7 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
|
19158
19533
|
};
|
|
19159
19534
|
gather(source);
|
|
19160
19535
|
const manifest = path33.join(source, "Package.swift");
|
|
19161
|
-
const targets =
|
|
19536
|
+
const targets = existsSync9(manifest) ? swiftManifestTargets(
|
|
19162
19537
|
readFileSync16(manifest, "utf8"),
|
|
19163
19538
|
[],
|
|
19164
19539
|
(file) => readFileSync16(file, "utf8")
|
|
@@ -19274,10 +19649,10 @@ function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
|
|
|
19274
19649
|
const directory = path33.join(layoutRoot, ".build", "peach-clang-modulemaps");
|
|
19275
19650
|
return (settings.moduleMaps ?? []).flatMap((map) => {
|
|
19276
19651
|
const headers = path33.join(layoutRoot, map.headers);
|
|
19277
|
-
if (!
|
|
19652
|
+
if (!existsSync9(headers)) return [];
|
|
19278
19653
|
const published = path33.join(headers, "module.modulemap");
|
|
19279
|
-
if (searched.has(map.headers) &&
|
|
19280
|
-
if (!searched.has(map.headers) &&
|
|
19654
|
+
if (searched.has(map.headers) && existsSync9(published)) return [];
|
|
19655
|
+
if (!searched.has(map.headers) && existsSync9(published))
|
|
19281
19656
|
return [`-fmodule-map-file=${published}`];
|
|
19282
19657
|
const cached = written.get(headers);
|
|
19283
19658
|
if (cached) return [cached];
|
|
@@ -19369,18 +19744,46 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19369
19744
|
const bySourcePath = [...targets].sort(
|
|
19370
19745
|
(left, right) => right.path.length - left.path.length
|
|
19371
19746
|
);
|
|
19747
|
+
const targetsByDir = indexTargetsByDirectory(bySourcePath);
|
|
19748
|
+
const targetByName = new Map(targets.map((target) => [target.name, target]));
|
|
19749
|
+
const nativeTargets = input.nativeTargets ?? [];
|
|
19750
|
+
const nativeTargetByName = new Map(nativeTargets.map((target) => [target.name, target]));
|
|
19751
|
+
const nativeTargetIndex = new Map(
|
|
19752
|
+
nativeTargets.map((target, index) => [target.name, index])
|
|
19753
|
+
);
|
|
19754
|
+
const resourceTargetByName = new Map(
|
|
19755
|
+
resourceTargets.map((target) => [target.name, target])
|
|
19756
|
+
);
|
|
19757
|
+
const targetSourceSets = /* @__PURE__ */ new Map();
|
|
19758
|
+
const targetExcludeFullSets = /* @__PURE__ */ new Map();
|
|
19759
|
+
const targetExcludeExactSets = /* @__PURE__ */ new Map();
|
|
19760
|
+
for (const target of targets) {
|
|
19761
|
+
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
19762
|
+
if (target.sources !== void 0) {
|
|
19763
|
+
targetSourceSets.set(
|
|
19764
|
+
target.name,
|
|
19765
|
+
new Set(target.sources.map((source) => path33.posix.join(prefix, source)))
|
|
19766
|
+
);
|
|
19767
|
+
}
|
|
19768
|
+
if (target.exclude?.length) {
|
|
19769
|
+
targetExcludeFullSets.set(
|
|
19770
|
+
target.name,
|
|
19771
|
+
new Set(target.exclude.map((excluded) => `${prefix}${excluded}`))
|
|
19772
|
+
);
|
|
19773
|
+
targetExcludeExactSets.set(
|
|
19774
|
+
target.name,
|
|
19775
|
+
new Set(target.exclude.map((name) => path33.posix.join(target.path, name)))
|
|
19776
|
+
);
|
|
19777
|
+
}
|
|
19778
|
+
}
|
|
19372
19779
|
const swiftTargets = /* @__PURE__ */ new Set();
|
|
19373
19780
|
for (const file of Object.keys(input.files)) {
|
|
19374
19781
|
if (!file.endsWith(".swift")) continue;
|
|
19375
|
-
const target =
|
|
19376
|
-
|
|
19377
|
-
|
|
19378
|
-
|
|
19379
|
-
|
|
19380
|
-
);
|
|
19381
|
-
const excluded = target?.exclude?.some(
|
|
19382
|
-
(name) => file === path33.posix.join(target.path, name)
|
|
19383
|
-
);
|
|
19782
|
+
const target = findTargetForFile(file, targetsByDir, (candidate) => {
|
|
19783
|
+
const selected = targetSourceSets.get(candidate.name);
|
|
19784
|
+
return !selected || matchesPathPrefixSet(file, selected);
|
|
19785
|
+
});
|
|
19786
|
+
const excluded = target && targetExcludeExactSets.get(target.name)?.has(file);
|
|
19384
19787
|
if (target && !excluded) swiftTargets.add(target.name);
|
|
19385
19788
|
}
|
|
19386
19789
|
const importedModules = /* @__PURE__ */ new Set();
|
|
@@ -19406,7 +19809,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19406
19809
|
)
|
|
19407
19810
|
);
|
|
19408
19811
|
const headerDirectory = path33.join(layout2.root, ".build", "peach-cxx-headers");
|
|
19409
|
-
if (
|
|
19812
|
+
if (existsSync9(headerDirectory)) {
|
|
19410
19813
|
for (const entry of readdirSync6(headerDirectory, { withFileTypes: true }))
|
|
19411
19814
|
if (entry.isDirectory() && !targets.some((target) => target.name === entry.name))
|
|
19412
19815
|
rmSync7(path33.join(headerDirectory, entry.name), { recursive: true, force: true });
|
|
@@ -19418,7 +19821,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19418
19821
|
checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
|
|
19419
19822
|
return checkedToolchain;
|
|
19420
19823
|
};
|
|
19421
|
-
const deploymentTarget = (name) =>
|
|
19824
|
+
const deploymentTarget = (name) => nativeTargetByName.get(name)?.deploymentTarget ?? targetByName.get(name)?.iosDeploymentTarget ?? null;
|
|
19422
19825
|
const targetStagedFiles = /* @__PURE__ */ new Map();
|
|
19423
19826
|
const stageTargetFile = (target, file, contents2, options) => {
|
|
19424
19827
|
const relative = path33.relative(layout2.root, file).split(path33.sep).join(path33.posix.sep);
|
|
@@ -19430,18 +19833,41 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19430
19833
|
targetStagedFiles.set(target, staged);
|
|
19431
19834
|
files.set(file, contents2);
|
|
19432
19835
|
};
|
|
19836
|
+
const entriesByPrefix = /* @__PURE__ */ new Map();
|
|
19837
|
+
for (const target of targets) {
|
|
19838
|
+
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
19839
|
+
if (!entriesByPrefix.has(prefix)) entriesByPrefix.set(prefix, []);
|
|
19840
|
+
}
|
|
19841
|
+
for (const entry of Object.entries(input.files)) {
|
|
19842
|
+
const [file] = entry;
|
|
19843
|
+
entriesByPrefix.get("")?.push(entry);
|
|
19844
|
+
for (let end = file.indexOf("/"); end !== -1; end = file.indexOf("/", end + 1)) {
|
|
19845
|
+
entriesByPrefix.get(file.slice(0, end + 1))?.push(entry);
|
|
19846
|
+
}
|
|
19847
|
+
}
|
|
19848
|
+
const targetEntriesCache = /* @__PURE__ */ new Map();
|
|
19433
19849
|
const targetEntries = (target) => {
|
|
19850
|
+
const cached = targetEntriesCache.get(target.name);
|
|
19851
|
+
if (cached) return cached;
|
|
19434
19852
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
19435
|
-
|
|
19436
|
-
|
|
19437
|
-
|
|
19438
|
-
|
|
19439
|
-
|
|
19440
|
-
(
|
|
19441
|
-
|
|
19442
|
-
|
|
19443
|
-
)
|
|
19444
|
-
|
|
19853
|
+
const selectedSources = targetSourceSets.get(target.name);
|
|
19854
|
+
const excludedPaths = targetExcludeFullSets.get(target.name);
|
|
19855
|
+
const nestedPrefixes = [];
|
|
19856
|
+
for (const candidate of targets) {
|
|
19857
|
+
if (candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix))
|
|
19858
|
+
nestedPrefixes.push(`${candidate.path}/`);
|
|
19859
|
+
}
|
|
19860
|
+
const matched = (entriesByPrefix.get(prefix) ?? []).filter(([file]) => {
|
|
19861
|
+
if (selectedSources !== void 0 && (file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) && !matchesPathPrefixSet(file, selectedSources))
|
|
19862
|
+
return false;
|
|
19863
|
+
if (excludedPaths !== void 0 && matchesPathPrefixSet(file, excludedPaths))
|
|
19864
|
+
return false;
|
|
19865
|
+
if (nestedPrefixes.length > 0 && nestedPrefixes.some((p) => file.startsWith(p)))
|
|
19866
|
+
return false;
|
|
19867
|
+
return true;
|
|
19868
|
+
});
|
|
19869
|
+
targetEntriesCache.set(target.name, matched);
|
|
19870
|
+
return matched;
|
|
19445
19871
|
};
|
|
19446
19872
|
const failTargetPreparation = (target, message) => {
|
|
19447
19873
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
@@ -19486,19 +19912,21 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19486
19912
|
return value;
|
|
19487
19913
|
};
|
|
19488
19914
|
const podHeaders = /* @__PURE__ */ new Map();
|
|
19489
|
-
for (const settings of
|
|
19915
|
+
for (const settings of nativeTargets)
|
|
19490
19916
|
for (const file of settings.headers) {
|
|
19491
19917
|
const owner = /\/Headers\/(?:Public|Private)\/([\w+-]+)\/(?:\1\/)?[^/]+\.h$/.exec(
|
|
19492
19918
|
file
|
|
19493
19919
|
)?.[1];
|
|
19494
|
-
if (owner)
|
|
19495
|
-
|
|
19496
|
-
|
|
19497
|
-
|
|
19498
|
-
]);
|
|
19920
|
+
if (owner) {
|
|
19921
|
+
const base = path33.basename(file);
|
|
19922
|
+
let list = podHeaders.get(base);
|
|
19923
|
+
if (!list) podHeaders.set(base, list = []);
|
|
19924
|
+
list.push({ owner, content: input.files[file] });
|
|
19925
|
+
}
|
|
19499
19926
|
}
|
|
19500
19927
|
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(path33.basename(file))?.find((header) => header.content === content)?.owner;
|
|
19501
|
-
|
|
19928
|
+
const alreadySynced = /* @__PURE__ */ new Map();
|
|
19929
|
+
for (const settings of nativeTargets) {
|
|
19502
19930
|
for (const file of settings.headers) {
|
|
19503
19931
|
const destination = path33.join(layout2.root, file);
|
|
19504
19932
|
if (files.has(destination)) continue;
|
|
@@ -19515,10 +19943,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19515
19943
|
`#import <${interfaceOwner}/${interfaceOwner}-Swift.h>`
|
|
19516
19944
|
) : rawContents;
|
|
19517
19945
|
writeBuildFile(destination, contents2);
|
|
19946
|
+
alreadySynced.set(destination, contents2);
|
|
19518
19947
|
files.set(destination, contents2);
|
|
19519
19948
|
}
|
|
19520
19949
|
}
|
|
19521
|
-
const nativeTargets = input.nativeTargets ?? [];
|
|
19522
19950
|
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path33.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
|
|
19523
19951
|
const inRoot = `${layout2.root}${path33.sep}`;
|
|
19524
19952
|
const binaryTree = `${path33.sep}${SWIFT_BINARY_TREES_DIR}${path33.sep}`;
|
|
@@ -19583,12 +20011,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19583
20011
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
19584
20012
|
const entries2 = targetEntries(target);
|
|
19585
20013
|
const units = entries2.filter(([file]) => isSwiftNativeTranslationUnit(file));
|
|
19586
|
-
|
|
19587
|
-
|
|
19588
|
-
)))
|
|
20014
|
+
const settings = nativeTargetByName.get(target.name);
|
|
20015
|
+
if (units.length === 0 && !(entries2.some(([file]) => file.endsWith(".swift")) && settings !== void 0 && (settings.publicHeaders.length > 0 || settings.bridgingHeader !== null)))
|
|
19589
20016
|
continue;
|
|
19590
20017
|
const includes = `${prefix}include/`;
|
|
19591
|
-
const settings = input.nativeTargets?.find((value) => value.name === target.name);
|
|
19592
20018
|
const searchRoots = [
|
|
19593
20019
|
...settings?.userHeaderSearchPaths ?? [],
|
|
19594
20020
|
...settings?.headerSearchPaths ?? [],
|
|
@@ -19619,7 +20045,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19619
20045
|
...searchRoots.map((root) => path33.posix.join(root, include))
|
|
19620
20046
|
].find((candidate) => input.files[candidate] !== void 0);
|
|
19621
20047
|
if (local) {
|
|
19622
|
-
|
|
20048
|
+
let parents = reverse.get(local);
|
|
20049
|
+
if (!parents) reverse.set(local, parents = []);
|
|
20050
|
+
parents.push(file);
|
|
19623
20051
|
if (xcodeTarget && !seenHeaders.has(local)) {
|
|
19624
20052
|
seenHeaders.add(local);
|
|
19625
20053
|
searchEntries.push([local, input.files[local]]);
|
|
@@ -19665,9 +20093,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19665
20093
|
const stageFlags = (flags2, sdkInclude2) => flags2.map(
|
|
19666
20094
|
(flag) => flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, layout2.root).replaceAll(SWIFT_NATIVE_SDK_INCLUDE, sdkInclude2)
|
|
19667
20095
|
);
|
|
20096
|
+
const settingsHeaderFlags = headerSearch.flags[nativeTargetIndex.get(settings.name)];
|
|
19668
20097
|
const originalFlags = [
|
|
19669
20098
|
...settings.flags,
|
|
19670
|
-
...
|
|
20099
|
+
...settingsHeaderFlags,
|
|
19671
20100
|
...search,
|
|
19672
20101
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
19673
20102
|
"-F",
|
|
@@ -19678,7 +20107,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19678
20107
|
];
|
|
19679
20108
|
const importOriginalFlags = settings.flattensPublicHeaders ? [
|
|
19680
20109
|
...settings.importerFlags,
|
|
19681
|
-
...
|
|
20110
|
+
...settingsHeaderFlags,
|
|
19682
20111
|
...search,
|
|
19683
20112
|
...settings.frameworkSearchPaths.flatMap((dir) => [
|
|
19684
20113
|
"-F",
|
|
@@ -19703,7 +20132,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19703
20132
|
}
|
|
19704
20133
|
return [
|
|
19705
20134
|
...kept,
|
|
19706
|
-
...
|
|
20135
|
+
...settingsHeaderFlags,
|
|
19707
20136
|
...search,
|
|
19708
20137
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
19709
20138
|
"-F",
|
|
@@ -19732,7 +20161,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19732
20161
|
const bundleName = entries2.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
|
|
19733
20162
|
target: target.name,
|
|
19734
20163
|
path: target.path,
|
|
19735
|
-
resources:
|
|
20164
|
+
resources: resourceTargetByName.get(target.name)?.resources ?? false,
|
|
19736
20165
|
usesBundleMacro: entries2.some(
|
|
19737
20166
|
([file, contents2]) => (isSwiftNativeTranslationUnit(file) || /\.(?:h|hpp|hh|hxx)$/.test(file)) && /\bSWIFTPM_MODULE_BUNDLE\b/.test(contents2)
|
|
19738
20167
|
),
|
|
@@ -19885,10 +20314,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19885
20314
|
.../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
|
|
19886
20315
|
...stageFlags(
|
|
19887
20316
|
[...objcCxx ? settings.cxxFlags : [], ...fileFlags],
|
|
19888
|
-
|
|
19889
|
-
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
19890
|
-
"darwin/usr/include"
|
|
19891
|
-
)
|
|
20317
|
+
sdkInclude
|
|
19892
20318
|
)
|
|
19893
20319
|
];
|
|
19894
20320
|
const moduleFlag = perFile.some((flag) => flag.startsWith("-fmodule-name=")) ? [] : [`-fmodule-name=${swiftTargetModuleName(target.name)}`];
|
|
@@ -19928,13 +20354,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19928
20354
|
...flags,
|
|
19929
20355
|
...prefixHeader,
|
|
19930
20356
|
...accessorFlags,
|
|
19931
|
-
...stageFlags(
|
|
19932
|
-
cxx ? settings.cxxFlags : [],
|
|
19933
|
-
path33.join(
|
|
19934
|
-
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
19935
|
-
"darwin/usr/include"
|
|
19936
|
-
)
|
|
19937
|
-
),
|
|
20357
|
+
...stageFlags(cxx ? settings.cxxFlags : [], sdkInclude),
|
|
19938
20358
|
...perFile,
|
|
19939
20359
|
...moduleFlag
|
|
19940
20360
|
]
|
|
@@ -20189,7 +20609,9 @@ module ${moduleName}.Swift {
|
|
|
20189
20609
|
}
|
|
20190
20610
|
` : swiftObjCModuleMap(
|
|
20191
20611
|
moduleName,
|
|
20192
|
-
(
|
|
20612
|
+
(nativeTargetByName.get(name)?.publicHeaders ?? []).map(
|
|
20613
|
+
(header) => path33.join(layout2.root, header)
|
|
20614
|
+
),
|
|
20193
20615
|
submoduleImports2.get(moduleName),
|
|
20194
20616
|
path33.join(headerDirectory, name + "-Swift.h")
|
|
20195
20617
|
)
|
|
@@ -20235,7 +20657,7 @@ module ${moduleName}.Swift {
|
|
|
20235
20657
|
);
|
|
20236
20658
|
stagedProducts.push(name);
|
|
20237
20659
|
}
|
|
20238
|
-
if (
|
|
20660
|
+
if (existsSync9(providedFrameworks)) {
|
|
20239
20661
|
for (const entry of readdirSync6(providedFrameworks))
|
|
20240
20662
|
if (!stagedProducts.includes(entry.replace(/\.framework$/, "")))
|
|
20241
20663
|
rmSync7(path33.join(providedFrameworks, entry), { recursive: true, force: true });
|
|
@@ -20252,7 +20674,7 @@ module ${moduleName}.Swift {
|
|
|
20252
20674
|
".build",
|
|
20253
20675
|
"peach-framework-search.json"
|
|
20254
20676
|
);
|
|
20255
|
-
if (!
|
|
20677
|
+
if (!existsSync9(frameworkSearchRecord) || readFileSync16(frameworkSearchRecord, "utf8") !== frameworkSearch)
|
|
20256
20678
|
for (const cache of [
|
|
20257
20679
|
path33.join(layout2.root, ".build", "ModuleCache"),
|
|
20258
20680
|
path33.join(layout2.root, ".build", WASM_TRIPLE, "release", "ModuleCache")
|
|
@@ -20633,7 +21055,7 @@ ${entry}`);
|
|
|
20633
21055
|
const reachesFrameworks = !distribution || swiftImportedModules.has("Foundation") || Object.entries(input.files).some(
|
|
20634
21056
|
([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
|
|
20635
21057
|
) || [...importedModules].some(
|
|
20636
|
-
(name) => distribution.modules.includes(name) && !targets.some((target) => target.name === name) && !(clangImportedModules.has(name) && !swiftImportedModules.has(name) &&
|
|
21058
|
+
(name) => distribution.modules.includes(name) && !targets.some((target) => target.name === name) && !(clangImportedModules.has(name) && !swiftImportedModules.has(name) && existsSync9(
|
|
20637
21059
|
path33.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name)
|
|
20638
21060
|
))
|
|
20639
21061
|
);
|
|
@@ -20739,6 +21161,7 @@ ${entry}`);
|
|
|
20739
21161
|
files.set(destination, Buffer.from(bytes, "base64"));
|
|
20740
21162
|
}
|
|
20741
21163
|
const targetToolset = nativeToolset || native.size > 0;
|
|
21164
|
+
let usesObjcPrebuilt = false;
|
|
20742
21165
|
if (targetToolset) {
|
|
20743
21166
|
const nativeToolsetFlags = [
|
|
20744
21167
|
...headerAliasFlags,
|
|
@@ -20759,6 +21182,7 @@ ${entry}`);
|
|
|
20759
21182
|
[...native.keys()],
|
|
20760
21183
|
objcPrebuiltStage
|
|
20761
21184
|
) : [];
|
|
21185
|
+
usesObjcPrebuilt = prebuiltCompiler.length > 0;
|
|
20762
21186
|
files.set(
|
|
20763
21187
|
clangWrapper2,
|
|
20764
21188
|
[
|
|
@@ -21067,17 +21491,39 @@ package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.
|
|
|
21067
21491
|
(name) => !nativePrerequisiteSet.has(name)
|
|
21068
21492
|
);
|
|
21069
21493
|
const nativeTargetUnitCount = /* @__PURE__ */ new Map();
|
|
21494
|
+
const nativeTargetSources = /* @__PURE__ */ new Map();
|
|
21070
21495
|
for (const target of manifestTargets)
|
|
21071
|
-
if (target.sources?.length)
|
|
21496
|
+
if (target.sources?.length) {
|
|
21072
21497
|
nativeTargetUnitCount.set(target.name, target.sources.length);
|
|
21498
|
+
nativeTargetSources.set(target.name, target.sources);
|
|
21499
|
+
}
|
|
21073
21500
|
for (const [name, plan] of native) {
|
|
21074
|
-
if (!plan.mixed && plan.sources.length > 0)
|
|
21075
|
-
|
|
21076
|
-
|
|
21501
|
+
if (!plan.mixed && plan.sources.length > 0) {
|
|
21502
|
+
const sources = plan.clang?.sources ?? plan.sources;
|
|
21503
|
+
nativeTargetUnitCount.set(name, sources.length);
|
|
21504
|
+
nativeTargetSources.set(name, sources);
|
|
21505
|
+
}
|
|
21506
|
+
for (const group of plan.groups ?? []) {
|
|
21077
21507
|
nativeTargetUnitCount.set(group.name, group.sources.length);
|
|
21078
|
-
|
|
21508
|
+
nativeTargetSources.set(group.name, group.sources);
|
|
21509
|
+
}
|
|
21510
|
+
if (plan.late && !plan.groups?.length) {
|
|
21079
21511
|
nativeTargetUnitCount.set(plan.late.name, plan.sources.length);
|
|
21512
|
+
nativeTargetSources.set(plan.late.name, plan.lateSources);
|
|
21513
|
+
}
|
|
21080
21514
|
}
|
|
21515
|
+
const nativeStageObjects = /* @__PURE__ */ new Map();
|
|
21516
|
+
const recordStageObjects = (stageTarget, members) => {
|
|
21517
|
+
const objects = [];
|
|
21518
|
+
for (const member of members) {
|
|
21519
|
+
const sources = nativeTargetSources.get(member);
|
|
21520
|
+
if (!sources || sources.length === 0) return stageTarget;
|
|
21521
|
+
for (const source of sources)
|
|
21522
|
+
objects.push(path33.join(`${member}.build`, `${source}.o`));
|
|
21523
|
+
}
|
|
21524
|
+
nativeStageObjects.set(stageTarget, objects);
|
|
21525
|
+
return stageTarget;
|
|
21526
|
+
};
|
|
21081
21527
|
const MAX_NATIVE_STAGE_UNITS = 250;
|
|
21082
21528
|
const chunkNativeStageTargets = (prefix, names) => {
|
|
21083
21529
|
if (names.length === 0) return [];
|
|
@@ -21086,7 +21532,7 @@ package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.
|
|
|
21086
21532
|
0
|
|
21087
21533
|
);
|
|
21088
21534
|
if (names.length === 1 || total <= MAX_NATIVE_STAGE_UNITS)
|
|
21089
|
-
return [buildProduct(prefix, names)];
|
|
21535
|
+
return [recordStageObjects(buildProduct(prefix, names), names)];
|
|
21090
21536
|
const chunks = [];
|
|
21091
21537
|
let current = [];
|
|
21092
21538
|
let count = 0;
|
|
@@ -21101,7 +21547,9 @@ package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.
|
|
|
21101
21547
|
count += size;
|
|
21102
21548
|
}
|
|
21103
21549
|
if (current.length > 0) chunks.push(current);
|
|
21104
|
-
return chunks.map(
|
|
21550
|
+
return chunks.map(
|
|
21551
|
+
(members, index) => recordStageObjects(buildProduct(`${prefix}${index + 1}`, members), members)
|
|
21552
|
+
);
|
|
21105
21553
|
};
|
|
21106
21554
|
const nativePrerequisiteStageTargets = chunkNativeStageTargets(
|
|
21107
21555
|
"PeachHeaderNativePrereqs",
|
|
@@ -21112,12 +21560,12 @@ package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.
|
|
|
21112
21560
|
remainingNativeBuildTargets
|
|
21113
21561
|
);
|
|
21114
21562
|
files.set(manifestPath, manifest);
|
|
21115
|
-
syncSwiftTree(layout2.root, files);
|
|
21563
|
+
syncSwiftTree(layout2.root, files, alreadySynced);
|
|
21116
21564
|
if (layout2.multi)
|
|
21117
21565
|
for (const target of targets)
|
|
21118
21566
|
mkdirSync8(path33.join(layout2.root, target.path), { recursive: true });
|
|
21119
21567
|
const clangWrapper = path33.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
|
|
21120
|
-
if (files.has(clangWrapper) && (
|
|
21568
|
+
if (files.has(clangWrapper) && (statSync5(clangWrapper).mode & 4095) !== 493)
|
|
21121
21569
|
chmodSync3(clangWrapper, 493);
|
|
21122
21570
|
return {
|
|
21123
21571
|
...nativePrerequisiteStageTargets.length ? { nativePrerequisiteTargets: nativePrerequisiteStageTargets } : {},
|
|
@@ -21127,7 +21575,9 @@ package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.
|
|
|
21127
21575
|
targetFailures,
|
|
21128
21576
|
generatedOwners,
|
|
21129
21577
|
targetToolset,
|
|
21130
|
-
headerCompiler
|
|
21578
|
+
headerCompiler,
|
|
21579
|
+
usesObjcPrebuilt,
|
|
21580
|
+
nativeStageObjects
|
|
21131
21581
|
};
|
|
21132
21582
|
}
|
|
21133
21583
|
function streamText(value) {
|
|
@@ -21285,12 +21735,12 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
21285
21735
|
encoding: "utf8"
|
|
21286
21736
|
})) {
|
|
21287
21737
|
try {
|
|
21288
|
-
bytes +=
|
|
21738
|
+
bytes += statSync5(path33.join(directory, "artifact", file)).size;
|
|
21289
21739
|
} catch (error) {
|
|
21290
21740
|
if (!vanished(error)) throw error;
|
|
21291
21741
|
}
|
|
21292
21742
|
}
|
|
21293
|
-
entries2.push({ directory, used:
|
|
21743
|
+
entries2.push({ directory, used: statSync5(directory).mtimeMs, bytes });
|
|
21294
21744
|
} catch (error) {
|
|
21295
21745
|
if (!vanished(error)) throw error;
|
|
21296
21746
|
}
|
|
@@ -21305,7 +21755,7 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
21305
21755
|
`${RETIRED_PREFIX}${process.pid}-${path33.basename(entry.directory)}`
|
|
21306
21756
|
);
|
|
21307
21757
|
try {
|
|
21308
|
-
if (
|
|
21758
|
+
if (statSync5(entry.directory).mtimeMs !== entry.used) continue;
|
|
21309
21759
|
renameSync5(entry.directory, retired);
|
|
21310
21760
|
} catch (error) {
|
|
21311
21761
|
if (vanished(error)) continue;
|
|
@@ -21445,10 +21895,10 @@ ${dependencies}
|
|
|
21445
21895
|
const sourceDir = path33.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
|
|
21446
21896
|
mkdirSync8(sourceDir, { recursive: true });
|
|
21447
21897
|
const manifestPath = path33.join(linkRoot, "Package.swift");
|
|
21448
|
-
if (!
|
|
21898
|
+
if (!existsSync9(manifestPath) || readFileSync16(manifestPath, "utf8") !== manifest)
|
|
21449
21899
|
writeFileSync8(manifestPath, manifest);
|
|
21450
21900
|
const source = path33.join(sourceDir, "Link.swift");
|
|
21451
|
-
if (!
|
|
21901
|
+
if (!existsSync9(source)) writeFileSync8(source, "");
|
|
21452
21902
|
}
|
|
21453
21903
|
function frameworkLinkClosure(scratch, roots) {
|
|
21454
21904
|
const suffix = `${WASM_TRIPLE}-release`;
|
|
@@ -21528,7 +21978,7 @@ function frameworkLinkClosure(scratch, roots) {
|
|
|
21528
21978
|
owners.set(file, name);
|
|
21529
21979
|
if (seen.has(file)) continue;
|
|
21530
21980
|
seen.add(file);
|
|
21531
|
-
if (!
|
|
21981
|
+
if (!existsSync9(file))
|
|
21532
21982
|
throw new Error(`swift-compile: framework object ${file} was not built`);
|
|
21533
21983
|
files.push(file);
|
|
21534
21984
|
}
|
|
@@ -21544,7 +21994,7 @@ function frameworkLinkClosure(scratch, roots) {
|
|
|
21544
21994
|
};
|
|
21545
21995
|
}
|
|
21546
21996
|
function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
|
|
21547
|
-
if (!
|
|
21997
|
+
if (!existsSync9(modulesDir)) return;
|
|
21548
21998
|
const folded = new Set([...keep].map((name) => name.toLowerCase()));
|
|
21549
21999
|
for (const name of readdirSync6(modulesDir)) {
|
|
21550
22000
|
const dot = name.indexOf(".");
|
|
@@ -21567,7 +22017,7 @@ var frameworkProductsReceiptSchema = object({
|
|
|
21567
22017
|
});
|
|
21568
22018
|
function readFrameworkProductsReceipt(scratch, receiptKey) {
|
|
21569
22019
|
const receiptFile = path33.join(scratch, "products-ready", `${receiptKey}.json`);
|
|
21570
|
-
if (!
|
|
22020
|
+
if (!existsSync9(receiptFile)) return null;
|
|
21571
22021
|
let parsed;
|
|
21572
22022
|
try {
|
|
21573
22023
|
parsed = parse(
|
|
@@ -21579,11 +22029,11 @@ function readFrameworkProductsReceipt(scratch, receiptKey) {
|
|
|
21579
22029
|
}
|
|
21580
22030
|
const archive = path33.join(scratch, "lib");
|
|
21581
22031
|
const archiveStamp = path33.join(archive, ".receipt");
|
|
21582
|
-
const archiveMatches =
|
|
21583
|
-
if (!
|
|
21584
|
-
for (const [object2] of parsed.archived) if (!
|
|
21585
|
-
for (const file of parsed.providers) if (!
|
|
21586
|
-
for (const file of parsed.moduleMaps) if (!
|
|
22032
|
+
const archiveMatches = existsSync9(archiveStamp) && readFileSync16(archiveStamp, "utf8") === receiptKey;
|
|
22033
|
+
if (!existsSync9(parsed.modules)) return null;
|
|
22034
|
+
for (const [object2] of parsed.archived) if (!existsSync9(object2)) return null;
|
|
22035
|
+
for (const file of parsed.providers) if (!existsSync9(file)) return null;
|
|
22036
|
+
for (const file of parsed.moduleMaps) if (!existsSync9(file)) return null;
|
|
21587
22037
|
if (!archiveMatches) {
|
|
21588
22038
|
rmSync7(archive, { recursive: true, force: true });
|
|
21589
22039
|
mkdirSync8(archive, { recursive: true });
|
|
@@ -21591,8 +22041,8 @@ function readFrameworkProductsReceipt(scratch, receiptKey) {
|
|
|
21591
22041
|
symlinkSync2(object2, path33.join(scratch, rel));
|
|
21592
22042
|
writeFileSync8(archiveStamp, receiptKey);
|
|
21593
22043
|
}
|
|
21594
|
-
for (const file of parsed.objects) if (!
|
|
21595
|
-
for (const file of parsed.lazyObjects) if (!
|
|
22044
|
+
for (const file of parsed.objects) if (!existsSync9(file)) return null;
|
|
22045
|
+
for (const file of parsed.lazyObjects) if (!existsSync9(file)) return null;
|
|
21596
22046
|
return {
|
|
21597
22047
|
root: scratch,
|
|
21598
22048
|
modules: parsed.modules,
|
|
@@ -21716,7 +22166,7 @@ async function buildFrameworkProducts(scratch, args) {
|
|
|
21716
22166
|
const constantsDir = path33.join(scratch, "uniform-type-constants");
|
|
21717
22167
|
const constantsStamp = path33.join(constantsDir, ".complete");
|
|
21718
22168
|
const object2 = path33.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
|
|
21719
|
-
if (!
|
|
22169
|
+
if (!existsSync9(constantsStamp) || readFileSync16(constantsStamp, "utf8") !== args.frameworkKey) {
|
|
21720
22170
|
rmSync7(constantsDir, { recursive: true, force: true });
|
|
21721
22171
|
mkdirSync8(constantsDir);
|
|
21722
22172
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
@@ -21754,7 +22204,7 @@ async function buildFrameworkProducts(scratch, args) {
|
|
|
21754
22204
|
}
|
|
21755
22205
|
const providerDir = path33.join(scratch, "darwin-records");
|
|
21756
22206
|
const providerStamp = path33.join(providerDir, ".complete");
|
|
21757
|
-
if (!
|
|
22207
|
+
if (!existsSync9(providerStamp) || readFileSync16(providerStamp, "utf8") !== args.frameworkKey) {
|
|
21758
22208
|
rmSync7(providerDir, { recursive: true, force: true });
|
|
21759
22209
|
mkdirSync8(providerDir);
|
|
21760
22210
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
@@ -21861,7 +22311,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
|
|
|
21861
22311
|
};
|
|
21862
22312
|
const staged = slots.find((slot) => swiftFrameworkSlotKey(slot) === frameworkKey);
|
|
21863
22313
|
if (staged) return withSwiftRootLock(staged, run2(staged), signal);
|
|
21864
|
-
const built = new Map(slots.map((slot) => [slot,
|
|
22314
|
+
const built = new Map(slots.map((slot) => [slot, statSync5(slot).mtimeMs]));
|
|
21865
22315
|
const own = (slot) => swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN) === moduleRoot;
|
|
21866
22316
|
const inputs = new Map(
|
|
21867
22317
|
swiftModuleInputFiles(moduleRoot).map((file) => [
|
|
@@ -21876,7 +22326,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
|
|
|
21876
22326
|
for (const [file, contents2] of inputs) {
|
|
21877
22327
|
try {
|
|
21878
22328
|
const candidate = path33.join(source, file);
|
|
21879
|
-
if (
|
|
22329
|
+
if (statSync5(candidate).size !== contents2.length || !readFileSync16(candidate).equals(contents2))
|
|
21880
22330
|
changes++;
|
|
21881
22331
|
} catch (error) {
|
|
21882
22332
|
if (!vanished(error)) throw error;
|
|
@@ -21931,7 +22381,7 @@ function mirrorTree2(source, target, skip) {
|
|
|
21931
22381
|
if (existing) rmSync7(to, { recursive: true, force: true });
|
|
21932
22382
|
symlinkSync2(link, to);
|
|
21933
22383
|
} else {
|
|
21934
|
-
const stat =
|
|
22384
|
+
const stat = statSync5(from);
|
|
21935
22385
|
if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs || readFileSync16(from).equals(readFileSync16(to))))
|
|
21936
22386
|
continue;
|
|
21937
22387
|
if (existing) rmSync7(to, { recursive: true, force: true });
|
|
@@ -21972,7 +22422,7 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
|
21972
22422
|
if (!file.startsWith("../")) continue;
|
|
21973
22423
|
const from = path33.resolve(moduleRoot, file);
|
|
21974
22424
|
const to = path33.resolve(stagedModule, file);
|
|
21975
|
-
if (
|
|
22425
|
+
if (existsSync9(to) && readFileSync16(from).equals(readFileSync16(to))) continue;
|
|
21976
22426
|
mkdirSync8(path33.dirname(to), { recursive: true });
|
|
21977
22427
|
copyFileSync2(from, to);
|
|
21978
22428
|
}
|
|
@@ -21980,7 +22430,7 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
|
21980
22430
|
throw new Error("Swift staged framework source differs from the caller");
|
|
21981
22431
|
const modules = path33.join(staged, "node_modules");
|
|
21982
22432
|
const target = realpathSync6(path33.join(moduleRoot, "../../node_modules"));
|
|
21983
|
-
if (!
|
|
22433
|
+
if (!existsSync9(modules) || readlinkSync(modules) !== target) {
|
|
21984
22434
|
rmSync7(modules, { recursive: true, force: true });
|
|
21985
22435
|
symlinkSync2(target, modules);
|
|
21986
22436
|
}
|
|
@@ -21998,7 +22448,7 @@ ${args.frameworkKey}
|
|
|
21998
22448
|
hash.update("package-host-macros\n" + JSON.stringify(args.packageHostMacros));
|
|
21999
22449
|
if (!args.prebuilt) return hash.digest("hex");
|
|
22000
22450
|
const statOf = (file) => {
|
|
22001
|
-
const stat =
|
|
22451
|
+
const stat = statSync5(file, { bigint: true });
|
|
22002
22452
|
return `${stat.size}:${stat.mtimeNs}`;
|
|
22003
22453
|
};
|
|
22004
22454
|
for (const object2 of args.prebuilt.objects)
|
|
@@ -22037,7 +22487,7 @@ function retireSwiftLinkTargets(retired) {
|
|
|
22037
22487
|
rmSync7(path33.join(retired, name), { recursive: true, force: true });
|
|
22038
22488
|
}
|
|
22039
22489
|
const releaseLink = path33.join(retired, "release");
|
|
22040
|
-
if (!
|
|
22490
|
+
if (!existsSync9(releaseLink)) return;
|
|
22041
22491
|
const releaseDir = realpathSync6(releaseLink);
|
|
22042
22492
|
for (const entry of readdirSync6(releaseDir, { withFileTypes: true })) {
|
|
22043
22493
|
const targetPath = path33.join(releaseDir, entry.name);
|
|
@@ -22066,7 +22516,7 @@ ${stamp}`;
|
|
|
22066
22516
|
writeFileSync8(receipt, `${combined}
|
|
22067
22517
|
`);
|
|
22068
22518
|
const retired = path33.join(root, ".build");
|
|
22069
|
-
if (previous === combined || !
|
|
22519
|
+
if (previous === combined || !existsSync9(retired)) return false;
|
|
22070
22520
|
const [previousBase] = previous?.split("\n") ?? [];
|
|
22071
22521
|
if (preserveClangObjects && previousBase === baseStamp) {
|
|
22072
22522
|
retireSwiftLinkTargets(retired);
|
|
@@ -22095,7 +22545,7 @@ async function compileSwiftProjectOnce(sources, options) {
|
|
|
22095
22545
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
22096
22546
|
const mirrorDistribution = options.linkOnly || options.project ? null : distribution;
|
|
22097
22547
|
if (distribution) refreshSwiftCacheHold(moduleRoot);
|
|
22098
|
-
const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-
|
|
22548
|
+
const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-KK3VRVOF.mjs")).useSwiftPackagePrebuilts(
|
|
22099
22549
|
sources,
|
|
22100
22550
|
moduleRoot,
|
|
22101
22551
|
options.toolchainBin
|
|
@@ -22109,7 +22559,7 @@ async function compileSwiftProjectOnce(sources, options) {
|
|
|
22109
22559
|
multi: compileTargets(input).length > 0
|
|
22110
22560
|
};
|
|
22111
22561
|
const sdkModule = options.sdkModule && !options.linkOnly;
|
|
22112
|
-
const sdkImage = sdkModule ? await (await import("./swift-sdk-image-
|
|
22562
|
+
const sdkImage = sdkModule ? await (await import("./swift-sdk-image-ZBA4EYBW.mjs")).buildSwiftSdkImage(
|
|
22113
22563
|
moduleRoot,
|
|
22114
22564
|
!!guestGraph,
|
|
22115
22565
|
distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
|
|
@@ -22225,7 +22675,7 @@ ${cap}` : "";
|
|
|
22225
22675
|
}
|
|
22226
22676
|
}
|
|
22227
22677
|
const swift = path33.join(options.toolchainBin, "swift");
|
|
22228
|
-
if (!
|
|
22678
|
+
if (!existsSync9(swift)) {
|
|
22229
22679
|
throw new Error(
|
|
22230
22680
|
`swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
|
|
22231
22681
|
);
|
|
@@ -22238,8 +22688,8 @@ ${cap}` : "";
|
|
|
22238
22688
|
work,
|
|
22239
22689
|
unoptimized
|
|
22240
22690
|
);
|
|
22241
|
-
const baseBuildEnv = {
|
|
22242
|
-
...options.project
|
|
22691
|
+
const baseBuildEnv = options.project?.env ? {
|
|
22692
|
+
...options.project.env,
|
|
22243
22693
|
// shipped host plugins resolve against the selected compiler's runtime.
|
|
22244
22694
|
...process.platform === "linux" ? {
|
|
22245
22695
|
LD_LIBRARY_PATH: [
|
|
@@ -22249,7 +22699,7 @@ ${cap}` : "";
|
|
|
22249
22699
|
].filter(Boolean).join(":")
|
|
22250
22700
|
} : {},
|
|
22251
22701
|
PEACH_DEFER_WASM_LINK: "1"
|
|
22252
|
-
};
|
|
22702
|
+
} : swiftCompilerBaseEnv(options.toolchainBin, process.env);
|
|
22253
22703
|
const {
|
|
22254
22704
|
frameworkRoot,
|
|
22255
22705
|
compileFrameworkRoot,
|
|
@@ -22345,7 +22795,7 @@ ${cap}` : "";
|
|
|
22345
22795
|
writeSwiftAutolinkLinker(
|
|
22346
22796
|
root,
|
|
22347
22797
|
options.toolchainBin,
|
|
22348
|
-
|
|
22798
|
+
existsSync9(productFile) ? [
|
|
22349
22799
|
parse(
|
|
22350
22800
|
swiftFrameworkProductSchema,
|
|
22351
22801
|
JSON.parse(readFileSync16(productFile, "utf8"))
|
|
@@ -22393,7 +22843,11 @@ ${cap}` : "";
|
|
|
22393
22843
|
} : {
|
|
22394
22844
|
...buildOptions,
|
|
22395
22845
|
temporaryDirectory,
|
|
22396
|
-
env: {
|
|
22846
|
+
env: {
|
|
22847
|
+
...buildOptions.env,
|
|
22848
|
+
...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
|
|
22849
|
+
...compiler
|
|
22850
|
+
}
|
|
22397
22851
|
};
|
|
22398
22852
|
const unprepared = preparation.targetFailures.map(
|
|
22399
22853
|
(failure) => `error: target ${failure}`
|
|
@@ -22440,10 +22894,18 @@ ${cap}` : "";
|
|
|
22440
22894
|
// the mirror finds a changed sdk header's readers in their
|
|
22441
22895
|
// dependency files, which omit system headers by default
|
|
22442
22896
|
...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
|
|
22443
|
-
// the link strips debug info, so none is generated (as for the framework)
|
|
22897
|
+
// the link strips debug info, so none is generated (as for the framework).
|
|
22898
|
+
// keep -num-threads fixed across caller core caps so llbuild does not
|
|
22899
|
+
// rebuild every target when callers alternate --cores, and bound backend
|
|
22900
|
+
// fan-out under high -j.
|
|
22444
22901
|
"-Xswiftc",
|
|
22445
22902
|
"-gnone",
|
|
22446
|
-
...incrementalPreview ? [] : [
|
|
22903
|
+
...incrementalPreview ? [] : [
|
|
22904
|
+
"-Xswiftc",
|
|
22905
|
+
"-num-threads",
|
|
22906
|
+
"-Xswiftc",
|
|
22907
|
+
String(perFile ? 1 : Math.min(8, os4.availableParallelism()))
|
|
22908
|
+
],
|
|
22447
22909
|
...swiftReproducibleBuildFlags([
|
|
22448
22910
|
[path33.dirname(options.toolchainBin), "toolchain"],
|
|
22449
22911
|
[compileFrameworkRoot, "framework"],
|
|
@@ -22482,7 +22944,7 @@ ${cap}` : "";
|
|
|
22482
22944
|
];
|
|
22483
22945
|
const linked = builtArtifact(layout2);
|
|
22484
22946
|
rmSync7(path33.join(root, ".peach-link.rsp"), { force: true });
|
|
22485
|
-
if (options.linkOnly ||
|
|
22947
|
+
if (options.linkOnly || existsSync9(linked) && statSync5(linked).size <= 8)
|
|
22486
22948
|
rmSync7(linked, { force: true });
|
|
22487
22949
|
report("compiling and linking Swift modules");
|
|
22488
22950
|
const frameworkInterfaces = /* @__PURE__ */ new Map();
|
|
@@ -22520,13 +22982,13 @@ ${cap}` : "";
|
|
|
22520
22982
|
const frameworkInterface = (name) => {
|
|
22521
22983
|
if (frameworkInterfaces.has(name)) return frameworkInterfaces.get(name);
|
|
22522
22984
|
const source = distribution ? path33.join(frameworkRoot, "modules", `${name}-Swift.h`) : prebuilt.objcHeaders.get(name);
|
|
22523
|
-
if (!source || !
|
|
22985
|
+
if (!source || !existsSync9(source)) {
|
|
22524
22986
|
frameworkInterfaces.set(name, null);
|
|
22525
22987
|
return null;
|
|
22526
22988
|
}
|
|
22527
22989
|
const headers = path33.join(sdkFrameworks, `${name}.framework/Headers`);
|
|
22528
22990
|
const declared = /* @__PURE__ */ new Set();
|
|
22529
|
-
if (
|
|
22991
|
+
if (existsSync9(headers)) {
|
|
22530
22992
|
for (const file of readdirSync6(headers, {
|
|
22531
22993
|
recursive: true,
|
|
22532
22994
|
encoding: "utf8"
|
|
@@ -22564,12 +23026,12 @@ ${cap}` : "";
|
|
|
22564
23026
|
const value = {
|
|
22565
23027
|
file: path33.join(root, ".build/peach-framework-objc", `${name}-Swift.h`),
|
|
22566
23028
|
header,
|
|
22567
|
-
module:
|
|
23029
|
+
module: existsSync9(headers)
|
|
22568
23030
|
};
|
|
22569
23031
|
frameworkInterfaces.set(name, value);
|
|
22570
23032
|
writeBuildFile(
|
|
22571
23033
|
value.file,
|
|
22572
|
-
(
|
|
23034
|
+
(existsSync9(path33.join(headers, `${name}.h`)) ? `#import <${name}/${name}.h>
|
|
22573
23035
|
` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
|
|
22574
23036
|
);
|
|
22575
23037
|
return value;
|
|
@@ -22618,29 +23080,40 @@ ${cap}` : "";
|
|
|
22618
23080
|
}))
|
|
22619
23081
|
];
|
|
22620
23082
|
const checkpoints = path33.join(root, ".build", "peach-product-checkpoints");
|
|
23083
|
+
const buildDbExists = existsSync9(path33.join(root, ".build", "build.db"));
|
|
23084
|
+
const releaseDir = path33.dirname(linked);
|
|
22621
23085
|
for (const { target, producers } of stages) {
|
|
23086
|
+
if (!options.project && producers.length === 0 && buildDbExists) {
|
|
23087
|
+
const expectedObjects = preparation.nativeStageObjects.get(target);
|
|
23088
|
+
if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
|
|
23089
|
+
(relative) => statSync5(path33.join(releaseDir, relative), {
|
|
23090
|
+
throwIfNoEntry: false
|
|
23091
|
+
})?.isFile()
|
|
23092
|
+
))
|
|
23093
|
+
continue;
|
|
23094
|
+
}
|
|
22622
23095
|
const receipt = path33.join(
|
|
22623
23096
|
checkpoints,
|
|
22624
23097
|
createHash18("sha256").update(target).digest("hex")
|
|
22625
23098
|
);
|
|
22626
23099
|
const headers = producers.map(headerPaths);
|
|
22627
23100
|
for (const header of headers)
|
|
22628
|
-
if (
|
|
23101
|
+
if (existsSync9(header.original)) publishHeader(header);
|
|
22629
23102
|
const fingerprint = () => {
|
|
22630
23103
|
const digest = createHash18("sha256").update(recipe);
|
|
22631
23104
|
for (const { original, emitted } of headers) {
|
|
22632
|
-
if (!
|
|
23105
|
+
if (!existsSync9(original) || !existsSync9(emitted)) return;
|
|
22633
23106
|
digest.update(
|
|
22634
23107
|
createHash18("sha256").update(readFileSync16(emitted)).digest()
|
|
22635
23108
|
);
|
|
22636
23109
|
}
|
|
22637
23110
|
return digest.digest("hex");
|
|
22638
23111
|
};
|
|
22639
|
-
if (!options.project &&
|
|
23112
|
+
if (!options.project && existsSync9(receipt) && readFileSync16(receipt, "utf8") === fingerprint())
|
|
22640
23113
|
continue;
|
|
22641
23114
|
if (!options.project) rmSync7(receipt, { force: true });
|
|
22642
23115
|
for (const header of headers) {
|
|
22643
|
-
if (!
|
|
23116
|
+
if (!existsSync9(header.original))
|
|
22644
23117
|
rmSync7(
|
|
22645
23118
|
path33.join(
|
|
22646
23119
|
path33.dirname(linked),
|
|
@@ -22705,7 +23178,7 @@ ${cap}` : "";
|
|
|
22705
23178
|
"release",
|
|
22706
23179
|
"ModuleCache"
|
|
22707
23180
|
);
|
|
22708
|
-
if (output2.includes("was compiled with module cache path") &&
|
|
23181
|
+
if (output2.includes("was compiled with module cache path") && existsSync9(moduleCache)) {
|
|
22709
23182
|
rmSync7(moduleCache, { recursive: true, force: true });
|
|
22710
23183
|
try {
|
|
22711
23184
|
await compileApp();
|
|
@@ -22732,9 +23205,9 @@ ${cap}` : "";
|
|
|
22732
23205
|
if (options.project) endSwiftProjectProcesses(options.project);
|
|
22733
23206
|
}
|
|
22734
23207
|
if (unprepared.length) throw new Error(unprepared.join("\n"));
|
|
22735
|
-
if (!
|
|
23208
|
+
if (!existsSync9(linked)) {
|
|
22736
23209
|
const binDir = path33.dirname(linked);
|
|
22737
|
-
const found =
|
|
23210
|
+
const found = existsSync9(binDir) ? readdirSync6(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
|
|
22738
23211
|
throw new Error(
|
|
22739
23212
|
`swift-compile: the build produced no ${path33.basename(linked)} (found: ${found.join(", ") || "none"})`
|
|
22740
23213
|
);
|
|
@@ -22754,7 +23227,7 @@ ${cap}` : "";
|
|
|
22754
23227
|
resourceReferences
|
|
22755
23228
|
);
|
|
22756
23229
|
if (options.linkOnly) {
|
|
22757
|
-
if (
|
|
23230
|
+
if (statSync5(linked).size <= 8)
|
|
22758
23231
|
throw new Error("swift-compile: deferred linker produced no executable");
|
|
22759
23232
|
report("project link verified");
|
|
22760
23233
|
return;
|
|
@@ -22791,7 +23264,7 @@ ${cap}` : "";
|
|
|
22791
23264
|
if (sdkImage && binding)
|
|
22792
23265
|
sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
|
|
22793
23266
|
} else if (sdkImage) {
|
|
22794
|
-
const { buildSwiftAppModule } = await import("./swift-sdk-app-module-
|
|
23267
|
+
const { buildSwiftAppModule } = await import("./swift-sdk-app-module-TEOC7LDK.mjs");
|
|
22795
23268
|
const binding = await buildSwiftAppModule({
|
|
22796
23269
|
buildRoot: root,
|
|
22797
23270
|
toolchainBin: options.toolchainBin,
|