peachsim 0.1.2421 → 0.1.2423
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/command-agent.ts +14 -15
- package/cli/commands/box.ts +33 -28
- package/cli/commands/canvas.ts +54 -0
- package/cli/commands/platform.ts +28 -27
- package/cli/commands/preview.ts +2 -1
- package/cli/outbound-endpoints.ts +3 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +4318 -3937
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +22 -1
- package/dist-lib/cloud-contract.mjs +20 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +27 -13
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +3343 -2962
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +4200 -3819
- package/dist-lib/host/fetch-proxy-handler.cjs +25 -4
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +88 -53
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +25 -4
- package/dist-lib/native-app-identity-project.cjs +2 -2
- package/dist-lib/native-app-identity-project.mjs +231 -212
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +30 -25
- package/dist-lib/public-origins-lib.json +78 -56
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +4990 -4586
- package/dist-lib/swift-compile.cjs +1261 -889
- package/dist-lib/swift-compile.mjs +1231 -849
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +2712 -2348
- package/dist-lib/vite.cjs +25 -4
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/native-layout.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/ios/apps/canvas-map-data.d.ts +83 -2
- package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +2 -2
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +0 -10
- package/dist-types/packages/peach-engine/src/render-worker/compositor-runtime/layer-claims.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +9 -0
- package/dist-types/packages/peach-globals/src/canvasAgentContract.d.ts +8 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +4 -2
- package/dist-types/packages/peach-globals/src/replayBridgeContract.d.ts +12 -0
- package/dist-types/packages/peach-globals/src/sceneStreamBridgeContract.d.ts +5 -1
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/CoreData.apinotes +2 -0
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSPersistentStore.h +2 -0
- package/sdk/ios/wasm/include/errno.h +10 -0
- package/src/agent-daemon-client.ts +1 -1
- package/src/agent-prompt.ts +1 -8
- package/src/canvas-agent-note-delivery.ts +2 -5
- package/src/canvas-groups.ts +11 -3
- package/src/cloud-contract.ts +31 -1
- package/src/expo-kotlin-bundle.ts +1 -1
- package/src/native-static-libraries.ts +51 -4
- package/src/swift-compile.ts +184 -108
- package/src/swift-compiler-digest.ts +2 -0
- package/src/swift-guest-compile.ts +2 -0
- package/src/swift-guest-source-inputs.ts +2 -2
- package/src/swift-header-compiler.ts +185 -0
- package/src/swift-header-dependencies.ts +174 -0
- package/src/swift-objc-compile.ts +18 -24
- package/src/vite-plugin.ts +4 -1
- package/dist-types/packages/peach-engine/src/render-worker/accessibilityHostContract.d.ts +0 -65
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2423 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -8,28 +8,28 @@ import {
|
|
|
8
8
|
spawn as spawn5,
|
|
9
9
|
execFileSync as execFileSync12
|
|
10
10
|
} from "node:child_process";
|
|
11
|
-
import { createHash as
|
|
11
|
+
import { createHash as createHash15, randomUUID as randomUUID5 } from "node:crypto";
|
|
12
12
|
import {
|
|
13
|
-
chmodSync as
|
|
13
|
+
chmodSync as chmodSync3,
|
|
14
14
|
copyFileSync,
|
|
15
15
|
cpSync,
|
|
16
|
-
existsSync as
|
|
16
|
+
existsSync as existsSync7,
|
|
17
17
|
lstatSync,
|
|
18
|
-
mkdirSync as
|
|
19
|
-
mkdtempSync as
|
|
20
|
-
readFileSync as
|
|
18
|
+
mkdirSync as mkdirSync8,
|
|
19
|
+
mkdtempSync as mkdtempSync4,
|
|
20
|
+
readFileSync as readFileSync18,
|
|
21
21
|
readdirSync as readdirSync8,
|
|
22
22
|
readlinkSync,
|
|
23
23
|
realpathSync as realpathSync6,
|
|
24
|
-
renameSync as
|
|
25
|
-
rmSync as
|
|
26
|
-
statSync as
|
|
24
|
+
renameSync as renameSync3,
|
|
25
|
+
rmSync as rmSync8,
|
|
26
|
+
statSync as statSync3,
|
|
27
27
|
symlinkSync as symlinkSync2,
|
|
28
28
|
utimesSync,
|
|
29
|
-
writeFileSync as
|
|
29
|
+
writeFileSync as writeFileSync9
|
|
30
30
|
} from "node:fs";
|
|
31
31
|
import os5 from "node:os";
|
|
32
|
-
import
|
|
32
|
+
import path30 from "node:path";
|
|
33
33
|
import * as v5 from "valibot";
|
|
34
34
|
|
|
35
35
|
// src/admitted-mac-build.ts
|
|
@@ -3653,7 +3653,7 @@ function swiftManifestTargets(manifest, resourcePaths = [], readArguments) {
|
|
|
3653
3653
|
const targets = [];
|
|
3654
3654
|
const packageCall = manifestCalls(manifest, ["Package"])[0];
|
|
3655
3655
|
const platformArgument = packageCall ? splitManifestArguments(packageCall.call.slice(0, -1)).find(
|
|
3656
|
-
(
|
|
3656
|
+
(argument2) => /^platforms\s*:/.test(argument2)
|
|
3657
3657
|
) : void 0;
|
|
3658
3658
|
const platformList = /^platforms\s*:\s*\[([\s\S]*)\]$/.exec(platformArgument ?? "")?.[1];
|
|
3659
3659
|
const iosPlatforms = [
|
|
@@ -3694,7 +3694,7 @@ function swiftManifestTargets(manifest, resourcePaths = [], readArguments) {
|
|
|
3694
3694
|
);
|
|
3695
3695
|
const targetArguments = splitManifestArguments(call.slice(0, -1));
|
|
3696
3696
|
const sourceArgument = targetArguments.find(
|
|
3697
|
-
(
|
|
3697
|
+
(argument2) => /^sources\s*:/.test(argument2)
|
|
3698
3698
|
);
|
|
3699
3699
|
const sourceList = sourceArgument?.replace(/^sources\s*:\s*/, "").trim();
|
|
3700
3700
|
if (sourceList && sourceList !== "nil" && !(sourceList.startsWith("[") && sourceList.endsWith("]")))
|
|
@@ -3708,7 +3708,7 @@ function swiftManifestTargets(manifest, resourcePaths = [], readArguments) {
|
|
|
3708
3708
|
return swiftStringValue(literal2[1], `a source of target ${name2}`).replace(/^\.\//, "").replace(/\/+$/, "");
|
|
3709
3709
|
}) : void 0;
|
|
3710
3710
|
const dependencyArgument = targetArguments.find(
|
|
3711
|
-
(
|
|
3711
|
+
(argument2) => /^dependencies\s*:/.test(argument2)
|
|
3712
3712
|
);
|
|
3713
3713
|
const dependencyList = dependencyArgument?.replace(/^dependencies\s*:\s*/, "").trim();
|
|
3714
3714
|
const dependencies = [];
|
|
@@ -4685,9 +4685,9 @@ var EXCERPT = /^(\s*)(\d+)( \| )(.*)$/;
|
|
|
4685
4685
|
var MARKER = /^(\s*)( \| )(.*)$/;
|
|
4686
4686
|
function designTimeDiagnostic(output, files) {
|
|
4687
4687
|
const rewritten = /* @__PURE__ */ new Map();
|
|
4688
|
-
const linesOf = (
|
|
4688
|
+
const linesOf = (path31) => {
|
|
4689
4689
|
const file = Object.keys(files).find(
|
|
4690
|
-
(name2) => name2.endsWith(".swift") && (
|
|
4690
|
+
(name2) => name2.endsWith(".swift") && (path31 === name2 || path31.endsWith(`/${name2}`))
|
|
4691
4691
|
);
|
|
4692
4692
|
if (file === void 0) return null;
|
|
4693
4693
|
let lines = rewritten.get(file);
|
|
@@ -9321,7 +9321,7 @@ function linkGuestImages(options) {
|
|
|
9321
9321
|
const trace = path16.join(directory, `${name2}-inputs.txt`);
|
|
9322
9322
|
fs6.writeFileSync(
|
|
9323
9323
|
response,
|
|
9324
|
-
[...arguments_, "--trace"].map((
|
|
9324
|
+
[...arguments_, "--trace"].map((argument2) => JSON.stringify(argument2)).join(" ")
|
|
9325
9325
|
);
|
|
9326
9326
|
const output = fs6.openSync(trace, "w");
|
|
9327
9327
|
try {
|
|
@@ -10199,7 +10199,7 @@ function sourceGuestClangLinkOptions(options) {
|
|
|
10199
10199
|
const command = commands.get(file);
|
|
10200
10200
|
if (!command) throw new Error(`missing source object producer ${file}`);
|
|
10201
10201
|
if (command.tool === "shell") {
|
|
10202
|
-
if (!command.args.length || realpathSync2(command.args[0]) !== realpathSync2(
|
|
10202
|
+
if (!command.args.length || realpathSync2(command.args[0]) !== realpathSync2(options.swiftCompiler))
|
|
10203
10203
|
throw new Error(`unsupported source object producer ${file}`);
|
|
10204
10204
|
continue;
|
|
10205
10205
|
}
|
|
@@ -11301,6 +11301,7 @@ async function compileGuestLink(options) {
|
|
|
11301
11301
|
buildDirectory: options.buildDirectory,
|
|
11302
11302
|
directory,
|
|
11303
11303
|
toolchainBin: options.toolchainBin,
|
|
11304
|
+
swiftCompiler: options.swiftCompiler,
|
|
11304
11305
|
objects: selectedSource.map((artifact) => artifact.path)
|
|
11305
11306
|
});
|
|
11306
11307
|
const links = sourceGuestRuntimeLinks({
|
|
@@ -11493,13 +11494,482 @@ async function compileGuestLink(options) {
|
|
|
11493
11494
|
writeFileSync6(options.optimized, finalized.wasm);
|
|
11494
11495
|
}
|
|
11495
11496
|
|
|
11497
|
+
// src/swift-header-compiler.ts
|
|
11498
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
11499
|
+
import {
|
|
11500
|
+
chmodSync,
|
|
11501
|
+
existsSync as existsSync3,
|
|
11502
|
+
mkdirSync as mkdirSync5,
|
|
11503
|
+
mkdtempSync as mkdtempSync3,
|
|
11504
|
+
readFileSync as readFileSync14,
|
|
11505
|
+
renameSync as renameSync2,
|
|
11506
|
+
rmSync as rmSync5,
|
|
11507
|
+
statSync,
|
|
11508
|
+
writeFileSync as writeFileSync7
|
|
11509
|
+
} from "node:fs";
|
|
11510
|
+
import { createServer } from "node:http";
|
|
11511
|
+
import path22 from "node:path";
|
|
11512
|
+
|
|
11513
|
+
// src/forked-script-contract.ts
|
|
11514
|
+
var PEACH_FORKED_SCRIPT_ENV = "PEACH_RUNS_FORKED_SCRIPTS";
|
|
11515
|
+
|
|
11516
|
+
// src/swift-header-compiler.ts
|
|
11517
|
+
var SWIFT_HEADER_COMPILER_WRAPPER = ".build/peach-swiftc";
|
|
11518
|
+
var argument = (value) => `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
11519
|
+
var client = `const { request } = require('node:http')
|
|
11520
|
+
const { spawnSync } = require('node:child_process')
|
|
11521
|
+
const { existsSync } = require('node:fs')
|
|
11522
|
+
const [socketPath, moduleName, swiftc, receipt, ...args] = process.argv.slice(2)
|
|
11523
|
+
const body = JSON.stringify(args)
|
|
11524
|
+
const notify = (method) => new Promise((resolve, reject) => {
|
|
11525
|
+
const req = request({ socketPath, path: '/' + moduleName, method }, response => {
|
|
11526
|
+
let message = ''
|
|
11527
|
+
response.setEncoding('utf8').on('data', data => { message += data })
|
|
11528
|
+
response.on('end', () => {
|
|
11529
|
+
if (response.statusCode === 200 || response.statusCode === 204) resolve(response.statusCode === 200)
|
|
11530
|
+
else reject(new Error(message))
|
|
11531
|
+
})
|
|
11532
|
+
response.on('error', reject)
|
|
11533
|
+
})
|
|
11534
|
+
req.on('error', reject)
|
|
11535
|
+
req.end(body)
|
|
11536
|
+
})
|
|
11537
|
+
async function compile() {
|
|
11538
|
+
if (existsSync(receipt) && await notify('PUT')) return
|
|
11539
|
+
const result = spawnSync(swiftc, args, { stdio: 'inherit' })
|
|
11540
|
+
if (result.error) throw result.error
|
|
11541
|
+
if (result.status !== 0) { process.exitCode = result.status ?? 1; return }
|
|
11542
|
+
await notify('POST')
|
|
11543
|
+
}
|
|
11544
|
+
compile().catch(error => {
|
|
11545
|
+
process.stderr.write(String(error) + '\\n')
|
|
11546
|
+
process.exitCode = 1
|
|
11547
|
+
})
|
|
11548
|
+
`;
|
|
11549
|
+
function compilerCheckpoint(root, recipe, args, header) {
|
|
11550
|
+
const value = (flag) => {
|
|
11551
|
+
const index = args.lastIndexOf(flag);
|
|
11552
|
+
return index < 0 ? void 0 : args[index + 1];
|
|
11553
|
+
};
|
|
11554
|
+
const outputMap = value("-output-file-map");
|
|
11555
|
+
const module = value("-emit-module-path");
|
|
11556
|
+
if (!outputMap || !module || !args.includes("-whole-module-optimization")) return;
|
|
11557
|
+
const mapText = readFileSync14(outputMap, "utf8");
|
|
11558
|
+
const map = JSON.parse(mapText);
|
|
11559
|
+
if (!isRecord(map) || !isRecord(map[""]) || typeof map[""].dependencies !== "string")
|
|
11560
|
+
return;
|
|
11561
|
+
const objects = [];
|
|
11562
|
+
for (const [source, outputs2] of Object.entries(map)) {
|
|
11563
|
+
if (!source) continue;
|
|
11564
|
+
if (!isRecord(outputs2) || typeof outputs2.object !== "string") return;
|
|
11565
|
+
objects.push(outputs2.object);
|
|
11566
|
+
}
|
|
11567
|
+
if (!objects.length) return;
|
|
11568
|
+
const outputs = [module, header, map[""].dependencies, ...objects];
|
|
11569
|
+
const digest = createHash12("sha256").update(recipe).update(JSON.stringify(args)).update(mapText);
|
|
11570
|
+
for (const flag of args) {
|
|
11571
|
+
if (!flag.startsWith("@")) continue;
|
|
11572
|
+
const response = flag.slice(1);
|
|
11573
|
+
if (!path22.isAbsolute(response) || !existsSync3(response)) return;
|
|
11574
|
+
digest.update(readFileSync14(response));
|
|
11575
|
+
}
|
|
11576
|
+
for (const file of outputs) {
|
|
11577
|
+
if (!file.startsWith(path22.join(root, ".build") + path22.sep)) return;
|
|
11578
|
+
const stat = statSync(file, { bigint: true, throwIfNoEntry: false });
|
|
11579
|
+
if (!stat?.isFile() || stat.size === 0n) return;
|
|
11580
|
+
digest.update(JSON.stringify([file, String(stat.size), String(stat.mtimeNs)]));
|
|
11581
|
+
}
|
|
11582
|
+
return digest.digest("hex");
|
|
11583
|
+
}
|
|
11584
|
+
async function withSwiftHeaderCompiler(root, toolchainBin, recipe, producers, build) {
|
|
11585
|
+
const wrapper = path22.join(root, SWIFT_HEADER_COMPILER_WRAPPER);
|
|
11586
|
+
const script = path22.join(root, ".build", "peach-swift-header.cjs");
|
|
11587
|
+
const checkpoints = path22.join(root, ".build", "peach-swift-header-checkpoints");
|
|
11588
|
+
mkdirSync5(checkpoints, { recursive: true });
|
|
11589
|
+
const swiftc = argument(path22.join(toolchainBin, "swiftc"));
|
|
11590
|
+
writeBuildFile(script, client);
|
|
11591
|
+
writeBuildFile(
|
|
11592
|
+
wrapper,
|
|
11593
|
+
[
|
|
11594
|
+
"#!/bin/sh",
|
|
11595
|
+
"module=; compile=; previous=",
|
|
11596
|
+
'for flag in "$@"; do',
|
|
11597
|
+
' if [ "$previous" = -module-name ]; then module=$flag; fi',
|
|
11598
|
+
' if [ "$flag" = -c ]; then compile=1; fi',
|
|
11599
|
+
" previous=$flag",
|
|
11600
|
+
"done",
|
|
11601
|
+
'case "$compile:$module" in',
|
|
11602
|
+
` ${[...producers.keys()].map((name2) => argument(`1:${name2}`)).join("|")})`,
|
|
11603
|
+
` ${PEACH_FORKED_SCRIPT_ENV}=1 exec ${argument(process.execPath)} ${argument(script)} "$PEACH_SWIFT_HEADER_SOCKET" "$module" ${swiftc} ${argument(checkpoints)}/"$module" "$@" ;;`,
|
|
11604
|
+
"esac",
|
|
11605
|
+
`exec ${swiftc} "$@"`,
|
|
11606
|
+
""
|
|
11607
|
+
].join("\n")
|
|
11608
|
+
);
|
|
11609
|
+
chmodSync(wrapper, 493);
|
|
11610
|
+
const directory = mkdtempSync3("/tmp/peach-headers-");
|
|
11611
|
+
const socket = path22.join(directory, "compile");
|
|
11612
|
+
const server = createServer(async (request, response) => {
|
|
11613
|
+
const module = request.url?.slice(1) ?? "";
|
|
11614
|
+
const producer = producers.get(module);
|
|
11615
|
+
if (!producer) {
|
|
11616
|
+
response.writeHead(404).end("unknown Swift header producer");
|
|
11617
|
+
return;
|
|
11618
|
+
}
|
|
11619
|
+
try {
|
|
11620
|
+
const chunks = [];
|
|
11621
|
+
for await (const chunk of request) chunks.push(chunk);
|
|
11622
|
+
const args = JSON.parse(Buffer.concat(chunks).toString());
|
|
11623
|
+
if (!Array.isArray(args) || !args.every((arg) => typeof arg === "string"))
|
|
11624
|
+
throw new Error("invalid Swift compiler arguments");
|
|
11625
|
+
const receipt = path22.join(checkpoints, module);
|
|
11626
|
+
const fingerprint = compilerCheckpoint(root, recipe, args, producer.header);
|
|
11627
|
+
if (request.method === "PUT") {
|
|
11628
|
+
if (!fingerprint || !existsSync3(receipt) || readFileSync14(receipt, "utf8") !== fingerprint) {
|
|
11629
|
+
response.writeHead(204).end();
|
|
11630
|
+
return;
|
|
11631
|
+
}
|
|
11632
|
+
producer.publish();
|
|
11633
|
+
response.end();
|
|
11634
|
+
return;
|
|
11635
|
+
}
|
|
11636
|
+
if (request.method !== "POST")
|
|
11637
|
+
throw new Error("invalid Swift compiler checkpoint method");
|
|
11638
|
+
producer.publish();
|
|
11639
|
+
if (fingerprint) {
|
|
11640
|
+
writeFileSync7(`${receipt}.partial`, fingerprint);
|
|
11641
|
+
renameSync2(`${receipt}.partial`, receipt);
|
|
11642
|
+
}
|
|
11643
|
+
response.end();
|
|
11644
|
+
} catch (error) {
|
|
11645
|
+
response.writeHead(500).end(String(error));
|
|
11646
|
+
}
|
|
11647
|
+
});
|
|
11648
|
+
try {
|
|
11649
|
+
await new Promise((resolve, reject) => {
|
|
11650
|
+
server.once("error", reject);
|
|
11651
|
+
server.listen(socket, resolve);
|
|
11652
|
+
});
|
|
11653
|
+
return await build({ SWIFT_EXEC: wrapper, PEACH_SWIFT_HEADER_SOCKET: socket });
|
|
11654
|
+
} finally {
|
|
11655
|
+
server.close();
|
|
11656
|
+
server.closeAllConnections();
|
|
11657
|
+
rmSync5(directory, { recursive: true, force: true });
|
|
11658
|
+
}
|
|
11659
|
+
}
|
|
11660
|
+
|
|
11661
|
+
// src/swift-header-dependencies.ts
|
|
11662
|
+
import path23 from "node:path";
|
|
11663
|
+
|
|
11664
|
+
// src/swiftContract.ts
|
|
11665
|
+
function isSwiftSourceLinkGraph(value) {
|
|
11666
|
+
if (!value || typeof value !== "object") return false;
|
|
11667
|
+
const text2 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
|
|
11668
|
+
const entry = Reflect.get(value, "entry");
|
|
11669
|
+
const targets = Reflect.get(value, "targets");
|
|
11670
|
+
if (!text2(entry) || !Array.isArray(targets) || targets.length > 1024) return false;
|
|
11671
|
+
const ids = /* @__PURE__ */ new Set();
|
|
11672
|
+
for (const target of targets) {
|
|
11673
|
+
if (!target || typeof target !== "object") return false;
|
|
11674
|
+
const id = Reflect.get(target, "id");
|
|
11675
|
+
const source = Reflect.get(target, "sourceTarget");
|
|
11676
|
+
const flags = Reflect.get(target, "linkerFlags");
|
|
11677
|
+
const dependencies = Reflect.get(target, "dependencies");
|
|
11678
|
+
const build = Reflect.get(target, "buildVersion");
|
|
11679
|
+
const nullableText = (value2) => value2 === null || text2(value2);
|
|
11680
|
+
if (!text2(id) || ids.has(id) || !(source === null || text2(source)) || !text2(Reflect.get(target, "productName")) || !text2(Reflect.get(target, "productType")) || !nullableText(Reflect.get(target, "installName")) || !build || typeof build !== "object" || !["platform", "minimumOS", "sdk"].every(
|
|
11681
|
+
(key) => nullableText(Reflect.get(build, key))
|
|
11682
|
+
) || !(Reflect.get(target, "machOType") === null || text2(Reflect.get(target, "machOType"))) || !Array.isArray(flags) || !flags.every(text2) || !Array.isArray(dependencies) || !dependencies.every(
|
|
11683
|
+
(link) => link && typeof link === "object" && text2(Reflect.get(link, "target")) && Array.isArray(Reflect.get(link, "attributes")) && Reflect.get(link, "attributes").every(text2)
|
|
11684
|
+
))
|
|
11685
|
+
return false;
|
|
11686
|
+
ids.add(id);
|
|
11687
|
+
}
|
|
11688
|
+
return ids.has(entry) && targets.every(
|
|
11689
|
+
(target) => Reflect.get(target, "dependencies").every(
|
|
11690
|
+
(link) => ids.has(link.target)
|
|
11691
|
+
)
|
|
11692
|
+
);
|
|
11693
|
+
}
|
|
11694
|
+
var SWIFT_REMOTE_PACKAGES_DIR = "__packages__";
|
|
11695
|
+
var SWIFT_LOCAL_PACKAGES_DIR = "__local_packages__";
|
|
11696
|
+
var SWIFT_XCODE_BUILD_CONDITION = "__PEACH_XCODE_BUILD";
|
|
11697
|
+
function isBase64Bytes(value) {
|
|
11698
|
+
return value.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}(?![\s\S])/.test(value);
|
|
11699
|
+
}
|
|
11700
|
+
function isSwiftPackageFiles(value) {
|
|
11701
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
11702
|
+
([file, bytes]) => isSwiftResourcePath(file) && (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`)) && typeof bytes === "string" && isBase64Bytes(bytes)
|
|
11703
|
+
);
|
|
11704
|
+
}
|
|
11705
|
+
function swiftProjectFileProblem(file) {
|
|
11706
|
+
if (!isSwiftResourcePath(file)) return "not a relative path of plain segments";
|
|
11707
|
+
if (file === "Package.swift") return "would replace the generated manifest";
|
|
11708
|
+
if (file.split("/").includes(".build")) return "is build output (.build)";
|
|
11709
|
+
if (file.startsWith(".")) return 'starts with "." (hidden file or peach output)';
|
|
11710
|
+
if (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`))
|
|
11711
|
+
return "collides with a transported package checkout";
|
|
11712
|
+
return void 0;
|
|
11713
|
+
}
|
|
11714
|
+
function swiftProjectEntryProblem(file, bytes) {
|
|
11715
|
+
return swiftProjectFileProblem(file) ?? (typeof bytes === "string" && isBase64Bytes(bytes) ? void 0 : "bytes are not base64");
|
|
11716
|
+
}
|
|
11717
|
+
function isSwiftProjectFiles(value) {
|
|
11718
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
11719
|
+
([file, bytes]) => swiftProjectEntryProblem(file, bytes) === void 0
|
|
11720
|
+
);
|
|
11721
|
+
}
|
|
11722
|
+
function swiftProjectFilesProblems(value) {
|
|
11723
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
11724
|
+
return ["projectFiles is not an object"];
|
|
11725
|
+
return Object.entries(value).flatMap(([file, bytes]) => {
|
|
11726
|
+
const problem = swiftProjectEntryProblem(file, bytes);
|
|
11727
|
+
return problem ? [`${file}: ${problem}`] : [];
|
|
11728
|
+
});
|
|
11729
|
+
}
|
|
11730
|
+
var SWIFT_NATIVE_INPUT_ROOT = "$(PEACH_INPUT_ROOT)";
|
|
11731
|
+
var SWIFT_NATIVE_SDK_INCLUDE = "$(PEACH_SDK_INCLUDE)";
|
|
11732
|
+
function isSwiftHeaderAliases(value) {
|
|
11733
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
11734
|
+
([alias, file]) => isSwiftResourcePath(alias) && isSwiftResourcePath(file)
|
|
11735
|
+
);
|
|
11736
|
+
}
|
|
11737
|
+
function isSwiftNativeTargets(value) {
|
|
11738
|
+
return swiftNativeTargetsRefusal(value) === null;
|
|
11739
|
+
}
|
|
11740
|
+
function swiftNativeTargetsRefusal(value) {
|
|
11741
|
+
const strings = (value2) => Array.isArray(value2) && value2.every((item) => typeof item === "string" && !item.includes("\0"));
|
|
11742
|
+
const paths = (value2) => strings(value2) && value2.every(isSwiftResourcePath);
|
|
11743
|
+
if (!Array.isArray(value)) return "nativeTargets";
|
|
11744
|
+
if (value.length > 128) return "nativeTargets:length";
|
|
11745
|
+
for (const target of value) {
|
|
11746
|
+
if (!target || typeof target !== "object") return "nativeTargets:shape";
|
|
11747
|
+
const field = (name3) => Reflect.get(target, name3);
|
|
11748
|
+
const name2 = typeof field("name") === "string" ? String(field("name")) : "?";
|
|
11749
|
+
const at = (shape) => `nativeTargets:${name2}:${shape}`;
|
|
11750
|
+
const nullablePath = (key) => field(key) === null || isSwiftResourcePath(field(key));
|
|
11751
|
+
const perFile = field("fileFlags");
|
|
11752
|
+
const directories = field("sourceDirectories");
|
|
11753
|
+
const searches = field("headerSearchPaths");
|
|
11754
|
+
const userSearches = field("userHeaderSearchPaths");
|
|
11755
|
+
const frameworks = field("frameworkSearchPaths");
|
|
11756
|
+
const maps = field("headerMaps");
|
|
11757
|
+
const products = field("productHeaders");
|
|
11758
|
+
const inputPath = (value2) => typeof value2 === "string" && value2.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) && isSwiftResourcePath(value2.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1));
|
|
11759
|
+
const deployment = field("deploymentTarget");
|
|
11760
|
+
const targetName = field("name");
|
|
11761
|
+
if (typeof targetName !== "string" || targetName.length === 0 || targetName.length > 4096 || targetName.includes("\0") || targetName.includes("/") || targetName.includes("\\") || targetName === "." || targetName === "..")
|
|
11762
|
+
return at("name");
|
|
11763
|
+
if (!(deployment === null || typeof deployment === "string" && /^\d+(?:\.\d+){0,2}$/.test(deployment)))
|
|
11764
|
+
return at("deploymentTarget");
|
|
11765
|
+
if (!paths(field("headers"))) return at("headers");
|
|
11766
|
+
if (!paths(field("publicHeaders"))) return at("publicHeaders");
|
|
11767
|
+
if (typeof field("flattensPublicHeaders") !== "boolean")
|
|
11768
|
+
return at("flattensPublicHeaders");
|
|
11769
|
+
if (!nullablePath("bridgingHeader")) return at("bridgingHeader");
|
|
11770
|
+
if (!nullablePath("prefixHeader")) return at("prefixHeader");
|
|
11771
|
+
if (!strings(searches) || !searches.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
11772
|
+
return at("headerSearchPaths");
|
|
11773
|
+
const moduleMaps = field("moduleMaps");
|
|
11774
|
+
if (moduleMaps !== void 0 && (!Array.isArray(moduleMaps) || moduleMaps.length > 128 || !moduleMaps.every((map) => {
|
|
11775
|
+
if (!map || typeof map !== "object") return false;
|
|
11776
|
+
const module = Reflect.get(map, "module");
|
|
11777
|
+
const headers = Reflect.get(map, "headers");
|
|
11778
|
+
return typeof module === "string" && module.length > 0 && module.length <= 4096 && !module.includes("\0") && (headers === "." || isSwiftResourcePath(headers));
|
|
11779
|
+
})))
|
|
11780
|
+
return at("moduleMaps");
|
|
11781
|
+
if (!strings(userSearches) || !userSearches.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
11782
|
+
return at("userHeaderSearchPaths");
|
|
11783
|
+
if (!strings(frameworks) || !frameworks.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
11784
|
+
return at("frameworkSearchPaths");
|
|
11785
|
+
if (!Array.isArray(maps) || !maps.every((map) => {
|
|
11786
|
+
if (!map || typeof map !== "object") return false;
|
|
11787
|
+
const flag = Reflect.get(map, "flag");
|
|
11788
|
+
const entries = Reflect.get(map, "entries");
|
|
11789
|
+
return (flag === "-I" || flag === "-iquote") && Array.isArray(entries) && entries.every(
|
|
11790
|
+
(entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && !entry[0].includes("\0") && (inputPath(entry[1]) || isSwiftResourcePath(entry[1]))
|
|
11791
|
+
);
|
|
11792
|
+
}))
|
|
11793
|
+
return at("headerMaps");
|
|
11794
|
+
if (!products || typeof products !== "object" || Array.isArray(products) || !Object.entries(products).every(
|
|
11795
|
+
([product, file]) => isSwiftResourcePath(product) && isSwiftResourcePath(file)
|
|
11796
|
+
))
|
|
11797
|
+
return at("productHeaders");
|
|
11798
|
+
if (!strings(field("flags"))) return at("flags");
|
|
11799
|
+
if (!strings(field("importerFlags"))) return at("importerFlags");
|
|
11800
|
+
if (!strings(field("cxxFlags"))) return at("cxxFlags");
|
|
11801
|
+
if (!perFile || typeof perFile !== "object" || Array.isArray(perFile) || !Object.entries(perFile).every(
|
|
11802
|
+
([file, flags]) => isSwiftResourcePath(file) && strings(flags)
|
|
11803
|
+
))
|
|
11804
|
+
return at("fileFlags");
|
|
11805
|
+
if (!directories || typeof directories !== "object" || Array.isArray(directories) || !Object.entries(directories).every(
|
|
11806
|
+
([file, directory]) => isSwiftResourcePath(file) && (directory === "." || isSwiftResourcePath(directory))
|
|
11807
|
+
))
|
|
11808
|
+
return at("sourceDirectories");
|
|
11809
|
+
}
|
|
11810
|
+
return null;
|
|
11811
|
+
}
|
|
11812
|
+
function isSwiftResourcePath(value) {
|
|
11813
|
+
return typeof value === "string" && value.length <= 4096 && !value.startsWith("/") && !value.includes("\\") && !value.includes("\0") && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
11814
|
+
}
|
|
11815
|
+
function isSwiftBundlePath(value) {
|
|
11816
|
+
return typeof value === "string" && (value === "." || isSwiftResourcePath(value) && /\.(bundle|framework)$/.test(value));
|
|
11817
|
+
}
|
|
11818
|
+
function isSwiftResourceBundles(value) {
|
|
11819
|
+
return Array.isArray(value) && value.every(
|
|
11820
|
+
(bundle) => typeof bundle === "object" && bundle !== null && typeof bundle.target === "string" && /^[A-Za-z_][A-Za-z0-9_-]*$/.test(bundle.target) && (bundle.sourcePath === "." || isSwiftResourcePath(bundle.sourcePath)) && isSwiftBundlePath(bundle.path)
|
|
11821
|
+
) && new Set(value.map((bundle) => bundle.target)).size === value.length && new Set(value.map((bundle) => bundle.path)).size === value.length;
|
|
11822
|
+
}
|
|
11823
|
+
|
|
11824
|
+
// src/swift-header-dependencies.ts
|
|
11825
|
+
function* nativeHeaderIncludes(source) {
|
|
11826
|
+
for (const match of source.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/^\s*#\s*(?:include|import)\s*[<"]([^>"]+)[>"]/gm))
|
|
11827
|
+
yield match[1];
|
|
11828
|
+
}
|
|
11829
|
+
function swiftHeaderDependencies(root, files, targets, nativeTargets, producers, aliases) {
|
|
11830
|
+
const headers = /* @__PURE__ */ new Map();
|
|
11831
|
+
for (const file of files.keys())
|
|
11832
|
+
if (/\.(?:h|hh|hpp|hxx|inc|inl|ipp|def|modulemap)$/.test(file))
|
|
11833
|
+
headers.set(file, /* @__PURE__ */ new Set());
|
|
11834
|
+
const byDirectory = /* @__PURE__ */ new Map();
|
|
11835
|
+
for (const target of targets) {
|
|
11836
|
+
const directory = path23.resolve(root, target.path);
|
|
11837
|
+
const owners = byDirectory.get(directory) ?? /* @__PURE__ */ new Set();
|
|
11838
|
+
owners.add(target.name);
|
|
11839
|
+
byDirectory.set(directory, owners);
|
|
11840
|
+
}
|
|
11841
|
+
const settings = new Map(nativeTargets.map((native) => [native.name, native]));
|
|
11842
|
+
const physicalHeaders = new Map(
|
|
11843
|
+
Object.entries(aliases).map(([alias, file]) => [
|
|
11844
|
+
path23.resolve(root, alias),
|
|
11845
|
+
path23.resolve(root, file)
|
|
11846
|
+
])
|
|
11847
|
+
);
|
|
11848
|
+
const lookup = new Map(
|
|
11849
|
+
targets.map((target) => {
|
|
11850
|
+
const native = settings.get(target.name);
|
|
11851
|
+
const directory = path23.resolve(root, target.path);
|
|
11852
|
+
const inputPrefix = `${SWIFT_NATIVE_INPUT_ROOT}/`;
|
|
11853
|
+
const flags = native?.importerFlags ?? [];
|
|
11854
|
+
const search = [
|
|
11855
|
+
path23.resolve(directory, target.publicHeadersPath ?? "include"),
|
|
11856
|
+
...(native?.userHeaderSearchPaths ?? []).map((file) => path23.resolve(root, file)),
|
|
11857
|
+
...(native?.headerSearchPaths ?? []).map((file) => path23.resolve(root, file)),
|
|
11858
|
+
...(target.clangSettings ?? []).flatMap(
|
|
11859
|
+
(setting) => "headerSearchPath" in setting ? [path23.resolve(directory, setting.headerSearchPath)] : []
|
|
11860
|
+
),
|
|
11861
|
+
...flags.flatMap(
|
|
11862
|
+
(flag, index) => (flags[index - 1] === "-I" || flags[index - 1] === "-iquote") && flag.startsWith(inputPrefix) ? [path23.resolve(root, flag.slice(inputPrefix.length))] : []
|
|
11863
|
+
)
|
|
11864
|
+
];
|
|
11865
|
+
const mapped = /* @__PURE__ */ new Map();
|
|
11866
|
+
const map = (include, file) => {
|
|
11867
|
+
const key = include.toLowerCase();
|
|
11868
|
+
const files2 = mapped.get(key) ?? [];
|
|
11869
|
+
files2.push(path23.resolve(root, file));
|
|
11870
|
+
mapped.set(key, files2);
|
|
11871
|
+
};
|
|
11872
|
+
for (const headerMap2 of native?.headerMaps ?? []) {
|
|
11873
|
+
for (const [alias, file] of headerMap2.entries) {
|
|
11874
|
+
if (file.startsWith(inputPrefix)) map(alias, file.slice(inputPrefix.length));
|
|
11875
|
+
else {
|
|
11876
|
+
const product = native?.productHeaders[file];
|
|
11877
|
+
if (product) map(alias, product);
|
|
11878
|
+
}
|
|
11879
|
+
}
|
|
11880
|
+
}
|
|
11881
|
+
for (const [alias, file] of Object.entries(native?.productHeaders ?? {}))
|
|
11882
|
+
map(alias, file);
|
|
11883
|
+
if (native?.flattensPublicHeaders)
|
|
11884
|
+
for (const file of native.publicHeaders)
|
|
11885
|
+
map(`${target.name}/${path23.basename(file)}`, file);
|
|
11886
|
+
return [target.name, { search, mapped }];
|
|
11887
|
+
})
|
|
11888
|
+
);
|
|
11889
|
+
const headersByTarget = /* @__PURE__ */ new Map();
|
|
11890
|
+
const ownersOf = (file) => {
|
|
11891
|
+
for (let directory = path23.dirname(file); ; directory = path23.dirname(directory)) {
|
|
11892
|
+
const owners = byDirectory.get(directory);
|
|
11893
|
+
if (owners) return owners;
|
|
11894
|
+
if (directory === root || !directory.startsWith(root + path23.sep)) break;
|
|
11895
|
+
}
|
|
11896
|
+
return /* @__PURE__ */ new Set();
|
|
11897
|
+
};
|
|
11898
|
+
const includers = /* @__PURE__ */ new Map();
|
|
11899
|
+
const enqueue = [];
|
|
11900
|
+
for (const [file, edges] of headers) {
|
|
11901
|
+
const source = files.get(file).toString();
|
|
11902
|
+
const owners = ownersOf(file);
|
|
11903
|
+
for (const owner of owners) {
|
|
11904
|
+
const files2 = headersByTarget.get(owner) ?? /* @__PURE__ */ new Set();
|
|
11905
|
+
files2.add(file);
|
|
11906
|
+
headersByTarget.set(owner, files2);
|
|
11907
|
+
}
|
|
11908
|
+
const moduleMap = file.endsWith(".modulemap");
|
|
11909
|
+
const tokens = moduleMap ? moduleMapTokens(source) : [];
|
|
11910
|
+
const includes = moduleMap ? tokens.flatMap(
|
|
11911
|
+
(token, index) => tokens[index - 1] === "header" && tokens[index - 2] !== "exclude" && token.startsWith('"') ? [token.slice(1, -1)] : []
|
|
11912
|
+
) : nativeHeaderIncludes(source);
|
|
11913
|
+
for (const include of includes) {
|
|
11914
|
+
const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include)?.[1];
|
|
11915
|
+
if (producer && producers.has(producer)) edges.add(producer);
|
|
11916
|
+
const local = path23.resolve(path23.dirname(file), include);
|
|
11917
|
+
const frameworkHeader = moduleMap && /\.framework\/Modules\//.test(file) ? ["../Headers", "../PrivateHeaders"].map(
|
|
11918
|
+
(directory) => path23.resolve(path23.dirname(file), directory, include)
|
|
11919
|
+
) : [];
|
|
11920
|
+
const searchPaths = [...owners].flatMap((owner) => {
|
|
11921
|
+
const { search, mapped } = lookup.get(owner);
|
|
11922
|
+
return [
|
|
11923
|
+
...search.map((directory) => path23.resolve(directory, include)),
|
|
11924
|
+
...mapped.get(include.toLowerCase()) ?? []
|
|
11925
|
+
];
|
|
11926
|
+
});
|
|
11927
|
+
for (const qualified of [local, ...frameworkHeader, ...searchPaths]) {
|
|
11928
|
+
const candidate = physicalHeaders.get(qualified) ?? qualified;
|
|
11929
|
+
if (!headers.has(candidate)) continue;
|
|
11930
|
+
const parents = includers.get(candidate) ?? /* @__PURE__ */ new Set();
|
|
11931
|
+
parents.add(file);
|
|
11932
|
+
includers.set(candidate, parents);
|
|
11933
|
+
}
|
|
11934
|
+
}
|
|
11935
|
+
if (edges.size) enqueue.push(file);
|
|
11936
|
+
}
|
|
11937
|
+
for (let index = 0; index < enqueue.length; index++) {
|
|
11938
|
+
const file = enqueue[index];
|
|
11939
|
+
for (const parent of includers.get(file) ?? []) {
|
|
11940
|
+
const edges = headers.get(parent);
|
|
11941
|
+
const before = edges.size;
|
|
11942
|
+
for (const producer of headers.get(file)) edges.add(producer);
|
|
11943
|
+
if (edges.size > before) enqueue.push(parent);
|
|
11944
|
+
}
|
|
11945
|
+
}
|
|
11946
|
+
return new Map(
|
|
11947
|
+
targets.map((target) => {
|
|
11948
|
+
const native = settings.get(target.name);
|
|
11949
|
+
const publicHeaders = [
|
|
11950
|
+
...native?.headers ?? [],
|
|
11951
|
+
...native?.publicHeaders ?? [],
|
|
11952
|
+
...Object.values(native?.productHeaders ?? {}),
|
|
11953
|
+
...native?.bridgingHeader ? [native.bridgingHeader] : [],
|
|
11954
|
+
...native?.prefixHeader ? [native.prefixHeader] : []
|
|
11955
|
+
].map((file) => path23.resolve(root, file));
|
|
11956
|
+
return [
|
|
11957
|
+
target.name,
|
|
11958
|
+
new Set(
|
|
11959
|
+
[...headersByTarget.get(target.name) ?? [], ...publicHeaders].flatMap((file) => [...headers.get(file) ?? []]).filter((producer) => producer !== target.name)
|
|
11960
|
+
)
|
|
11961
|
+
];
|
|
11962
|
+
})
|
|
11963
|
+
);
|
|
11964
|
+
}
|
|
11965
|
+
|
|
11496
11966
|
// src/swift-icu.ts
|
|
11497
11967
|
import { execFile as execFile3 } from "node:child_process";
|
|
11498
|
-
import { createHash as
|
|
11499
|
-
import { existsSync as
|
|
11968
|
+
import { createHash as createHash13, randomUUID as randomUUID3 } from "node:crypto";
|
|
11969
|
+
import { existsSync as existsSync4, readFileSync as readFileSync15 } from "node:fs";
|
|
11500
11970
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
11501
11971
|
import os3 from "node:os";
|
|
11502
|
-
import
|
|
11972
|
+
import path24 from "node:path";
|
|
11503
11973
|
import { promisify as promisify3 } from "node:util";
|
|
11504
11974
|
import {
|
|
11505
11975
|
brotliCompress,
|
|
@@ -11574,12 +12044,12 @@ var raw = /* @__PURE__ */ new Map();
|
|
|
11574
12044
|
var assets = /* @__PURE__ */ new Map();
|
|
11575
12045
|
var brotliMemoryCache = /* @__PURE__ */ new Map();
|
|
11576
12046
|
async function cachedBrotli(bytes, quality, cacheKey) {
|
|
11577
|
-
const key = cacheKey && /^[a-f0-9]{64}$/.test(cacheKey) ? cacheKey :
|
|
12047
|
+
const key = cacheKey && /^[a-f0-9]{64}$/.test(cacheKey) ? cacheKey : createHash13("sha256").update(bytes).digest("hex");
|
|
11578
12048
|
const cacheId = `${quality}:${key}`;
|
|
11579
12049
|
const cached = brotliMemoryCache.get(cacheId);
|
|
11580
12050
|
if (cached) return cached;
|
|
11581
|
-
const dir =
|
|
11582
|
-
const file =
|
|
12051
|
+
const dir = path24.join(os3.homedir(), ".peach", "cache", "swift-brotli");
|
|
12052
|
+
const file = path24.join(dir, `${key}${quality === 11 ? "" : "-q4"}.br`);
|
|
11583
12053
|
let compressed;
|
|
11584
12054
|
try {
|
|
11585
12055
|
compressed = await readFile(file);
|
|
@@ -11627,13 +12097,13 @@ function swiftIcuAsset(toolchainBin, sdk) {
|
|
|
11627
12097
|
JSON.stringify([toolchainBin, sdk, swiftSdkOptions()]),
|
|
11628
12098
|
async () => {
|
|
11629
12099
|
const zipped = await deflate(await swiftIcuData(toolchainBin, sdk));
|
|
11630
|
-
return { sha256:
|
|
12100
|
+
return { sha256: createHash13("sha256").update(zipped).digest("hex"), gzip: zipped };
|
|
11631
12101
|
}
|
|
11632
12102
|
);
|
|
11633
12103
|
}
|
|
11634
12104
|
async function load(toolchainBin, sdk) {
|
|
11635
|
-
const swift =
|
|
11636
|
-
if (!
|
|
12105
|
+
const swift = path24.join(toolchainBin, "swift");
|
|
12106
|
+
if (!existsSync4(swift))
|
|
11637
12107
|
throw new Error(`swift-icu: no swift at ${swift} for the ${sdk} SDK's icu data`);
|
|
11638
12108
|
const { stdout: listed } = await run(swift, ["sdk", "list", ...swiftSdkOptions()], {
|
|
11639
12109
|
env: swiftEnvironment()
|
|
@@ -11655,7 +12125,7 @@ async function load(toolchainBin, sdk) {
|
|
|
11655
12125
|
const resources = /^swiftStaticResourcesPath: (.+)$/m.exec(stdout)?.[1]?.trim();
|
|
11656
12126
|
if (!resources) throw new Error(`swift-icu: ${sdk} names no static resources`);
|
|
11657
12127
|
return Buffer.from(
|
|
11658
|
-
icuSegment(archiveMember(
|
|
12128
|
+
icuSegment(archiveMember(readFileSync15(path24.join(resources, ARCHIVE)), MEMBER))
|
|
11659
12129
|
);
|
|
11660
12130
|
}
|
|
11661
12131
|
function archiveMember(archive, name2) {
|
|
@@ -11715,21 +12185,21 @@ function swiftIcuAddress(icu) {
|
|
|
11715
12185
|
var packedFiles = /* @__PURE__ */ new Map();
|
|
11716
12186
|
function swiftIcuPacked(icu) {
|
|
11717
12187
|
return memo(packedFiles, icu.sha256, async () => {
|
|
11718
|
-
const file =
|
|
12188
|
+
const file = path24.join(
|
|
11719
12189
|
os3.homedir(),
|
|
11720
12190
|
".peach",
|
|
11721
12191
|
"cache",
|
|
11722
12192
|
"swift-brotli",
|
|
11723
12193
|
swiftIcuAddress(icu)
|
|
11724
12194
|
);
|
|
11725
|
-
if (
|
|
12195
|
+
if (existsSync4(file)) return readFile(file);
|
|
11726
12196
|
const packed = Buffer.from(
|
|
11727
12197
|
swiftIcuPack(
|
|
11728
12198
|
await inflateGzip(icu.gzip),
|
|
11729
12199
|
(bytes) => deflateRawSync(bytes, { level: 9 })
|
|
11730
12200
|
)
|
|
11731
12201
|
);
|
|
11732
|
-
await mkdir(
|
|
12202
|
+
await mkdir(path24.dirname(file), { recursive: true });
|
|
11733
12203
|
const tmp = `${file}.${randomUUID3()}.tmp`;
|
|
11734
12204
|
await writeFile(tmp, packed);
|
|
11735
12205
|
await rename(tmp, file);
|
|
@@ -11746,7 +12216,7 @@ async function swiftIcuBundleAsset(icu) {
|
|
|
11746
12216
|
|
|
11747
12217
|
// src/swift-link-roots.ts
|
|
11748
12218
|
import fs10 from "node:fs";
|
|
11749
|
-
import
|
|
12219
|
+
import path25 from "node:path";
|
|
11750
12220
|
var leb = (bytes, at) => {
|
|
11751
12221
|
let value = 0;
|
|
11752
12222
|
let scale = 1;
|
|
@@ -11841,7 +12311,7 @@ function swiftObjcRootObjects(id, root, objects) {
|
|
|
11841
12311
|
const cached = rootsByDistribution.get(id);
|
|
11842
12312
|
if (cached) return cached;
|
|
11843
12313
|
const measured = objects.map(
|
|
11844
|
-
(object3) => [object3, objcRootInfo(fs10.readFileSync(
|
|
12314
|
+
(object3) => [object3, objcRootInfo(fs10.readFileSync(path25.join(root, object3)))]
|
|
11845
12315
|
);
|
|
11846
12316
|
const roots = new Set(
|
|
11847
12317
|
measured.filter(
|
|
@@ -11969,41 +12439,41 @@ function swiftObjCModuleMap(module, headers, submodules = /* @__PURE__ */ new Se
|
|
|
11969
12439
|
// src/swift-project-user.ts
|
|
11970
12440
|
import { execFileSync as execFileSync10 } from "node:child_process";
|
|
11971
12441
|
import {
|
|
11972
|
-
chmodSync,
|
|
11973
|
-
existsSync as
|
|
11974
|
-
mkdirSync as
|
|
12442
|
+
chmodSync as chmodSync2,
|
|
12443
|
+
existsSync as existsSync5,
|
|
12444
|
+
mkdirSync as mkdirSync6,
|
|
11975
12445
|
readdirSync as readdirSync6,
|
|
11976
|
-
readFileSync as
|
|
12446
|
+
readFileSync as readFileSync16,
|
|
11977
12447
|
realpathSync as realpathSync3,
|
|
11978
|
-
rmSync as
|
|
11979
|
-
statSync
|
|
12448
|
+
rmSync as rmSync6,
|
|
12449
|
+
statSync as statSync2
|
|
11980
12450
|
} from "node:fs";
|
|
11981
|
-
import
|
|
12451
|
+
import path26 from "node:path";
|
|
11982
12452
|
function prepareSwiftProjectProcess(root, user) {
|
|
11983
12453
|
const home = `${root}.project-home`;
|
|
11984
|
-
|
|
11985
|
-
const tmp =
|
|
11986
|
-
const swiftpm =
|
|
11987
|
-
|
|
11988
|
-
const caches = ["cache", "config", "security"].map((name2) =>
|
|
11989
|
-
for (const directory of caches)
|
|
12454
|
+
rmSync6(home, { recursive: true, force: true });
|
|
12455
|
+
const tmp = path26.join(home, "tmp");
|
|
12456
|
+
const swiftpm = path26.join(home, "swiftpm");
|
|
12457
|
+
mkdirSync6(tmp, { recursive: true });
|
|
12458
|
+
const caches = ["cache", "config", "security"].map((name2) => path26.join(swiftpm, name2));
|
|
12459
|
+
for (const directory of caches) mkdirSync6(directory, { recursive: true });
|
|
11990
12460
|
execFileSync10("chown", ["-R", "-P", `${user.uid}:${user.gid}`, root, home]);
|
|
11991
|
-
|
|
11992
|
-
|
|
12461
|
+
chmodSync2(root, 448);
|
|
12462
|
+
chmodSync2(home, 448);
|
|
11993
12463
|
return {
|
|
11994
12464
|
uid: user.uid,
|
|
11995
12465
|
gid: user.gid,
|
|
11996
12466
|
env: {
|
|
11997
12467
|
HOME: home,
|
|
11998
12468
|
TMPDIR: tmp,
|
|
11999
|
-
XDG_CONFIG_HOME:
|
|
12000
|
-
XDG_CACHE_HOME:
|
|
12001
|
-
XDG_DATA_HOME:
|
|
12469
|
+
XDG_CONFIG_HOME: path26.join(home, ".config"),
|
|
12470
|
+
XDG_CACHE_HOME: path26.join(home, ".cache"),
|
|
12471
|
+
XDG_DATA_HOME: path26.join(home, ".local", "share")
|
|
12002
12472
|
},
|
|
12003
12473
|
cacheOptions: [
|
|
12004
12474
|
...["cache", "config", "security"].flatMap((name2) => [
|
|
12005
12475
|
`--${name2}-path`,
|
|
12006
|
-
|
|
12476
|
+
path26.join(swiftpm, name2)
|
|
12007
12477
|
]),
|
|
12008
12478
|
"--disable-keychain"
|
|
12009
12479
|
]
|
|
@@ -12018,8 +12488,8 @@ function endSwiftProjectProcesses(user) {
|
|
|
12018
12488
|
function projectOutputFile(root, file, user) {
|
|
12019
12489
|
const real = realpathSync3(file);
|
|
12020
12490
|
const base = realpathSync3(root);
|
|
12021
|
-
const stat =
|
|
12022
|
-
if (!real.startsWith(base +
|
|
12491
|
+
const stat = statSync2(real);
|
|
12492
|
+
if (!real.startsWith(base + path26.sep) || !stat.isFile() || stat.uid !== user.uid) {
|
|
12023
12493
|
throw new Error(`swift-compile: project output ${file} is not a file of its build`);
|
|
12024
12494
|
}
|
|
12025
12495
|
return real;
|
|
@@ -12028,11 +12498,11 @@ function removeProjectLinks(root) {
|
|
|
12028
12498
|
const pending = [root];
|
|
12029
12499
|
for (let directory = pending.pop(); directory; directory = pending.pop()) {
|
|
12030
12500
|
for (const entry of readdirSync6(directory, { withFileTypes: true })) {
|
|
12031
|
-
const full =
|
|
12501
|
+
const full = path26.join(directory, entry.name);
|
|
12032
12502
|
if (directory === root && entry.name === ".build") continue;
|
|
12033
12503
|
if (directory === root && entry.name.startsWith(".peach-modules-")) {
|
|
12034
|
-
|
|
12035
|
-
} else if (entry.isSymbolicLink())
|
|
12504
|
+
rmSync6(full, { recursive: true, force: true });
|
|
12505
|
+
} else if (entry.isSymbolicLink()) rmSync6(full);
|
|
12036
12506
|
else if (entry.isDirectory()) pending.push(full);
|
|
12037
12507
|
}
|
|
12038
12508
|
}
|
|
@@ -12060,19 +12530,19 @@ function swiftReproducibleBuildFlags(roots) {
|
|
|
12060
12530
|
import {
|
|
12061
12531
|
spawn as spawn4
|
|
12062
12532
|
} from "node:child_process";
|
|
12063
|
-
import { createHash as
|
|
12533
|
+
import { createHash as createHash14, randomUUID as randomUUID4 } from "node:crypto";
|
|
12064
12534
|
import {
|
|
12065
|
-
existsSync as
|
|
12535
|
+
existsSync as existsSync6,
|
|
12066
12536
|
linkSync,
|
|
12067
|
-
mkdirSync as
|
|
12537
|
+
mkdirSync as mkdirSync7,
|
|
12068
12538
|
readdirSync as readdirSync7,
|
|
12069
|
-
readFileSync as
|
|
12539
|
+
readFileSync as readFileSync17,
|
|
12070
12540
|
realpathSync as realpathSync5,
|
|
12071
|
-
rmSync as
|
|
12072
|
-
writeFileSync as
|
|
12541
|
+
rmSync as rmSync7,
|
|
12542
|
+
writeFileSync as writeFileSync8
|
|
12073
12543
|
} from "node:fs";
|
|
12074
12544
|
import { homedir as homedir2 } from "node:os";
|
|
12075
|
-
import
|
|
12545
|
+
import path27 from "node:path";
|
|
12076
12546
|
var POLL_MS = 250;
|
|
12077
12547
|
var INSPECT_ATTEMPTS = 5;
|
|
12078
12548
|
var START_TOLERANCE_MS = 2e3;
|
|
@@ -12138,7 +12608,7 @@ function generationNumbers(directory) {
|
|
|
12138
12608
|
function readGeneration(directory, number3) {
|
|
12139
12609
|
let owner;
|
|
12140
12610
|
try {
|
|
12141
|
-
owner =
|
|
12611
|
+
owner = readFileSync17(path27.join(directory, name(number3, "owner")), "utf8");
|
|
12142
12612
|
} catch (error) {
|
|
12143
12613
|
if (errorCode(error) === "ENOENT") return null;
|
|
12144
12614
|
throw error;
|
|
@@ -12151,7 +12621,7 @@ function readGeneration(directory, number3) {
|
|
|
12151
12621
|
}
|
|
12152
12622
|
function readChildren(directory, number3) {
|
|
12153
12623
|
const prefix = name(number3, "child.");
|
|
12154
|
-
return readdirSync7(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(
|
|
12624
|
+
return readdirSync7(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(readFileSync17(path27.join(directory, entry), "utf8")));
|
|
12155
12625
|
}
|
|
12156
12626
|
function groupAlive(table, leader) {
|
|
12157
12627
|
const row = table.find((candidate) => candidate.pid === leader.pid);
|
|
@@ -12159,30 +12629,30 @@ function groupAlive(table, leader) {
|
|
|
12159
12629
|
return table.some((candidate) => candidate.pgid === leader.pid && !candidate.zombie);
|
|
12160
12630
|
}
|
|
12161
12631
|
function canonicalRoot(root) {
|
|
12162
|
-
let existing =
|
|
12632
|
+
let existing = path27.resolve(root);
|
|
12163
12633
|
const missing = [];
|
|
12164
|
-
while (!
|
|
12165
|
-
missing.unshift(
|
|
12166
|
-
existing =
|
|
12634
|
+
while (!existsSync6(existing) && path27.dirname(existing) !== existing) {
|
|
12635
|
+
missing.unshift(path27.basename(existing));
|
|
12636
|
+
existing = path27.dirname(existing);
|
|
12167
12637
|
}
|
|
12168
|
-
return
|
|
12638
|
+
return path27.join(realpathSync5(existing), ...missing);
|
|
12169
12639
|
}
|
|
12170
12640
|
function swiftRootLocksDir() {
|
|
12171
|
-
return
|
|
12641
|
+
return path27.join(homedir2(), ".peach", "cache", "swift-root-locks");
|
|
12172
12642
|
}
|
|
12173
12643
|
async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
12174
|
-
const directory =
|
|
12644
|
+
const directory = path27.join(
|
|
12175
12645
|
swiftRootLocksDir(),
|
|
12176
|
-
|
|
12646
|
+
createHash14("sha256").update(canonicalRoot(root)).digest("hex").slice(0, 32)
|
|
12177
12647
|
);
|
|
12178
|
-
|
|
12648
|
+
mkdirSync7(directory, { recursive: true });
|
|
12179
12649
|
const token = randomUUID4();
|
|
12180
12650
|
const ownRow = (await processTableWithRetry(process.pid, signal)).find(
|
|
12181
12651
|
(candidate) => candidate.pid === process.pid && !candidate.zombie
|
|
12182
12652
|
);
|
|
12183
12653
|
if (!ownRow) throw new Error(`swift root lock cannot find process ${process.pid}`);
|
|
12184
12654
|
const owner = JSON.stringify({ pid: process.pid, start: ownRow.start });
|
|
12185
|
-
const pending =
|
|
12655
|
+
const pending = path27.join(directory, `pending.${token}`);
|
|
12186
12656
|
let held = 0;
|
|
12187
12657
|
let announced = 0;
|
|
12188
12658
|
let current = null;
|
|
@@ -12221,18 +12691,18 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
12221
12691
|
}
|
|
12222
12692
|
}
|
|
12223
12693
|
}
|
|
12224
|
-
|
|
12694
|
+
writeFileSync8(pending, owner);
|
|
12225
12695
|
try {
|
|
12226
|
-
linkSync(pending,
|
|
12696
|
+
linkSync(pending, path27.join(directory, name(newest + 1, "owner")));
|
|
12227
12697
|
} catch (error) {
|
|
12228
12698
|
if (errorCode(error) === "EEXIST") continue;
|
|
12229
12699
|
throw error;
|
|
12230
12700
|
} finally {
|
|
12231
|
-
|
|
12701
|
+
rmSync7(pending, { force: true });
|
|
12232
12702
|
}
|
|
12233
12703
|
const numbers = generationNumbers(directory);
|
|
12234
12704
|
if (numbers.at(-1) !== newest + 1) {
|
|
12235
|
-
|
|
12705
|
+
rmSync7(path27.join(directory, name(newest + 1, "owner")), { force: true });
|
|
12236
12706
|
continue;
|
|
12237
12707
|
}
|
|
12238
12708
|
held = newest + 1;
|
|
@@ -12240,7 +12710,7 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
12240
12710
|
if (number3 < held) {
|
|
12241
12711
|
for (const entry of readdirSync7(directory))
|
|
12242
12712
|
if (entry.startsWith(name(number3, "")))
|
|
12243
|
-
|
|
12713
|
+
rmSync7(path27.join(directory, entry), { force: true });
|
|
12244
12714
|
}
|
|
12245
12715
|
break;
|
|
12246
12716
|
}
|
|
@@ -12251,10 +12721,10 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
12251
12721
|
if (child.pid === void 0) throw new Error("could not register compiler process");
|
|
12252
12722
|
const childPending = `${pending}.child.${index}`;
|
|
12253
12723
|
try {
|
|
12254
|
-
|
|
12255
|
-
linkSync(childPending,
|
|
12724
|
+
writeFileSync8(childPending, JSON.stringify(ownIdentity(child.pid)));
|
|
12725
|
+
linkSync(childPending, path27.join(directory, name(held, `child.${index}`)));
|
|
12256
12726
|
} finally {
|
|
12257
|
-
|
|
12727
|
+
rmSync7(childPending, { force: true });
|
|
12258
12728
|
}
|
|
12259
12729
|
},
|
|
12260
12730
|
spawn(command, args, options, companion) {
|
|
@@ -12284,18 +12754,18 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
12284
12754
|
return await work(lease);
|
|
12285
12755
|
} finally {
|
|
12286
12756
|
await Promise.all(children.map((child) => terminateProcessGroup(child, "SIGKILL", 0)));
|
|
12287
|
-
|
|
12757
|
+
writeFileSync8(path27.join(directory, name(held, "released")), "");
|
|
12288
12758
|
}
|
|
12289
12759
|
}
|
|
12290
12760
|
|
|
12291
12761
|
// src/swift-uniform-type-constants.ts
|
|
12292
12762
|
import { execFileSync as execFileSync11 } from "node:child_process";
|
|
12293
|
-
import
|
|
12763
|
+
import path28 from "node:path";
|
|
12294
12764
|
function compileUniformTypeConstants(args) {
|
|
12295
|
-
const source =
|
|
12296
|
-
const object3 =
|
|
12765
|
+
const source = path28.join(args.packageRoot, "runtime/UniformTypeIdentifiersConstants.m");
|
|
12766
|
+
const object3 = path28.join(args.out, "UniformTypeIdentifiers-NativeConstants.o");
|
|
12297
12767
|
execFileSync11(
|
|
12298
|
-
|
|
12768
|
+
path28.join(args.bin, "clang"),
|
|
12299
12769
|
[
|
|
12300
12770
|
"--target=wasm64-unknown-wasip1",
|
|
12301
12771
|
`--sysroot=${args.sysroot}`,
|
|
@@ -12304,7 +12774,7 @@ function compileUniformTypeConstants(args) {
|
|
|
12304
12774
|
...swiftObjCRuntimeFlags,
|
|
12305
12775
|
"-fwasm-exceptions",
|
|
12306
12776
|
"-F",
|
|
12307
|
-
|
|
12777
|
+
path28.resolve(args.packageRoot, "../peachsim/sdk/ios/System/Library/Frameworks"),
|
|
12308
12778
|
...objcSdkIntakeFlags(args.darwin, args.bin, args.minimum),
|
|
12309
12779
|
"-c",
|
|
12310
12780
|
source,
|
|
@@ -12316,174 +12786,14 @@ function compileUniformTypeConstants(args) {
|
|
|
12316
12786
|
return object3;
|
|
12317
12787
|
}
|
|
12318
12788
|
|
|
12319
|
-
// src/swiftContract.ts
|
|
12320
|
-
function isSwiftSourceLinkGraph(value) {
|
|
12321
|
-
if (!value || typeof value !== "object") return false;
|
|
12322
|
-
const text2 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
|
|
12323
|
-
const entry = Reflect.get(value, "entry");
|
|
12324
|
-
const targets = Reflect.get(value, "targets");
|
|
12325
|
-
if (!text2(entry) || !Array.isArray(targets) || targets.length > 1024) return false;
|
|
12326
|
-
const ids = /* @__PURE__ */ new Set();
|
|
12327
|
-
for (const target of targets) {
|
|
12328
|
-
if (!target || typeof target !== "object") return false;
|
|
12329
|
-
const id = Reflect.get(target, "id");
|
|
12330
|
-
const source = Reflect.get(target, "sourceTarget");
|
|
12331
|
-
const flags = Reflect.get(target, "linkerFlags");
|
|
12332
|
-
const dependencies = Reflect.get(target, "dependencies");
|
|
12333
|
-
const build = Reflect.get(target, "buildVersion");
|
|
12334
|
-
const nullableText = (value2) => value2 === null || text2(value2);
|
|
12335
|
-
if (!text2(id) || ids.has(id) || !(source === null || text2(source)) || !text2(Reflect.get(target, "productName")) || !text2(Reflect.get(target, "productType")) || !nullableText(Reflect.get(target, "installName")) || !build || typeof build !== "object" || !["platform", "minimumOS", "sdk"].every(
|
|
12336
|
-
(key) => nullableText(Reflect.get(build, key))
|
|
12337
|
-
) || !(Reflect.get(target, "machOType") === null || text2(Reflect.get(target, "machOType"))) || !Array.isArray(flags) || !flags.every(text2) || !Array.isArray(dependencies) || !dependencies.every(
|
|
12338
|
-
(link) => link && typeof link === "object" && text2(Reflect.get(link, "target")) && Array.isArray(Reflect.get(link, "attributes")) && Reflect.get(link, "attributes").every(text2)
|
|
12339
|
-
))
|
|
12340
|
-
return false;
|
|
12341
|
-
ids.add(id);
|
|
12342
|
-
}
|
|
12343
|
-
return ids.has(entry) && targets.every(
|
|
12344
|
-
(target) => Reflect.get(target, "dependencies").every(
|
|
12345
|
-
(link) => ids.has(link.target)
|
|
12346
|
-
)
|
|
12347
|
-
);
|
|
12348
|
-
}
|
|
12349
|
-
var SWIFT_REMOTE_PACKAGES_DIR = "__packages__";
|
|
12350
|
-
var SWIFT_LOCAL_PACKAGES_DIR = "__local_packages__";
|
|
12351
|
-
var SWIFT_XCODE_BUILD_CONDITION = "__PEACH_XCODE_BUILD";
|
|
12352
|
-
function isBase64Bytes(value) {
|
|
12353
|
-
return value.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}(?![\s\S])/.test(value);
|
|
12354
|
-
}
|
|
12355
|
-
function isSwiftPackageFiles(value) {
|
|
12356
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
12357
|
-
([file, bytes]) => isSwiftResourcePath(file) && (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`)) && typeof bytes === "string" && isBase64Bytes(bytes)
|
|
12358
|
-
);
|
|
12359
|
-
}
|
|
12360
|
-
function swiftProjectFileProblem(file) {
|
|
12361
|
-
if (!isSwiftResourcePath(file)) return "not a relative path of plain segments";
|
|
12362
|
-
if (file === "Package.swift") return "would replace the generated manifest";
|
|
12363
|
-
if (file.split("/").includes(".build")) return "is build output (.build)";
|
|
12364
|
-
if (file.startsWith(".")) return 'starts with "." (hidden file or peach output)';
|
|
12365
|
-
if (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`))
|
|
12366
|
-
return "collides with a transported package checkout";
|
|
12367
|
-
return void 0;
|
|
12368
|
-
}
|
|
12369
|
-
function swiftProjectEntryProblem(file, bytes) {
|
|
12370
|
-
return swiftProjectFileProblem(file) ?? (typeof bytes === "string" && isBase64Bytes(bytes) ? void 0 : "bytes are not base64");
|
|
12371
|
-
}
|
|
12372
|
-
function isSwiftProjectFiles(value) {
|
|
12373
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
12374
|
-
([file, bytes]) => swiftProjectEntryProblem(file, bytes) === void 0
|
|
12375
|
-
);
|
|
12376
|
-
}
|
|
12377
|
-
function swiftProjectFilesProblems(value) {
|
|
12378
|
-
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
12379
|
-
return ["projectFiles is not an object"];
|
|
12380
|
-
return Object.entries(value).flatMap(([file, bytes]) => {
|
|
12381
|
-
const problem = swiftProjectEntryProblem(file, bytes);
|
|
12382
|
-
return problem ? [`${file}: ${problem}`] : [];
|
|
12383
|
-
});
|
|
12384
|
-
}
|
|
12385
|
-
var SWIFT_NATIVE_INPUT_ROOT = "$(PEACH_INPUT_ROOT)";
|
|
12386
|
-
var SWIFT_NATIVE_SDK_INCLUDE = "$(PEACH_SDK_INCLUDE)";
|
|
12387
|
-
function isSwiftHeaderAliases(value) {
|
|
12388
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
12389
|
-
([alias, file]) => isSwiftResourcePath(alias) && isSwiftResourcePath(file)
|
|
12390
|
-
);
|
|
12391
|
-
}
|
|
12392
|
-
function isSwiftNativeTargets(value) {
|
|
12393
|
-
return swiftNativeTargetsRefusal(value) === null;
|
|
12394
|
-
}
|
|
12395
|
-
function swiftNativeTargetsRefusal(value) {
|
|
12396
|
-
const strings = (value2) => Array.isArray(value2) && value2.every((item) => typeof item === "string" && !item.includes("\0"));
|
|
12397
|
-
const paths = (value2) => strings(value2) && value2.every(isSwiftResourcePath);
|
|
12398
|
-
if (!Array.isArray(value)) return "nativeTargets";
|
|
12399
|
-
if (value.length > 128) return "nativeTargets:length";
|
|
12400
|
-
for (const target of value) {
|
|
12401
|
-
if (!target || typeof target !== "object") return "nativeTargets:shape";
|
|
12402
|
-
const field = (name3) => Reflect.get(target, name3);
|
|
12403
|
-
const name2 = typeof field("name") === "string" ? String(field("name")) : "?";
|
|
12404
|
-
const at = (shape) => `nativeTargets:${name2}:${shape}`;
|
|
12405
|
-
const nullablePath = (key) => field(key) === null || isSwiftResourcePath(field(key));
|
|
12406
|
-
const perFile = field("fileFlags");
|
|
12407
|
-
const directories = field("sourceDirectories");
|
|
12408
|
-
const searches = field("headerSearchPaths");
|
|
12409
|
-
const userSearches = field("userHeaderSearchPaths");
|
|
12410
|
-
const frameworks = field("frameworkSearchPaths");
|
|
12411
|
-
const maps = field("headerMaps");
|
|
12412
|
-
const products = field("productHeaders");
|
|
12413
|
-
const inputPath = (value2) => typeof value2 === "string" && value2.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) && isSwiftResourcePath(value2.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1));
|
|
12414
|
-
const deployment = field("deploymentTarget");
|
|
12415
|
-
const targetName = field("name");
|
|
12416
|
-
if (typeof targetName !== "string" || targetName.length === 0 || targetName.length > 4096 || targetName.includes("\0") || targetName.includes("/") || targetName.includes("\\") || targetName === "." || targetName === "..")
|
|
12417
|
-
return at("name");
|
|
12418
|
-
if (!(deployment === null || typeof deployment === "string" && /^\d+(?:\.\d+){0,2}$/.test(deployment)))
|
|
12419
|
-
return at("deploymentTarget");
|
|
12420
|
-
if (!paths(field("headers"))) return at("headers");
|
|
12421
|
-
if (!paths(field("publicHeaders"))) return at("publicHeaders");
|
|
12422
|
-
if (typeof field("flattensPublicHeaders") !== "boolean")
|
|
12423
|
-
return at("flattensPublicHeaders");
|
|
12424
|
-
if (!nullablePath("bridgingHeader")) return at("bridgingHeader");
|
|
12425
|
-
if (!nullablePath("prefixHeader")) return at("prefixHeader");
|
|
12426
|
-
if (!strings(searches) || !searches.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
12427
|
-
return at("headerSearchPaths");
|
|
12428
|
-
const moduleMaps = field("moduleMaps");
|
|
12429
|
-
if (moduleMaps !== void 0 && (!Array.isArray(moduleMaps) || moduleMaps.length > 128 || !moduleMaps.every((map) => {
|
|
12430
|
-
if (!map || typeof map !== "object") return false;
|
|
12431
|
-
const module = Reflect.get(map, "module");
|
|
12432
|
-
const headers = Reflect.get(map, "headers");
|
|
12433
|
-
return typeof module === "string" && module.length > 0 && module.length <= 4096 && !module.includes("\0") && (headers === "." || isSwiftResourcePath(headers));
|
|
12434
|
-
})))
|
|
12435
|
-
return at("moduleMaps");
|
|
12436
|
-
if (!strings(userSearches) || !userSearches.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
12437
|
-
return at("userHeaderSearchPaths");
|
|
12438
|
-
if (!strings(frameworks) || !frameworks.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
12439
|
-
return at("frameworkSearchPaths");
|
|
12440
|
-
if (!Array.isArray(maps) || !maps.every((map) => {
|
|
12441
|
-
if (!map || typeof map !== "object") return false;
|
|
12442
|
-
const flag = Reflect.get(map, "flag");
|
|
12443
|
-
const entries = Reflect.get(map, "entries");
|
|
12444
|
-
return (flag === "-I" || flag === "-iquote") && Array.isArray(entries) && entries.every(
|
|
12445
|
-
(entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && !entry[0].includes("\0") && (inputPath(entry[1]) || isSwiftResourcePath(entry[1]))
|
|
12446
|
-
);
|
|
12447
|
-
}))
|
|
12448
|
-
return at("headerMaps");
|
|
12449
|
-
if (!products || typeof products !== "object" || Array.isArray(products) || !Object.entries(products).every(
|
|
12450
|
-
([product, file]) => isSwiftResourcePath(product) && isSwiftResourcePath(file)
|
|
12451
|
-
))
|
|
12452
|
-
return at("productHeaders");
|
|
12453
|
-
if (!strings(field("flags"))) return at("flags");
|
|
12454
|
-
if (!strings(field("importerFlags"))) return at("importerFlags");
|
|
12455
|
-
if (!strings(field("cxxFlags"))) return at("cxxFlags");
|
|
12456
|
-
if (!perFile || typeof perFile !== "object" || Array.isArray(perFile) || !Object.entries(perFile).every(
|
|
12457
|
-
([file, flags]) => isSwiftResourcePath(file) && strings(flags)
|
|
12458
|
-
))
|
|
12459
|
-
return at("fileFlags");
|
|
12460
|
-
if (!directories || typeof directories !== "object" || Array.isArray(directories) || !Object.entries(directories).every(
|
|
12461
|
-
([file, directory]) => isSwiftResourcePath(file) && (directory === "." || isSwiftResourcePath(directory))
|
|
12462
|
-
))
|
|
12463
|
-
return at("sourceDirectories");
|
|
12464
|
-
}
|
|
12465
|
-
return null;
|
|
12466
|
-
}
|
|
12467
|
-
function isSwiftResourcePath(value) {
|
|
12468
|
-
return typeof value === "string" && value.length <= 4096 && !value.startsWith("/") && !value.includes("\\") && !value.includes("\0") && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
12469
|
-
}
|
|
12470
|
-
function isSwiftBundlePath(value) {
|
|
12471
|
-
return typeof value === "string" && (value === "." || isSwiftResourcePath(value) && /\.(bundle|framework)$/.test(value));
|
|
12472
|
-
}
|
|
12473
|
-
function isSwiftResourceBundles(value) {
|
|
12474
|
-
return Array.isArray(value) && value.every(
|
|
12475
|
-
(bundle) => typeof bundle === "object" && bundle !== null && typeof bundle.target === "string" && /^[A-Za-z_][A-Za-z0-9_-]*$/.test(bundle.target) && (bundle.sourcePath === "." || isSwiftResourcePath(bundle.sourcePath)) && isSwiftBundlePath(bundle.path)
|
|
12476
|
-
) && new Set(value.map((bundle) => bundle.target)).size === value.length && new Set(value.map((bundle) => bundle.path)).size === value.length;
|
|
12477
|
-
}
|
|
12478
|
-
|
|
12479
12789
|
// src/xcode-header-search.ts
|
|
12480
12790
|
import fs11 from "node:fs";
|
|
12481
|
-
import
|
|
12791
|
+
import path29 from "node:path";
|
|
12482
12792
|
function coalescibleHeaderOverlays(files) {
|
|
12483
12793
|
const aliases = /* @__PURE__ */ new Map();
|
|
12484
12794
|
const key = (file) => file.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
|
|
12485
12795
|
const index = (directory, entry) => {
|
|
12486
|
-
const name2 =
|
|
12796
|
+
const name2 = path29.resolve(directory, entry.name);
|
|
12487
12797
|
if (entry.type === "directory")
|
|
12488
12798
|
return entry.contents.every((child) => index(name2, child));
|
|
12489
12799
|
const source = entry["external-contents"];
|
|
@@ -12494,11 +12804,11 @@ function coalescibleHeaderOverlays(files) {
|
|
|
12494
12804
|
};
|
|
12495
12805
|
for (const file of files) {
|
|
12496
12806
|
const overlay = JSON.parse(fs11.readFileSync(file, "utf8"));
|
|
12497
|
-
if (!overlay.roots.every((entry) => index(
|
|
12807
|
+
if (!overlay.roots.every((entry) => index(path29.dirname(file), entry)))
|
|
12498
12808
|
return /* @__PURE__ */ new Set();
|
|
12499
12809
|
}
|
|
12500
12810
|
for (const file of [...files, ...aliases.values()]) {
|
|
12501
|
-
const source = aliases.get(key(
|
|
12811
|
+
const source = aliases.get(key(path29.normalize(file)));
|
|
12502
12812
|
if (source !== void 0 && source !== file) return /* @__PURE__ */ new Set();
|
|
12503
12813
|
}
|
|
12504
12814
|
return files;
|
|
@@ -12558,11 +12868,11 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}) {
|
|
|
12558
12868
|
seen.add(file);
|
|
12559
12869
|
file = headerAliases[file];
|
|
12560
12870
|
}
|
|
12561
|
-
const listed = productDirectories.get(
|
|
12562
|
-
productDirectories.set(
|
|
12563
|
-
listed.push({ name:
|
|
12871
|
+
const listed = productDirectories.get(path29.dirname(product)) ?? [];
|
|
12872
|
+
productDirectories.set(path29.dirname(product), listed);
|
|
12873
|
+
listed.push({ name: path29.basename(product), file });
|
|
12564
12874
|
}
|
|
12565
|
-
const overlay =
|
|
12875
|
+
const overlay = path29.join(directory, "all-product-headers.yaml");
|
|
12566
12876
|
writeBuildFile(
|
|
12567
12877
|
overlay,
|
|
12568
12878
|
JSON.stringify({
|
|
@@ -12582,7 +12892,7 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}) {
|
|
|
12582
12892
|
const files = [overlay];
|
|
12583
12893
|
const flags = targets.map((target, index) => {
|
|
12584
12894
|
const maps = target.headerMaps.map((map, order) => {
|
|
12585
|
-
const file =
|
|
12895
|
+
const file = path29.join(directory, `${index}-${order}.hmap`);
|
|
12586
12896
|
writeBuildFile(file, headerMap(map.entries));
|
|
12587
12897
|
files.push(file);
|
|
12588
12898
|
return { flag: map.flag, file };
|
|
@@ -12702,37 +13012,37 @@ function swiftBuildJobs() {
|
|
|
12702
13012
|
);
|
|
12703
13013
|
}
|
|
12704
13014
|
function swiftDistributionAt(root) {
|
|
12705
|
-
const file =
|
|
12706
|
-
if (!
|
|
12707
|
-
return parseSwiftDistributionManifest(JSON.parse(
|
|
13015
|
+
const file = path30.join(root, SWIFT_DISTRIBUTION_MANIFEST);
|
|
13016
|
+
if (!existsSync7(file)) return null;
|
|
13017
|
+
return parseSwiftDistributionManifest(JSON.parse(readFileSync18(file, "utf8")));
|
|
12708
13018
|
}
|
|
12709
13019
|
var REACH_STAGED_FRAMEWORKS = /* @__PURE__ */ new Set(["React"]);
|
|
12710
13020
|
function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
|
|
12711
13021
|
if (REACH_STAGED_FRAMEWORKS.has(name2)) return null;
|
|
12712
13022
|
if (swiftDistributionAt(moduleRoot)) {
|
|
12713
|
-
const file =
|
|
12714
|
-
interfaceRoot ??
|
|
13023
|
+
const file = path30.join(
|
|
13024
|
+
interfaceRoot ?? path30.join(moduleRoot, "modules"),
|
|
12715
13025
|
`${name2}-Swift.h`
|
|
12716
13026
|
);
|
|
12717
|
-
if (!
|
|
12718
|
-
const header = clangInterfaceHeader(
|
|
13027
|
+
if (!existsSync7(file)) return null;
|
|
13028
|
+
const header = clangInterfaceHeader(readFileSync18(file, "utf8"));
|
|
12719
13029
|
return { declared: swiftInterfaceDeclarations(header), header };
|
|
12720
13030
|
}
|
|
12721
|
-
const sources =
|
|
12722
|
-
const built =
|
|
12723
|
-
if (!
|
|
13031
|
+
const sources = path30.join(moduleRoot, "Sources", name2);
|
|
13032
|
+
const built = path30.join(moduleRoot, ".build/host", `${name2}-Swift.h`);
|
|
13033
|
+
if (!existsSync7(sources) || !existsSync7(built)) return null;
|
|
12724
13034
|
const declared = /* @__PURE__ */ new Set();
|
|
12725
13035
|
for (const file of readdirSync8(sources, { recursive: true, encoding: "utf8" }))
|
|
12726
13036
|
if (file.endsWith(".swift"))
|
|
12727
|
-
for (const [, objc, subclass] of
|
|
12728
|
-
|
|
13037
|
+
for (const [, objc, subclass] of readFileSync18(
|
|
13038
|
+
path30.join(sources, file),
|
|
12729
13039
|
"utf8"
|
|
12730
13040
|
).matchAll(
|
|
12731
13041
|
/@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s|^(?:public|open)\s+(?:final\s+)?class\s+(\w+)\s*:\s*NSObject\b/gm
|
|
12732
13042
|
))
|
|
12733
13043
|
declared.add(objc ?? subclass);
|
|
12734
13044
|
if (declared.size === 0) return null;
|
|
12735
|
-
return { declared, header: clangInterfaceHeader(
|
|
13045
|
+
return { declared, header: clangInterfaceHeader(readFileSync18(built, "utf8")) };
|
|
12736
13046
|
}
|
|
12737
13047
|
var clangInterfaceHeader = (header) => header.replace(/^@import (?:UIKitCore|UIKitText);$/gm, "@import UIKit;").replace(
|
|
12738
13048
|
/^@import (?:CoreFoundation|FoundationNetworking);$/gm,
|
|
@@ -12765,11 +13075,11 @@ function sdkObjCDeclarationOwners(frameworks) {
|
|
|
12765
13075
|
const owners = /* @__PURE__ */ new Map();
|
|
12766
13076
|
for (const framework of readdirSync8(frameworks))
|
|
12767
13077
|
if (framework.endsWith(".framework")) {
|
|
12768
|
-
const headers =
|
|
12769
|
-
if (
|
|
13078
|
+
const headers = path30.join(frameworks, framework, "Headers");
|
|
13079
|
+
if (existsSync7(headers)) {
|
|
12770
13080
|
for (const file of readdirSync8(headers, { recursive: true, encoding: "utf8" }))
|
|
12771
13081
|
if (file.endsWith(".h")) {
|
|
12772
|
-
const header =
|
|
13082
|
+
const header = readFileSync18(path30.join(headers, file), "utf8");
|
|
12773
13083
|
for (const name2 of [
|
|
12774
13084
|
...swiftInterfaceDeclarations(header),
|
|
12775
13085
|
...objcEnumerations(header),
|
|
@@ -12865,25 +13175,25 @@ function swiftCompileSdkOptions(moduleRoot, toolchainBin) {
|
|
|
12865
13175
|
);
|
|
12866
13176
|
}
|
|
12867
13177
|
function swiftObjCSelectorOptions(moduleRoot) {
|
|
12868
|
-
let map =
|
|
13178
|
+
let map = path30.join(moduleRoot, SWIFT_DISTRIBUTION_OBJC_SELECTORS);
|
|
12869
13179
|
if (!swiftDistributionAt(moduleRoot)) {
|
|
12870
13180
|
const classes = {};
|
|
12871
13181
|
for (const framework of ["UIKitCore", "WebKit"])
|
|
12872
13182
|
for (const [name2, members] of Object.entries(
|
|
12873
13183
|
JSON.parse(
|
|
12874
|
-
|
|
12875
|
-
|
|
13184
|
+
readFileSync18(
|
|
13185
|
+
path30.join(moduleRoot, "Sources", framework, "ObjCSelectors.json"),
|
|
12876
13186
|
"utf8"
|
|
12877
13187
|
)
|
|
12878
13188
|
).classes
|
|
12879
13189
|
))
|
|
12880
13190
|
classes[name2] = [...classes[name2] ?? [], ...members];
|
|
12881
|
-
map =
|
|
12882
|
-
|
|
13191
|
+
map = path30.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
|
|
13192
|
+
mkdirSync8(path30.dirname(map), { recursive: true });
|
|
12883
13193
|
const partial = `${map}.${randomUUID5()}`;
|
|
12884
|
-
|
|
13194
|
+
writeFileSync9(partial, `${JSON.stringify({ classes }, null, 2)}
|
|
12885
13195
|
`);
|
|
12886
|
-
|
|
13196
|
+
renameSync3(partial, map);
|
|
12887
13197
|
}
|
|
12888
13198
|
return ["-Xswiftc", "-Xllvm", "-Xswiftc", `-peach-objc-selector-map=${map}`];
|
|
12889
13199
|
}
|
|
@@ -12917,7 +13227,7 @@ function swiftModuleInputFiles(root) {
|
|
|
12917
13227
|
"toolchain.json"
|
|
12918
13228
|
];
|
|
12919
13229
|
const walk = (dir) => {
|
|
12920
|
-
for (const entry of readdirSync8(
|
|
13230
|
+
for (const entry of readdirSync8(path30.join(root, dir), {
|
|
12921
13231
|
withFileTypes: true
|
|
12922
13232
|
})) {
|
|
12923
13233
|
const relative = `${dir}/${entry.name}`;
|
|
@@ -12931,46 +13241,46 @@ function swiftModuleInputFiles(root) {
|
|
|
12931
13241
|
walk("ios-simulator-stdlib");
|
|
12932
13242
|
return files.sort();
|
|
12933
13243
|
}
|
|
12934
|
-
function swiftMacroPlugins(moduleRoot, dir =
|
|
13244
|
+
function swiftMacroPlugins(moduleRoot, dir = path30.join(moduleRoot, ".build/host/RnxPreviewMacros")) {
|
|
12935
13245
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
12936
13246
|
if (distribution)
|
|
12937
13247
|
return {
|
|
12938
|
-
libraries: distribution.plugins.filter((plugin) =>
|
|
12939
|
-
executables: distribution.plugins.filter((plugin) =>
|
|
13248
|
+
libraries: distribution.plugins.filter((plugin) => path30.basename(plugin) !== "ExpoModulesMacros").map((plugin) => path30.join(moduleRoot, plugin)),
|
|
13249
|
+
executables: distribution.plugins.filter((plugin) => path30.basename(plugin) === "ExpoModulesMacros").map((plugin) => path30.join(moduleRoot, plugin)),
|
|
12940
13250
|
stale: false
|
|
12941
13251
|
};
|
|
12942
13252
|
const release = JSON.parse(
|
|
12943
|
-
|
|
13253
|
+
readFileSync18(path30.join(moduleRoot, "toolchain.json"), "utf8")
|
|
12944
13254
|
).release;
|
|
12945
|
-
const compilerStamp =
|
|
12946
|
-
const pluginScript =
|
|
12947
|
-
const expoPlugin =
|
|
13255
|
+
const compilerStamp = path30.join(dir, "compiler-release");
|
|
13256
|
+
const pluginScript = path30.join(moduleRoot, "scripts/build-preview-plugin.sh");
|
|
13257
|
+
const expoPlugin = path30.join(dir, "ExpoModulesMacros");
|
|
12948
13258
|
const ext = process.platform === "darwin" ? "dylib" : "so";
|
|
12949
13259
|
const plugins = [
|
|
12950
13260
|
{
|
|
12951
|
-
library:
|
|
12952
|
-
sources: [
|
|
13261
|
+
library: path30.join(dir, `libRnxPreviewMacros.${ext}`),
|
|
13262
|
+
sources: [path30.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
|
|
12953
13263
|
},
|
|
12954
13264
|
{
|
|
12955
|
-
library:
|
|
13265
|
+
library: path30.join(dir, `libFoundationMacros.${ext}`),
|
|
12956
13266
|
sources: [
|
|
12957
|
-
|
|
12958
|
-
|
|
13267
|
+
path30.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
|
|
13268
|
+
path30.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
|
|
12959
13269
|
]
|
|
12960
13270
|
},
|
|
12961
13271
|
{
|
|
12962
|
-
library:
|
|
13272
|
+
library: path30.join(dir, `libTipKitMacros.${ext}`),
|
|
12963
13273
|
sources: [
|
|
12964
|
-
|
|
12965
|
-
|
|
13274
|
+
path30.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
|
|
13275
|
+
path30.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
|
|
12966
13276
|
]
|
|
12967
13277
|
}
|
|
12968
13278
|
];
|
|
12969
13279
|
return {
|
|
12970
13280
|
libraries: plugins.map(({ library }) => library),
|
|
12971
13281
|
executables: [expoPlugin],
|
|
12972
|
-
stale: !
|
|
12973
|
-
({ library, sources }) => !
|
|
13282
|
+
stale: !existsSync7(compilerStamp) || !existsSync7(expoPlugin) || statSync3(pluginScript).mtimeMs > statSync3(expoPlugin).mtimeMs || readFileSync18(compilerStamp, "utf8").trim() !== release || plugins.some(
|
|
13283
|
+
({ library, sources }) => !existsSync7(library) || sources.some((source) => statSync3(source).mtimeMs > statSync3(library).mtimeMs)
|
|
12974
13284
|
)
|
|
12975
13285
|
};
|
|
12976
13286
|
}
|
|
@@ -12980,14 +13290,14 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal, lea
|
|
|
12980
13290
|
await runCompiler(
|
|
12981
13291
|
"sh",
|
|
12982
13292
|
[
|
|
12983
|
-
|
|
13293
|
+
path30.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
12984
13294
|
toolchainBin,
|
|
12985
13295
|
libraries[0]
|
|
12986
13296
|
],
|
|
12987
13297
|
{ signal, lease }
|
|
12988
13298
|
);
|
|
12989
|
-
|
|
12990
|
-
|
|
13299
|
+
writeFileSync9(
|
|
13300
|
+
path30.join(path30.dirname(libraries[0]), "compiler-release"),
|
|
12991
13301
|
`${release}
|
|
12992
13302
|
`
|
|
12993
13303
|
);
|
|
@@ -13001,9 +13311,9 @@ function clearLinkedModuleDigests(root) {
|
|
|
13001
13311
|
}
|
|
13002
13312
|
function swiftModuleDigest(root) {
|
|
13003
13313
|
const files = swiftModuleInputFiles(root);
|
|
13004
|
-
const stampHash =
|
|
13314
|
+
const stampHash = createHash15("sha256");
|
|
13005
13315
|
for (const file of files) {
|
|
13006
|
-
const stat =
|
|
13316
|
+
const stat = statSync3(path30.join(root, file), { bigint: true });
|
|
13007
13317
|
stampHash.update(file);
|
|
13008
13318
|
stampHash.update(
|
|
13009
13319
|
`${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
|
|
@@ -13013,36 +13323,36 @@ function swiftModuleDigest(root) {
|
|
|
13013
13323
|
const stamp = stampHash.digest("hex");
|
|
13014
13324
|
const cached = linkedModuleDigests.get(root);
|
|
13015
13325
|
if (cached?.stamp === stamp) return cached.digest;
|
|
13016
|
-
const record =
|
|
13326
|
+
const record = path30.join(
|
|
13017
13327
|
swiftCacheDir(),
|
|
13018
13328
|
"swift-module-digests",
|
|
13019
|
-
`${
|
|
13329
|
+
`${createHash15("sha256").update(root).digest("hex")}.json`
|
|
13020
13330
|
);
|
|
13021
|
-
if (
|
|
13022
|
-
const saved = JSON.parse(
|
|
13331
|
+
if (existsSync7(record)) {
|
|
13332
|
+
const saved = JSON.parse(readFileSync18(record, "utf8"));
|
|
13023
13333
|
if (saved && typeof saved === "object" && Reflect.get(saved, "stamp") === stamp && typeof Reflect.get(saved, "digest") === "string") {
|
|
13024
13334
|
const digest2 = Buffer.from(String(Reflect.get(saved, "digest")), "hex");
|
|
13025
13335
|
linkedModuleDigests.set(root, { stamp, digest: digest2 });
|
|
13026
13336
|
return digest2;
|
|
13027
13337
|
}
|
|
13028
13338
|
}
|
|
13029
|
-
const hash =
|
|
13339
|
+
const hash = createHash15("sha256");
|
|
13030
13340
|
for (const file of files) {
|
|
13031
|
-
hash.update(
|
|
13341
|
+
hash.update(createHash15("sha256").update(file).digest());
|
|
13032
13342
|
hash.update(
|
|
13033
|
-
|
|
13343
|
+
createHash15("sha256").update(readFileSync18(path30.join(root, file))).digest()
|
|
13034
13344
|
);
|
|
13035
13345
|
}
|
|
13036
13346
|
const digest = hash.digest();
|
|
13037
13347
|
linkedModuleDigests.set(root, { stamp, digest });
|
|
13038
|
-
|
|
13348
|
+
mkdirSync8(path30.dirname(record), { recursive: true });
|
|
13039
13349
|
const partial = `${record}.${process.pid}.${randomUUID5()}`;
|
|
13040
|
-
|
|
13041
|
-
|
|
13350
|
+
writeFileSync9(partial, JSON.stringify({ stamp, digest: digest.toString("hex") }));
|
|
13351
|
+
renameSync3(partial, record);
|
|
13042
13352
|
return digest;
|
|
13043
13353
|
}
|
|
13044
13354
|
function swiftProjectBuildKey(moduleRoot, release) {
|
|
13045
|
-
return
|
|
13355
|
+
return createHash15("sha256").update(`swift-framework/v2\0${release}\0${swiftModuleSdk(moduleRoot).wasmSdkId}`).update(swiftModuleDigest(moduleRoot)).digest("hex").slice(0, 32);
|
|
13046
13356
|
}
|
|
13047
13357
|
var SYSTEM_MODULE_LIBRARIES = {
|
|
13048
13358
|
"sqlite3.h": "sqlite3",
|
|
@@ -13089,7 +13399,7 @@ function withNativeSourceGlue(input, glue) {
|
|
|
13089
13399
|
...input,
|
|
13090
13400
|
files: {
|
|
13091
13401
|
...input.files,
|
|
13092
|
-
[
|
|
13402
|
+
[path30.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
|
|
13093
13403
|
},
|
|
13094
13404
|
oneModule: true
|
|
13095
13405
|
};
|
|
@@ -13181,12 +13491,12 @@ function swiftCondition(text2, available) {
|
|
|
13181
13491
|
if (token === "false") return false;
|
|
13182
13492
|
const call = /^(\w+)\s*\(\s*([^,()]*?)\s*(?:,[^()]*)?\)$/.exec(token ?? "");
|
|
13183
13493
|
if (!call) return void 0;
|
|
13184
|
-
const [, name2,
|
|
13185
|
-
if (name2 === "os") return
|
|
13494
|
+
const [, name2, argument2] = call;
|
|
13495
|
+
if (name2 === "os") return argument2 === "iOS";
|
|
13186
13496
|
if (name2 === "canImport")
|
|
13187
|
-
return
|
|
13188
|
-
if (name2 === "targetEnvironment") return
|
|
13189
|
-
if (name2 === "arch") return
|
|
13497
|
+
return argument2 !== "FoundationNetworking" && available?.has(argument2);
|
|
13498
|
+
if (name2 === "targetEnvironment") return argument2 === "simulator";
|
|
13499
|
+
if (name2 === "arch") return argument2 === "wasm64" || argument2 === "arm64";
|
|
13190
13500
|
return void 0;
|
|
13191
13501
|
};
|
|
13192
13502
|
const both = () => {
|
|
@@ -13245,7 +13555,7 @@ function swiftImportNames(contents2, available) {
|
|
|
13245
13555
|
function swiftPeachModules(moduleRoot) {
|
|
13246
13556
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
13247
13557
|
return distribution ? distribution.modules : swiftManifestDeclarations(
|
|
13248
|
-
|
|
13558
|
+
readFileSync18(path30.join(moduleRoot, "Package.swift"), "utf8")
|
|
13249
13559
|
).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
|
|
13250
13560
|
}
|
|
13251
13561
|
var sdkPaths = /* @__PURE__ */ new Map();
|
|
@@ -13256,7 +13566,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
13256
13566
|
const cached = sdkPaths.get(key);
|
|
13257
13567
|
if (cached) return cached;
|
|
13258
13568
|
const configuration = execFileSync12(
|
|
13259
|
-
|
|
13569
|
+
path30.join(toolchainBin, "swift"),
|
|
13260
13570
|
[
|
|
13261
13571
|
"sdk",
|
|
13262
13572
|
"configure",
|
|
@@ -13281,7 +13591,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
13281
13591
|
if (!Array.isArray(toolsets) || !toolsets.every((value) => typeof value === "string"))
|
|
13282
13592
|
throw new Error(`swift sdk ${sdk} reports invalid toolset paths`);
|
|
13283
13593
|
for (const toolset of toolsets) {
|
|
13284
|
-
const config = JSON.parse(
|
|
13594
|
+
const config = JSON.parse(readFileSync18(toolset, "utf8"));
|
|
13285
13595
|
if (!config || typeof config !== "object" || !("swiftCompiler" in config)) continue;
|
|
13286
13596
|
const compiler = config.swiftCompiler;
|
|
13287
13597
|
if (!compiler || typeof compiler !== "object" || !("extraCLIOptions" in compiler))
|
|
@@ -13297,7 +13607,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
13297
13607
|
if (flag !== "-fwasm-exceptions") cFlags.push(flag);
|
|
13298
13608
|
if (flag === "-iframeworkwithsysroot" && options2[index + 2] === "-Xcc" && typeof options2[index + 3] === "string") {
|
|
13299
13609
|
cFlags.push(options2[index + 3]);
|
|
13300
|
-
frameworks.push(
|
|
13610
|
+
frameworks.push(path30.join(sysroot, options2[index + 3]));
|
|
13301
13611
|
index += 3;
|
|
13302
13612
|
continue;
|
|
13303
13613
|
}
|
|
@@ -13314,7 +13624,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
13314
13624
|
}
|
|
13315
13625
|
const paths = {
|
|
13316
13626
|
sysroot,
|
|
13317
|
-
darwin:
|
|
13627
|
+
darwin: path30.join(sysroot, "darwin"),
|
|
13318
13628
|
resources: field("swiftResourcesPath"),
|
|
13319
13629
|
frameworks,
|
|
13320
13630
|
cFlags
|
|
@@ -13342,24 +13652,24 @@ function swiftOverlayFrameworks(moduleRoot, toolchainBin) {
|
|
|
13342
13652
|
const { darwin, resources, frameworks } = swiftSdkPaths(moduleRoot, toolchainBin);
|
|
13343
13653
|
const swiftModules = new Set(swiftPeachModules(moduleRoot));
|
|
13344
13654
|
const result = /* @__PURE__ */ new Set();
|
|
13345
|
-
const include =
|
|
13655
|
+
const include = path30.join(darwin, "usr/include");
|
|
13346
13656
|
for (const entry of readdirSync8(include))
|
|
13347
13657
|
if (entry.endsWith(".modulemap"))
|
|
13348
13658
|
addSwiftOverlayFrameworks(
|
|
13349
|
-
|
|
13659
|
+
readFileSync18(path30.join(include, entry), "utf8"),
|
|
13350
13660
|
swiftModules,
|
|
13351
13661
|
result
|
|
13352
13662
|
);
|
|
13353
13663
|
for (const entry of readdirSync8(resources)) {
|
|
13354
|
-
const map =
|
|
13355
|
-
if (
|
|
13356
|
-
addSwiftOverlayFrameworks(
|
|
13664
|
+
const map = path30.join(resources, entry, "module.modulemap");
|
|
13665
|
+
if (existsSync7(map))
|
|
13666
|
+
addSwiftOverlayFrameworks(readFileSync18(map, "utf8"), swiftModules, result);
|
|
13357
13667
|
}
|
|
13358
13668
|
for (const directory of frameworks)
|
|
13359
13669
|
for (const entry of readdirSync8(directory)) {
|
|
13360
|
-
const map =
|
|
13361
|
-
if (
|
|
13362
|
-
addSwiftOverlayFrameworks(
|
|
13670
|
+
const map = path30.join(directory, entry, "Modules/module.modulemap");
|
|
13671
|
+
if (existsSync7(map))
|
|
13672
|
+
addSwiftOverlayFrameworks(readFileSync18(map, "utf8"), swiftModules, result);
|
|
13363
13673
|
}
|
|
13364
13674
|
sdkOverlayFrameworks.set(key, result);
|
|
13365
13675
|
return result;
|
|
@@ -13375,51 +13685,51 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
13375
13685
|
toolchainBin
|
|
13376
13686
|
);
|
|
13377
13687
|
const maps = /* @__PURE__ */ new Set([
|
|
13378
|
-
|
|
13688
|
+
path30.join(darwin, "usr/include/module.modulemap"),
|
|
13379
13689
|
...cFlags.filter((flag) => flag.startsWith("-fmodule-map-file=")).map((flag) => {
|
|
13380
13690
|
const file = flag.slice("-fmodule-map-file=".length);
|
|
13381
|
-
return file.startsWith("=") ?
|
|
13691
|
+
return file.startsWith("=") ? path30.join(sysroot, file.slice(1)) : file;
|
|
13382
13692
|
})
|
|
13383
13693
|
]);
|
|
13384
13694
|
for (const map of maps) {
|
|
13385
|
-
if (!
|
|
13386
|
-
const contents2 =
|
|
13695
|
+
if (!existsSync7(map)) continue;
|
|
13696
|
+
const contents2 = readFileSync18(map, "utf8");
|
|
13387
13697
|
for (const match of contents2.matchAll(
|
|
13388
13698
|
/^(?:explicit\s+)?(?:framework\s+)?module\s+([A-Za-z_]\w*)/gm
|
|
13389
13699
|
))
|
|
13390
13700
|
modules.add(match[1]);
|
|
13391
13701
|
for (const match of contents2.matchAll(/^\s*extern\s+module\s+\w+\s+"([^"]+)"/gm))
|
|
13392
|
-
maps.add(
|
|
13702
|
+
maps.add(path30.resolve(path30.dirname(map), match[1]));
|
|
13393
13703
|
}
|
|
13394
|
-
for (const entry of readdirSync8(
|
|
13704
|
+
for (const entry of readdirSync8(path30.join(resources, "wasi"))) {
|
|
13395
13705
|
if (entry.endsWith(".swiftmodule"))
|
|
13396
13706
|
modules.add(entry.slice(0, -".swiftmodule".length));
|
|
13397
13707
|
}
|
|
13398
13708
|
for (const entry of readdirSync8(resources)) {
|
|
13399
|
-
const map =
|
|
13400
|
-
if (!
|
|
13401
|
-
for (const match of
|
|
13709
|
+
const map = path30.join(resources, entry, "module.modulemap");
|
|
13710
|
+
if (!existsSync7(map)) continue;
|
|
13711
|
+
for (const match of readFileSync18(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
|
|
13402
13712
|
modules.add(match[1]);
|
|
13403
13713
|
}
|
|
13404
13714
|
for (const libc of [
|
|
13405
|
-
|
|
13406
|
-
|
|
13715
|
+
path30.join(darwin, "usr/include"),
|
|
13716
|
+
path30.join(
|
|
13407
13717
|
swiftSharedSdkRoot(moduleRoot, swiftDistributionAt(moduleRoot) !== null),
|
|
13408
13718
|
"usr/include"
|
|
13409
13719
|
)
|
|
13410
13720
|
])
|
|
13411
13721
|
for (const entry of readdirSync8(libc)) {
|
|
13412
13722
|
if (!entry.endsWith(".modulemap")) continue;
|
|
13413
|
-
for (const match of
|
|
13723
|
+
for (const match of readFileSync18(path30.join(libc, entry), "utf8").matchAll(
|
|
13414
13724
|
/^module\s+([A-Za-z_]\w*)/gm
|
|
13415
13725
|
))
|
|
13416
13726
|
modules.add(match[1]);
|
|
13417
13727
|
}
|
|
13418
13728
|
for (const directory of frameworks) {
|
|
13419
13729
|
for (const entry of readdirSync8(directory)) {
|
|
13420
|
-
const map =
|
|
13421
|
-
if (!
|
|
13422
|
-
for (const match of
|
|
13730
|
+
const map = path30.join(directory, entry, "Modules/module.modulemap");
|
|
13731
|
+
if (!existsSync7(map)) continue;
|
|
13732
|
+
for (const match of readFileSync18(map, "utf8").matchAll(
|
|
13423
13733
|
/^framework\s+module\s+([A-Za-z_]\w*)/gm
|
|
13424
13734
|
))
|
|
13425
13735
|
modules.add(match[1]);
|
|
@@ -13517,23 +13827,23 @@ int EXUpdatesApplyBSDiffPatch(const char * _Nonnull oldFilePath,
|
|
|
13517
13827
|
}
|
|
13518
13828
|
];
|
|
13519
13829
|
function distributionClangModulePresent(modules, name2) {
|
|
13520
|
-
return
|
|
13830
|
+
return existsSync7(path30.join(modules, `${name2}.swiftmodule`)) || existsSync7(path30.join(modules, name2, "module.modulemap"));
|
|
13521
13831
|
}
|
|
13522
13832
|
function distributionClangModuleMap(root, modules) {
|
|
13523
13833
|
const missing = DISTRIBUTION_CLANG_MODULES.filter(
|
|
13524
13834
|
(mod) => !distributionClangModulePresent(modules, mod.name)
|
|
13525
13835
|
);
|
|
13526
13836
|
if (missing.length === 0) return null;
|
|
13527
|
-
const key =
|
|
13528
|
-
const directory =
|
|
13529
|
-
const mapPath =
|
|
13530
|
-
if (!
|
|
13531
|
-
|
|
13837
|
+
const key = createHash15("sha256").update(modules).update(missing.map((mod) => `${mod.name}\0${mod.source}`).join("\0")).digest("hex").slice(0, 16);
|
|
13838
|
+
const directory = path30.join(root, `.peach-clang-modules-${key}`);
|
|
13839
|
+
const mapPath = path30.join(directory, "module.modulemap");
|
|
13840
|
+
if (!existsSync7(mapPath)) {
|
|
13841
|
+
mkdirSync8(directory, { recursive: true });
|
|
13532
13842
|
const parts = [];
|
|
13533
13843
|
for (const mod of missing) {
|
|
13534
|
-
const destination =
|
|
13535
|
-
|
|
13536
|
-
|
|
13844
|
+
const destination = path30.join(directory, mod.header);
|
|
13845
|
+
mkdirSync8(path30.dirname(destination), { recursive: true });
|
|
13846
|
+
writeFileSync9(destination, mod.source);
|
|
13537
13847
|
parts.push(
|
|
13538
13848
|
`module ${mod.name} {
|
|
13539
13849
|
requires objc
|
|
@@ -13543,7 +13853,7 @@ function distributionClangModuleMap(root, modules) {
|
|
|
13543
13853
|
`
|
|
13544
13854
|
);
|
|
13545
13855
|
}
|
|
13546
|
-
|
|
13856
|
+
writeFileSync9(mapPath, parts.join("\n"));
|
|
13547
13857
|
}
|
|
13548
13858
|
return mapPath;
|
|
13549
13859
|
}
|
|
@@ -13554,17 +13864,17 @@ function distributionClangModuleOptions(root, modules) {
|
|
|
13554
13864
|
function providedModulesPath(root, modules, excluded) {
|
|
13555
13865
|
if (!excluded || excluded.size === 0) return modules;
|
|
13556
13866
|
const entries = readdirSync8(modules).filter((entry) => !excluded.has(entry.replace(/\..*$/, ""))).sort();
|
|
13557
|
-
const key =
|
|
13558
|
-
const directory =
|
|
13559
|
-
const complete =
|
|
13560
|
-
if (!
|
|
13561
|
-
|
|
13867
|
+
const key = createHash15("sha256").update(JSON.stringify([modules, entries])).update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
|
|
13868
|
+
const directory = path30.join(root, `.peach-modules-${key}`);
|
|
13869
|
+
const complete = path30.join(directory, ".complete");
|
|
13870
|
+
if (!existsSync7(complete)) {
|
|
13871
|
+
mkdirSync8(directory, { recursive: true });
|
|
13562
13872
|
for (const entry of readdirSync8(directory))
|
|
13563
|
-
|
|
13873
|
+
rmSync8(path30.join(directory, entry), { recursive: true, force: true });
|
|
13564
13874
|
for (const entry of entries) {
|
|
13565
|
-
symlinkSync2(
|
|
13875
|
+
symlinkSync2(path30.join(modules, entry), path30.join(directory, entry));
|
|
13566
13876
|
}
|
|
13567
|
-
|
|
13877
|
+
writeFileSync9(complete, "");
|
|
13568
13878
|
}
|
|
13569
13879
|
return directory;
|
|
13570
13880
|
}
|
|
@@ -13576,7 +13886,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
|
|
|
13576
13886
|
);
|
|
13577
13887
|
const names = /* @__PURE__ */ new Set([...frameworks, ...targets.map((target) => target.name)]);
|
|
13578
13888
|
const entriesByPrefix = new Map(
|
|
13579
|
-
targets.map(({ path:
|
|
13889
|
+
targets.map(({ path: path31 }) => [path31 === "." ? "" : `${path31}/`, []])
|
|
13580
13890
|
);
|
|
13581
13891
|
for (const entry of Object.entries(files)) {
|
|
13582
13892
|
const [file] = entry;
|
|
@@ -13611,7 +13921,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
|
|
|
13611
13921
|
(excluded) => relative === excluded || relative.startsWith(`${excluded}/`)
|
|
13612
13922
|
))
|
|
13613
13923
|
continue;
|
|
13614
|
-
if (nested.some((
|
|
13924
|
+
if (nested.some((path31) => file.startsWith(path31))) continue;
|
|
13615
13925
|
const imports = file.endsWith(".swift") ? swiftImportNames(contents2) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents2, ownsHeader) : [];
|
|
13616
13926
|
for (const name2 of imports) {
|
|
13617
13927
|
if (names.has(name2) && name2 !== target.name && !(target.dependencies !== void 0 && localNames.has(name2)))
|
|
@@ -13658,7 +13968,7 @@ var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
|
|
|
13658
13968
|
).join("");
|
|
13659
13969
|
var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
13660
13970
|
var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
13661
|
-
"-Xclang-linker", ${JSON.stringify(`-fuse-ld=${
|
|
13971
|
+
"-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path30.join(root, SWIFT_AUTOLINK_LINKER)}`)},
|
|
13662
13972
|
"-Xlinker", "-z", "-Xlinker", "stack-size=8372224",
|
|
13663
13973
|
"-Xlinker", "--stack-first",
|
|
13664
13974
|
"-Xlinker", "--global-base=8372224",
|
|
@@ -13672,11 +13982,11 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
|
13672
13982
|
`;
|
|
13673
13983
|
var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...quoted2, "-Wl,--end-lib"] : [];
|
|
13674
13984
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
13675
|
-
var MULTI_MANIFEST_VERSION =
|
|
13985
|
+
var MULTI_MANIFEST_VERSION = 72;
|
|
13676
13986
|
var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
13677
|
-
var compilerSourceDigest = true ? "
|
|
13987
|
+
var compilerSourceDigest = true ? "886349932526d72a5a1493acbcd1799ec941afd89998ad0eab64bbe9c48afb95" : swiftCompilerSourceDigest(import.meta.dirname);
|
|
13678
13988
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
13679
|
-
const hash =
|
|
13989
|
+
const hash = createHash15("sha256");
|
|
13680
13990
|
hash.update(`swift-compile
|
|
13681
13991
|
${release}
|
|
13682
13992
|
`);
|
|
@@ -13689,32 +13999,32 @@ ${WASM_LOWER_IDENTITY}
|
|
|
13689
13999
|
`);
|
|
13690
14000
|
if (input.optimize) hash.update("optimize\n");
|
|
13691
14001
|
for (const file of Object.keys(input.files).sort()) {
|
|
13692
|
-
hash.update(
|
|
13693
|
-
hash.update(
|
|
14002
|
+
hash.update(createHash15("sha256").update(file).digest());
|
|
14003
|
+
hash.update(createHash15("sha256").update(input.files[file]).digest());
|
|
13694
14004
|
}
|
|
13695
14005
|
for (const file of Object.keys(input.metalSources ?? {}).sort()) {
|
|
13696
14006
|
hash.update("metal-source\n");
|
|
13697
|
-
hash.update(
|
|
14007
|
+
hash.update(createHash15("sha256").update(file).digest());
|
|
13698
14008
|
hash.update(
|
|
13699
|
-
|
|
14009
|
+
createHash15("sha256").update(input.metalSources?.[file] ?? "").digest()
|
|
13700
14010
|
);
|
|
13701
14011
|
}
|
|
13702
14012
|
for (const base of Object.keys(input.resources ?? {}).sort()) {
|
|
13703
|
-
hash.update(
|
|
14013
|
+
hash.update(createHash15("sha256").update(base).digest());
|
|
13704
14014
|
hash.update(
|
|
13705
|
-
|
|
14015
|
+
createHash15("sha256").update(input.resources?.[base] ?? "").digest()
|
|
13706
14016
|
);
|
|
13707
14017
|
}
|
|
13708
14018
|
for (const name2 of Object.keys(input.images ?? {}).sort()) {
|
|
13709
14019
|
const image = input.images?.[name2];
|
|
13710
14020
|
if (!image) continue;
|
|
13711
|
-
hash.update(
|
|
13712
|
-
hash.update(
|
|
13713
|
-
hash.update(
|
|
14021
|
+
hash.update(createHash15("sha256").update(name2).digest());
|
|
14022
|
+
hash.update(createHash15("sha256").update(image.file).digest());
|
|
14023
|
+
hash.update(createHash15("sha256").update(image.data).digest());
|
|
13714
14024
|
}
|
|
13715
14025
|
for (const file of [...new Set(input.resourcePaths ?? [])].sort()) {
|
|
13716
14026
|
hash.update("resource-path\n");
|
|
13717
|
-
hash.update(
|
|
14027
|
+
hash.update(createHash15("sha256").update(file).digest());
|
|
13718
14028
|
}
|
|
13719
14029
|
hash.update(
|
|
13720
14030
|
JSON.stringify(
|
|
@@ -13732,18 +14042,18 @@ ${input.defaultLocalization}
|
|
|
13732
14042
|
`);
|
|
13733
14043
|
for (const file of Object.keys(input.packageFiles ?? {}).sort()) {
|
|
13734
14044
|
hash.update(`package-file\0${file}\0`);
|
|
13735
|
-
hash.update(
|
|
14045
|
+
hash.update(createHash15("sha256").update(input.packageFiles[file]).digest());
|
|
13736
14046
|
}
|
|
13737
14047
|
for (const file of Object.keys(input.projectFiles ?? {}).sort()) {
|
|
13738
14048
|
hash.update(`project-file\0${file}\0`);
|
|
13739
|
-
hash.update(
|
|
14049
|
+
hash.update(createHash15("sha256").update(input.projectFiles[file]).digest());
|
|
13740
14050
|
}
|
|
13741
14051
|
for (const target of Object.keys(input.libraries ?? {}).sort()) {
|
|
13742
14052
|
hash.update(`library
|
|
13743
14053
|
${target}
|
|
13744
14054
|
`);
|
|
13745
14055
|
hash.update(
|
|
13746
|
-
|
|
14056
|
+
createHash15("sha256").update(input.libraries?.[target] ?? "").digest()
|
|
13747
14057
|
);
|
|
13748
14058
|
}
|
|
13749
14059
|
for (const [name2, bytes] of Object.entries(input.binaryModules ?? {}).sort())
|
|
@@ -13767,7 +14077,7 @@ var nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
|
13767
14077
|
var cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|
|
13768
14078
|
var cxxFlagArray = (flags) => JSON.stringify([...nativeCxxCompilerFlags, ...withoutGlogModuleMap(flags)]);
|
|
13769
14079
|
function swiftCrossImportFlags(moduleRoot, distribution) {
|
|
13770
|
-
const overlayRoot =
|
|
14080
|
+
const overlayRoot = path30.join(
|
|
13771
14081
|
moduleRoot,
|
|
13772
14082
|
distribution ? "modules" : "cross-import-overlays"
|
|
13773
14083
|
);
|
|
@@ -13775,9 +14085,9 @@ function swiftCrossImportFlags(moduleRoot, distribution) {
|
|
|
13775
14085
|
"-Xfrontend",
|
|
13776
14086
|
"-swift-module-cross-import",
|
|
13777
14087
|
"-Xfrontend",
|
|
13778
|
-
|
|
14088
|
+
path30.basename(path30.dirname(file), ".swiftcrossimport"),
|
|
13779
14089
|
"-Xfrontend",
|
|
13780
|
-
|
|
14090
|
+
path30.join(overlayRoot, file)
|
|
13781
14091
|
]);
|
|
13782
14092
|
}
|
|
13783
14093
|
function withoutWasmOverlayIsystem(flags) {
|
|
@@ -13817,7 +14127,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13817
14127
|
if (!flag.startsWith("-fmodule-map-file=")) return false;
|
|
13818
14128
|
const file = flag.slice("-fmodule-map-file=".length).replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root);
|
|
13819
14129
|
if (!file.includes("/Pods/Headers/")) return false;
|
|
13820
|
-
const map = args.files.get(file) ?? (
|
|
14130
|
+
const map = args.files.get(file) ?? (existsSync7(file) ? readFileSync18(file) : void 0);
|
|
13821
14131
|
const name2 = map === void 0 ? void 0 : moduleMapName(map.toString());
|
|
13822
14132
|
return name2 !== void 0 && packageModules.has(name2);
|
|
13823
14133
|
};
|
|
@@ -13849,7 +14159,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13849
14159
|
const product = v5.parse(
|
|
13850
14160
|
swiftFrameworkProductSchema,
|
|
13851
14161
|
JSON.parse(
|
|
13852
|
-
|
|
14162
|
+
readFileSync18(path30.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
|
|
13853
14163
|
)
|
|
13854
14164
|
);
|
|
13855
14165
|
const replacedObjects = new Set(
|
|
@@ -13863,7 +14173,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13863
14173
|
(name2) => !object3.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
|
|
13864
14174
|
)
|
|
13865
14175
|
);
|
|
13866
|
-
const quoted2 = (object3) => `"${
|
|
14176
|
+
const quoted2 = (object3) => `"${path30.join(moduleRoot, object3).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
13867
14177
|
const categoryObjects = new Set(
|
|
13868
14178
|
foundationCategoryObjects.map((name2) => `lib/Foundation-${name2}.o`)
|
|
13869
14179
|
);
|
|
@@ -13880,7 +14190,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13880
14190
|
].join("\n") + "\n";
|
|
13881
14191
|
distributionLinkPath = distributionLink.path.replace(
|
|
13882
14192
|
/\.rsp$/,
|
|
13883
|
-
`-${
|
|
14193
|
+
`-${createHash15("sha256").update(list).digest("hex").slice(0, 12)}.rsp`
|
|
13884
14194
|
);
|
|
13885
14195
|
distributionLink.files.set(distributionLinkPath, list);
|
|
13886
14196
|
}
|
|
@@ -13897,8 +14207,8 @@ function emitSwiftPackageManifest(args) {
|
|
|
13897
14207
|
const macroSettings = (values) => (values ?? []).map((value) => ` ${clangMacroSetting(value)},`).join("");
|
|
13898
14208
|
const flagArray = (literal2) => {
|
|
13899
14209
|
const content = literal2.replace(/,\s*]$/, "]");
|
|
13900
|
-
const digest =
|
|
13901
|
-
const file =
|
|
14210
|
+
const digest = createHash15("sha256").update(content).digest("hex");
|
|
14211
|
+
const file = path30.join(args.root, ".peach-manifest-arguments", `${digest}.json`);
|
|
13902
14212
|
args.files.set(file, content);
|
|
13903
14213
|
return `peachCompilerArguments(${JSON.stringify(file)})`;
|
|
13904
14214
|
};
|
|
@@ -13909,8 +14219,8 @@ function emitSwiftPackageManifest(args) {
|
|
|
13909
14219
|
const macros = compactSwiftClangDefines(flags);
|
|
13910
14220
|
const compact = args.coalescibleOverlays ? compactSwiftClangOverlays(macros, args.coalescibleOverlays) : macros;
|
|
13911
14221
|
const content = compact.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
|
|
13912
|
-
const digest =
|
|
13913
|
-
const file =
|
|
14222
|
+
const digest = createHash15("sha256").update(content).digest("hex");
|
|
14223
|
+
const file = path30.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
|
|
13914
14224
|
args.files.set(file, content);
|
|
13915
14225
|
return JSON.stringify([`@${file}`]);
|
|
13916
14226
|
};
|
|
@@ -13922,7 +14232,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13922
14232
|
owner?.publicHeadersPath ?? ""
|
|
13923
14233
|
);
|
|
13924
14234
|
return [
|
|
13925
|
-
...owner && framework ? [
|
|
14235
|
+
...owner && framework ? [path30.posix.join(args.root, owner.path, framework[1])] : [],
|
|
13926
14236
|
...frameworkDirectories(dependency, seen)
|
|
13927
14237
|
];
|
|
13928
14238
|
});
|
|
@@ -13944,7 +14254,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13944
14254
|
const stanza = (target) => {
|
|
13945
14255
|
const native = args.native?.get(target.name);
|
|
13946
14256
|
if (target.systemLibrary || native?.clang?.sources.length === 0)
|
|
13947
|
-
return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ?
|
|
14257
|
+
return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? path30.posix.dirname(native.clang.modulemap) : target.path)}),`;
|
|
13948
14258
|
const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
|
|
13949
14259
|
const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
|
|
13950
14260
|
const defines = (target.defines ?? []).map((name2) => ` .define(${JSON.stringify(name2)}),`).join("");
|
|
@@ -13957,10 +14267,10 @@ function emitSwiftPackageManifest(args) {
|
|
|
13957
14267
|
const imports = binaryImports + (distribution ? `, "-Isystem", ${JSON.stringify(
|
|
13958
14268
|
providedModulesPath(
|
|
13959
14269
|
args.root,
|
|
13960
|
-
|
|
14270
|
+
path30.join(moduleRoot, "modules"),
|
|
13961
14271
|
args.moduleExcludes
|
|
13962
14272
|
)
|
|
13963
|
-
)}${distributionClangModuleOptions(args.root,
|
|
14273
|
+
)}${distributionClangModuleOptions(args.root, path30.join(moduleRoot, "modules")).map((flag) => `, ${JSON.stringify(flag)}`).join("")}` : prebuilt ? `, "-Isystem", ${JSON.stringify(providedModulesPath(args.root, prebuilt.modules, args.moduleExcludes))}${prebuilt.moduleMaps.map((map) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map}`)}`).join("")}` : "");
|
|
13964
14274
|
const nativeFlags = [
|
|
13965
14275
|
...args.nativeFlags?.get(target.name) ?? [],
|
|
13966
14276
|
...args.nativeHeaderFlags ?? []
|
|
@@ -13999,7 +14309,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13999
14309
|
].map((flag) => `, ${JSON.stringify(flag)}`).join("");
|
|
14000
14310
|
const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || [...args.native?.values() ?? []].some(
|
|
14001
14311
|
(value) => value.late?.producers.includes(target.name)
|
|
14002
|
-
)) ? `, "-emit-objc-header-path", ${JSON.stringify(
|
|
14312
|
+
)) ? `, "-emit-objc-header-path", ${JSON.stringify(path30.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
|
|
14003
14313
|
const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
|
|
14004
14314
|
const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
|
|
14005
14315
|
const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImportFlags}${objcFlags}${header}${clangMode}${deployment}${upstream}]`)})]`;
|
|
@@ -14168,19 +14478,19 @@ function emitSwiftPackageManifest(args) {
|
|
|
14168
14478
|
].join("\n");
|
|
14169
14479
|
}
|
|
14170
14480
|
function syncSwiftTree(base, files) {
|
|
14171
|
-
|
|
14481
|
+
mkdirSync8(base, { recursive: true });
|
|
14172
14482
|
const kept = /* @__PURE__ */ new Set();
|
|
14173
|
-
for (const file of files.keys()) if (
|
|
14483
|
+
for (const file of files.keys()) if (existsSync7(file)) kept.add(statSync3(file).ino);
|
|
14174
14484
|
const walk = (dir) => {
|
|
14175
14485
|
for (const entry of readdirSync8(dir, { withFileTypes: true })) {
|
|
14176
|
-
const full =
|
|
14486
|
+
const full = path30.join(dir, entry.name);
|
|
14177
14487
|
if (dir === base && (entry.name === ".build" || entry.name.startsWith(".peach-modules-") || // distribution clang maps are written beside the project and named
|
|
14178
14488
|
// from the compiler flags, so a sync must not remove them.
|
|
14179
14489
|
entry.name.startsWith(".peach-clang-modules-") || entry.name === SWIFT_LINK_STAMP))
|
|
14180
14490
|
continue;
|
|
14181
14491
|
if (entry.isDirectory()) walk(full);
|
|
14182
14492
|
else if (!files.has(full) && !kept.has(lstatSync(full).ino))
|
|
14183
|
-
|
|
14493
|
+
rmSync8(full, { force: true });
|
|
14184
14494
|
}
|
|
14185
14495
|
};
|
|
14186
14496
|
walk(base);
|
|
@@ -14328,7 +14638,7 @@ function compiledSwiftSources(files, targets, overlayFrameworks, headers, native
|
|
|
14328
14638
|
const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
|
|
14329
14639
|
return new Map(
|
|
14330
14640
|
[...owners].map(([file, { source, owner }]) => {
|
|
14331
|
-
if (nativeSourceGlue &&
|
|
14641
|
+
if (nativeSourceGlue && path30.posix.basename(file) === "OneNativeSource.generated.swift")
|
|
14332
14642
|
return [file, source];
|
|
14333
14643
|
const manifest = /(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file);
|
|
14334
14644
|
if (manifest && (!owner || /^Package(?:@swift-[\d.]+)?\.swift$/.test(file)))
|
|
@@ -14525,7 +14835,6 @@ var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
|
|
|
14525
14835
|
"NSSwappedDouble",
|
|
14526
14836
|
"NSSwappedFloat",
|
|
14527
14837
|
"NSUbiquitousKeyValueStore",
|
|
14528
|
-
"NSValueTransformerName",
|
|
14529
14838
|
"NSXPCCoder",
|
|
14530
14839
|
"NSXPCConnection",
|
|
14531
14840
|
"NSXPCInterface",
|
|
@@ -14548,7 +14857,6 @@ var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
|
|
|
14548
14857
|
]);
|
|
14549
14858
|
var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
14550
14859
|
"CFBridgingRetain",
|
|
14551
|
-
"NSASCIIStringEncoding",
|
|
14552
14860
|
"NSAllHashTableObjects",
|
|
14553
14861
|
"NSAllMapTableKeys",
|
|
14554
14862
|
"NSAllMapTableValues",
|
|
@@ -14627,21 +14935,16 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14627
14935
|
"NSHashTableWeakMemory",
|
|
14628
14936
|
"NSHebrewCalendar",
|
|
14629
14937
|
"NSHostByteOrder",
|
|
14630
|
-
"NSISO2022JPStringEncoding",
|
|
14631
14938
|
"NSISO8601Calendar",
|
|
14632
|
-
"NSISOLatin1StringEncoding",
|
|
14633
|
-
"NSISOLatin2StringEncoding",
|
|
14634
14939
|
"NSIndianCalendar",
|
|
14635
14940
|
"NSIslamicCalendar",
|
|
14636
14941
|
"NSIslamicCivilCalendar",
|
|
14637
14942
|
"NSItemProviderPreferredImageSizeKey",
|
|
14638
14943
|
"NSJapaneseCalendar",
|
|
14639
|
-
"NSJapaneseEUCStringEncoding",
|
|
14640
14944
|
"NSLoadedClasses",
|
|
14641
14945
|
"NSLocalizedFailureErrorKey",
|
|
14642
14946
|
"NSLogPageSize",
|
|
14643
14947
|
"NSMACHOperatingSystem",
|
|
14644
|
-
"NSMacOSRomanStringEncoding",
|
|
14645
14948
|
"NSMapGet",
|
|
14646
14949
|
"NSMapInsert",
|
|
14647
14950
|
"NSMapInsertIfAbsent",
|
|
@@ -14653,10 +14956,8 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14653
14956
|
"NSMapTableStrongMemory",
|
|
14654
14957
|
"NSMapTableWeakMemory",
|
|
14655
14958
|
"NSMultipleUnderlyingErrorsKey",
|
|
14656
|
-
"NSNEXTSTEPStringEncoding",
|
|
14657
14959
|
"NSNextHashEnumeratorItem",
|
|
14658
14960
|
"NSNextMapEnumeratorPair",
|
|
14659
|
-
"NSNonLossyASCIIStringEncoding",
|
|
14660
14961
|
"NSNonOwnedPointerHashCallBacks",
|
|
14661
14962
|
"NSNonOwnedPointerMapKeyCallBacks",
|
|
14662
14963
|
"NSNonOwnedPointerMapValueCallBacks",
|
|
@@ -14678,12 +14979,10 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14678
14979
|
"NSPointerToStructHashCallBacks",
|
|
14679
14980
|
"NSPropertyListErrorMaximum",
|
|
14680
14981
|
"NSPropertyListErrorMinimum",
|
|
14681
|
-
"NSProprietaryStringEncoding",
|
|
14682
14982
|
"NSProtocolFromString",
|
|
14683
14983
|
"NSRepublicOfChinaCalendar",
|
|
14684
14984
|
"NSResetHashTable",
|
|
14685
14985
|
"NSResetMapTable",
|
|
14686
|
-
"NSShiftJISStringEncoding",
|
|
14687
14986
|
"NSSolarisOperatingSystem",
|
|
14688
14987
|
"NSStringFromHashTable",
|
|
14689
14988
|
"NSStringFromMapTable",
|
|
@@ -14719,7 +15018,6 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14719
15018
|
"NSSwapLong",
|
|
14720
15019
|
"NSSwapLongLong",
|
|
14721
15020
|
"NSSwapShort",
|
|
14722
|
-
"NSSymbolStringEncoding",
|
|
14723
15021
|
"NSTextCheckingAllCustomTypes",
|
|
14724
15022
|
"NSTextCheckingAllSystemTypes",
|
|
14725
15023
|
"NSTextCheckingAllTypes",
|
|
@@ -14737,13 +15035,6 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14737
15035
|
"NSURLProtectionSpaceHTTPSProxy",
|
|
14738
15036
|
"NSURLProtectionSpaceSOCKSProxy",
|
|
14739
15037
|
"NSURLSessionUploadTaskResumeData",
|
|
14740
|
-
"NSUTF16BigEndianStringEncoding",
|
|
14741
|
-
"NSUTF16LittleEndianStringEncoding",
|
|
14742
|
-
"NSUTF16StringEncoding",
|
|
14743
|
-
"NSUTF32BigEndianStringEncoding",
|
|
14744
|
-
"NSUTF32LittleEndianStringEncoding",
|
|
14745
|
-
"NSUTF32StringEncoding",
|
|
14746
|
-
"NSUTF8StringEncoding",
|
|
14747
15038
|
"NSUbiquitousFileErrorMaximum",
|
|
14748
15039
|
"NSUbiquitousFileErrorMinimum",
|
|
14749
15040
|
"NSUbiquitousKeyValueStoreAccountChange",
|
|
@@ -14755,17 +15046,11 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14755
15046
|
"NSUndefinedDateComponent",
|
|
14756
15047
|
"NSUndoCloseGroupingRunLoopOrdering",
|
|
14757
15048
|
"NSUndoManagerGroupIsDiscardableKey",
|
|
14758
|
-
"NSUnicodeStringEncoding",
|
|
14759
15049
|
"NSUserActivityErrorMaximum",
|
|
14760
15050
|
"NSUserActivityErrorMinimum",
|
|
14761
15051
|
"NSValidationErrorMaximum",
|
|
14762
15052
|
"NSValidationErrorMinimum",
|
|
14763
15053
|
"NSWindows95OperatingSystem",
|
|
14764
|
-
"NSWindowsCP1250StringEncoding",
|
|
14765
|
-
"NSWindowsCP1251StringEncoding",
|
|
14766
|
-
"NSWindowsCP1252StringEncoding",
|
|
14767
|
-
"NSWindowsCP1253StringEncoding",
|
|
14768
|
-
"NSWindowsCP1254StringEncoding",
|
|
14769
15054
|
"NSWindowsNTOperatingSystem",
|
|
14770
15055
|
"NSWrapCalendarComponents",
|
|
14771
15056
|
"NSXPCConnectionCodeSigningRequirementFailure",
|
|
@@ -15086,7 +15371,7 @@ function swiftApplicationEntry(file, source) {
|
|
|
15086
15371
|
else if (source[at] === "}") depth--;
|
|
15087
15372
|
else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
|
|
15088
15373
|
return true;
|
|
15089
|
-
else if (depth === 0 &&
|
|
15374
|
+
else if (depth === 0 && path30.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
|
|
15090
15375
|
return true;
|
|
15091
15376
|
}
|
|
15092
15377
|
return false;
|
|
@@ -15201,11 +15486,11 @@ function objcApplicationMainCall(source) {
|
|
|
15201
15486
|
if (principal === null || delegate === null) return null;
|
|
15202
15487
|
return { principal, delegate };
|
|
15203
15488
|
}
|
|
15204
|
-
function objcMainCallArgument(
|
|
15205
|
-
if (/^(?:nil|NULL|Nil)$/.test(
|
|
15206
|
-
const literal2 = /^@"((?:[^"\\]|\\.)*)"$/.exec(
|
|
15489
|
+
function objcMainCallArgument(argument2) {
|
|
15490
|
+
if (/^(?:nil|NULL|Nil)$/.test(argument2)) return "nil";
|
|
15491
|
+
const literal2 = /^@"((?:[^"\\]|\\.)*)"$/.exec(argument2);
|
|
15207
15492
|
if (literal2) return `"${literal2[1]}"`;
|
|
15208
|
-
const name2 = /^NSStringFromClass\(\[([A-Za-z_]\w*) class\]\)$/.exec(
|
|
15493
|
+
const name2 = /^NSStringFromClass\(\[([A-Za-z_]\w*) class\]\)$/.exec(argument2);
|
|
15209
15494
|
if (name2) return `"${name2[1]}"`;
|
|
15210
15495
|
return null;
|
|
15211
15496
|
}
|
|
@@ -15474,6 +15759,18 @@ function swiftCMainEntry(file, source, env = emptyMacroEnvironment) {
|
|
|
15474
15759
|
}
|
|
15475
15760
|
return false;
|
|
15476
15761
|
}
|
|
15762
|
+
var SWIFT_SCAN_KEYWORDS = {
|
|
15763
|
+
c: "class",
|
|
15764
|
+
e: "extension",
|
|
15765
|
+
o: "override",
|
|
15766
|
+
i: "import",
|
|
15767
|
+
f: "func",
|
|
15768
|
+
U: "UIApplicationMain",
|
|
15769
|
+
F: "Foundation",
|
|
15770
|
+
C: "CoreFoundation",
|
|
15771
|
+
O: "ObjectiveC",
|
|
15772
|
+
_: "_LocationEssentials"
|
|
15773
|
+
};
|
|
15477
15774
|
function swiftCodeScan(source) {
|
|
15478
15775
|
const starts = /* @__PURE__ */ new Set();
|
|
15479
15776
|
const tokens = [];
|
|
@@ -15556,8 +15853,8 @@ function swiftCodeScan(source) {
|
|
|
15556
15853
|
else top.parens--;
|
|
15557
15854
|
i++;
|
|
15558
15855
|
} else {
|
|
15559
|
-
const keyword =
|
|
15560
|
-
if (keyword && !/[\w$]/.test(source[i - 1] ?? "") && !/[\w$]/.test(source[i + keyword.length] ?? "")) {
|
|
15856
|
+
const keyword = SWIFT_SCAN_KEYWORDS[char];
|
|
15857
|
+
if (keyword && source.startsWith(keyword, i) && !/[\w$]/.test(source[i - 1] ?? "") && !/[\w$]/.test(source[i + keyword.length] ?? "")) {
|
|
15561
15858
|
tokens.push(i);
|
|
15562
15859
|
i += keyword.length;
|
|
15563
15860
|
} else {
|
|
@@ -15569,27 +15866,27 @@ function swiftCodeScan(source) {
|
|
|
15569
15866
|
return { lineStarts: starts, tokens };
|
|
15570
15867
|
}
|
|
15571
15868
|
function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
15572
|
-
|
|
15869
|
+
rmSync8(destination, { recursive: true, force: true });
|
|
15573
15870
|
const origins = {};
|
|
15574
15871
|
const moduleMaps = [];
|
|
15575
15872
|
const gather = (from) => {
|
|
15576
15873
|
for (const entry of readdirSync8(from, { withFileTypes: true })) {
|
|
15577
15874
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
15578
15875
|
continue;
|
|
15579
|
-
const file =
|
|
15876
|
+
const file = path30.join(from, entry.name);
|
|
15580
15877
|
if (entry.isDirectory()) gather(file);
|
|
15581
15878
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
15582
|
-
origins[
|
|
15879
|
+
origins[path30.relative(source, file)] = readFileSync18(file, "utf8");
|
|
15583
15880
|
else if (entry.isFile() && entry.name.endsWith(".modulemap"))
|
|
15584
|
-
moduleMaps.push(
|
|
15881
|
+
moduleMaps.push(readFileSync18(file, "utf8"));
|
|
15585
15882
|
}
|
|
15586
15883
|
};
|
|
15587
15884
|
gather(source);
|
|
15588
|
-
const manifest =
|
|
15589
|
-
const targets =
|
|
15590
|
-
|
|
15885
|
+
const manifest = path30.join(source, "Package.swift");
|
|
15886
|
+
const targets = existsSync7(manifest) ? swiftManifestTargets(
|
|
15887
|
+
readFileSync18(manifest, "utf8"),
|
|
15591
15888
|
[],
|
|
15592
|
-
(file) =>
|
|
15889
|
+
(file) => readFileSync18(file, "utf8")
|
|
15593
15890
|
) : [];
|
|
15594
15891
|
let dependencyOverlays;
|
|
15595
15892
|
const compiled = compiledSwiftSources(
|
|
@@ -15613,15 +15910,15 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
|
15613
15910
|
() => []
|
|
15614
15911
|
);
|
|
15615
15912
|
const copy = (from, to) => {
|
|
15616
|
-
|
|
15913
|
+
mkdirSync8(to, { recursive: true });
|
|
15617
15914
|
for (const entry of readdirSync8(from, { withFileTypes: true })) {
|
|
15618
15915
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
15619
15916
|
continue;
|
|
15620
|
-
const file =
|
|
15621
|
-
const target =
|
|
15917
|
+
const file = path30.join(from, entry.name);
|
|
15918
|
+
const target = path30.join(to, entry.name);
|
|
15622
15919
|
if (entry.isDirectory()) copy(file, target);
|
|
15623
15920
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
15624
|
-
|
|
15921
|
+
writeFileSync9(target, compiled.get(path30.relative(source, file)));
|
|
15625
15922
|
else cpSync(file, target, { verbatimSymlinks: true });
|
|
15626
15923
|
}
|
|
15627
15924
|
};
|
|
@@ -15643,18 +15940,18 @@ function swiftWholeFileArm64Guard(source) {
|
|
|
15643
15940
|
}
|
|
15644
15941
|
function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
|
|
15645
15942
|
const searched = new Set(settings.headerSearchPaths);
|
|
15646
|
-
const directory =
|
|
15943
|
+
const directory = path30.join(layoutRoot, ".build", "peach-clang-modulemaps");
|
|
15647
15944
|
return (settings.moduleMaps ?? []).flatMap((map) => {
|
|
15648
|
-
const headers =
|
|
15649
|
-
if (!
|
|
15650
|
-
const published =
|
|
15651
|
-
if (searched.has(map.headers) &&
|
|
15652
|
-
if (!searched.has(map.headers) &&
|
|
15945
|
+
const headers = path30.join(layoutRoot, map.headers);
|
|
15946
|
+
if (!existsSync7(headers)) return [];
|
|
15947
|
+
const published = path30.join(headers, "module.modulemap");
|
|
15948
|
+
if (searched.has(map.headers) && existsSync7(published)) return [];
|
|
15949
|
+
if (!searched.has(map.headers) && existsSync7(published))
|
|
15653
15950
|
return [`-fmodule-map-file=${published}`];
|
|
15654
15951
|
const cached = written.get(headers);
|
|
15655
15952
|
if (cached) return [cached];
|
|
15656
|
-
|
|
15657
|
-
const output =
|
|
15953
|
+
mkdirSync8(directory, { recursive: true });
|
|
15954
|
+
const output = path30.join(directory, `module-${written.size}.modulemap`);
|
|
15658
15955
|
writeBuildFile(
|
|
15659
15956
|
output,
|
|
15660
15957
|
swiftPackageClangModuleMap(swiftTargetModuleName(map.module), {
|
|
@@ -15688,7 +15985,7 @@ function needsNativeToolset(input, prebuilt) {
|
|
|
15688
15985
|
input.packageFiles || prebuilt || Object.keys(input.files).some(isSwiftNativeTranslationUnit)
|
|
15689
15986
|
);
|
|
15690
15987
|
}
|
|
15691
|
-
function writeSwiftProject(layout2, input, moduleRoot, prebuilt) {
|
|
15988
|
+
function writeSwiftProject(layout2, input, moduleRoot, prebuilt, allowHeaderCompiler = false) {
|
|
15692
15989
|
const nativeToolset = needsNativeToolset(input, prebuilt);
|
|
15693
15990
|
if (input.headerAliases !== void 0 && !isSwiftHeaderAliases(input.headerAliases))
|
|
15694
15991
|
throw new Error("swift compile input has invalid original header aliases");
|
|
@@ -15719,7 +16016,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15719
16016
|
const targets = distribution && compileTargets(input).length === 0 ? [
|
|
15720
16017
|
{
|
|
15721
16018
|
name: "App",
|
|
15722
|
-
path:
|
|
16019
|
+
path: path30.relative(layout2.root, layout2.sources),
|
|
15723
16020
|
executable: true,
|
|
15724
16021
|
languageMode: 5,
|
|
15725
16022
|
mainActorIsolation: false,
|
|
@@ -15745,12 +16042,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15745
16042
|
if (!file.endsWith(".swift")) continue;
|
|
15746
16043
|
const target = bySourcePath.find(
|
|
15747
16044
|
(candidate) => (candidate.path === "." || file.startsWith(`${candidate.path}/`)) && (candidate.sources === void 0 || candidate.sources.some((source) => {
|
|
15748
|
-
const selected =
|
|
16045
|
+
const selected = path30.posix.join(candidate.path, source);
|
|
15749
16046
|
return file === selected || file.startsWith(`${selected}/`);
|
|
15750
16047
|
}))
|
|
15751
16048
|
);
|
|
15752
16049
|
const excluded = target?.exclude?.some(
|
|
15753
|
-
(name2) => file ===
|
|
16050
|
+
(name2) => file === path30.posix.join(target.path, name2)
|
|
15754
16051
|
);
|
|
15755
16052
|
if (target && !excluded) swiftTargets.add(target.name);
|
|
15756
16053
|
}
|
|
@@ -15776,24 +16073,24 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15776
16073
|
([file, contents2]) => file.endsWith(".swift") ? [contents2] : []
|
|
15777
16074
|
)
|
|
15778
16075
|
);
|
|
15779
|
-
const headerDirectory =
|
|
16076
|
+
const headerDirectory = path30.join(layout2.root, ".build", "peach-cxx-headers");
|
|
15780
16077
|
const flattenedHeaders = /* @__PURE__ */ new Set();
|
|
15781
|
-
if (
|
|
16078
|
+
if (existsSync7(headerDirectory)) {
|
|
15782
16079
|
for (const entry of readdirSync8(headerDirectory, { withFileTypes: true }))
|
|
15783
16080
|
if (entry.isDirectory() && !targets.some((target) => target.name === entry.name))
|
|
15784
|
-
|
|
16081
|
+
rmSync8(path30.join(headerDirectory, entry.name), { recursive: true, force: true });
|
|
15785
16082
|
}
|
|
15786
16083
|
let checkedToolchain;
|
|
15787
16084
|
const nativeToolchain = () => {
|
|
15788
16085
|
if (checkedToolchain) return checkedToolchain;
|
|
15789
|
-
const pin = distribution ?? JSON.parse(
|
|
16086
|
+
const pin = distribution ?? JSON.parse(readFileSync18(path30.join(moduleRoot, "toolchain.json"), "utf8"));
|
|
15790
16087
|
checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
|
|
15791
16088
|
return checkedToolchain;
|
|
15792
16089
|
};
|
|
15793
16090
|
const deploymentTarget = (name2) => input.nativeTargets?.find((value) => value.name === name2)?.deploymentTarget ?? targets.find((value) => value.name === name2)?.iosDeploymentTarget ?? null;
|
|
15794
16091
|
const targetStagedFiles = /* @__PURE__ */ new Map();
|
|
15795
16092
|
const stageTargetFile = (target, file, contents2, options) => {
|
|
15796
|
-
const relative =
|
|
16093
|
+
const relative = path30.relative(layout2.root, file).split(path30.sep).join(path30.posix.sep);
|
|
15797
16094
|
const prior = files.has(file) ? files.get(file) : Object.hasOwn(input.files, relative) ? input.files[relative] : void 0;
|
|
15798
16095
|
if (!options?.allowExisting && prior !== void 0)
|
|
15799
16096
|
throw new Error(`target ${target} already contains generated output ${relative}`);
|
|
@@ -15806,7 +16103,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15806
16103
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
15807
16104
|
return Object.entries(input.files).filter(
|
|
15808
16105
|
([file]) => file.startsWith(prefix) && (target.sources === void 0 || !(file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) || target.sources.some((source) => {
|
|
15809
|
-
const selected =
|
|
16106
|
+
const selected = path30.posix.join(prefix, source);
|
|
15810
16107
|
return file === selected || file.startsWith(`${selected}/`);
|
|
15811
16108
|
})) && !target.exclude?.some(
|
|
15812
16109
|
(excluded) => file === `${prefix}${excluded}` || file.startsWith(`${prefix}${excluded}/`)
|
|
@@ -15827,7 +16124,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15827
16124
|
targetStagedFiles.delete(target.name);
|
|
15828
16125
|
if (entries.some(([file]) => isSwiftNativeTranslationUnit(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name))) {
|
|
15829
16126
|
if (!swift) {
|
|
15830
|
-
const unprepared =
|
|
16127
|
+
const unprepared = path30.join(
|
|
15831
16128
|
layout2.root,
|
|
15832
16129
|
target.path,
|
|
15833
16130
|
"PeachUnprepared.generated.swift"
|
|
@@ -15842,7 +16139,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15842
16139
|
native.set(target.name, {
|
|
15843
16140
|
mixed: true,
|
|
15844
16141
|
path: target.path,
|
|
15845
|
-
includeDirectory:
|
|
16142
|
+
includeDirectory: path30.join(layout2.root, target.path, "include"),
|
|
15846
16143
|
sources: [],
|
|
15847
16144
|
lateSources: [],
|
|
15848
16145
|
exclude: entries.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length))
|
|
@@ -15864,15 +16161,15 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15864
16161
|
file
|
|
15865
16162
|
)?.[1];
|
|
15866
16163
|
if (owner)
|
|
15867
|
-
podHeaders.set(
|
|
15868
|
-
...podHeaders.get(
|
|
16164
|
+
podHeaders.set(path30.basename(file), [
|
|
16165
|
+
...podHeaders.get(path30.basename(file)) ?? [],
|
|
15869
16166
|
{ owner, content: input.files[file] }
|
|
15870
16167
|
]);
|
|
15871
16168
|
}
|
|
15872
|
-
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(
|
|
16169
|
+
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(path30.basename(file))?.find((header) => header.content === content)?.owner;
|
|
15873
16170
|
for (const settings of input.nativeTargets ?? []) {
|
|
15874
16171
|
for (const file of settings.headers) {
|
|
15875
|
-
const destination =
|
|
16172
|
+
const destination = path30.join(layout2.root, file);
|
|
15876
16173
|
if (files.has(destination)) continue;
|
|
15877
16174
|
const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
|
|
15878
16175
|
const frameworkHeader = !interfaceModule && /(?:^|\/)(\w+)\.framework\/Headers\/[\w+.-]+\.h$/.exec(file)?.[1];
|
|
@@ -15891,10 +16188,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15891
16188
|
}
|
|
15892
16189
|
if (settings.flattensPublicHeaders)
|
|
15893
16190
|
for (const header of settings.publicHeaders) {
|
|
15894
|
-
const destination =
|
|
16191
|
+
const destination = path30.join(
|
|
15895
16192
|
headerDirectory,
|
|
15896
16193
|
settings.name,
|
|
15897
|
-
|
|
16194
|
+
path30.basename(header)
|
|
15898
16195
|
);
|
|
15899
16196
|
if (flattenedHeaders.has(destination))
|
|
15900
16197
|
throw new Error(`duplicate product header ${destination}`);
|
|
@@ -15902,9 +16199,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15902
16199
|
}
|
|
15903
16200
|
}
|
|
15904
16201
|
const nativeTargets = input.nativeTargets ?? [];
|
|
15905
|
-
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ?
|
|
16202
|
+
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path30.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
|
|
15906
16203
|
const headerSearch = writeXcodeHeaderSearch(
|
|
15907
|
-
|
|
16204
|
+
path30.join(layout2.root, ".build", "peach-xcode-headers"),
|
|
15908
16205
|
nativeTargets.map((settings) => ({
|
|
15909
16206
|
headerMaps: settings.headerMaps.map((map) => ({
|
|
15910
16207
|
flag: map.flag,
|
|
@@ -15915,26 +16212,26 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15915
16212
|
})),
|
|
15916
16213
|
productHeaders: Object.fromEntries([
|
|
15917
16214
|
...Object.entries(settings.productHeaders).map(([product, file]) => [
|
|
15918
|
-
|
|
15919
|
-
|
|
16215
|
+
path30.join(layout2.root, product),
|
|
16216
|
+
path30.join(layout2.root, file)
|
|
15920
16217
|
]),
|
|
15921
16218
|
...settings.flattensPublicHeaders ? settings.publicHeaders.map((header) => [
|
|
15922
|
-
|
|
15923
|
-
|
|
16219
|
+
path30.join(headerDirectory, settings.name, path30.basename(header)),
|
|
16220
|
+
path30.join(layout2.root, header)
|
|
15924
16221
|
]) : []
|
|
15925
16222
|
]),
|
|
15926
16223
|
userHeaderSearchPaths: settings.userHeaderSearchPaths.map(
|
|
15927
|
-
(directory) =>
|
|
16224
|
+
(directory) => path30.join(layout2.root, directory)
|
|
15928
16225
|
),
|
|
15929
16226
|
searchDirectories: [
|
|
15930
16227
|
...settings.headerSearchPaths,
|
|
15931
16228
|
...settings.frameworkSearchPaths
|
|
15932
|
-
].map((directory) =>
|
|
16229
|
+
].map((directory) => path30.join(layout2.root, directory))
|
|
15933
16230
|
})),
|
|
15934
16231
|
Object.fromEntries(
|
|
15935
16232
|
Object.entries(input.headerAliases ?? {}).map(([alias, file]) => [
|
|
15936
|
-
|
|
15937
|
-
|
|
16233
|
+
path30.join(layout2.root, alias),
|
|
16234
|
+
path30.join(layout2.root, file)
|
|
15938
16235
|
])
|
|
15939
16236
|
)
|
|
15940
16237
|
);
|
|
@@ -15963,16 +16260,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15963
16260
|
for (const [file, contents2] of entries) {
|
|
15964
16261
|
const producers2 = /* @__PURE__ */ new Set();
|
|
15965
16262
|
const source = contents2.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
15966
|
-
for (const
|
|
15967
|
-
/^\s*#\s*(?:include|import)\s*[<"]([^>"]+)[>"]/gm
|
|
15968
|
-
)) {
|
|
15969
|
-
const include = match[1];
|
|
16263
|
+
for (const include of nativeHeaderIncludes(contents2)) {
|
|
15970
16264
|
const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include)?.[1];
|
|
15971
16265
|
if (producer && swiftTargets.has(producer)) producers2.add(producer);
|
|
15972
16266
|
const local = [
|
|
15973
|
-
|
|
16267
|
+
path30.posix.join(path30.posix.dirname(file), include),
|
|
15974
16268
|
`${includes}${include}`,
|
|
15975
|
-
...searchRoots.map((root) =>
|
|
16269
|
+
...searchRoots.map((root) => path30.posix.join(root, include))
|
|
15976
16270
|
].find((candidate) => input.files[candidate] !== void 0);
|
|
15977
16271
|
if (local) {
|
|
15978
16272
|
reverse.set(local, [...reverse.get(local) ?? [], file]);
|
|
@@ -16003,7 +16297,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16003
16297
|
);
|
|
16004
16298
|
const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : entries.some(([file]) => file.endsWith(".swift")) || importedModules.has(swiftTargetModuleName(target.name)) ? settings.publicHeaders : [];
|
|
16005
16299
|
const search = [.../* @__PURE__ */ new Set([...settings?.headerSearchPaths ?? []])].flatMap(
|
|
16006
|
-
(dir) => ["-I",
|
|
16300
|
+
(dir) => ["-I", path30.join(layout2.root, dir)]
|
|
16007
16301
|
);
|
|
16008
16302
|
const toolchainBin = nativeToolchain();
|
|
16009
16303
|
const stageFlags = (flags2, sdkInclude2) => flags2.map(
|
|
@@ -16015,7 +16309,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16015
16309
|
...search,
|
|
16016
16310
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
16017
16311
|
"-F",
|
|
16018
|
-
|
|
16312
|
+
path30.join(layout2.root, dir)
|
|
16019
16313
|
]),
|
|
16020
16314
|
"-I",
|
|
16021
16315
|
headerDirectory
|
|
@@ -16026,7 +16320,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16026
16320
|
...search,
|
|
16027
16321
|
...settings.frameworkSearchPaths.flatMap((dir) => [
|
|
16028
16322
|
"-F",
|
|
16029
|
-
|
|
16323
|
+
path30.join(layout2.root, dir)
|
|
16030
16324
|
]),
|
|
16031
16325
|
"-I",
|
|
16032
16326
|
headerDirectory
|
|
@@ -16036,13 +16330,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16036
16330
|
const flag = settings.importerFlags[index];
|
|
16037
16331
|
if (flag === "-I" || flag === "-iquote") {
|
|
16038
16332
|
const directory = settings.importerFlags[index + 1];
|
|
16039
|
-
if (directory === void 0 || !
|
|
16333
|
+
if (directory === void 0 || !path30.isAbsolute(directory)) {
|
|
16040
16334
|
index++;
|
|
16041
16335
|
continue;
|
|
16042
16336
|
}
|
|
16043
16337
|
}
|
|
16044
16338
|
const joined = /^-(?:I|iquote)(.+)$/.exec(flag);
|
|
16045
|
-
if (joined && !
|
|
16339
|
+
if (joined && !path30.isAbsolute(joined[1])) continue;
|
|
16046
16340
|
kept.push(flag);
|
|
16047
16341
|
}
|
|
16048
16342
|
return [
|
|
@@ -16051,13 +16345,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16051
16345
|
...search,
|
|
16052
16346
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
16053
16347
|
"-F",
|
|
16054
|
-
|
|
16348
|
+
path30.join(layout2.root, dir)
|
|
16055
16349
|
]),
|
|
16056
16350
|
"-I",
|
|
16057
16351
|
headerDirectory
|
|
16058
16352
|
];
|
|
16059
16353
|
})();
|
|
16060
|
-
const sdkInclude =
|
|
16354
|
+
const sdkInclude = path30.join(
|
|
16061
16355
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
16062
16356
|
"darwin/usr/include"
|
|
16063
16357
|
);
|
|
@@ -16072,7 +16366,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16072
16366
|
...dependencyModuleMaps,
|
|
16073
16367
|
...target.defines?.includes(SWIFT_XCODE_BUILD_CONDITION) && !target.defines.includes("SWIFT_PACKAGE") ? ["-USWIFT_PACKAGE"] : []
|
|
16074
16368
|
];
|
|
16075
|
-
const prefixHeader = settings?.prefixHeader ? ["-include",
|
|
16369
|
+
const prefixHeader = settings?.prefixHeader ? ["-include", path30.join(layout2.root, settings.prefixHeader)] : [];
|
|
16076
16370
|
const bundleName = entries.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
|
|
16077
16371
|
target: target.name,
|
|
16078
16372
|
path: target.path,
|
|
@@ -16083,7 +16377,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16083
16377
|
bundles: input.resourceBundles
|
|
16084
16378
|
});
|
|
16085
16379
|
const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
|
|
16086
|
-
const accessorHeader =
|
|
16380
|
+
const accessorHeader = path30.join(
|
|
16087
16381
|
layout2.root,
|
|
16088
16382
|
target.path,
|
|
16089
16383
|
OBJC_RESOURCE_ACCESSOR_HEADER
|
|
@@ -16094,7 +16388,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16094
16388
|
const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
|
|
16095
16389
|
const unitSource = (file) => {
|
|
16096
16390
|
const relative = file.slice(prefix.length);
|
|
16097
|
-
return relative.split("/").some((part) => part.startsWith(".")) ?
|
|
16391
|
+
return relative.split("/").some((part) => part.startsWith(".")) ? path30.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
|
|
16098
16392
|
};
|
|
16099
16393
|
const accessorFlags = accessor ? ["-include", accessorHeader] : [];
|
|
16100
16394
|
const nativeC = !entries.some(([file]) => file.endsWith(".swift"));
|
|
@@ -16124,20 +16418,20 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16124
16418
|
)
|
|
16125
16419
|
].sort();
|
|
16126
16420
|
const topHeaders = settings.publicHeaders.filter(
|
|
16127
|
-
(file) =>
|
|
16421
|
+
(file) => path30.posix.dirname(file) === headerDir
|
|
16128
16422
|
);
|
|
16129
16423
|
if (input.files[custom] !== void 0) {
|
|
16130
16424
|
swiftpmModuleMap = { path: custom, contents: input.files[custom] };
|
|
16131
16425
|
} else if (input.files[umbrella] !== void 0) {
|
|
16132
16426
|
if (siblingDirs.length > 0)
|
|
16133
16427
|
throw new Error(
|
|
16134
|
-
`target ${target.name} has invalid header layout: umbrella header found at '${
|
|
16428
|
+
`target ${target.name} has invalid header layout: umbrella header found at '${path30.join(layout2.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name2) => path30.join(layout2.root, headerDir, name2)).join(", ")}; consider removing them`
|
|
16135
16429
|
);
|
|
16136
16430
|
swiftpmModuleMap = {
|
|
16137
16431
|
path: custom,
|
|
16138
16432
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
16139
16433
|
kind: "header",
|
|
16140
|
-
path:
|
|
16434
|
+
path: path30.join(layout2.root, umbrella)
|
|
16141
16435
|
})
|
|
16142
16436
|
};
|
|
16143
16437
|
} else if (input.files[nestedUmbrella] !== void 0 && siblingDirs.length === 1 && siblingDirs[0] === moduleName && topHeaders.length === 0) {
|
|
@@ -16145,7 +16439,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16145
16439
|
path: custom,
|
|
16146
16440
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
16147
16441
|
kind: "header",
|
|
16148
|
-
path:
|
|
16442
|
+
path: path30.join(layout2.root, nestedUmbrella)
|
|
16149
16443
|
})
|
|
16150
16444
|
};
|
|
16151
16445
|
} else {
|
|
@@ -16153,12 +16447,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16153
16447
|
path: custom,
|
|
16154
16448
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
16155
16449
|
kind: "directory",
|
|
16156
|
-
path:
|
|
16450
|
+
path: path30.join(layout2.root, headerDir)
|
|
16157
16451
|
})
|
|
16158
16452
|
};
|
|
16159
16453
|
}
|
|
16160
16454
|
}
|
|
16161
|
-
const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ??
|
|
16455
|
+
const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? path30.posix.join(
|
|
16162
16456
|
".build",
|
|
16163
16457
|
"peach-objc-originals",
|
|
16164
16458
|
target.name,
|
|
@@ -16166,79 +16460,79 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16166
16460
|
);
|
|
16167
16461
|
const moduleContents = originalModuleMap ? input.files[originalModuleMap[1]] : swiftpmModuleMap?.contents ?? packageModuleMap?.[1] ?? swiftObjCModuleMap(
|
|
16168
16462
|
swiftTargetModuleName(target.name),
|
|
16169
|
-
roots2.map((file) =>
|
|
16463
|
+
roots2.map((file) => path30.join(layout2.root, file)),
|
|
16170
16464
|
submoduleImports.get(swiftTargetModuleName(target.name))
|
|
16171
16465
|
);
|
|
16172
16466
|
if (moduleContents === void 0)
|
|
16173
16467
|
throw new Error("missing original module map " + modulemap);
|
|
16174
|
-
stageTargetFile(target.name,
|
|
16468
|
+
stageTargetFile(target.name, path30.join(layout2.root, modulemap), moduleContents, {
|
|
16175
16469
|
allowExisting: true
|
|
16176
16470
|
});
|
|
16177
16471
|
sourceModuleMaps.set(swiftTargetModuleName(target.name), {
|
|
16178
|
-
path:
|
|
16472
|
+
path: path30.join(layout2.root, modulemap),
|
|
16179
16473
|
contents: moduleContents.toString()
|
|
16180
16474
|
});
|
|
16181
16475
|
if (modulemap.endsWith("/Modules/module.modulemap")) {
|
|
16182
|
-
const framework =
|
|
16476
|
+
const framework = path30.posix.dirname(path30.posix.dirname(modulemap));
|
|
16183
16477
|
for (const [, header] of moduleContents.toString().matchAll(/\bheader\s+"([^"]+)"/g))
|
|
16184
16478
|
for (const folder of ["Headers", "PrivateHeaders"]) {
|
|
16185
|
-
const source = settings.productHeaders[
|
|
16479
|
+
const source = settings.productHeaders[path30.posix.join(framework, folder, header)];
|
|
16186
16480
|
const contents2 = source === void 0 ? void 0 : input.files[source];
|
|
16187
16481
|
if (contents2 !== void 0)
|
|
16188
16482
|
stageTargetFile(
|
|
16189
16483
|
target.name,
|
|
16190
|
-
|
|
16484
|
+
path30.join(layout2.root, path30.posix.dirname(modulemap), folder, header),
|
|
16191
16485
|
contents2,
|
|
16192
16486
|
{ allowExisting: true }
|
|
16193
16487
|
);
|
|
16194
16488
|
}
|
|
16195
16489
|
}
|
|
16196
|
-
if (nativeC &&
|
|
16490
|
+
if (nativeC && path30.posix.basename(modulemap) !== "module.modulemap") {
|
|
16197
16491
|
stageTargetFile(
|
|
16198
16492
|
target.name,
|
|
16199
|
-
|
|
16200
|
-
`extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(
|
|
16493
|
+
path30.join(layout2.root, path30.posix.dirname(modulemap), "module.modulemap"),
|
|
16494
|
+
`extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(path30.join(layout2.root, modulemap))}
|
|
16201
16495
|
`
|
|
16202
16496
|
);
|
|
16203
16497
|
}
|
|
16204
16498
|
const importFlags = [
|
|
16205
16499
|
...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
|
|
16206
|
-
"-fmodule-map-file=" +
|
|
16500
|
+
"-fmodule-map-file=" + path30.join(layout2.root, modulemap),
|
|
16207
16501
|
...dependencyModuleMaps
|
|
16208
16502
|
];
|
|
16209
16503
|
const groups = /* @__PURE__ */ new Map();
|
|
16210
16504
|
for (const [file, contents2] of nativeUnits) {
|
|
16211
16505
|
const origin = settings?.sourceDirectories[file];
|
|
16212
16506
|
if (origin) {
|
|
16213
|
-
const original =
|
|
16214
|
-
|
|
16507
|
+
const original = path30.join(layout2.root, origin, path30.posix.basename(file));
|
|
16508
|
+
mkdirSync8(path30.dirname(original), { recursive: true });
|
|
16215
16509
|
stageTargetFile(target.name, original, contents2, { allowExisting: true });
|
|
16216
16510
|
}
|
|
16217
16511
|
const source = unitSource(file);
|
|
16218
16512
|
if (source !== file.slice(prefix.length))
|
|
16219
16513
|
stageTargetFile(
|
|
16220
16514
|
target.name,
|
|
16221
|
-
|
|
16515
|
+
path30.join(layout2.root, target.path, source),
|
|
16222
16516
|
contents2,
|
|
16223
16517
|
{
|
|
16224
16518
|
allowExisting: true
|
|
16225
16519
|
}
|
|
16226
16520
|
);
|
|
16227
|
-
const stagedDir =
|
|
16521
|
+
const stagedDir = path30.posix.dirname(file);
|
|
16228
16522
|
const quoteDirs = [
|
|
16229
16523
|
...stagedDir !== "." ? [stagedDir] : [],
|
|
16230
16524
|
...origin && origin !== stagedDir ? [origin] : []
|
|
16231
16525
|
];
|
|
16232
16526
|
const quoteFlags = quoteDirs.flatMap((dir) => [
|
|
16233
16527
|
"-iquote",
|
|
16234
|
-
|
|
16528
|
+
path30.join(layout2.root, dir)
|
|
16235
16529
|
]);
|
|
16236
16530
|
const perFile = [
|
|
16237
16531
|
...file.endsWith(".c") && swiftWholeFileArm64Guard(contents2) ? ["-D__arm64__=1"] : [],
|
|
16238
16532
|
.../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
|
|
16239
16533
|
...stageFlags(
|
|
16240
16534
|
settings?.fileFlags[file] ?? [],
|
|
16241
|
-
|
|
16535
|
+
path30.join(
|
|
16242
16536
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
16243
16537
|
"darwin/usr/include"
|
|
16244
16538
|
)
|
|
@@ -16246,7 +16540,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16246
16540
|
];
|
|
16247
16541
|
const cxx = /\.(?:cc|cpp|cxx|mm)$/.test(file);
|
|
16248
16542
|
const moduleFlag = perFile.some((flag) => flag.startsWith("-fmodule-name=")) ? [] : [`-fmodule-name=${swiftTargetModuleName(target.name)}`];
|
|
16249
|
-
const identity =
|
|
16543
|
+
const identity = createHash15("sha256").update(
|
|
16250
16544
|
JSON.stringify([
|
|
16251
16545
|
cxx,
|
|
16252
16546
|
quoteFlags,
|
|
@@ -16255,12 +16549,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16255
16549
|
])
|
|
16256
16550
|
).digest("hex").slice(0, 12);
|
|
16257
16551
|
const name2 = `${target.name}${nativeC ? "Native" : "Swift"}Implementation_${identity}`;
|
|
16258
|
-
const groupPath =
|
|
16259
|
-
const canonicalTargetPath =
|
|
16552
|
+
const groupPath = path30.posix.join("PeachNativeSources", name2);
|
|
16553
|
+
const canonicalTargetPath = path30.posix.join("/peach/build", target.path);
|
|
16260
16554
|
const sourceIdentity = [
|
|
16261
|
-
`-ffile-prefix-map=${
|
|
16555
|
+
`-ffile-prefix-map=${path30.join(layout2.root, groupPath)}=${canonicalTargetPath}`,
|
|
16262
16556
|
...nativeToolset ? [
|
|
16263
|
-
`-ffile-prefix-map=${
|
|
16557
|
+
`-ffile-prefix-map=${path30.posix.join("/peach/build", groupPath)}=${canonicalTargetPath}`
|
|
16264
16558
|
] : []
|
|
16265
16559
|
];
|
|
16266
16560
|
const group = groups.get(identity) ?? {
|
|
@@ -16284,7 +16578,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16284
16578
|
...accessorFlags,
|
|
16285
16579
|
...stageFlags(
|
|
16286
16580
|
cxx ? settings.cxxFlags : [],
|
|
16287
|
-
|
|
16581
|
+
path30.join(
|
|
16288
16582
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
16289
16583
|
"darwin/usr/include"
|
|
16290
16584
|
)
|
|
@@ -16295,12 +16589,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16295
16589
|
};
|
|
16296
16590
|
stageTargetFile(
|
|
16297
16591
|
target.name,
|
|
16298
|
-
|
|
16592
|
+
path30.join(layout2.root, group.path, source),
|
|
16299
16593
|
contents2
|
|
16300
16594
|
);
|
|
16301
16595
|
stageTargetFile(
|
|
16302
16596
|
target.name,
|
|
16303
|
-
|
|
16597
|
+
path30.join(layout2.root, group.path, "include/module.modulemap"),
|
|
16304
16598
|
`module ${swiftTargetModuleName(group.name)} { export * }
|
|
16305
16599
|
`,
|
|
16306
16600
|
{ allowExisting: true }
|
|
@@ -16312,7 +16606,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16312
16606
|
stageTargetFile(target.name, accessorHeader, accessor.header);
|
|
16313
16607
|
stageTargetFile(
|
|
16314
16608
|
target.name,
|
|
16315
|
-
|
|
16609
|
+
path30.join(layout2.root, accessorUnit),
|
|
16316
16610
|
accessor.body
|
|
16317
16611
|
);
|
|
16318
16612
|
}
|
|
@@ -16327,7 +16621,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16327
16621
|
].sort();
|
|
16328
16622
|
native.set(target.name, {
|
|
16329
16623
|
path: target.path,
|
|
16330
|
-
includeDirectory:
|
|
16624
|
+
includeDirectory: path30.dirname(path30.join(layout2.root, modulemap)),
|
|
16331
16625
|
importFlags,
|
|
16332
16626
|
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
16333
16627
|
lateSources: implementations.flatMap((group) => group.sources),
|
|
@@ -16350,23 +16644,23 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16350
16644
|
throw new Error(`original module map declares no module: ${modulemap}`);
|
|
16351
16645
|
stageTargetFile(
|
|
16352
16646
|
target.name,
|
|
16353
|
-
|
|
16354
|
-
`extern module ${exportedModule} ${JSON.stringify(
|
|
16647
|
+
path30.join(layout2.root, owner.path, "include/module.modulemap"),
|
|
16648
|
+
`extern module ${exportedModule} ${JSON.stringify(path30.join(layout2.root, modulemap))}
|
|
16355
16649
|
`,
|
|
16356
16650
|
{ allowExisting: true }
|
|
16357
16651
|
);
|
|
16358
16652
|
}
|
|
16359
16653
|
continue;
|
|
16360
16654
|
}
|
|
16361
|
-
const implementationHeaders =
|
|
16655
|
+
const implementationHeaders = path30.posix.join(
|
|
16362
16656
|
".build",
|
|
16363
16657
|
"peach-objc-implementations",
|
|
16364
16658
|
target.name
|
|
16365
16659
|
);
|
|
16366
|
-
const include =
|
|
16660
|
+
const include = path30.join(layout2.root, implementationHeaders);
|
|
16367
16661
|
stageTargetFile(
|
|
16368
16662
|
target.name,
|
|
16369
|
-
|
|
16663
|
+
path30.join(include, "module.modulemap"),
|
|
16370
16664
|
`module ${target.name}ImplementationDeclarations { export * }
|
|
16371
16665
|
`
|
|
16372
16666
|
);
|
|
@@ -16376,7 +16670,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16376
16670
|
includeDirectory: include,
|
|
16377
16671
|
importFlags,
|
|
16378
16672
|
swiftFlags: [
|
|
16379
|
-
...settings.bridgingHeader ? ["-import-objc-header",
|
|
16673
|
+
...settings.bridgingHeader ? ["-import-objc-header", path30.join(layout2.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
|
|
16380
16674
|
...importFlags.flatMap((flag) => ["-Xcc", flag])
|
|
16381
16675
|
],
|
|
16382
16676
|
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
@@ -16406,7 +16700,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16406
16700
|
}
|
|
16407
16701
|
native.set(target.name, {
|
|
16408
16702
|
path: target.path,
|
|
16409
|
-
includeDirectory:
|
|
16703
|
+
includeDirectory: path30.join(layout2.root, includes),
|
|
16410
16704
|
sources: units.map(([file]) => file.slice(prefix.length)),
|
|
16411
16705
|
lateSources: late.map(([file]) => file.slice(prefix.length)),
|
|
16412
16706
|
...late.length > 0 ? {
|
|
@@ -16420,7 +16714,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16420
16714
|
});
|
|
16421
16715
|
if (late.length > 0)
|
|
16422
16716
|
files.set(
|
|
16423
|
-
|
|
16717
|
+
path30.join(layout2.root, target.path, "PeachSwiftImplementation/module.modulemap"),
|
|
16424
16718
|
`module ${swiftTargetModuleName(`${target.name}SwiftImplementation`)} { export * }
|
|
16425
16719
|
`
|
|
16426
16720
|
);
|
|
@@ -16432,7 +16726,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16432
16726
|
([file]) => file.startsWith(includes) && /\.(?:h|hpp|hh|hxx)$/.test(file) && consumers.get(file).size === 0
|
|
16433
16727
|
);
|
|
16434
16728
|
files.set(
|
|
16435
|
-
|
|
16729
|
+
path30.join(layout2.root, includes, "module.modulemap"),
|
|
16436
16730
|
[
|
|
16437
16731
|
`module ${target.name} {`,
|
|
16438
16732
|
...roots.map(
|
|
@@ -16447,14 +16741,14 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16447
16741
|
for (const map of generatedModuleMaps)
|
|
16448
16742
|
if (files.has(map.published) || Object.hasOwn(
|
|
16449
16743
|
input.files,
|
|
16450
|
-
|
|
16744
|
+
path30.relative(layout2.root, map.published).split(path30.sep).join(path30.posix.sep)
|
|
16451
16745
|
))
|
|
16452
16746
|
writeBuildFile(
|
|
16453
16747
|
map.output,
|
|
16454
16748
|
`extern module ${map.module} ${JSON.stringify(map.published)}
|
|
16455
16749
|
`
|
|
16456
16750
|
);
|
|
16457
|
-
if (native.size > 0)
|
|
16751
|
+
if (native.size > 0) mkdirSync8(headerDirectory, { recursive: true });
|
|
16458
16752
|
const headerAliasFlags = Object.keys(input.headerAliases ?? {}).length > 0 ? ["-ivfsoverlay", headerSearch.files[0]] : [];
|
|
16459
16753
|
const nativeHeaderFlags = [...headerAliasFlags];
|
|
16460
16754
|
const nativeSwiftHeaderMaps = /* @__PURE__ */ new Map();
|
|
@@ -16476,10 +16770,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16476
16770
|
[...native.values()].flatMap((value) => value.late?.producers ?? [])
|
|
16477
16771
|
)) {
|
|
16478
16772
|
files.set(
|
|
16479
|
-
|
|
16773
|
+
path30.join(headerDirectory, name2, name2 + "-Swift.h"),
|
|
16480
16774
|
'#include "../' + name2 + '-Swift.h"\n'
|
|
16481
16775
|
);
|
|
16482
|
-
const modulemap =
|
|
16776
|
+
const modulemap = path30.join(
|
|
16483
16777
|
layout2.root,
|
|
16484
16778
|
".build",
|
|
16485
16779
|
"peach-objc-swift-headers",
|
|
@@ -16489,7 +16783,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16489
16783
|
const moduleName = swiftTargetModuleName(name2);
|
|
16490
16784
|
const originalMap = originalMaps.get(moduleName);
|
|
16491
16785
|
const stagedMap = sourceModuleMaps.get(moduleName);
|
|
16492
|
-
const originalPath = stagedMap?.path ?? (originalMap ?
|
|
16786
|
+
const originalPath = stagedMap?.path ?? (originalMap ? path30.join(layout2.root, originalMap) : void 0);
|
|
16493
16787
|
const originalContents = stagedMap?.contents ?? (originalMap && input.files[originalMap]);
|
|
16494
16788
|
const originalTokens = originalContents ? moduleMapTokens(originalContents) : [];
|
|
16495
16789
|
if (originalPath && originalTokens.some(
|
|
@@ -16503,29 +16797,29 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16503
16797
|
modulemap,
|
|
16504
16798
|
originalPath ? `extern module ${moduleName} ${JSON.stringify(originalPath)}
|
|
16505
16799
|
module ${moduleName}.Swift {
|
|
16506
|
-
header ${JSON.stringify(
|
|
16800
|
+
header ${JSON.stringify(path30.join(headerDirectory, name2 + "-Swift.h"))}
|
|
16507
16801
|
requires objc
|
|
16508
16802
|
}
|
|
16509
16803
|
` : swiftObjCModuleMap(
|
|
16510
16804
|
moduleName,
|
|
16511
|
-
(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) =>
|
|
16805
|
+
(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) => path30.join(layout2.root, header)),
|
|
16512
16806
|
submoduleImports.get(moduleName),
|
|
16513
|
-
|
|
16807
|
+
path30.join(headerDirectory, name2 + "-Swift.h")
|
|
16514
16808
|
)
|
|
16515
16809
|
);
|
|
16516
16810
|
nativeHeaderFlags.push("-fmodule-map-file=" + modulemap);
|
|
16517
16811
|
nativeSwiftHeaderMaps.set(name2, modulemap);
|
|
16518
16812
|
}
|
|
16519
|
-
const modulePlan =
|
|
16813
|
+
const modulePlan = createHash15("sha256").update(
|
|
16520
16814
|
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
16521
16815
|
);
|
|
16522
16816
|
if (!distribution) {
|
|
16523
|
-
modulePlan.update(
|
|
16817
|
+
modulePlan.update(readFileSync18(path30.join(moduleRoot, "Package.swift")));
|
|
16524
16818
|
}
|
|
16525
16819
|
modulePlan.update(
|
|
16526
16820
|
Object.keys(input.files).filter((file) => file.endsWith(".swift")).sort().join("\n")
|
|
16527
16821
|
);
|
|
16528
|
-
const resourcePlan =
|
|
16822
|
+
const resourcePlan = createHash15("sha256").update(
|
|
16529
16823
|
JSON.stringify(
|
|
16530
16824
|
resourceTargets.filter((target) => target.resources).map((target) => [
|
|
16531
16825
|
target.name,
|
|
@@ -16575,7 +16869,7 @@ module ${moduleName}.Swift {
|
|
|
16575
16869
|
(target) => {
|
|
16576
16870
|
const native2 = input.nativeTargets?.find(({ name: name2 }) => name2 === target.name);
|
|
16577
16871
|
if (native2) return native2.publicHeaders.map((file) => input.files[file] ?? "");
|
|
16578
|
-
const directory =
|
|
16872
|
+
const directory = path30.posix.join(
|
|
16579
16873
|
target.path,
|
|
16580
16874
|
target.publicHeadersPath ?? "include"
|
|
16581
16875
|
);
|
|
@@ -16611,7 +16905,7 @@ module ${moduleName}.Swift {
|
|
|
16611
16905
|
`;
|
|
16612
16906
|
} else if (mains.length === 0) {
|
|
16613
16907
|
const procedural = entries.filter(
|
|
16614
|
-
([file, source]) =>
|
|
16908
|
+
([file, source]) => path30.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
|
|
16615
16909
|
);
|
|
16616
16910
|
const wrapped = procedural.length === 1 ? wrapUIApplicationMainEntry(procedural[0][1]) : null;
|
|
16617
16911
|
if (wrapped) {
|
|
@@ -16632,7 +16926,7 @@ module ${moduleName}.Swift {
|
|
|
16632
16926
|
`mixed executable ${target.name} requires one typed Swift application entry`
|
|
16633
16927
|
);
|
|
16634
16928
|
files.set(
|
|
16635
|
-
|
|
16929
|
+
path30.join(layout2.root, nativeMains[0][0]),
|
|
16636
16930
|
neutralizedNativeMain(nativeMains[0][1])
|
|
16637
16931
|
);
|
|
16638
16932
|
nativeEntry = true;
|
|
@@ -16644,9 +16938,9 @@ module ${moduleName}.Swift {
|
|
|
16644
16938
|
}
|
|
16645
16939
|
if (!nativeEntry) {
|
|
16646
16940
|
compiled.set(entryFile, entrySource);
|
|
16647
|
-
if (
|
|
16648
|
-
const libraryEntry =
|
|
16649
|
-
|
|
16941
|
+
if (path30.basename(entryFile) === "main.swift") {
|
|
16942
|
+
const libraryEntry = path30.posix.join(
|
|
16943
|
+
path30.posix.dirname(entryFile),
|
|
16650
16944
|
"PeachApplicationEntry.generated.swift"
|
|
16651
16945
|
);
|
|
16652
16946
|
if (Object.hasOwn(input.files, libraryEntry))
|
|
@@ -16670,7 +16964,7 @@ module ${moduleName}.Swift {
|
|
|
16670
16964
|
exclude: []
|
|
16671
16965
|
});
|
|
16672
16966
|
files.set(
|
|
16673
|
-
|
|
16967
|
+
path30.join(layout2.root, `PeachApplication/${name2}/Entry.swift`),
|
|
16674
16968
|
!nativeEntry ? `import ${swiftTargetModuleName(target.name)}
|
|
16675
16969
|
@main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }
|
|
16676
16970
|
` : `import ${swiftTargetModuleName(target.name)}
|
|
@@ -16702,7 +16996,7 @@ module ${moduleName}.Swift {
|
|
|
16702
16996
|
);
|
|
16703
16997
|
if (nativeFlags) {
|
|
16704
16998
|
const toolchainBin = nativeToolchain();
|
|
16705
|
-
const headers =
|
|
16999
|
+
const headers = path30.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
|
|
16706
17000
|
const dependencies2 = swiftTargetDependencies(input.files, targets);
|
|
16707
17001
|
const reachesNative = (name2, seen = /* @__PURE__ */ new Set()) => {
|
|
16708
17002
|
if (native.has(name2)) return true;
|
|
@@ -16747,10 +17041,10 @@ module ${moduleName}.Swift {
|
|
|
16747
17041
|
if (targets.length === 0 && !prebuilt) {
|
|
16748
17042
|
for (const [file, contents2] of Object.entries(input.files)) {
|
|
16749
17043
|
if (file === "Package.swift") continue;
|
|
16750
|
-
files.set(
|
|
17044
|
+
files.set(path30.join(layout2.sources, file), compiled.get(file) ?? contents2);
|
|
16751
17045
|
}
|
|
16752
|
-
let manifest2 =
|
|
16753
|
-
|
|
17046
|
+
let manifest2 = readFileSync18(
|
|
17047
|
+
path30.join(moduleRoot, "scripts/contrast-app-Package.swift"),
|
|
16754
17048
|
"utf8"
|
|
16755
17049
|
).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
|
|
16756
17050
|
const reactor = ` ${REACTOR_FLAG}`;
|
|
@@ -16797,35 +17091,35 @@ module ${moduleName}.Swift {
|
|
|
16797
17091
|
[anchor, ...games.map((name2) => `${gameProduct(name2)},`)].join("\n ")
|
|
16798
17092
|
);
|
|
16799
17093
|
}
|
|
16800
|
-
files.set(
|
|
17094
|
+
files.set(path30.join(layout2.root, "Package.swift"), manifest2 + moduleFiles);
|
|
16801
17095
|
} else {
|
|
16802
17096
|
const base = layout2.multi ? layout2.root : layout2.sources;
|
|
16803
17097
|
const libraries = /* @__PURE__ */ new Map();
|
|
16804
|
-
const binaryModules =
|
|
17098
|
+
const binaryModules = path30.join(layout2.root, ".peach-binary-modules");
|
|
16805
17099
|
for (const [name2, data] of Object.entries(input.binaryModules ?? {})) {
|
|
16806
17100
|
if (!/^[A-Za-z_]\w*$/.test(name2) || !input.libraries?.[name2])
|
|
16807
17101
|
throw new Error(`invalid native Swift module ${name2}: its library is required`);
|
|
16808
17102
|
files.set(
|
|
16809
|
-
|
|
17103
|
+
path30.join(binaryModules, `${name2}.swiftmodule`),
|
|
16810
17104
|
Buffer.from(data, "base64")
|
|
16811
17105
|
);
|
|
16812
17106
|
}
|
|
16813
17107
|
for (const [target, data] of Object.entries(input.libraries ?? {})) {
|
|
16814
17108
|
const bytes = Buffer.from(data, "base64");
|
|
16815
|
-
const digest =
|
|
16816
|
-
const file =
|
|
17109
|
+
const digest = createHash15("sha256").update(bytes).digest("hex");
|
|
17110
|
+
const file = path30.join(layout2.root, ".peach-libraries", `lib${target}-${digest}.a`);
|
|
16817
17111
|
files.set(file, bytes);
|
|
16818
17112
|
libraries.set(target, file);
|
|
16819
17113
|
}
|
|
16820
17114
|
for (const [file, contents2] of Object.entries(input.files)) {
|
|
16821
17115
|
if (file === "Package.swift") continue;
|
|
16822
|
-
const destination =
|
|
17116
|
+
const destination = path30.join(base, libraryEntryFiles.get(file) ?? file);
|
|
16823
17117
|
const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
|
|
16824
17118
|
const localInterface = interfaceModule && swiftTargets.has(interfaceModule) ? `#include ${JSON.stringify(
|
|
16825
|
-
|
|
16826
|
-
|
|
16827
|
-
|
|
16828
|
-
).split(
|
|
17119
|
+
path30.relative(
|
|
17120
|
+
path30.dirname(destination),
|
|
17121
|
+
path30.join(headerDirectory, `${interfaceModule}-Swift.h`)
|
|
17122
|
+
).split(path30.sep).join("/")
|
|
16829
17123
|
)}
|
|
16830
17124
|
` : void 0;
|
|
16831
17125
|
files.set(
|
|
@@ -16833,10 +17127,10 @@ module ${moduleName}.Swift {
|
|
|
16833
17127
|
localInterface ?? compiled.get(file) ?? files.get(destination) ?? (interfaceModule && moduleInterface(interfaceModule)?.header) ?? contents2
|
|
16834
17128
|
);
|
|
16835
17129
|
}
|
|
16836
|
-
const
|
|
17130
|
+
const manifestTargets2 = targets.length > 0 ? targets : [
|
|
16837
17131
|
{
|
|
16838
17132
|
name: "App",
|
|
16839
|
-
path:
|
|
17133
|
+
path: path30.relative(layout2.root, layout2.sources).split(path30.sep).join("/"),
|
|
16840
17134
|
executable: true,
|
|
16841
17135
|
languageMode: 5,
|
|
16842
17136
|
mainActorIsolation: false,
|
|
@@ -16846,11 +17140,11 @@ module ${moduleName}.Swift {
|
|
|
16846
17140
|
const reachesFrameworks = !distribution || swiftImportedModules.has("Foundation") || Object.entries(input.files).some(
|
|
16847
17141
|
([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
|
|
16848
17142
|
) || [...importedModules].some(
|
|
16849
|
-
(name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2) && !(clangImportedModules.has(name2) && !swiftImportedModules.has(name2) &&
|
|
16850
|
-
|
|
17143
|
+
(name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2) && !(clangImportedModules.has(name2) && !swiftImportedModules.has(name2) && existsSync7(
|
|
17144
|
+
path30.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name2)
|
|
16851
17145
|
))
|
|
16852
17146
|
);
|
|
16853
|
-
const frameworkLink = prebuilt ?
|
|
17147
|
+
const frameworkLink = prebuilt ? path30.join(layout2.root, ".peach-framework-objects.rsp") : void 0;
|
|
16854
17148
|
if (prebuilt && frameworkLink) {
|
|
16855
17149
|
const quote = (object3) => `"${object3.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
16856
17150
|
files.set(
|
|
@@ -16866,10 +17160,10 @@ module ${moduleName}.Swift {
|
|
|
16866
17160
|
}
|
|
16867
17161
|
const moduleSiblings = swiftTargetDependencies(
|
|
16868
17162
|
input.files,
|
|
16869
|
-
layout2.multi ?
|
|
17163
|
+
layout2.multi ? manifestTargets2 : manifestTargets2.map((target) => ({ ...target, path: "." }))
|
|
16870
17164
|
);
|
|
16871
|
-
if (namesLibxml2(input) && !
|
|
16872
|
-
const executable =
|
|
17165
|
+
if (namesLibxml2(input) && !manifestTargets2.some((target) => target.name === "libxml2")) {
|
|
17166
|
+
const executable = manifestTargets2.find((target) => target.executable);
|
|
16873
17167
|
if (executable) {
|
|
16874
17168
|
const reached = moduleSiblings.get(executable.name) ?? [];
|
|
16875
17169
|
if (!reached.includes("libxml2"))
|
|
@@ -16877,15 +17171,15 @@ module ${moduleName}.Swift {
|
|
|
16877
17171
|
}
|
|
16878
17172
|
}
|
|
16879
17173
|
files.set(
|
|
16880
|
-
|
|
17174
|
+
path30.join(layout2.root, "Package.swift"),
|
|
16881
17175
|
emitSwiftPackageManifest({
|
|
16882
17176
|
root: layout2.root,
|
|
16883
17177
|
files,
|
|
16884
|
-
targets:
|
|
17178
|
+
targets: manifestTargets2.map((target) => ({
|
|
16885
17179
|
...target,
|
|
16886
17180
|
sources: target.sources?.map((source) => {
|
|
16887
|
-
const entry = libraryEntryFiles.get(
|
|
16888
|
-
return entry ?
|
|
17181
|
+
const entry = libraryEntryFiles.get(path30.posix.join(target.path, source));
|
|
17182
|
+
return entry ? path30.posix.relative(target.path, entry) : source;
|
|
16889
17183
|
})
|
|
16890
17184
|
})),
|
|
16891
17185
|
packages,
|
|
@@ -16919,7 +17213,7 @@ module ${moduleName}.Swift {
|
|
|
16919
17213
|
),
|
|
16920
17214
|
...reachesFrameworks ? {
|
|
16921
17215
|
distributionLink: {
|
|
16922
|
-
path:
|
|
17216
|
+
path: path30.join(layout2.root, ".peach-distribution-objects.rsp"),
|
|
16923
17217
|
files
|
|
16924
17218
|
}
|
|
16925
17219
|
} : {},
|
|
@@ -16940,14 +17234,14 @@ module ${moduleName}.Swift {
|
|
|
16940
17234
|
for (const [file, bytes] of Object.entries(input.packageFiles ?? {})) {
|
|
16941
17235
|
const contents2 = Buffer.from(bytes, "base64");
|
|
16942
17236
|
files.set(
|
|
16943
|
-
|
|
17237
|
+
path30.join(layout2.root, file),
|
|
16944
17238
|
file.endsWith(".swift") && !/(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file) ? withPreconcurrencyFoundationModules(
|
|
16945
17239
|
swiftPackageSourceAsIOS(contents2.toString("utf8"))
|
|
16946
17240
|
) : contents2
|
|
16947
17241
|
);
|
|
16948
17242
|
}
|
|
16949
17243
|
for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
|
|
16950
|
-
const destination =
|
|
17244
|
+
const destination = path30.join(layout2.root, file);
|
|
16951
17245
|
if (files.has(destination)) continue;
|
|
16952
17246
|
files.set(destination, Buffer.from(bytes, "base64"));
|
|
16953
17247
|
}
|
|
@@ -16956,13 +17250,13 @@ module ${moduleName}.Swift {
|
|
|
16956
17250
|
const nativeToolsetFlags = [
|
|
16957
17251
|
...headerAliasFlags,
|
|
16958
17252
|
...native.size > 0 ? [
|
|
16959
|
-
"-fmodule-map-file=" +
|
|
17253
|
+
"-fmodule-map-file=" + path30.join(
|
|
16960
17254
|
swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
|
|
16961
17255
|
"darwin/wasm/include/module.modulemap"
|
|
16962
17256
|
)
|
|
16963
17257
|
] : []
|
|
16964
17258
|
];
|
|
16965
|
-
const clangWrapper2 =
|
|
17259
|
+
const clangWrapper2 = path30.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
|
|
16966
17260
|
files.set(
|
|
16967
17261
|
clangWrapper2,
|
|
16968
17262
|
[
|
|
@@ -17003,21 +17297,21 @@ module ${moduleName}.Swift {
|
|
|
17003
17297
|
" done",
|
|
17004
17298
|
"fi",
|
|
17005
17299
|
'if [ -n "$name" ] && [ -z "$explicit" ]; then',
|
|
17006
|
-
` exec '${
|
|
17300
|
+
` exec '${path30.join(nativeToolchain(), "clang")}' "-fmodule-name=$name" "$@"`,
|
|
17007
17301
|
"fi",
|
|
17008
|
-
`exec '${
|
|
17302
|
+
`exec '${path30.join(nativeToolchain(), "clang")}' "$@"`,
|
|
17009
17303
|
""
|
|
17010
17304
|
].join("\n")
|
|
17011
17305
|
);
|
|
17012
17306
|
files.set(
|
|
17013
|
-
|
|
17307
|
+
path30.join(layout2.root, ".peach-target-toolset.json"),
|
|
17014
17308
|
JSON.stringify({
|
|
17015
17309
|
schemaVersion: "1.0",
|
|
17016
17310
|
cCompiler: {
|
|
17017
17311
|
extraCLIOptions: [
|
|
17018
17312
|
...nativeToolsetFlags,
|
|
17019
17313
|
"-fmodules",
|
|
17020
|
-
`-fmodules-cache-path=${
|
|
17314
|
+
`-fmodules-cache-path=${path30.join(layout2.root, ".build", "ModuleCache")}`
|
|
17021
17315
|
]
|
|
17022
17316
|
},
|
|
17023
17317
|
...nativeToolsetFlags.length > 0 ? { cxxCompiler: { extraCLIOptions: nativeToolsetFlags } } : {},
|
|
@@ -17027,12 +17321,12 @@ module ${moduleName}.Swift {
|
|
|
17027
17321
|
distribution || prebuilt ? "-Isystem" : "-I",
|
|
17028
17322
|
distribution ? providedModulesPath(
|
|
17029
17323
|
layout2.root,
|
|
17030
|
-
|
|
17324
|
+
path30.join(moduleRoot, "modules"),
|
|
17031
17325
|
moduleExcludes
|
|
17032
|
-
) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) :
|
|
17326
|
+
) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) : path30.join(layout2.root, ".build", WASM_TRIPLE, "release", "Modules"),
|
|
17033
17327
|
...distribution ? distributionClangModuleOptions(
|
|
17034
17328
|
layout2.root,
|
|
17035
|
-
|
|
17329
|
+
path30.join(moduleRoot, "modules")
|
|
17036
17330
|
) : [],
|
|
17037
17331
|
...prebuilt?.moduleMaps.flatMap((map) => [
|
|
17038
17332
|
"-Xcc",
|
|
@@ -17062,9 +17356,9 @@ module ${moduleName}.Swift {
|
|
|
17062
17356
|
throw new Error(
|
|
17063
17357
|
`swift resource target ${target.name} has no matching bundle assignment`
|
|
17064
17358
|
);
|
|
17065
|
-
const directory = layout2.multi ?
|
|
17359
|
+
const directory = layout2.multi ? path30.join(layout2.root, target.path) : layout2.sources;
|
|
17066
17360
|
files.set(
|
|
17067
|
-
|
|
17361
|
+
path30.join(directory, "ResourceBundleAccessor.generated.swift"),
|
|
17068
17362
|
[
|
|
17069
17363
|
"import Foundation",
|
|
17070
17364
|
"",
|
|
@@ -17081,7 +17375,7 @@ module ${moduleName}.Swift {
|
|
|
17081
17375
|
}
|
|
17082
17376
|
for (const [file, source] of compiled)
|
|
17083
17377
|
if (!Object.hasOwn(input.files, file))
|
|
17084
|
-
files.set(
|
|
17378
|
+
files.set(path30.join(layout2.multi ? layout2.root : layout2.sources, file), source);
|
|
17085
17379
|
const producers = [
|
|
17086
17380
|
.../* @__PURE__ */ new Set([...[...native.values()].flatMap((value) => value.late?.producers ?? [])])
|
|
17087
17381
|
];
|
|
@@ -17094,14 +17388,15 @@ module ${moduleName}.Swift {
|
|
|
17094
17388
|
generatedOwners.set(group.name, owner);
|
|
17095
17389
|
}
|
|
17096
17390
|
}
|
|
17097
|
-
const manifestPath =
|
|
17391
|
+
const manifestPath = path30.join(layout2.root, "Package.swift");
|
|
17098
17392
|
let manifest = files.get(manifestPath).toString();
|
|
17393
|
+
const manifestTargets = swiftManifestTargets(manifest, [], (file) => {
|
|
17394
|
+
const contents2 = files.get(file);
|
|
17395
|
+
if (contents2 === void 0) throw new Error(`missing compiler arguments ${file}`);
|
|
17396
|
+
return contents2.toString();
|
|
17397
|
+
});
|
|
17099
17398
|
const dependencies = new Map(
|
|
17100
|
-
|
|
17101
|
-
const contents2 = files.get(file);
|
|
17102
|
-
if (contents2 === void 0) throw new Error(`missing compiler arguments ${file}`);
|
|
17103
|
-
return contents2.toString();
|
|
17104
|
-
}).map((target) => [
|
|
17399
|
+
manifestTargets.map((target) => [
|
|
17105
17400
|
target.name,
|
|
17106
17401
|
(target.dependencies ?? []).flatMap(
|
|
17107
17402
|
(dependency) => dependency.kind === "target" ? [dependency.name] : []
|
|
@@ -17109,6 +17404,62 @@ module ${moduleName}.Swift {
|
|
|
17109
17404
|
])
|
|
17110
17405
|
);
|
|
17111
17406
|
const producerSet = /* @__PURE__ */ new Set([...Object.keys(nativeHeaderDeclarations), ...producers]);
|
|
17407
|
+
let headerCompiler = allowHeaderCompiler && packages.size === 0 && producerSet.size > 0;
|
|
17408
|
+
if (headerCompiler) {
|
|
17409
|
+
const clang = new Set(
|
|
17410
|
+
manifestTargets.filter(
|
|
17411
|
+
(target) => target.systemLibrary || !swiftTargets.has(target.name) && native.has(target.name)
|
|
17412
|
+
).map(({ name: name2 }) => name2)
|
|
17413
|
+
);
|
|
17414
|
+
const headers = swiftHeaderDependencies(
|
|
17415
|
+
layout2.root,
|
|
17416
|
+
files,
|
|
17417
|
+
manifestTargets,
|
|
17418
|
+
nativeTargets,
|
|
17419
|
+
producerSet,
|
|
17420
|
+
input.headerAliases ?? {}
|
|
17421
|
+
);
|
|
17422
|
+
const nativeEdges = /* @__PURE__ */ new Map();
|
|
17423
|
+
const dependsOn = (from, to, seen = /* @__PURE__ */ new Set()) => {
|
|
17424
|
+
if (from === to) return true;
|
|
17425
|
+
if (seen.has(from)) return false;
|
|
17426
|
+
seen.add(from);
|
|
17427
|
+
return [...dependencies.get(from) ?? [], ...nativeEdges.get(from) ?? []].some(
|
|
17428
|
+
(dependency) => dependsOn(dependency, to, seen)
|
|
17429
|
+
);
|
|
17430
|
+
};
|
|
17431
|
+
for (const target of manifestTargets) {
|
|
17432
|
+
if (target.systemLibrary) continue;
|
|
17433
|
+
const required = new Set(headers.get(target.name));
|
|
17434
|
+
const visited = /* @__PURE__ */ new Set();
|
|
17435
|
+
const imports = (name2) => {
|
|
17436
|
+
if (!clang.has(name2) || visited.has(name2)) return;
|
|
17437
|
+
visited.add(name2);
|
|
17438
|
+
for (const header of headers.get(name2) ?? []) required.add(header);
|
|
17439
|
+
for (const dependency of dependencies.get(name2) ?? []) imports(dependency);
|
|
17440
|
+
};
|
|
17441
|
+
for (const dependency of dependencies.get(target.name) ?? []) imports(dependency);
|
|
17442
|
+
for (const producer of required) {
|
|
17443
|
+
if (dependsOn(target.name, producer)) continue;
|
|
17444
|
+
if (dependsOn(producer, target.name)) {
|
|
17445
|
+
headerCompiler = false;
|
|
17446
|
+
break;
|
|
17447
|
+
}
|
|
17448
|
+
const edges = nativeEdges.get(target.name) ?? [];
|
|
17449
|
+
edges.push(producer);
|
|
17450
|
+
nativeEdges.set(target.name, edges);
|
|
17451
|
+
}
|
|
17452
|
+
if (!headerCompiler) break;
|
|
17453
|
+
}
|
|
17454
|
+
if (headerCompiler)
|
|
17455
|
+
for (const [target, producers2] of nativeEdges) {
|
|
17456
|
+
const additions = producers2.map((producer) => `.target(name: ${JSON.stringify(producer)})`).join(", ");
|
|
17457
|
+
manifest += `
|
|
17458
|
+
package.targets.first(where: { $0.name == ${JSON.stringify(target)} })!.dependencies += [${additions}]
|
|
17459
|
+
`;
|
|
17460
|
+
dependencies.get(target).push(...producers2);
|
|
17461
|
+
}
|
|
17462
|
+
}
|
|
17112
17463
|
const depths = /* @__PURE__ */ new Map();
|
|
17113
17464
|
const orderedProducers = [];
|
|
17114
17465
|
const depth = (name2) => {
|
|
@@ -17137,13 +17488,18 @@ module ${moduleName}.Swift {
|
|
|
17137
17488
|
if (members.length === 1) return members[0];
|
|
17138
17489
|
if (dependencies.has(name2))
|
|
17139
17490
|
throw new Error(`generated build target collides with ${name2}`);
|
|
17140
|
-
files.set(
|
|
17491
|
+
files.set(path30.join(layout2.root, name2, "Products.swift"), "");
|
|
17141
17492
|
manifest += `
|
|
17142
17493
|
package.targets += [.target(name: ${JSON.stringify(name2)}, dependencies: ${JSON.stringify(members)}, path: ${JSON.stringify(name2)}, swiftSettings: [.swiftLanguageMode(.v5)])]
|
|
17143
17494
|
`;
|
|
17144
17495
|
return name2;
|
|
17145
17496
|
};
|
|
17146
|
-
const headerBuilds =
|
|
17497
|
+
const headerBuilds = headerCompiler ? [
|
|
17498
|
+
{
|
|
17499
|
+
target: buildProduct(SWIFT_HEADER_PRODUCTS_TARGET, orderedProducers),
|
|
17500
|
+
producers: orderedProducers
|
|
17501
|
+
}
|
|
17502
|
+
] : [...stages].sort(([left], [right]) => left - right).map(([level, producers2]) => ({
|
|
17147
17503
|
target: buildProduct(`${SWIFT_HEADER_PRODUCTS_TARGET}${level}`, producers2),
|
|
17148
17504
|
producers: producers2
|
|
17149
17505
|
}));
|
|
@@ -17161,16 +17517,17 @@ package.targets += [.target(name: ${JSON.stringify(name2)}, dependencies: ${JSON
|
|
|
17161
17517
|
syncSwiftTree(layout2.root, files);
|
|
17162
17518
|
if (layout2.multi)
|
|
17163
17519
|
for (const target of targets)
|
|
17164
|
-
|
|
17165
|
-
const clangWrapper =
|
|
17166
|
-
if (files.has(clangWrapper))
|
|
17520
|
+
mkdirSync8(path30.join(layout2.root, target.path), { recursive: true });
|
|
17521
|
+
const clangWrapper = path30.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
|
|
17522
|
+
if (files.has(clangWrapper)) chmodSync3(clangWrapper, 493);
|
|
17167
17523
|
return {
|
|
17168
17524
|
headerBuilds,
|
|
17169
17525
|
nativeHeaderDeclarations,
|
|
17170
17526
|
nativeProductTarget,
|
|
17171
17527
|
targetFailures,
|
|
17172
17528
|
generatedOwners,
|
|
17173
|
-
targetToolset
|
|
17529
|
+
targetToolset,
|
|
17530
|
+
headerCompiler
|
|
17174
17531
|
};
|
|
17175
17532
|
}
|
|
17176
17533
|
function streamText(value) {
|
|
@@ -17190,21 +17547,21 @@ function outputOf(error) {
|
|
|
17190
17547
|
return error instanceof Error ? error.message : String(error);
|
|
17191
17548
|
}
|
|
17192
17549
|
function builtArtifact(layout2) {
|
|
17193
|
-
const binDir =
|
|
17194
|
-
const manifest =
|
|
17550
|
+
const binDir = path30.join(layout2.root, ".build", WASM_TRIPLE, "release");
|
|
17551
|
+
const manifest = readFileSync18(path30.join(layout2.root, "Package.swift"), "utf8");
|
|
17195
17552
|
const executable = swiftManifestTargets(
|
|
17196
17553
|
manifest,
|
|
17197
17554
|
[],
|
|
17198
|
-
(file) =>
|
|
17555
|
+
(file) => readFileSync18(file, "utf8")
|
|
17199
17556
|
).find((target) => target.executable);
|
|
17200
17557
|
if (executable === void 0) {
|
|
17201
17558
|
throw new Error("swift-compile: the written manifest names no executable target");
|
|
17202
17559
|
}
|
|
17203
|
-
return
|
|
17560
|
+
return path30.join(binDir, `${executable.name}.wasm`);
|
|
17204
17561
|
}
|
|
17205
17562
|
function projectDiagnostic(output, layout2, files) {
|
|
17206
17563
|
const base = layout2.multi ? layout2.root : layout2.sources;
|
|
17207
|
-
const prefix = `${base}${
|
|
17564
|
+
const prefix = `${base}${path30.sep}`;
|
|
17208
17565
|
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();
|
|
17209
17566
|
}
|
|
17210
17567
|
var ROOT_LOCKS = Symbol.for("peachsim.swiftCompile.rootLocks");
|
|
@@ -17240,13 +17597,13 @@ function serialize(root, work, signal) {
|
|
|
17240
17597
|
function readCompiledArtifact(directory, hash) {
|
|
17241
17598
|
try {
|
|
17242
17599
|
const receipt = JSON.parse(
|
|
17243
|
-
|
|
17600
|
+
readFileSync18(path30.join(directory, "artifact.json"), "utf8")
|
|
17244
17601
|
);
|
|
17245
17602
|
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")
|
|
17246
17603
|
return null;
|
|
17247
|
-
const bytes =
|
|
17248
|
-
const gzip2 =
|
|
17249
|
-
if (
|
|
17604
|
+
const bytes = readFileSync18(path30.join(directory, "app.wasm"));
|
|
17605
|
+
const gzip2 = readFileSync18(path30.join(directory, "icu.gz"));
|
|
17606
|
+
if (createHash15("sha256").update(bytes).digest("hex") !== receipt.wasm || createHash15("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length <= 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
|
|
17250
17607
|
return null;
|
|
17251
17608
|
return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 } };
|
|
17252
17609
|
} catch (error) {
|
|
@@ -17256,25 +17613,25 @@ function readCompiledArtifact(directory, hash) {
|
|
|
17256
17613
|
}
|
|
17257
17614
|
}
|
|
17258
17615
|
function saveCompiledArtifact(root, artifact) {
|
|
17259
|
-
const directory =
|
|
17260
|
-
|
|
17261
|
-
const pending =
|
|
17616
|
+
const directory = path30.join(root, "artifact");
|
|
17617
|
+
mkdirSync8(directory, { recursive: true });
|
|
17618
|
+
const pending = mkdtempSync4(path30.join(root, ".artifact-"));
|
|
17262
17619
|
try {
|
|
17263
|
-
|
|
17264
|
-
|
|
17265
|
-
|
|
17266
|
-
|
|
17620
|
+
writeFileSync9(path30.join(pending, "app.wasm"), artifact.bytes);
|
|
17621
|
+
writeFileSync9(path30.join(pending, "icu.gz"), artifact.icu.gzip);
|
|
17622
|
+
writeFileSync9(
|
|
17623
|
+
path30.join(pending, "artifact.json"),
|
|
17267
17624
|
JSON.stringify({
|
|
17268
17625
|
hash: artifact.hash,
|
|
17269
|
-
wasm:
|
|
17626
|
+
wasm: createHash15("sha256").update(artifact.bytes).digest("hex"),
|
|
17270
17627
|
icu: artifact.icu.sha256
|
|
17271
17628
|
})
|
|
17272
17629
|
);
|
|
17273
17630
|
for (const file of ["app.wasm", "icu.gz", "artifact.json"]) {
|
|
17274
|
-
|
|
17631
|
+
renameSync3(path30.join(pending, file), path30.join(directory, file));
|
|
17275
17632
|
}
|
|
17276
17633
|
} finally {
|
|
17277
|
-
|
|
17634
|
+
rmSync8(pending, { recursive: true, force: true });
|
|
17278
17635
|
}
|
|
17279
17636
|
}
|
|
17280
17637
|
var SHARED_ARTIFACT_BUDGET_BYTES = 4 * 1024 ** 3;
|
|
@@ -17293,21 +17650,21 @@ function renewSharedArtifact(sharedRoot) {
|
|
|
17293
17650
|
function pruneSharedArtifacts(parent, keep) {
|
|
17294
17651
|
const entries = [];
|
|
17295
17652
|
for (const name2 of readdirSync8(parent)) {
|
|
17296
|
-
const directory =
|
|
17653
|
+
const directory = path30.join(parent, name2);
|
|
17297
17654
|
if (name2.startsWith(RETIRED_PREFIX)) {
|
|
17298
17655
|
reapRetiredCacheDirectory(parent, name2);
|
|
17299
17656
|
continue;
|
|
17300
17657
|
}
|
|
17301
17658
|
try {
|
|
17302
17659
|
let bytes = 0;
|
|
17303
|
-
for (const file of readdirSync8(
|
|
17660
|
+
for (const file of readdirSync8(path30.join(directory, "artifact"))) {
|
|
17304
17661
|
try {
|
|
17305
|
-
bytes +=
|
|
17662
|
+
bytes += statSync3(path30.join(directory, "artifact", file)).size;
|
|
17306
17663
|
} catch (error) {
|
|
17307
17664
|
if (!vanished(error)) throw error;
|
|
17308
17665
|
}
|
|
17309
17666
|
}
|
|
17310
|
-
entries.push({ directory, used:
|
|
17667
|
+
entries.push({ directory, used: statSync3(directory).mtimeMs, bytes });
|
|
17311
17668
|
} catch (error) {
|
|
17312
17669
|
if (!vanished(error)) throw error;
|
|
17313
17670
|
}
|
|
@@ -17317,13 +17674,13 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
17317
17674
|
if (total <= SHARED_ARTIFACT_BUDGET_BYTES) break;
|
|
17318
17675
|
if (entry.directory === keep || Date.now() - entry.used < SHARED_ARTIFACT_GRACE_MS)
|
|
17319
17676
|
continue;
|
|
17320
|
-
const retired =
|
|
17677
|
+
const retired = path30.join(
|
|
17321
17678
|
parent,
|
|
17322
|
-
`${RETIRED_PREFIX}${process.pid}-${
|
|
17679
|
+
`${RETIRED_PREFIX}${process.pid}-${path30.basename(entry.directory)}`
|
|
17323
17680
|
);
|
|
17324
17681
|
try {
|
|
17325
|
-
if (
|
|
17326
|
-
|
|
17682
|
+
if (statSync3(entry.directory).mtimeMs !== entry.used) continue;
|
|
17683
|
+
renameSync3(entry.directory, retired);
|
|
17327
17684
|
} catch (error) {
|
|
17328
17685
|
if (vanished(error)) continue;
|
|
17329
17686
|
throw error;
|
|
@@ -17335,7 +17692,7 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
17335
17692
|
function saveSharedArtifact(sharedRoot, artifact) {
|
|
17336
17693
|
saveCompiledArtifact(sharedRoot, artifact);
|
|
17337
17694
|
renewSharedArtifact(sharedRoot);
|
|
17338
|
-
pruneSharedArtifacts(
|
|
17695
|
+
pruneSharedArtifacts(path30.dirname(sharedRoot), sharedRoot);
|
|
17339
17696
|
}
|
|
17340
17697
|
var retainedArtifacts = /* @__PURE__ */ new Map();
|
|
17341
17698
|
function retain(root, artifact) {
|
|
@@ -17363,7 +17720,7 @@ function frameworkLibraryTargets(manifest) {
|
|
|
17363
17720
|
}
|
|
17364
17721
|
function linkedFrameworkTargets(moduleRoot, input) {
|
|
17365
17722
|
const libraries = frameworkLibraryTargets(
|
|
17366
|
-
|
|
17723
|
+
readFileSync18(path30.join(moduleRoot, "Package.swift"), "utf8")
|
|
17367
17724
|
);
|
|
17368
17725
|
const targets = compileTargets(input);
|
|
17369
17726
|
const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
|
|
@@ -17386,7 +17743,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
17386
17743
|
for (const name2 of [...siblings.values()].flat())
|
|
17387
17744
|
if (libraries.has(name2) && !planning.some((target) => target.name === name2))
|
|
17388
17745
|
reach(name2);
|
|
17389
|
-
const manifest =
|
|
17746
|
+
const manifest = readFileSync18(path30.join(moduleRoot, "Package.swift"), "utf8");
|
|
17390
17747
|
const targetDependencies = /* @__PURE__ */ new Map();
|
|
17391
17748
|
for (const match of manifest.matchAll(
|
|
17392
17749
|
/\.target\(\s*name:\s*"([^"]+)"\s*,\s*dependencies:\s*\[([^\]]*)\]/g
|
|
@@ -17403,12 +17760,12 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
17403
17760
|
};
|
|
17404
17761
|
for (const name2 of reached)
|
|
17405
17762
|
for (const member of libraries.get(name2) ?? []) build(member);
|
|
17406
|
-
const overlays =
|
|
17763
|
+
const overlays = path30.join(moduleRoot, "cross-import-overlays");
|
|
17407
17764
|
for (const directory of readdirSync8(overlays)) {
|
|
17408
|
-
const companion =
|
|
17765
|
+
const companion = path30.basename(directory, ".swiftcrossimport");
|
|
17409
17766
|
if (!built.has(companion)) continue;
|
|
17410
|
-
const declaration =
|
|
17411
|
-
for (const match of
|
|
17767
|
+
const declaration = path30.join(overlays, directory, "SwiftUI.swiftoverlay");
|
|
17768
|
+
for (const match of readFileSync18(declaration, "utf8").matchAll(
|
|
17412
17769
|
/^\s*- name: ([A-Za-z_]\w*)\s*$/gm
|
|
17413
17770
|
))
|
|
17414
17771
|
reach(match[1]);
|
|
@@ -17434,7 +17791,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
17434
17791
|
return { products: linked, targets: linkedMembers };
|
|
17435
17792
|
}
|
|
17436
17793
|
function writeFrameworkLinkPackage(linkRoot, moduleRoot, products) {
|
|
17437
|
-
const identity =
|
|
17794
|
+
const identity = path30.basename(moduleRoot).toLowerCase();
|
|
17438
17795
|
const swiftString = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
17439
17796
|
const dependencies = products.map(
|
|
17440
17797
|
(name2) => ` .product(name: ${swiftString(name2)}, package: ${swiftString(identity)}),`
|
|
@@ -17456,13 +17813,13 @@ ${dependencies}
|
|
|
17456
17813
|
]
|
|
17457
17814
|
)
|
|
17458
17815
|
`;
|
|
17459
|
-
const sourceDir =
|
|
17460
|
-
|
|
17461
|
-
const manifestPath =
|
|
17462
|
-
if (!
|
|
17463
|
-
|
|
17464
|
-
const source =
|
|
17465
|
-
if (!
|
|
17816
|
+
const sourceDir = path30.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
|
|
17817
|
+
mkdirSync8(sourceDir, { recursive: true });
|
|
17818
|
+
const manifestPath = path30.join(linkRoot, "Package.swift");
|
|
17819
|
+
if (!existsSync7(manifestPath) || readFileSync18(manifestPath, "utf8") !== manifest)
|
|
17820
|
+
writeFileSync9(manifestPath, manifest);
|
|
17821
|
+
const source = path30.join(sourceDir, "Link.swift");
|
|
17822
|
+
if (!existsSync7(source)) writeFileSync9(source, "");
|
|
17466
17823
|
}
|
|
17467
17824
|
function frameworkLinkClosure(scratch2, roots) {
|
|
17468
17825
|
const suffix = `${WASM_TRIPLE}-release`;
|
|
@@ -17473,7 +17830,7 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
17473
17830
|
const moduleMaps = /* @__PURE__ */ new Map();
|
|
17474
17831
|
let pending = null;
|
|
17475
17832
|
let compiling = null;
|
|
17476
|
-
for (const line of
|
|
17833
|
+
for (const line of readFileSync18(path30.join(scratch2, "release.yaml"), "utf8").split(
|
|
17477
17834
|
"\n"
|
|
17478
17835
|
)) {
|
|
17479
17836
|
const phony = phonyHeader.exec(line);
|
|
@@ -17537,7 +17894,7 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
17537
17894
|
owners.set(file, name2);
|
|
17538
17895
|
if (seen.has(file)) continue;
|
|
17539
17896
|
seen.add(file);
|
|
17540
|
-
if (!
|
|
17897
|
+
if (!existsSync7(file))
|
|
17541
17898
|
throw new Error(`swift-compile: framework object ${file} was not built`);
|
|
17542
17899
|
files.push(file);
|
|
17543
17900
|
}
|
|
@@ -17547,19 +17904,19 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
17547
17904
|
return { objects: files, owners, modules, moduleMaps: [...maps].sort() };
|
|
17548
17905
|
}
|
|
17549
17906
|
function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
|
|
17550
|
-
if (!
|
|
17907
|
+
if (!existsSync7(modulesDir)) return;
|
|
17551
17908
|
const folded = new Set([...keep].map((name2) => name2.toLowerCase()));
|
|
17552
17909
|
for (const name2 of readdirSync8(modulesDir)) {
|
|
17553
17910
|
const dot = name2.indexOf(".");
|
|
17554
17911
|
if (dot <= 0) continue;
|
|
17555
17912
|
const module = name2.slice(0, dot);
|
|
17556
17913
|
if (keep.has(module) || !folded.has(module.toLowerCase())) continue;
|
|
17557
|
-
|
|
17914
|
+
rmSync8(path30.join(modulesDir, name2), { recursive: true, force: true });
|
|
17558
17915
|
}
|
|
17559
17916
|
}
|
|
17560
17917
|
async function buildFrameworkProducts(scratch2, args) {
|
|
17561
17918
|
const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input);
|
|
17562
|
-
const linkRoot =
|
|
17919
|
+
const linkRoot = path30.join(scratch2, "link");
|
|
17563
17920
|
writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products);
|
|
17564
17921
|
await runCompiler(
|
|
17565
17922
|
args.swift,
|
|
@@ -17592,7 +17949,7 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17592
17949
|
"-Xswiftc",
|
|
17593
17950
|
String(swiftBuildJobs()),
|
|
17594
17951
|
...swiftReproducibleBuildFlags([
|
|
17595
|
-
[
|
|
17952
|
+
[path30.dirname(args.toolchainBin), "toolchain"],
|
|
17596
17953
|
[args.moduleRoot, "framework"],
|
|
17597
17954
|
[scratch2, "framework-scratch"]
|
|
17598
17955
|
]),
|
|
@@ -17617,16 +17974,16 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17617
17974
|
).catch((error) => {
|
|
17618
17975
|
throw new Error(outputOf(error), { cause: error });
|
|
17619
17976
|
});
|
|
17620
|
-
const release =
|
|
17977
|
+
const release = path30.join(scratch2, WASM_TRIPLE, "release");
|
|
17621
17978
|
const linked = frameworkLinkClosure(scratch2, linkedTargets.targets);
|
|
17622
17979
|
const objects = linked.objects;
|
|
17623
17980
|
if (linked.modules.has("UniformTypeIdentifiers")) {
|
|
17624
|
-
const constantsDir =
|
|
17625
|
-
const constantsStamp =
|
|
17626
|
-
const object3 =
|
|
17627
|
-
if (!
|
|
17628
|
-
|
|
17629
|
-
|
|
17981
|
+
const constantsDir = path30.join(scratch2, "uniform-type-constants");
|
|
17982
|
+
const constantsStamp = path30.join(constantsDir, ".complete");
|
|
17983
|
+
const object3 = path30.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
|
|
17984
|
+
if (!existsSync7(constantsStamp) || readFileSync18(constantsStamp, "utf8") !== args.frameworkKey) {
|
|
17985
|
+
rmSync8(constantsDir, { recursive: true, force: true });
|
|
17986
|
+
mkdirSync8(constantsDir);
|
|
17630
17987
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
17631
17988
|
compileUniformTypeConstants({
|
|
17632
17989
|
bin: args.toolchainBin,
|
|
@@ -17636,35 +17993,35 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17636
17993
|
minimum: darwinRecordsMinimum(),
|
|
17637
17994
|
out: constantsDir
|
|
17638
17995
|
});
|
|
17639
|
-
|
|
17996
|
+
writeFileSync9(constantsStamp, args.frameworkKey);
|
|
17640
17997
|
}
|
|
17641
17998
|
objects.push(object3);
|
|
17642
17999
|
linked.owners.set(object3, "UniformTypeIdentifiers");
|
|
17643
18000
|
}
|
|
17644
|
-
removeCaseCollidingModuleArtifacts(
|
|
17645
|
-
const response =
|
|
17646
|
-
|
|
18001
|
+
removeCaseCollidingModuleArtifacts(path30.join(release, "Modules"), linked.modules);
|
|
18002
|
+
const response = path30.join(scratch2, "autolink-objects.rsp");
|
|
18003
|
+
writeFileSync9(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
|
|
17647
18004
|
const extracted = await runCompiler(
|
|
17648
|
-
|
|
18005
|
+
path30.join(args.toolchainBin, "swift-autolink-extract"),
|
|
17649
18006
|
[`@${response}`, "-o", "-"],
|
|
17650
18007
|
args.buildOptions
|
|
17651
18008
|
);
|
|
17652
|
-
|
|
18009
|
+
rmSync8(response, { force: true });
|
|
17653
18010
|
const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
|
|
17654
18011
|
if (link.includes("-lFoundation"))
|
|
17655
18012
|
for (const name2 of foundationCategoryObjects) {
|
|
17656
|
-
const object3 =
|
|
18013
|
+
const object3 = path30.join(
|
|
17657
18014
|
swiftSdkPaths(args.moduleRoot, args.toolchainBin).resources,
|
|
17658
18015
|
`wasi/${name2}.objc.o`
|
|
17659
18016
|
);
|
|
17660
18017
|
objects.push(object3);
|
|
17661
18018
|
linked.owners.set(object3, "Foundation");
|
|
17662
18019
|
}
|
|
17663
|
-
const providerDir =
|
|
17664
|
-
const providerStamp =
|
|
17665
|
-
if (!
|
|
17666
|
-
|
|
17667
|
-
|
|
18020
|
+
const providerDir = path30.join(scratch2, "darwin-records");
|
|
18021
|
+
const providerStamp = path30.join(providerDir, ".complete");
|
|
18022
|
+
if (!existsSync7(providerStamp) || readFileSync18(providerStamp, "utf8") !== args.frameworkKey) {
|
|
18023
|
+
rmSync8(providerDir, { recursive: true, force: true });
|
|
18024
|
+
mkdirSync8(providerDir);
|
|
17668
18025
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
17669
18026
|
compileDarwinRecords({
|
|
17670
18027
|
bin: args.toolchainBin,
|
|
@@ -17674,20 +18031,20 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17674
18031
|
minimum: darwinRecordsMinimum(),
|
|
17675
18032
|
out: providerDir
|
|
17676
18033
|
});
|
|
17677
|
-
|
|
18034
|
+
writeFileSync9(providerStamp, args.frameworkKey);
|
|
17678
18035
|
}
|
|
17679
|
-
const providers = readdirSync8(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) =>
|
|
18036
|
+
const providers = readdirSync8(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path30.join(providerDir, file));
|
|
17680
18037
|
for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
|
|
17681
|
-
const archive =
|
|
17682
|
-
|
|
17683
|
-
|
|
18038
|
+
const archive = path30.join(scratch2, "lib");
|
|
18039
|
+
rmSync8(archive, { recursive: true, force: true });
|
|
18040
|
+
mkdirSync8(archive);
|
|
17684
18041
|
const archived = /* @__PURE__ */ new Map();
|
|
17685
18042
|
for (const object3 of objects) {
|
|
17686
18043
|
const target = linked.owners.get(object3);
|
|
17687
|
-
const dir =
|
|
17688
|
-
if (!target || target === "Darwin" || !object3.startsWith(dir +
|
|
17689
|
-
const name2 = `${target}-${
|
|
17690
|
-
symlinkSync2(object3,
|
|
18044
|
+
const dir = path30.join(release, `${target}.build`);
|
|
18045
|
+
if (!target || target === "Darwin" || !object3.startsWith(dir + path30.sep)) continue;
|
|
18046
|
+
const name2 = `${target}-${path30.relative(dir, object3).replaceAll(path30.sep, "-").replace(/\.swift\.o$/, ".o")}`;
|
|
18047
|
+
symlinkSync2(object3, path30.join(archive, name2));
|
|
17691
18048
|
archived.set(object3, `lib/${name2}`);
|
|
17692
18049
|
}
|
|
17693
18050
|
const roots = swiftObjcRootObjects(`${scratch2}
|
|
@@ -17696,11 +18053,11 @@ ${args.frameworkKey}`, scratch2, [
|
|
|
17696
18053
|
]);
|
|
17697
18054
|
const linkedObjects = objects.map((object3) => {
|
|
17698
18055
|
const name2 = archived.get(object3);
|
|
17699
|
-
return name2 ? { path:
|
|
18056
|
+
return name2 ? { path: path30.join(scratch2, name2), lazy: !roots.has(name2) } : { path: object3, lazy: false };
|
|
17700
18057
|
});
|
|
17701
18058
|
return {
|
|
17702
18059
|
root: scratch2,
|
|
17703
|
-
modules:
|
|
18060
|
+
modules: path30.join(release, "Modules"),
|
|
17704
18061
|
objects: linkedObjects.filter((object3) => !object3.lazy).map((object3) => object3.path),
|
|
17705
18062
|
lazyObjects: linkedObjects.filter((object3) => object3.lazy).map((object3) => object3.path),
|
|
17706
18063
|
owners: linked.owners,
|
|
@@ -17714,14 +18071,14 @@ var SWIFT_FRAMEWORK_SLOTS = 8;
|
|
|
17714
18071
|
var SWIFT_FRAMEWORK_SLOT_KEY = ".peach-framework-key";
|
|
17715
18072
|
var SWIFT_FRAMEWORK_SLOT_ORIGIN = ".peach-framework-origin";
|
|
17716
18073
|
function swiftFrameworksDir() {
|
|
17717
|
-
return
|
|
18074
|
+
return path30.join(swiftCacheDir(), "swift-frameworks");
|
|
17718
18075
|
}
|
|
17719
18076
|
function swiftFrameworkScratch(frameworkKey) {
|
|
17720
|
-
return
|
|
18077
|
+
return path30.join(swiftFrameworksDir(), frameworkKey);
|
|
17721
18078
|
}
|
|
17722
18079
|
function swiftFrameworkSlotRecord(slot, record) {
|
|
17723
18080
|
try {
|
|
17724
|
-
return
|
|
18081
|
+
return readFileSync18(path30.join(slot, record), "utf8").trim();
|
|
17725
18082
|
} catch (error) {
|
|
17726
18083
|
if (!vanished(error)) throw error;
|
|
17727
18084
|
return null;
|
|
@@ -17732,8 +18089,8 @@ function swiftFrameworkSlotKey(slot) {
|
|
|
17732
18089
|
}
|
|
17733
18090
|
async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
17734
18091
|
const slots = Array.from({ length: SWIFT_FRAMEWORK_SLOTS }, (_, index) => {
|
|
17735
|
-
const slot =
|
|
17736
|
-
|
|
18092
|
+
const slot = path30.join(swiftFrameworksDir(), `slot-${index}`);
|
|
18093
|
+
mkdirSync8(slot, { recursive: true });
|
|
17737
18094
|
return slot;
|
|
17738
18095
|
});
|
|
17739
18096
|
const run2 = (slot) => (lease) => {
|
|
@@ -17743,21 +18100,21 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
|
17743
18100
|
};
|
|
17744
18101
|
const staged = slots.find((slot) => swiftFrameworkSlotKey(slot) === frameworkKey);
|
|
17745
18102
|
if (staged) return withSwiftRootLock(staged, run2(staged), signal);
|
|
17746
|
-
const built = new Map(slots.map((slot) => [slot,
|
|
18103
|
+
const built = new Map(slots.map((slot) => [slot, statSync3(slot).mtimeMs]));
|
|
17747
18104
|
const own = (slot) => swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN) === moduleRoot;
|
|
17748
18105
|
const inputs = new Map(
|
|
17749
18106
|
swiftModuleInputFiles(moduleRoot).map((file) => [
|
|
17750
18107
|
file,
|
|
17751
|
-
|
|
18108
|
+
readFileSync18(path30.join(moduleRoot, file))
|
|
17752
18109
|
])
|
|
17753
18110
|
);
|
|
17754
18111
|
const ranked = slots.map((slot) => {
|
|
17755
18112
|
let changes = 0;
|
|
17756
18113
|
if (swiftFrameworkSlotKey(slot) === null) return { slot, changes: Infinity };
|
|
17757
|
-
const source =
|
|
18114
|
+
const source = path30.join(slot, "source", "packages", path30.basename(moduleRoot));
|
|
17758
18115
|
for (const [file, contents2] of inputs) {
|
|
17759
18116
|
try {
|
|
17760
|
-
if (!
|
|
18117
|
+
if (!readFileSync18(path30.join(source, file)).equals(contents2)) changes++;
|
|
17761
18118
|
} catch (error) {
|
|
17762
18119
|
if (!vanished(error)) throw error;
|
|
17763
18120
|
changes++;
|
|
@@ -17772,7 +18129,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
|
17772
18129
|
slot,
|
|
17773
18130
|
async (lease) => {
|
|
17774
18131
|
console.error(
|
|
17775
|
-
`[swift-framework-cache] ${
|
|
18132
|
+
`[swift-framework-cache] ${path30.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`
|
|
17776
18133
|
);
|
|
17777
18134
|
return { value: await run2(slot)(lease) };
|
|
17778
18135
|
},
|
|
@@ -17785,14 +18142,14 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
|
17785
18142
|
return withSwiftRootLock(nearest, run2(nearest), signal);
|
|
17786
18143
|
}
|
|
17787
18144
|
function mirrorTree2(source, target, skip) {
|
|
17788
|
-
|
|
18145
|
+
mkdirSync8(target, { recursive: true });
|
|
17789
18146
|
const wanted = /* @__PURE__ */ new Set();
|
|
17790
18147
|
let restructured = false;
|
|
17791
18148
|
for (const entry of readdirSync8(source, { withFileTypes: true })) {
|
|
17792
18149
|
if (entry.name === skip) continue;
|
|
17793
18150
|
wanted.add(entry.name);
|
|
17794
|
-
const from =
|
|
17795
|
-
const to =
|
|
18151
|
+
const from = path30.join(source, entry.name);
|
|
18152
|
+
const to = path30.join(target, entry.name);
|
|
17796
18153
|
let existing = null;
|
|
17797
18154
|
try {
|
|
17798
18155
|
existing = lstatSync(to);
|
|
@@ -17801,75 +18158,75 @@ function mirrorTree2(source, target, skip) {
|
|
|
17801
18158
|
}
|
|
17802
18159
|
if (!existing) restructured = true;
|
|
17803
18160
|
if (entry.isDirectory()) {
|
|
17804
|
-
if (existing && !existing.isDirectory())
|
|
18161
|
+
if (existing && !existing.isDirectory()) rmSync8(to, { force: true });
|
|
17805
18162
|
if (mirrorTree2(from, to)) restructured = true;
|
|
17806
18163
|
} else if (entry.isSymbolicLink()) {
|
|
17807
18164
|
const link = readlinkSync(from);
|
|
17808
18165
|
if (existing?.isSymbolicLink() && readlinkSync(to) === link) continue;
|
|
17809
|
-
if (existing)
|
|
18166
|
+
if (existing) rmSync8(to, { recursive: true, force: true });
|
|
17810
18167
|
symlinkSync2(link, to);
|
|
17811
18168
|
} else {
|
|
17812
|
-
const stat =
|
|
17813
|
-
if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs ||
|
|
18169
|
+
const stat = statSync3(from);
|
|
18170
|
+
if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs || readFileSync18(from).equals(readFileSync18(to))))
|
|
17814
18171
|
continue;
|
|
17815
|
-
if (existing)
|
|
18172
|
+
if (existing) rmSync8(to, { recursive: true, force: true });
|
|
17816
18173
|
const partial = `${to}.${randomUUID5()}`;
|
|
17817
18174
|
copyFileSync(from, partial);
|
|
17818
18175
|
utimesSync(partial, stat.atime, stat.mtime);
|
|
17819
|
-
|
|
18176
|
+
renameSync3(partial, to);
|
|
17820
18177
|
}
|
|
17821
18178
|
}
|
|
17822
18179
|
for (const name2 of readdirSync8(target))
|
|
17823
18180
|
if (!wanted.has(name2) && name2 !== skip) {
|
|
17824
|
-
|
|
18181
|
+
rmSync8(path30.join(target, name2), { recursive: true, force: true });
|
|
17825
18182
|
restructured = true;
|
|
17826
18183
|
}
|
|
17827
18184
|
return restructured;
|
|
17828
18185
|
}
|
|
17829
18186
|
function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
17830
18187
|
if (!slot) return moduleRoot;
|
|
17831
|
-
const staged =
|
|
17832
|
-
const stagedModule =
|
|
18188
|
+
const staged = path30.join(slot, "source");
|
|
18189
|
+
const stagedModule = path30.join(staged, "packages", path30.basename(moduleRoot));
|
|
17833
18190
|
if (swiftFrameworkSlotKey(slot) !== frameworkKey) {
|
|
17834
|
-
|
|
18191
|
+
rmSync8(path30.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
|
|
17835
18192
|
const moduleRestructured = mirrorTree2(moduleRoot, stagedModule, ".build");
|
|
17836
18193
|
const sdkRestructured = mirrorTree2(
|
|
17837
18194
|
swiftSharedSdkRoot(moduleRoot, false),
|
|
17838
|
-
|
|
18195
|
+
path30.join(staged, "packages/peachsim/sdk/ios")
|
|
17839
18196
|
);
|
|
17840
18197
|
if (moduleRestructured || sdkRestructured) {
|
|
17841
|
-
|
|
17842
|
-
|
|
18198
|
+
rmSync8(path30.join(slot, "release.yaml"), { force: true });
|
|
18199
|
+
rmSync8(path30.join(slot, "release", "description.json"), { force: true });
|
|
17843
18200
|
}
|
|
17844
18201
|
for (const file of swiftModuleInputFiles(moduleRoot)) {
|
|
17845
18202
|
if (!file.startsWith("../")) continue;
|
|
17846
|
-
const from =
|
|
17847
|
-
const to =
|
|
17848
|
-
if (
|
|
17849
|
-
|
|
18203
|
+
const from = path30.resolve(moduleRoot, file);
|
|
18204
|
+
const to = path30.resolve(stagedModule, file);
|
|
18205
|
+
if (existsSync7(to) && readFileSync18(from).equals(readFileSync18(to))) continue;
|
|
18206
|
+
mkdirSync8(path30.dirname(to), { recursive: true });
|
|
17850
18207
|
copyFileSync(from, to);
|
|
17851
18208
|
}
|
|
17852
18209
|
if (swiftProjectBuildKey(stagedModule, release) !== frameworkKey)
|
|
17853
18210
|
throw new Error("Swift staged framework source differs from the caller");
|
|
17854
|
-
const modules =
|
|
17855
|
-
const target = realpathSync6(
|
|
17856
|
-
if (!
|
|
17857
|
-
|
|
18211
|
+
const modules = path30.join(staged, "node_modules");
|
|
18212
|
+
const target = realpathSync6(path30.join(moduleRoot, "../../node_modules"));
|
|
18213
|
+
if (!existsSync7(modules) || readlinkSync(modules) !== target) {
|
|
18214
|
+
rmSync8(modules, { recursive: true, force: true });
|
|
17858
18215
|
symlinkSync2(target, modules);
|
|
17859
18216
|
}
|
|
17860
|
-
|
|
17861
|
-
|
|
18217
|
+
writeFileSync9(path30.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
|
|
18218
|
+
writeFileSync9(path30.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
|
|
17862
18219
|
}
|
|
17863
18220
|
return stagedModule;
|
|
17864
18221
|
}
|
|
17865
18222
|
function swiftLinkStamp(args) {
|
|
17866
|
-
const hash =
|
|
18223
|
+
const hash = createHash15("sha256");
|
|
17867
18224
|
hash.update(`swift-link/v1
|
|
17868
18225
|
${args.frameworkKey}
|
|
17869
18226
|
`);
|
|
17870
18227
|
if (!args.prebuilt) return hash.digest("hex");
|
|
17871
18228
|
const statOf = (file) => {
|
|
17872
|
-
const stat =
|
|
18229
|
+
const stat = statSync3(file, { bigint: true });
|
|
17873
18230
|
return `${stat.size}:${stat.mtimeNs}`;
|
|
17874
18231
|
};
|
|
17875
18232
|
for (const object3 of args.prebuilt.objects)
|
|
@@ -17896,23 +18253,23 @@ ${args.prebuilt.modules}
|
|
|
17896
18253
|
`);
|
|
17897
18254
|
for (const entry of readdirSync8(args.prebuilt.modules).sort())
|
|
17898
18255
|
hash.update(`${entry}
|
|
17899
|
-
${statOf(
|
|
18256
|
+
${statOf(path30.join(args.prebuilt.modules, entry))}`);
|
|
17900
18257
|
return hash.digest("hex");
|
|
17901
18258
|
}
|
|
17902
18259
|
function retireStaleSwiftLink(root, stamp) {
|
|
17903
|
-
const receipt =
|
|
18260
|
+
const receipt = path30.join(root, SWIFT_LINK_STAMP);
|
|
17904
18261
|
let previous = null;
|
|
17905
18262
|
try {
|
|
17906
|
-
previous =
|
|
18263
|
+
previous = readFileSync18(receipt, "utf8").trim();
|
|
17907
18264
|
} catch (error) {
|
|
17908
18265
|
if (!vanished(error)) throw error;
|
|
17909
18266
|
}
|
|
17910
|
-
|
|
17911
|
-
|
|
18267
|
+
mkdirSync8(root, { recursive: true });
|
|
18268
|
+
writeFileSync9(receipt, `${stamp}
|
|
17912
18269
|
`);
|
|
17913
|
-
const retired =
|
|
17914
|
-
if (previous === stamp || !
|
|
17915
|
-
|
|
18270
|
+
const retired = path30.join(root, ".build");
|
|
18271
|
+
if (previous === stamp || !existsSync7(retired)) return false;
|
|
18272
|
+
rmSync8(retired, { recursive: true, force: true });
|
|
17916
18273
|
return true;
|
|
17917
18274
|
}
|
|
17918
18275
|
async function compileSwiftProjectUnit(input, options) {
|
|
@@ -17927,21 +18284,21 @@ async function compileSwiftProjectUnit(input, options) {
|
|
|
17927
18284
|
}
|
|
17928
18285
|
function compileSwiftProjectOnce(input, options) {
|
|
17929
18286
|
options.signal?.throwIfAborted();
|
|
17930
|
-
|
|
18287
|
+
mkdirSync8(options.buildRoot, { recursive: true });
|
|
17931
18288
|
const root = realpathSync6(options.buildRoot);
|
|
17932
|
-
const moduleRoot =
|
|
18289
|
+
const moduleRoot = path30.resolve(options.moduleRoot);
|
|
17933
18290
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
17934
18291
|
const guestGraph = distribution ? input.sourceLinkGraph : void 0;
|
|
17935
18292
|
if (options.linkOnly && guestGraph)
|
|
17936
18293
|
throw new Error("swift-compile: link-only builds do not support guest image graphs");
|
|
17937
18294
|
const layout2 = {
|
|
17938
18295
|
root,
|
|
17939
|
-
sources:
|
|
18296
|
+
sources: path30.join(root, "Sources", "App"),
|
|
17940
18297
|
multi: compileTargets(input).length > 0
|
|
17941
18298
|
};
|
|
17942
18299
|
const hash = swiftArtifactHash(input, options.release, moduleRoot);
|
|
17943
18300
|
const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
|
|
17944
|
-
const sharedRoot =
|
|
18301
|
+
const sharedRoot = path30.join(swiftCacheDir(), "swift-projects", hash);
|
|
17945
18302
|
const report = (message) => {
|
|
17946
18303
|
console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
|
|
17947
18304
|
options.onStage?.(message);
|
|
@@ -17956,8 +18313,8 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
17956
18313
|
report("reusing memory artifact");
|
|
17957
18314
|
return retain(root, retained);
|
|
17958
18315
|
}
|
|
17959
|
-
const cached = readCompiledArtifact(
|
|
17960
|
-
const previous = cached ?? (options.project ? null : readCompiledArtifact(
|
|
18316
|
+
const cached = readCompiledArtifact(path30.join(sharedRoot, "artifact"), hash);
|
|
18317
|
+
const previous = cached ?? (options.project ? null : readCompiledArtifact(path30.join(root, "artifact"), hash));
|
|
17961
18318
|
if (previous) {
|
|
17962
18319
|
if (cached) renewSharedArtifact(sharedRoot);
|
|
17963
18320
|
else saveSharedArtifact(sharedRoot, previous);
|
|
@@ -17966,10 +18323,10 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
17966
18323
|
}
|
|
17967
18324
|
}
|
|
17968
18325
|
if (!options.intermediates && process.platform === "darwin" && process.env.TM_SESSION && !windowAdmission() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
|
|
17969
|
-
const requestRoot =
|
|
17970
|
-
const output =
|
|
17971
|
-
const request =
|
|
17972
|
-
|
|
18326
|
+
const requestRoot = mkdtempSync4(`${root}.builder-request-`);
|
|
18327
|
+
const output = path30.join(requestRoot, "output");
|
|
18328
|
+
const request = path30.join(requestRoot, "request.json");
|
|
18329
|
+
writeFileSync9(
|
|
17973
18330
|
request,
|
|
17974
18331
|
JSON.stringify({
|
|
17975
18332
|
input,
|
|
@@ -17982,12 +18339,12 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
17982
18339
|
})
|
|
17983
18340
|
);
|
|
17984
18341
|
try {
|
|
17985
|
-
const repo =
|
|
18342
|
+
const repo = path30.resolve(moduleRoot, "../..");
|
|
17986
18343
|
report("requesting builder admission or cached result");
|
|
17987
18344
|
await runCompiler(
|
|
17988
18345
|
"bun",
|
|
17989
18346
|
[
|
|
17990
|
-
|
|
18347
|
+
path30.join(repo, "scripts/build/swift-project.ts"),
|
|
17991
18348
|
"--request",
|
|
17992
18349
|
request,
|
|
17993
18350
|
"--output",
|
|
@@ -18015,7 +18372,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18015
18372
|
report("builder artifact verified");
|
|
18016
18373
|
return retain(root, artifact);
|
|
18017
18374
|
} finally {
|
|
18018
|
-
|
|
18375
|
+
rmSync8(requestRoot, { recursive: true, force: true });
|
|
18019
18376
|
}
|
|
18020
18377
|
}
|
|
18021
18378
|
return withSwiftCompileBudget(options.timeoutMs, options.signal, async (budget) => {
|
|
@@ -18023,14 +18380,14 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18023
18380
|
root,
|
|
18024
18381
|
async (lease) => {
|
|
18025
18382
|
if (!options.intermediates) {
|
|
18026
|
-
const built = readCompiledArtifact(
|
|
18383
|
+
const built = readCompiledArtifact(path30.join(sharedRoot, "artifact"), hash);
|
|
18027
18384
|
if (built) {
|
|
18028
18385
|
report("reusing verified disk artifact");
|
|
18029
18386
|
return retain(root, built);
|
|
18030
18387
|
}
|
|
18031
18388
|
}
|
|
18032
|
-
const swift =
|
|
18033
|
-
if (!
|
|
18389
|
+
const swift = path30.join(options.toolchainBin, "swift");
|
|
18390
|
+
if (!existsSync7(swift)) {
|
|
18034
18391
|
throw new Error(
|
|
18035
18392
|
`swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
|
|
18036
18393
|
);
|
|
@@ -18064,8 +18421,8 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18064
18421
|
// shipped host plugins resolve against the selected compiler's runtime.
|
|
18065
18422
|
...process.platform === "linux" ? {
|
|
18066
18423
|
LD_LIBRARY_PATH: [
|
|
18067
|
-
|
|
18068
|
-
|
|
18424
|
+
path30.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
18425
|
+
path30.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
18069
18426
|
process.env.LD_LIBRARY_PATH
|
|
18070
18427
|
].filter(Boolean).join(":")
|
|
18071
18428
|
} : {},
|
|
@@ -18104,21 +18461,22 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18104
18461
|
layout2,
|
|
18105
18462
|
input,
|
|
18106
18463
|
frameworkRoot,
|
|
18107
|
-
prebuilt
|
|
18464
|
+
prebuilt,
|
|
18465
|
+
!options.project
|
|
18108
18466
|
);
|
|
18109
|
-
const productFile =
|
|
18467
|
+
const productFile = path30.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
|
|
18110
18468
|
writeSwiftAutolinkLinker(
|
|
18111
18469
|
root,
|
|
18112
18470
|
options.toolchainBin,
|
|
18113
|
-
|
|
18471
|
+
existsSync7(productFile) ? [
|
|
18114
18472
|
v5.parse(
|
|
18115
18473
|
swiftFrameworkProductSchema,
|
|
18116
|
-
JSON.parse(
|
|
18474
|
+
JSON.parse(readFileSync18(productFile, "utf8"))
|
|
18117
18475
|
).product.name
|
|
18118
18476
|
] : []
|
|
18119
18477
|
);
|
|
18120
18478
|
const projectProcess = options.project ? prepareSwiftProjectProcess(root, options.project) : void 0;
|
|
18121
|
-
const compiler = preparation.targetToolset ? { CC:
|
|
18479
|
+
const compiler = preparation.targetToolset ? { CC: path30.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
|
|
18122
18480
|
const appOptions = projectProcess ? {
|
|
18123
18481
|
...buildOptions,
|
|
18124
18482
|
uid: projectProcess.uid,
|
|
@@ -18132,10 +18490,10 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18132
18490
|
for (const [file, text2] of Object.entries(input.files)) {
|
|
18133
18491
|
const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text2)?.[1];
|
|
18134
18492
|
if (!parents) continue;
|
|
18135
|
-
const directory =
|
|
18493
|
+
const directory = path30.posix.dirname(file);
|
|
18136
18494
|
forwarders.set(
|
|
18137
|
-
`${
|
|
18138
|
-
|
|
18495
|
+
`${path30.join(root, directory)}/${parents.slice(0, -1)}`,
|
|
18496
|
+
path30.posix.join("build", directory, parents).replace(/\/$/, "")
|
|
18139
18497
|
);
|
|
18140
18498
|
}
|
|
18141
18499
|
const buildArgs = [
|
|
@@ -18151,7 +18509,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18151
18509
|
...swiftObjCSelectorOptions(frameworkRoot),
|
|
18152
18510
|
"--swift-sdk",
|
|
18153
18511
|
sdk,
|
|
18154
|
-
...preparation.targetToolset ? ["--toolset",
|
|
18512
|
+
...preparation.targetToolset ? ["--toolset", path30.join(root, ".peach-target-toolset.json")] : [],
|
|
18155
18513
|
"-c",
|
|
18156
18514
|
"release",
|
|
18157
18515
|
// the link strips debug info, so none is generated (as for the framework)
|
|
@@ -18162,14 +18520,14 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18162
18520
|
"-Xswiftc",
|
|
18163
18521
|
String(swiftBuildJobs()),
|
|
18164
18522
|
...swiftReproducibleBuildFlags([
|
|
18165
|
-
[
|
|
18523
|
+
[path30.dirname(options.toolchainBin), "toolchain"],
|
|
18166
18524
|
[frameworkRoot, "framework"],
|
|
18167
18525
|
[root, "build"],
|
|
18168
18526
|
...forwarders
|
|
18169
18527
|
]).flatMap((flag, index, flags) => {
|
|
18170
18528
|
if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
|
|
18171
18529
|
return [flag];
|
|
18172
|
-
const toolchainDir =
|
|
18530
|
+
const toolchainDir = path30.dirname(options.toolchainBin);
|
|
18173
18531
|
let mapped = flag;
|
|
18174
18532
|
for (const [dir, target] of [
|
|
18175
18533
|
[root, "/peach/build"],
|
|
@@ -18198,9 +18556,9 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18198
18556
|
])
|
|
18199
18557
|
];
|
|
18200
18558
|
const linked = builtArtifact(layout2);
|
|
18201
|
-
|
|
18202
|
-
if (options.linkOnly ||
|
|
18203
|
-
|
|
18559
|
+
rmSync8(path30.join(root, ".peach-link.rsp"), { force: true });
|
|
18560
|
+
if (options.linkOnly || existsSync7(linked) && statSync3(linked).size <= 8)
|
|
18561
|
+
rmSync8(linked, { force: true });
|
|
18204
18562
|
report("compiling and linking Swift modules");
|
|
18205
18563
|
const frameworkInterfaces = /* @__PURE__ */ new Map();
|
|
18206
18564
|
const nativeDeclarations = /* @__PURE__ */ new Map();
|
|
@@ -18210,58 +18568,58 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18210
18568
|
const name2 = moduleMapName(contents2);
|
|
18211
18569
|
const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
|
|
18212
18570
|
if (!name2 || !umbrella) continue;
|
|
18213
|
-
const header = input.files[
|
|
18571
|
+
const header = input.files[path30.posix.join(path30.posix.dirname(file), umbrella)];
|
|
18214
18572
|
if (header === void 0) continue;
|
|
18215
18573
|
const included = new Set(
|
|
18216
18574
|
[
|
|
18217
18575
|
...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
|
|
18218
|
-
].map((match) =>
|
|
18576
|
+
].map((match) => path30.posix.basename(match[1]))
|
|
18219
18577
|
);
|
|
18220
18578
|
const declarations = nativeDeclarations.get(name2) ?? /* @__PURE__ */ new Set();
|
|
18221
18579
|
for (const declaration of swiftInterfaceDeclarations(header))
|
|
18222
18580
|
declarations.add(declaration);
|
|
18223
18581
|
for (const [candidate, source] of Object.entries(input.files))
|
|
18224
|
-
if (included.has(
|
|
18582
|
+
if (included.has(path30.posix.basename(candidate)))
|
|
18225
18583
|
for (const declaration of swiftInterfaceDeclarations(source))
|
|
18226
18584
|
declarations.add(declaration);
|
|
18227
18585
|
nativeDeclarations.set(name2, declarations);
|
|
18228
18586
|
}
|
|
18229
18587
|
const frameworkInterface = (name2) => {
|
|
18230
18588
|
if (frameworkInterfaces.has(name2)) return frameworkInterfaces.get(name2);
|
|
18231
|
-
const source = distribution ?
|
|
18589
|
+
const source = distribution ? path30.join(frameworkRoot, "modules", `${name2}-Swift.h`) : path30.join(
|
|
18232
18590
|
prebuilt.modules,
|
|
18233
18591
|
"..",
|
|
18234
18592
|
`${name2}.build/include/${name2}-Swift.h`
|
|
18235
18593
|
);
|
|
18236
|
-
if (!
|
|
18594
|
+
if (!existsSync7(source)) {
|
|
18237
18595
|
frameworkInterfaces.set(name2, null);
|
|
18238
18596
|
return null;
|
|
18239
18597
|
}
|
|
18240
|
-
const headers =
|
|
18598
|
+
const headers = path30.join(
|
|
18241
18599
|
swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
|
|
18242
18600
|
`System/Library/Frameworks/${name2}.framework/Headers`
|
|
18243
18601
|
);
|
|
18244
18602
|
const declared = /* @__PURE__ */ new Set();
|
|
18245
|
-
if (
|
|
18603
|
+
if (existsSync7(headers)) {
|
|
18246
18604
|
for (const file of readdirSync8(headers, {
|
|
18247
18605
|
recursive: true,
|
|
18248
18606
|
encoding: "utf8"
|
|
18249
18607
|
}))
|
|
18250
18608
|
if (file.endsWith(".h"))
|
|
18251
18609
|
for (const name3 of swiftInterfaceDeclarations(
|
|
18252
|
-
|
|
18610
|
+
readFileSync18(path30.join(headers, file), "utf8")
|
|
18253
18611
|
))
|
|
18254
18612
|
declared.add(name3);
|
|
18255
18613
|
}
|
|
18256
18614
|
for (const declaration of nativeDeclarations.get(name2) ?? [])
|
|
18257
18615
|
declared.add(declaration);
|
|
18258
18616
|
const own = withoutSwiftDeclarations(
|
|
18259
|
-
clangInterfaceHeader(
|
|
18617
|
+
clangInterfaceHeader(readFileSync18(source, "utf8")),
|
|
18260
18618
|
declared,
|
|
18261
18619
|
nativeDeclarations.has(name2) ? `@import ${name2};` : `#import <${name2}/${name2}.h>`
|
|
18262
18620
|
);
|
|
18263
18621
|
const owners = sdkObjCDeclarationOwners(
|
|
18264
|
-
|
|
18622
|
+
path30.dirname(path30.dirname(headers))
|
|
18265
18623
|
);
|
|
18266
18624
|
const foreign = /* @__PURE__ */ new Map();
|
|
18267
18625
|
for (const declaration of [
|
|
@@ -18280,117 +18638,140 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18280
18638
|
[...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
|
|
18281
18639
|
) : own;
|
|
18282
18640
|
const value = {
|
|
18283
|
-
file:
|
|
18641
|
+
file: path30.join(root, ".build/peach-framework-objc", `${name2}-Swift.h`),
|
|
18284
18642
|
header,
|
|
18285
|
-
module:
|
|
18643
|
+
module: existsSync7(headers)
|
|
18286
18644
|
};
|
|
18287
18645
|
frameworkInterfaces.set(name2, value);
|
|
18288
18646
|
writeBuildFile(
|
|
18289
18647
|
value.file,
|
|
18290
|
-
(
|
|
18648
|
+
(existsSync7(path30.join(headers, `${name2}.h`)) ? `#import <${name2}/${name2}.h>
|
|
18291
18649
|
` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
|
|
18292
18650
|
);
|
|
18293
18651
|
return value;
|
|
18294
18652
|
};
|
|
18295
|
-
const
|
|
18653
|
+
const headerPaths = (producer) => {
|
|
18654
|
+
const stem = path30.join(
|
|
18655
|
+
root,
|
|
18656
|
+
".build",
|
|
18657
|
+
"peach-cxx-headers",
|
|
18658
|
+
`${producer}-Swift`
|
|
18659
|
+
);
|
|
18660
|
+
return { producer, original: `${stem}.original.h`, emitted: `${stem}.h` };
|
|
18661
|
+
};
|
|
18662
|
+
const publishHeader = ({
|
|
18663
|
+
producer,
|
|
18664
|
+
original,
|
|
18665
|
+
emitted
|
|
18666
|
+
}) => {
|
|
18667
|
+
const generated = clangInterfaceHeader(readFileSync18(original, "utf8"));
|
|
18668
|
+
writeBuildFile(
|
|
18669
|
+
emitted,
|
|
18670
|
+
withoutSwiftDeclarations(
|
|
18671
|
+
swiftHeaderWithSuperclassImports(generated, frameworkInterface),
|
|
18672
|
+
/* @__PURE__ */ new Set([
|
|
18673
|
+
...preparation.nativeHeaderDeclarations[producer] ?? [],
|
|
18674
|
+
...nativelyDeclaredFunctions(generated, nativeHeaders)
|
|
18675
|
+
]),
|
|
18676
|
+
`#import <${producer}/${producer}.h>`
|
|
18677
|
+
)
|
|
18678
|
+
);
|
|
18679
|
+
};
|
|
18680
|
+
const recipe = createHash15("sha256").update(hash).update(readFileSync18(path30.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
|
|
18681
|
+
const runApp = async (compiler2) => {
|
|
18682
|
+
const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
|
|
18296
18683
|
const stages = [
|
|
18297
18684
|
...preparation.headerBuilds,
|
|
18298
18685
|
...preparation.nativeProductTarget ? [{ target: preparation.nativeProductTarget, producers: [] }] : []
|
|
18299
18686
|
];
|
|
18300
|
-
const checkpoints =
|
|
18301
|
-
const recipe = createHash14("sha256").update(hash).update(readFileSync17(path28.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
|
|
18687
|
+
const checkpoints = path30.join(root, ".build", "peach-product-checkpoints");
|
|
18302
18688
|
for (const { target, producers } of stages) {
|
|
18303
|
-
const receipt =
|
|
18689
|
+
const receipt = path30.join(
|
|
18304
18690
|
checkpoints,
|
|
18305
|
-
|
|
18691
|
+
createHash15("sha256").update(target).digest("hex")
|
|
18306
18692
|
);
|
|
18307
|
-
const headers = producers.map(
|
|
18308
|
-
const stem = path28.join(
|
|
18309
|
-
root,
|
|
18310
|
-
".build",
|
|
18311
|
-
"peach-cxx-headers",
|
|
18312
|
-
`${producer}-Swift`
|
|
18313
|
-
);
|
|
18314
|
-
return {
|
|
18315
|
-
producer,
|
|
18316
|
-
original: `${stem}.original.h`,
|
|
18317
|
-
emitted: `${stem}.h`
|
|
18318
|
-
};
|
|
18319
|
-
});
|
|
18693
|
+
const headers = producers.map(headerPaths);
|
|
18320
18694
|
const fingerprint = () => {
|
|
18321
|
-
const digest =
|
|
18322
|
-
for (const { emitted } of headers) {
|
|
18323
|
-
if (!
|
|
18695
|
+
const digest = createHash15("sha256").update(recipe);
|
|
18696
|
+
for (const { original, emitted } of headers) {
|
|
18697
|
+
if (!existsSync7(original) || !existsSync7(emitted)) return;
|
|
18324
18698
|
digest.update(
|
|
18325
|
-
|
|
18699
|
+
createHash15("sha256").update(readFileSync18(emitted)).digest()
|
|
18326
18700
|
);
|
|
18327
18701
|
}
|
|
18328
18702
|
return digest.digest("hex");
|
|
18329
18703
|
};
|
|
18330
|
-
if (!options.project &&
|
|
18704
|
+
if (!options.project && existsSync7(receipt) && readFileSync18(receipt, "utf8") === fingerprint())
|
|
18331
18705
|
continue;
|
|
18332
|
-
if (!options.project)
|
|
18333
|
-
for (const
|
|
18334
|
-
if (
|
|
18335
|
-
|
|
18336
|
-
|
|
18337
|
-
|
|
18338
|
-
|
|
18339
|
-
WASM_TRIPLE,
|
|
18340
|
-
"release",
|
|
18706
|
+
if (!options.project) rmSync8(receipt, { force: true });
|
|
18707
|
+
for (const header of headers) {
|
|
18708
|
+
if (compiler2 && existsSync7(header.original)) publishHeader(header);
|
|
18709
|
+
if (!existsSync7(header.original))
|
|
18710
|
+
rmSync8(
|
|
18711
|
+
path30.join(
|
|
18712
|
+
path30.dirname(linked),
|
|
18341
18713
|
"Modules",
|
|
18342
|
-
`${swiftTargetModuleName(producer)}.swiftmodule`
|
|
18714
|
+
`${swiftTargetModuleName(header.producer)}.swiftmodule`
|
|
18343
18715
|
),
|
|
18344
18716
|
{ force: true }
|
|
18345
18717
|
);
|
|
18718
|
+
}
|
|
18346
18719
|
await runCompiler(
|
|
18347
18720
|
swift,
|
|
18348
18721
|
[...buildArgs, "--target", target],
|
|
18349
|
-
|
|
18722
|
+
optionsWithCompiler,
|
|
18350
18723
|
SWIFTPM_PROGRESS,
|
|
18351
18724
|
SWIFTPM_NOISE
|
|
18352
18725
|
);
|
|
18353
|
-
for (const
|
|
18354
|
-
const generated = clangInterfaceHeader(readFileSync17(original, "utf8"));
|
|
18355
|
-
writeBuildFile(
|
|
18356
|
-
emitted,
|
|
18357
|
-
withoutSwiftDeclarations(
|
|
18358
|
-
swiftHeaderWithSuperclassImports(generated, frameworkInterface),
|
|
18359
|
-
/* @__PURE__ */ new Set([
|
|
18360
|
-
...preparation.nativeHeaderDeclarations[producer] ?? [],
|
|
18361
|
-
...nativelyDeclaredFunctions(generated, nativeHeaders)
|
|
18362
|
-
]),
|
|
18363
|
-
`#import <${producer}/${producer}.h>`
|
|
18364
|
-
)
|
|
18365
|
-
);
|
|
18366
|
-
}
|
|
18726
|
+
if (!compiler2) for (const header of headers) publishHeader(header);
|
|
18367
18727
|
if (!options.project) {
|
|
18368
|
-
|
|
18369
|
-
|
|
18370
|
-
|
|
18728
|
+
const checkpoint = fingerprint();
|
|
18729
|
+
if (checkpoint === void 0)
|
|
18730
|
+
throw new Error(`missing Swift headers after building ${target}`);
|
|
18731
|
+
mkdirSync8(checkpoints, { recursive: true });
|
|
18732
|
+
writeFileSync9(`${receipt}.partial`, checkpoint);
|
|
18733
|
+
renameSync3(`${receipt}.partial`, receipt);
|
|
18371
18734
|
}
|
|
18372
18735
|
}
|
|
18373
18736
|
await runCompiler(
|
|
18374
18737
|
swift,
|
|
18375
18738
|
buildArgs,
|
|
18376
|
-
|
|
18739
|
+
optionsWithCompiler,
|
|
18377
18740
|
SWIFTPM_PROGRESS,
|
|
18378
18741
|
SWIFTPM_NOISE
|
|
18379
18742
|
);
|
|
18380
18743
|
};
|
|
18744
|
+
const compileApp = () => preparation.headerCompiler ? withSwiftHeaderCompiler(
|
|
18745
|
+
root,
|
|
18746
|
+
options.toolchainBin,
|
|
18747
|
+
recipe,
|
|
18748
|
+
new Map(
|
|
18749
|
+
preparation.headerBuilds[0].producers.map((producer) => {
|
|
18750
|
+
const paths = headerPaths(producer);
|
|
18751
|
+
return [
|
|
18752
|
+
swiftTargetModuleName(producer),
|
|
18753
|
+
{
|
|
18754
|
+
header: paths.original,
|
|
18755
|
+
publish: () => publishHeader(paths)
|
|
18756
|
+
}
|
|
18757
|
+
];
|
|
18758
|
+
})
|
|
18759
|
+
),
|
|
18760
|
+
runApp
|
|
18761
|
+
) : runApp();
|
|
18381
18762
|
try {
|
|
18382
18763
|
await compileApp();
|
|
18383
18764
|
} catch (error) {
|
|
18384
18765
|
const output2 = outputOf(error);
|
|
18385
|
-
const moduleCache =
|
|
18766
|
+
const moduleCache = path30.join(
|
|
18386
18767
|
root,
|
|
18387
18768
|
".build",
|
|
18388
18769
|
WASM_TRIPLE,
|
|
18389
18770
|
"release",
|
|
18390
18771
|
"ModuleCache"
|
|
18391
18772
|
);
|
|
18392
|
-
if (output2.includes("was compiled with module cache path") &&
|
|
18393
|
-
|
|
18773
|
+
if (output2.includes("was compiled with module cache path") && existsSync7(moduleCache)) {
|
|
18774
|
+
rmSync8(moduleCache, { recursive: true, force: true });
|
|
18394
18775
|
try {
|
|
18395
18776
|
await compileApp();
|
|
18396
18777
|
} catch (retryError) {
|
|
@@ -18414,11 +18795,11 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18414
18795
|
if (options.project) endSwiftProjectProcesses(options.project);
|
|
18415
18796
|
}
|
|
18416
18797
|
if (unprepared.length) throw new Error(unprepared.join("\n"));
|
|
18417
|
-
if (!
|
|
18418
|
-
const binDir =
|
|
18419
|
-
const found =
|
|
18798
|
+
if (!existsSync7(linked)) {
|
|
18799
|
+
const binDir = path30.dirname(linked);
|
|
18800
|
+
const found = existsSync7(binDir) ? readdirSync8(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
|
|
18420
18801
|
throw new Error(
|
|
18421
|
-
`swift-compile: the build produced no ${
|
|
18802
|
+
`swift-compile: the build produced no ${path30.basename(linked)} (found: ${found.join(", ") || "none"})`
|
|
18422
18803
|
);
|
|
18423
18804
|
}
|
|
18424
18805
|
if (options.project) removeProjectLinks(root);
|
|
@@ -18436,7 +18817,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18436
18817
|
resourceReferences
|
|
18437
18818
|
);
|
|
18438
18819
|
if (options.linkOnly) {
|
|
18439
|
-
if (
|
|
18820
|
+
if (statSync3(linked).size <= 8)
|
|
18440
18821
|
throw new Error("swift-compile: deferred linker produced no executable");
|
|
18441
18822
|
report("project link verified");
|
|
18442
18823
|
return;
|
|
@@ -18447,9 +18828,10 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18447
18828
|
await compileGuestLink({
|
|
18448
18829
|
graph: guestGraph,
|
|
18449
18830
|
buildDirectory: root,
|
|
18450
|
-
releaseDirectory:
|
|
18831
|
+
releaseDirectory: path30.dirname(linked),
|
|
18451
18832
|
moduleRoot: frameworkRoot,
|
|
18452
18833
|
toolchainBin: options.toolchainBin,
|
|
18834
|
+
swiftCompiler: preparation.headerCompiler ? path30.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : path30.join(options.toolchainBin, "swiftc"),
|
|
18453
18835
|
sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
|
|
18454
18836
|
sdk: swiftModuleSdk(frameworkRoot),
|
|
18455
18837
|
staticClangTargets: input.staticClangTargets ?? [],
|
|
@@ -18462,13 +18844,13 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18462
18844
|
else
|
|
18463
18845
|
await lowerWasm(output, optimized, { optimize: input.optimize === true });
|
|
18464
18846
|
await runCompiler(
|
|
18465
|
-
|
|
18847
|
+
path30.join(options.toolchainBin, "llvm-objcopy"),
|
|
18466
18848
|
["--remove-section=.swift1_autolink_entries", optimized],
|
|
18467
18849
|
buildOptions
|
|
18468
18850
|
);
|
|
18469
18851
|
const artifact = {
|
|
18470
18852
|
hash,
|
|
18471
|
-
bytes:
|
|
18853
|
+
bytes: readFileSync18(optimized),
|
|
18472
18854
|
icu: await icu
|
|
18473
18855
|
};
|
|
18474
18856
|
if (artifact.bytes.length <= 8)
|