peachsim 0.1.2595 → 0.1.2597
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 +982 -431
- 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-J5DSQG5R.mjs → acorn-55PXV665.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-D4XFTOV2.mjs → chunk-3DRJIOHV.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-NZEHZIHZ.mjs → chunk-42RIRPTB.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-CDGSSOLF.mjs → chunk-56YYEI6C.mjs} +16 -13
- package/dist-lib/esm-chunks/{chunk-MTGZYNXH.mjs → chunk-7ECUAVIA.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-YYAPBU4L.mjs → chunk-7J65FNXI.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-FHFNRCCX.mjs → chunk-AJHFCIEU.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-G35VGABO.mjs → chunk-CKUEWEY4.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-NCMIX32U.mjs → chunk-DCL2ZEGA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3Z2POHJV.mjs → chunk-GECWNEHA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BCLZPP3O.mjs → chunk-GRGNTIO7.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-RYCGXYYL.mjs → chunk-GZD5CTG7.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5U76J6OF.mjs → chunk-HATXI62T.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-GCOZNVG7.mjs → chunk-INA4S3MF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-AEI4FOZK.mjs → chunk-IPN35TGX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-U4X644Y4.mjs → chunk-LH524OUR.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-ESKLJRT5.mjs → chunk-MMHNSEZY.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-POM7QBEW.mjs → chunk-NWLCTKBM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ZSJEHQ3R.mjs → chunk-O5FDNHDG.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-D6RI7LMX.mjs → chunk-ROFBHGEA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-LLO2FLAP.mjs → chunk-V6SI2XY7.mjs} +967 -491
- package/dist-lib/esm-chunks/{chunk-JVVPCJEO.mjs → chunk-VN7BXTMG.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-VZY2J2YJ.mjs → chunk-Y4XMEBRN.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-ZHPHHXG3.mjs → metro-layout-parser-5FUYCP6P.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-UXU6DFC3.mjs → swift-package-prebuilt-W3VMDYHC.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-25XPGJ4P.mjs → swift-sdk-app-module-ZHGBY6T7.mjs} +126 -56
- package/dist-lib/esm-chunks/{swift-sdk-image-7JKGAHEW.mjs → swift-sdk-image-2PC4PKHZ.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-KG5I2NUP.mjs → swift-sdk-image-producer-WDN6BXQL.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +981 -430
- 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 +1019 -434
- 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 +1020 -435
- package/dist-lib/swift-compile.cjs +979 -428
- 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/nativeAnimMirrorContract.d.ts +0 -2
- package/package.json +1 -1
- package/src/one-native-controls-package.ts +32 -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 +25 -3
- 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 +13 -9
- 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.2597 | (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-IPN35TGX.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-GZD5CTG7.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-MMHNSEZY.mjs";
|
|
64
64
|
import {
|
|
65
65
|
rnxPublicBrand
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-3DRJIOHV.mjs";
|
|
67
67
|
import {
|
|
68
68
|
isRecord
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-INA4S3MF.mjs";
|
|
70
70
|
import {
|
|
71
71
|
__publicField
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-NWLCTKBM.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") {
|
|
@@ -12671,7 +12822,10 @@ function linkGuestImages(options) {
|
|
|
12671
12822
|
}
|
|
12672
12823
|
const members = archives.get(artifact.path);
|
|
12673
12824
|
if (!members) continue;
|
|
12674
|
-
const
|
|
12825
|
+
const listing = execFileSync7(llvmAr, ["t", artifact.path], {
|
|
12826
|
+
encoding: "utf8"
|
|
12827
|
+
}).trimEnd();
|
|
12828
|
+
const listed = listing ? listing.split("\n") : [];
|
|
12675
12829
|
if (listed.length !== members.length || new Set(listed).size !== listed.length || members.some(
|
|
12676
12830
|
(member, i) => listed[i] !== member.name || path20.basename(member.name) !== member.name
|
|
12677
12831
|
))
|
|
@@ -12700,6 +12854,10 @@ function linkGuestImages(options) {
|
|
|
12700
12854
|
const response = path20.join(memberDir, "members.rsp");
|
|
12701
12855
|
fs9.writeFileSync(response, inputs.map((input) => JSON.stringify(input)).join(" "));
|
|
12702
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
|
+
);
|
|
12703
12861
|
replacements.set(artifact.path, output);
|
|
12704
12862
|
}
|
|
12705
12863
|
const compileLedger = (name, source) => {
|
|
@@ -12831,7 +12989,8 @@ function linkGuestImages(options) {
|
|
|
12831
12989
|
remapGuestLinkPlan(plan, replacements),
|
|
12832
12990
|
finalArgs,
|
|
12833
12991
|
fs9.readFileSync(finalWhy, "utf8"),
|
|
12834
|
-
finalTrace
|
|
12992
|
+
finalTrace,
|
|
12993
|
+
finalArchives
|
|
12835
12994
|
);
|
|
12836
12995
|
const original = new Map([...replacements].map(([before2, after2]) => [after2, before2]));
|
|
12837
12996
|
const key = (item) => JSON.stringify([original.get(item.artifact) ?? item.artifact, item.member]);
|
|
@@ -12864,12 +13023,25 @@ ${changed.join("\n")}`
|
|
|
12864
13023
|
])
|
|
12865
13024
|
);
|
|
12866
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
|
+
}
|
|
12867
13037
|
options.onSplitInputs({
|
|
12868
13038
|
appObjects,
|
|
12869
13039
|
appSections,
|
|
12870
13040
|
sdkObjects,
|
|
12871
13041
|
lazyFunctions: ledger.appLazyFunctions ?? [],
|
|
12872
|
-
dyldSymbols: ledger.dyldSymbols
|
|
13042
|
+
dyldSymbols: ledger.dyldSymbols,
|
|
13043
|
+
appReferencedSymbols,
|
|
13044
|
+
appDefinedSymbols
|
|
12873
13045
|
});
|
|
12874
13046
|
}
|
|
12875
13047
|
return selected;
|
|
@@ -13509,12 +13681,12 @@ function linkPrunedGuestImages(options) {
|
|
|
13509
13681
|
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
13510
13682
|
import { createHash as createHash12 } from "node:crypto";
|
|
13511
13683
|
import {
|
|
13512
|
-
existsSync as
|
|
13684
|
+
existsSync as existsSync3,
|
|
13513
13685
|
mkdirSync as mkdirSync4,
|
|
13514
13686
|
readFileSync as readFileSync11,
|
|
13515
13687
|
realpathSync as realpathSync2,
|
|
13516
13688
|
renameSync as renameSync3,
|
|
13517
|
-
statSync,
|
|
13689
|
+
statSync as statSync2,
|
|
13518
13690
|
writeFileSync as writeFileSync5
|
|
13519
13691
|
} from "node:fs";
|
|
13520
13692
|
import path21 from "node:path";
|
|
@@ -13598,11 +13770,11 @@ Promise.all(Array.from({ length: jobs }, run))
|
|
|
13598
13770
|
})
|
|
13599
13771
|
`;
|
|
13600
13772
|
function clangProducerStamp(file) {
|
|
13601
|
-
const stat =
|
|
13773
|
+
const stat = statSync2(file, { bigint: true });
|
|
13602
13774
|
return [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(":");
|
|
13603
13775
|
}
|
|
13604
13776
|
function clangBinaryStamp(file) {
|
|
13605
|
-
const stat =
|
|
13777
|
+
const stat = statSync2(file, { bigint: true });
|
|
13606
13778
|
return [file, stat.size, stat.mtimeNs].join(":");
|
|
13607
13779
|
}
|
|
13608
13780
|
function clangWrapperStamp(file) {
|
|
@@ -13650,7 +13822,7 @@ function clangArgsNeedCwd(args) {
|
|
|
13650
13822
|
}
|
|
13651
13823
|
if (includeFlags.has(arg)) {
|
|
13652
13824
|
const value = args[++i] ?? "";
|
|
13653
|
-
if (isRelativePath(value) && (value.includes("/") ||
|
|
13825
|
+
if (isRelativePath(value) && (value.includes("/") || existsSync3(value))) return true;
|
|
13654
13826
|
continue;
|
|
13655
13827
|
}
|
|
13656
13828
|
if (valueFlags.has(arg)) {
|
|
@@ -13664,7 +13836,7 @@ function clangArgsNeedCwd(args) {
|
|
|
13664
13836
|
if (arg.startsWith("-")) {
|
|
13665
13837
|
if (arg.startsWith("-include") && arg.length > 8) {
|
|
13666
13838
|
const value = arg.slice(8);
|
|
13667
|
-
if (isRelativePath(value) && (value.includes("/") ||
|
|
13839
|
+
if (isRelativePath(value) && (value.includes("/") || existsSync3(value)))
|
|
13668
13840
|
return true;
|
|
13669
13841
|
continue;
|
|
13670
13842
|
}
|
|
@@ -13693,7 +13865,7 @@ function validateClangLinkOptions(flags) {
|
|
|
13693
13865
|
}
|
|
13694
13866
|
}
|
|
13695
13867
|
function readClangLinkOptions(file, key) {
|
|
13696
|
-
if (!
|
|
13868
|
+
if (!existsSync3(file)) return;
|
|
13697
13869
|
let receipt;
|
|
13698
13870
|
try {
|
|
13699
13871
|
receipt = JSON.parse(readFileSync11(file, "utf8"));
|
|
@@ -13892,6 +14064,93 @@ function sourceGuestInputIdentities(graph, buildDirectory, objects) {
|
|
|
13892
14064
|
}
|
|
13893
14065
|
return identities;
|
|
13894
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
|
+
}
|
|
13895
14154
|
function sourceGuestRuntimeLinks(options) {
|
|
13896
14155
|
const aliases = /* @__PURE__ */ new Map();
|
|
13897
14156
|
const artifacts = /* @__PURE__ */ new Map();
|
|
@@ -13979,15 +14238,7 @@ function sourceGuestRuntimeLinks(options) {
|
|
|
13979
14238
|
for (const image of options.images) {
|
|
13980
14239
|
if (result.has(image.id)) throw new Error(`duplicate source image ${image.id}`);
|
|
13981
14240
|
const response = path21.join(options.directory, `image-${image.id}-autolink.rsp`);
|
|
13982
|
-
|
|
13983
|
-
response,
|
|
13984
|
-
image.objects.map((file) => JSON.stringify(file)).join("\n") + "\n"
|
|
13985
|
-
);
|
|
13986
|
-
const autolink = image.objects.length ? execFileSync8(
|
|
13987
|
-
path21.join(options.toolchainBin, "swift-autolink-extract"),
|
|
13988
|
-
[`@${response}`, "-o", "-"],
|
|
13989
|
-
{ encoding: "utf8" }
|
|
13990
|
-
).split("\n").map((line) => line.trim()).filter((line) => line.length > 0) : [];
|
|
14241
|
+
const autolink = readAutolinkFlags(image.objects, options.toolchainBin, response);
|
|
13991
14242
|
const links = [];
|
|
13992
14243
|
const requests = [];
|
|
13993
14244
|
const optionGroups = [
|
|
@@ -14081,13 +14332,13 @@ function logicalGuestLinkOptions(args, identities, roots) {
|
|
|
14081
14332
|
import { execFileSync as execFileSync9 } from "node:child_process";
|
|
14082
14333
|
import {
|
|
14083
14334
|
chmodSync,
|
|
14084
|
-
existsSync as
|
|
14335
|
+
existsSync as existsSync4,
|
|
14085
14336
|
mkdirSync as mkdirSync5,
|
|
14086
14337
|
readdirSync as readdirSync5,
|
|
14087
14338
|
readFileSync as readFileSync12,
|
|
14088
14339
|
realpathSync as realpathSync3,
|
|
14089
14340
|
rmSync as rmSync5,
|
|
14090
|
-
statSync as
|
|
14341
|
+
statSync as statSync3
|
|
14091
14342
|
} from "node:fs";
|
|
14092
14343
|
import path22 from "node:path";
|
|
14093
14344
|
function prepareSwiftProjectProcess(root, user) {
|
|
@@ -14129,7 +14380,7 @@ function endSwiftProjectProcesses(user) {
|
|
|
14129
14380
|
function projectOutputFile(root, file, user) {
|
|
14130
14381
|
const real = realpathSync3(file);
|
|
14131
14382
|
const base = realpathSync3(root);
|
|
14132
|
-
const stat =
|
|
14383
|
+
const stat = statSync3(real);
|
|
14133
14384
|
if (!real.startsWith(base + path22.sep) || !stat.isFile() || stat.uid !== user.uid) {
|
|
14134
14385
|
throw new Error(`swift-compile: project output ${file} is not a file of its build`);
|
|
14135
14386
|
}
|
|
@@ -14412,7 +14663,7 @@ async function compileGuestLink(options) {
|
|
|
14412
14663
|
};
|
|
14413
14664
|
const sdk = options.sdkImage;
|
|
14414
14665
|
const sdkCallers = sdk?.sdkInterface.guestCallers;
|
|
14415
|
-
const sdkObjects = sdk ? (await import("./swift-sdk-image-
|
|
14666
|
+
const sdkObjects = sdk ? (await import("./swift-sdk-image-2PC4PKHZ.mjs")).readSwiftSdkManifestIndex(sdk).guestObjects : void 0;
|
|
14416
14667
|
if (sdk && (!sdkCallers || !sdkObjects))
|
|
14417
14668
|
throw new Error("the SDK image has no guest link manifest");
|
|
14418
14669
|
const result = linkPrunedGuestImages({
|
|
@@ -14706,7 +14957,7 @@ async function compileGuestLink(options) {
|
|
|
14706
14957
|
linkSwiftAppModule,
|
|
14707
14958
|
readSwiftSdkUsage,
|
|
14708
14959
|
swiftSdkProjectionSpans
|
|
14709
|
-
} = await import("./swift-sdk-app-module-
|
|
14960
|
+
} = await import("./swift-sdk-app-module-ZHGBY6T7.mjs");
|
|
14710
14961
|
const project = options.project;
|
|
14711
14962
|
const work = project ? mkdtempSync2(path24.join(directory, "app-module-")) : path24.join(directory, "app-module");
|
|
14712
14963
|
if (project) chownSync(work, project.uid, project.gid);
|
|
@@ -14749,6 +15000,15 @@ async function compileGuestLink(options) {
|
|
|
14749
15000
|
{ stdio: "pipe" }
|
|
14750
15001
|
);
|
|
14751
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
|
+
}
|
|
14752
15012
|
for (; ; ) {
|
|
14753
15013
|
const link = await linkSwiftAppModule({
|
|
14754
15014
|
objects: [...owners.keys()],
|
|
@@ -14760,6 +15020,7 @@ async function compileGuestLink(options) {
|
|
|
14760
15020
|
optimize: options.optimize,
|
|
14761
15021
|
layoutMap,
|
|
14762
15022
|
project,
|
|
15023
|
+
precomputedSymbols,
|
|
14763
15024
|
loweringCache: project ? void 0 : {
|
|
14764
15025
|
file: path24.join(
|
|
14765
15026
|
options.buildDirectory,
|
|
@@ -14869,13 +15130,13 @@ async function compileGuestLink(options) {
|
|
|
14869
15130
|
import { createHash as createHash14 } from "node:crypto";
|
|
14870
15131
|
import {
|
|
14871
15132
|
chmodSync as chmodSync2,
|
|
14872
|
-
existsSync as
|
|
15133
|
+
existsSync as existsSync5,
|
|
14873
15134
|
mkdirSync as mkdirSync7,
|
|
14874
15135
|
mkdtempSync as mkdtempSync3,
|
|
14875
15136
|
readFileSync as readFileSync14,
|
|
14876
15137
|
renameSync as renameSync4,
|
|
14877
15138
|
rmSync as rmSync6,
|
|
14878
|
-
statSync as
|
|
15139
|
+
statSync as statSync4,
|
|
14879
15140
|
writeFileSync as writeFileSync7
|
|
14880
15141
|
} from "node:fs";
|
|
14881
15142
|
import { createServer } from "node:http";
|
|
@@ -14937,12 +15198,12 @@ function compilerCheckpoint(root, recipe, args, header) {
|
|
|
14937
15198
|
for (const flag of args) {
|
|
14938
15199
|
if (!flag.startsWith("@")) continue;
|
|
14939
15200
|
const response = flag.slice(1);
|
|
14940
|
-
if (!path25.isAbsolute(response) || !
|
|
15201
|
+
if (!path25.isAbsolute(response) || !existsSync5(response)) return;
|
|
14941
15202
|
digest.update(readFileSync14(response));
|
|
14942
15203
|
}
|
|
14943
15204
|
for (const file of outputs) {
|
|
14944
15205
|
if (!file.startsWith(path25.join(root, ".build") + path25.sep)) return;
|
|
14945
|
-
const stat =
|
|
15206
|
+
const stat = statSync4(file, { bigint: true, throwIfNoEntry: false });
|
|
14946
15207
|
if (!stat?.isFile() || stat.size === 0n) return;
|
|
14947
15208
|
digest.update(JSON.stringify([file, String(stat.size), String(stat.mtimeNs)]));
|
|
14948
15209
|
}
|
|
@@ -14993,7 +15254,7 @@ async function withSwiftHeaderCompiler(root, toolchainBin, recipe, producers, bu
|
|
|
14993
15254
|
const receipt = path25.join(checkpoints, module);
|
|
14994
15255
|
const fingerprint = compilerCheckpoint(root, recipe, args, producer.header);
|
|
14995
15256
|
if (request.method === "PUT") {
|
|
14996
|
-
if (!fingerprint || !
|
|
15257
|
+
if (!fingerprint || !existsSync5(receipt) || readFileSync14(receipt, "utf8") !== fingerprint) {
|
|
14997
15258
|
response.writeHead(204).end();
|
|
14998
15259
|
return;
|
|
14999
15260
|
}
|
|
@@ -15174,7 +15435,7 @@ function swiftHeaderDependencies(root, files, targets, nativeTargets, producers,
|
|
|
15174
15435
|
// src/swift-icu.ts
|
|
15175
15436
|
import { execFile as execFile2 } from "node:child_process";
|
|
15176
15437
|
import { createHash as createHash15, randomUUID as randomUUID4 } from "node:crypto";
|
|
15177
|
-
import { existsSync as
|
|
15438
|
+
import { existsSync as existsSync6, readFileSync as readFileSync15 } from "node:fs";
|
|
15178
15439
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
15179
15440
|
import os2 from "node:os";
|
|
15180
15441
|
import path27 from "node:path";
|
|
@@ -15314,7 +15575,7 @@ function swiftIcuAsset(toolchainBin, sdk) {
|
|
|
15314
15575
|
}
|
|
15315
15576
|
async function load(toolchainBin, sdk) {
|
|
15316
15577
|
const swift = path27.join(toolchainBin, "swift");
|
|
15317
|
-
if (!
|
|
15578
|
+
if (!existsSync6(swift))
|
|
15318
15579
|
throw new Error(`swift-icu: no swift at ${swift} for the ${sdk} SDK's icu data`);
|
|
15319
15580
|
const { stdout: listed } = await run(swift, ["sdk", "list", ...swiftSdkOptions()], {
|
|
15320
15581
|
env: swiftEnvironment()
|
|
@@ -15403,7 +15664,7 @@ function swiftIcuPacked(icu) {
|
|
|
15403
15664
|
"swift-brotli",
|
|
15404
15665
|
swiftIcuAddress(icu)
|
|
15405
15666
|
);
|
|
15406
|
-
if (
|
|
15667
|
+
if (existsSync6(file)) return readFile(file);
|
|
15407
15668
|
const packed = Buffer.from(
|
|
15408
15669
|
swiftIcuPack(
|
|
15409
15670
|
await inflateGzip(icu.gzip),
|
|
@@ -15695,7 +15956,7 @@ var RNX_INTERNAL_CHILDREN = {
|
|
|
15695
15956
|
|
|
15696
15957
|
// cli/self-invocation.ts
|
|
15697
15958
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
15698
|
-
import { existsSync as
|
|
15959
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
15699
15960
|
import { basename as basename2, dirname as dirname2, isAbsolute, join as join2 } from "node:path";
|
|
15700
15961
|
import { fileURLToPath } from "node:url";
|
|
15701
15962
|
|
|
@@ -15706,7 +15967,7 @@ var IS_STANDALONE = typeof __SOOTSIM_STANDALONE__ !== "undefined" && __SOOTSIM_S
|
|
|
15706
15967
|
function sourceEntryPath() {
|
|
15707
15968
|
try {
|
|
15708
15969
|
const candidate = join2(dirname2(fileURLToPath(import.meta.url)), "bin.ts");
|
|
15709
|
-
return
|
|
15970
|
+
return existsSync7(candidate) ? candidate : null;
|
|
15710
15971
|
} catch {
|
|
15711
15972
|
return null;
|
|
15712
15973
|
}
|
|
@@ -15837,13 +16098,13 @@ function swiftObjCPrebuiltCompiler(clang, root, sysroot, distribution, targets,
|
|
|
15837
16098
|
}
|
|
15838
16099
|
|
|
15839
16100
|
// src/swift-reproducible.ts
|
|
15840
|
-
import { existsSync as
|
|
16101
|
+
import { existsSync as existsSync8, realpathSync as realpathSync5 } from "node:fs";
|
|
15841
16102
|
import os3 from "node:os";
|
|
15842
16103
|
import path30 from "node:path";
|
|
15843
16104
|
function canonicalHomeDir() {
|
|
15844
16105
|
const home = os3.homedir();
|
|
15845
16106
|
const dotPeach = path30.join(home, ".peach");
|
|
15846
|
-
if (
|
|
16107
|
+
if (existsSync8(dotPeach)) {
|
|
15847
16108
|
const realHome = path30.dirname(realpathSync5(dotPeach));
|
|
15848
16109
|
if (home === realHome || home.startsWith(`${realHome}${path30.sep}`)) return realHome;
|
|
15849
16110
|
}
|
|
@@ -16177,7 +16438,48 @@ function swiftBuildJobs() {
|
|
|
16177
16438
|
return Math.min(cores, memoryJobs);
|
|
16178
16439
|
}
|
|
16179
16440
|
function swiftCompilerJobs() {
|
|
16180
|
-
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;
|
|
16181
16483
|
}
|
|
16182
16484
|
function assertSwiftBuildCores() {
|
|
16183
16485
|
const admitted = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
|
|
@@ -16188,7 +16490,7 @@ function assertSwiftBuildCores() {
|
|
|
16188
16490
|
}
|
|
16189
16491
|
function swiftDistributionAt(root) {
|
|
16190
16492
|
const file = path33.join(root, SWIFT_DISTRIBUTION_MANIFEST);
|
|
16191
|
-
const stat =
|
|
16493
|
+
const stat = statSync5(file, { bigint: true, throwIfNoEntry: false });
|
|
16192
16494
|
if (!stat) return null;
|
|
16193
16495
|
const identity = `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}`;
|
|
16194
16496
|
const cached = distributionManifests.get(file);
|
|
@@ -16201,13 +16503,13 @@ var distributionManifests = /* @__PURE__ */ new Map();
|
|
|
16201
16503
|
var distributionCompileViews = /* @__PURE__ */ new WeakMap();
|
|
16202
16504
|
function swiftDistributionCompileView(moduleRoot, distribution) {
|
|
16203
16505
|
let view = distributionCompileViews.get(distribution);
|
|
16204
|
-
if (!view || !
|
|
16506
|
+
if (!view || !existsSync9(view)) {
|
|
16205
16507
|
const inputs = Object.entries(distribution.files).filter(
|
|
16206
16508
|
([file]) => file.startsWith("host/") || file === SWIFT_DISTRIBUTION_OBJC_SELECTORS
|
|
16207
16509
|
).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
|
|
16208
16510
|
const digest = createHash18("sha256").update(JSON.stringify(inputs)).digest("hex");
|
|
16209
16511
|
view = path33.join(swiftCacheDir(), "swift-sdk-views", `compile-${digest}`);
|
|
16210
|
-
if (!
|
|
16512
|
+
if (!existsSync9(view)) {
|
|
16211
16513
|
mkdirSync8(path33.dirname(view), { recursive: true });
|
|
16212
16514
|
const staging = mkdtempSync4(`${view}-`);
|
|
16213
16515
|
try {
|
|
@@ -16222,7 +16524,7 @@ function swiftDistributionCompileView(moduleRoot, distribution) {
|
|
|
16222
16524
|
try {
|
|
16223
16525
|
renameSync5(staging, view);
|
|
16224
16526
|
} catch (error) {
|
|
16225
|
-
if (!
|
|
16527
|
+
if (!existsSync9(view)) throw error;
|
|
16226
16528
|
}
|
|
16227
16529
|
} finally {
|
|
16228
16530
|
rmSync7(staging, { recursive: true, force: true });
|
|
@@ -16240,13 +16542,13 @@ function swiftModuleInterface(moduleRoot, name) {
|
|
|
16240
16542
|
if (REACH_STAGED_FRAMEWORKS.has(name)) return null;
|
|
16241
16543
|
if (swiftDistributionAt(moduleRoot)) {
|
|
16242
16544
|
const file = path33.join(moduleRoot, "modules", `${name}-Swift.h`);
|
|
16243
|
-
if (!
|
|
16545
|
+
if (!existsSync9(file)) return null;
|
|
16244
16546
|
const header = clangInterfaceHeader(readFileSync16(file, "utf8"), moduleRoot);
|
|
16245
16547
|
return { declared: swiftInterfaceDeclarations(header), header };
|
|
16246
16548
|
}
|
|
16247
16549
|
const sources = path33.join(moduleRoot, "Sources", name);
|
|
16248
16550
|
const built = path33.join(moduleRoot, ".build/host", `${name}-Swift.h`);
|
|
16249
|
-
if (!
|
|
16551
|
+
if (!existsSync9(sources) || !existsSync9(built)) return null;
|
|
16250
16552
|
const declared = /* @__PURE__ */ new Set();
|
|
16251
16553
|
for (const file of readdirSync6(sources, { recursive: true, encoding: "utf8" }))
|
|
16252
16554
|
if (file.endsWith(".swift"))
|
|
@@ -16279,7 +16581,7 @@ function clangInterfaceHeader(header, moduleRoot) {
|
|
|
16279
16581
|
const imports = [`@import ${framework};`];
|
|
16280
16582
|
imported.add(framework);
|
|
16281
16583
|
const directory = distribution ? path33.join(moduleRoot, "modules", module) : path33.join(moduleRoot, "Sources", module, "include");
|
|
16282
|
-
if (!
|
|
16584
|
+
if (!existsSync9(directory)) return imports[0];
|
|
16283
16585
|
if (!references) {
|
|
16284
16586
|
references = new Set(header.match(/\b[A-Z]\w*\b/g));
|
|
16285
16587
|
for (const name of objcEnumerations(header)) references.delete(name);
|
|
@@ -16343,7 +16645,7 @@ function sdkObjCDeclarationOwners(frameworks) {
|
|
|
16343
16645
|
for (const framework of readdirSync6(frameworks))
|
|
16344
16646
|
if (framework.endsWith(".framework")) {
|
|
16345
16647
|
const headers = path33.join(frameworks, framework, "Headers");
|
|
16346
|
-
if (
|
|
16648
|
+
if (existsSync9(headers)) {
|
|
16347
16649
|
for (const file of readdirSync6(headers, { recursive: true, encoding: "utf8" }))
|
|
16348
16650
|
if (file.endsWith(".h")) {
|
|
16349
16651
|
const header = readFileSync16(path33.join(headers, file), "utf8");
|
|
@@ -16464,7 +16766,7 @@ function swiftObjCSelectorOptions(moduleRoot) {
|
|
|
16464
16766
|
map = path33.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
|
|
16465
16767
|
const content = `${JSON.stringify({ classes }, null, 2)}
|
|
16466
16768
|
`;
|
|
16467
|
-
if (!
|
|
16769
|
+
if (!existsSync9(map) || readFileSync16(map, "utf8") !== content) {
|
|
16468
16770
|
mkdirSync8(path33.dirname(map), { recursive: true });
|
|
16469
16771
|
const partial = `${map}.${randomUUID5()}`;
|
|
16470
16772
|
writeFileSync8(partial, content);
|
|
@@ -16563,8 +16865,8 @@ function swiftMacroPlugins(moduleRoot, dir = path33.join(moduleRoot, ".build/hos
|
|
|
16563
16865
|
return {
|
|
16564
16866
|
libraries: plugins.map(({ library }) => library),
|
|
16565
16867
|
executables: [expoPlugin],
|
|
16566
|
-
stale: !
|
|
16567
|
-
({ 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)
|
|
16568
16870
|
)
|
|
16569
16871
|
};
|
|
16570
16872
|
}
|
|
@@ -16660,7 +16962,7 @@ function swiftModuleDigest(root) {
|
|
|
16660
16962
|
const files = swiftModuleInputFiles(root);
|
|
16661
16963
|
const stampHash = createHash18("sha256");
|
|
16662
16964
|
for (const file of files) {
|
|
16663
|
-
const stat =
|
|
16965
|
+
const stat = statSync5(path33.join(root, file), { bigint: true });
|
|
16664
16966
|
stampHash.update(file);
|
|
16665
16967
|
stampHash.update(
|
|
16666
16968
|
`${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
|
|
@@ -16681,7 +16983,7 @@ function swiftModuleDigest(root) {
|
|
|
16681
16983
|
writeFileSync8(partial, body);
|
|
16682
16984
|
renameSync5(partial, target);
|
|
16683
16985
|
};
|
|
16684
|
-
if (
|
|
16986
|
+
if (existsSync9(record)) {
|
|
16685
16987
|
const saved = JSON.parse(readFileSync16(record, "utf8"));
|
|
16686
16988
|
if (saved && typeof saved === "object" && Reflect.get(saved, "stamp") === stamp && typeof Reflect.get(saved, "digest") === "string") {
|
|
16687
16989
|
const digest2 = Buffer.from(String(Reflect.get(saved, "digest")), "hex");
|
|
@@ -16691,7 +16993,7 @@ function swiftModuleDigest(root) {
|
|
|
16691
16993
|
}
|
|
16692
16994
|
const gitKey = gitCleanModuleInputsKey(root, files);
|
|
16693
16995
|
const gitRecord = gitKey ? path33.join(digestDir, `git-${gitKey}.json`) : null;
|
|
16694
|
-
if (gitRecord &&
|
|
16996
|
+
if (gitRecord && existsSync9(gitRecord)) {
|
|
16695
16997
|
const saved = JSON.parse(readFileSync16(gitRecord, "utf8"));
|
|
16696
16998
|
if (saved && typeof saved === "object" && typeof Reflect.get(saved, "digest") === "string") {
|
|
16697
16999
|
const hex2 = String(Reflect.get(saved, "digest"));
|
|
@@ -17041,13 +17343,13 @@ function swiftOverlayFrameworks(moduleRoot, toolchainBin) {
|
|
|
17041
17343
|
);
|
|
17042
17344
|
for (const entry of readdirSync6(resources)) {
|
|
17043
17345
|
const map = path33.join(resources, entry, "module.modulemap");
|
|
17044
|
-
if (
|
|
17346
|
+
if (existsSync9(map))
|
|
17045
17347
|
addSwiftOverlayFrameworks(readFileSync16(map, "utf8"), swiftModules, result);
|
|
17046
17348
|
}
|
|
17047
17349
|
for (const directory of frameworks)
|
|
17048
17350
|
for (const entry of readdirSync6(directory)) {
|
|
17049
17351
|
const map = path33.join(directory, entry, "Modules/module.modulemap");
|
|
17050
|
-
if (
|
|
17352
|
+
if (existsSync9(map))
|
|
17051
17353
|
addSwiftOverlayFrameworks(readFileSync16(map, "utf8"), swiftModules, result);
|
|
17052
17354
|
}
|
|
17053
17355
|
sdkOverlayFrameworks.set(key, result);
|
|
@@ -17071,7 +17373,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
17071
17373
|
})
|
|
17072
17374
|
]);
|
|
17073
17375
|
for (const map of maps) {
|
|
17074
|
-
if (!
|
|
17376
|
+
if (!existsSync9(map)) continue;
|
|
17075
17377
|
const contents2 = readFileSync16(map, "utf8");
|
|
17076
17378
|
for (const match of contents2.matchAll(
|
|
17077
17379
|
/^(?:explicit\s+)?(?:framework\s+)?module\s+([A-Za-z_]\w*)/gm
|
|
@@ -17086,7 +17388,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
17086
17388
|
}
|
|
17087
17389
|
for (const entry of readdirSync6(resources)) {
|
|
17088
17390
|
const map = path33.join(resources, entry, "module.modulemap");
|
|
17089
|
-
if (!
|
|
17391
|
+
if (!existsSync9(map)) continue;
|
|
17090
17392
|
for (const match of readFileSync16(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
|
|
17091
17393
|
modules.add(match[1]);
|
|
17092
17394
|
}
|
|
@@ -17107,7 +17409,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
17107
17409
|
for (const directory of frameworks) {
|
|
17108
17410
|
for (const entry of readdirSync6(directory)) {
|
|
17109
17411
|
const map = path33.join(directory, entry, "Modules/module.modulemap");
|
|
17110
|
-
if (!
|
|
17412
|
+
if (!existsSync9(map)) continue;
|
|
17111
17413
|
for (const match of readFileSync16(map, "utf8").matchAll(
|
|
17112
17414
|
/^framework\s+module\s+([A-Za-z_]\w*)/gm
|
|
17113
17415
|
))
|
|
@@ -17207,7 +17509,7 @@ int EXUpdatesApplyBSDiffPatch(const char * _Nonnull oldFilePath,
|
|
|
17207
17509
|
];
|
|
17208
17510
|
var CLANG_DISTRIBUTION_MODULES = ".peach-clang-modules";
|
|
17209
17511
|
function distributionClangModulePresent(modules, name) {
|
|
17210
|
-
return
|
|
17512
|
+
return existsSync9(path33.join(modules, `${name}.swiftmodule`)) || existsSync9(path33.join(modules, name, "module.modulemap"));
|
|
17211
17513
|
}
|
|
17212
17514
|
function distributionClangModuleMap(root, modules) {
|
|
17213
17515
|
const missing = DISTRIBUTION_CLANG_MODULES.filter(
|
|
@@ -17224,7 +17526,7 @@ function distributionClangModuleMap(root, modules) {
|
|
|
17224
17526
|
}
|
|
17225
17527
|
`
|
|
17226
17528
|
).join("\n");
|
|
17227
|
-
if (
|
|
17529
|
+
if (existsSync9(mapPath) && readFileSync16(mapPath, "utf8") !== map)
|
|
17228
17530
|
rmSync7(directory, { recursive: true, force: true });
|
|
17229
17531
|
for (const mod of missing) writeBuildFile(path33.join(directory, mod.header), mod.source);
|
|
17230
17532
|
writeBuildFile(mapPath, map);
|
|
@@ -17240,7 +17542,7 @@ function providedModulesPath(root, modules, excluded) {
|
|
|
17240
17542
|
const key = createHash18("sha256").update(JSON.stringify([modules, entries2])).update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
|
|
17241
17543
|
const directory = path33.join(root, `.peach-modules-${key}`);
|
|
17242
17544
|
const complete = path33.join(directory, ".complete");
|
|
17243
|
-
if (!
|
|
17545
|
+
if (!existsSync9(complete)) {
|
|
17244
17546
|
mkdirSync8(directory, { recursive: true });
|
|
17245
17547
|
for (const entry of readdirSync6(directory))
|
|
17246
17548
|
rmSync7(path33.join(directory, entry), { recursive: true, force: true });
|
|
@@ -17385,7 +17687,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
|
|
|
17385
17687
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
17386
17688
|
var MULTI_MANIFEST_VERSION = 76;
|
|
17387
17689
|
var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
17388
|
-
var compilerSourceDigest = true ? "
|
|
17690
|
+
var compilerSourceDigest = true ? "4d55fa7cbb29586c08e4e51867226f96047bae2103c89f4fa59d9cf3ed3862fb" : swiftCompilerSourceDigest(import.meta.dirname);
|
|
17389
17691
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
17390
17692
|
return swiftCompileInputHash(input, release).update(swiftModuleDigest(moduleRoot)).digest("hex");
|
|
17391
17693
|
}
|
|
@@ -17533,7 +17835,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17533
17835
|
if (!flag.startsWith("-fmodule-map-file=")) return false;
|
|
17534
17836
|
const file = flag.slice("-fmodule-map-file=".length).replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root);
|
|
17535
17837
|
if (!file.includes("/Pods/Headers/")) return false;
|
|
17536
|
-
const map = args.files.get(file) ?? (
|
|
17838
|
+
const map = args.files.get(file) ?? (existsSync9(file) ? readFileSync16(file) : void 0);
|
|
17537
17839
|
const name = map === void 0 ? void 0 : moduleMapName(map.toString());
|
|
17538
17840
|
return name !== void 0 && packageModules.has(name);
|
|
17539
17841
|
};
|
|
@@ -17574,10 +17876,22 @@ function emitSwiftPackageManifest(args) {
|
|
|
17574
17876
|
const available = distribution.objects.filter(
|
|
17575
17877
|
(object2) => !isProvider(object2) && !replacedObjects.has(object2)
|
|
17576
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
|
+
};
|
|
17577
17893
|
const objects = available.filter(
|
|
17578
|
-
(object2) => !
|
|
17579
|
-
(name) => !object2.startsWith(`lib/${name}-`) || reachedFrameworks.has(name)
|
|
17580
|
-
)
|
|
17894
|
+
(object2) => !isTargetObject(object2) && !isUnreachedOptional(object2)
|
|
17581
17895
|
);
|
|
17582
17896
|
const quoted2 = (object2) => `"${path33.join(moduleRoot, object2).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
17583
17897
|
const categoryObjects = new Set(
|
|
@@ -17658,18 +17972,53 @@ function emitSwiftPackageManifest(args) {
|
|
|
17658
17972
|
args.files.set(file, content);
|
|
17659
17973
|
return JSON.stringify([`@${file}`]);
|
|
17660
17974
|
};
|
|
17661
|
-
const
|
|
17662
|
-
|
|
17663
|
-
|
|
17664
|
-
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) {
|
|
17665
17978
|
const framework = /^(.*)\/[^/]+\.framework\/Modules$/.exec(
|
|
17666
|
-
|
|
17979
|
+
target.publicHeadersPath ?? ""
|
|
17667
17980
|
);
|
|
17668
|
-
|
|
17669
|
-
|
|
17670
|
-
|
|
17671
|
-
|
|
17672
|
-
|
|
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("")}` : "");
|
|
17673
18022
|
const frameworkSearchFlags = (target, tool) => frameworkDirectories(target?.name ?? "").map((directory) => ({
|
|
17674
18023
|
tool,
|
|
17675
18024
|
flags: ["-F", directory]
|
|
@@ -17718,10 +18067,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17718
18067
|
const upstream = (target.swiftFlags ?? []).map(
|
|
17719
18068
|
(flag) => `, ${JSON.stringify(flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root))}`
|
|
17720
18069
|
).join("");
|
|
17721
|
-
const
|
|
17722
|
-
const imports = binaryImports + (distributionModules ? `, "-Isystem", ${JSON.stringify(
|
|
17723
|
-
providedModulesPath(args.root, distributionModules, args.moduleExcludes)
|
|
17724
|
-
)}${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;
|
|
17725
18071
|
const nativeFlags = [
|
|
17726
18072
|
...args.nativeFlags?.get(target.name) ?? [],
|
|
17727
18073
|
...args.nativeHeaderFlags ?? []
|
|
@@ -17745,12 +18091,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17745
18091
|
return map ? ["-fmodule-map-file=" + map] : [];
|
|
17746
18092
|
}),
|
|
17747
18093
|
...[...importContext].flatMap((name) => args.native?.get(name)?.importFlags ?? []),
|
|
17748
|
-
...[...importContext].flatMap((name) =>
|
|
17749
|
-
const flags = targets.find((target2) => target2.name === name)?.swiftFlags ?? [];
|
|
17750
|
-
return flags.flatMap(
|
|
17751
|
-
(flag, index) => flags[index - 1] === "-Xcc" ? [flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root)] : []
|
|
17752
|
-
);
|
|
17753
|
-
})
|
|
18094
|
+
...[...importContext].flatMap((name) => targetSwiftXccFlags.get(name) ?? [])
|
|
17754
18095
|
];
|
|
17755
18096
|
const nativeImportFlags = [
|
|
17756
18097
|
...frameworkDirectories(target.name).flatMap((directory) => ["-F", directory]),
|
|
@@ -17765,9 +18106,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17765
18106
|
...native?.swiftFlags ?? [],
|
|
17766
18107
|
...args.objcImplementationModules?.has(target.name) ? ["-enable-experimental-feature", "ObjCImplementation"] : []
|
|
17767
18108
|
].map((flag) => `, ${JSON.stringify(flag)}`).join("");
|
|
17768
|
-
const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] ||
|
|
17769
|
-
(value) => value.late?.producers.includes(target.name)
|
|
17770
|
-
)) ? `, "-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`))}` : "";
|
|
17771
18110
|
const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
|
|
17772
18111
|
const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
|
|
17773
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}]`)})]`;
|
|
@@ -17800,9 +18139,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17800
18139
|
(dependency) => clang && // textual native headers can include one another without imposing
|
|
17801
18140
|
// an object build order. the executable already links every native
|
|
17802
18141
|
// target; only generated Swift headers require producer ordering.
|
|
17803
|
-
(args.native?.get(dependency)?.clang || [
|
|
17804
|
-
(value) => value.late?.producers.includes(dependency)
|
|
17805
|
-
)) ? [] : 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}"`]
|
|
17806
18143
|
),
|
|
17807
18144
|
// a swift importer still needs the producers its clang dependencies
|
|
17808
18145
|
// reached upstream, whose edges the clang targets above dropped.
|
|
@@ -17889,7 +18226,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17889
18226
|
...args.nativeFlags?.get(name) ?? [],
|
|
17890
18227
|
...args.nativeHeaderFlags ?? []
|
|
17891
18228
|
];
|
|
17892
|
-
const owner =
|
|
18229
|
+
const owner = targetByName.get(name);
|
|
17893
18230
|
const context = /* @__PURE__ */ new Set();
|
|
17894
18231
|
const visit = (dependency) => {
|
|
17895
18232
|
if (context.has(dependency)) return;
|
|
@@ -17965,10 +18302,16 @@ ${declaration.replace(/,$/, "")}
|
|
|
17965
18302
|
""
|
|
17966
18303
|
].join("\n");
|
|
17967
18304
|
}
|
|
17968
|
-
function syncSwiftTree(base, files) {
|
|
18305
|
+
function syncSwiftTree(base, files, alreadySynced) {
|
|
17969
18306
|
mkdirSync8(base, { recursive: true });
|
|
17970
|
-
|
|
17971
|
-
|
|
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
|
+
}
|
|
17972
18315
|
const walk = (dir) => {
|
|
17973
18316
|
for (const entry of readdirSync6(dir, { withFileTypes: true })) {
|
|
17974
18317
|
const full = path33.join(dir, entry.name);
|
|
@@ -17977,12 +18320,13 @@ function syncSwiftTree(base, files) {
|
|
|
17977
18320
|
entry.name === CLANG_DISTRIBUTION_MODULES || entry.name === SWIFT_DISTRIBUTION_MIRROR || entry.name === SWIFT_LINK_STAMP))
|
|
17978
18321
|
continue;
|
|
17979
18322
|
if (entry.isDirectory()) walk(full);
|
|
17980
|
-
else if (!files.has(full) && !kept.has(lstatSync(full).ino))
|
|
18323
|
+
else if (!files.has(full) && (!kept || !kept.has(lstatSync(full).ino)))
|
|
17981
18324
|
rmSync7(full, { force: true });
|
|
17982
18325
|
}
|
|
17983
18326
|
};
|
|
17984
18327
|
walk(base);
|
|
17985
18328
|
for (const [full, contents2] of files) {
|
|
18329
|
+
if (alreadySynced?.get(full) === contents2) continue;
|
|
17986
18330
|
writeBuildFile(full, contents2);
|
|
17987
18331
|
}
|
|
17988
18332
|
}
|
|
@@ -18106,25 +18450,59 @@ function swiftWasmCallGuards(source, unavailable) {
|
|
|
18106
18450
|
out = out.slice(0, at) + replacement + out.slice(at + width);
|
|
18107
18451
|
return out;
|
|
18108
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
|
+
}
|
|
18109
18483
|
function compiledSwiftSources(files, targets, overlayFrameworks, headers, nativeSourceGlue = false) {
|
|
18110
18484
|
const ordered = [...targets].sort((a, b) => b.path.length - a.path.length);
|
|
18111
|
-
const
|
|
18112
|
-
|
|
18113
|
-
|
|
18114
|
-
|
|
18115
|
-
|
|
18116
|
-
|
|
18117
|
-
|
|
18118
|
-
|
|
18119
|
-
|
|
18120
|
-
|
|
18121
|
-
return
|
|
18122
|
-
})
|
|
18123
|
-
|
|
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
|
+
}
|
|
18124
18499
|
const swiftSources = /* @__PURE__ */ new Map();
|
|
18125
|
-
for (const { source, owner } of owners.values())
|
|
18126
|
-
if (owner)
|
|
18127
|
-
|
|
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
|
+
}
|
|
18128
18506
|
const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
|
|
18129
18507
|
return new Map(
|
|
18130
18508
|
[...owners].map(([file, { source, owner }]) => {
|
|
@@ -19155,7 +19533,7 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
|
19155
19533
|
};
|
|
19156
19534
|
gather(source);
|
|
19157
19535
|
const manifest = path33.join(source, "Package.swift");
|
|
19158
|
-
const targets =
|
|
19536
|
+
const targets = existsSync9(manifest) ? swiftManifestTargets(
|
|
19159
19537
|
readFileSync16(manifest, "utf8"),
|
|
19160
19538
|
[],
|
|
19161
19539
|
(file) => readFileSync16(file, "utf8")
|
|
@@ -19271,10 +19649,10 @@ function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
|
|
|
19271
19649
|
const directory = path33.join(layoutRoot, ".build", "peach-clang-modulemaps");
|
|
19272
19650
|
return (settings.moduleMaps ?? []).flatMap((map) => {
|
|
19273
19651
|
const headers = path33.join(layoutRoot, map.headers);
|
|
19274
|
-
if (!
|
|
19652
|
+
if (!existsSync9(headers)) return [];
|
|
19275
19653
|
const published = path33.join(headers, "module.modulemap");
|
|
19276
|
-
if (searched.has(map.headers) &&
|
|
19277
|
-
if (!searched.has(map.headers) &&
|
|
19654
|
+
if (searched.has(map.headers) && existsSync9(published)) return [];
|
|
19655
|
+
if (!searched.has(map.headers) && existsSync9(published))
|
|
19278
19656
|
return [`-fmodule-map-file=${published}`];
|
|
19279
19657
|
const cached = written.get(headers);
|
|
19280
19658
|
if (cached) return [cached];
|
|
@@ -19366,18 +19744,46 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19366
19744
|
const bySourcePath = [...targets].sort(
|
|
19367
19745
|
(left, right) => right.path.length - left.path.length
|
|
19368
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
|
+
}
|
|
19369
19779
|
const swiftTargets = /* @__PURE__ */ new Set();
|
|
19370
19780
|
for (const file of Object.keys(input.files)) {
|
|
19371
19781
|
if (!file.endsWith(".swift")) continue;
|
|
19372
|
-
const target =
|
|
19373
|
-
|
|
19374
|
-
|
|
19375
|
-
|
|
19376
|
-
|
|
19377
|
-
);
|
|
19378
|
-
const excluded = target?.exclude?.some(
|
|
19379
|
-
(name) => file === path33.posix.join(target.path, name)
|
|
19380
|
-
);
|
|
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);
|
|
19381
19787
|
if (target && !excluded) swiftTargets.add(target.name);
|
|
19382
19788
|
}
|
|
19383
19789
|
const importedModules = /* @__PURE__ */ new Set();
|
|
@@ -19403,7 +19809,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19403
19809
|
)
|
|
19404
19810
|
);
|
|
19405
19811
|
const headerDirectory = path33.join(layout2.root, ".build", "peach-cxx-headers");
|
|
19406
|
-
if (
|
|
19812
|
+
if (existsSync9(headerDirectory)) {
|
|
19407
19813
|
for (const entry of readdirSync6(headerDirectory, { withFileTypes: true }))
|
|
19408
19814
|
if (entry.isDirectory() && !targets.some((target) => target.name === entry.name))
|
|
19409
19815
|
rmSync7(path33.join(headerDirectory, entry.name), { recursive: true, force: true });
|
|
@@ -19415,7 +19821,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19415
19821
|
checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
|
|
19416
19822
|
return checkedToolchain;
|
|
19417
19823
|
};
|
|
19418
|
-
const deploymentTarget = (name) =>
|
|
19824
|
+
const deploymentTarget = (name) => nativeTargetByName.get(name)?.deploymentTarget ?? targetByName.get(name)?.iosDeploymentTarget ?? null;
|
|
19419
19825
|
const targetStagedFiles = /* @__PURE__ */ new Map();
|
|
19420
19826
|
const stageTargetFile = (target, file, contents2, options) => {
|
|
19421
19827
|
const relative = path33.relative(layout2.root, file).split(path33.sep).join(path33.posix.sep);
|
|
@@ -19427,18 +19833,41 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19427
19833
|
targetStagedFiles.set(target, staged);
|
|
19428
19834
|
files.set(file, contents2);
|
|
19429
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();
|
|
19430
19849
|
const targetEntries = (target) => {
|
|
19850
|
+
const cached = targetEntriesCache.get(target.name);
|
|
19851
|
+
if (cached) return cached;
|
|
19431
19852
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
19432
|
-
|
|
19433
|
-
|
|
19434
|
-
|
|
19435
|
-
|
|
19436
|
-
|
|
19437
|
-
(
|
|
19438
|
-
|
|
19439
|
-
|
|
19440
|
-
)
|
|
19441
|
-
|
|
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;
|
|
19442
19871
|
};
|
|
19443
19872
|
const failTargetPreparation = (target, message) => {
|
|
19444
19873
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
@@ -19483,19 +19912,21 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19483
19912
|
return value;
|
|
19484
19913
|
};
|
|
19485
19914
|
const podHeaders = /* @__PURE__ */ new Map();
|
|
19486
|
-
for (const settings of
|
|
19915
|
+
for (const settings of nativeTargets)
|
|
19487
19916
|
for (const file of settings.headers) {
|
|
19488
19917
|
const owner = /\/Headers\/(?:Public|Private)\/([\w+-]+)\/(?:\1\/)?[^/]+\.h$/.exec(
|
|
19489
19918
|
file
|
|
19490
19919
|
)?.[1];
|
|
19491
|
-
if (owner)
|
|
19492
|
-
|
|
19493
|
-
|
|
19494
|
-
|
|
19495
|
-
]);
|
|
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
|
+
}
|
|
19496
19926
|
}
|
|
19497
19927
|
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(path33.basename(file))?.find((header) => header.content === content)?.owner;
|
|
19498
|
-
|
|
19928
|
+
const alreadySynced = /* @__PURE__ */ new Map();
|
|
19929
|
+
for (const settings of nativeTargets) {
|
|
19499
19930
|
for (const file of settings.headers) {
|
|
19500
19931
|
const destination = path33.join(layout2.root, file);
|
|
19501
19932
|
if (files.has(destination)) continue;
|
|
@@ -19512,10 +19943,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19512
19943
|
`#import <${interfaceOwner}/${interfaceOwner}-Swift.h>`
|
|
19513
19944
|
) : rawContents;
|
|
19514
19945
|
writeBuildFile(destination, contents2);
|
|
19946
|
+
alreadySynced.set(destination, contents2);
|
|
19515
19947
|
files.set(destination, contents2);
|
|
19516
19948
|
}
|
|
19517
19949
|
}
|
|
19518
|
-
const nativeTargets = input.nativeTargets ?? [];
|
|
19519
19950
|
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path33.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
|
|
19520
19951
|
const inRoot = `${layout2.root}${path33.sep}`;
|
|
19521
19952
|
const binaryTree = `${path33.sep}${SWIFT_BINARY_TREES_DIR}${path33.sep}`;
|
|
@@ -19580,12 +20011,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19580
20011
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
19581
20012
|
const entries2 = targetEntries(target);
|
|
19582
20013
|
const units = entries2.filter(([file]) => isSwiftNativeTranslationUnit(file));
|
|
19583
|
-
|
|
19584
|
-
|
|
19585
|
-
)))
|
|
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)))
|
|
19586
20016
|
continue;
|
|
19587
20017
|
const includes = `${prefix}include/`;
|
|
19588
|
-
const settings = input.nativeTargets?.find((value) => value.name === target.name);
|
|
19589
20018
|
const searchRoots = [
|
|
19590
20019
|
...settings?.userHeaderSearchPaths ?? [],
|
|
19591
20020
|
...settings?.headerSearchPaths ?? [],
|
|
@@ -19616,7 +20045,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19616
20045
|
...searchRoots.map((root) => path33.posix.join(root, include))
|
|
19617
20046
|
].find((candidate) => input.files[candidate] !== void 0);
|
|
19618
20047
|
if (local) {
|
|
19619
|
-
|
|
20048
|
+
let parents = reverse.get(local);
|
|
20049
|
+
if (!parents) reverse.set(local, parents = []);
|
|
20050
|
+
parents.push(file);
|
|
19620
20051
|
if (xcodeTarget && !seenHeaders.has(local)) {
|
|
19621
20052
|
seenHeaders.add(local);
|
|
19622
20053
|
searchEntries.push([local, input.files[local]]);
|
|
@@ -19662,9 +20093,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19662
20093
|
const stageFlags = (flags2, sdkInclude2) => flags2.map(
|
|
19663
20094
|
(flag) => flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, layout2.root).replaceAll(SWIFT_NATIVE_SDK_INCLUDE, sdkInclude2)
|
|
19664
20095
|
);
|
|
20096
|
+
const settingsHeaderFlags = headerSearch.flags[nativeTargetIndex.get(settings.name)];
|
|
19665
20097
|
const originalFlags = [
|
|
19666
20098
|
...settings.flags,
|
|
19667
|
-
...
|
|
20099
|
+
...settingsHeaderFlags,
|
|
19668
20100
|
...search,
|
|
19669
20101
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
19670
20102
|
"-F",
|
|
@@ -19675,7 +20107,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19675
20107
|
];
|
|
19676
20108
|
const importOriginalFlags = settings.flattensPublicHeaders ? [
|
|
19677
20109
|
...settings.importerFlags,
|
|
19678
|
-
...
|
|
20110
|
+
...settingsHeaderFlags,
|
|
19679
20111
|
...search,
|
|
19680
20112
|
...settings.frameworkSearchPaths.flatMap((dir) => [
|
|
19681
20113
|
"-F",
|
|
@@ -19700,7 +20132,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19700
20132
|
}
|
|
19701
20133
|
return [
|
|
19702
20134
|
...kept,
|
|
19703
|
-
...
|
|
20135
|
+
...settingsHeaderFlags,
|
|
19704
20136
|
...search,
|
|
19705
20137
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
19706
20138
|
"-F",
|
|
@@ -19729,7 +20161,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19729
20161
|
const bundleName = entries2.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
|
|
19730
20162
|
target: target.name,
|
|
19731
20163
|
path: target.path,
|
|
19732
|
-
resources:
|
|
20164
|
+
resources: resourceTargetByName.get(target.name)?.resources ?? false,
|
|
19733
20165
|
usesBundleMacro: entries2.some(
|
|
19734
20166
|
([file, contents2]) => (isSwiftNativeTranslationUnit(file) || /\.(?:h|hpp|hh|hxx)$/.test(file)) && /\bSWIFTPM_MODULE_BUNDLE\b/.test(contents2)
|
|
19735
20167
|
),
|
|
@@ -19882,10 +20314,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19882
20314
|
.../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
|
|
19883
20315
|
...stageFlags(
|
|
19884
20316
|
[...objcCxx ? settings.cxxFlags : [], ...fileFlags],
|
|
19885
|
-
|
|
19886
|
-
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
19887
|
-
"darwin/usr/include"
|
|
19888
|
-
)
|
|
20317
|
+
sdkInclude
|
|
19889
20318
|
)
|
|
19890
20319
|
];
|
|
19891
20320
|
const moduleFlag = perFile.some((flag) => flag.startsWith("-fmodule-name=")) ? [] : [`-fmodule-name=${swiftTargetModuleName(target.name)}`];
|
|
@@ -19925,13 +20354,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19925
20354
|
...flags,
|
|
19926
20355
|
...prefixHeader,
|
|
19927
20356
|
...accessorFlags,
|
|
19928
|
-
...stageFlags(
|
|
19929
|
-
cxx ? settings.cxxFlags : [],
|
|
19930
|
-
path33.join(
|
|
19931
|
-
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
19932
|
-
"darwin/usr/include"
|
|
19933
|
-
)
|
|
19934
|
-
),
|
|
20357
|
+
...stageFlags(cxx ? settings.cxxFlags : [], sdkInclude),
|
|
19935
20358
|
...perFile,
|
|
19936
20359
|
...moduleFlag
|
|
19937
20360
|
]
|
|
@@ -20186,7 +20609,9 @@ module ${moduleName}.Swift {
|
|
|
20186
20609
|
}
|
|
20187
20610
|
` : swiftObjCModuleMap(
|
|
20188
20611
|
moduleName,
|
|
20189
|
-
(
|
|
20612
|
+
(nativeTargetByName.get(name)?.publicHeaders ?? []).map(
|
|
20613
|
+
(header) => path33.join(layout2.root, header)
|
|
20614
|
+
),
|
|
20190
20615
|
submoduleImports2.get(moduleName),
|
|
20191
20616
|
path33.join(headerDirectory, name + "-Swift.h")
|
|
20192
20617
|
)
|
|
@@ -20232,7 +20657,7 @@ module ${moduleName}.Swift {
|
|
|
20232
20657
|
);
|
|
20233
20658
|
stagedProducts.push(name);
|
|
20234
20659
|
}
|
|
20235
|
-
if (
|
|
20660
|
+
if (existsSync9(providedFrameworks)) {
|
|
20236
20661
|
for (const entry of readdirSync6(providedFrameworks))
|
|
20237
20662
|
if (!stagedProducts.includes(entry.replace(/\.framework$/, "")))
|
|
20238
20663
|
rmSync7(path33.join(providedFrameworks, entry), { recursive: true, force: true });
|
|
@@ -20249,7 +20674,7 @@ module ${moduleName}.Swift {
|
|
|
20249
20674
|
".build",
|
|
20250
20675
|
"peach-framework-search.json"
|
|
20251
20676
|
);
|
|
20252
|
-
if (!
|
|
20677
|
+
if (!existsSync9(frameworkSearchRecord) || readFileSync16(frameworkSearchRecord, "utf8") !== frameworkSearch)
|
|
20253
20678
|
for (const cache of [
|
|
20254
20679
|
path33.join(layout2.root, ".build", "ModuleCache"),
|
|
20255
20680
|
path33.join(layout2.root, ".build", WASM_TRIPLE, "release", "ModuleCache")
|
|
@@ -20630,7 +21055,7 @@ ${entry}`);
|
|
|
20630
21055
|
const reachesFrameworks = !distribution || swiftImportedModules.has("Foundation") || Object.entries(input.files).some(
|
|
20631
21056
|
([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
|
|
20632
21057
|
) || [...importedModules].some(
|
|
20633
|
-
(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(
|
|
20634
21059
|
path33.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name)
|
|
20635
21060
|
))
|
|
20636
21061
|
);
|
|
@@ -20736,6 +21161,7 @@ ${entry}`);
|
|
|
20736
21161
|
files.set(destination, Buffer.from(bytes, "base64"));
|
|
20737
21162
|
}
|
|
20738
21163
|
const targetToolset = nativeToolset || native.size > 0;
|
|
21164
|
+
let usesObjcPrebuilt = false;
|
|
20739
21165
|
if (targetToolset) {
|
|
20740
21166
|
const nativeToolsetFlags = [
|
|
20741
21167
|
...headerAliasFlags,
|
|
@@ -20756,6 +21182,7 @@ ${entry}`);
|
|
|
20756
21182
|
[...native.keys()],
|
|
20757
21183
|
objcPrebuiltStage
|
|
20758
21184
|
) : [];
|
|
21185
|
+
usesObjcPrebuilt = prebuiltCompiler.length > 0;
|
|
20759
21186
|
files.set(
|
|
20760
21187
|
clangWrapper2,
|
|
20761
21188
|
[
|
|
@@ -21064,17 +21491,39 @@ package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.
|
|
|
21064
21491
|
(name) => !nativePrerequisiteSet.has(name)
|
|
21065
21492
|
);
|
|
21066
21493
|
const nativeTargetUnitCount = /* @__PURE__ */ new Map();
|
|
21494
|
+
const nativeTargetSources = /* @__PURE__ */ new Map();
|
|
21067
21495
|
for (const target of manifestTargets)
|
|
21068
|
-
if (target.sources?.length)
|
|
21496
|
+
if (target.sources?.length) {
|
|
21069
21497
|
nativeTargetUnitCount.set(target.name, target.sources.length);
|
|
21498
|
+
nativeTargetSources.set(target.name, target.sources);
|
|
21499
|
+
}
|
|
21070
21500
|
for (const [name, plan] of native) {
|
|
21071
|
-
if (!plan.mixed && plan.sources.length > 0)
|
|
21072
|
-
|
|
21073
|
-
|
|
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 ?? []) {
|
|
21074
21507
|
nativeTargetUnitCount.set(group.name, group.sources.length);
|
|
21075
|
-
|
|
21508
|
+
nativeTargetSources.set(group.name, group.sources);
|
|
21509
|
+
}
|
|
21510
|
+
if (plan.late && !plan.groups?.length) {
|
|
21076
21511
|
nativeTargetUnitCount.set(plan.late.name, plan.sources.length);
|
|
21512
|
+
nativeTargetSources.set(plan.late.name, plan.lateSources);
|
|
21513
|
+
}
|
|
21077
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
|
+
};
|
|
21078
21527
|
const MAX_NATIVE_STAGE_UNITS = 250;
|
|
21079
21528
|
const chunkNativeStageTargets = (prefix, names) => {
|
|
21080
21529
|
if (names.length === 0) return [];
|
|
@@ -21083,7 +21532,7 @@ package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.
|
|
|
21083
21532
|
0
|
|
21084
21533
|
);
|
|
21085
21534
|
if (names.length === 1 || total <= MAX_NATIVE_STAGE_UNITS)
|
|
21086
|
-
return [buildProduct(prefix, names)];
|
|
21535
|
+
return [recordStageObjects(buildProduct(prefix, names), names)];
|
|
21087
21536
|
const chunks = [];
|
|
21088
21537
|
let current = [];
|
|
21089
21538
|
let count = 0;
|
|
@@ -21098,7 +21547,9 @@ package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.
|
|
|
21098
21547
|
count += size;
|
|
21099
21548
|
}
|
|
21100
21549
|
if (current.length > 0) chunks.push(current);
|
|
21101
|
-
return chunks.map(
|
|
21550
|
+
return chunks.map(
|
|
21551
|
+
(members, index) => recordStageObjects(buildProduct(`${prefix}${index + 1}`, members), members)
|
|
21552
|
+
);
|
|
21102
21553
|
};
|
|
21103
21554
|
const nativePrerequisiteStageTargets = chunkNativeStageTargets(
|
|
21104
21555
|
"PeachHeaderNativePrereqs",
|
|
@@ -21109,12 +21560,12 @@ package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.
|
|
|
21109
21560
|
remainingNativeBuildTargets
|
|
21110
21561
|
);
|
|
21111
21562
|
files.set(manifestPath, manifest);
|
|
21112
|
-
syncSwiftTree(layout2.root, files);
|
|
21563
|
+
syncSwiftTree(layout2.root, files, alreadySynced);
|
|
21113
21564
|
if (layout2.multi)
|
|
21114
21565
|
for (const target of targets)
|
|
21115
21566
|
mkdirSync8(path33.join(layout2.root, target.path), { recursive: true });
|
|
21116
21567
|
const clangWrapper = path33.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
|
|
21117
|
-
if (files.has(clangWrapper) && (
|
|
21568
|
+
if (files.has(clangWrapper) && (statSync5(clangWrapper).mode & 4095) !== 493)
|
|
21118
21569
|
chmodSync3(clangWrapper, 493);
|
|
21119
21570
|
return {
|
|
21120
21571
|
...nativePrerequisiteStageTargets.length ? { nativePrerequisiteTargets: nativePrerequisiteStageTargets } : {},
|
|
@@ -21124,7 +21575,9 @@ package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.
|
|
|
21124
21575
|
targetFailures,
|
|
21125
21576
|
generatedOwners,
|
|
21126
21577
|
targetToolset,
|
|
21127
|
-
headerCompiler
|
|
21578
|
+
headerCompiler,
|
|
21579
|
+
usesObjcPrebuilt,
|
|
21580
|
+
nativeStageObjects
|
|
21128
21581
|
};
|
|
21129
21582
|
}
|
|
21130
21583
|
function streamText(value) {
|
|
@@ -21282,12 +21735,12 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
21282
21735
|
encoding: "utf8"
|
|
21283
21736
|
})) {
|
|
21284
21737
|
try {
|
|
21285
|
-
bytes +=
|
|
21738
|
+
bytes += statSync5(path33.join(directory, "artifact", file)).size;
|
|
21286
21739
|
} catch (error) {
|
|
21287
21740
|
if (!vanished(error)) throw error;
|
|
21288
21741
|
}
|
|
21289
21742
|
}
|
|
21290
|
-
entries2.push({ directory, used:
|
|
21743
|
+
entries2.push({ directory, used: statSync5(directory).mtimeMs, bytes });
|
|
21291
21744
|
} catch (error) {
|
|
21292
21745
|
if (!vanished(error)) throw error;
|
|
21293
21746
|
}
|
|
@@ -21302,7 +21755,7 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
21302
21755
|
`${RETIRED_PREFIX}${process.pid}-${path33.basename(entry.directory)}`
|
|
21303
21756
|
);
|
|
21304
21757
|
try {
|
|
21305
|
-
if (
|
|
21758
|
+
if (statSync5(entry.directory).mtimeMs !== entry.used) continue;
|
|
21306
21759
|
renameSync5(entry.directory, retired);
|
|
21307
21760
|
} catch (error) {
|
|
21308
21761
|
if (vanished(error)) continue;
|
|
@@ -21442,10 +21895,10 @@ ${dependencies}
|
|
|
21442
21895
|
const sourceDir = path33.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
|
|
21443
21896
|
mkdirSync8(sourceDir, { recursive: true });
|
|
21444
21897
|
const manifestPath = path33.join(linkRoot, "Package.swift");
|
|
21445
|
-
if (!
|
|
21898
|
+
if (!existsSync9(manifestPath) || readFileSync16(manifestPath, "utf8") !== manifest)
|
|
21446
21899
|
writeFileSync8(manifestPath, manifest);
|
|
21447
21900
|
const source = path33.join(sourceDir, "Link.swift");
|
|
21448
|
-
if (!
|
|
21901
|
+
if (!existsSync9(source)) writeFileSync8(source, "");
|
|
21449
21902
|
}
|
|
21450
21903
|
function frameworkLinkClosure(scratch, roots) {
|
|
21451
21904
|
const suffix = `${WASM_TRIPLE}-release`;
|
|
@@ -21525,7 +21978,7 @@ function frameworkLinkClosure(scratch, roots) {
|
|
|
21525
21978
|
owners.set(file, name);
|
|
21526
21979
|
if (seen.has(file)) continue;
|
|
21527
21980
|
seen.add(file);
|
|
21528
|
-
if (!
|
|
21981
|
+
if (!existsSync9(file))
|
|
21529
21982
|
throw new Error(`swift-compile: framework object ${file} was not built`);
|
|
21530
21983
|
files.push(file);
|
|
21531
21984
|
}
|
|
@@ -21541,7 +21994,7 @@ function frameworkLinkClosure(scratch, roots) {
|
|
|
21541
21994
|
};
|
|
21542
21995
|
}
|
|
21543
21996
|
function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
|
|
21544
|
-
if (!
|
|
21997
|
+
if (!existsSync9(modulesDir)) return;
|
|
21545
21998
|
const folded = new Set([...keep].map((name) => name.toLowerCase()));
|
|
21546
21999
|
for (const name of readdirSync6(modulesDir)) {
|
|
21547
22000
|
const dot = name.indexOf(".");
|
|
@@ -21564,7 +22017,7 @@ var frameworkProductsReceiptSchema = object({
|
|
|
21564
22017
|
});
|
|
21565
22018
|
function readFrameworkProductsReceipt(scratch, receiptKey) {
|
|
21566
22019
|
const receiptFile = path33.join(scratch, "products-ready", `${receiptKey}.json`);
|
|
21567
|
-
if (!
|
|
22020
|
+
if (!existsSync9(receiptFile)) return null;
|
|
21568
22021
|
let parsed;
|
|
21569
22022
|
try {
|
|
21570
22023
|
parsed = parse(
|
|
@@ -21576,11 +22029,11 @@ function readFrameworkProductsReceipt(scratch, receiptKey) {
|
|
|
21576
22029
|
}
|
|
21577
22030
|
const archive = path33.join(scratch, "lib");
|
|
21578
22031
|
const archiveStamp = path33.join(archive, ".receipt");
|
|
21579
|
-
const archiveMatches =
|
|
21580
|
-
if (!
|
|
21581
|
-
for (const [object2] of parsed.archived) if (!
|
|
21582
|
-
for (const file of parsed.providers) if (!
|
|
21583
|
-
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;
|
|
21584
22037
|
if (!archiveMatches) {
|
|
21585
22038
|
rmSync7(archive, { recursive: true, force: true });
|
|
21586
22039
|
mkdirSync8(archive, { recursive: true });
|
|
@@ -21588,8 +22041,8 @@ function readFrameworkProductsReceipt(scratch, receiptKey) {
|
|
|
21588
22041
|
symlinkSync2(object2, path33.join(scratch, rel));
|
|
21589
22042
|
writeFileSync8(archiveStamp, receiptKey);
|
|
21590
22043
|
}
|
|
21591
|
-
for (const file of parsed.objects) if (!
|
|
21592
|
-
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;
|
|
21593
22046
|
return {
|
|
21594
22047
|
root: scratch,
|
|
21595
22048
|
modules: parsed.modules,
|
|
@@ -21713,7 +22166,7 @@ async function buildFrameworkProducts(scratch, args) {
|
|
|
21713
22166
|
const constantsDir = path33.join(scratch, "uniform-type-constants");
|
|
21714
22167
|
const constantsStamp = path33.join(constantsDir, ".complete");
|
|
21715
22168
|
const object2 = path33.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
|
|
21716
|
-
if (!
|
|
22169
|
+
if (!existsSync9(constantsStamp) || readFileSync16(constantsStamp, "utf8") !== args.frameworkKey) {
|
|
21717
22170
|
rmSync7(constantsDir, { recursive: true, force: true });
|
|
21718
22171
|
mkdirSync8(constantsDir);
|
|
21719
22172
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
@@ -21751,7 +22204,7 @@ async function buildFrameworkProducts(scratch, args) {
|
|
|
21751
22204
|
}
|
|
21752
22205
|
const providerDir = path33.join(scratch, "darwin-records");
|
|
21753
22206
|
const providerStamp = path33.join(providerDir, ".complete");
|
|
21754
|
-
if (!
|
|
22207
|
+
if (!existsSync9(providerStamp) || readFileSync16(providerStamp, "utf8") !== args.frameworkKey) {
|
|
21755
22208
|
rmSync7(providerDir, { recursive: true, force: true });
|
|
21756
22209
|
mkdirSync8(providerDir);
|
|
21757
22210
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
@@ -21858,7 +22311,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
|
|
|
21858
22311
|
};
|
|
21859
22312
|
const staged = slots.find((slot) => swiftFrameworkSlotKey(slot) === frameworkKey);
|
|
21860
22313
|
if (staged) return withSwiftRootLock(staged, run2(staged), signal);
|
|
21861
|
-
const built = new Map(slots.map((slot) => [slot,
|
|
22314
|
+
const built = new Map(slots.map((slot) => [slot, statSync5(slot).mtimeMs]));
|
|
21862
22315
|
const own = (slot) => swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN) === moduleRoot;
|
|
21863
22316
|
const inputs = new Map(
|
|
21864
22317
|
swiftModuleInputFiles(moduleRoot).map((file) => [
|
|
@@ -21873,7 +22326,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
|
|
|
21873
22326
|
for (const [file, contents2] of inputs) {
|
|
21874
22327
|
try {
|
|
21875
22328
|
const candidate = path33.join(source, file);
|
|
21876
|
-
if (
|
|
22329
|
+
if (statSync5(candidate).size !== contents2.length || !readFileSync16(candidate).equals(contents2))
|
|
21877
22330
|
changes++;
|
|
21878
22331
|
} catch (error) {
|
|
21879
22332
|
if (!vanished(error)) throw error;
|
|
@@ -21928,7 +22381,7 @@ function mirrorTree2(source, target, skip) {
|
|
|
21928
22381
|
if (existing) rmSync7(to, { recursive: true, force: true });
|
|
21929
22382
|
symlinkSync2(link, to);
|
|
21930
22383
|
} else {
|
|
21931
|
-
const stat =
|
|
22384
|
+
const stat = statSync5(from);
|
|
21932
22385
|
if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs || readFileSync16(from).equals(readFileSync16(to))))
|
|
21933
22386
|
continue;
|
|
21934
22387
|
if (existing) rmSync7(to, { recursive: true, force: true });
|
|
@@ -21969,7 +22422,7 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
|
21969
22422
|
if (!file.startsWith("../")) continue;
|
|
21970
22423
|
const from = path33.resolve(moduleRoot, file);
|
|
21971
22424
|
const to = path33.resolve(stagedModule, file);
|
|
21972
|
-
if (
|
|
22425
|
+
if (existsSync9(to) && readFileSync16(from).equals(readFileSync16(to))) continue;
|
|
21973
22426
|
mkdirSync8(path33.dirname(to), { recursive: true });
|
|
21974
22427
|
copyFileSync2(from, to);
|
|
21975
22428
|
}
|
|
@@ -21977,7 +22430,7 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
|
21977
22430
|
throw new Error("Swift staged framework source differs from the caller");
|
|
21978
22431
|
const modules = path33.join(staged, "node_modules");
|
|
21979
22432
|
const target = realpathSync6(path33.join(moduleRoot, "../../node_modules"));
|
|
21980
|
-
if (!
|
|
22433
|
+
if (!existsSync9(modules) || readlinkSync(modules) !== target) {
|
|
21981
22434
|
rmSync7(modules, { recursive: true, force: true });
|
|
21982
22435
|
symlinkSync2(target, modules);
|
|
21983
22436
|
}
|
|
@@ -21995,7 +22448,7 @@ ${args.frameworkKey}
|
|
|
21995
22448
|
hash.update("package-host-macros\n" + JSON.stringify(args.packageHostMacros));
|
|
21996
22449
|
if (!args.prebuilt) return hash.digest("hex");
|
|
21997
22450
|
const statOf = (file) => {
|
|
21998
|
-
const stat =
|
|
22451
|
+
const stat = statSync5(file, { bigint: true });
|
|
21999
22452
|
return `${stat.size}:${stat.mtimeNs}`;
|
|
22000
22453
|
};
|
|
22001
22454
|
for (const object2 of args.prebuilt.objects)
|
|
@@ -22034,7 +22487,7 @@ function retireSwiftLinkTargets(retired) {
|
|
|
22034
22487
|
rmSync7(path33.join(retired, name), { recursive: true, force: true });
|
|
22035
22488
|
}
|
|
22036
22489
|
const releaseLink = path33.join(retired, "release");
|
|
22037
|
-
if (!
|
|
22490
|
+
if (!existsSync9(releaseLink)) return;
|
|
22038
22491
|
const releaseDir = realpathSync6(releaseLink);
|
|
22039
22492
|
for (const entry of readdirSync6(releaseDir, { withFileTypes: true })) {
|
|
22040
22493
|
const targetPath = path33.join(releaseDir, entry.name);
|
|
@@ -22063,7 +22516,7 @@ ${stamp}`;
|
|
|
22063
22516
|
writeFileSync8(receipt, `${combined}
|
|
22064
22517
|
`);
|
|
22065
22518
|
const retired = path33.join(root, ".build");
|
|
22066
|
-
if (previous === combined || !
|
|
22519
|
+
if (previous === combined || !existsSync9(retired)) return false;
|
|
22067
22520
|
const [previousBase] = previous?.split("\n") ?? [];
|
|
22068
22521
|
if (preserveClangObjects && previousBase === baseStamp) {
|
|
22069
22522
|
retireSwiftLinkTargets(retired);
|
|
@@ -22092,7 +22545,7 @@ async function compileSwiftProjectOnce(sources, options) {
|
|
|
22092
22545
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
22093
22546
|
const mirrorDistribution = options.linkOnly || options.project ? null : distribution;
|
|
22094
22547
|
if (distribution) refreshSwiftCacheHold(moduleRoot);
|
|
22095
|
-
const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-
|
|
22548
|
+
const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-W3VMDYHC.mjs")).useSwiftPackagePrebuilts(
|
|
22096
22549
|
sources,
|
|
22097
22550
|
moduleRoot,
|
|
22098
22551
|
options.toolchainBin
|
|
@@ -22106,7 +22559,7 @@ async function compileSwiftProjectOnce(sources, options) {
|
|
|
22106
22559
|
multi: compileTargets(input).length > 0
|
|
22107
22560
|
};
|
|
22108
22561
|
const sdkModule = options.sdkModule && !options.linkOnly;
|
|
22109
|
-
const sdkImage = sdkModule ? await (await import("./swift-sdk-image-
|
|
22562
|
+
const sdkImage = sdkModule ? await (await import("./swift-sdk-image-2PC4PKHZ.mjs")).buildSwiftSdkImage(
|
|
22110
22563
|
moduleRoot,
|
|
22111
22564
|
!!guestGraph,
|
|
22112
22565
|
distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
|
|
@@ -22222,7 +22675,7 @@ ${cap}` : "";
|
|
|
22222
22675
|
}
|
|
22223
22676
|
}
|
|
22224
22677
|
const swift = path33.join(options.toolchainBin, "swift");
|
|
22225
|
-
if (!
|
|
22678
|
+
if (!existsSync9(swift)) {
|
|
22226
22679
|
throw new Error(
|
|
22227
22680
|
`swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
|
|
22228
22681
|
);
|
|
@@ -22235,8 +22688,8 @@ ${cap}` : "";
|
|
|
22235
22688
|
work,
|
|
22236
22689
|
unoptimized
|
|
22237
22690
|
);
|
|
22238
|
-
const baseBuildEnv = {
|
|
22239
|
-
...options.project
|
|
22691
|
+
const baseBuildEnv = options.project?.env ? {
|
|
22692
|
+
...options.project.env,
|
|
22240
22693
|
// shipped host plugins resolve against the selected compiler's runtime.
|
|
22241
22694
|
...process.platform === "linux" ? {
|
|
22242
22695
|
LD_LIBRARY_PATH: [
|
|
@@ -22246,7 +22699,7 @@ ${cap}` : "";
|
|
|
22246
22699
|
].filter(Boolean).join(":")
|
|
22247
22700
|
} : {},
|
|
22248
22701
|
PEACH_DEFER_WASM_LINK: "1"
|
|
22249
|
-
};
|
|
22702
|
+
} : swiftCompilerBaseEnv(options.toolchainBin, process.env);
|
|
22250
22703
|
const {
|
|
22251
22704
|
frameworkRoot,
|
|
22252
22705
|
compileFrameworkRoot,
|
|
@@ -22342,7 +22795,7 @@ ${cap}` : "";
|
|
|
22342
22795
|
writeSwiftAutolinkLinker(
|
|
22343
22796
|
root,
|
|
22344
22797
|
options.toolchainBin,
|
|
22345
|
-
|
|
22798
|
+
existsSync9(productFile) ? [
|
|
22346
22799
|
parse(
|
|
22347
22800
|
swiftFrameworkProductSchema,
|
|
22348
22801
|
JSON.parse(readFileSync16(productFile, "utf8"))
|
|
@@ -22390,7 +22843,11 @@ ${cap}` : "";
|
|
|
22390
22843
|
} : {
|
|
22391
22844
|
...buildOptions,
|
|
22392
22845
|
temporaryDirectory,
|
|
22393
|
-
env: {
|
|
22846
|
+
env: {
|
|
22847
|
+
...buildOptions.env,
|
|
22848
|
+
...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
|
|
22849
|
+
...compiler
|
|
22850
|
+
}
|
|
22394
22851
|
};
|
|
22395
22852
|
const unprepared = preparation.targetFailures.map(
|
|
22396
22853
|
(failure) => `error: target ${failure}`
|
|
@@ -22437,10 +22894,18 @@ ${cap}` : "";
|
|
|
22437
22894
|
// the mirror finds a changed sdk header's readers in their
|
|
22438
22895
|
// dependency files, which omit system headers by default
|
|
22439
22896
|
...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
|
|
22440
|
-
// 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.
|
|
22441
22901
|
"-Xswiftc",
|
|
22442
22902
|
"-gnone",
|
|
22443
|
-
...incrementalPreview ? [] : [
|
|
22903
|
+
...incrementalPreview ? [] : [
|
|
22904
|
+
"-Xswiftc",
|
|
22905
|
+
"-num-threads",
|
|
22906
|
+
"-Xswiftc",
|
|
22907
|
+
String(perFile ? 1 : Math.min(8, os4.availableParallelism()))
|
|
22908
|
+
],
|
|
22444
22909
|
...swiftReproducibleBuildFlags([
|
|
22445
22910
|
[path33.dirname(options.toolchainBin), "toolchain"],
|
|
22446
22911
|
[compileFrameworkRoot, "framework"],
|
|
@@ -22479,7 +22944,7 @@ ${cap}` : "";
|
|
|
22479
22944
|
];
|
|
22480
22945
|
const linked = builtArtifact(layout2);
|
|
22481
22946
|
rmSync7(path33.join(root, ".peach-link.rsp"), { force: true });
|
|
22482
|
-
if (options.linkOnly ||
|
|
22947
|
+
if (options.linkOnly || existsSync9(linked) && statSync5(linked).size <= 8)
|
|
22483
22948
|
rmSync7(linked, { force: true });
|
|
22484
22949
|
report("compiling and linking Swift modules");
|
|
22485
22950
|
const frameworkInterfaces = /* @__PURE__ */ new Map();
|
|
@@ -22517,13 +22982,13 @@ ${cap}` : "";
|
|
|
22517
22982
|
const frameworkInterface = (name) => {
|
|
22518
22983
|
if (frameworkInterfaces.has(name)) return frameworkInterfaces.get(name);
|
|
22519
22984
|
const source = distribution ? path33.join(frameworkRoot, "modules", `${name}-Swift.h`) : prebuilt.objcHeaders.get(name);
|
|
22520
|
-
if (!source || !
|
|
22985
|
+
if (!source || !existsSync9(source)) {
|
|
22521
22986
|
frameworkInterfaces.set(name, null);
|
|
22522
22987
|
return null;
|
|
22523
22988
|
}
|
|
22524
22989
|
const headers = path33.join(sdkFrameworks, `${name}.framework/Headers`);
|
|
22525
22990
|
const declared = /* @__PURE__ */ new Set();
|
|
22526
|
-
if (
|
|
22991
|
+
if (existsSync9(headers)) {
|
|
22527
22992
|
for (const file of readdirSync6(headers, {
|
|
22528
22993
|
recursive: true,
|
|
22529
22994
|
encoding: "utf8"
|
|
@@ -22561,12 +23026,12 @@ ${cap}` : "";
|
|
|
22561
23026
|
const value = {
|
|
22562
23027
|
file: path33.join(root, ".build/peach-framework-objc", `${name}-Swift.h`),
|
|
22563
23028
|
header,
|
|
22564
|
-
module:
|
|
23029
|
+
module: existsSync9(headers)
|
|
22565
23030
|
};
|
|
22566
23031
|
frameworkInterfaces.set(name, value);
|
|
22567
23032
|
writeBuildFile(
|
|
22568
23033
|
value.file,
|
|
22569
|
-
(
|
|
23034
|
+
(existsSync9(path33.join(headers, `${name}.h`)) ? `#import <${name}/${name}.h>
|
|
22570
23035
|
` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
|
|
22571
23036
|
);
|
|
22572
23037
|
return value;
|
|
@@ -22615,29 +23080,40 @@ ${cap}` : "";
|
|
|
22615
23080
|
}))
|
|
22616
23081
|
];
|
|
22617
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);
|
|
22618
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
|
+
}
|
|
22619
23095
|
const receipt = path33.join(
|
|
22620
23096
|
checkpoints,
|
|
22621
23097
|
createHash18("sha256").update(target).digest("hex")
|
|
22622
23098
|
);
|
|
22623
23099
|
const headers = producers.map(headerPaths);
|
|
22624
23100
|
for (const header of headers)
|
|
22625
|
-
if (
|
|
23101
|
+
if (existsSync9(header.original)) publishHeader(header);
|
|
22626
23102
|
const fingerprint = () => {
|
|
22627
23103
|
const digest = createHash18("sha256").update(recipe);
|
|
22628
23104
|
for (const { original, emitted } of headers) {
|
|
22629
|
-
if (!
|
|
23105
|
+
if (!existsSync9(original) || !existsSync9(emitted)) return;
|
|
22630
23106
|
digest.update(
|
|
22631
23107
|
createHash18("sha256").update(readFileSync16(emitted)).digest()
|
|
22632
23108
|
);
|
|
22633
23109
|
}
|
|
22634
23110
|
return digest.digest("hex");
|
|
22635
23111
|
};
|
|
22636
|
-
if (!options.project &&
|
|
23112
|
+
if (!options.project && existsSync9(receipt) && readFileSync16(receipt, "utf8") === fingerprint())
|
|
22637
23113
|
continue;
|
|
22638
23114
|
if (!options.project) rmSync7(receipt, { force: true });
|
|
22639
23115
|
for (const header of headers) {
|
|
22640
|
-
if (!
|
|
23116
|
+
if (!existsSync9(header.original))
|
|
22641
23117
|
rmSync7(
|
|
22642
23118
|
path33.join(
|
|
22643
23119
|
path33.dirname(linked),
|
|
@@ -22702,7 +23178,7 @@ ${cap}` : "";
|
|
|
22702
23178
|
"release",
|
|
22703
23179
|
"ModuleCache"
|
|
22704
23180
|
);
|
|
22705
|
-
if (output2.includes("was compiled with module cache path") &&
|
|
23181
|
+
if (output2.includes("was compiled with module cache path") && existsSync9(moduleCache)) {
|
|
22706
23182
|
rmSync7(moduleCache, { recursive: true, force: true });
|
|
22707
23183
|
try {
|
|
22708
23184
|
await compileApp();
|
|
@@ -22729,9 +23205,9 @@ ${cap}` : "";
|
|
|
22729
23205
|
if (options.project) endSwiftProjectProcesses(options.project);
|
|
22730
23206
|
}
|
|
22731
23207
|
if (unprepared.length) throw new Error(unprepared.join("\n"));
|
|
22732
|
-
if (!
|
|
23208
|
+
if (!existsSync9(linked)) {
|
|
22733
23209
|
const binDir = path33.dirname(linked);
|
|
22734
|
-
const found =
|
|
23210
|
+
const found = existsSync9(binDir) ? readdirSync6(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
|
|
22735
23211
|
throw new Error(
|
|
22736
23212
|
`swift-compile: the build produced no ${path33.basename(linked)} (found: ${found.join(", ") || "none"})`
|
|
22737
23213
|
);
|
|
@@ -22751,7 +23227,7 @@ ${cap}` : "";
|
|
|
22751
23227
|
resourceReferences
|
|
22752
23228
|
);
|
|
22753
23229
|
if (options.linkOnly) {
|
|
22754
|
-
if (
|
|
23230
|
+
if (statSync5(linked).size <= 8)
|
|
22755
23231
|
throw new Error("swift-compile: deferred linker produced no executable");
|
|
22756
23232
|
report("project link verified");
|
|
22757
23233
|
return;
|
|
@@ -22788,7 +23264,7 @@ ${cap}` : "";
|
|
|
22788
23264
|
if (sdkImage && binding)
|
|
22789
23265
|
sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
|
|
22790
23266
|
} else if (sdkImage) {
|
|
22791
|
-
const { buildSwiftAppModule } = await import("./swift-sdk-app-module-
|
|
23267
|
+
const { buildSwiftAppModule } = await import("./swift-sdk-app-module-ZHGBY6T7.mjs");
|
|
22792
23268
|
const binding = await buildSwiftAppModule({
|
|
22793
23269
|
buildRoot: root,
|
|
22794
23270
|
toolchainBin: options.toolchainBin,
|