peachsim 0.1.2590 → 0.1.2592
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 +4184 -3613
- 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 +2 -2
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-65FNEARV.mjs → acorn-67PU73QE.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-X2EKFONU.mjs → chunk-5FTHILIE.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ADKUIQXX.mjs → chunk-6DB5FR7S.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WPDY5IAD.mjs → chunk-CF3MTPMY.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-RGC2JNCL.mjs → chunk-D4LYKRRB.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-EFKDUMB5.mjs → chunk-DFF5XZ5M.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-2GUB5OLB.mjs → chunk-EHRSWFTD.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-NZY4GOG5.mjs → chunk-EITX573K.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-SLPXTLBK.mjs → chunk-EWHA6X3Z.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-BZS5SIYK.mjs → chunk-FYXXFYML.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-JG4AANWA.mjs → chunk-GQ3EO2UV.mjs} +107 -6
- package/dist-lib/esm-chunks/{chunk-N2II5SRJ.mjs → chunk-GY6TE4B4.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-HZTK7TP5.mjs → chunk-KDI5YYQ6.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4VCRUQ36.mjs → chunk-L5T3HBPO.mjs} +973 -549
- package/dist-lib/esm-chunks/{chunk-SRFKOU76.mjs → chunk-M4QLI2SY.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-OZJ66CXY.mjs → chunk-PITO2NI2.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-5GNGHM5B.mjs → chunk-QSFWBVUO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-YPPH6F77.mjs → chunk-R3WTQB5J.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-XE3VHAU2.mjs → chunk-RV4ACE6R.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-GBD26EBV.mjs → chunk-SW4PSSTF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-V5TTEXYO.mjs → chunk-TJZPNFVF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WYDRQRJL.mjs → chunk-XSQH4R5E.mjs} +48 -15
- package/dist-lib/esm-chunks/{chunk-462CWTWI.mjs → chunk-XZ3FX3HW.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-CRI3GMCM.mjs → metro-layout-parser-EX65MARK.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-5XDZ2HZZ.mjs → swift-package-prebuilt-3BPDQVA7.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-6H3G6AXD.mjs → swift-sdk-app-module-CRX6E3TR.mjs} +151 -67
- package/dist-lib/esm-chunks/{swift-sdk-image-WAC7GG2R.mjs → swift-sdk-image-EJD5TPQH.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-B3L27QTG.mjs → swift-sdk-image-producer-QAZOSLTZ.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +3555 -2987
- 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 +5981 -4986
- package/dist-lib/host/fetch-proxy-handler.cjs +310 -298
- 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 +238 -223
- package/dist-lib/native-app-identity-project.mjs +17 -17
- 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 +73 -71
- 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 +6603 -5608
- package/dist-lib/swift-compile.cjs +1363 -778
- 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 +12 -6
- 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/engine/native-node-queries.d.ts +1 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/src/native-bundles.ts +2 -0
- package/src/one-native-controls-package.ts +141 -31
- package/src/one-sdk/source.ts +2 -1
- package/src/oneSdkContract.ts +13 -2
- package/src/swift-compile.ts +301 -48
- package/src/swift-guest-compile.ts +41 -8
- package/src/swift-guest-link.ts +3 -0
- package/src/swift-guest-source-inputs.ts +158 -30
- package/src/swift-host.ts +88 -16
- package/src/swift-reproducible.ts +16 -2
- package/src/swift-root-lock.ts +77 -5
- package/src/swift-sdk-app-module.ts +146 -59
- package/src/swift-sdk-image.ts +53 -10
- package/src/swift-startup-split.ts +65 -27
- package/src/swift-toolchain.ts +16 -5
- package/src/wasm-lazy-split.ts +46 -40
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2592 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
import {
|
|
3
3
|
SWIFT_AUTOLINK_LINKER,
|
|
4
4
|
SWIFT_CACHE_HOLD_MARKER,
|
|
5
5
|
SWIFT_WASM_TRIPLE,
|
|
6
|
+
acquireSwiftRootReadHold,
|
|
7
|
+
hasLiveSwiftRootReaders,
|
|
6
8
|
refreshSwiftCacheHold,
|
|
7
9
|
sourceSwiftCheckout,
|
|
8
10
|
swiftCacheDir,
|
|
@@ -13,12 +15,13 @@ import {
|
|
|
13
15
|
swiftSourceSdk,
|
|
14
16
|
swiftToolchain,
|
|
15
17
|
terminateProcessGroup,
|
|
18
|
+
waitForNoSwiftRootReaders,
|
|
16
19
|
wasmThreadFlags,
|
|
17
20
|
wasmThreadLinkFlags,
|
|
18
21
|
windowAdmission,
|
|
19
22
|
withSwiftRootLock,
|
|
20
23
|
writeSwiftAutolinkLinker
|
|
21
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-GQ3EO2UV.mjs";
|
|
22
25
|
import {
|
|
23
26
|
SWIFT_BINARY_TREES_DIR,
|
|
24
27
|
SWIFT_NATIVE_INPUT_ROOT,
|
|
@@ -33,7 +36,7 @@ import {
|
|
|
33
36
|
isSwiftResourcePath,
|
|
34
37
|
isSwiftSourceLinkGraph,
|
|
35
38
|
swiftProjectFilesProblems
|
|
36
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-QSFWBVUO.mjs";
|
|
37
40
|
import {
|
|
38
41
|
OBJC_RESOURCE_ACCESSOR_BODY,
|
|
39
42
|
OBJC_RESOURCE_ACCESSOR_HEADER,
|
|
@@ -57,20 +60,21 @@ import {
|
|
|
57
60
|
swiftPackagePartition,
|
|
58
61
|
swiftTargetModuleName,
|
|
59
62
|
withoutGlogModuleMap
|
|
60
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-SW4PSSTF.mjs";
|
|
61
64
|
import {
|
|
62
65
|
rnxPublicBrand
|
|
63
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-6DB5FR7S.mjs";
|
|
64
67
|
import {
|
|
65
68
|
isRecord
|
|
66
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-CF3MTPMY.mjs";
|
|
67
70
|
import {
|
|
68
71
|
__publicField
|
|
69
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-EITX573K.mjs";
|
|
70
73
|
|
|
71
74
|
// src/swift-compile.ts
|
|
72
75
|
import {
|
|
73
76
|
spawn as spawn2,
|
|
77
|
+
spawnSync as spawnSync5,
|
|
74
78
|
execFileSync as execFileSync13
|
|
75
79
|
} from "node:child_process";
|
|
76
80
|
import { createHash as createHash18, randomUUID as randomUUID5 } from "node:crypto";
|
|
@@ -78,7 +82,7 @@ import {
|
|
|
78
82
|
chmodSync as chmodSync3,
|
|
79
83
|
copyFileSync as copyFileSync2,
|
|
80
84
|
cpSync,
|
|
81
|
-
existsSync as
|
|
85
|
+
existsSync as existsSync10,
|
|
82
86
|
lstatSync,
|
|
83
87
|
mkdirSync as mkdirSync8,
|
|
84
88
|
mkdtempSync as mkdtempSync4,
|
|
@@ -94,7 +98,7 @@ import {
|
|
|
94
98
|
writeFileSync as writeFileSync8
|
|
95
99
|
} from "node:fs";
|
|
96
100
|
import os4 from "node:os";
|
|
97
|
-
import
|
|
101
|
+
import path33 from "node:path";
|
|
98
102
|
|
|
99
103
|
// ../../node_modules/valibot/dist/index.mjs
|
|
100
104
|
var store$4;
|
|
@@ -511,6 +515,54 @@ function string(message$1) {
|
|
|
511
515
|
};
|
|
512
516
|
}
|
|
513
517
|
// @__NO_SIDE_EFFECTS__
|
|
518
|
+
function tuple(items, message$1) {
|
|
519
|
+
return {
|
|
520
|
+
kind: "schema",
|
|
521
|
+
type: "tuple",
|
|
522
|
+
reference: tuple,
|
|
523
|
+
expects: "Array",
|
|
524
|
+
async: false,
|
|
525
|
+
items,
|
|
526
|
+
message: message$1,
|
|
527
|
+
get "~standard"() {
|
|
528
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
529
|
+
},
|
|
530
|
+
"~run"(dataset, config$1) {
|
|
531
|
+
const input = dataset.value;
|
|
532
|
+
if (Array.isArray(input)) {
|
|
533
|
+
dataset.typed = true;
|
|
534
|
+
dataset.value = [];
|
|
535
|
+
for (let key = 0; key < this.items.length; key++) {
|
|
536
|
+
const value$1 = input[key];
|
|
537
|
+
const itemDataset = this.items[key]["~run"]({ value: value$1 }, config$1);
|
|
538
|
+
if (itemDataset.issues) {
|
|
539
|
+
const pathItem = {
|
|
540
|
+
type: "array",
|
|
541
|
+
origin: "value",
|
|
542
|
+
input,
|
|
543
|
+
key,
|
|
544
|
+
value: value$1
|
|
545
|
+
};
|
|
546
|
+
for (const issue of itemDataset.issues) {
|
|
547
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
548
|
+
else issue.path = [pathItem];
|
|
549
|
+
dataset.issues?.push(issue);
|
|
550
|
+
}
|
|
551
|
+
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
552
|
+
if (config$1.abortEarly) {
|
|
553
|
+
dataset.typed = false;
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
if (!itemDataset.typed) dataset.typed = false;
|
|
558
|
+
dataset.value.push(itemDataset.value);
|
|
559
|
+
}
|
|
560
|
+
} else _addIssue(this, "type", dataset, config$1);
|
|
561
|
+
return dataset;
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
// @__NO_SIDE_EFFECTS__
|
|
514
566
|
function unknown() {
|
|
515
567
|
return {
|
|
516
568
|
kind: "schema",
|
|
@@ -3751,8 +3803,8 @@ function designTimeSites(source) {
|
|
|
3751
3803
|
sites.push({ kind: "boolean", start: token.start, end: token.end, value: word });
|
|
3752
3804
|
} else if (token.kind === "number") {
|
|
3753
3805
|
const kind = numberKind(word);
|
|
3754
|
-
const
|
|
3755
|
-
if (kind && !
|
|
3806
|
+
const tuple2 = source[token.start - 1] === "." && source[token.start - 2] !== ".";
|
|
3807
|
+
if (kind && !tuple2) {
|
|
3756
3808
|
const minus = tokens[t - 1];
|
|
3757
3809
|
const negative = minus !== void 0 && text(source, minus) === "-" && minus.end === token.start && t - 1 >= from && !/[^\s([{,;:=]/.test(source[minus.start - 1] ?? " ");
|
|
3758
3810
|
const start = negative ? minus.start : token.start;
|
|
@@ -3841,9 +3893,9 @@ var EXCERPT = /^(\s*)(\d+)( \| )(.*)$/;
|
|
|
3841
3893
|
var MARKER = /^(\s*)( \| )(.*)$/;
|
|
3842
3894
|
function designTimeDiagnostic(output, files) {
|
|
3843
3895
|
const rewritten = /* @__PURE__ */ new Map();
|
|
3844
|
-
const linesOf = (
|
|
3896
|
+
const linesOf = (path34) => {
|
|
3845
3897
|
const file = Object.keys(files).find(
|
|
3846
|
-
(name) => name.endsWith(".swift") && (
|
|
3898
|
+
(name) => name.endsWith(".swift") && (path34 === name || path34.endsWith(`/${name}`))
|
|
3847
3899
|
);
|
|
3848
3900
|
if (file === void 0) return null;
|
|
3849
3901
|
let lines = rewritten.get(file);
|
|
@@ -12730,6 +12782,7 @@ function linkGuestImages(options) {
|
|
|
12730
12782
|
{ stdio: "pipe" }
|
|
12731
12783
|
);
|
|
12732
12784
|
finalTrace = linkFinal(projectionObject, callerMap ? void 0 : layoutMap);
|
|
12785
|
+
if (sharedSdk) break;
|
|
12733
12786
|
const wasm = fs9.readFileSync(finalOutput);
|
|
12734
12787
|
const actual = guestProjectionRegionCounts(
|
|
12735
12788
|
images.length,
|
|
@@ -13477,27 +13530,131 @@ function clangIrLinkOptions(ir) {
|
|
|
13477
13530
|
var CLANG_TARGET_MODULE_WRAPPER = ".peach-clang";
|
|
13478
13531
|
var PARALLEL_REPLAY = `
|
|
13479
13532
|
const { spawn } = require('node:child_process')
|
|
13480
|
-
const
|
|
13533
|
+
const fs = require('node:fs')
|
|
13534
|
+
const commands = JSON.parse(fs.readFileSync(process.env.PEACH_CLANG_REPLAYS, 'utf8'))
|
|
13535
|
+
const results = new Array(commands.length)
|
|
13481
13536
|
let next = 0
|
|
13482
13537
|
const run = () => {
|
|
13483
13538
|
if (next >= commands.length) return Promise.resolve()
|
|
13484
|
-
const
|
|
13539
|
+
const index = next++
|
|
13540
|
+
const [file, ...args] = commands[index]
|
|
13485
13541
|
return new Promise((resolve, reject) => {
|
|
13486
|
-
const child = spawn(file, args, { stdio: 'inherit' })
|
|
13542
|
+
const child = spawn(file, args, { stdio: ['ignore', 'pipe', 'inherit'] })
|
|
13543
|
+
const metadata = []
|
|
13544
|
+
let pending = ''
|
|
13545
|
+
child.stdout.setEncoding('utf8')
|
|
13546
|
+
child.stdout.on('data', (chunk) => {
|
|
13547
|
+
const text = pending + chunk
|
|
13548
|
+
let start = 0
|
|
13549
|
+
for (let nl = text.indexOf('\\n'); nl !== -1; nl = text.indexOf('\\n', start)) {
|
|
13550
|
+
if (text.charCodeAt(start) === 33) metadata.push(text.slice(start, nl))
|
|
13551
|
+
start = nl + 1
|
|
13552
|
+
}
|
|
13553
|
+
pending = text.slice(start)
|
|
13554
|
+
})
|
|
13487
13555
|
child.on('error', reject)
|
|
13488
|
-
child.on('close', (code) =>
|
|
13556
|
+
child.on('close', (code) => {
|
|
13557
|
+
if (pending.charCodeAt(0) === 33) metadata.push(pending)
|
|
13558
|
+
if (code === 0) {
|
|
13559
|
+
results[index] = metadata.join('\\n')
|
|
13560
|
+
resolve()
|
|
13561
|
+
} else reject(new Error('clang link replay failed: ' + file))
|
|
13562
|
+
})
|
|
13489
13563
|
}).then(run)
|
|
13490
13564
|
}
|
|
13491
13565
|
const jobs = Math.max(1, Number(process.env.PEACH_CLANG_JOBS) || 1)
|
|
13492
|
-
Promise.all(Array.from({ length: jobs }, run))
|
|
13493
|
-
|
|
13494
|
-
|
|
13495
|
-
})
|
|
13566
|
+
Promise.all(Array.from({ length: jobs }, run))
|
|
13567
|
+
.then(() => {
|
|
13568
|
+
fs.writeFileSync(process.env.PEACH_CLANG_RESULTS, JSON.stringify(results))
|
|
13569
|
+
})
|
|
13570
|
+
.catch((error) => {
|
|
13571
|
+
console.error(error.message)
|
|
13572
|
+
process.exit(1)
|
|
13573
|
+
})
|
|
13496
13574
|
`;
|
|
13497
13575
|
function clangProducerStamp(file) {
|
|
13498
13576
|
const stat = statSync(file, { bigint: true });
|
|
13499
13577
|
return [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(":");
|
|
13500
13578
|
}
|
|
13579
|
+
function clangBinaryStamp(file) {
|
|
13580
|
+
const stat = statSync(file, { bigint: true });
|
|
13581
|
+
return [file, stat.size, stat.mtimeNs].join(":");
|
|
13582
|
+
}
|
|
13583
|
+
function clangWrapperStamp(file) {
|
|
13584
|
+
return createHash12("sha256").update(readFileSync11(file)).digest("hex");
|
|
13585
|
+
}
|
|
13586
|
+
function clangArgsNeedCwd(args) {
|
|
13587
|
+
const pathFlags = /* @__PURE__ */ new Set([
|
|
13588
|
+
"-I",
|
|
13589
|
+
"-isystem",
|
|
13590
|
+
"-iquote",
|
|
13591
|
+
"-F",
|
|
13592
|
+
"-iframework",
|
|
13593
|
+
"-isysroot",
|
|
13594
|
+
"-o",
|
|
13595
|
+
"-MF"
|
|
13596
|
+
]);
|
|
13597
|
+
const includeFlags = /* @__PURE__ */ new Set(["-include", "-imacros"]);
|
|
13598
|
+
const valueFlags = /* @__PURE__ */ new Set([
|
|
13599
|
+
"-x",
|
|
13600
|
+
"-target",
|
|
13601
|
+
"-MT",
|
|
13602
|
+
"-MQ",
|
|
13603
|
+
"-D",
|
|
13604
|
+
"-U",
|
|
13605
|
+
"-mllvm",
|
|
13606
|
+
"-Xclang",
|
|
13607
|
+
"-arch",
|
|
13608
|
+
"-std"
|
|
13609
|
+
]);
|
|
13610
|
+
const prefixFlags = [
|
|
13611
|
+
"-I",
|
|
13612
|
+
"-F",
|
|
13613
|
+
"-isystem",
|
|
13614
|
+
"-iquote",
|
|
13615
|
+
"--sysroot=",
|
|
13616
|
+
"-fmodule-map-file=",
|
|
13617
|
+
"-fmodules-cache-path="
|
|
13618
|
+
];
|
|
13619
|
+
const isRelativePath = (value) => value.length > 0 && !value.startsWith("/") && !value.startsWith("=/") && value !== "-";
|
|
13620
|
+
for (let i = 1; i < args.length; i++) {
|
|
13621
|
+
const arg = args[i];
|
|
13622
|
+
if (pathFlags.has(arg)) {
|
|
13623
|
+
if (isRelativePath(args[++i] ?? "")) return true;
|
|
13624
|
+
continue;
|
|
13625
|
+
}
|
|
13626
|
+
if (includeFlags.has(arg)) {
|
|
13627
|
+
const value = args[++i] ?? "";
|
|
13628
|
+
if (isRelativePath(value) && (value.includes("/") || existsSync4(value))) return true;
|
|
13629
|
+
continue;
|
|
13630
|
+
}
|
|
13631
|
+
if (valueFlags.has(arg)) {
|
|
13632
|
+
i++;
|
|
13633
|
+
continue;
|
|
13634
|
+
}
|
|
13635
|
+
if (arg.startsWith("@")) {
|
|
13636
|
+
if (isRelativePath(arg.slice(1))) return true;
|
|
13637
|
+
continue;
|
|
13638
|
+
}
|
|
13639
|
+
if (arg.startsWith("-")) {
|
|
13640
|
+
if (arg.startsWith("-include") && arg.length > 8) {
|
|
13641
|
+
const value = arg.slice(8);
|
|
13642
|
+
if (isRelativePath(value) && (value.includes("/") || existsSync4(value)))
|
|
13643
|
+
return true;
|
|
13644
|
+
continue;
|
|
13645
|
+
}
|
|
13646
|
+
for (const prefix of prefixFlags) {
|
|
13647
|
+
if (arg.startsWith(prefix) && arg.length > prefix.length) {
|
|
13648
|
+
if (isRelativePath(arg.slice(prefix.length))) return true;
|
|
13649
|
+
break;
|
|
13650
|
+
}
|
|
13651
|
+
}
|
|
13652
|
+
continue;
|
|
13653
|
+
}
|
|
13654
|
+
if (isRelativePath(arg)) return true;
|
|
13655
|
+
}
|
|
13656
|
+
return false;
|
|
13657
|
+
}
|
|
13501
13658
|
function validateClangLinkOptions(flags) {
|
|
13502
13659
|
for (let index = 0; index < flags.length; index++) {
|
|
13503
13660
|
const flag = flags[index];
|
|
@@ -13577,7 +13734,7 @@ function sourceGuestClangLinkOptions(options) {
|
|
|
13577
13734
|
let clang;
|
|
13578
13735
|
let clangStamp;
|
|
13579
13736
|
let wrapperStamp;
|
|
13580
|
-
for (const
|
|
13737
|
+
for (const file of wanted) {
|
|
13581
13738
|
const command = commands.get(file);
|
|
13582
13739
|
if (!command) throw new Error(`missing source object producer ${file}`);
|
|
13583
13740
|
if (command.tool === "shell") {
|
|
@@ -13591,12 +13748,12 @@ function sourceGuestClangLinkOptions(options) {
|
|
|
13591
13748
|
throw new Error(`unsupported source object producer ${file}`);
|
|
13592
13749
|
const key = createHash12("sha256").update(
|
|
13593
13750
|
JSON.stringify([
|
|
13594
|
-
"clang-link-options/
|
|
13595
|
-
process.cwd(),
|
|
13751
|
+
"clang-link-options/v2",
|
|
13752
|
+
clangArgsNeedCwd(command.args) ? process.cwd() : null,
|
|
13596
13753
|
driverEnvironment,
|
|
13597
13754
|
command.args,
|
|
13598
|
-
clangStamp ?? (clangStamp =
|
|
13599
|
-
compiler === clang ? null : wrapperStamp ?? (wrapperStamp =
|
|
13755
|
+
clangStamp ?? (clangStamp = clangBinaryStamp(clang)),
|
|
13756
|
+
compiler === clang ? null : wrapperStamp ?? (wrapperStamp = clangWrapperStamp(compiler)),
|
|
13600
13757
|
clangProducerStamp(file)
|
|
13601
13758
|
])
|
|
13602
13759
|
).digest("hex");
|
|
@@ -13611,31 +13768,44 @@ function sourceGuestClangLinkOptions(options) {
|
|
|
13611
13768
|
continue;
|
|
13612
13769
|
}
|
|
13613
13770
|
result.set(file, []);
|
|
13614
|
-
const args = command.args.slice(1).filter((arg) => arg !== "-c");
|
|
13615
13771
|
const targetBuild = path21.relative(options.buildDirectory, file).split(path21.sep).findLast((part) => part !== ".build" && part.endsWith(".build"));
|
|
13616
|
-
const
|
|
13617
|
-
|
|
13618
|
-
|
|
13619
|
-
)
|
|
13620
|
-
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13772
|
+
const args = [];
|
|
13773
|
+
let sawOutput = false;
|
|
13774
|
+
let explicitModuleName = false;
|
|
13775
|
+
for (let i = 1; i < command.args.length; i++) {
|
|
13776
|
+
const arg = command.args[i];
|
|
13777
|
+
if (arg === "-c" || arg === "-MD" || arg === "-MMD" || arg === "-MP") continue;
|
|
13778
|
+
if (arg === "-MF" || arg === "-MT" || arg === "-MQ") {
|
|
13779
|
+
if (i + 1 >= command.args.length)
|
|
13780
|
+
throw new Error(`missing clang ${arg} for ${file}`);
|
|
13781
|
+
i++;
|
|
13782
|
+
continue;
|
|
13783
|
+
}
|
|
13784
|
+
if (arg === "-o") {
|
|
13785
|
+
if (i + 1 >= command.args.length) throw new Error(`missing clang -o for ${file}`);
|
|
13786
|
+
i++;
|
|
13787
|
+
args.push("-o", "-");
|
|
13788
|
+
sawOutput = true;
|
|
13789
|
+
continue;
|
|
13790
|
+
}
|
|
13791
|
+
if (arg.startsWith("-fmodule-name=")) explicitModuleName = true;
|
|
13792
|
+
args.push(arg);
|
|
13793
|
+
}
|
|
13794
|
+
if (!sawOutput) throw new Error(`missing clang -o for ${file}`);
|
|
13795
|
+
if (compiler !== clang && targetBuild && !explicitModuleName) {
|
|
13796
|
+
args.unshift(`-fmodule-name=${targetBuild.slice(0, -".build".length)}`);
|
|
13627
13797
|
}
|
|
13628
13798
|
replays.push({
|
|
13629
13799
|
file,
|
|
13630
13800
|
compiler: command.args[0],
|
|
13631
13801
|
args: [...args, "-S", "-emit-llvm", "-Xclang", "-disable-llvm-passes"],
|
|
13632
|
-
output,
|
|
13633
13802
|
cacheFile,
|
|
13634
13803
|
key
|
|
13635
13804
|
});
|
|
13636
13805
|
}
|
|
13637
13806
|
if (replays.length === 0) return result;
|
|
13638
13807
|
const plan = path21.join(options.directory, "clang-link-replays.json");
|
|
13808
|
+
const resultsPath = path21.join(options.directory, "clang-link-results.json");
|
|
13639
13809
|
writeFileSync5(
|
|
13640
13810
|
plan,
|
|
13641
13811
|
JSON.stringify(replays.map(({ compiler, args }) => [compiler, ...args]))
|
|
@@ -13648,12 +13818,16 @@ function sourceGuestClangLinkOptions(options) {
|
|
|
13648
13818
|
...process.env,
|
|
13649
13819
|
[PEACH_FORKED_SCRIPT_ENV]: "1",
|
|
13650
13820
|
PEACH_CLANG_REPLAYS: plan,
|
|
13821
|
+
PEACH_CLANG_RESULTS: resultsPath,
|
|
13651
13822
|
PEACH_CLANG_JOBS: String(options.jobs)
|
|
13652
13823
|
}
|
|
13653
13824
|
});
|
|
13825
|
+
const replayMetadata = JSON.parse(readFileSync11(resultsPath, "utf8"));
|
|
13826
|
+
if (!Array.isArray(replayMetadata) || replayMetadata.length !== replays.length || !replayMetadata.every((item) => typeof item === "string"))
|
|
13827
|
+
throw new Error("invalid clang link replay results");
|
|
13654
13828
|
mkdirSync4(cacheDirectory, { recursive: true });
|
|
13655
|
-
for (const { file,
|
|
13656
|
-
const flags = clangIrLinkOptions(
|
|
13829
|
+
for (const [index, { file, cacheFile, key }] of replays.entries()) {
|
|
13830
|
+
const flags = clangIrLinkOptions(replayMetadata[index]);
|
|
13657
13831
|
validateClangLinkOptions(flags);
|
|
13658
13832
|
const temporary = `${cacheFile}.${process.pid}`;
|
|
13659
13833
|
writeFileSync5(temporary, JSON.stringify({ key, flags }));
|
|
@@ -14060,13 +14234,13 @@ function swiftSdkGuestLookups(moduleRoot, sdkRoot, objects) {
|
|
|
14060
14234
|
const shared = /* @__PURE__ */ new Set();
|
|
14061
14235
|
const sdkWeakReferences = /* @__PURE__ */ new Map();
|
|
14062
14236
|
for (const objects2 of groups.values())
|
|
14063
|
-
for (const { path:
|
|
14237
|
+
for (const { path: path34, bytes } of objects2) {
|
|
14064
14238
|
const defined = guestWasmSymbols(bytes);
|
|
14065
14239
|
for (const name of defined.defined) symbols.add(name);
|
|
14066
14240
|
for (const name of defined.tags) shared.add(name);
|
|
14067
14241
|
for (const name of defined.globals) shared.add(name);
|
|
14068
14242
|
if (defined.weakUndefined.length)
|
|
14069
|
-
sdkWeakReferences.set(
|
|
14243
|
+
sdkWeakReferences.set(path34, new Set(defined.weakUndefined));
|
|
14070
14244
|
}
|
|
14071
14245
|
return createGuestImageLedger({
|
|
14072
14246
|
images,
|
|
@@ -14179,7 +14353,7 @@ async function compileGuestLink(options) {
|
|
|
14179
14353
|
let lazyFunctions = [];
|
|
14180
14354
|
let dyldSymbols = [];
|
|
14181
14355
|
const bundlePaths = new Map(
|
|
14182
|
-
options.resourceBundles.map(({ target, path:
|
|
14356
|
+
options.resourceBundles.map(({ target, path: path34 }) => [target, path34])
|
|
14183
14357
|
);
|
|
14184
14358
|
const imageMetadata = (products) => {
|
|
14185
14359
|
const source = sourceImages.map((image) => {
|
|
@@ -14213,7 +14387,7 @@ async function compileGuestLink(options) {
|
|
|
14213
14387
|
};
|
|
14214
14388
|
const sdk = options.sdkImage;
|
|
14215
14389
|
const sdkCallers = sdk?.sdkInterface.guestCallers;
|
|
14216
|
-
const sdkObjects = sdk ? (await import("./swift-sdk-image-
|
|
14390
|
+
const sdkObjects = sdk ? (await import("./swift-sdk-image-EJD5TPQH.mjs")).readSwiftSdkManifestIndex(sdk).guestObjects : void 0;
|
|
14217
14391
|
if (sdk && (!sdkCallers || !sdkObjects))
|
|
14218
14392
|
throw new Error("the SDK image has no guest link manifest");
|
|
14219
14393
|
const result = linkPrunedGuestImages({
|
|
@@ -14311,13 +14485,19 @@ async function compileGuestLink(options) {
|
|
|
14311
14485
|
const selectedSource = source.artifacts.filter(
|
|
14312
14486
|
(artifact) => selected.has(path24.resolve(rewritten.get(artifact.path) ?? artifact.path))
|
|
14313
14487
|
);
|
|
14488
|
+
const admittedCores = Number(process.env.TM_EXEC_CPU_CORES);
|
|
14489
|
+
const linuxMemory = process.env.TM_EXEC_ADMITTED === "1" && process.env.LINUX_BUILD_SCOPE ? Number(process.env.TM_EXEC_LINUX_MEMORY_MAX) : NaN;
|
|
14490
|
+
const clangReplayJobs = Number.isInteger(admittedCores) && admittedCores > 0 ? Math.min(
|
|
14491
|
+
admittedCores,
|
|
14492
|
+
Number.isSafeInteger(linuxMemory) && linuxMemory > 0 ? Math.max(options.jobs, Math.floor(linuxMemory / (512 * 1024 ** 2))) : Math.max(options.jobs, admittedCores)
|
|
14493
|
+
) : options.jobs;
|
|
14314
14494
|
const clangOptions2 = sourceGuestClangLinkOptions({
|
|
14315
14495
|
buildDirectory: options.buildDirectory,
|
|
14316
14496
|
directory,
|
|
14317
14497
|
toolchainBin: options.toolchainBin,
|
|
14318
14498
|
swiftCompiler: options.swiftCompiler,
|
|
14319
14499
|
objects: selectedSource.map((artifact) => artifact.path),
|
|
14320
|
-
jobs:
|
|
14500
|
+
jobs: clangReplayJobs
|
|
14321
14501
|
});
|
|
14322
14502
|
const links = sourceGuestRuntimeLinks({
|
|
14323
14503
|
toolchainBin: options.toolchainBin,
|
|
@@ -14499,8 +14679,9 @@ async function compileGuestLink(options) {
|
|
|
14499
14679
|
createSwiftSdkBinding,
|
|
14500
14680
|
finishSwiftAppModule,
|
|
14501
14681
|
linkSwiftAppModule,
|
|
14502
|
-
readSwiftSdkUsage
|
|
14503
|
-
|
|
14682
|
+
readSwiftSdkUsage,
|
|
14683
|
+
swiftSdkProjectionSpans
|
|
14684
|
+
} = await import("./swift-sdk-app-module-CRX6E3TR.mjs");
|
|
14504
14685
|
const project = options.project;
|
|
14505
14686
|
const work = project ? mkdtempSync2(path24.join(directory, "app-module-")) : path24.join(directory, "app-module");
|
|
14506
14687
|
if (project) chownSync(work, project.uid, project.gid);
|
|
@@ -14521,7 +14702,28 @@ async function compileGuestLink(options) {
|
|
|
14521
14702
|
}
|
|
14522
14703
|
const usage = readSwiftSdkUsage(result.mapPath, options.output, sdkObjectKeys);
|
|
14523
14704
|
const linkedModule = path24.join(work, "app.wasm");
|
|
14705
|
+
const sdkSpans = swiftSdkProjectionSpans(
|
|
14706
|
+
sdk,
|
|
14707
|
+
(object2, product) => sdkObjectImages.get(object2) ?? sdkProductImages.get(product)
|
|
14708
|
+
);
|
|
14524
14709
|
let storage = reserved;
|
|
14710
|
+
if (sdkSpans.length > 0) {
|
|
14711
|
+
const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
|
|
14712
|
+
storage = reserveGuestProjectionStorage(
|
|
14713
|
+
storage.images,
|
|
14714
|
+
storage.capacities.map((capacity, index) => ({
|
|
14715
|
+
...capacity,
|
|
14716
|
+
regions: capacity.regions + sdkCounts[index] + 16
|
|
14717
|
+
}))
|
|
14718
|
+
);
|
|
14719
|
+
const projectionSource = path24.join(work, "projection.c");
|
|
14720
|
+
writeFileSync6(projectionSource, storage.source);
|
|
14721
|
+
execFileSync10(
|
|
14722
|
+
path24.join(options.toolchainBin, "clang"),
|
|
14723
|
+
[...clangOptions, "-c", projectionSource, "-o", projectionObject],
|
|
14724
|
+
{ stdio: "pipe" }
|
|
14725
|
+
);
|
|
14726
|
+
}
|
|
14525
14727
|
for (; ; ) {
|
|
14526
14728
|
const link = await linkSwiftAppModule({
|
|
14527
14729
|
objects: [...owners.keys()],
|
|
@@ -14559,11 +14761,7 @@ async function compileGuestLink(options) {
|
|
|
14559
14761
|
bindingRows.set((address - values.address) / 8, value);
|
|
14560
14762
|
} else data.push(address, size, value);
|
|
14561
14763
|
}
|
|
14562
|
-
const
|
|
14563
|
-
const binding = createSwiftSdkBinding({ ...link.linkage, data }, sdk, usage, {
|
|
14564
|
-
imageFor: (object2, product) => sdkObjectImages.get(object2) ?? sdkProductImages.get(product),
|
|
14565
|
-
spans: sdkSpans
|
|
14566
|
-
});
|
|
14764
|
+
const binding = createSwiftSdkBinding({ ...link.linkage, data }, sdk, usage);
|
|
14567
14765
|
const linked = readFileSync13(
|
|
14568
14766
|
project ? projectOutputFile(work, linkedModule, project) : linkedModule
|
|
14569
14767
|
);
|
|
@@ -15479,8 +15677,8 @@ function sourceEntryPath() {
|
|
|
15479
15677
|
return null;
|
|
15480
15678
|
}
|
|
15481
15679
|
}
|
|
15482
|
-
function isCliEntry(
|
|
15483
|
-
const name = basename2(
|
|
15680
|
+
function isCliEntry(path34) {
|
|
15681
|
+
const name = basename2(path34);
|
|
15484
15682
|
return name === "bin.ts" || name === "bin.js";
|
|
15485
15683
|
}
|
|
15486
15684
|
function rnxSelfInvocation() {
|
|
@@ -15605,10 +15803,20 @@ function swiftObjCPrebuiltCompiler(clang, root, sysroot, distribution, targets,
|
|
|
15605
15803
|
}
|
|
15606
15804
|
|
|
15607
15805
|
// src/swift-reproducible.ts
|
|
15608
|
-
import { realpathSync as realpathSync5 } from "node:fs";
|
|
15806
|
+
import { existsSync as existsSync9, realpathSync as realpathSync5 } from "node:fs";
|
|
15609
15807
|
import os3 from "node:os";
|
|
15808
|
+
import path30 from "node:path";
|
|
15809
|
+
function canonicalHomeDir() {
|
|
15810
|
+
const home = os3.homedir();
|
|
15811
|
+
const dotPeach = path30.join(home, ".peach");
|
|
15812
|
+
if (existsSync9(dotPeach)) {
|
|
15813
|
+
const realHome = path30.dirname(realpathSync5(dotPeach));
|
|
15814
|
+
if (home === realHome || home.startsWith(`${realHome}${path30.sep}`)) return realHome;
|
|
15815
|
+
}
|
|
15816
|
+
return home;
|
|
15817
|
+
}
|
|
15610
15818
|
function swiftReproducibleBuildFlags(roots) {
|
|
15611
|
-
return [[
|
|
15819
|
+
return [[canonicalHomeDir(), "home"], ...roots].flatMap(
|
|
15612
15820
|
([root, name]) => [.../* @__PURE__ */ new Set([root, realpathSync5(root)])].map((from) => `${from}=/peach/${name}`)
|
|
15613
15821
|
).flatMap((map) => [
|
|
15614
15822
|
"-Xswiftc",
|
|
@@ -15673,12 +15881,12 @@ function collectSwiftSourceClosure(files, roots, swiftCodeMask2, extensionMember
|
|
|
15673
15881
|
|
|
15674
15882
|
// src/swift-uniform-type-constants.ts
|
|
15675
15883
|
import { execFileSync as execFileSync12 } from "node:child_process";
|
|
15676
|
-
import
|
|
15884
|
+
import path31 from "node:path";
|
|
15677
15885
|
function compileUniformTypeConstants(args) {
|
|
15678
|
-
const source =
|
|
15679
|
-
const object2 =
|
|
15886
|
+
const source = path31.join(args.packageRoot, "runtime/UniformTypeIdentifiersConstants.m");
|
|
15887
|
+
const object2 = path31.join(args.out, "UniformTypeIdentifiers-NativeConstants.o");
|
|
15680
15888
|
execFileSync12(
|
|
15681
|
-
|
|
15889
|
+
path31.join(args.bin, "clang"),
|
|
15682
15890
|
[
|
|
15683
15891
|
"--target=wasm64-unknown-wasip1-threads",
|
|
15684
15892
|
...wasmThreadFlags,
|
|
@@ -15688,7 +15896,7 @@ function compileUniformTypeConstants(args) {
|
|
|
15688
15896
|
...swiftObjCRuntimeFlags,
|
|
15689
15897
|
"-fwasm-exceptions",
|
|
15690
15898
|
"-F",
|
|
15691
|
-
|
|
15899
|
+
path31.resolve(args.packageRoot, "../peachsim/sdk/ios/System/Library/Frameworks"),
|
|
15692
15900
|
...objcSdkIntakeFlags(args.darwin, args.bin, args.minimum),
|
|
15693
15901
|
"-c",
|
|
15694
15902
|
source,
|
|
@@ -15702,12 +15910,12 @@ function compileUniformTypeConstants(args) {
|
|
|
15702
15910
|
|
|
15703
15911
|
// src/xcode-header-search.ts
|
|
15704
15912
|
import fs12 from "node:fs";
|
|
15705
|
-
import
|
|
15913
|
+
import path32 from "node:path";
|
|
15706
15914
|
function coalescibleHeaderOverlays(files) {
|
|
15707
15915
|
const aliases = /* @__PURE__ */ new Map();
|
|
15708
15916
|
const key = (file) => file.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
|
|
15709
15917
|
const index = (directory, entry) => {
|
|
15710
|
-
const name =
|
|
15918
|
+
const name = path32.resolve(directory, entry.name);
|
|
15711
15919
|
if (entry.type === "directory")
|
|
15712
15920
|
return entry.contents.every((child) => index(name, child));
|
|
15713
15921
|
const source = entry["external-contents"];
|
|
@@ -15718,11 +15926,11 @@ function coalescibleHeaderOverlays(files) {
|
|
|
15718
15926
|
};
|
|
15719
15927
|
for (const file of files) {
|
|
15720
15928
|
const overlay = JSON.parse(fs12.readFileSync(file, "utf8"));
|
|
15721
|
-
if (!overlay.roots.every((entry) => index(
|
|
15929
|
+
if (!overlay.roots.every((entry) => index(path32.dirname(file), entry)))
|
|
15722
15930
|
return /* @__PURE__ */ new Set();
|
|
15723
15931
|
}
|
|
15724
15932
|
for (const file of [...files, ...aliases.values()]) {
|
|
15725
|
-
const source = aliases.get(key(
|
|
15933
|
+
const source = aliases.get(key(path32.normalize(file)));
|
|
15726
15934
|
if (source !== void 0 && source !== file) return /* @__PURE__ */ new Set();
|
|
15727
15935
|
}
|
|
15728
15936
|
return files;
|
|
@@ -15782,11 +15990,11 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}, listed)
|
|
|
15782
15990
|
seen.add(file);
|
|
15783
15991
|
file = headerAliases[file];
|
|
15784
15992
|
}
|
|
15785
|
-
const listed2 = productDirectories.get(
|
|
15786
|
-
productDirectories.set(
|
|
15787
|
-
listed2.push({ name:
|
|
15993
|
+
const listed2 = productDirectories.get(path32.dirname(product)) ?? [];
|
|
15994
|
+
productDirectories.set(path32.dirname(product), listed2);
|
|
15995
|
+
listed2.push({ name: path32.basename(product), file });
|
|
15788
15996
|
}
|
|
15789
|
-
const overlay =
|
|
15997
|
+
const overlay = path32.join(directory, "all-product-headers.yaml");
|
|
15790
15998
|
writeBuildFile(
|
|
15791
15999
|
overlay,
|
|
15792
16000
|
JSON.stringify({
|
|
@@ -15806,7 +16014,7 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}, listed)
|
|
|
15806
16014
|
const files = [overlay];
|
|
15807
16015
|
const flags = targets.map((target, index) => {
|
|
15808
16016
|
const maps = target.headerMaps.map((map, order) => {
|
|
15809
|
-
const file =
|
|
16017
|
+
const file = path32.join(directory, `${index}-${order}.hmap`);
|
|
15810
16018
|
writeBuildFile(file, headerMap(map.entries));
|
|
15811
16019
|
files.push(file);
|
|
15812
16020
|
return { flag: map.flag, file };
|
|
@@ -15945,7 +16153,7 @@ function assertSwiftBuildCores() {
|
|
|
15945
16153
|
);
|
|
15946
16154
|
}
|
|
15947
16155
|
function swiftDistributionAt(root) {
|
|
15948
|
-
const file =
|
|
16156
|
+
const file = path33.join(root, SWIFT_DISTRIBUTION_MANIFEST);
|
|
15949
16157
|
const stat = statSync4(file, { bigint: true, throwIfNoEntry: false });
|
|
15950
16158
|
if (!stat) return null;
|
|
15951
16159
|
const identity = `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}`;
|
|
@@ -15959,28 +16167,28 @@ var distributionManifests = /* @__PURE__ */ new Map();
|
|
|
15959
16167
|
var distributionCompileViews = /* @__PURE__ */ new WeakMap();
|
|
15960
16168
|
function swiftDistributionCompileView(moduleRoot, distribution) {
|
|
15961
16169
|
let view = distributionCompileViews.get(distribution);
|
|
15962
|
-
if (!view || !
|
|
16170
|
+
if (!view || !existsSync10(view)) {
|
|
15963
16171
|
const inputs = Object.entries(distribution.files).filter(
|
|
15964
16172
|
([file]) => file.startsWith("host/") || file === SWIFT_DISTRIBUTION_OBJC_SELECTORS
|
|
15965
16173
|
).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
|
|
15966
16174
|
const digest = createHash18("sha256").update(JSON.stringify(inputs)).digest("hex");
|
|
15967
|
-
view =
|
|
15968
|
-
if (!
|
|
15969
|
-
mkdirSync8(
|
|
16175
|
+
view = path33.join(swiftCacheDir(), "swift-sdk-views", `compile-${digest}`);
|
|
16176
|
+
if (!existsSync10(view)) {
|
|
16177
|
+
mkdirSync8(path33.dirname(view), { recursive: true });
|
|
15970
16178
|
const staging = mkdtempSync4(`${view}-`);
|
|
15971
16179
|
try {
|
|
15972
16180
|
chmodSync3(staging, 493);
|
|
15973
16181
|
for (const [file] of inputs) {
|
|
15974
16182
|
if (!isSwiftResourcePath(file))
|
|
15975
16183
|
throw new Error(`invalid Swift distribution compile path ${file}`);
|
|
15976
|
-
const destination =
|
|
15977
|
-
mkdirSync8(
|
|
15978
|
-
copyFileSync2(
|
|
16184
|
+
const destination = path33.join(staging, file);
|
|
16185
|
+
mkdirSync8(path33.dirname(destination), { recursive: true });
|
|
16186
|
+
copyFileSync2(path33.join(moduleRoot, file), destination);
|
|
15979
16187
|
}
|
|
15980
16188
|
try {
|
|
15981
16189
|
renameSync6(staging, view);
|
|
15982
16190
|
} catch (error) {
|
|
15983
|
-
if (!
|
|
16191
|
+
if (!existsSync10(view)) throw error;
|
|
15984
16192
|
}
|
|
15985
16193
|
} finally {
|
|
15986
16194
|
rmSync7(staging, { recursive: true, force: true });
|
|
@@ -15997,19 +16205,19 @@ var REACH_STAGED_FRAMEWORKS = /* @__PURE__ */ new Set(["React"]);
|
|
|
15997
16205
|
function swiftModuleInterface(moduleRoot, name) {
|
|
15998
16206
|
if (REACH_STAGED_FRAMEWORKS.has(name)) return null;
|
|
15999
16207
|
if (swiftDistributionAt(moduleRoot)) {
|
|
16000
|
-
const file =
|
|
16001
|
-
if (!
|
|
16208
|
+
const file = path33.join(moduleRoot, "modules", `${name}-Swift.h`);
|
|
16209
|
+
if (!existsSync10(file)) return null;
|
|
16002
16210
|
const header = clangInterfaceHeader(readFileSync16(file, "utf8"), moduleRoot);
|
|
16003
16211
|
return { declared: swiftInterfaceDeclarations(header), header };
|
|
16004
16212
|
}
|
|
16005
|
-
const sources =
|
|
16006
|
-
const built =
|
|
16007
|
-
if (!
|
|
16213
|
+
const sources = path33.join(moduleRoot, "Sources", name);
|
|
16214
|
+
const built = path33.join(moduleRoot, ".build/host", `${name}-Swift.h`);
|
|
16215
|
+
if (!existsSync10(sources) || !existsSync10(built)) return null;
|
|
16008
16216
|
const declared = /* @__PURE__ */ new Set();
|
|
16009
16217
|
for (const file of readdirSync6(sources, { recursive: true, encoding: "utf8" }))
|
|
16010
16218
|
if (file.endsWith(".swift"))
|
|
16011
16219
|
for (const [, objc, subclass] of readFileSync16(
|
|
16012
|
-
|
|
16220
|
+
path33.join(sources, file),
|
|
16013
16221
|
"utf8"
|
|
16014
16222
|
).matchAll(
|
|
16015
16223
|
/@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s|^(?:public|open)\s+(?:final\s+)?class\s+(\w+)\s*:\s*NSObject\b/gm
|
|
@@ -16023,7 +16231,7 @@ function swiftModuleInterface(moduleRoot, name) {
|
|
|
16023
16231
|
}
|
|
16024
16232
|
function clangInterfaceHeader(header, moduleRoot) {
|
|
16025
16233
|
const distribution = swiftDistributionAt(moduleRoot) !== null;
|
|
16026
|
-
const frameworks =
|
|
16234
|
+
const frameworks = path33.join(
|
|
16027
16235
|
swiftSharedSdkSourceRoot(moduleRoot, distribution),
|
|
16028
16236
|
"System/Library/Frameworks"
|
|
16029
16237
|
);
|
|
@@ -16036,8 +16244,8 @@ function clangInterfaceHeader(header, moduleRoot) {
|
|
|
16036
16244
|
(_, module, framework) => {
|
|
16037
16245
|
const imports = [`@import ${framework};`];
|
|
16038
16246
|
imported.add(framework);
|
|
16039
|
-
const directory = distribution ?
|
|
16040
|
-
if (!
|
|
16247
|
+
const directory = distribution ? path33.join(moduleRoot, "modules", module) : path33.join(moduleRoot, "Sources", module, "include");
|
|
16248
|
+
if (!existsSync10(directory)) return imports[0];
|
|
16041
16249
|
if (!references) {
|
|
16042
16250
|
references = new Set(header.match(/\b[A-Z]\w*\b/g));
|
|
16043
16251
|
for (const name of objcEnumerations(header)) references.delete(name);
|
|
@@ -16065,7 +16273,7 @@ var clangDeclarationEnumCache = /* @__PURE__ */ new Map();
|
|
|
16065
16273
|
function clangDeclarationEnums(directory) {
|
|
16066
16274
|
const cached = clangDeclarationEnumCache.get(directory);
|
|
16067
16275
|
if (cached) return cached;
|
|
16068
|
-
const enums = readdirSync6(directory).filter((file) => file.endsWith(".h")).flatMap((file) => objcEnumerations(readFileSync16(
|
|
16276
|
+
const enums = readdirSync6(directory).filter((file) => file.endsWith(".h")).flatMap((file) => objcEnumerations(readFileSync16(path33.join(directory, file), "utf8")));
|
|
16069
16277
|
clangDeclarationEnumCache.set(directory, enums);
|
|
16070
16278
|
return enums;
|
|
16071
16279
|
}
|
|
@@ -16100,11 +16308,11 @@ function sdkObjCDeclarationOwners(frameworks) {
|
|
|
16100
16308
|
const owners = /* @__PURE__ */ new Map();
|
|
16101
16309
|
for (const framework of readdirSync6(frameworks))
|
|
16102
16310
|
if (framework.endsWith(".framework")) {
|
|
16103
|
-
const headers =
|
|
16104
|
-
if (
|
|
16311
|
+
const headers = path33.join(frameworks, framework, "Headers");
|
|
16312
|
+
if (existsSync10(headers)) {
|
|
16105
16313
|
for (const file of readdirSync6(headers, { recursive: true, encoding: "utf8" }))
|
|
16106
16314
|
if (file.endsWith(".h")) {
|
|
16107
|
-
const header = readFileSync16(
|
|
16315
|
+
const header = readFileSync16(path33.join(headers, file), "utf8");
|
|
16108
16316
|
for (const name of [
|
|
16109
16317
|
...swiftInterfaceDeclarations(header),
|
|
16110
16318
|
...objcEnumerations(header),
|
|
@@ -16203,7 +16411,7 @@ function swiftCompileSdkOptions(moduleRoot, toolchainBin) {
|
|
|
16203
16411
|
}
|
|
16204
16412
|
function swiftObjCSelectorOptions(moduleRoot) {
|
|
16205
16413
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
16206
|
-
let map =
|
|
16414
|
+
let map = path33.join(
|
|
16207
16415
|
distribution ? swiftDistributionCompileView(moduleRoot, distribution) : moduleRoot,
|
|
16208
16416
|
SWIFT_DISTRIBUTION_OBJC_SELECTORS
|
|
16209
16417
|
);
|
|
@@ -16213,18 +16421,21 @@ function swiftObjCSelectorOptions(moduleRoot) {
|
|
|
16213
16421
|
for (const [name, members] of Object.entries(
|
|
16214
16422
|
JSON.parse(
|
|
16215
16423
|
readFileSync16(
|
|
16216
|
-
|
|
16424
|
+
path33.join(moduleRoot, "Sources", framework, "ObjCSelectors.json"),
|
|
16217
16425
|
"utf8"
|
|
16218
16426
|
)
|
|
16219
16427
|
).classes
|
|
16220
16428
|
))
|
|
16221
16429
|
classes[name] = [...classes[name] ?? [], ...members];
|
|
16222
|
-
map =
|
|
16223
|
-
|
|
16224
|
-
|
|
16225
|
-
|
|
16226
|
-
|
|
16227
|
-
|
|
16430
|
+
map = path33.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
|
|
16431
|
+
const content = `${JSON.stringify({ classes }, null, 2)}
|
|
16432
|
+
`;
|
|
16433
|
+
if (!existsSync10(map) || readFileSync16(map, "utf8") !== content) {
|
|
16434
|
+
mkdirSync8(path33.dirname(map), { recursive: true });
|
|
16435
|
+
const partial = `${map}.${randomUUID5()}`;
|
|
16436
|
+
writeFileSync8(partial, content);
|
|
16437
|
+
renameSync6(partial, map);
|
|
16438
|
+
}
|
|
16228
16439
|
}
|
|
16229
16440
|
return ["-Xswiftc", "-Xllvm", "-Xswiftc", `-peach-objc-selector-map=${map}`];
|
|
16230
16441
|
}
|
|
@@ -16262,7 +16473,7 @@ function swiftModuleInputFiles(root) {
|
|
|
16262
16473
|
"toolchain.json"
|
|
16263
16474
|
];
|
|
16264
16475
|
const walk = (dir) => {
|
|
16265
|
-
for (const entry of readdirSync6(
|
|
16476
|
+
for (const entry of readdirSync6(path33.join(root, dir), {
|
|
16266
16477
|
withFileTypes: true
|
|
16267
16478
|
})) {
|
|
16268
16479
|
const relative = `${dir}/${entry.name}`;
|
|
@@ -16278,48 +16489,48 @@ function swiftModuleInputFiles(root) {
|
|
|
16278
16489
|
walk("ios-simulator-stdlib");
|
|
16279
16490
|
return files.sort();
|
|
16280
16491
|
}
|
|
16281
|
-
function swiftMacroPlugins(moduleRoot, dir =
|
|
16492
|
+
function swiftMacroPlugins(moduleRoot, dir = path33.join(moduleRoot, ".build/host/RnxPreviewMacros")) {
|
|
16282
16493
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
16283
16494
|
if (distribution) {
|
|
16284
16495
|
const view = swiftDistributionCompileView(moduleRoot, distribution);
|
|
16285
16496
|
return {
|
|
16286
|
-
libraries: distribution.plugins.filter((plugin) =>
|
|
16287
|
-
executables: distribution.plugins.filter((plugin) =>
|
|
16497
|
+
libraries: distribution.plugins.filter((plugin) => path33.basename(plugin) !== "ExpoModulesMacros").map((plugin) => path33.join(view, plugin)),
|
|
16498
|
+
executables: distribution.plugins.filter((plugin) => path33.basename(plugin) === "ExpoModulesMacros").map((plugin) => path33.join(view, plugin)),
|
|
16288
16499
|
stale: false
|
|
16289
16500
|
};
|
|
16290
16501
|
}
|
|
16291
16502
|
const release = JSON.parse(
|
|
16292
|
-
readFileSync16(
|
|
16503
|
+
readFileSync16(path33.join(moduleRoot, "toolchain.json"), "utf8")
|
|
16293
16504
|
).release;
|
|
16294
|
-
const compilerStamp =
|
|
16295
|
-
const pluginScript =
|
|
16296
|
-
const expoPlugin =
|
|
16505
|
+
const compilerStamp = path33.join(dir, "compiler-release");
|
|
16506
|
+
const pluginScript = path33.join(moduleRoot, "scripts/build-preview-plugin.sh");
|
|
16507
|
+
const expoPlugin = path33.join(dir, "ExpoModulesMacros");
|
|
16297
16508
|
const ext = process.platform === "darwin" ? "dylib" : "so";
|
|
16298
16509
|
const plugins = [
|
|
16299
16510
|
{
|
|
16300
|
-
library:
|
|
16301
|
-
sources: [
|
|
16511
|
+
library: path33.join(dir, `libRnxPreviewMacros.${ext}`),
|
|
16512
|
+
sources: [path33.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
|
|
16302
16513
|
},
|
|
16303
16514
|
{
|
|
16304
|
-
library:
|
|
16515
|
+
library: path33.join(dir, `libFoundationMacros.${ext}`),
|
|
16305
16516
|
sources: [
|
|
16306
|
-
|
|
16307
|
-
|
|
16517
|
+
path33.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
|
|
16518
|
+
path33.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
|
|
16308
16519
|
]
|
|
16309
16520
|
},
|
|
16310
16521
|
{
|
|
16311
|
-
library:
|
|
16522
|
+
library: path33.join(dir, `libTipKitMacros.${ext}`),
|
|
16312
16523
|
sources: [
|
|
16313
|
-
|
|
16314
|
-
|
|
16524
|
+
path33.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
|
|
16525
|
+
path33.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
|
|
16315
16526
|
]
|
|
16316
16527
|
}
|
|
16317
16528
|
];
|
|
16318
16529
|
return {
|
|
16319
16530
|
libraries: plugins.map(({ library }) => library),
|
|
16320
16531
|
executables: [expoPlugin],
|
|
16321
|
-
stale: !
|
|
16322
|
-
({ library, sources }) => !
|
|
16532
|
+
stale: !existsSync10(compilerStamp) || !existsSync10(expoPlugin) || statSync4(pluginScript).mtimeMs > statSync4(expoPlugin).mtimeMs || readFileSync16(compilerStamp, "utf8").trim() !== release || plugins.some(
|
|
16533
|
+
({ library, sources }) => !existsSync10(library) || sources.some((source) => statSync4(source).mtimeMs > statSync4(library).mtimeMs)
|
|
16323
16534
|
)
|
|
16324
16535
|
};
|
|
16325
16536
|
}
|
|
@@ -16329,14 +16540,14 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal, lea
|
|
|
16329
16540
|
await runCompiler(
|
|
16330
16541
|
"sh",
|
|
16331
16542
|
[
|
|
16332
|
-
|
|
16543
|
+
path33.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
16333
16544
|
toolchainBin,
|
|
16334
16545
|
libraries[0]
|
|
16335
16546
|
],
|
|
16336
16547
|
{ signal, lease }
|
|
16337
16548
|
);
|
|
16338
16549
|
writeFileSync8(
|
|
16339
|
-
|
|
16550
|
+
path33.join(path33.dirname(libraries[0]), "compiler-release"),
|
|
16340
16551
|
`${release}
|
|
16341
16552
|
`
|
|
16342
16553
|
);
|
|
@@ -16348,11 +16559,74 @@ function clearLinkedModuleDigests(root) {
|
|
|
16348
16559
|
if (root === void 0) linkedModuleDigests.clear();
|
|
16349
16560
|
else linkedModuleDigests.delete(root);
|
|
16350
16561
|
}
|
|
16562
|
+
function gitCleanModuleInputsKey(root, files) {
|
|
16563
|
+
if (swiftDistributionAt(root)) return null;
|
|
16564
|
+
const top = spawnSync5("git", ["-C", root, "rev-parse", "--show-toplevel"], {
|
|
16565
|
+
encoding: "utf8",
|
|
16566
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
16567
|
+
});
|
|
16568
|
+
if (top.status !== 0) return null;
|
|
16569
|
+
const repoTop = top.stdout.trim();
|
|
16570
|
+
if (!repoTop) return null;
|
|
16571
|
+
const realTop = realpathSync6(repoTop);
|
|
16572
|
+
const realRoot = realpathSync6(root);
|
|
16573
|
+
const collapsedDirs = [
|
|
16574
|
+
path33.join(realRoot, "Sources"),
|
|
16575
|
+
path33.join(realRoot, "cross-import-overlays"),
|
|
16576
|
+
path33.join(realRoot, "ios-simulator-stdlib"),
|
|
16577
|
+
realpathSync6(path33.resolve(realRoot, "../peachsim/sdk/ios"))
|
|
16578
|
+
];
|
|
16579
|
+
const scoped = /* @__PURE__ */ new Set();
|
|
16580
|
+
for (const dir of collapsedDirs) {
|
|
16581
|
+
const rel = path33.relative(realTop, dir).split(path33.sep).join("/");
|
|
16582
|
+
if (!rel || rel.startsWith("../")) return null;
|
|
16583
|
+
scoped.add(rel);
|
|
16584
|
+
}
|
|
16585
|
+
for (const file of files) {
|
|
16586
|
+
const full = path33.resolve(realRoot, file);
|
|
16587
|
+
if (collapsedDirs.some((dir) => full.startsWith(dir + path33.sep))) continue;
|
|
16588
|
+
const rel = path33.relative(realTop, full).split(path33.sep).join("/");
|
|
16589
|
+
if (!rel || rel.startsWith("../")) return null;
|
|
16590
|
+
scoped.add(rel);
|
|
16591
|
+
}
|
|
16592
|
+
const paths = [...scoped].sort();
|
|
16593
|
+
const status = spawnSync5(
|
|
16594
|
+
"git",
|
|
16595
|
+
[
|
|
16596
|
+
"-C",
|
|
16597
|
+
realTop,
|
|
16598
|
+
"status",
|
|
16599
|
+
"--porcelain",
|
|
16600
|
+
"--untracked-files=all",
|
|
16601
|
+
"--ignored=matching",
|
|
16602
|
+
"--",
|
|
16603
|
+
...paths
|
|
16604
|
+
],
|
|
16605
|
+
{
|
|
16606
|
+
encoding: "utf8",
|
|
16607
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
16608
|
+
maxBuffer: 16 * 1024 * 1024
|
|
16609
|
+
}
|
|
16610
|
+
);
|
|
16611
|
+
if (status.status !== 0 || status.stdout.trim().length > 0) return null;
|
|
16612
|
+
const oids = spawnSync5(
|
|
16613
|
+
"git",
|
|
16614
|
+
["-C", realTop, "rev-parse", ...paths.map((entry) => `HEAD:${entry}`)],
|
|
16615
|
+
{ encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }
|
|
16616
|
+
);
|
|
16617
|
+
if (oids.status !== 0) return null;
|
|
16618
|
+
const keyHash = createHash18("sha256");
|
|
16619
|
+
keyHash.update("git-module-digest/v1\n");
|
|
16620
|
+
keyHash.update(oids.stdout);
|
|
16621
|
+
keyHash.update("\n");
|
|
16622
|
+
for (const file of files) keyHash.update(file).update("\n");
|
|
16623
|
+
return keyHash.digest("hex");
|
|
16624
|
+
}
|
|
16351
16625
|
function swiftModuleDigest(root) {
|
|
16352
16626
|
const files = swiftModuleInputFiles(root);
|
|
16353
16627
|
const stampHash = createHash18("sha256");
|
|
16354
16628
|
for (const file of files) {
|
|
16355
|
-
const stat = statSync4(
|
|
16629
|
+
const stat = statSync4(path33.join(root, file), { bigint: true });
|
|
16356
16630
|
stampHash.update(file);
|
|
16357
16631
|
stampHash.update(
|
|
16358
16632
|
`${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
|
|
@@ -16362,12 +16636,18 @@ function swiftModuleDigest(root) {
|
|
|
16362
16636
|
const stamp = stampHash.digest("hex");
|
|
16363
16637
|
const cached = linkedModuleDigests.get(root);
|
|
16364
16638
|
if (cached?.stamp === stamp) return cached.digest;
|
|
16365
|
-
const
|
|
16366
|
-
|
|
16367
|
-
|
|
16639
|
+
const digestDir = path33.join(swiftCacheDir(), "swift-module-digests");
|
|
16640
|
+
const record = path33.join(
|
|
16641
|
+
digestDir,
|
|
16368
16642
|
`${createHash18("sha256").update(root).digest("hex")}.json`
|
|
16369
16643
|
);
|
|
16370
|
-
|
|
16644
|
+
const writeRecord = (target, body) => {
|
|
16645
|
+
mkdirSync8(path33.dirname(target), { recursive: true });
|
|
16646
|
+
const partial = `${target}.${process.pid}.${randomUUID5()}`;
|
|
16647
|
+
writeFileSync8(partial, body);
|
|
16648
|
+
renameSync6(partial, target);
|
|
16649
|
+
};
|
|
16650
|
+
if (existsSync10(record)) {
|
|
16371
16651
|
const saved = JSON.parse(readFileSync16(record, "utf8"));
|
|
16372
16652
|
if (saved && typeof saved === "object" && Reflect.get(saved, "stamp") === stamp && typeof Reflect.get(saved, "digest") === "string") {
|
|
16373
16653
|
const digest2 = Buffer.from(String(Reflect.get(saved, "digest")), "hex");
|
|
@@ -16375,19 +16655,30 @@ function swiftModuleDigest(root) {
|
|
|
16375
16655
|
return digest2;
|
|
16376
16656
|
}
|
|
16377
16657
|
}
|
|
16658
|
+
const gitKey = gitCleanModuleInputsKey(root, files);
|
|
16659
|
+
const gitRecord = gitKey ? path33.join(digestDir, `git-${gitKey}.json`) : null;
|
|
16660
|
+
if (gitRecord && existsSync10(gitRecord)) {
|
|
16661
|
+
const saved = JSON.parse(readFileSync16(gitRecord, "utf8"));
|
|
16662
|
+
if (saved && typeof saved === "object" && typeof Reflect.get(saved, "digest") === "string") {
|
|
16663
|
+
const hex2 = String(Reflect.get(saved, "digest"));
|
|
16664
|
+
const digest2 = Buffer.from(hex2, "hex");
|
|
16665
|
+
linkedModuleDigests.set(root, { stamp, digest: digest2 });
|
|
16666
|
+
writeRecord(record, JSON.stringify({ stamp, digest: hex2 }));
|
|
16667
|
+
return digest2;
|
|
16668
|
+
}
|
|
16669
|
+
}
|
|
16378
16670
|
const hash = createHash18("sha256");
|
|
16379
16671
|
for (const file of files) {
|
|
16380
16672
|
hash.update(createHash18("sha256").update(file).digest());
|
|
16381
16673
|
hash.update(
|
|
16382
|
-
createHash18("sha256").update(readFileSync16(
|
|
16674
|
+
createHash18("sha256").update(readFileSync16(path33.join(root, file))).digest()
|
|
16383
16675
|
);
|
|
16384
16676
|
}
|
|
16385
16677
|
const digest = hash.digest();
|
|
16678
|
+
const hex = digest.toString("hex");
|
|
16386
16679
|
linkedModuleDigests.set(root, { stamp, digest });
|
|
16387
|
-
|
|
16388
|
-
|
|
16389
|
-
writeFileSync8(partial, JSON.stringify({ stamp, digest: digest.toString("hex") }));
|
|
16390
|
-
renameSync6(partial, record);
|
|
16680
|
+
writeRecord(record, JSON.stringify({ stamp, digest: hex }));
|
|
16681
|
+
if (gitRecord) writeRecord(gitRecord, JSON.stringify({ digest: hex }));
|
|
16391
16682
|
return digest;
|
|
16392
16683
|
}
|
|
16393
16684
|
var compileSurfaces = /* @__PURE__ */ new WeakMap();
|
|
@@ -16459,7 +16750,7 @@ function withNativeSourceGlue(input, glue) {
|
|
|
16459
16750
|
...input,
|
|
16460
16751
|
files: {
|
|
16461
16752
|
...input.files,
|
|
16462
|
-
[
|
|
16753
|
+
[path33.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
|
|
16463
16754
|
},
|
|
16464
16755
|
oneModule: true
|
|
16465
16756
|
};
|
|
@@ -16617,7 +16908,7 @@ function swiftImportNames(contents2, available) {
|
|
|
16617
16908
|
function swiftPeachModules(moduleRoot) {
|
|
16618
16909
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
16619
16910
|
return distribution ? distribution.modules : swiftManifestDeclarations(
|
|
16620
|
-
readFileSync16(
|
|
16911
|
+
readFileSync16(path33.join(moduleRoot, "Package.swift"), "utf8")
|
|
16621
16912
|
).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
|
|
16622
16913
|
}
|
|
16623
16914
|
var sdkPaths = /* @__PURE__ */ new Map();
|
|
@@ -16627,7 +16918,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOption
|
|
|
16627
16918
|
const cached = sdkPaths.get(key);
|
|
16628
16919
|
if (cached) return cached;
|
|
16629
16920
|
const configuration = execFileSync13(
|
|
16630
|
-
|
|
16921
|
+
path33.join(toolchainBin, "swift"),
|
|
16631
16922
|
["sdk", "configure", ...options, "--show-configuration", sdk, SWIFT_WASM_TRIPLE],
|
|
16632
16923
|
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
16633
16924
|
);
|
|
@@ -16661,7 +16952,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOption
|
|
|
16661
16952
|
if (flag !== "-fwasm-exceptions") cFlags.push(flag);
|
|
16662
16953
|
if (flag === "-iframeworkwithsysroot" && options2[index + 2] === "-Xcc" && typeof options2[index + 3] === "string") {
|
|
16663
16954
|
cFlags.push(options2[index + 3]);
|
|
16664
|
-
frameworks.push(
|
|
16955
|
+
frameworks.push(path33.join(sysroot, options2[index + 3]));
|
|
16665
16956
|
index += 3;
|
|
16666
16957
|
continue;
|
|
16667
16958
|
}
|
|
@@ -16678,7 +16969,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOption
|
|
|
16678
16969
|
}
|
|
16679
16970
|
const paths = {
|
|
16680
16971
|
sysroot,
|
|
16681
|
-
darwin:
|
|
16972
|
+
darwin: path33.join(sysroot, "darwin"),
|
|
16682
16973
|
resources: field("swiftResourcesPath"),
|
|
16683
16974
|
frameworks,
|
|
16684
16975
|
cFlags
|
|
@@ -16706,23 +16997,23 @@ function swiftOverlayFrameworks(moduleRoot, toolchainBin) {
|
|
|
16706
16997
|
const { darwin, resources, frameworks } = swiftSdkPaths(moduleRoot, toolchainBin);
|
|
16707
16998
|
const swiftModules = new Set(swiftPeachModules(moduleRoot));
|
|
16708
16999
|
const result = /* @__PURE__ */ new Set();
|
|
16709
|
-
const include =
|
|
17000
|
+
const include = path33.join(darwin, "usr/include");
|
|
16710
17001
|
for (const entry of readdirSync6(include))
|
|
16711
17002
|
if (entry.endsWith(".modulemap"))
|
|
16712
17003
|
addSwiftOverlayFrameworks(
|
|
16713
|
-
readFileSync16(
|
|
17004
|
+
readFileSync16(path33.join(include, entry), "utf8"),
|
|
16714
17005
|
swiftModules,
|
|
16715
17006
|
result
|
|
16716
17007
|
);
|
|
16717
17008
|
for (const entry of readdirSync6(resources)) {
|
|
16718
|
-
const map =
|
|
16719
|
-
if (
|
|
17009
|
+
const map = path33.join(resources, entry, "module.modulemap");
|
|
17010
|
+
if (existsSync10(map))
|
|
16720
17011
|
addSwiftOverlayFrameworks(readFileSync16(map, "utf8"), swiftModules, result);
|
|
16721
17012
|
}
|
|
16722
17013
|
for (const directory of frameworks)
|
|
16723
17014
|
for (const entry of readdirSync6(directory)) {
|
|
16724
|
-
const map =
|
|
16725
|
-
if (
|
|
17015
|
+
const map = path33.join(directory, entry, "Modules/module.modulemap");
|
|
17016
|
+
if (existsSync10(map))
|
|
16726
17017
|
addSwiftOverlayFrameworks(readFileSync16(map, "utf8"), swiftModules, result);
|
|
16727
17018
|
}
|
|
16728
17019
|
sdkOverlayFrameworks.set(key, result);
|
|
@@ -16739,50 +17030,50 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
16739
17030
|
toolchainBin
|
|
16740
17031
|
);
|
|
16741
17032
|
const maps = /* @__PURE__ */ new Set([
|
|
16742
|
-
|
|
17033
|
+
path33.join(darwin, "usr/include/module.modulemap"),
|
|
16743
17034
|
...cFlags.filter((flag) => flag.startsWith("-fmodule-map-file=")).map((flag) => {
|
|
16744
17035
|
const file = flag.slice("-fmodule-map-file=".length);
|
|
16745
|
-
return file.startsWith("=") ?
|
|
17036
|
+
return file.startsWith("=") ? path33.join(sysroot, file.slice(1)) : file;
|
|
16746
17037
|
})
|
|
16747
17038
|
]);
|
|
16748
17039
|
for (const map of maps) {
|
|
16749
|
-
if (!
|
|
17040
|
+
if (!existsSync10(map)) continue;
|
|
16750
17041
|
const contents2 = readFileSync16(map, "utf8");
|
|
16751
17042
|
for (const match of contents2.matchAll(
|
|
16752
17043
|
/^(?:explicit\s+)?(?:framework\s+)?module\s+([A-Za-z_]\w*)/gm
|
|
16753
17044
|
))
|
|
16754
17045
|
modules.add(match[1]);
|
|
16755
17046
|
for (const match of contents2.matchAll(/^\s*extern\s+module\s+\w+\s+"([^"]+)"/gm))
|
|
16756
|
-
maps.add(
|
|
17047
|
+
maps.add(path33.resolve(path33.dirname(map), match[1]));
|
|
16757
17048
|
}
|
|
16758
|
-
for (const entry of readdirSync6(
|
|
17049
|
+
for (const entry of readdirSync6(path33.join(resources, "wasi"))) {
|
|
16759
17050
|
if (entry.endsWith(".swiftmodule"))
|
|
16760
17051
|
modules.add(entry.slice(0, -".swiftmodule".length));
|
|
16761
17052
|
}
|
|
16762
17053
|
for (const entry of readdirSync6(resources)) {
|
|
16763
|
-
const map =
|
|
16764
|
-
if (!
|
|
17054
|
+
const map = path33.join(resources, entry, "module.modulemap");
|
|
17055
|
+
if (!existsSync10(map)) continue;
|
|
16765
17056
|
for (const match of readFileSync16(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
|
|
16766
17057
|
modules.add(match[1]);
|
|
16767
17058
|
}
|
|
16768
17059
|
for (const libc of [
|
|
16769
|
-
|
|
16770
|
-
|
|
17060
|
+
path33.join(darwin, "usr/include"),
|
|
17061
|
+
path33.join(
|
|
16771
17062
|
swiftSharedSdkRoot(moduleRoot, swiftDistributionAt(moduleRoot) !== null),
|
|
16772
17063
|
"usr/include"
|
|
16773
17064
|
)
|
|
16774
17065
|
])
|
|
16775
17066
|
for (const entry of readdirSync6(libc)) {
|
|
16776
17067
|
if (!entry.endsWith(".modulemap")) continue;
|
|
16777
|
-
for (const match of readFileSync16(
|
|
17068
|
+
for (const match of readFileSync16(path33.join(libc, entry), "utf8").matchAll(
|
|
16778
17069
|
/^module\s+([A-Za-z_]\w*)/gm
|
|
16779
17070
|
))
|
|
16780
17071
|
modules.add(match[1]);
|
|
16781
17072
|
}
|
|
16782
17073
|
for (const directory of frameworks) {
|
|
16783
17074
|
for (const entry of readdirSync6(directory)) {
|
|
16784
|
-
const map =
|
|
16785
|
-
if (!
|
|
17075
|
+
const map = path33.join(directory, entry, "Modules/module.modulemap");
|
|
17076
|
+
if (!existsSync10(map)) continue;
|
|
16786
17077
|
for (const match of readFileSync16(map, "utf8").matchAll(
|
|
16787
17078
|
/^framework\s+module\s+([A-Za-z_]\w*)/gm
|
|
16788
17079
|
))
|
|
@@ -16882,15 +17173,15 @@ int EXUpdatesApplyBSDiffPatch(const char * _Nonnull oldFilePath,
|
|
|
16882
17173
|
];
|
|
16883
17174
|
var CLANG_DISTRIBUTION_MODULES = ".peach-clang-modules";
|
|
16884
17175
|
function distributionClangModulePresent(modules, name) {
|
|
16885
|
-
return
|
|
17176
|
+
return existsSync10(path33.join(modules, `${name}.swiftmodule`)) || existsSync10(path33.join(modules, name, "module.modulemap"));
|
|
16886
17177
|
}
|
|
16887
17178
|
function distributionClangModuleMap(root, modules) {
|
|
16888
17179
|
const missing = DISTRIBUTION_CLANG_MODULES.filter(
|
|
16889
17180
|
(mod) => !distributionClangModulePresent(modules, mod.name)
|
|
16890
17181
|
);
|
|
16891
17182
|
if (missing.length === 0) return null;
|
|
16892
|
-
const directory =
|
|
16893
|
-
const mapPath =
|
|
17183
|
+
const directory = path33.join(root, CLANG_DISTRIBUTION_MODULES);
|
|
17184
|
+
const mapPath = path33.join(directory, "module.modulemap");
|
|
16894
17185
|
const map = missing.map(
|
|
16895
17186
|
(mod) => `module ${mod.name} {
|
|
16896
17187
|
requires objc
|
|
@@ -16899,9 +17190,9 @@ function distributionClangModuleMap(root, modules) {
|
|
|
16899
17190
|
}
|
|
16900
17191
|
`
|
|
16901
17192
|
).join("\n");
|
|
16902
|
-
if (
|
|
17193
|
+
if (existsSync10(mapPath) && readFileSync16(mapPath, "utf8") !== map)
|
|
16903
17194
|
rmSync7(directory, { recursive: true, force: true });
|
|
16904
|
-
for (const mod of missing) writeBuildFile(
|
|
17195
|
+
for (const mod of missing) writeBuildFile(path33.join(directory, mod.header), mod.source);
|
|
16905
17196
|
writeBuildFile(mapPath, map);
|
|
16906
17197
|
return mapPath;
|
|
16907
17198
|
}
|
|
@@ -16913,14 +17204,14 @@ function providedModulesPath(root, modules, excluded) {
|
|
|
16913
17204
|
if (!excluded || excluded.size === 0) return modules;
|
|
16914
17205
|
const entries2 = readdirSync6(modules).filter((entry) => !excluded.has(entry.replace(/\..*$/, ""))).sort();
|
|
16915
17206
|
const key = createHash18("sha256").update(JSON.stringify([modules, entries2])).update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
|
|
16916
|
-
const directory =
|
|
16917
|
-
const complete =
|
|
16918
|
-
if (!
|
|
17207
|
+
const directory = path33.join(root, `.peach-modules-${key}`);
|
|
17208
|
+
const complete = path33.join(directory, ".complete");
|
|
17209
|
+
if (!existsSync10(complete)) {
|
|
16919
17210
|
mkdirSync8(directory, { recursive: true });
|
|
16920
17211
|
for (const entry of readdirSync6(directory))
|
|
16921
|
-
rmSync7(
|
|
17212
|
+
rmSync7(path33.join(directory, entry), { recursive: true, force: true });
|
|
16922
17213
|
for (const entry of entries2) {
|
|
16923
|
-
symlinkSync2(
|
|
17214
|
+
symlinkSync2(path33.join(modules, entry), path33.join(directory, entry));
|
|
16924
17215
|
}
|
|
16925
17216
|
writeFileSync8(complete, "");
|
|
16926
17217
|
}
|
|
@@ -16934,7 +17225,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
|
|
|
16934
17225
|
);
|
|
16935
17226
|
const names = /* @__PURE__ */ new Set([...frameworks, ...targets.map((target) => target.name)]);
|
|
16936
17227
|
const entriesByPrefix = new Map(
|
|
16937
|
-
targets.map(({ path:
|
|
17228
|
+
targets.map(({ path: path34 }) => [path34 === "." ? "" : `${path34}/`, []])
|
|
16938
17229
|
);
|
|
16939
17230
|
for (const entry of Object.entries(files)) {
|
|
16940
17231
|
const [file] = entry;
|
|
@@ -16969,7 +17260,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
|
|
|
16969
17260
|
(excluded) => relative === excluded || relative.startsWith(`${excluded}/`)
|
|
16970
17261
|
))
|
|
16971
17262
|
continue;
|
|
16972
|
-
if (nested.some((
|
|
17263
|
+
if (nested.some((path34) => file.startsWith(path34))) continue;
|
|
16973
17264
|
const imports = file.endsWith(".swift") ? swiftImportNames(contents2) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents2, ownsHeader) : [];
|
|
16974
17265
|
for (const name of imports) {
|
|
16975
17266
|
if (names.has(name) && name !== target.name && !(target.dependencies !== void 0 && localNames.has(name)))
|
|
@@ -17045,7 +17336,7 @@ ${imports.join("\n")}
|
|
|
17045
17336
|
}
|
|
17046
17337
|
var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
17047
17338
|
var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
17048
|
-
"-Xclang-linker", ${JSON.stringify(`-fuse-ld=${
|
|
17339
|
+
"-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path33.join(root, SWIFT_AUTOLINK_LINKER)}`)},
|
|
17049
17340
|
"-Xlinker", "-z", "-Xlinker", "stack-size=8372224",
|
|
17050
17341
|
"-Xlinker", "--stack-first",
|
|
17051
17342
|
"-Xlinker", "--global-base=8372224",
|
|
@@ -17060,7 +17351,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
|
|
|
17060
17351
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
17061
17352
|
var MULTI_MANIFEST_VERSION = 76;
|
|
17062
17353
|
var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
17063
|
-
var compilerSourceDigest = true ? "
|
|
17354
|
+
var compilerSourceDigest = true ? "57c5faa7bb7758647030422e32db0f4a53fbab724723e220c14fea1e41d2391e" : swiftCompilerSourceDigest(import.meta.dirname);
|
|
17064
17355
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
17065
17356
|
return swiftCompileInputHash(input, release).update(swiftModuleDigest(moduleRoot)).digest("hex");
|
|
17066
17357
|
}
|
|
@@ -17160,14 +17451,14 @@ var cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|
|
|
17160
17451
|
var cxxFlagArray = (flags) => JSON.stringify([...nativeCxxCompilerFlags, ...withoutGlogModuleMap(flags)]);
|
|
17161
17452
|
function swiftCrossImportFlags(moduleRoot, distribution) {
|
|
17162
17453
|
const manifest = distribution ? swiftDistributionAt(moduleRoot) : null;
|
|
17163
|
-
const overlayRoot = manifest ?
|
|
17454
|
+
const overlayRoot = manifest ? path33.join(moduleRoot, "modules") : path33.join(moduleRoot, "cross-import-overlays");
|
|
17164
17455
|
return readdirSync6(overlayRoot, { encoding: "utf8", recursive: true }).filter((file) => file.endsWith(".swiftoverlay")).sort((left, right) => left.localeCompare(right)).flatMap((file) => [
|
|
17165
17456
|
"-Xfrontend",
|
|
17166
17457
|
"-swift-module-cross-import",
|
|
17167
17458
|
"-Xfrontend",
|
|
17168
|
-
|
|
17459
|
+
path33.basename(path33.dirname(file), ".swiftcrossimport"),
|
|
17169
17460
|
"-Xfrontend",
|
|
17170
|
-
|
|
17461
|
+
path33.join(overlayRoot, file)
|
|
17171
17462
|
]);
|
|
17172
17463
|
}
|
|
17173
17464
|
function withoutWasmOverlayIsystem(flags) {
|
|
@@ -17198,7 +17489,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17198
17489
|
distribution
|
|
17199
17490
|
} = args;
|
|
17200
17491
|
const prebuilt = args.prebuilt;
|
|
17201
|
-
const distributionModules = distribution ?
|
|
17492
|
+
const distributionModules = distribution ? path33.join(moduleRoot, "modules") : void 0;
|
|
17202
17493
|
const linkedObjects = Boolean(distribution || prebuilt);
|
|
17203
17494
|
const cxxFlagsFor = (flags) => args.deferDarwinOverlay ? withoutWasmOverlayIsystem(flags) : flags;
|
|
17204
17495
|
const packageModules = new Set(
|
|
@@ -17208,7 +17499,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17208
17499
|
if (!flag.startsWith("-fmodule-map-file=")) return false;
|
|
17209
17500
|
const file = flag.slice("-fmodule-map-file=".length).replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root);
|
|
17210
17501
|
if (!file.includes("/Pods/Headers/")) return false;
|
|
17211
|
-
const map = args.files.get(file) ?? (
|
|
17502
|
+
const map = args.files.get(file) ?? (existsSync10(file) ? readFileSync16(file) : void 0);
|
|
17212
17503
|
const name = map === void 0 ? void 0 : moduleMapName(map.toString());
|
|
17213
17504
|
return name !== void 0 && packageModules.has(name);
|
|
17214
17505
|
};
|
|
@@ -17240,7 +17531,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17240
17531
|
const product = parse(
|
|
17241
17532
|
swiftFrameworkProductSchema,
|
|
17242
17533
|
JSON.parse(
|
|
17243
|
-
readFileSync16(
|
|
17534
|
+
readFileSync16(path33.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
|
|
17244
17535
|
)
|
|
17245
17536
|
);
|
|
17246
17537
|
const replacedObjects = new Set(
|
|
@@ -17254,7 +17545,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17254
17545
|
(name) => !object2.startsWith(`lib/${name}-`) || reachedFrameworks.has(name)
|
|
17255
17546
|
)
|
|
17256
17547
|
);
|
|
17257
|
-
const quoted2 = (object2) => `"${
|
|
17548
|
+
const quoted2 = (object2) => `"${path33.join(moduleRoot, object2).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
17258
17549
|
const categoryObjects = new Set(
|
|
17259
17550
|
foundationCategoryObjects.map((name) => `lib/Foundation-${name}.o`)
|
|
17260
17551
|
);
|
|
@@ -17293,7 +17584,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17293
17584
|
if (run2.length >= MODULE_MAP_RESPONSE_FILE_RUN) {
|
|
17294
17585
|
const lines = run2.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
|
|
17295
17586
|
const digest2 = createHash18("sha256").update(lines).digest("hex");
|
|
17296
|
-
const file2 =
|
|
17587
|
+
const file2 = path33.join(args.root, ".peach-clang-arguments", `${digest2}.rsp`);
|
|
17297
17588
|
args.files.set(file2, lines);
|
|
17298
17589
|
flags.push(`@${file2}`);
|
|
17299
17590
|
} else flags.push(...run2);
|
|
@@ -17317,7 +17608,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17317
17608
|
endRun();
|
|
17318
17609
|
const content = JSON.stringify(flags);
|
|
17319
17610
|
const digest = createHash18("sha256").update(content).digest("hex");
|
|
17320
|
-
const file =
|
|
17611
|
+
const file = path33.join(args.root, ".peach-manifest-arguments", `${digest}.json`);
|
|
17321
17612
|
args.files.set(file, content);
|
|
17322
17613
|
return `peachCompilerArguments(${JSON.stringify(file)})`;
|
|
17323
17614
|
};
|
|
@@ -17329,7 +17620,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17329
17620
|
const compact = args.coalescibleOverlays ? compactSwiftClangOverlays(macros, args.coalescibleOverlays) : macros;
|
|
17330
17621
|
const content = compact.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
|
|
17331
17622
|
const digest = createHash18("sha256").update(content).digest("hex");
|
|
17332
|
-
const file =
|
|
17623
|
+
const file = path33.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
|
|
17333
17624
|
args.files.set(file, content);
|
|
17334
17625
|
return JSON.stringify([`@${file}`]);
|
|
17335
17626
|
};
|
|
@@ -17341,7 +17632,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17341
17632
|
owner?.publicHeadersPath ?? ""
|
|
17342
17633
|
);
|
|
17343
17634
|
return [
|
|
17344
|
-
...owner && framework ? [
|
|
17635
|
+
...owner && framework ? [path33.posix.join(args.root, owner.path, framework[1])] : [],
|
|
17345
17636
|
...frameworkDirectories(dependency, seen)
|
|
17346
17637
|
];
|
|
17347
17638
|
});
|
|
@@ -17384,7 +17675,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17384
17675
|
const stanza = (target) => {
|
|
17385
17676
|
const native = args.native?.get(target.name);
|
|
17386
17677
|
if (target.systemLibrary || native?.clang?.sources.length === 0)
|
|
17387
|
-
return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ?
|
|
17678
|
+
return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? path33.posix.dirname(native.clang.modulemap) : target.path)}),`;
|
|
17388
17679
|
const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
|
|
17389
17680
|
const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
|
|
17390
17681
|
const defines = (target.defines ?? []).map((name) => ` .define(${JSON.stringify(name)}),`).join("");
|
|
@@ -17442,7 +17733,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
17442
17733
|
].map((flag) => `, ${JSON.stringify(flag)}`).join("");
|
|
17443
17734
|
const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || [...args.native?.values() ?? []].some(
|
|
17444
17735
|
(value) => value.late?.producers.includes(target.name)
|
|
17445
|
-
)) ? `, "-emit-objc-header-path", ${JSON.stringify(
|
|
17736
|
+
)) ? `, "-emit-objc-header-path", ${JSON.stringify(path33.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
|
|
17446
17737
|
const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
|
|
17447
17738
|
const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
|
|
17448
17739
|
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}]`)})]`;
|
|
@@ -17643,10 +17934,10 @@ ${declaration.replace(/,$/, "")}
|
|
|
17643
17934
|
function syncSwiftTree(base, files) {
|
|
17644
17935
|
mkdirSync8(base, { recursive: true });
|
|
17645
17936
|
const kept = /* @__PURE__ */ new Set();
|
|
17646
|
-
for (const file of files.keys()) if (
|
|
17937
|
+
for (const file of files.keys()) if (existsSync10(file)) kept.add(statSync4(file).ino);
|
|
17647
17938
|
const walk = (dir) => {
|
|
17648
17939
|
for (const entry of readdirSync6(dir, { withFileTypes: true })) {
|
|
17649
|
-
const full =
|
|
17940
|
+
const full = path33.join(dir, entry.name);
|
|
17650
17941
|
if (dir === base && (entry.name === ".build" || entry.name === SWIFT_CACHE_HOLD_MARKER || entry.name.startsWith(".peach-modules-") || // distribution clang maps are written beside the project, so a sync
|
|
17651
17942
|
// must not remove them.
|
|
17652
17943
|
entry.name === CLANG_DISTRIBUTION_MODULES || entry.name === SWIFT_DISTRIBUTION_MIRROR || entry.name === SWIFT_LINK_STAMP))
|
|
@@ -17803,7 +18094,7 @@ function compiledSwiftSources(files, targets, overlayFrameworks, headers, native
|
|
|
17803
18094
|
const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
|
|
17804
18095
|
return new Map(
|
|
17805
18096
|
[...owners].map(([file, { source, owner }]) => {
|
|
17806
|
-
if (nativeSourceGlue &&
|
|
18097
|
+
if (nativeSourceGlue && path33.posix.basename(file) === "OneNativeSource.generated.swift")
|
|
17807
18098
|
return [file, source];
|
|
17808
18099
|
const manifest = /(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file);
|
|
17809
18100
|
if (manifest && (!owner || /^Package(?:@swift-[\d.]+)?\.swift$/.test(file)))
|
|
@@ -18424,7 +18715,7 @@ function swiftApplicationEntry(file, source) {
|
|
|
18424
18715
|
else if (source[at] === "}") depth--;
|
|
18425
18716
|
else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
|
|
18426
18717
|
return true;
|
|
18427
|
-
else if (depth === 0 &&
|
|
18718
|
+
else if (depth === 0 && path33.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
|
|
18428
18719
|
return true;
|
|
18429
18720
|
}
|
|
18430
18721
|
return false;
|
|
@@ -18820,17 +19111,17 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
|
18820
19111
|
for (const entry of readdirSync6(from, { withFileTypes: true })) {
|
|
18821
19112
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
18822
19113
|
continue;
|
|
18823
|
-
const file =
|
|
19114
|
+
const file = path33.join(from, entry.name);
|
|
18824
19115
|
if (entry.isDirectory()) gather(file);
|
|
18825
19116
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
18826
|
-
origins[
|
|
19117
|
+
origins[path33.relative(source, file)] = readFileSync16(file, "utf8");
|
|
18827
19118
|
else if (entry.isFile() && entry.name.endsWith(".modulemap"))
|
|
18828
19119
|
moduleMaps.push(readFileSync16(file, "utf8"));
|
|
18829
19120
|
}
|
|
18830
19121
|
};
|
|
18831
19122
|
gather(source);
|
|
18832
|
-
const manifest =
|
|
18833
|
-
const targets =
|
|
19123
|
+
const manifest = path33.join(source, "Package.swift");
|
|
19124
|
+
const targets = existsSync10(manifest) ? swiftManifestTargets(
|
|
18834
19125
|
readFileSync16(manifest, "utf8"),
|
|
18835
19126
|
[],
|
|
18836
19127
|
(file) => readFileSync16(file, "utf8")
|
|
@@ -18861,11 +19152,11 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
|
18861
19152
|
for (const entry of readdirSync6(from, { withFileTypes: true })) {
|
|
18862
19153
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
18863
19154
|
continue;
|
|
18864
|
-
const file =
|
|
18865
|
-
const target =
|
|
19155
|
+
const file = path33.join(from, entry.name);
|
|
19156
|
+
const target = path33.join(to, entry.name);
|
|
18866
19157
|
if (entry.isDirectory()) copy(file, target);
|
|
18867
19158
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
18868
|
-
writeFileSync8(target, compiled.get(
|
|
19159
|
+
writeFileSync8(target, compiled.get(path33.relative(source, file)));
|
|
18869
19160
|
else cpSync(file, target, { verbatimSymlinks: true });
|
|
18870
19161
|
}
|
|
18871
19162
|
};
|
|
@@ -18943,18 +19234,18 @@ function withoutRepeatedClangFlags(flags) {
|
|
|
18943
19234
|
}
|
|
18944
19235
|
function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
|
|
18945
19236
|
const searched = new Set(settings.headerSearchPaths);
|
|
18946
|
-
const directory =
|
|
19237
|
+
const directory = path33.join(layoutRoot, ".build", "peach-clang-modulemaps");
|
|
18947
19238
|
return (settings.moduleMaps ?? []).flatMap((map) => {
|
|
18948
|
-
const headers =
|
|
18949
|
-
if (!
|
|
18950
|
-
const published =
|
|
18951
|
-
if (searched.has(map.headers) &&
|
|
18952
|
-
if (!searched.has(map.headers) &&
|
|
19239
|
+
const headers = path33.join(layoutRoot, map.headers);
|
|
19240
|
+
if (!existsSync10(headers)) return [];
|
|
19241
|
+
const published = path33.join(headers, "module.modulemap");
|
|
19242
|
+
if (searched.has(map.headers) && existsSync10(published)) return [];
|
|
19243
|
+
if (!searched.has(map.headers) && existsSync10(published))
|
|
18953
19244
|
return [`-fmodule-map-file=${published}`];
|
|
18954
19245
|
const cached = written.get(headers);
|
|
18955
19246
|
if (cached) return [cached];
|
|
18956
19247
|
mkdirSync8(directory, { recursive: true });
|
|
18957
|
-
const output =
|
|
19248
|
+
const output = path33.join(directory, `module-${written.size}.modulemap`);
|
|
18958
19249
|
writeBuildFile(
|
|
18959
19250
|
output,
|
|
18960
19251
|
swiftPackageClangModuleMap(swiftTargetModuleName(map.module), {
|
|
@@ -19016,11 +19307,11 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19016
19307
|
input.resourcePaths
|
|
19017
19308
|
);
|
|
19018
19309
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
19019
|
-
const distributionModules = distribution ?
|
|
19310
|
+
const distributionModules = distribution ? path33.join(moduleRoot, "modules") : void 0;
|
|
19020
19311
|
const targets = distribution && compileTargets(input).length === 0 ? [
|
|
19021
19312
|
{
|
|
19022
19313
|
name: "App",
|
|
19023
|
-
path:
|
|
19314
|
+
path: path33.relative(layout2.root, layout2.sources),
|
|
19024
19315
|
executable: true,
|
|
19025
19316
|
languageMode: 5,
|
|
19026
19317
|
mainActorIsolation: false,
|
|
@@ -19046,12 +19337,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19046
19337
|
if (!file.endsWith(".swift")) continue;
|
|
19047
19338
|
const target = bySourcePath.find(
|
|
19048
19339
|
(candidate) => (candidate.path === "." || file.startsWith(`${candidate.path}/`)) && (candidate.sources === void 0 || candidate.sources.some((source) => {
|
|
19049
|
-
const selected =
|
|
19340
|
+
const selected = path33.posix.join(candidate.path, source);
|
|
19050
19341
|
return file === selected || file.startsWith(`${selected}/`);
|
|
19051
19342
|
}))
|
|
19052
19343
|
);
|
|
19053
19344
|
const excluded = target?.exclude?.some(
|
|
19054
|
-
(name) => file ===
|
|
19345
|
+
(name) => file === path33.posix.join(target.path, name)
|
|
19055
19346
|
);
|
|
19056
19347
|
if (target && !excluded) swiftTargets.add(target.name);
|
|
19057
19348
|
}
|
|
@@ -19077,23 +19368,23 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19077
19368
|
([file, contents2]) => /\.(?:swift|h|m|mm)$/.test(file) ? [contents2.toString()] : []
|
|
19078
19369
|
)
|
|
19079
19370
|
);
|
|
19080
|
-
const headerDirectory =
|
|
19081
|
-
if (
|
|
19371
|
+
const headerDirectory = path33.join(layout2.root, ".build", "peach-cxx-headers");
|
|
19372
|
+
if (existsSync10(headerDirectory)) {
|
|
19082
19373
|
for (const entry of readdirSync6(headerDirectory, { withFileTypes: true }))
|
|
19083
19374
|
if (entry.isDirectory() && !targets.some((target) => target.name === entry.name))
|
|
19084
|
-
rmSync7(
|
|
19375
|
+
rmSync7(path33.join(headerDirectory, entry.name), { recursive: true, force: true });
|
|
19085
19376
|
}
|
|
19086
19377
|
let checkedToolchain;
|
|
19087
19378
|
const nativeToolchain = () => {
|
|
19088
19379
|
if (checkedToolchain) return checkedToolchain;
|
|
19089
|
-
const pin = distribution ?? JSON.parse(readFileSync16(
|
|
19380
|
+
const pin = distribution ?? JSON.parse(readFileSync16(path33.join(moduleRoot, "toolchain.json"), "utf8"));
|
|
19090
19381
|
checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
|
|
19091
19382
|
return checkedToolchain;
|
|
19092
19383
|
};
|
|
19093
19384
|
const deploymentTarget = (name) => input.nativeTargets?.find((value) => value.name === name)?.deploymentTarget ?? targets.find((value) => value.name === name)?.iosDeploymentTarget ?? null;
|
|
19094
19385
|
const targetStagedFiles = /* @__PURE__ */ new Map();
|
|
19095
19386
|
const stageTargetFile = (target, file, contents2, options) => {
|
|
19096
|
-
const relative =
|
|
19387
|
+
const relative = path33.relative(layout2.root, file).split(path33.sep).join(path33.posix.sep);
|
|
19097
19388
|
const prior = files.has(file) ? files.get(file) : Object.hasOwn(input.files, relative) ? input.files[relative] : void 0;
|
|
19098
19389
|
if (!options?.allowExisting && prior !== void 0)
|
|
19099
19390
|
throw new Error(`target ${target} already contains generated output ${relative}`);
|
|
@@ -19106,7 +19397,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19106
19397
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
19107
19398
|
return Object.entries(input.files).filter(
|
|
19108
19399
|
([file]) => file.startsWith(prefix) && (target.sources === void 0 || !(file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) || target.sources.some((source) => {
|
|
19109
|
-
const selected =
|
|
19400
|
+
const selected = path33.posix.join(prefix, source);
|
|
19110
19401
|
return file === selected || file.startsWith(`${selected}/`);
|
|
19111
19402
|
})) && !target.exclude?.some(
|
|
19112
19403
|
(excluded) => file === `${prefix}${excluded}` || file.startsWith(`${prefix}${excluded}/`)
|
|
@@ -19127,7 +19418,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19127
19418
|
targetStagedFiles.delete(target.name);
|
|
19128
19419
|
if (entries2.some(([file]) => isSwiftNativeTranslationUnit(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name))) {
|
|
19129
19420
|
if (!swift) {
|
|
19130
|
-
const unprepared =
|
|
19421
|
+
const unprepared = path33.join(
|
|
19131
19422
|
layout2.root,
|
|
19132
19423
|
target.path,
|
|
19133
19424
|
"PeachUnprepared.generated.swift"
|
|
@@ -19142,7 +19433,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19142
19433
|
native.set(target.name, {
|
|
19143
19434
|
mixed: true,
|
|
19144
19435
|
path: target.path,
|
|
19145
|
-
includeDirectory:
|
|
19436
|
+
includeDirectory: path33.join(layout2.root, target.path, "include"),
|
|
19146
19437
|
sources: [],
|
|
19147
19438
|
lateSources: [],
|
|
19148
19439
|
exclude: entries2.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length))
|
|
@@ -19164,15 +19455,15 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19164
19455
|
file
|
|
19165
19456
|
)?.[1];
|
|
19166
19457
|
if (owner)
|
|
19167
|
-
podHeaders.set(
|
|
19168
|
-
...podHeaders.get(
|
|
19458
|
+
podHeaders.set(path33.basename(file), [
|
|
19459
|
+
...podHeaders.get(path33.basename(file)) ?? [],
|
|
19169
19460
|
{ owner, content: input.files[file] }
|
|
19170
19461
|
]);
|
|
19171
19462
|
}
|
|
19172
|
-
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(
|
|
19463
|
+
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(path33.basename(file))?.find((header) => header.content === content)?.owner;
|
|
19173
19464
|
for (const settings of input.nativeTargets ?? []) {
|
|
19174
19465
|
for (const file of settings.headers) {
|
|
19175
|
-
const destination =
|
|
19466
|
+
const destination = path33.join(layout2.root, file);
|
|
19176
19467
|
if (files.has(destination)) continue;
|
|
19177
19468
|
const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
|
|
19178
19469
|
const frameworkHeader = !interfaceModule && /(?:^|\/)(\w+)\.framework\/Headers\/[\w+.-]+\.h$/.exec(file)?.[1];
|
|
@@ -19191,35 +19482,35 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19191
19482
|
}
|
|
19192
19483
|
}
|
|
19193
19484
|
const nativeTargets = input.nativeTargets ?? [];
|
|
19194
|
-
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ?
|
|
19195
|
-
const inRoot = `${layout2.root}${
|
|
19196
|
-
const binaryTree = `${
|
|
19485
|
+
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path33.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
|
|
19486
|
+
const inRoot = `${layout2.root}${path33.sep}`;
|
|
19487
|
+
const binaryTree = `${path33.sep}${SWIFT_BINARY_TREES_DIR}${path33.sep}`;
|
|
19197
19488
|
const headerSearch = writeXcodeHeaderSearch(
|
|
19198
|
-
|
|
19489
|
+
path33.join(layout2.root, ".build", "peach-xcode-headers"),
|
|
19199
19490
|
nativeTargets.map((settings) => {
|
|
19200
19491
|
const productHeaders = {};
|
|
19201
19492
|
const publishedHeaders = /* @__PURE__ */ new Set();
|
|
19202
19493
|
const moduleName = swiftTargetModuleName(settings.name);
|
|
19203
19494
|
for (const [product, file] of Object.entries(settings.productHeaders)) {
|
|
19204
|
-
const header =
|
|
19205
|
-
productHeaders[
|
|
19495
|
+
const header = path33.join(layout2.root, file);
|
|
19496
|
+
productHeaders[path33.join(layout2.root, product)] = header;
|
|
19206
19497
|
const framework = /^(.+\.framework)\/((?:Private)?Headers\/.+)$/.exec(product);
|
|
19207
19498
|
if (framework && Object.hasOwn(
|
|
19208
19499
|
settings.productHeaders,
|
|
19209
19500
|
`${framework[1]}/Modules/module.modulemap`
|
|
19210
19501
|
)) {
|
|
19211
|
-
productHeaders[
|
|
19212
|
-
if (
|
|
19502
|
+
productHeaders[path33.join(layout2.root, framework[1], "Modules", framework[2])] = header;
|
|
19503
|
+
if (path33.posix.basename(framework[1]) === `${moduleName}.framework` && framework[2] === `Headers/${path33.posix.basename(file)}`)
|
|
19213
19504
|
publishedHeaders.add(file);
|
|
19214
19505
|
}
|
|
19215
19506
|
}
|
|
19216
19507
|
if (settings.flattensPublicHeaders)
|
|
19217
19508
|
for (const file of settings.publicHeaders) {
|
|
19218
19509
|
if (publishedHeaders.has(file)) continue;
|
|
19219
|
-
const alias =
|
|
19510
|
+
const alias = path33.join(headerDirectory, settings.name, path33.basename(file));
|
|
19220
19511
|
if (Object.hasOwn(productHeaders, alias))
|
|
19221
19512
|
throw new Error(`duplicate product header ${alias}`);
|
|
19222
|
-
productHeaders[alias] =
|
|
19513
|
+
productHeaders[alias] = path33.join(layout2.root, file);
|
|
19223
19514
|
}
|
|
19224
19515
|
return {
|
|
19225
19516
|
headerMaps: settings.headerMaps.map((map) => ({
|
|
@@ -19231,18 +19522,18 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19231
19522
|
})),
|
|
19232
19523
|
productHeaders,
|
|
19233
19524
|
userHeaderSearchPaths: settings.userHeaderSearchPaths.map(
|
|
19234
|
-
(directory) =>
|
|
19525
|
+
(directory) => path33.join(layout2.root, directory)
|
|
19235
19526
|
),
|
|
19236
19527
|
searchDirectories: [
|
|
19237
19528
|
...settings.headerSearchPaths,
|
|
19238
19529
|
...settings.frameworkSearchPaths
|
|
19239
|
-
].map((directory) =>
|
|
19530
|
+
].map((directory) => path33.join(layout2.root, directory))
|
|
19240
19531
|
};
|
|
19241
19532
|
}),
|
|
19242
19533
|
Object.fromEntries(
|
|
19243
19534
|
Object.entries(input.headerAliases ?? {}).map(([alias, file]) => [
|
|
19244
|
-
|
|
19245
|
-
|
|
19535
|
+
path33.join(layout2.root, alias),
|
|
19536
|
+
path33.join(layout2.root, file)
|
|
19246
19537
|
])
|
|
19247
19538
|
),
|
|
19248
19539
|
(file) => !file.startsWith(inRoot) || files.has(file) || file.includes(binaryTree)
|
|
@@ -19286,9 +19577,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19286
19577
|
const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include)?.[1];
|
|
19287
19578
|
if (producer && swiftTargets.has(producer)) producers2.add(producer);
|
|
19288
19579
|
const local = [
|
|
19289
|
-
|
|
19580
|
+
path33.posix.join(path33.posix.dirname(file), include),
|
|
19290
19581
|
`${includes}${include}`,
|
|
19291
|
-
...searchRoots.map((root) =>
|
|
19582
|
+
...searchRoots.map((root) => path33.posix.join(root, include))
|
|
19292
19583
|
].find((candidate) => input.files[candidate] !== void 0);
|
|
19293
19584
|
if (local) {
|
|
19294
19585
|
reverse.set(local, [...reverse.get(local) ?? [], file]);
|
|
@@ -19331,7 +19622,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19331
19622
|
);
|
|
19332
19623
|
const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : entries2.some(([file]) => file.endsWith(".swift")) || importedModules.has(swiftTargetModuleName(target.name)) ? settings.publicHeaders : [];
|
|
19333
19624
|
const search = [.../* @__PURE__ */ new Set([...settings?.headerSearchPaths ?? []])].flatMap(
|
|
19334
|
-
(dir) => ["-I",
|
|
19625
|
+
(dir) => ["-I", path33.join(layout2.root, dir)]
|
|
19335
19626
|
);
|
|
19336
19627
|
const toolchainBin = nativeToolchain();
|
|
19337
19628
|
const stageFlags = (flags2, sdkInclude2) => flags2.map(
|
|
@@ -19343,7 +19634,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19343
19634
|
...search,
|
|
19344
19635
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
19345
19636
|
"-F",
|
|
19346
|
-
|
|
19637
|
+
path33.join(layout2.root, dir)
|
|
19347
19638
|
]),
|
|
19348
19639
|
"-I",
|
|
19349
19640
|
headerDirectory
|
|
@@ -19354,7 +19645,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19354
19645
|
...search,
|
|
19355
19646
|
...settings.frameworkSearchPaths.flatMap((dir) => [
|
|
19356
19647
|
"-F",
|
|
19357
|
-
|
|
19648
|
+
path33.join(layout2.root, dir)
|
|
19358
19649
|
]),
|
|
19359
19650
|
"-I",
|
|
19360
19651
|
headerDirectory
|
|
@@ -19364,13 +19655,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19364
19655
|
const flag = settings.importerFlags[index];
|
|
19365
19656
|
if (flag === "-I" || flag === "-iquote") {
|
|
19366
19657
|
const directory = settings.importerFlags[index + 1];
|
|
19367
|
-
if (directory === void 0 || !
|
|
19658
|
+
if (directory === void 0 || !path33.isAbsolute(directory)) {
|
|
19368
19659
|
index++;
|
|
19369
19660
|
continue;
|
|
19370
19661
|
}
|
|
19371
19662
|
}
|
|
19372
19663
|
const joined = /^-(?:I|iquote)(.+)$/.exec(flag);
|
|
19373
|
-
if (joined && !
|
|
19664
|
+
if (joined && !path33.isAbsolute(joined[1])) continue;
|
|
19374
19665
|
kept.push(flag);
|
|
19375
19666
|
}
|
|
19376
19667
|
return [
|
|
@@ -19379,13 +19670,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19379
19670
|
...search,
|
|
19380
19671
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
19381
19672
|
"-F",
|
|
19382
|
-
|
|
19673
|
+
path33.join(layout2.root, dir)
|
|
19383
19674
|
]),
|
|
19384
19675
|
"-I",
|
|
19385
19676
|
headerDirectory
|
|
19386
19677
|
];
|
|
19387
19678
|
})();
|
|
19388
|
-
const sdkInclude =
|
|
19679
|
+
const sdkInclude = path33.join(
|
|
19389
19680
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
19390
19681
|
"darwin/usr/include"
|
|
19391
19682
|
);
|
|
@@ -19400,7 +19691,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19400
19691
|
...dependencyModuleMaps,
|
|
19401
19692
|
...xcodeTarget && !target.defines?.includes("SWIFT_PACKAGE") ? ["-USWIFT_PACKAGE"] : []
|
|
19402
19693
|
];
|
|
19403
|
-
const prefixHeader = settings?.prefixHeader ? ["-include",
|
|
19694
|
+
const prefixHeader = settings?.prefixHeader ? ["-include", path33.join(layout2.root, settings.prefixHeader)] : [];
|
|
19404
19695
|
const bundleName = entries2.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
|
|
19405
19696
|
target: target.name,
|
|
19406
19697
|
path: target.path,
|
|
@@ -19411,7 +19702,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19411
19702
|
bundles: input.resourceBundles
|
|
19412
19703
|
});
|
|
19413
19704
|
const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
|
|
19414
|
-
const accessorHeader =
|
|
19705
|
+
const accessorHeader = path33.join(
|
|
19415
19706
|
layout2.root,
|
|
19416
19707
|
target.path,
|
|
19417
19708
|
OBJC_RESOURCE_ACCESSOR_HEADER
|
|
@@ -19422,7 +19713,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19422
19713
|
const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
|
|
19423
19714
|
const unitSource = (file) => {
|
|
19424
19715
|
const relative = file.slice(prefix.length);
|
|
19425
|
-
return relative.split("/").some((part) => part.startsWith(".")) ?
|
|
19716
|
+
return relative.split("/").some((part) => part.startsWith(".")) ? path33.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
|
|
19426
19717
|
};
|
|
19427
19718
|
const accessorFlags = accessor ? ["-include", accessorHeader] : [];
|
|
19428
19719
|
const nativeC = !entries2.some(([file]) => file.endsWith(".swift"));
|
|
@@ -19452,20 +19743,20 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19452
19743
|
)
|
|
19453
19744
|
].sort();
|
|
19454
19745
|
const topHeaders = settings.publicHeaders.filter(
|
|
19455
|
-
(file) =>
|
|
19746
|
+
(file) => path33.posix.dirname(file) === headerDir
|
|
19456
19747
|
);
|
|
19457
19748
|
if (input.files[custom] !== void 0) {
|
|
19458
19749
|
swiftpmModuleMap = { path: custom, contents: input.files[custom] };
|
|
19459
19750
|
} else if (input.files[umbrella] !== void 0) {
|
|
19460
19751
|
if (siblingDirs.length > 0)
|
|
19461
19752
|
throw new Error(
|
|
19462
|
-
`target ${target.name} has invalid header layout: umbrella header found at '${
|
|
19753
|
+
`target ${target.name} has invalid header layout: umbrella header found at '${path33.join(layout2.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name) => path33.join(layout2.root, headerDir, name)).join(", ")}; consider removing them`
|
|
19463
19754
|
);
|
|
19464
19755
|
swiftpmModuleMap = {
|
|
19465
19756
|
path: custom,
|
|
19466
19757
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
19467
19758
|
kind: "header",
|
|
19468
|
-
path:
|
|
19759
|
+
path: path33.join(layout2.root, umbrella)
|
|
19469
19760
|
})
|
|
19470
19761
|
};
|
|
19471
19762
|
} else if (input.files[nestedUmbrella] !== void 0 && siblingDirs.length === 1 && siblingDirs[0] === moduleName && topHeaders.length === 0) {
|
|
@@ -19473,7 +19764,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19473
19764
|
path: custom,
|
|
19474
19765
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
19475
19766
|
kind: "header",
|
|
19476
|
-
path:
|
|
19767
|
+
path: path33.join(layout2.root, nestedUmbrella)
|
|
19477
19768
|
})
|
|
19478
19769
|
};
|
|
19479
19770
|
} else {
|
|
@@ -19481,12 +19772,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19481
19772
|
path: custom,
|
|
19482
19773
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
19483
19774
|
kind: "directory",
|
|
19484
|
-
path:
|
|
19775
|
+
path: path33.join(layout2.root, headerDir)
|
|
19485
19776
|
})
|
|
19486
19777
|
};
|
|
19487
19778
|
}
|
|
19488
19779
|
}
|
|
19489
|
-
const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ??
|
|
19780
|
+
const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? path33.posix.join(
|
|
19490
19781
|
".build",
|
|
19491
19782
|
"peach-objc-originals",
|
|
19492
19783
|
target.name,
|
|
@@ -19494,59 +19785,59 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19494
19785
|
);
|
|
19495
19786
|
const moduleContents = originalModuleMap ? input.files[originalModuleMap[1]] : swiftpmModuleMap?.contents ?? packageModuleMap?.[1] ?? swiftObjCModuleMap(
|
|
19496
19787
|
swiftTargetModuleName(target.name),
|
|
19497
|
-
roots2.map((file) =>
|
|
19788
|
+
roots2.map((file) => path33.join(layout2.root, file)),
|
|
19498
19789
|
submoduleImports2.get(swiftTargetModuleName(target.name))
|
|
19499
19790
|
);
|
|
19500
19791
|
if (moduleContents === void 0)
|
|
19501
19792
|
throw new Error("missing original module map " + modulemap);
|
|
19502
19793
|
const framework = nativeC && moduleMapTokens(moduleContents.toString())[0] === "framework" ? /^(.*)\/[^/]+\.framework\/Modules\/module\.modulemap$/.exec(modulemap) : null;
|
|
19503
|
-
const frameworkDirectory = framework ?
|
|
19504
|
-
stageTargetFile(target.name,
|
|
19794
|
+
const frameworkDirectory = framework ? path33.join(layout2.root, framework[1]) : void 0;
|
|
19795
|
+
stageTargetFile(target.name, path33.join(layout2.root, modulemap), moduleContents, {
|
|
19505
19796
|
allowExisting: true
|
|
19506
19797
|
});
|
|
19507
19798
|
sourceModuleMaps.set(swiftTargetModuleName(target.name), {
|
|
19508
|
-
path:
|
|
19799
|
+
path: path33.join(layout2.root, modulemap),
|
|
19509
19800
|
contents: moduleContents.toString()
|
|
19510
19801
|
});
|
|
19511
|
-
if (nativeC &&
|
|
19802
|
+
if (nativeC && path33.posix.basename(modulemap) !== "module.modulemap") {
|
|
19512
19803
|
stageTargetFile(
|
|
19513
19804
|
target.name,
|
|
19514
|
-
|
|
19515
|
-
`extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(
|
|
19805
|
+
path33.join(layout2.root, path33.posix.dirname(modulemap), "module.modulemap"),
|
|
19806
|
+
`extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(path33.join(layout2.root, modulemap))}
|
|
19516
19807
|
`
|
|
19517
19808
|
);
|
|
19518
19809
|
}
|
|
19519
19810
|
const importFlags = [
|
|
19520
19811
|
...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
|
|
19521
|
-
"-fmodule-map-file=" +
|
|
19812
|
+
"-fmodule-map-file=" + path33.join(layout2.root, modulemap),
|
|
19522
19813
|
...dependencyModuleMaps
|
|
19523
19814
|
];
|
|
19524
19815
|
const groups = /* @__PURE__ */ new Map();
|
|
19525
19816
|
for (const [file, contents2] of nativeUnits) {
|
|
19526
19817
|
const origin = settings?.sourceDirectories[file];
|
|
19527
19818
|
if (origin) {
|
|
19528
|
-
const original =
|
|
19529
|
-
mkdirSync8(
|
|
19819
|
+
const original = path33.join(layout2.root, origin, path33.posix.basename(file));
|
|
19820
|
+
mkdirSync8(path33.dirname(original), { recursive: true });
|
|
19530
19821
|
stageTargetFile(target.name, original, contents2, { allowExisting: true });
|
|
19531
19822
|
}
|
|
19532
19823
|
const source = unitSource(file);
|
|
19533
19824
|
if (source !== file.slice(prefix.length))
|
|
19534
19825
|
stageTargetFile(
|
|
19535
19826
|
target.name,
|
|
19536
|
-
|
|
19827
|
+
path33.join(layout2.root, target.path, source),
|
|
19537
19828
|
contents2,
|
|
19538
19829
|
{
|
|
19539
19830
|
allowExisting: true
|
|
19540
19831
|
}
|
|
19541
19832
|
);
|
|
19542
|
-
const stagedDir =
|
|
19833
|
+
const stagedDir = path33.posix.dirname(file);
|
|
19543
19834
|
const quoteDirs = [
|
|
19544
19835
|
...stagedDir !== "." ? [stagedDir] : [],
|
|
19545
19836
|
...origin && origin !== stagedDir ? [origin] : []
|
|
19546
19837
|
];
|
|
19547
19838
|
const quoteFlags = quoteDirs.flatMap((dir) => [
|
|
19548
19839
|
"-iquote",
|
|
19549
|
-
|
|
19840
|
+
path33.join(layout2.root, dir)
|
|
19550
19841
|
]);
|
|
19551
19842
|
const fileFlags = settings.fileFlags[file] ?? [];
|
|
19552
19843
|
const objcCxx = fileFlags.includes(SWIFT_OBJCXX_LANGUAGE_FLAG);
|
|
@@ -19557,7 +19848,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19557
19848
|
.../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
|
|
19558
19849
|
...stageFlags(
|
|
19559
19850
|
[...objcCxx ? settings.cxxFlags : [], ...fileFlags],
|
|
19560
|
-
|
|
19851
|
+
path33.join(
|
|
19561
19852
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
19562
19853
|
"darwin/usr/include"
|
|
19563
19854
|
)
|
|
@@ -19568,17 +19859,17 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19568
19859
|
JSON.stringify([
|
|
19569
19860
|
cxx,
|
|
19570
19861
|
quoteDirs,
|
|
19571
|
-
perFile.map((flag) => flag.replaceAll(layout2.root +
|
|
19862
|
+
perFile.map((flag) => flag.replaceAll(layout2.root + path33.sep, "")),
|
|
19572
19863
|
(consumers.get(file)?.size ?? 0) > 0
|
|
19573
19864
|
])
|
|
19574
19865
|
).digest("hex").slice(0, 12);
|
|
19575
19866
|
const name = `${target.name}${nativeC ? "Native" : "Swift"}Implementation_${identity}`;
|
|
19576
|
-
const groupPath =
|
|
19577
|
-
const canonicalTargetPath =
|
|
19867
|
+
const groupPath = path33.posix.join("PeachNativeSources", name);
|
|
19868
|
+
const canonicalTargetPath = path33.posix.join("/peach/build", target.path);
|
|
19578
19869
|
const sourceIdentity = [
|
|
19579
|
-
`-ffile-prefix-map=${
|
|
19870
|
+
`-ffile-prefix-map=${path33.join(layout2.root, groupPath)}=${canonicalTargetPath}`,
|
|
19580
19871
|
...nativeToolset ? [
|
|
19581
|
-
`-ffile-prefix-map=${
|
|
19872
|
+
`-ffile-prefix-map=${path33.posix.join("/peach/build", groupPath)}=${canonicalTargetPath}`
|
|
19582
19873
|
] : []
|
|
19583
19874
|
];
|
|
19584
19875
|
const group = groups.get(identity) ?? {
|
|
@@ -19602,7 +19893,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19602
19893
|
...accessorFlags,
|
|
19603
19894
|
...stageFlags(
|
|
19604
19895
|
cxx ? settings.cxxFlags : [],
|
|
19605
|
-
|
|
19896
|
+
path33.join(
|
|
19606
19897
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
19607
19898
|
"darwin/usr/include"
|
|
19608
19899
|
)
|
|
@@ -19613,12 +19904,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19613
19904
|
};
|
|
19614
19905
|
stageTargetFile(
|
|
19615
19906
|
target.name,
|
|
19616
|
-
|
|
19907
|
+
path33.join(layout2.root, group.path, source),
|
|
19617
19908
|
contents2
|
|
19618
19909
|
);
|
|
19619
19910
|
stageTargetFile(
|
|
19620
19911
|
target.name,
|
|
19621
|
-
|
|
19912
|
+
path33.join(layout2.root, group.path, "include/module.modulemap"),
|
|
19622
19913
|
`module ${swiftTargetModuleName(group.name)} { export * }
|
|
19623
19914
|
`,
|
|
19624
19915
|
{ allowExisting: true }
|
|
@@ -19636,7 +19927,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19636
19927
|
stageTargetFile(target.name, accessorHeader, accessor.header);
|
|
19637
19928
|
stageTargetFile(
|
|
19638
19929
|
target.name,
|
|
19639
|
-
|
|
19930
|
+
path33.join(layout2.root, accessorUnit),
|
|
19640
19931
|
accessor.body
|
|
19641
19932
|
);
|
|
19642
19933
|
}
|
|
@@ -19651,7 +19942,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19651
19942
|
].sort();
|
|
19652
19943
|
native.set(target.name, {
|
|
19653
19944
|
path: target.path,
|
|
19654
|
-
includeDirectory:
|
|
19945
|
+
includeDirectory: path33.dirname(path33.join(layout2.root, modulemap)),
|
|
19655
19946
|
importFlags,
|
|
19656
19947
|
frameworkDirectory,
|
|
19657
19948
|
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
@@ -19675,23 +19966,23 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19675
19966
|
throw new Error(`original module map declares no module: ${modulemap}`);
|
|
19676
19967
|
stageTargetFile(
|
|
19677
19968
|
target.name,
|
|
19678
|
-
|
|
19679
|
-
`extern module ${exportedModule} ${JSON.stringify(
|
|
19969
|
+
path33.join(layout2.root, owner.path, "include/module.modulemap"),
|
|
19970
|
+
`extern module ${exportedModule} ${JSON.stringify(path33.join(layout2.root, modulemap))}
|
|
19680
19971
|
`,
|
|
19681
19972
|
{ allowExisting: true }
|
|
19682
19973
|
);
|
|
19683
19974
|
}
|
|
19684
19975
|
continue;
|
|
19685
19976
|
}
|
|
19686
|
-
const implementationHeaders =
|
|
19977
|
+
const implementationHeaders = path33.posix.join(
|
|
19687
19978
|
".build",
|
|
19688
19979
|
"peach-objc-implementations",
|
|
19689
19980
|
target.name
|
|
19690
19981
|
);
|
|
19691
|
-
const include =
|
|
19982
|
+
const include = path33.join(layout2.root, implementationHeaders);
|
|
19692
19983
|
stageTargetFile(
|
|
19693
19984
|
target.name,
|
|
19694
|
-
|
|
19985
|
+
path33.join(include, "module.modulemap"),
|
|
19695
19986
|
`module ${target.name}ImplementationDeclarations { export * }
|
|
19696
19987
|
`
|
|
19697
19988
|
);
|
|
@@ -19701,7 +19992,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19701
19992
|
includeDirectory: include,
|
|
19702
19993
|
importFlags,
|
|
19703
19994
|
swiftFlags: [
|
|
19704
|
-
...settings.bridgingHeader ? ["-import-objc-header",
|
|
19995
|
+
...settings.bridgingHeader ? ["-import-objc-header", path33.join(layout2.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
|
|
19705
19996
|
...importFlags.flatMap((flag) => ["-Xcc", flag])
|
|
19706
19997
|
],
|
|
19707
19998
|
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
@@ -19732,7 +20023,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19732
20023
|
const textualIncludes = entries2.map(([file]) => file).filter((file) => /\.(?:inc|inl|ipp|def)$/.test(file));
|
|
19733
20024
|
native.set(target.name, {
|
|
19734
20025
|
path: target.path,
|
|
19735
|
-
includeDirectory:
|
|
20026
|
+
includeDirectory: path33.join(layout2.root, includes),
|
|
19736
20027
|
sources: units.map(([file]) => file.slice(prefix.length)),
|
|
19737
20028
|
lateSources: late.map(([file]) => file.slice(prefix.length)),
|
|
19738
20029
|
exclude: [
|
|
@@ -19749,21 +20040,21 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19749
20040
|
} : {}
|
|
19750
20041
|
});
|
|
19751
20042
|
if (late.length === 0) {
|
|
19752
|
-
const headers =
|
|
20043
|
+
const headers = path33.posix.join(target.path, target.publicHeadersPath ?? "include");
|
|
19753
20044
|
const fragments = textualIncludes.filter(
|
|
19754
20045
|
(file) => headers === "." || file.startsWith(`${headers}/`)
|
|
19755
20046
|
);
|
|
19756
20047
|
const name = swiftTargetModuleName(target.name);
|
|
19757
|
-
const map =
|
|
19758
|
-
if (fragments.length > 0 && !Object.hasOwn(input.files, map) && !files.has(
|
|
20048
|
+
const map = path33.posix.join(headers, "module.modulemap");
|
|
20049
|
+
if (fragments.length > 0 && !Object.hasOwn(input.files, map) && !files.has(path33.join(layout2.root, map)) && !Object.hasOwn(input.files, path33.posix.join(headers, `${name}.h`)) && !Object.hasOwn(input.files, path33.posix.join(headers, name, `${name}.h`)))
|
|
19759
20050
|
stageTargetFile(
|
|
19760
20051
|
target.name,
|
|
19761
|
-
|
|
20052
|
+
path33.join(layout2.root, map),
|
|
19762
20053
|
[
|
|
19763
20054
|
`module ${name} {`,
|
|
19764
20055
|
' umbrella "."',
|
|
19765
20056
|
...fragments.map(
|
|
19766
|
-
(file) => ` textual header ${JSON.stringify(
|
|
20057
|
+
(file) => ` textual header ${JSON.stringify(path33.posix.relative(headers, file))}`
|
|
19767
20058
|
),
|
|
19768
20059
|
" export *",
|
|
19769
20060
|
"}",
|
|
@@ -19773,7 +20064,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19773
20064
|
continue;
|
|
19774
20065
|
}
|
|
19775
20066
|
files.set(
|
|
19776
|
-
|
|
20067
|
+
path33.join(layout2.root, target.path, "PeachSwiftImplementation/module.modulemap"),
|
|
19777
20068
|
`module ${swiftTargetModuleName(`${target.name}SwiftImplementation`)} { export * }
|
|
19778
20069
|
`
|
|
19779
20070
|
);
|
|
@@ -19785,7 +20076,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19785
20076
|
([file]) => file.startsWith(includes) && /\.(?:h|hpp|hh|hxx)$/.test(file) && consumers.get(file).size === 0
|
|
19786
20077
|
);
|
|
19787
20078
|
files.set(
|
|
19788
|
-
|
|
20079
|
+
path33.join(layout2.root, includes, "module.modulemap"),
|
|
19789
20080
|
[
|
|
19790
20081
|
`module ${target.name} {`,
|
|
19791
20082
|
...roots.map(
|
|
@@ -19800,7 +20091,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19800
20091
|
for (const map of generatedModuleMaps)
|
|
19801
20092
|
if (files.has(map.published) || Object.hasOwn(
|
|
19802
20093
|
input.files,
|
|
19803
|
-
|
|
20094
|
+
path33.relative(layout2.root, map.published).split(path33.sep).join(path33.posix.sep)
|
|
19804
20095
|
))
|
|
19805
20096
|
writeBuildFile(
|
|
19806
20097
|
map.output,
|
|
@@ -19829,10 +20120,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19829
20120
|
[...native.values()].flatMap((value) => value.late?.producers ?? [])
|
|
19830
20121
|
)) {
|
|
19831
20122
|
files.set(
|
|
19832
|
-
|
|
20123
|
+
path33.join(headerDirectory, name, name + "-Swift.h"),
|
|
19833
20124
|
'#include "../' + name + '-Swift.h"\n'
|
|
19834
20125
|
);
|
|
19835
|
-
const modulemap =
|
|
20126
|
+
const modulemap = path33.join(
|
|
19836
20127
|
layout2.root,
|
|
19837
20128
|
".build",
|
|
19838
20129
|
"peach-objc-swift-headers",
|
|
@@ -19842,7 +20133,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19842
20133
|
const moduleName = swiftTargetModuleName(name);
|
|
19843
20134
|
const originalMap = originalMaps.get(moduleName);
|
|
19844
20135
|
const stagedMap = sourceModuleMaps.get(moduleName);
|
|
19845
|
-
const originalPath = stagedMap?.path ?? (originalMap ?
|
|
20136
|
+
const originalPath = stagedMap?.path ?? (originalMap ? path33.join(layout2.root, originalMap) : void 0);
|
|
19846
20137
|
const originalContents = stagedMap?.contents ?? (originalMap && input.files[originalMap]);
|
|
19847
20138
|
const originalTokens = originalContents ? moduleMapTokens(originalContents) : [];
|
|
19848
20139
|
if (originalPath && originalTokens.some(
|
|
@@ -19856,20 +20147,20 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
19856
20147
|
modulemap,
|
|
19857
20148
|
originalPath ? `extern module ${moduleName} ${JSON.stringify(originalPath)}
|
|
19858
20149
|
module ${moduleName}.Swift {
|
|
19859
|
-
header ${JSON.stringify(
|
|
20150
|
+
header ${JSON.stringify(path33.join(headerDirectory, name + "-Swift.h"))}
|
|
19860
20151
|
requires objc
|
|
19861
20152
|
}
|
|
19862
20153
|
` : swiftObjCModuleMap(
|
|
19863
20154
|
moduleName,
|
|
19864
|
-
(input.nativeTargets?.find((target) => target.name === name)?.publicHeaders ?? []).map((header) =>
|
|
20155
|
+
(input.nativeTargets?.find((target) => target.name === name)?.publicHeaders ?? []).map((header) => path33.join(layout2.root, header)),
|
|
19865
20156
|
submoduleImports2.get(moduleName),
|
|
19866
|
-
|
|
20157
|
+
path33.join(headerDirectory, name + "-Swift.h")
|
|
19867
20158
|
)
|
|
19868
20159
|
);
|
|
19869
20160
|
nativeHeaderFlags.push("-fmodule-map-file=" + modulemap);
|
|
19870
20161
|
nativeSwiftHeaderMaps.set(name, modulemap);
|
|
19871
20162
|
}
|
|
19872
|
-
const providedFrameworks =
|
|
20163
|
+
const providedFrameworks = path33.join(layout2.root, ".build", "peach-provided-frameworks");
|
|
19873
20164
|
const probedProducts = /* @__PURE__ */ new Set();
|
|
19874
20165
|
if (distribution) {
|
|
19875
20166
|
for (const [file, contents2] of Object.entries(input.files))
|
|
@@ -19895,10 +20186,10 @@ module ${moduleName}.Swift {
|
|
|
19895
20186
|
continue;
|
|
19896
20187
|
const providedInterface = moduleInterface(name);
|
|
19897
20188
|
if (!providedInterface) continue;
|
|
19898
|
-
const framework =
|
|
19899
|
-
files.set(
|
|
20189
|
+
const framework = path33.join(providedFrameworks, `${name}.framework`);
|
|
20190
|
+
files.set(path33.join(framework, "Headers", `${name}.h`), providedInterface.header);
|
|
19900
20191
|
files.set(
|
|
19901
|
-
|
|
20192
|
+
path33.join(framework, "Modules", "module.modulemap"),
|
|
19902
20193
|
`framework module ${name} {
|
|
19903
20194
|
umbrella header "${name}.h"
|
|
19904
20195
|
export *
|
|
@@ -19907,10 +20198,10 @@ module ${moduleName}.Swift {
|
|
|
19907
20198
|
);
|
|
19908
20199
|
stagedProducts.push(name);
|
|
19909
20200
|
}
|
|
19910
|
-
if (
|
|
20201
|
+
if (existsSync10(providedFrameworks)) {
|
|
19911
20202
|
for (const entry of readdirSync6(providedFrameworks))
|
|
19912
20203
|
if (!stagedProducts.includes(entry.replace(/\.framework$/, "")))
|
|
19913
|
-
rmSync7(
|
|
20204
|
+
rmSync7(path33.join(providedFrameworks, entry), { recursive: true, force: true });
|
|
19914
20205
|
}
|
|
19915
20206
|
const providedFrameworkFlags = stagedProducts.length ? ["-F", providedFrameworks] : [];
|
|
19916
20207
|
const frameworkSearch = JSON.stringify([
|
|
@@ -19919,15 +20210,15 @@ module ${moduleName}.Swift {
|
|
|
19919
20210
|
...new Set(nativeTargets.flatMap((settings) => settings.frameworkSearchPaths))
|
|
19920
20211
|
].sort()
|
|
19921
20212
|
]);
|
|
19922
|
-
const frameworkSearchRecord =
|
|
20213
|
+
const frameworkSearchRecord = path33.join(
|
|
19923
20214
|
layout2.root,
|
|
19924
20215
|
".build",
|
|
19925
20216
|
"peach-framework-search.json"
|
|
19926
20217
|
);
|
|
19927
|
-
if (!
|
|
20218
|
+
if (!existsSync10(frameworkSearchRecord) || readFileSync16(frameworkSearchRecord, "utf8") !== frameworkSearch)
|
|
19928
20219
|
for (const cache of [
|
|
19929
|
-
|
|
19930
|
-
|
|
20220
|
+
path33.join(layout2.root, ".build", "ModuleCache"),
|
|
20221
|
+
path33.join(layout2.root, ".build", WASM_TRIPLE, "release", "ModuleCache")
|
|
19931
20222
|
])
|
|
19932
20223
|
rmSync7(cache, { recursive: true, force: true });
|
|
19933
20224
|
files.set(frameworkSearchRecord, frameworkSearch);
|
|
@@ -19935,7 +20226,7 @@ module ${moduleName}.Swift {
|
|
|
19935
20226
|
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
19936
20227
|
);
|
|
19937
20228
|
if (!distribution) {
|
|
19938
|
-
modulePlan.update(readFileSync16(
|
|
20229
|
+
modulePlan.update(readFileSync16(path33.join(moduleRoot, "Package.swift")));
|
|
19939
20230
|
}
|
|
19940
20231
|
modulePlan.update(
|
|
19941
20232
|
Object.keys(input.files).filter((file) => file.endsWith(".swift")).sort().join("\n")
|
|
@@ -19990,7 +20281,7 @@ module ${moduleName}.Swift {
|
|
|
19990
20281
|
(target) => {
|
|
19991
20282
|
const native2 = input.nativeTargets?.find(({ name }) => name === target.name);
|
|
19992
20283
|
if (native2) return native2.publicHeaders.map((file) => input.files[file] ?? "");
|
|
19993
|
-
const directory =
|
|
20284
|
+
const directory = path33.posix.join(
|
|
19994
20285
|
target.path,
|
|
19995
20286
|
target.publicHeadersPath ?? "include"
|
|
19996
20287
|
);
|
|
@@ -20026,7 +20317,7 @@ module ${moduleName}.Swift {
|
|
|
20026
20317
|
`;
|
|
20027
20318
|
} else if (mains.length === 0) {
|
|
20028
20319
|
const procedural = entries2.filter(
|
|
20029
|
-
([file, source]) =>
|
|
20320
|
+
([file, source]) => path33.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
|
|
20030
20321
|
);
|
|
20031
20322
|
const wrapped = procedural.length === 1 ? wrapUIApplicationMainEntry(procedural[0][1]) : null;
|
|
20032
20323
|
if (wrapped) {
|
|
@@ -20047,22 +20338,22 @@ module ${moduleName}.Swift {
|
|
|
20047
20338
|
`mixed executable ${target.name} requires one typed Swift application entry`
|
|
20048
20339
|
);
|
|
20049
20340
|
const [file, source] = nativeMains[0];
|
|
20050
|
-
const original =
|
|
20341
|
+
const original = path33.join(layout2.root, file);
|
|
20051
20342
|
const entry = neutralizedNativeMain(source);
|
|
20052
20343
|
files.set(original, entry);
|
|
20053
20344
|
const implementation = executableNativeUnits.get(file);
|
|
20054
20345
|
if (implementation) {
|
|
20055
20346
|
const unit = implementation.sources[implementation.index];
|
|
20056
|
-
const extension =
|
|
20057
|
-
const staged =
|
|
20058
|
-
|
|
20347
|
+
const extension = path33.posix.extname(unit);
|
|
20348
|
+
const staged = path33.posix.basename(unit, extension) === "main" ? path33.posix.join(
|
|
20349
|
+
path33.posix.dirname(unit),
|
|
20059
20350
|
`PeachApplicationEntry.generated${extension}`
|
|
20060
20351
|
) : unit;
|
|
20061
|
-
const directory =
|
|
20062
|
-
const destination =
|
|
20352
|
+
const directory = path33.join(layout2.root, implementation.path);
|
|
20353
|
+
const destination = path33.join(directory, staged);
|
|
20063
20354
|
if (staged !== unit && files.has(destination))
|
|
20064
20355
|
throw new Error(`mixed application entry conflicts with ${destination}`);
|
|
20065
|
-
files.delete(
|
|
20356
|
+
files.delete(path33.join(directory, unit));
|
|
20066
20357
|
files.set(destination, `#line 1 ${JSON.stringify(original)}
|
|
20067
20358
|
${entry}`);
|
|
20068
20359
|
implementation.sources[implementation.index] = staged;
|
|
@@ -20076,9 +20367,9 @@ ${entry}`);
|
|
|
20076
20367
|
}
|
|
20077
20368
|
if (!nativeEntry) {
|
|
20078
20369
|
compiled.set(entryFile, entrySource);
|
|
20079
|
-
if (
|
|
20080
|
-
const libraryEntry =
|
|
20081
|
-
|
|
20370
|
+
if (path33.basename(entryFile) === "main.swift") {
|
|
20371
|
+
const libraryEntry = path33.posix.join(
|
|
20372
|
+
path33.posix.dirname(entryFile),
|
|
20082
20373
|
"PeachApplicationEntry.generated.swift"
|
|
20083
20374
|
);
|
|
20084
20375
|
if (Object.hasOwn(input.files, libraryEntry))
|
|
@@ -20102,7 +20393,7 @@ ${entry}`);
|
|
|
20102
20393
|
exclude: []
|
|
20103
20394
|
});
|
|
20104
20395
|
files.set(
|
|
20105
|
-
|
|
20396
|
+
path33.join(layout2.root, `PeachApplication/${name}/Entry.swift`),
|
|
20106
20397
|
!nativeEntry ? `import ${swiftTargetModuleName(target.name)}
|
|
20107
20398
|
@main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }
|
|
20108
20399
|
` : `import ${swiftTargetModuleName(target.name)}
|
|
@@ -20134,7 +20425,7 @@ ${entry}`);
|
|
|
20134
20425
|
);
|
|
20135
20426
|
if (nativeFlags) {
|
|
20136
20427
|
const toolchainBin = nativeToolchain();
|
|
20137
|
-
const headers =
|
|
20428
|
+
const headers = path33.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
|
|
20138
20429
|
const dependencies2 = swiftTargetDependencies(input.files, targets);
|
|
20139
20430
|
const reachesNative = (name, seen = /* @__PURE__ */ new Set()) => {
|
|
20140
20431
|
if (native.has(name)) return true;
|
|
@@ -20180,10 +20471,10 @@ ${entry}`);
|
|
|
20180
20471
|
if (targets.length === 0 && !prebuilt) {
|
|
20181
20472
|
for (const [file, contents2] of Object.entries(input.files)) {
|
|
20182
20473
|
if (file === "Package.swift") continue;
|
|
20183
|
-
files.set(
|
|
20474
|
+
files.set(path33.join(layout2.sources, file), compiled.get(file) ?? contents2);
|
|
20184
20475
|
}
|
|
20185
20476
|
let manifest2 = readFileSync16(
|
|
20186
|
-
|
|
20477
|
+
path33.join(moduleRoot, "scripts/contrast-app-Package.swift"),
|
|
20187
20478
|
"utf8"
|
|
20188
20479
|
).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
|
|
20189
20480
|
const reactor = ` ${REACTOR_FLAG}`;
|
|
@@ -20230,16 +20521,16 @@ ${entry}`);
|
|
|
20230
20521
|
[anchor, ...games.map((name) => `${gameProduct(name)},`)].join("\n ")
|
|
20231
20522
|
);
|
|
20232
20523
|
}
|
|
20233
|
-
files.set(
|
|
20524
|
+
files.set(path33.join(layout2.root, "Package.swift"), manifest2 + moduleFiles);
|
|
20234
20525
|
} else {
|
|
20235
20526
|
const base = layout2.multi ? layout2.root : layout2.sources;
|
|
20236
20527
|
const libraries = /* @__PURE__ */ new Map();
|
|
20237
|
-
const binaryModules =
|
|
20528
|
+
const binaryModules = path33.join(layout2.root, ".peach-binary-modules");
|
|
20238
20529
|
for (const [name, data] of Object.entries(input.binaryModules ?? {})) {
|
|
20239
20530
|
if (!/^[A-Za-z_]\w*$/.test(name) || !input.libraries?.[name])
|
|
20240
20531
|
throw new Error(`invalid native Swift module ${name}: its library is required`);
|
|
20241
20532
|
files.set(
|
|
20242
|
-
|
|
20533
|
+
path33.join(binaryModules, `${name}.swiftmodule`),
|
|
20243
20534
|
Buffer.from(data, "base64")
|
|
20244
20535
|
);
|
|
20245
20536
|
}
|
|
@@ -20250,7 +20541,7 @@ ${entry}`);
|
|
|
20250
20541
|
const bytes = Buffer.from(data, "base64");
|
|
20251
20542
|
const digest = createHash18("sha256").update(bytes).digest("hex");
|
|
20252
20543
|
if (input.binaryModules?.[target] && packageTargets.has(target)) {
|
|
20253
|
-
const objects =
|
|
20544
|
+
const objects = path33.join(
|
|
20254
20545
|
layout2.root,
|
|
20255
20546
|
NATIVE_ARCHIVE_OBJECTS_DIR,
|
|
20256
20547
|
`${target}.build`
|
|
@@ -20261,13 +20552,13 @@ ${entry}`);
|
|
|
20261
20552
|
libraries.set(
|
|
20262
20553
|
target,
|
|
20263
20554
|
members.map(({ name, bytes: bytes2 }, index) => {
|
|
20264
|
-
const file =
|
|
20555
|
+
const file = path33.join(objects, `${index}-${digest}-${path33.basename(name)}`);
|
|
20265
20556
|
files.set(file, Buffer.from(bytes2));
|
|
20266
20557
|
return file;
|
|
20267
20558
|
})
|
|
20268
20559
|
);
|
|
20269
20560
|
} else {
|
|
20270
|
-
const file =
|
|
20561
|
+
const file = path33.join(
|
|
20271
20562
|
layout2.root,
|
|
20272
20563
|
".peach-libraries",
|
|
20273
20564
|
`lib${target}-${digest}.a`
|
|
@@ -20278,13 +20569,13 @@ ${entry}`);
|
|
|
20278
20569
|
}
|
|
20279
20570
|
for (const [file, contents2] of Object.entries(input.files)) {
|
|
20280
20571
|
if (file === "Package.swift") continue;
|
|
20281
|
-
const destination =
|
|
20572
|
+
const destination = path33.join(base, libraryEntryFiles.get(file) ?? file);
|
|
20282
20573
|
const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
|
|
20283
20574
|
const localInterface = interfaceModule && swiftTargets.has(interfaceModule) ? `#include ${JSON.stringify(
|
|
20284
|
-
|
|
20285
|
-
|
|
20286
|
-
|
|
20287
|
-
).split(
|
|
20575
|
+
path33.relative(
|
|
20576
|
+
path33.dirname(destination),
|
|
20577
|
+
path33.join(headerDirectory, `${interfaceModule}-Swift.h`)
|
|
20578
|
+
).split(path33.sep).join("/")
|
|
20288
20579
|
)}
|
|
20289
20580
|
` : void 0;
|
|
20290
20581
|
files.set(
|
|
@@ -20295,7 +20586,7 @@ ${entry}`);
|
|
|
20295
20586
|
const manifestTargets2 = targets.length > 0 ? targets : [
|
|
20296
20587
|
{
|
|
20297
20588
|
name: "App",
|
|
20298
|
-
path:
|
|
20589
|
+
path: path33.relative(layout2.root, layout2.sources).split(path33.sep).join("/"),
|
|
20299
20590
|
executable: true,
|
|
20300
20591
|
languageMode: 5,
|
|
20301
20592
|
mainActorIsolation: false,
|
|
@@ -20305,11 +20596,11 @@ ${entry}`);
|
|
|
20305
20596
|
const reachesFrameworks = !distribution || swiftImportedModules.has("Foundation") || Object.entries(input.files).some(
|
|
20306
20597
|
([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
|
|
20307
20598
|
) || [...importedModules].some(
|
|
20308
|
-
(name) => distribution.modules.includes(name) && !targets.some((target) => target.name === name) && !(clangImportedModules.has(name) && !swiftImportedModules.has(name) &&
|
|
20309
|
-
|
|
20599
|
+
(name) => distribution.modules.includes(name) && !targets.some((target) => target.name === name) && !(clangImportedModules.has(name) && !swiftImportedModules.has(name) && existsSync10(
|
|
20600
|
+
path33.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name)
|
|
20310
20601
|
))
|
|
20311
20602
|
);
|
|
20312
|
-
const frameworkLink = prebuilt ?
|
|
20603
|
+
const frameworkLink = prebuilt ? path33.join(layout2.root, ".peach-framework-objects.rsp") : void 0;
|
|
20313
20604
|
if (prebuilt && frameworkLink) {
|
|
20314
20605
|
const quote2 = (object2) => `"${object2.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
20315
20606
|
files.set(
|
|
@@ -20336,15 +20627,15 @@ ${entry}`);
|
|
|
20336
20627
|
}
|
|
20337
20628
|
}
|
|
20338
20629
|
files.set(
|
|
20339
|
-
|
|
20630
|
+
path33.join(layout2.root, "Package.swift"),
|
|
20340
20631
|
emitSwiftPackageManifest({
|
|
20341
20632
|
root: layout2.root,
|
|
20342
20633
|
files,
|
|
20343
20634
|
targets: manifestTargets2.map((target) => ({
|
|
20344
20635
|
...target,
|
|
20345
20636
|
sources: target.sources?.map((source) => {
|
|
20346
|
-
const entry = libraryEntryFiles.get(
|
|
20347
|
-
return entry ?
|
|
20637
|
+
const entry = libraryEntryFiles.get(path33.posix.join(target.path, source));
|
|
20638
|
+
return entry ? path33.posix.relative(target.path, entry) : source;
|
|
20348
20639
|
})
|
|
20349
20640
|
})),
|
|
20350
20641
|
packages,
|
|
@@ -20378,7 +20669,7 @@ ${entry}`);
|
|
|
20378
20669
|
),
|
|
20379
20670
|
...reachesFrameworks ? {
|
|
20380
20671
|
distributionLink: {
|
|
20381
|
-
path:
|
|
20672
|
+
path: path33.join(layout2.root, ".peach-distribution-objects.rsp"),
|
|
20382
20673
|
files
|
|
20383
20674
|
}
|
|
20384
20675
|
} : {},
|
|
@@ -20399,14 +20690,14 @@ ${entry}`);
|
|
|
20399
20690
|
for (const [file, bytes] of Object.entries(input.packageFiles ?? {})) {
|
|
20400
20691
|
const contents2 = Buffer.from(bytes, "base64");
|
|
20401
20692
|
files.set(
|
|
20402
|
-
|
|
20693
|
+
path33.join(layout2.root, file),
|
|
20403
20694
|
file.endsWith(".swift") && !/(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file) ? withFrameworkCompanionImports(
|
|
20404
20695
|
swiftPackageSourceAsIOS(contents2.toString("utf8"))
|
|
20405
20696
|
) : contents2
|
|
20406
20697
|
);
|
|
20407
20698
|
}
|
|
20408
20699
|
for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
|
|
20409
|
-
const destination =
|
|
20700
|
+
const destination = path33.join(layout2.root, file);
|
|
20410
20701
|
if (files.has(destination)) continue;
|
|
20411
20702
|
files.set(destination, Buffer.from(bytes, "base64"));
|
|
20412
20703
|
}
|
|
@@ -20415,14 +20706,14 @@ ${entry}`);
|
|
|
20415
20706
|
const nativeToolsetFlags = [
|
|
20416
20707
|
...headerAliasFlags,
|
|
20417
20708
|
...native.size > 0 ? [
|
|
20418
|
-
"-fmodule-map-file=" +
|
|
20709
|
+
"-fmodule-map-file=" + path33.join(
|
|
20419
20710
|
swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
|
|
20420
20711
|
"darwin/wasm/include/module.modulemap"
|
|
20421
20712
|
)
|
|
20422
20713
|
] : []
|
|
20423
20714
|
];
|
|
20424
|
-
const clangWrapper2 =
|
|
20425
|
-
const clang =
|
|
20715
|
+
const clangWrapper2 = path33.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
|
|
20716
|
+
const clang = path33.join(nativeToolchain(), "clang");
|
|
20426
20717
|
const prebuiltCompiler = distribution && objcPrebuiltStage !== false ? swiftObjCPrebuiltCompiler(
|
|
20427
20718
|
clang,
|
|
20428
20719
|
layout2.root,
|
|
@@ -20506,14 +20797,14 @@ ${entry}`);
|
|
|
20506
20797
|
].join("\n")
|
|
20507
20798
|
);
|
|
20508
20799
|
files.set(
|
|
20509
|
-
|
|
20800
|
+
path33.join(layout2.root, ".peach-target-toolset.json"),
|
|
20510
20801
|
JSON.stringify({
|
|
20511
20802
|
schemaVersion: "1.0",
|
|
20512
20803
|
cCompiler: {
|
|
20513
20804
|
extraCLIOptions: [
|
|
20514
20805
|
...nativeToolsetFlags,
|
|
20515
20806
|
"-fmodules",
|
|
20516
|
-
`-fmodules-cache-path=${
|
|
20807
|
+
`-fmodules-cache-path=${path33.join(layout2.root, ".build", "ModuleCache")}`
|
|
20517
20808
|
]
|
|
20518
20809
|
},
|
|
20519
20810
|
...nativeToolsetFlags.length > 0 ? { cxxCompiler: { extraCLIOptions: nativeToolsetFlags } } : {},
|
|
@@ -20521,7 +20812,7 @@ ${entry}`);
|
|
|
20521
20812
|
extraCLIOptions: [
|
|
20522
20813
|
...headerAliasFlags.flatMap((flag) => ["-Xcc", flag]),
|
|
20523
20814
|
distribution || prebuilt ? "-Isystem" : "-I",
|
|
20524
|
-
distributionModules ? providedModulesPath(layout2.root, distributionModules, moduleExcludes) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) :
|
|
20815
|
+
distributionModules ? providedModulesPath(layout2.root, distributionModules, moduleExcludes) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) : path33.join(layout2.root, ".build", WASM_TRIPLE, "release", "Modules"),
|
|
20525
20816
|
...distributionModules ? distributionClangModuleOptions(layout2.root, distributionModules) : [],
|
|
20526
20817
|
...prebuilt?.moduleMaps.flatMap((map) => [
|
|
20527
20818
|
"-Xcc",
|
|
@@ -20545,9 +20836,9 @@ ${entry}`);
|
|
|
20545
20836
|
throw new Error(
|
|
20546
20837
|
`swift resource target ${target.name} has no matching bundle assignment`
|
|
20547
20838
|
);
|
|
20548
|
-
const directory = layout2.multi ?
|
|
20839
|
+
const directory = layout2.multi ? path33.join(layout2.root, target.path) : layout2.sources;
|
|
20549
20840
|
files.set(
|
|
20550
|
-
|
|
20841
|
+
path33.join(directory, "ResourceBundleAccessor.generated.swift"),
|
|
20551
20842
|
[
|
|
20552
20843
|
"import Foundation",
|
|
20553
20844
|
"",
|
|
@@ -20564,7 +20855,7 @@ ${entry}`);
|
|
|
20564
20855
|
}
|
|
20565
20856
|
for (const [file, source] of compiled)
|
|
20566
20857
|
if (!Object.hasOwn(input.files, file))
|
|
20567
|
-
files.set(
|
|
20858
|
+
files.set(path33.join(layout2.multi ? layout2.root : layout2.sources, file), source);
|
|
20568
20859
|
const producers = [
|
|
20569
20860
|
.../* @__PURE__ */ new Set([...[...native.values()].flatMap((value) => value.late?.producers ?? [])])
|
|
20570
20861
|
];
|
|
@@ -20577,7 +20868,7 @@ ${entry}`);
|
|
|
20577
20868
|
generatedOwners.set(group.name, owner);
|
|
20578
20869
|
}
|
|
20579
20870
|
}
|
|
20580
|
-
const manifestPath =
|
|
20871
|
+
const manifestPath = path33.join(layout2.root, "Package.swift");
|
|
20581
20872
|
let manifest = files.get(manifestPath).toString();
|
|
20582
20873
|
const manifestTargets = swiftManifestTargets(manifest, [], (file) => {
|
|
20583
20874
|
const contents2 = files.get(file);
|
|
@@ -20677,7 +20968,7 @@ package.targets.first(where: { $0.name == ${JSON.stringify(target)} })!.dependen
|
|
|
20677
20968
|
if (members.length === 1) return members[0];
|
|
20678
20969
|
if (dependencies.has(name))
|
|
20679
20970
|
throw new Error(`generated build target collides with ${name}`);
|
|
20680
|
-
files.set(
|
|
20971
|
+
files.set(path33.join(layout2.root, name, "Products.swift"), "");
|
|
20681
20972
|
manifest += `
|
|
20682
20973
|
package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.stringify(members)}, path: ${JSON.stringify(name)}, swiftSettings: [.swiftLanguageMode(.v5)])]
|
|
20683
20974
|
`;
|
|
@@ -20787,8 +21078,8 @@ package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.
|
|
|
20787
21078
|
syncSwiftTree(layout2.root, files);
|
|
20788
21079
|
if (layout2.multi)
|
|
20789
21080
|
for (const target of targets)
|
|
20790
|
-
mkdirSync8(
|
|
20791
|
-
const clangWrapper =
|
|
21081
|
+
mkdirSync8(path33.join(layout2.root, target.path), { recursive: true });
|
|
21082
|
+
const clangWrapper = path33.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
|
|
20792
21083
|
if (files.has(clangWrapper) && (statSync4(clangWrapper).mode & 4095) !== 493)
|
|
20793
21084
|
chmodSync3(clangWrapper, 493);
|
|
20794
21085
|
return {
|
|
@@ -20819,8 +21110,8 @@ function outputOf(error) {
|
|
|
20819
21110
|
return error instanceof Error ? error.message : String(error);
|
|
20820
21111
|
}
|
|
20821
21112
|
function builtArtifact(layout2) {
|
|
20822
|
-
const binDir =
|
|
20823
|
-
const manifest = readFileSync16(
|
|
21113
|
+
const binDir = path33.join(layout2.root, ".build", WASM_TRIPLE, "release");
|
|
21114
|
+
const manifest = readFileSync16(path33.join(layout2.root, "Package.swift"), "utf8");
|
|
20824
21115
|
const executable = swiftManifestTargets(
|
|
20825
21116
|
manifest,
|
|
20826
21117
|
[],
|
|
@@ -20829,11 +21120,11 @@ function builtArtifact(layout2) {
|
|
|
20829
21120
|
if (executable === void 0) {
|
|
20830
21121
|
throw new Error("swift-compile: the written manifest names no executable target");
|
|
20831
21122
|
}
|
|
20832
|
-
return
|
|
21123
|
+
return path33.join(binDir, `${executable.name}.wasm`);
|
|
20833
21124
|
}
|
|
20834
21125
|
function projectDiagnostic(output, layout2, files) {
|
|
20835
21126
|
const base = layout2.multi ? layout2.root : layout2.sources;
|
|
20836
|
-
const prefix = `${base}${
|
|
21127
|
+
const prefix = `${base}${path33.sep}`;
|
|
20837
21128
|
return designTimeDiagnostic(output, files).split("\n").filter((line) => !SWIFTPM_NOISE.test(line)).map((line) => line.startsWith(prefix) ? line.slice(prefix.length) : line).join("\n").trim();
|
|
20838
21129
|
}
|
|
20839
21130
|
var ROOT_LOCKS = Symbol.for("peachsim.swiftCompile.rootLocks");
|
|
@@ -20869,12 +21160,12 @@ function serialize(root, work, signal) {
|
|
|
20869
21160
|
function readCompiledArtifact(directory, hash) {
|
|
20870
21161
|
try {
|
|
20871
21162
|
const receipt = JSON.parse(
|
|
20872
|
-
readFileSync16(
|
|
21163
|
+
readFileSync16(path33.join(directory, "artifact.json"), "utf8")
|
|
20873
21164
|
);
|
|
20874
21165
|
if (!receipt || typeof receipt !== "object" || !("hash" in receipt) || receipt.hash !== hash || !("icu" in receipt) || typeof receipt.icu !== "string" || !("wasm" in receipt) || typeof receipt.wasm !== "string")
|
|
20875
21166
|
return null;
|
|
20876
|
-
const bytes = readFileSync16(
|
|
20877
|
-
const gzip2 = readFileSync16(
|
|
21167
|
+
const bytes = readFileSync16(path33.join(directory, "app.wasm"));
|
|
21168
|
+
const gzip2 = readFileSync16(path33.join(directory, "icu.gz"));
|
|
20878
21169
|
if (createHash18("sha256").update(bytes).digest("hex") !== receipt.wasm || createHash18("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length <= 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
|
|
20879
21170
|
return null;
|
|
20880
21171
|
let sdk;
|
|
@@ -20882,7 +21173,7 @@ function readCompiledArtifact(directory, hash) {
|
|
|
20882
21173
|
const image = receipt.sdk;
|
|
20883
21174
|
if (!isRecord(image) || typeof image.key !== "string" || typeof image.sha256 !== "string" || typeof image.binding !== "string")
|
|
20884
21175
|
return null;
|
|
20885
|
-
const binding = readFileSync16(
|
|
21176
|
+
const binding = readFileSync16(path33.join(directory, "sdk-binding.bin"));
|
|
20886
21177
|
if (createHash18("sha256").update(binding).digest("hex") !== image.binding)
|
|
20887
21178
|
return null;
|
|
20888
21179
|
sdk = {
|
|
@@ -20899,16 +21190,16 @@ function readCompiledArtifact(directory, hash) {
|
|
|
20899
21190
|
}
|
|
20900
21191
|
}
|
|
20901
21192
|
function saveCompiledArtifact(root, artifact) {
|
|
20902
|
-
const directory =
|
|
21193
|
+
const directory = path33.join(root, "artifact");
|
|
20903
21194
|
mkdirSync8(directory, { recursive: true });
|
|
20904
|
-
const pending = mkdtempSync4(
|
|
21195
|
+
const pending = mkdtempSync4(path33.join(root, ".artifact-"));
|
|
20905
21196
|
try {
|
|
20906
|
-
writeFileSync8(
|
|
20907
|
-
writeFileSync8(
|
|
21197
|
+
writeFileSync8(path33.join(pending, "app.wasm"), artifact.bytes);
|
|
21198
|
+
writeFileSync8(path33.join(pending, "icu.gz"), artifact.icu.gzip);
|
|
20908
21199
|
if (artifact.sdk)
|
|
20909
|
-
writeFileSync8(
|
|
21200
|
+
writeFileSync8(path33.join(pending, "sdk-binding.bin"), artifact.sdk.binding.bytes);
|
|
20910
21201
|
writeFileSync8(
|
|
20911
|
-
|
|
21202
|
+
path33.join(pending, "artifact.json"),
|
|
20912
21203
|
JSON.stringify({
|
|
20913
21204
|
hash: artifact.hash,
|
|
20914
21205
|
wasm: createHash18("sha256").update(artifact.bytes).digest("hex"),
|
|
@@ -20923,7 +21214,7 @@ function saveCompiledArtifact(root, artifact) {
|
|
|
20923
21214
|
const outputs = ["app.wasm", "icu.gz"];
|
|
20924
21215
|
if (artifact.sdk) outputs.push("sdk-binding.bin");
|
|
20925
21216
|
for (const file of [...outputs, "artifact.json"]) {
|
|
20926
|
-
renameSync6(
|
|
21217
|
+
renameSync6(path33.join(pending, file), path33.join(directory, file));
|
|
20927
21218
|
}
|
|
20928
21219
|
} finally {
|
|
20929
21220
|
rmSync7(pending, { recursive: true, force: true });
|
|
@@ -20945,19 +21236,19 @@ function renewSharedArtifact(sharedRoot) {
|
|
|
20945
21236
|
function pruneSharedArtifacts(parent, keep) {
|
|
20946
21237
|
const entries2 = [];
|
|
20947
21238
|
for (const name of readdirSync6(parent)) {
|
|
20948
|
-
const directory =
|
|
21239
|
+
const directory = path33.join(parent, name);
|
|
20949
21240
|
if (name.startsWith(RETIRED_PREFIX)) {
|
|
20950
21241
|
reapRetiredCacheDirectory(parent, name);
|
|
20951
21242
|
continue;
|
|
20952
21243
|
}
|
|
20953
21244
|
try {
|
|
20954
21245
|
let bytes = 0;
|
|
20955
|
-
for (const file of readdirSync6(
|
|
21246
|
+
for (const file of readdirSync6(path33.join(directory, "artifact"), {
|
|
20956
21247
|
recursive: true,
|
|
20957
21248
|
encoding: "utf8"
|
|
20958
21249
|
})) {
|
|
20959
21250
|
try {
|
|
20960
|
-
bytes += statSync4(
|
|
21251
|
+
bytes += statSync4(path33.join(directory, "artifact", file)).size;
|
|
20961
21252
|
} catch (error) {
|
|
20962
21253
|
if (!vanished(error)) throw error;
|
|
20963
21254
|
}
|
|
@@ -20972,9 +21263,9 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
20972
21263
|
if (total <= SHARED_ARTIFACT_BUDGET_BYTES) break;
|
|
20973
21264
|
if (entry.directory === keep || Date.now() - entry.used < SHARED_ARTIFACT_GRACE_MS)
|
|
20974
21265
|
continue;
|
|
20975
|
-
const retired =
|
|
21266
|
+
const retired = path33.join(
|
|
20976
21267
|
parent,
|
|
20977
|
-
`${RETIRED_PREFIX}${process.pid}-${
|
|
21268
|
+
`${RETIRED_PREFIX}${process.pid}-${path33.basename(entry.directory)}`
|
|
20978
21269
|
);
|
|
20979
21270
|
try {
|
|
20980
21271
|
if (statSync4(entry.directory).mtimeMs !== entry.used) continue;
|
|
@@ -20990,7 +21281,7 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
20990
21281
|
function saveSharedArtifact(sharedRoot, artifact) {
|
|
20991
21282
|
saveCompiledArtifact(sharedRoot, artifact);
|
|
20992
21283
|
renewSharedArtifact(sharedRoot);
|
|
20993
|
-
pruneSharedArtifacts(
|
|
21284
|
+
pruneSharedArtifacts(path33.dirname(sharedRoot), sharedRoot);
|
|
20994
21285
|
}
|
|
20995
21286
|
var retainedArtifacts = /* @__PURE__ */ new Map();
|
|
20996
21287
|
function retain(root, artifact) {
|
|
@@ -21018,7 +21309,7 @@ function frameworkLibraryTargets(manifest) {
|
|
|
21018
21309
|
}
|
|
21019
21310
|
function linkedFrameworkTargets(moduleRoot, input) {
|
|
21020
21311
|
const libraries = frameworkLibraryTargets(
|
|
21021
|
-
readFileSync16(
|
|
21312
|
+
readFileSync16(path33.join(moduleRoot, "Package.swift"), "utf8")
|
|
21022
21313
|
);
|
|
21023
21314
|
const targets = compileTargets(input);
|
|
21024
21315
|
const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
|
|
@@ -21044,7 +21335,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
21044
21335
|
imports.add(name);
|
|
21045
21336
|
reach(name);
|
|
21046
21337
|
}
|
|
21047
|
-
const manifest = readFileSync16(
|
|
21338
|
+
const manifest = readFileSync16(path33.join(moduleRoot, "Package.swift"), "utf8");
|
|
21048
21339
|
const targetDependencies = /* @__PURE__ */ new Map();
|
|
21049
21340
|
for (const match of manifest.matchAll(
|
|
21050
21341
|
/\.target\(\s*name:\s*"([^"]+)"\s*,\s*dependencies:\s*\[([^\]]*)\]/g
|
|
@@ -21061,11 +21352,11 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
21061
21352
|
};
|
|
21062
21353
|
for (const name of reached)
|
|
21063
21354
|
for (const member of libraries.get(name) ?? []) build(member);
|
|
21064
|
-
const overlays =
|
|
21355
|
+
const overlays = path33.join(moduleRoot, "cross-import-overlays");
|
|
21065
21356
|
for (const directory of readdirSync6(overlays)) {
|
|
21066
|
-
const companion =
|
|
21357
|
+
const companion = path33.basename(directory, ".swiftcrossimport");
|
|
21067
21358
|
if (!built.has(companion)) continue;
|
|
21068
|
-
const declaration =
|
|
21359
|
+
const declaration = path33.join(overlays, directory, "SwiftUI.swiftoverlay");
|
|
21069
21360
|
for (const match of readFileSync16(declaration, "utf8").matchAll(
|
|
21070
21361
|
/^\s*- name: ([A-Za-z_]\w*)\s*$/gm
|
|
21071
21362
|
))
|
|
@@ -21092,7 +21383,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
21092
21383
|
return { products: linked, targets: linkedMembers, imports: [...imports].sort() };
|
|
21093
21384
|
}
|
|
21094
21385
|
function writeFrameworkLinkPackage(linkRoot, moduleRoot, products) {
|
|
21095
|
-
const identity =
|
|
21386
|
+
const identity = path33.basename(moduleRoot).toLowerCase();
|
|
21096
21387
|
const swiftString = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
21097
21388
|
const dependencies = products.map(
|
|
21098
21389
|
(name) => ` .product(name: ${swiftString(name)}, package: ${swiftString(identity)}),`
|
|
@@ -21114,13 +21405,13 @@ ${dependencies}
|
|
|
21114
21405
|
]
|
|
21115
21406
|
)
|
|
21116
21407
|
`;
|
|
21117
|
-
const sourceDir =
|
|
21408
|
+
const sourceDir = path33.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
|
|
21118
21409
|
mkdirSync8(sourceDir, { recursive: true });
|
|
21119
|
-
const manifestPath =
|
|
21120
|
-
if (!
|
|
21410
|
+
const manifestPath = path33.join(linkRoot, "Package.swift");
|
|
21411
|
+
if (!existsSync10(manifestPath) || readFileSync16(manifestPath, "utf8") !== manifest)
|
|
21121
21412
|
writeFileSync8(manifestPath, manifest);
|
|
21122
|
-
const source =
|
|
21123
|
-
if (!
|
|
21413
|
+
const source = path33.join(sourceDir, "Link.swift");
|
|
21414
|
+
if (!existsSync10(source)) writeFileSync8(source, "");
|
|
21124
21415
|
}
|
|
21125
21416
|
function frameworkLinkClosure(scratch, roots) {
|
|
21126
21417
|
const suffix = `${WASM_TRIPLE}-release`;
|
|
@@ -21132,7 +21423,7 @@ function frameworkLinkClosure(scratch, roots) {
|
|
|
21132
21423
|
const objcHeaders = /* @__PURE__ */ new Map();
|
|
21133
21424
|
let pending = null;
|
|
21134
21425
|
let compiling = null;
|
|
21135
|
-
for (const line of readFileSync16(
|
|
21426
|
+
for (const line of readFileSync16(path33.join(scratch, "release.yaml"), "utf8").split(
|
|
21136
21427
|
"\n"
|
|
21137
21428
|
)) {
|
|
21138
21429
|
const phony = phonyHeader.exec(line);
|
|
@@ -21200,7 +21491,7 @@ function frameworkLinkClosure(scratch, roots) {
|
|
|
21200
21491
|
owners.set(file, name);
|
|
21201
21492
|
if (seen.has(file)) continue;
|
|
21202
21493
|
seen.add(file);
|
|
21203
|
-
if (!
|
|
21494
|
+
if (!existsSync10(file))
|
|
21204
21495
|
throw new Error(`swift-compile: framework object ${file} was not built`);
|
|
21205
21496
|
files.push(file);
|
|
21206
21497
|
}
|
|
@@ -21216,22 +21507,94 @@ function frameworkLinkClosure(scratch, roots) {
|
|
|
21216
21507
|
};
|
|
21217
21508
|
}
|
|
21218
21509
|
function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
|
|
21219
|
-
if (!
|
|
21510
|
+
if (!existsSync10(modulesDir)) return;
|
|
21220
21511
|
const folded = new Set([...keep].map((name) => name.toLowerCase()));
|
|
21221
21512
|
for (const name of readdirSync6(modulesDir)) {
|
|
21222
21513
|
const dot = name.indexOf(".");
|
|
21223
21514
|
if (dot <= 0) continue;
|
|
21224
21515
|
const module = name.slice(0, dot);
|
|
21225
21516
|
if (keep.has(module) || !folded.has(module.toLowerCase())) continue;
|
|
21226
|
-
rmSync7(
|
|
21517
|
+
rmSync7(path33.join(modulesDir, name), { recursive: true, force: true });
|
|
21518
|
+
}
|
|
21519
|
+
}
|
|
21520
|
+
var frameworkProductsReceiptSchema = object({
|
|
21521
|
+
modules: string(),
|
|
21522
|
+
objects: array(string()),
|
|
21523
|
+
lazyObjects: array(string()),
|
|
21524
|
+
owners: array(tuple([string(), string()])),
|
|
21525
|
+
providers: array(string()),
|
|
21526
|
+
link: array(string()),
|
|
21527
|
+
moduleMaps: array(string()),
|
|
21528
|
+
objcHeaders: array(tuple([string(), string()])),
|
|
21529
|
+
archived: array(tuple([string(), string()]))
|
|
21530
|
+
});
|
|
21531
|
+
function readFrameworkProductsReceipt(scratch, receiptKey) {
|
|
21532
|
+
const receiptFile = path33.join(scratch, "products-ready", `${receiptKey}.json`);
|
|
21533
|
+
if (!existsSync10(receiptFile)) return null;
|
|
21534
|
+
let parsed;
|
|
21535
|
+
try {
|
|
21536
|
+
parsed = parse(
|
|
21537
|
+
frameworkProductsReceiptSchema,
|
|
21538
|
+
JSON.parse(readFileSync16(receiptFile, "utf8"))
|
|
21539
|
+
);
|
|
21540
|
+
} catch {
|
|
21541
|
+
return null;
|
|
21227
21542
|
}
|
|
21543
|
+
const archive = path33.join(scratch, "lib");
|
|
21544
|
+
const archiveStamp = path33.join(archive, ".receipt");
|
|
21545
|
+
const archiveMatches = existsSync10(archiveStamp) && readFileSync16(archiveStamp, "utf8") === receiptKey;
|
|
21546
|
+
if (!existsSync10(parsed.modules)) return null;
|
|
21547
|
+
for (const [object2] of parsed.archived) if (!existsSync10(object2)) return null;
|
|
21548
|
+
for (const file of parsed.providers) if (!existsSync10(file)) return null;
|
|
21549
|
+
for (const file of parsed.moduleMaps) if (!existsSync10(file)) return null;
|
|
21550
|
+
if (!archiveMatches) {
|
|
21551
|
+
rmSync7(archive, { recursive: true, force: true });
|
|
21552
|
+
mkdirSync8(archive, { recursive: true });
|
|
21553
|
+
for (const [object2, rel] of parsed.archived)
|
|
21554
|
+
symlinkSync2(object2, path33.join(scratch, rel));
|
|
21555
|
+
writeFileSync8(archiveStamp, receiptKey);
|
|
21556
|
+
}
|
|
21557
|
+
for (const file of parsed.objects) if (!existsSync10(file)) return null;
|
|
21558
|
+
for (const file of parsed.lazyObjects) if (!existsSync10(file)) return null;
|
|
21559
|
+
return {
|
|
21560
|
+
root: scratch,
|
|
21561
|
+
modules: parsed.modules,
|
|
21562
|
+
objects: parsed.objects,
|
|
21563
|
+
lazyObjects: parsed.lazyObjects,
|
|
21564
|
+
owners: new Map(parsed.owners),
|
|
21565
|
+
providers: parsed.providers,
|
|
21566
|
+
link: parsed.link,
|
|
21567
|
+
moduleMaps: parsed.moduleMaps,
|
|
21568
|
+
objcHeaders: new Map(parsed.objcHeaders)
|
|
21569
|
+
};
|
|
21228
21570
|
}
|
|
21229
21571
|
async function buildFrameworkProducts(scratch, args) {
|
|
21230
21572
|
const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input);
|
|
21231
|
-
const
|
|
21573
|
+
const unoptimized = args.input.unoptimized === true;
|
|
21574
|
+
const sdkOptions = swiftCompileSdkOptions(args.moduleRoot, args.toolchainBin);
|
|
21575
|
+
const selectorOptions = swiftObjCSelectorOptions(args.moduleRoot);
|
|
21576
|
+
const receiptKey = createHash18("sha256").update(
|
|
21577
|
+
JSON.stringify([
|
|
21578
|
+
"framework-products/v1",
|
|
21579
|
+
args.frameworkKey,
|
|
21580
|
+
unoptimized,
|
|
21581
|
+
args.sdk,
|
|
21582
|
+
args.toolchainBin,
|
|
21583
|
+
[...linkedTargets.products].sort(),
|
|
21584
|
+
darwinRecordsMinimum(),
|
|
21585
|
+
args.plugins,
|
|
21586
|
+
sdkOptions,
|
|
21587
|
+
selectorOptions
|
|
21588
|
+
])
|
|
21589
|
+
).digest("hex").slice(0, 32);
|
|
21590
|
+
const ready = readFrameworkProductsReceipt(scratch, receiptKey);
|
|
21591
|
+
if (ready) return ready;
|
|
21592
|
+
await waitForNoSwiftRootReaders(scratch, args.buildOptions.signal);
|
|
21593
|
+
const linkRoot = path33.join(scratch, "link");
|
|
21232
21594
|
writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products);
|
|
21595
|
+
const frameworkTmp = path33.join(scratch, "peach-compiler-tmp");
|
|
21596
|
+
mkdirSync8(frameworkTmp, { recursive: true });
|
|
21233
21597
|
const jobs = swiftCompilerJobs();
|
|
21234
|
-
const unoptimized = args.input.unoptimized === true;
|
|
21235
21598
|
const targetJobs = unoptimized ? jobs >= 4 ? 2 : 1 : jobs;
|
|
21236
21599
|
const driverJobs = unoptimized ? Math.max(1, Math.floor(jobs / targetJobs)) : jobs;
|
|
21237
21600
|
await runCompiler(
|
|
@@ -21249,8 +21612,8 @@ async function buildFrameworkProducts(scratch, args) {
|
|
|
21249
21612
|
scratch,
|
|
21250
21613
|
"--target",
|
|
21251
21614
|
FRAMEWORK_LINK_TARGET,
|
|
21252
|
-
...
|
|
21253
|
-
...
|
|
21615
|
+
...sdkOptions,
|
|
21616
|
+
...selectorOptions,
|
|
21254
21617
|
"--swift-sdk",
|
|
21255
21618
|
args.sdk,
|
|
21256
21619
|
"-c",
|
|
@@ -21269,15 +21632,17 @@ async function buildFrameworkProducts(scratch, args) {
|
|
|
21269
21632
|
"-Xswiftc",
|
|
21270
21633
|
String(driverJobs)
|
|
21271
21634
|
] : ["-Xswiftc", "-Osize"],
|
|
21272
|
-
// the release link strips all debug info, so none is generated
|
|
21635
|
+
// the release link strips all debug info, so none is generated. keep
|
|
21636
|
+
// -num-threads fixed across caller core caps so llbuild does not rebuild
|
|
21637
|
+
// every framework target when callers alternate --cores.
|
|
21273
21638
|
"-Xswiftc",
|
|
21274
21639
|
"-gnone",
|
|
21275
21640
|
"-Xswiftc",
|
|
21276
21641
|
"-num-threads",
|
|
21277
21642
|
"-Xswiftc",
|
|
21278
|
-
String(unoptimized ? 1 :
|
|
21643
|
+
String(unoptimized ? 1 : Math.min(4, os4.availableParallelism())),
|
|
21279
21644
|
...swiftReproducibleBuildFlags([
|
|
21280
|
-
[
|
|
21645
|
+
[path33.dirname(args.toolchainBin), "toolchain"],
|
|
21281
21646
|
[args.moduleRoot, "framework"],
|
|
21282
21647
|
[scratch, "framework-scratch"]
|
|
21283
21648
|
]),
|
|
@@ -21294,22 +21659,27 @@ async function buildFrameworkProducts(scratch, args) {
|
|
|
21294
21659
|
`${plugin}#ExpoModulesMacros`
|
|
21295
21660
|
])
|
|
21296
21661
|
],
|
|
21662
|
+
// swiftpm hashes TMPDIR into its plan; keep one stable compiler scratch inside the locked slot.
|
|
21297
21663
|
// the framework build's warnings alone pass the default 1 MiB cap, which kills
|
|
21298
21664
|
// the build one step from the end.
|
|
21299
|
-
{
|
|
21665
|
+
{
|
|
21666
|
+
...args.buildOptions,
|
|
21667
|
+
temporaryDirectory: frameworkTmp,
|
|
21668
|
+
maxBuffer: 64 * 1024 * 1024
|
|
21669
|
+
},
|
|
21300
21670
|
SWIFTPM_PROGRESS,
|
|
21301
21671
|
SWIFTPM_NOISE
|
|
21302
21672
|
).catch((error) => {
|
|
21303
21673
|
throw new Error(outputOf(error), { cause: error });
|
|
21304
21674
|
});
|
|
21305
|
-
const release =
|
|
21675
|
+
const release = path33.join(scratch, WASM_TRIPLE, "release");
|
|
21306
21676
|
const linked = frameworkLinkClosure(scratch, linkedTargets.targets);
|
|
21307
21677
|
const objects = linked.objects;
|
|
21308
21678
|
if (linked.modules.has("UniformTypeIdentifiers")) {
|
|
21309
|
-
const constantsDir =
|
|
21310
|
-
const constantsStamp =
|
|
21311
|
-
const object2 =
|
|
21312
|
-
if (!
|
|
21679
|
+
const constantsDir = path33.join(scratch, "uniform-type-constants");
|
|
21680
|
+
const constantsStamp = path33.join(constantsDir, ".complete");
|
|
21681
|
+
const object2 = path33.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
|
|
21682
|
+
if (!existsSync10(constantsStamp) || readFileSync16(constantsStamp, "utf8") !== args.frameworkKey) {
|
|
21313
21683
|
rmSync7(constantsDir, { recursive: true, force: true });
|
|
21314
21684
|
mkdirSync8(constantsDir);
|
|
21315
21685
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
@@ -21326,11 +21696,11 @@ async function buildFrameworkProducts(scratch, args) {
|
|
|
21326
21696
|
objects.push(object2);
|
|
21327
21697
|
linked.owners.set(object2, "UniformTypeIdentifiers");
|
|
21328
21698
|
}
|
|
21329
|
-
removeCaseCollidingModuleArtifacts(
|
|
21330
|
-
const response =
|
|
21699
|
+
removeCaseCollidingModuleArtifacts(path33.join(release, "Modules"), linked.modules);
|
|
21700
|
+
const response = path33.join(scratch, "autolink-objects.rsp");
|
|
21331
21701
|
writeFileSync8(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
|
|
21332
21702
|
const extracted = await runCompiler(
|
|
21333
|
-
|
|
21703
|
+
path33.join(args.toolchainBin, "swift-autolink-extract"),
|
|
21334
21704
|
[`@${response}`, "-o", "-"],
|
|
21335
21705
|
args.buildOptions
|
|
21336
21706
|
);
|
|
@@ -21338,16 +21708,16 @@ async function buildFrameworkProducts(scratch, args) {
|
|
|
21338
21708
|
const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
|
|
21339
21709
|
if (link.includes("-lFoundation"))
|
|
21340
21710
|
for (const name of foundationCategoryObjects) {
|
|
21341
|
-
const object2 =
|
|
21711
|
+
const object2 = path33.join(
|
|
21342
21712
|
swiftSdkPaths(args.moduleRoot, args.toolchainBin).resources,
|
|
21343
21713
|
`wasi/${name}.objc.o`
|
|
21344
21714
|
);
|
|
21345
21715
|
objects.push(object2);
|
|
21346
21716
|
linked.owners.set(object2, "Foundation");
|
|
21347
21717
|
}
|
|
21348
|
-
const providerDir =
|
|
21349
|
-
const providerStamp =
|
|
21350
|
-
if (!
|
|
21718
|
+
const providerDir = path33.join(scratch, "darwin-records");
|
|
21719
|
+
const providerStamp = path33.join(providerDir, ".complete");
|
|
21720
|
+
if (!existsSync10(providerStamp) || readFileSync16(providerStamp, "utf8") !== args.frameworkKey) {
|
|
21351
21721
|
rmSync7(providerDir, { recursive: true, force: true });
|
|
21352
21722
|
mkdirSync8(providerDir);
|
|
21353
21723
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
@@ -21361,18 +21731,18 @@ async function buildFrameworkProducts(scratch, args) {
|
|
|
21361
21731
|
});
|
|
21362
21732
|
writeFileSync8(providerStamp, args.frameworkKey);
|
|
21363
21733
|
}
|
|
21364
|
-
const providers = readdirSync6(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) =>
|
|
21734
|
+
const providers = readdirSync6(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path33.join(providerDir, file));
|
|
21365
21735
|
for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
|
|
21366
|
-
const archive =
|
|
21736
|
+
const archive = path33.join(scratch, "lib");
|
|
21367
21737
|
rmSync7(archive, { recursive: true, force: true });
|
|
21368
21738
|
mkdirSync8(archive);
|
|
21369
21739
|
const archived = /* @__PURE__ */ new Map();
|
|
21370
21740
|
for (const object2 of objects) {
|
|
21371
21741
|
const target = linked.owners.get(object2);
|
|
21372
|
-
const dir =
|
|
21373
|
-
if (!target || target === "Darwin" || !object2.startsWith(dir +
|
|
21374
|
-
const name = `${target}-${
|
|
21375
|
-
symlinkSync2(object2,
|
|
21742
|
+
const dir = path33.join(release, `${target}.build`);
|
|
21743
|
+
if (!target || target === "Darwin" || !object2.startsWith(dir + path33.sep)) continue;
|
|
21744
|
+
const name = `${target}-${path33.relative(dir, object2).replaceAll(path33.sep, "-").replace(/\.swift\.o$/, ".o")}`;
|
|
21745
|
+
symlinkSync2(object2, path33.join(archive, name));
|
|
21376
21746
|
archived.set(object2, `lib/${name}`);
|
|
21377
21747
|
}
|
|
21378
21748
|
const roots = swiftObjcRootObjects(`${scratch}
|
|
@@ -21381,11 +21751,11 @@ ${args.frameworkKey}`, scratch, [
|
|
|
21381
21751
|
]);
|
|
21382
21752
|
const linkedObjects = objects.map((object2) => {
|
|
21383
21753
|
const name = archived.get(object2);
|
|
21384
|
-
return name ? { path:
|
|
21754
|
+
return name ? { path: path33.join(scratch, name), lazy: !roots.has(name) } : { path: object2, lazy: false };
|
|
21385
21755
|
});
|
|
21386
|
-
|
|
21756
|
+
const result = {
|
|
21387
21757
|
root: scratch,
|
|
21388
|
-
modules:
|
|
21758
|
+
modules: path33.join(release, "Modules"),
|
|
21389
21759
|
objects: linkedObjects.filter((object2) => !object2.lazy).map((object2) => object2.path),
|
|
21390
21760
|
lazyObjects: linkedObjects.filter((object2) => object2.lazy).map((object2) => object2.path),
|
|
21391
21761
|
owners: linked.owners,
|
|
@@ -21394,6 +21764,27 @@ ${args.frameworkKey}`, scratch, [
|
|
|
21394
21764
|
moduleMaps: linked.moduleMaps,
|
|
21395
21765
|
objcHeaders: linked.objcHeaders
|
|
21396
21766
|
};
|
|
21767
|
+
writeFileSync8(path33.join(archive, ".receipt"), receiptKey);
|
|
21768
|
+
const receiptsDir = path33.join(scratch, "products-ready");
|
|
21769
|
+
mkdirSync8(receiptsDir, { recursive: true });
|
|
21770
|
+
const receiptFile = path33.join(receiptsDir, `${receiptKey}.json`);
|
|
21771
|
+
const partialReceipt = `${receiptFile}.${process.pid}.${randomUUID5()}`;
|
|
21772
|
+
writeFileSync8(
|
|
21773
|
+
partialReceipt,
|
|
21774
|
+
JSON.stringify({
|
|
21775
|
+
modules: result.modules,
|
|
21776
|
+
objects: result.objects,
|
|
21777
|
+
lazyObjects: result.lazyObjects,
|
|
21778
|
+
owners: [...result.owners.entries()],
|
|
21779
|
+
providers: result.providers,
|
|
21780
|
+
link: result.link,
|
|
21781
|
+
moduleMaps: result.moduleMaps,
|
|
21782
|
+
objcHeaders: [...result.objcHeaders.entries()],
|
|
21783
|
+
archived: [...archived.entries()]
|
|
21784
|
+
})
|
|
21785
|
+
);
|
|
21786
|
+
renameSync6(partialReceipt, receiptFile);
|
|
21787
|
+
return result;
|
|
21397
21788
|
}
|
|
21398
21789
|
var SWIFT_LINK_STAMP = ".peach-link-stamp";
|
|
21399
21790
|
var SWIFT_HOST_COMPILER_WRAPPER = ".peach-swiftc";
|
|
@@ -21402,14 +21793,14 @@ var SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS = 4;
|
|
|
21402
21793
|
var SWIFT_FRAMEWORK_SLOT_KEY = ".peach-framework-key";
|
|
21403
21794
|
var SWIFT_FRAMEWORK_SLOT_ORIGIN = ".peach-framework-origin";
|
|
21404
21795
|
function swiftFrameworksDir(unoptimized = false) {
|
|
21405
|
-
return
|
|
21796
|
+
return path33.join(
|
|
21406
21797
|
swiftCacheDir(),
|
|
21407
21798
|
unoptimized ? "swift-frameworks-unoptimized" : "swift-frameworks"
|
|
21408
21799
|
);
|
|
21409
21800
|
}
|
|
21410
21801
|
function swiftFrameworkSlotRecord(slot, record) {
|
|
21411
21802
|
try {
|
|
21412
|
-
return readFileSync16(
|
|
21803
|
+
return readFileSync16(path33.join(slot, record), "utf8").trim();
|
|
21413
21804
|
} catch (error) {
|
|
21414
21805
|
if (!vanished(error)) throw error;
|
|
21415
21806
|
return null;
|
|
@@ -21422,7 +21813,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
|
|
|
21422
21813
|
const slotCount = unoptimized ? SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS : SWIFT_FRAMEWORK_SLOTS;
|
|
21423
21814
|
const slotsDir = swiftFrameworksDir(unoptimized);
|
|
21424
21815
|
const slots = Array.from({ length: slotCount }, (_, index) => {
|
|
21425
|
-
const slot =
|
|
21816
|
+
const slot = path33.join(slotsDir, `slot-${index}`);
|
|
21426
21817
|
mkdirSync8(slot, { recursive: true });
|
|
21427
21818
|
return slot;
|
|
21428
21819
|
});
|
|
@@ -21438,16 +21829,18 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
|
|
|
21438
21829
|
const inputs = new Map(
|
|
21439
21830
|
swiftModuleInputFiles(moduleRoot).map((file) => [
|
|
21440
21831
|
file,
|
|
21441
|
-
readFileSync16(
|
|
21832
|
+
readFileSync16(path33.join(moduleRoot, file))
|
|
21442
21833
|
])
|
|
21443
21834
|
);
|
|
21444
21835
|
const ranked = slots.map((slot) => {
|
|
21445
21836
|
let changes = 0;
|
|
21446
21837
|
if (swiftFrameworkSlotKey(slot) === null) return { slot, changes: Infinity };
|
|
21447
|
-
const source =
|
|
21838
|
+
const source = path33.join(slot, "source", "packages", path33.basename(moduleRoot));
|
|
21448
21839
|
for (const [file, contents2] of inputs) {
|
|
21449
21840
|
try {
|
|
21450
|
-
|
|
21841
|
+
const candidate = path33.join(source, file);
|
|
21842
|
+
if (statSync4(candidate).size !== contents2.length || !readFileSync16(candidate).equals(contents2))
|
|
21843
|
+
changes++;
|
|
21451
21844
|
} catch (error) {
|
|
21452
21845
|
if (!vanished(error)) throw error;
|
|
21453
21846
|
changes++;
|
|
@@ -21458,11 +21851,13 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
|
|
|
21458
21851
|
(left, right) => left.changes - right.changes || Number(own(right.slot)) - Number(own(left.slot)) || (built.get(right.slot) ?? 0) - (built.get(left.slot) ?? 0)
|
|
21459
21852
|
);
|
|
21460
21853
|
for (const { slot, changes } of ranked) {
|
|
21854
|
+
if (await hasLiveSwiftRootReaders(slot, signal)) continue;
|
|
21461
21855
|
const result = await withSwiftRootLock(
|
|
21462
21856
|
slot,
|
|
21463
21857
|
async (lease) => {
|
|
21858
|
+
if (await hasLiveSwiftRootReaders(slot, signal)) return void 0;
|
|
21464
21859
|
console.error(
|
|
21465
|
-
`[swift-framework-cache] ${
|
|
21860
|
+
`[swift-framework-cache] ${path33.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`
|
|
21466
21861
|
);
|
|
21467
21862
|
return { value: await run2(slot)(lease) };
|
|
21468
21863
|
},
|
|
@@ -21481,8 +21876,8 @@ function mirrorTree2(source, target, skip) {
|
|
|
21481
21876
|
for (const entry of readdirSync6(source, { withFileTypes: true })) {
|
|
21482
21877
|
if (entry.name === skip) continue;
|
|
21483
21878
|
wanted.add(entry.name);
|
|
21484
|
-
const from =
|
|
21485
|
-
const to =
|
|
21879
|
+
const from = path33.join(source, entry.name);
|
|
21880
|
+
const to = path33.join(target, entry.name);
|
|
21486
21881
|
let existing = null;
|
|
21487
21882
|
try {
|
|
21488
21883
|
existing = lstatSync(to);
|
|
@@ -21511,47 +21906,49 @@ function mirrorTree2(source, target, skip) {
|
|
|
21511
21906
|
}
|
|
21512
21907
|
for (const name of readdirSync6(target))
|
|
21513
21908
|
if (!wanted.has(name) && name !== skip) {
|
|
21514
|
-
rmSync7(
|
|
21909
|
+
rmSync7(path33.join(target, name), { recursive: true, force: true });
|
|
21515
21910
|
restructured = true;
|
|
21516
21911
|
}
|
|
21517
21912
|
return restructured;
|
|
21518
21913
|
}
|
|
21519
21914
|
function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
21520
21915
|
if (!slot) return moduleRoot;
|
|
21521
|
-
const staged =
|
|
21522
|
-
const stagedModule =
|
|
21916
|
+
const staged = path33.join(slot, "source");
|
|
21917
|
+
const stagedModule = path33.join(staged, "packages", path33.basename(moduleRoot));
|
|
21523
21918
|
const hadKey = swiftFrameworkSlotKey(slot);
|
|
21524
21919
|
if (hadKey !== frameworkKey) {
|
|
21525
|
-
rmSync7(
|
|
21920
|
+
rmSync7(path33.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
|
|
21921
|
+
rmSync7(path33.join(slot, "products-ready"), { recursive: true, force: true });
|
|
21922
|
+
rmSync7(path33.join(slot, "lib", ".receipt"), { force: true });
|
|
21526
21923
|
const moduleRestructured = mirrorTree2(moduleRoot, stagedModule, ".build");
|
|
21527
21924
|
const sdkRestructured = mirrorTree2(
|
|
21528
21925
|
swiftSharedSdkRoot(moduleRoot, false),
|
|
21529
|
-
|
|
21926
|
+
path33.join(staged, "packages/peachsim/sdk/ios")
|
|
21530
21927
|
);
|
|
21531
21928
|
if (moduleRestructured || sdkRestructured || hadKey === null) {
|
|
21532
|
-
rmSync7(
|
|
21533
|
-
rmSync7(
|
|
21929
|
+
rmSync7(path33.join(slot, "release.yaml"), { force: true });
|
|
21930
|
+
rmSync7(path33.join(slot, WASM_TRIPLE, "release", "description.json"), {
|
|
21534
21931
|
force: true
|
|
21535
21932
|
});
|
|
21536
21933
|
}
|
|
21537
21934
|
for (const file of swiftModuleInputFiles(moduleRoot)) {
|
|
21538
21935
|
if (!file.startsWith("../")) continue;
|
|
21539
|
-
const from =
|
|
21540
|
-
const to =
|
|
21541
|
-
if (
|
|
21542
|
-
mkdirSync8(
|
|
21936
|
+
const from = path33.resolve(moduleRoot, file);
|
|
21937
|
+
const to = path33.resolve(stagedModule, file);
|
|
21938
|
+
if (existsSync10(to) && readFileSync16(from).equals(readFileSync16(to))) continue;
|
|
21939
|
+
mkdirSync8(path33.dirname(to), { recursive: true });
|
|
21543
21940
|
copyFileSync2(from, to);
|
|
21544
21941
|
}
|
|
21545
21942
|
if (swiftProjectBuildKey(stagedModule, release) !== frameworkKey)
|
|
21546
21943
|
throw new Error("Swift staged framework source differs from the caller");
|
|
21547
|
-
const modules =
|
|
21548
|
-
const target = realpathSync6(
|
|
21549
|
-
if (!
|
|
21944
|
+
const modules = path33.join(staged, "node_modules");
|
|
21945
|
+
const target = realpathSync6(path33.join(moduleRoot, "../../node_modules"));
|
|
21946
|
+
if (!existsSync10(modules) || readlinkSync(modules) !== target) {
|
|
21550
21947
|
rmSync7(modules, { recursive: true, force: true });
|
|
21551
21948
|
symlinkSync2(target, modules);
|
|
21552
21949
|
}
|
|
21553
|
-
writeFileSync8(
|
|
21554
|
-
writeFileSync8(
|
|
21950
|
+
writeFileSync8(path33.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
|
|
21951
|
+
writeFileSync8(path33.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
|
|
21555
21952
|
}
|
|
21556
21953
|
return stagedModule;
|
|
21557
21954
|
}
|
|
@@ -21591,7 +21988,7 @@ ${args.prebuilt.modules}
|
|
|
21591
21988
|
`);
|
|
21592
21989
|
for (const entry of readdirSync6(args.prebuilt.modules).sort())
|
|
21593
21990
|
hash.update(`${entry}
|
|
21594
|
-
${statOf(
|
|
21991
|
+
${statOf(path33.join(args.prebuilt.modules, entry))}`);
|
|
21595
21992
|
return hash.digest("hex");
|
|
21596
21993
|
}
|
|
21597
21994
|
function retireSwiftLinkTargets(retired) {
|
|
@@ -21600,13 +21997,13 @@ function retireSwiftLinkTargets(retired) {
|
|
|
21600
21997
|
"peach-product-checkpoints",
|
|
21601
21998
|
"peach-swift-header-checkpoints"
|
|
21602
21999
|
]) {
|
|
21603
|
-
rmSync7(
|
|
22000
|
+
rmSync7(path33.join(retired, name), { recursive: true, force: true });
|
|
21604
22001
|
}
|
|
21605
|
-
const releaseLink =
|
|
21606
|
-
if (!
|
|
22002
|
+
const releaseLink = path33.join(retired, "release");
|
|
22003
|
+
if (!existsSync10(releaseLink)) return;
|
|
21607
22004
|
const releaseDir = realpathSync6(releaseLink);
|
|
21608
22005
|
for (const entry of readdirSync6(releaseDir, { withFileTypes: true })) {
|
|
21609
|
-
const targetPath =
|
|
22006
|
+
const targetPath = path33.join(releaseDir, entry.name);
|
|
21610
22007
|
if (entry.name === "ModuleCache" || entry.name === "Modules" || entry.name.endsWith(".product") || entry.name.endsWith(".wasm")) {
|
|
21611
22008
|
rmSync7(targetPath, { recursive: true, force: true });
|
|
21612
22009
|
continue;
|
|
@@ -21619,7 +22016,7 @@ function retireSwiftLinkTargets(retired) {
|
|
|
21619
22016
|
}
|
|
21620
22017
|
}
|
|
21621
22018
|
function retireStaleSwiftLink(root, baseStamp, stamp, preserveClangObjects = false) {
|
|
21622
|
-
const receipt =
|
|
22019
|
+
const receipt = path33.join(root, SWIFT_LINK_STAMP);
|
|
21623
22020
|
let previous = null;
|
|
21624
22021
|
try {
|
|
21625
22022
|
previous = readFileSync16(receipt, "utf8").trim();
|
|
@@ -21631,8 +22028,8 @@ function retireStaleSwiftLink(root, baseStamp, stamp, preserveClangObjects = fal
|
|
|
21631
22028
|
${stamp}`;
|
|
21632
22029
|
writeFileSync8(receipt, `${combined}
|
|
21633
22030
|
`);
|
|
21634
|
-
const retired =
|
|
21635
|
-
if (previous === combined || !
|
|
22031
|
+
const retired = path33.join(root, ".build");
|
|
22032
|
+
if (previous === combined || !existsSync10(retired)) return false;
|
|
21636
22033
|
const [previousBase] = previous?.split("\n") ?? [];
|
|
21637
22034
|
if (preserveClangObjects && previousBase === baseStamp) {
|
|
21638
22035
|
retireSwiftLinkTargets(retired);
|
|
@@ -21657,11 +22054,11 @@ async function compileSwiftProjectOnce(sources, options) {
|
|
|
21657
22054
|
mkdirSync8(options.buildRoot, { recursive: true });
|
|
21658
22055
|
const root = realpathSync6(options.buildRoot);
|
|
21659
22056
|
refreshSwiftCacheHold(root);
|
|
21660
|
-
const moduleRoot =
|
|
22057
|
+
const moduleRoot = path33.resolve(options.moduleRoot);
|
|
21661
22058
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
21662
22059
|
const mirrorDistribution = options.linkOnly || options.project ? null : distribution;
|
|
21663
22060
|
if (distribution) refreshSwiftCacheHold(moduleRoot);
|
|
21664
|
-
const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-
|
|
22061
|
+
const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-3BPDQVA7.mjs")).useSwiftPackagePrebuilts(
|
|
21665
22062
|
sources,
|
|
21666
22063
|
moduleRoot,
|
|
21667
22064
|
options.toolchainBin
|
|
@@ -21671,11 +22068,11 @@ async function compileSwiftProjectOnce(sources, options) {
|
|
|
21671
22068
|
throw new Error("swift-compile: link-only builds do not support guest image graphs");
|
|
21672
22069
|
const layout2 = {
|
|
21673
22070
|
root,
|
|
21674
|
-
sources:
|
|
22071
|
+
sources: path33.join(root, "Sources", "App"),
|
|
21675
22072
|
multi: compileTargets(input).length > 0
|
|
21676
22073
|
};
|
|
21677
22074
|
const sdkModule = options.sdkModule && !options.linkOnly;
|
|
21678
|
-
const sdkImage = sdkModule ? await (await import("./swift-sdk-image-
|
|
22075
|
+
const sdkImage = sdkModule ? await (await import("./swift-sdk-image-EJD5TPQH.mjs")).buildSwiftSdkImage(
|
|
21679
22076
|
moduleRoot,
|
|
21680
22077
|
!!guestGraph,
|
|
21681
22078
|
distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
|
|
@@ -21687,7 +22084,7 @@ async function compileSwiftProjectOnce(sources, options) {
|
|
|
21687
22084
|
const hash = sdkImage ? createHash18("sha256").update(`${sourceHash}
|
|
21688
22085
|
sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
|
|
21689
22086
|
const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
|
|
21690
|
-
const sharedRoot =
|
|
22087
|
+
const sharedRoot = path33.join(swiftCacheDir(), "swift-projects", hash);
|
|
21691
22088
|
const report = (message) => {
|
|
21692
22089
|
console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
|
|
21693
22090
|
options.onStage?.(message);
|
|
@@ -21702,8 +22099,8 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
|
|
|
21702
22099
|
report("reusing memory artifact");
|
|
21703
22100
|
return retain(root, retained);
|
|
21704
22101
|
}
|
|
21705
|
-
const cached = readCompiledArtifact(
|
|
21706
|
-
const previous = cached ?? (options.project ? null : readCompiledArtifact(
|
|
22102
|
+
const cached = readCompiledArtifact(path33.join(sharedRoot, "artifact"), hash);
|
|
22103
|
+
const previous = cached ?? (options.project ? null : readCompiledArtifact(path33.join(root, "artifact"), hash));
|
|
21707
22104
|
if (previous) {
|
|
21708
22105
|
if (cached) renewSharedArtifact(sharedRoot);
|
|
21709
22106
|
else saveSharedArtifact(sharedRoot, previous);
|
|
@@ -21713,8 +22110,8 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
|
|
|
21713
22110
|
}
|
|
21714
22111
|
if (!options.intermediates && !sdkImage && process.platform === "darwin" && process.env.TM_SESSION && !windowAdmission() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
|
|
21715
22112
|
const requestRoot = mkdtempSync4(`${root}.builder-request-`);
|
|
21716
|
-
const output =
|
|
21717
|
-
const request =
|
|
22113
|
+
const output = path33.join(requestRoot, "output");
|
|
22114
|
+
const request = path33.join(requestRoot, "request.json");
|
|
21718
22115
|
writeFileSync8(
|
|
21719
22116
|
request,
|
|
21720
22117
|
JSON.stringify({
|
|
@@ -21728,13 +22125,13 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
|
|
|
21728
22125
|
})
|
|
21729
22126
|
);
|
|
21730
22127
|
try {
|
|
21731
|
-
const repo =
|
|
22128
|
+
const repo = path33.resolve(moduleRoot, "../..");
|
|
21732
22129
|
const timeout = swiftBuilderHopTimeoutMs(options.timeoutMs);
|
|
21733
22130
|
report("requesting builder admission or cached result");
|
|
21734
22131
|
await runCompiler(
|
|
21735
22132
|
"bun",
|
|
21736
22133
|
[
|
|
21737
|
-
|
|
22134
|
+
path33.join(repo, "scripts/build/swift-project.ts"),
|
|
21738
22135
|
"--request",
|
|
21739
22136
|
request,
|
|
21740
22137
|
"--output",
|
|
@@ -21784,14 +22181,14 @@ ${cap}` : "";
|
|
|
21784
22181
|
root,
|
|
21785
22182
|
async (lease) => {
|
|
21786
22183
|
if (!options.intermediates) {
|
|
21787
|
-
const built = readCompiledArtifact(
|
|
22184
|
+
const built = readCompiledArtifact(path33.join(sharedRoot, "artifact"), hash);
|
|
21788
22185
|
if (built) {
|
|
21789
22186
|
report("reusing verified disk artifact");
|
|
21790
22187
|
return retain(root, built);
|
|
21791
22188
|
}
|
|
21792
22189
|
}
|
|
21793
|
-
const swift =
|
|
21794
|
-
if (!
|
|
22190
|
+
const swift = path33.join(options.toolchainBin, "swift");
|
|
22191
|
+
if (!existsSync10(swift)) {
|
|
21795
22192
|
throw new Error(
|
|
21796
22193
|
`swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
|
|
21797
22194
|
);
|
|
@@ -21804,54 +22201,82 @@ ${cap}` : "";
|
|
|
21804
22201
|
work,
|
|
21805
22202
|
unoptimized
|
|
21806
22203
|
);
|
|
21807
|
-
|
|
22204
|
+
const baseBuildEnv = {
|
|
22205
|
+
...options.project?.env ?? process.env,
|
|
22206
|
+
// shipped host plugins resolve against the selected compiler's runtime.
|
|
22207
|
+
...process.platform === "linux" ? {
|
|
22208
|
+
LD_LIBRARY_PATH: [
|
|
22209
|
+
path33.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
22210
|
+
path33.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
22211
|
+
process.env.LD_LIBRARY_PATH
|
|
22212
|
+
].filter(Boolean).join(":")
|
|
22213
|
+
} : {},
|
|
22214
|
+
PEACH_DEFER_WASM_LINK: "1"
|
|
22215
|
+
};
|
|
22216
|
+
const {
|
|
22217
|
+
frameworkRoot,
|
|
22218
|
+
compileFrameworkRoot,
|
|
22219
|
+
macroPlugins,
|
|
22220
|
+
sdk,
|
|
22221
|
+
icu,
|
|
22222
|
+
prebuilt,
|
|
22223
|
+
readHold
|
|
22224
|
+
} = await withFrameworkLock(async (slot, frameworkLease) => {
|
|
21808
22225
|
budget.startCompile();
|
|
21809
|
-
|
|
21810
|
-
|
|
22226
|
+
if (slot && swiftFrameworkSlotKey(slot) !== frameworkKey)
|
|
22227
|
+
await waitForNoSwiftRootReaders(slot, budget.signal);
|
|
22228
|
+
const frameworkRoot2 = mirrorDistribution ? syncSwiftDistributionMirror(root, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(moduleRoot, slot, frameworkKey, options.release);
|
|
22229
|
+
if (!swiftModuleDigest(frameworkRoot2).equals(moduleDigest))
|
|
21811
22230
|
throw new Error("Swift staged project source differs from the caller");
|
|
21812
22231
|
report("preparing compiler plugins");
|
|
21813
|
-
const
|
|
21814
|
-
|
|
22232
|
+
const macroPlugins2 = await ensureMacroPlugins(
|
|
22233
|
+
frameworkRoot2,
|
|
21815
22234
|
options.toolchainBin,
|
|
21816
22235
|
options.release,
|
|
21817
22236
|
budget.signal,
|
|
21818
22237
|
frameworkLease
|
|
21819
22238
|
);
|
|
21820
|
-
const
|
|
21821
|
-
const
|
|
21822
|
-
const
|
|
21823
|
-
|
|
21824
|
-
env: {
|
|
21825
|
-
...options.project?.env ?? process.env,
|
|
21826
|
-
// shipped host plugins resolve against the selected compiler's runtime.
|
|
21827
|
-
...process.platform === "linux" ? {
|
|
21828
|
-
LD_LIBRARY_PATH: [
|
|
21829
|
-
path32.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
21830
|
-
path32.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
21831
|
-
process.env.LD_LIBRARY_PATH
|
|
21832
|
-
].filter(Boolean).join(":")
|
|
21833
|
-
} : {},
|
|
21834
|
-
PEACH_DEFER_WASM_LINK: "1"
|
|
21835
|
-
},
|
|
21836
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
21837
|
-
signal: budget.signal,
|
|
21838
|
-
lease,
|
|
21839
|
-
frameworkLease
|
|
21840
|
-
};
|
|
21841
|
-
let prebuilt;
|
|
22239
|
+
const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
|
|
22240
|
+
const sdk2 = swiftModuleSdk(frameworkRoot2).wasmSdkId;
|
|
22241
|
+
const icu2 = options.linkOnly ? null : swiftIcuAsset(options.toolchainBin, sdk2);
|
|
22242
|
+
let prebuilt2;
|
|
21842
22243
|
if (!distribution) {
|
|
21843
22244
|
report("compiling framework products");
|
|
21844
|
-
|
|
21845
|
-
moduleRoot:
|
|
22245
|
+
prebuilt2 = await buildFrameworkProducts(slot, {
|
|
22246
|
+
moduleRoot: frameworkRoot2,
|
|
21846
22247
|
frameworkKey,
|
|
21847
22248
|
input,
|
|
21848
22249
|
swift,
|
|
21849
|
-
sdk,
|
|
22250
|
+
sdk: sdk2,
|
|
21850
22251
|
toolchainBin: options.toolchainBin,
|
|
21851
|
-
plugins:
|
|
21852
|
-
buildOptions
|
|
22252
|
+
plugins: macroPlugins2,
|
|
22253
|
+
buildOptions: {
|
|
22254
|
+
env: baseBuildEnv,
|
|
22255
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
22256
|
+
signal: budget.signal,
|
|
22257
|
+
lease,
|
|
22258
|
+
frameworkLease
|
|
22259
|
+
}
|
|
21853
22260
|
});
|
|
21854
22261
|
}
|
|
22262
|
+
const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
|
|
22263
|
+
return {
|
|
22264
|
+
frameworkRoot: frameworkRoot2,
|
|
22265
|
+
compileFrameworkRoot: compileFrameworkRoot2,
|
|
22266
|
+
macroPlugins: macroPlugins2,
|
|
22267
|
+
sdk: sdk2,
|
|
22268
|
+
icu: icu2,
|
|
22269
|
+
prebuilt: prebuilt2,
|
|
22270
|
+
readHold: readHold2
|
|
22271
|
+
};
|
|
22272
|
+
});
|
|
22273
|
+
const buildOptions = {
|
|
22274
|
+
env: baseBuildEnv,
|
|
22275
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
22276
|
+
signal: budget.signal,
|
|
22277
|
+
lease
|
|
22278
|
+
};
|
|
22279
|
+
try {
|
|
21855
22280
|
if (options.project) removeProjectLinks(root);
|
|
21856
22281
|
const packageHostMacros = process.platform === "linux" ? input.packageHostMacros : void 0;
|
|
21857
22282
|
if (retireStaleSwiftLink(
|
|
@@ -21879,20 +22304,20 @@ ${cap}` : "";
|
|
|
21879
22304
|
!options.project,
|
|
21880
22305
|
options.project ? false : options.objcPrebuiltStage ?? (options.intermediates ? false : void 0)
|
|
21881
22306
|
);
|
|
21882
|
-
const productFile =
|
|
22307
|
+
const productFile = path33.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
|
|
21883
22308
|
writeSwiftAutolinkLinker(
|
|
21884
22309
|
root,
|
|
21885
22310
|
options.toolchainBin,
|
|
21886
|
-
|
|
22311
|
+
existsSync10(productFile) ? [
|
|
21887
22312
|
parse(
|
|
21888
22313
|
swiftFrameworkProductSchema,
|
|
21889
22314
|
JSON.parse(readFileSync16(productFile, "utf8"))
|
|
21890
22315
|
).product.name
|
|
21891
22316
|
] : []
|
|
21892
22317
|
);
|
|
21893
|
-
const compiler = preparation.targetToolset ? { CC:
|
|
22318
|
+
const compiler = preparation.targetToolset ? { CC: path33.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
|
|
21894
22319
|
if (packageHostMacros?.length) {
|
|
21895
|
-
const swiftc =
|
|
22320
|
+
const swiftc = path33.join(root, SWIFT_HOST_COMPILER_WRAPPER);
|
|
21896
22321
|
writeBuildFile(
|
|
21897
22322
|
swiftc,
|
|
21898
22323
|
[
|
|
@@ -21919,10 +22344,10 @@ ${cap}` : "";
|
|
|
21919
22344
|
chmodSync3(swiftc, 493);
|
|
21920
22345
|
compiler.SWIFT_EXEC = swiftc;
|
|
21921
22346
|
compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
|
|
21922
|
-
compiler.PEACH_SWIFTC =
|
|
22347
|
+
compiler.PEACH_SWIFTC = path33.join(options.toolchainBin, "swiftc");
|
|
21923
22348
|
}
|
|
21924
22349
|
const projectProcess = options.project ? prepareSwiftProjectProcess(root, options.project) : void 0;
|
|
21925
|
-
const temporaryDirectory = projectProcess ? void 0 :
|
|
22350
|
+
const temporaryDirectory = projectProcess ? void 0 : path33.join(root, ".build", "peach-compiler-tmp");
|
|
21926
22351
|
const appOptions = projectProcess ? {
|
|
21927
22352
|
...buildOptions,
|
|
21928
22353
|
uid: projectProcess.uid,
|
|
@@ -21940,10 +22365,10 @@ ${cap}` : "";
|
|
|
21940
22365
|
for (const [file, text2] of Object.entries(input.files)) {
|
|
21941
22366
|
const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text2)?.[1];
|
|
21942
22367
|
if (!parents) continue;
|
|
21943
|
-
const directory =
|
|
22368
|
+
const directory = path33.posix.dirname(file);
|
|
21944
22369
|
forwarders.set(
|
|
21945
|
-
`${
|
|
21946
|
-
|
|
22370
|
+
`${path33.join(root, directory)}/${parents.slice(0, -1)}`,
|
|
22371
|
+
path33.posix.join("build", directory, parents).replace(/\/$/, "")
|
|
21947
22372
|
);
|
|
21948
22373
|
}
|
|
21949
22374
|
const jobs = swiftCompilerJobs();
|
|
@@ -21962,7 +22387,7 @@ ${cap}` : "";
|
|
|
21962
22387
|
...swiftObjCSelectorOptions(frameworkRoot),
|
|
21963
22388
|
"--swift-sdk",
|
|
21964
22389
|
sdk,
|
|
21965
|
-
...preparation.targetToolset ? ["--toolset",
|
|
22390
|
+
...preparation.targetToolset ? ["--toolset", path33.join(root, ".peach-target-toolset.json")] : [],
|
|
21966
22391
|
"-c",
|
|
21967
22392
|
"release",
|
|
21968
22393
|
...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
|
|
@@ -21981,19 +22406,16 @@ ${cap}` : "";
|
|
|
21981
22406
|
// the link strips debug info, so none is generated (as for the framework)
|
|
21982
22407
|
"-Xswiftc",
|
|
21983
22408
|
"-gnone",
|
|
21984
|
-
"-Xswiftc",
|
|
21985
|
-
"-num-threads",
|
|
21986
|
-
"-Xswiftc",
|
|
21987
|
-
String(perFile ? 1 : jobs),
|
|
22409
|
+
...incrementalPreview ? [] : ["-Xswiftc", "-num-threads", "-Xswiftc", String(perFile ? 1 : jobs)],
|
|
21988
22410
|
...swiftReproducibleBuildFlags([
|
|
21989
|
-
[
|
|
22411
|
+
[path33.dirname(options.toolchainBin), "toolchain"],
|
|
21990
22412
|
[compileFrameworkRoot, "framework"],
|
|
21991
22413
|
[root, "build"],
|
|
21992
22414
|
...forwarders
|
|
21993
22415
|
]).flatMap((flag, index, flags) => {
|
|
21994
22416
|
if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
|
|
21995
22417
|
return [flag];
|
|
21996
|
-
const toolchainDir =
|
|
22418
|
+
const toolchainDir = path33.dirname(options.toolchainBin);
|
|
21997
22419
|
let mapped = flag;
|
|
21998
22420
|
for (const [dir, target] of [
|
|
21999
22421
|
[root, "/peach/build"],
|
|
@@ -22022,12 +22444,12 @@ ${cap}` : "";
|
|
|
22022
22444
|
])
|
|
22023
22445
|
];
|
|
22024
22446
|
const linked = builtArtifact(layout2);
|
|
22025
|
-
rmSync7(
|
|
22026
|
-
if (options.linkOnly ||
|
|
22447
|
+
rmSync7(path33.join(root, ".peach-link.rsp"), { force: true });
|
|
22448
|
+
if (options.linkOnly || existsSync10(linked) && statSync4(linked).size <= 8)
|
|
22027
22449
|
rmSync7(linked, { force: true });
|
|
22028
22450
|
report("compiling and linking Swift modules");
|
|
22029
22451
|
const frameworkInterfaces = /* @__PURE__ */ new Map();
|
|
22030
|
-
const sdkFrameworks =
|
|
22452
|
+
const sdkFrameworks = path33.join(
|
|
22031
22453
|
swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
|
|
22032
22454
|
"System/Library/Frameworks"
|
|
22033
22455
|
);
|
|
@@ -22042,39 +22464,39 @@ ${cap}` : "";
|
|
|
22042
22464
|
const name = moduleMapName(contents2);
|
|
22043
22465
|
const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
|
|
22044
22466
|
if (!name || !umbrella) continue;
|
|
22045
|
-
const header = input.files[
|
|
22467
|
+
const header = input.files[path33.posix.join(path33.posix.dirname(file), umbrella)];
|
|
22046
22468
|
if (header === void 0) continue;
|
|
22047
22469
|
const included = new Set(
|
|
22048
22470
|
[
|
|
22049
22471
|
...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
|
|
22050
|
-
].map((match) =>
|
|
22472
|
+
].map((match) => path33.posix.basename(match[1]))
|
|
22051
22473
|
);
|
|
22052
22474
|
const declarations = nativeDeclarations.get(name) ?? /* @__PURE__ */ new Set();
|
|
22053
22475
|
for (const declaration of swiftInterfaceDeclarations(header))
|
|
22054
22476
|
declarations.add(declaration);
|
|
22055
22477
|
for (const [candidate, source] of Object.entries(input.files))
|
|
22056
|
-
if (included.has(
|
|
22478
|
+
if (included.has(path33.posix.basename(candidate)))
|
|
22057
22479
|
for (const declaration of swiftInterfaceDeclarations(source))
|
|
22058
22480
|
declarations.add(declaration);
|
|
22059
22481
|
nativeDeclarations.set(name, declarations);
|
|
22060
22482
|
}
|
|
22061
22483
|
const frameworkInterface = (name) => {
|
|
22062
22484
|
if (frameworkInterfaces.has(name)) return frameworkInterfaces.get(name);
|
|
22063
|
-
const source = distribution ?
|
|
22064
|
-
if (!source || !
|
|
22485
|
+
const source = distribution ? path33.join(frameworkRoot, "modules", `${name}-Swift.h`) : prebuilt.objcHeaders.get(name);
|
|
22486
|
+
if (!source || !existsSync10(source)) {
|
|
22065
22487
|
frameworkInterfaces.set(name, null);
|
|
22066
22488
|
return null;
|
|
22067
22489
|
}
|
|
22068
|
-
const headers =
|
|
22490
|
+
const headers = path33.join(sdkFrameworks, `${name}.framework/Headers`);
|
|
22069
22491
|
const declared = /* @__PURE__ */ new Set();
|
|
22070
|
-
if (
|
|
22492
|
+
if (existsSync10(headers)) {
|
|
22071
22493
|
for (const file of readdirSync6(headers, {
|
|
22072
22494
|
recursive: true,
|
|
22073
22495
|
encoding: "utf8"
|
|
22074
22496
|
}))
|
|
22075
22497
|
if (file.endsWith(".h"))
|
|
22076
22498
|
for (const name2 of swiftInterfaceDeclarations(
|
|
22077
|
-
readFileSync16(
|
|
22499
|
+
readFileSync16(path33.join(headers, file), "utf8")
|
|
22078
22500
|
))
|
|
22079
22501
|
declared.add(name2);
|
|
22080
22502
|
}
|
|
@@ -22103,20 +22525,20 @@ ${cap}` : "";
|
|
|
22103
22525
|
[...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
|
|
22104
22526
|
) : own;
|
|
22105
22527
|
const value = {
|
|
22106
|
-
file:
|
|
22528
|
+
file: path33.join(root, ".build/peach-framework-objc", `${name}-Swift.h`),
|
|
22107
22529
|
header,
|
|
22108
|
-
module:
|
|
22530
|
+
module: existsSync10(headers)
|
|
22109
22531
|
};
|
|
22110
22532
|
frameworkInterfaces.set(name, value);
|
|
22111
22533
|
writeBuildFile(
|
|
22112
22534
|
value.file,
|
|
22113
|
-
(
|
|
22535
|
+
(existsSync10(path33.join(headers, `${name}.h`)) ? `#import <${name}/${name}.h>
|
|
22114
22536
|
` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
|
|
22115
22537
|
);
|
|
22116
22538
|
return value;
|
|
22117
22539
|
};
|
|
22118
22540
|
const headerPaths = (producer) => {
|
|
22119
|
-
const stem =
|
|
22541
|
+
const stem = path33.join(
|
|
22120
22542
|
root,
|
|
22121
22543
|
".build",
|
|
22122
22544
|
"peach-cxx-headers",
|
|
@@ -22144,7 +22566,7 @@ ${cap}` : "";
|
|
|
22144
22566
|
};
|
|
22145
22567
|
const recipe = inputHash.copy().update(
|
|
22146
22568
|
distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
|
|
22147
|
-
).update(readFileSync16(
|
|
22569
|
+
).update(readFileSync16(path33.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
|
|
22148
22570
|
const runApp = async (compiler2) => {
|
|
22149
22571
|
const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
|
|
22150
22572
|
const stages = [
|
|
@@ -22158,33 +22580,33 @@ ${cap}` : "";
|
|
|
22158
22580
|
producers: []
|
|
22159
22581
|
}))
|
|
22160
22582
|
];
|
|
22161
|
-
const checkpoints =
|
|
22583
|
+
const checkpoints = path33.join(root, ".build", "peach-product-checkpoints");
|
|
22162
22584
|
for (const { target, producers } of stages) {
|
|
22163
|
-
const receipt =
|
|
22585
|
+
const receipt = path33.join(
|
|
22164
22586
|
checkpoints,
|
|
22165
22587
|
createHash18("sha256").update(target).digest("hex")
|
|
22166
22588
|
);
|
|
22167
22589
|
const headers = producers.map(headerPaths);
|
|
22168
22590
|
for (const header of headers)
|
|
22169
|
-
if (
|
|
22591
|
+
if (existsSync10(header.original)) publishHeader(header);
|
|
22170
22592
|
const fingerprint = () => {
|
|
22171
22593
|
const digest = createHash18("sha256").update(recipe);
|
|
22172
22594
|
for (const { original, emitted } of headers) {
|
|
22173
|
-
if (!
|
|
22595
|
+
if (!existsSync10(original) || !existsSync10(emitted)) return;
|
|
22174
22596
|
digest.update(
|
|
22175
22597
|
createHash18("sha256").update(readFileSync16(emitted)).digest()
|
|
22176
22598
|
);
|
|
22177
22599
|
}
|
|
22178
22600
|
return digest.digest("hex");
|
|
22179
22601
|
};
|
|
22180
|
-
if (!options.project &&
|
|
22602
|
+
if (!options.project && existsSync10(receipt) && readFileSync16(receipt, "utf8") === fingerprint())
|
|
22181
22603
|
continue;
|
|
22182
22604
|
if (!options.project) rmSync7(receipt, { force: true });
|
|
22183
22605
|
for (const header of headers) {
|
|
22184
|
-
if (!
|
|
22606
|
+
if (!existsSync10(header.original))
|
|
22185
22607
|
rmSync7(
|
|
22186
|
-
|
|
22187
|
-
|
|
22608
|
+
path33.join(
|
|
22609
|
+
path33.dirname(linked),
|
|
22188
22610
|
"Modules",
|
|
22189
22611
|
`${swiftTargetModuleName(header.producer)}.swiftmodule`
|
|
22190
22612
|
),
|
|
@@ -22239,14 +22661,14 @@ ${cap}` : "";
|
|
|
22239
22661
|
await compileApp();
|
|
22240
22662
|
} catch (error) {
|
|
22241
22663
|
const output2 = outputOf(error);
|
|
22242
|
-
const moduleCache =
|
|
22664
|
+
const moduleCache = path33.join(
|
|
22243
22665
|
root,
|
|
22244
22666
|
".build",
|
|
22245
22667
|
WASM_TRIPLE,
|
|
22246
22668
|
"release",
|
|
22247
22669
|
"ModuleCache"
|
|
22248
22670
|
);
|
|
22249
|
-
if (output2.includes("was compiled with module cache path") &&
|
|
22671
|
+
if (output2.includes("was compiled with module cache path") && existsSync10(moduleCache)) {
|
|
22250
22672
|
rmSync7(moduleCache, { recursive: true, force: true });
|
|
22251
22673
|
try {
|
|
22252
22674
|
await compileApp();
|
|
@@ -22273,11 +22695,11 @@ ${cap}` : "";
|
|
|
22273
22695
|
if (options.project) endSwiftProjectProcesses(options.project);
|
|
22274
22696
|
}
|
|
22275
22697
|
if (unprepared.length) throw new Error(unprepared.join("\n"));
|
|
22276
|
-
if (!
|
|
22277
|
-
const binDir =
|
|
22278
|
-
const found =
|
|
22698
|
+
if (!existsSync10(linked)) {
|
|
22699
|
+
const binDir = path33.dirname(linked);
|
|
22700
|
+
const found = existsSync10(binDir) ? readdirSync6(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
|
|
22279
22701
|
throw new Error(
|
|
22280
|
-
`swift-compile: the build produced no ${
|
|
22702
|
+
`swift-compile: the build produced no ${path33.basename(linked)} (found: ${found.join(", ") || "none"})`
|
|
22281
22703
|
);
|
|
22282
22704
|
}
|
|
22283
22705
|
if (options.project) removeProjectLinks(root);
|
|
@@ -22308,10 +22730,10 @@ ${cap}` : "";
|
|
|
22308
22730
|
const binding = await compileGuestLink({
|
|
22309
22731
|
graph: guestGraph,
|
|
22310
22732
|
buildDirectory: root,
|
|
22311
|
-
releaseDirectory:
|
|
22733
|
+
releaseDirectory: path33.dirname(linked),
|
|
22312
22734
|
moduleRoot: frameworkRoot,
|
|
22313
22735
|
toolchainBin: options.toolchainBin,
|
|
22314
|
-
swiftCompiler: preparation.headerCompiler ?
|
|
22736
|
+
swiftCompiler: preparation.headerCompiler ? path33.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? path33.join(options.toolchainBin, "swiftc"),
|
|
22315
22737
|
sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
|
|
22316
22738
|
sdk: swiftModuleSdk(frameworkRoot),
|
|
22317
22739
|
sdkImage,
|
|
@@ -22332,7 +22754,7 @@ ${cap}` : "";
|
|
|
22332
22754
|
if (sdkImage && binding)
|
|
22333
22755
|
sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
|
|
22334
22756
|
} else if (sdkImage) {
|
|
22335
|
-
const { buildSwiftAppModule } = await import("./swift-sdk-app-module-
|
|
22757
|
+
const { buildSwiftAppModule } = await import("./swift-sdk-app-module-CRX6E3TR.mjs");
|
|
22336
22758
|
const binding = await buildSwiftAppModule({
|
|
22337
22759
|
buildRoot: root,
|
|
22338
22760
|
toolchainBin: options.toolchainBin,
|
|
@@ -22342,7 +22764,7 @@ ${cap}` : "";
|
|
|
22342
22764
|
project: options.project && {
|
|
22343
22765
|
...options.project,
|
|
22344
22766
|
env: { ...options.project.env, ...projectProcess?.env },
|
|
22345
|
-
sdkRoot:
|
|
22767
|
+
sdkRoot: path33.dirname(
|
|
22346
22768
|
swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot
|
|
22347
22769
|
),
|
|
22348
22770
|
linked: output
|
|
@@ -22357,7 +22779,7 @@ ${cap}` : "";
|
|
|
22357
22779
|
}
|
|
22358
22780
|
if (!sdkImage)
|
|
22359
22781
|
await runCompiler(
|
|
22360
|
-
|
|
22782
|
+
path33.join(options.toolchainBin, "llvm-objcopy"),
|
|
22361
22783
|
["--remove-section=.swift1_autolink_entries", optimized],
|
|
22362
22784
|
buildOptions
|
|
22363
22785
|
);
|
|
@@ -22373,7 +22795,9 @@ ${cap}` : "";
|
|
|
22373
22795
|
saveSharedArtifact(sharedRoot, artifact);
|
|
22374
22796
|
report("compiled artifact verified");
|
|
22375
22797
|
return retain(root, artifact);
|
|
22376
|
-
}
|
|
22798
|
+
} finally {
|
|
22799
|
+
readHold?.release();
|
|
22800
|
+
}
|
|
22377
22801
|
},
|
|
22378
22802
|
budget.signal
|
|
22379
22803
|
);
|