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
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -95,10 +95,10 @@ __export(swift_compile_exports, {
|
|
|
95
95
|
});
|
|
96
96
|
module.exports = __toCommonJS(swift_compile_exports);
|
|
97
97
|
var import_node_child_process19 = require("node:child_process");
|
|
98
|
-
var
|
|
99
|
-
var
|
|
98
|
+
var import_node_crypto15 = require("node:crypto");
|
|
99
|
+
var import_node_fs26 = require("node:fs");
|
|
100
100
|
var import_node_os10 = __toESM(require("node:os"), 1);
|
|
101
|
-
var
|
|
101
|
+
var import_node_path28 = __toESM(require("node:path"), 1);
|
|
102
102
|
var v5 = __toESM(require("valibot"), 1);
|
|
103
103
|
|
|
104
104
|
// src/admitted-mac-build.ts
|
|
@@ -3699,7 +3699,7 @@ function swiftManifestTargets(manifest, resourcePaths = [], readArguments) {
|
|
|
3699
3699
|
const targets = [];
|
|
3700
3700
|
const packageCall = manifestCalls(manifest, ["Package"])[0];
|
|
3701
3701
|
const platformArgument = packageCall ? splitManifestArguments(packageCall.call.slice(0, -1)).find(
|
|
3702
|
-
(
|
|
3702
|
+
(argument2) => /^platforms\s*:/.test(argument2)
|
|
3703
3703
|
) : void 0;
|
|
3704
3704
|
const platformList = /^platforms\s*:\s*\[([\s\S]*)\]$/.exec(platformArgument ?? "")?.[1];
|
|
3705
3705
|
const iosPlatforms = [
|
|
@@ -3740,7 +3740,7 @@ function swiftManifestTargets(manifest, resourcePaths = [], readArguments) {
|
|
|
3740
3740
|
);
|
|
3741
3741
|
const targetArguments = splitManifestArguments(call.slice(0, -1));
|
|
3742
3742
|
const sourceArgument = targetArguments.find(
|
|
3743
|
-
(
|
|
3743
|
+
(argument2) => /^sources\s*:/.test(argument2)
|
|
3744
3744
|
);
|
|
3745
3745
|
const sourceList = sourceArgument?.replace(/^sources\s*:\s*/, "").trim();
|
|
3746
3746
|
if (sourceList && sourceList !== "nil" && !(sourceList.startsWith("[") && sourceList.endsWith("]")))
|
|
@@ -3754,7 +3754,7 @@ function swiftManifestTargets(manifest, resourcePaths = [], readArguments) {
|
|
|
3754
3754
|
return swiftStringValue(literal2[1], `a source of target ${name2}`).replace(/^\.\//, "").replace(/\/+$/, "");
|
|
3755
3755
|
}) : void 0;
|
|
3756
3756
|
const dependencyArgument = targetArguments.find(
|
|
3757
|
-
(
|
|
3757
|
+
(argument2) => /^dependencies\s*:/.test(argument2)
|
|
3758
3758
|
);
|
|
3759
3759
|
const dependencyList = dependencyArgument?.replace(/^dependencies\s*:\s*/, "").trim();
|
|
3760
3760
|
const dependencies = [];
|
|
@@ -4731,9 +4731,9 @@ var EXCERPT = /^(\s*)(\d+)( \| )(.*)$/;
|
|
|
4731
4731
|
var MARKER = /^(\s*)( \| )(.*)$/;
|
|
4732
4732
|
function designTimeDiagnostic(output, files) {
|
|
4733
4733
|
const rewritten = /* @__PURE__ */ new Map();
|
|
4734
|
-
const linesOf = (
|
|
4734
|
+
const linesOf = (path27) => {
|
|
4735
4735
|
const file = Object.keys(files).find(
|
|
4736
|
-
(name2) => name2.endsWith(".swift") && (
|
|
4736
|
+
(name2) => name2.endsWith(".swift") && (path27 === name2 || path27.endsWith(`/${name2}`))
|
|
4737
4737
|
);
|
|
4738
4738
|
if (file === void 0) return null;
|
|
4739
4739
|
let lines = rewritten.get(file);
|
|
@@ -9366,7 +9366,7 @@ function linkGuestImages(options) {
|
|
|
9366
9366
|
const trace = import_node_path14.default.join(directory, `${name2}-inputs.txt`);
|
|
9367
9367
|
import_node_fs14.default.writeFileSync(
|
|
9368
9368
|
response,
|
|
9369
|
-
[...arguments_, "--trace"].map((
|
|
9369
|
+
[...arguments_, "--trace"].map((argument2) => JSON.stringify(argument2)).join(" ")
|
|
9370
9370
|
);
|
|
9371
9371
|
const output = import_node_fs14.default.openSync(trace, "w");
|
|
9372
9372
|
try {
|
|
@@ -10244,7 +10244,7 @@ function sourceGuestClangLinkOptions(options) {
|
|
|
10244
10244
|
const command = commands.get(file);
|
|
10245
10245
|
if (!command) throw new Error(`missing source object producer ${file}`);
|
|
10246
10246
|
if (command.tool === "shell") {
|
|
10247
|
-
if (!command.args.length || (0, import_node_fs15.realpathSync)(command.args[0]) !== (0, import_node_fs15.realpathSync)(
|
|
10247
|
+
if (!command.args.length || (0, import_node_fs15.realpathSync)(command.args[0]) !== (0, import_node_fs15.realpathSync)(options.swiftCompiler))
|
|
10248
10248
|
throw new Error(`unsupported source object producer ${file}`);
|
|
10249
10249
|
continue;
|
|
10250
10250
|
}
|
|
@@ -11338,6 +11338,7 @@ async function compileGuestLink(options) {
|
|
|
11338
11338
|
buildDirectory: options.buildDirectory,
|
|
11339
11339
|
directory,
|
|
11340
11340
|
toolchainBin: options.toolchainBin,
|
|
11341
|
+
swiftCompiler: options.swiftCompiler,
|
|
11341
11342
|
objects: selectedSource.map((artifact) => artifact.path)
|
|
11342
11343
|
});
|
|
11343
11344
|
const links = sourceGuestRuntimeLinks({
|
|
@@ -11530,13 +11531,472 @@ async function compileGuestLink(options) {
|
|
|
11530
11531
|
(0, import_node_fs18.writeFileSync)(options.optimized, finalized.wasm);
|
|
11531
11532
|
}
|
|
11532
11533
|
|
|
11533
|
-
// src/swift-
|
|
11534
|
-
var import_node_child_process15 = require("node:child_process");
|
|
11534
|
+
// src/swift-header-compiler.ts
|
|
11535
11535
|
var import_node_crypto12 = require("node:crypto");
|
|
11536
11536
|
var import_node_fs19 = require("node:fs");
|
|
11537
|
+
var import_node_http = require("node:http");
|
|
11538
|
+
var import_node_path20 = __toESM(require("node:path"), 1);
|
|
11539
|
+
|
|
11540
|
+
// src/forked-script-contract.ts
|
|
11541
|
+
var PEACH_FORKED_SCRIPT_ENV = "PEACH_RUNS_FORKED_SCRIPTS";
|
|
11542
|
+
|
|
11543
|
+
// src/swift-header-compiler.ts
|
|
11544
|
+
var SWIFT_HEADER_COMPILER_WRAPPER = ".build/peach-swiftc";
|
|
11545
|
+
var argument = (value) => `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
11546
|
+
var client = `const { request } = require('node:http')
|
|
11547
|
+
const { spawnSync } = require('node:child_process')
|
|
11548
|
+
const { existsSync } = require('node:fs')
|
|
11549
|
+
const [socketPath, moduleName, swiftc, receipt, ...args] = process.argv.slice(2)
|
|
11550
|
+
const body = JSON.stringify(args)
|
|
11551
|
+
const notify = (method) => new Promise((resolve, reject) => {
|
|
11552
|
+
const req = request({ socketPath, path: '/' + moduleName, method }, response => {
|
|
11553
|
+
let message = ''
|
|
11554
|
+
response.setEncoding('utf8').on('data', data => { message += data })
|
|
11555
|
+
response.on('end', () => {
|
|
11556
|
+
if (response.statusCode === 200 || response.statusCode === 204) resolve(response.statusCode === 200)
|
|
11557
|
+
else reject(new Error(message))
|
|
11558
|
+
})
|
|
11559
|
+
response.on('error', reject)
|
|
11560
|
+
})
|
|
11561
|
+
req.on('error', reject)
|
|
11562
|
+
req.end(body)
|
|
11563
|
+
})
|
|
11564
|
+
async function compile() {
|
|
11565
|
+
if (existsSync(receipt) && await notify('PUT')) return
|
|
11566
|
+
const result = spawnSync(swiftc, args, { stdio: 'inherit' })
|
|
11567
|
+
if (result.error) throw result.error
|
|
11568
|
+
if (result.status !== 0) { process.exitCode = result.status ?? 1; return }
|
|
11569
|
+
await notify('POST')
|
|
11570
|
+
}
|
|
11571
|
+
compile().catch(error => {
|
|
11572
|
+
process.stderr.write(String(error) + '\\n')
|
|
11573
|
+
process.exitCode = 1
|
|
11574
|
+
})
|
|
11575
|
+
`;
|
|
11576
|
+
function compilerCheckpoint(root, recipe, args, header) {
|
|
11577
|
+
const value = (flag) => {
|
|
11578
|
+
const index = args.lastIndexOf(flag);
|
|
11579
|
+
return index < 0 ? void 0 : args[index + 1];
|
|
11580
|
+
};
|
|
11581
|
+
const outputMap = value("-output-file-map");
|
|
11582
|
+
const module2 = value("-emit-module-path");
|
|
11583
|
+
if (!outputMap || !module2 || !args.includes("-whole-module-optimization")) return;
|
|
11584
|
+
const mapText = (0, import_node_fs19.readFileSync)(outputMap, "utf8");
|
|
11585
|
+
const map = JSON.parse(mapText);
|
|
11586
|
+
if (!isRecord(map) || !isRecord(map[""]) || typeof map[""].dependencies !== "string")
|
|
11587
|
+
return;
|
|
11588
|
+
const objects = [];
|
|
11589
|
+
for (const [source, outputs2] of Object.entries(map)) {
|
|
11590
|
+
if (!source) continue;
|
|
11591
|
+
if (!isRecord(outputs2) || typeof outputs2.object !== "string") return;
|
|
11592
|
+
objects.push(outputs2.object);
|
|
11593
|
+
}
|
|
11594
|
+
if (!objects.length) return;
|
|
11595
|
+
const outputs = [module2, header, map[""].dependencies, ...objects];
|
|
11596
|
+
const digest = (0, import_node_crypto12.createHash)("sha256").update(recipe).update(JSON.stringify(args)).update(mapText);
|
|
11597
|
+
for (const flag of args) {
|
|
11598
|
+
if (!flag.startsWith("@")) continue;
|
|
11599
|
+
const response = flag.slice(1);
|
|
11600
|
+
if (!import_node_path20.default.isAbsolute(response) || !(0, import_node_fs19.existsSync)(response)) return;
|
|
11601
|
+
digest.update((0, import_node_fs19.readFileSync)(response));
|
|
11602
|
+
}
|
|
11603
|
+
for (const file of outputs) {
|
|
11604
|
+
if (!file.startsWith(import_node_path20.default.join(root, ".build") + import_node_path20.default.sep)) return;
|
|
11605
|
+
const stat = (0, import_node_fs19.statSync)(file, { bigint: true, throwIfNoEntry: false });
|
|
11606
|
+
if (!stat?.isFile() || stat.size === 0n) return;
|
|
11607
|
+
digest.update(JSON.stringify([file, String(stat.size), String(stat.mtimeNs)]));
|
|
11608
|
+
}
|
|
11609
|
+
return digest.digest("hex");
|
|
11610
|
+
}
|
|
11611
|
+
async function withSwiftHeaderCompiler(root, toolchainBin, recipe, producers, build) {
|
|
11612
|
+
const wrapper = import_node_path20.default.join(root, SWIFT_HEADER_COMPILER_WRAPPER);
|
|
11613
|
+
const script = import_node_path20.default.join(root, ".build", "peach-swift-header.cjs");
|
|
11614
|
+
const checkpoints = import_node_path20.default.join(root, ".build", "peach-swift-header-checkpoints");
|
|
11615
|
+
(0, import_node_fs19.mkdirSync)(checkpoints, { recursive: true });
|
|
11616
|
+
const swiftc = argument(import_node_path20.default.join(toolchainBin, "swiftc"));
|
|
11617
|
+
writeBuildFile(script, client);
|
|
11618
|
+
writeBuildFile(
|
|
11619
|
+
wrapper,
|
|
11620
|
+
[
|
|
11621
|
+
"#!/bin/sh",
|
|
11622
|
+
"module=; compile=; previous=",
|
|
11623
|
+
'for flag in "$@"; do',
|
|
11624
|
+
' if [ "$previous" = -module-name ]; then module=$flag; fi',
|
|
11625
|
+
' if [ "$flag" = -c ]; then compile=1; fi',
|
|
11626
|
+
" previous=$flag",
|
|
11627
|
+
"done",
|
|
11628
|
+
'case "$compile:$module" in',
|
|
11629
|
+
` ${[...producers.keys()].map((name2) => argument(`1:${name2}`)).join("|")})`,
|
|
11630
|
+
` ${PEACH_FORKED_SCRIPT_ENV}=1 exec ${argument(process.execPath)} ${argument(script)} "$PEACH_SWIFT_HEADER_SOCKET" "$module" ${swiftc} ${argument(checkpoints)}/"$module" "$@" ;;`,
|
|
11631
|
+
"esac",
|
|
11632
|
+
`exec ${swiftc} "$@"`,
|
|
11633
|
+
""
|
|
11634
|
+
].join("\n")
|
|
11635
|
+
);
|
|
11636
|
+
(0, import_node_fs19.chmodSync)(wrapper, 493);
|
|
11637
|
+
const directory = (0, import_node_fs19.mkdtempSync)("/tmp/peach-headers-");
|
|
11638
|
+
const socket = import_node_path20.default.join(directory, "compile");
|
|
11639
|
+
const server = (0, import_node_http.createServer)(async (request, response) => {
|
|
11640
|
+
const module2 = request.url?.slice(1) ?? "";
|
|
11641
|
+
const producer = producers.get(module2);
|
|
11642
|
+
if (!producer) {
|
|
11643
|
+
response.writeHead(404).end("unknown Swift header producer");
|
|
11644
|
+
return;
|
|
11645
|
+
}
|
|
11646
|
+
try {
|
|
11647
|
+
const chunks = [];
|
|
11648
|
+
for await (const chunk of request) chunks.push(chunk);
|
|
11649
|
+
const args = JSON.parse(Buffer.concat(chunks).toString());
|
|
11650
|
+
if (!Array.isArray(args) || !args.every((arg) => typeof arg === "string"))
|
|
11651
|
+
throw new Error("invalid Swift compiler arguments");
|
|
11652
|
+
const receipt = import_node_path20.default.join(checkpoints, module2);
|
|
11653
|
+
const fingerprint = compilerCheckpoint(root, recipe, args, producer.header);
|
|
11654
|
+
if (request.method === "PUT") {
|
|
11655
|
+
if (!fingerprint || !(0, import_node_fs19.existsSync)(receipt) || (0, import_node_fs19.readFileSync)(receipt, "utf8") !== fingerprint) {
|
|
11656
|
+
response.writeHead(204).end();
|
|
11657
|
+
return;
|
|
11658
|
+
}
|
|
11659
|
+
producer.publish();
|
|
11660
|
+
response.end();
|
|
11661
|
+
return;
|
|
11662
|
+
}
|
|
11663
|
+
if (request.method !== "POST")
|
|
11664
|
+
throw new Error("invalid Swift compiler checkpoint method");
|
|
11665
|
+
producer.publish();
|
|
11666
|
+
if (fingerprint) {
|
|
11667
|
+
(0, import_node_fs19.writeFileSync)(`${receipt}.partial`, fingerprint);
|
|
11668
|
+
(0, import_node_fs19.renameSync)(`${receipt}.partial`, receipt);
|
|
11669
|
+
}
|
|
11670
|
+
response.end();
|
|
11671
|
+
} catch (error) {
|
|
11672
|
+
response.writeHead(500).end(String(error));
|
|
11673
|
+
}
|
|
11674
|
+
});
|
|
11675
|
+
try {
|
|
11676
|
+
await new Promise((resolve, reject) => {
|
|
11677
|
+
server.once("error", reject);
|
|
11678
|
+
server.listen(socket, resolve);
|
|
11679
|
+
});
|
|
11680
|
+
return await build({ SWIFT_EXEC: wrapper, PEACH_SWIFT_HEADER_SOCKET: socket });
|
|
11681
|
+
} finally {
|
|
11682
|
+
server.close();
|
|
11683
|
+
server.closeAllConnections();
|
|
11684
|
+
(0, import_node_fs19.rmSync)(directory, { recursive: true, force: true });
|
|
11685
|
+
}
|
|
11686
|
+
}
|
|
11687
|
+
|
|
11688
|
+
// src/swift-header-dependencies.ts
|
|
11689
|
+
var import_node_path21 = __toESM(require("node:path"), 1);
|
|
11690
|
+
|
|
11691
|
+
// src/swiftContract.ts
|
|
11692
|
+
function isSwiftSourceLinkGraph(value) {
|
|
11693
|
+
if (!value || typeof value !== "object") return false;
|
|
11694
|
+
const text2 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
|
|
11695
|
+
const entry = Reflect.get(value, "entry");
|
|
11696
|
+
const targets = Reflect.get(value, "targets");
|
|
11697
|
+
if (!text2(entry) || !Array.isArray(targets) || targets.length > 1024) return false;
|
|
11698
|
+
const ids = /* @__PURE__ */ new Set();
|
|
11699
|
+
for (const target of targets) {
|
|
11700
|
+
if (!target || typeof target !== "object") return false;
|
|
11701
|
+
const id = Reflect.get(target, "id");
|
|
11702
|
+
const source = Reflect.get(target, "sourceTarget");
|
|
11703
|
+
const flags = Reflect.get(target, "linkerFlags");
|
|
11704
|
+
const dependencies = Reflect.get(target, "dependencies");
|
|
11705
|
+
const build = Reflect.get(target, "buildVersion");
|
|
11706
|
+
const nullableText = (value2) => value2 === null || text2(value2);
|
|
11707
|
+
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(
|
|
11708
|
+
(key) => nullableText(Reflect.get(build, key))
|
|
11709
|
+
) || !(Reflect.get(target, "machOType") === null || text2(Reflect.get(target, "machOType"))) || !Array.isArray(flags) || !flags.every(text2) || !Array.isArray(dependencies) || !dependencies.every(
|
|
11710
|
+
(link) => link && typeof link === "object" && text2(Reflect.get(link, "target")) && Array.isArray(Reflect.get(link, "attributes")) && Reflect.get(link, "attributes").every(text2)
|
|
11711
|
+
))
|
|
11712
|
+
return false;
|
|
11713
|
+
ids.add(id);
|
|
11714
|
+
}
|
|
11715
|
+
return ids.has(entry) && targets.every(
|
|
11716
|
+
(target) => Reflect.get(target, "dependencies").every(
|
|
11717
|
+
(link) => ids.has(link.target)
|
|
11718
|
+
)
|
|
11719
|
+
);
|
|
11720
|
+
}
|
|
11721
|
+
var SWIFT_REMOTE_PACKAGES_DIR = "__packages__";
|
|
11722
|
+
var SWIFT_LOCAL_PACKAGES_DIR = "__local_packages__";
|
|
11723
|
+
var SWIFT_XCODE_BUILD_CONDITION = "__PEACH_XCODE_BUILD";
|
|
11724
|
+
function isBase64Bytes(value) {
|
|
11725
|
+
return value.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}(?![\s\S])/.test(value);
|
|
11726
|
+
}
|
|
11727
|
+
function isSwiftPackageFiles(value) {
|
|
11728
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
11729
|
+
([file, bytes]) => isSwiftResourcePath(file) && (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`)) && typeof bytes === "string" && isBase64Bytes(bytes)
|
|
11730
|
+
);
|
|
11731
|
+
}
|
|
11732
|
+
function swiftProjectFileProblem(file) {
|
|
11733
|
+
if (!isSwiftResourcePath(file)) return "not a relative path of plain segments";
|
|
11734
|
+
if (file === "Package.swift") return "would replace the generated manifest";
|
|
11735
|
+
if (file.split("/").includes(".build")) return "is build output (.build)";
|
|
11736
|
+
if (file.startsWith(".")) return 'starts with "." (hidden file or peach output)';
|
|
11737
|
+
if (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`))
|
|
11738
|
+
return "collides with a transported package checkout";
|
|
11739
|
+
return void 0;
|
|
11740
|
+
}
|
|
11741
|
+
function swiftProjectEntryProblem(file, bytes) {
|
|
11742
|
+
return swiftProjectFileProblem(file) ?? (typeof bytes === "string" && isBase64Bytes(bytes) ? void 0 : "bytes are not base64");
|
|
11743
|
+
}
|
|
11744
|
+
function isSwiftProjectFiles(value) {
|
|
11745
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
11746
|
+
([file, bytes]) => swiftProjectEntryProblem(file, bytes) === void 0
|
|
11747
|
+
);
|
|
11748
|
+
}
|
|
11749
|
+
function swiftProjectFilesProblems(value) {
|
|
11750
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
11751
|
+
return ["projectFiles is not an object"];
|
|
11752
|
+
return Object.entries(value).flatMap(([file, bytes]) => {
|
|
11753
|
+
const problem = swiftProjectEntryProblem(file, bytes);
|
|
11754
|
+
return problem ? [`${file}: ${problem}`] : [];
|
|
11755
|
+
});
|
|
11756
|
+
}
|
|
11757
|
+
var SWIFT_NATIVE_INPUT_ROOT = "$(PEACH_INPUT_ROOT)";
|
|
11758
|
+
var SWIFT_NATIVE_SDK_INCLUDE = "$(PEACH_SDK_INCLUDE)";
|
|
11759
|
+
function isSwiftHeaderAliases(value) {
|
|
11760
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
11761
|
+
([alias, file]) => isSwiftResourcePath(alias) && isSwiftResourcePath(file)
|
|
11762
|
+
);
|
|
11763
|
+
}
|
|
11764
|
+
function isSwiftNativeTargets(value) {
|
|
11765
|
+
return swiftNativeTargetsRefusal(value) === null;
|
|
11766
|
+
}
|
|
11767
|
+
function swiftNativeTargetsRefusal(value) {
|
|
11768
|
+
const strings = (value2) => Array.isArray(value2) && value2.every((item) => typeof item === "string" && !item.includes("\0"));
|
|
11769
|
+
const paths = (value2) => strings(value2) && value2.every(isSwiftResourcePath);
|
|
11770
|
+
if (!Array.isArray(value)) return "nativeTargets";
|
|
11771
|
+
if (value.length > 128) return "nativeTargets:length";
|
|
11772
|
+
for (const target of value) {
|
|
11773
|
+
if (!target || typeof target !== "object") return "nativeTargets:shape";
|
|
11774
|
+
const field = (name3) => Reflect.get(target, name3);
|
|
11775
|
+
const name2 = typeof field("name") === "string" ? String(field("name")) : "?";
|
|
11776
|
+
const at = (shape) => `nativeTargets:${name2}:${shape}`;
|
|
11777
|
+
const nullablePath = (key) => field(key) === null || isSwiftResourcePath(field(key));
|
|
11778
|
+
const perFile = field("fileFlags");
|
|
11779
|
+
const directories = field("sourceDirectories");
|
|
11780
|
+
const searches = field("headerSearchPaths");
|
|
11781
|
+
const userSearches = field("userHeaderSearchPaths");
|
|
11782
|
+
const frameworks = field("frameworkSearchPaths");
|
|
11783
|
+
const maps = field("headerMaps");
|
|
11784
|
+
const products = field("productHeaders");
|
|
11785
|
+
const inputPath = (value2) => typeof value2 === "string" && value2.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) && isSwiftResourcePath(value2.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1));
|
|
11786
|
+
const deployment = field("deploymentTarget");
|
|
11787
|
+
const targetName = field("name");
|
|
11788
|
+
if (typeof targetName !== "string" || targetName.length === 0 || targetName.length > 4096 || targetName.includes("\0") || targetName.includes("/") || targetName.includes("\\") || targetName === "." || targetName === "..")
|
|
11789
|
+
return at("name");
|
|
11790
|
+
if (!(deployment === null || typeof deployment === "string" && /^\d+(?:\.\d+){0,2}$/.test(deployment)))
|
|
11791
|
+
return at("deploymentTarget");
|
|
11792
|
+
if (!paths(field("headers"))) return at("headers");
|
|
11793
|
+
if (!paths(field("publicHeaders"))) return at("publicHeaders");
|
|
11794
|
+
if (typeof field("flattensPublicHeaders") !== "boolean")
|
|
11795
|
+
return at("flattensPublicHeaders");
|
|
11796
|
+
if (!nullablePath("bridgingHeader")) return at("bridgingHeader");
|
|
11797
|
+
if (!nullablePath("prefixHeader")) return at("prefixHeader");
|
|
11798
|
+
if (!strings(searches) || !searches.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
11799
|
+
return at("headerSearchPaths");
|
|
11800
|
+
const moduleMaps = field("moduleMaps");
|
|
11801
|
+
if (moduleMaps !== void 0 && (!Array.isArray(moduleMaps) || moduleMaps.length > 128 || !moduleMaps.every((map) => {
|
|
11802
|
+
if (!map || typeof map !== "object") return false;
|
|
11803
|
+
const module2 = Reflect.get(map, "module");
|
|
11804
|
+
const headers = Reflect.get(map, "headers");
|
|
11805
|
+
return typeof module2 === "string" && module2.length > 0 && module2.length <= 4096 && !module2.includes("\0") && (headers === "." || isSwiftResourcePath(headers));
|
|
11806
|
+
})))
|
|
11807
|
+
return at("moduleMaps");
|
|
11808
|
+
if (!strings(userSearches) || !userSearches.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
11809
|
+
return at("userHeaderSearchPaths");
|
|
11810
|
+
if (!strings(frameworks) || !frameworks.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
11811
|
+
return at("frameworkSearchPaths");
|
|
11812
|
+
if (!Array.isArray(maps) || !maps.every((map) => {
|
|
11813
|
+
if (!map || typeof map !== "object") return false;
|
|
11814
|
+
const flag = Reflect.get(map, "flag");
|
|
11815
|
+
const entries = Reflect.get(map, "entries");
|
|
11816
|
+
return (flag === "-I" || flag === "-iquote") && Array.isArray(entries) && entries.every(
|
|
11817
|
+
(entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && !entry[0].includes("\0") && (inputPath(entry[1]) || isSwiftResourcePath(entry[1]))
|
|
11818
|
+
);
|
|
11819
|
+
}))
|
|
11820
|
+
return at("headerMaps");
|
|
11821
|
+
if (!products || typeof products !== "object" || Array.isArray(products) || !Object.entries(products).every(
|
|
11822
|
+
([product, file]) => isSwiftResourcePath(product) && isSwiftResourcePath(file)
|
|
11823
|
+
))
|
|
11824
|
+
return at("productHeaders");
|
|
11825
|
+
if (!strings(field("flags"))) return at("flags");
|
|
11826
|
+
if (!strings(field("importerFlags"))) return at("importerFlags");
|
|
11827
|
+
if (!strings(field("cxxFlags"))) return at("cxxFlags");
|
|
11828
|
+
if (!perFile || typeof perFile !== "object" || Array.isArray(perFile) || !Object.entries(perFile).every(
|
|
11829
|
+
([file, flags]) => isSwiftResourcePath(file) && strings(flags)
|
|
11830
|
+
))
|
|
11831
|
+
return at("fileFlags");
|
|
11832
|
+
if (!directories || typeof directories !== "object" || Array.isArray(directories) || !Object.entries(directories).every(
|
|
11833
|
+
([file, directory]) => isSwiftResourcePath(file) && (directory === "." || isSwiftResourcePath(directory))
|
|
11834
|
+
))
|
|
11835
|
+
return at("sourceDirectories");
|
|
11836
|
+
}
|
|
11837
|
+
return null;
|
|
11838
|
+
}
|
|
11839
|
+
function isSwiftResourcePath(value) {
|
|
11840
|
+
return typeof value === "string" && value.length <= 4096 && !value.startsWith("/") && !value.includes("\\") && !value.includes("\0") && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
11841
|
+
}
|
|
11842
|
+
function isSwiftBundlePath(value) {
|
|
11843
|
+
return typeof value === "string" && (value === "." || isSwiftResourcePath(value) && /\.(bundle|framework)$/.test(value));
|
|
11844
|
+
}
|
|
11845
|
+
function isSwiftResourceBundles(value) {
|
|
11846
|
+
return Array.isArray(value) && value.every(
|
|
11847
|
+
(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)
|
|
11848
|
+
) && new Set(value.map((bundle) => bundle.target)).size === value.length && new Set(value.map((bundle) => bundle.path)).size === value.length;
|
|
11849
|
+
}
|
|
11850
|
+
|
|
11851
|
+
// src/swift-header-dependencies.ts
|
|
11852
|
+
function* nativeHeaderIncludes(source) {
|
|
11853
|
+
for (const match of source.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/^\s*#\s*(?:include|import)\s*[<"]([^>"]+)[>"]/gm))
|
|
11854
|
+
yield match[1];
|
|
11855
|
+
}
|
|
11856
|
+
function swiftHeaderDependencies(root, files, targets, nativeTargets, producers, aliases) {
|
|
11857
|
+
const headers = /* @__PURE__ */ new Map();
|
|
11858
|
+
for (const file of files.keys())
|
|
11859
|
+
if (/\.(?:h|hh|hpp|hxx|inc|inl|ipp|def|modulemap)$/.test(file))
|
|
11860
|
+
headers.set(file, /* @__PURE__ */ new Set());
|
|
11861
|
+
const byDirectory = /* @__PURE__ */ new Map();
|
|
11862
|
+
for (const target of targets) {
|
|
11863
|
+
const directory = import_node_path21.default.resolve(root, target.path);
|
|
11864
|
+
const owners = byDirectory.get(directory) ?? /* @__PURE__ */ new Set();
|
|
11865
|
+
owners.add(target.name);
|
|
11866
|
+
byDirectory.set(directory, owners);
|
|
11867
|
+
}
|
|
11868
|
+
const settings = new Map(nativeTargets.map((native) => [native.name, native]));
|
|
11869
|
+
const physicalHeaders = new Map(
|
|
11870
|
+
Object.entries(aliases).map(([alias, file]) => [
|
|
11871
|
+
import_node_path21.default.resolve(root, alias),
|
|
11872
|
+
import_node_path21.default.resolve(root, file)
|
|
11873
|
+
])
|
|
11874
|
+
);
|
|
11875
|
+
const lookup = new Map(
|
|
11876
|
+
targets.map((target) => {
|
|
11877
|
+
const native = settings.get(target.name);
|
|
11878
|
+
const directory = import_node_path21.default.resolve(root, target.path);
|
|
11879
|
+
const inputPrefix = `${SWIFT_NATIVE_INPUT_ROOT}/`;
|
|
11880
|
+
const flags = native?.importerFlags ?? [];
|
|
11881
|
+
const search = [
|
|
11882
|
+
import_node_path21.default.resolve(directory, target.publicHeadersPath ?? "include"),
|
|
11883
|
+
...(native?.userHeaderSearchPaths ?? []).map((file) => import_node_path21.default.resolve(root, file)),
|
|
11884
|
+
...(native?.headerSearchPaths ?? []).map((file) => import_node_path21.default.resolve(root, file)),
|
|
11885
|
+
...(target.clangSettings ?? []).flatMap(
|
|
11886
|
+
(setting) => "headerSearchPath" in setting ? [import_node_path21.default.resolve(directory, setting.headerSearchPath)] : []
|
|
11887
|
+
),
|
|
11888
|
+
...flags.flatMap(
|
|
11889
|
+
(flag, index) => (flags[index - 1] === "-I" || flags[index - 1] === "-iquote") && flag.startsWith(inputPrefix) ? [import_node_path21.default.resolve(root, flag.slice(inputPrefix.length))] : []
|
|
11890
|
+
)
|
|
11891
|
+
];
|
|
11892
|
+
const mapped = /* @__PURE__ */ new Map();
|
|
11893
|
+
const map = (include, file) => {
|
|
11894
|
+
const key = include.toLowerCase();
|
|
11895
|
+
const files2 = mapped.get(key) ?? [];
|
|
11896
|
+
files2.push(import_node_path21.default.resolve(root, file));
|
|
11897
|
+
mapped.set(key, files2);
|
|
11898
|
+
};
|
|
11899
|
+
for (const headerMap2 of native?.headerMaps ?? []) {
|
|
11900
|
+
for (const [alias, file] of headerMap2.entries) {
|
|
11901
|
+
if (file.startsWith(inputPrefix)) map(alias, file.slice(inputPrefix.length));
|
|
11902
|
+
else {
|
|
11903
|
+
const product = native?.productHeaders[file];
|
|
11904
|
+
if (product) map(alias, product);
|
|
11905
|
+
}
|
|
11906
|
+
}
|
|
11907
|
+
}
|
|
11908
|
+
for (const [alias, file] of Object.entries(native?.productHeaders ?? {}))
|
|
11909
|
+
map(alias, file);
|
|
11910
|
+
if (native?.flattensPublicHeaders)
|
|
11911
|
+
for (const file of native.publicHeaders)
|
|
11912
|
+
map(`${target.name}/${import_node_path21.default.basename(file)}`, file);
|
|
11913
|
+
return [target.name, { search, mapped }];
|
|
11914
|
+
})
|
|
11915
|
+
);
|
|
11916
|
+
const headersByTarget = /* @__PURE__ */ new Map();
|
|
11917
|
+
const ownersOf = (file) => {
|
|
11918
|
+
for (let directory = import_node_path21.default.dirname(file); ; directory = import_node_path21.default.dirname(directory)) {
|
|
11919
|
+
const owners = byDirectory.get(directory);
|
|
11920
|
+
if (owners) return owners;
|
|
11921
|
+
if (directory === root || !directory.startsWith(root + import_node_path21.default.sep)) break;
|
|
11922
|
+
}
|
|
11923
|
+
return /* @__PURE__ */ new Set();
|
|
11924
|
+
};
|
|
11925
|
+
const includers = /* @__PURE__ */ new Map();
|
|
11926
|
+
const enqueue = [];
|
|
11927
|
+
for (const [file, edges] of headers) {
|
|
11928
|
+
const source = files.get(file).toString();
|
|
11929
|
+
const owners = ownersOf(file);
|
|
11930
|
+
for (const owner of owners) {
|
|
11931
|
+
const files2 = headersByTarget.get(owner) ?? /* @__PURE__ */ new Set();
|
|
11932
|
+
files2.add(file);
|
|
11933
|
+
headersByTarget.set(owner, files2);
|
|
11934
|
+
}
|
|
11935
|
+
const moduleMap = file.endsWith(".modulemap");
|
|
11936
|
+
const tokens = moduleMap ? moduleMapTokens(source) : [];
|
|
11937
|
+
const includes = moduleMap ? tokens.flatMap(
|
|
11938
|
+
(token, index) => tokens[index - 1] === "header" && tokens[index - 2] !== "exclude" && token.startsWith('"') ? [token.slice(1, -1)] : []
|
|
11939
|
+
) : nativeHeaderIncludes(source);
|
|
11940
|
+
for (const include of includes) {
|
|
11941
|
+
const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include)?.[1];
|
|
11942
|
+
if (producer && producers.has(producer)) edges.add(producer);
|
|
11943
|
+
const local = import_node_path21.default.resolve(import_node_path21.default.dirname(file), include);
|
|
11944
|
+
const frameworkHeader = moduleMap && /\.framework\/Modules\//.test(file) ? ["../Headers", "../PrivateHeaders"].map(
|
|
11945
|
+
(directory) => import_node_path21.default.resolve(import_node_path21.default.dirname(file), directory, include)
|
|
11946
|
+
) : [];
|
|
11947
|
+
const searchPaths = [...owners].flatMap((owner) => {
|
|
11948
|
+
const { search, mapped } = lookup.get(owner);
|
|
11949
|
+
return [
|
|
11950
|
+
...search.map((directory) => import_node_path21.default.resolve(directory, include)),
|
|
11951
|
+
...mapped.get(include.toLowerCase()) ?? []
|
|
11952
|
+
];
|
|
11953
|
+
});
|
|
11954
|
+
for (const qualified of [local, ...frameworkHeader, ...searchPaths]) {
|
|
11955
|
+
const candidate = physicalHeaders.get(qualified) ?? qualified;
|
|
11956
|
+
if (!headers.has(candidate)) continue;
|
|
11957
|
+
const parents = includers.get(candidate) ?? /* @__PURE__ */ new Set();
|
|
11958
|
+
parents.add(file);
|
|
11959
|
+
includers.set(candidate, parents);
|
|
11960
|
+
}
|
|
11961
|
+
}
|
|
11962
|
+
if (edges.size) enqueue.push(file);
|
|
11963
|
+
}
|
|
11964
|
+
for (let index = 0; index < enqueue.length; index++) {
|
|
11965
|
+
const file = enqueue[index];
|
|
11966
|
+
for (const parent of includers.get(file) ?? []) {
|
|
11967
|
+
const edges = headers.get(parent);
|
|
11968
|
+
const before = edges.size;
|
|
11969
|
+
for (const producer of headers.get(file)) edges.add(producer);
|
|
11970
|
+
if (edges.size > before) enqueue.push(parent);
|
|
11971
|
+
}
|
|
11972
|
+
}
|
|
11973
|
+
return new Map(
|
|
11974
|
+
targets.map((target) => {
|
|
11975
|
+
const native = settings.get(target.name);
|
|
11976
|
+
const publicHeaders = [
|
|
11977
|
+
...native?.headers ?? [],
|
|
11978
|
+
...native?.publicHeaders ?? [],
|
|
11979
|
+
...Object.values(native?.productHeaders ?? {}),
|
|
11980
|
+
...native?.bridgingHeader ? [native.bridgingHeader] : [],
|
|
11981
|
+
...native?.prefixHeader ? [native.prefixHeader] : []
|
|
11982
|
+
].map((file) => import_node_path21.default.resolve(root, file));
|
|
11983
|
+
return [
|
|
11984
|
+
target.name,
|
|
11985
|
+
new Set(
|
|
11986
|
+
[...headersByTarget.get(target.name) ?? [], ...publicHeaders].flatMap((file) => [...headers.get(file) ?? []]).filter((producer) => producer !== target.name)
|
|
11987
|
+
)
|
|
11988
|
+
];
|
|
11989
|
+
})
|
|
11990
|
+
);
|
|
11991
|
+
}
|
|
11992
|
+
|
|
11993
|
+
// src/swift-icu.ts
|
|
11994
|
+
var import_node_child_process15 = require("node:child_process");
|
|
11995
|
+
var import_node_crypto13 = require("node:crypto");
|
|
11996
|
+
var import_node_fs20 = require("node:fs");
|
|
11537
11997
|
var import_promises4 = require("node:fs/promises");
|
|
11538
11998
|
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
11539
|
-
var
|
|
11999
|
+
var import_node_path22 = __toESM(require("node:path"), 1);
|
|
11540
12000
|
var import_node_util2 = require("node:util");
|
|
11541
12001
|
var import_node_zlib2 = require("node:zlib");
|
|
11542
12002
|
|
|
@@ -11605,12 +12065,12 @@ var raw = /* @__PURE__ */ new Map();
|
|
|
11605
12065
|
var assets = /* @__PURE__ */ new Map();
|
|
11606
12066
|
var brotliMemoryCache = /* @__PURE__ */ new Map();
|
|
11607
12067
|
async function cachedBrotli(bytes, quality, cacheKey) {
|
|
11608
|
-
const key = cacheKey && /^[a-f0-9]{64}$/.test(cacheKey) ? cacheKey : (0,
|
|
12068
|
+
const key = cacheKey && /^[a-f0-9]{64}$/.test(cacheKey) ? cacheKey : (0, import_node_crypto13.createHash)("sha256").update(bytes).digest("hex");
|
|
11609
12069
|
const cacheId = `${quality}:${key}`;
|
|
11610
12070
|
const cached = brotliMemoryCache.get(cacheId);
|
|
11611
12071
|
if (cached) return cached;
|
|
11612
|
-
const dir =
|
|
11613
|
-
const file =
|
|
12072
|
+
const dir = import_node_path22.default.join(import_node_os7.default.homedir(), ".peach", "cache", "swift-brotli");
|
|
12073
|
+
const file = import_node_path22.default.join(dir, `${key}${quality === 11 ? "" : "-q4"}.br`);
|
|
11614
12074
|
let compressed;
|
|
11615
12075
|
try {
|
|
11616
12076
|
compressed = await (0, import_promises4.readFile)(file);
|
|
@@ -11623,7 +12083,7 @@ async function cachedBrotli(bytes, quality, cacheKey) {
|
|
|
11623
12083
|
});
|
|
11624
12084
|
try {
|
|
11625
12085
|
await (0, import_promises4.mkdir)(dir, { recursive: true });
|
|
11626
|
-
const tmp = `${file}.${(0,
|
|
12086
|
+
const tmp = `${file}.${(0, import_node_crypto13.randomUUID)()}.tmp`;
|
|
11627
12087
|
await (0, import_promises4.writeFile)(tmp, compressed);
|
|
11628
12088
|
await (0, import_promises4.rename)(tmp, file);
|
|
11629
12089
|
} catch {
|
|
@@ -11658,13 +12118,13 @@ function swiftIcuAsset(toolchainBin, sdk) {
|
|
|
11658
12118
|
JSON.stringify([toolchainBin, sdk, swiftSdkOptions()]),
|
|
11659
12119
|
async () => {
|
|
11660
12120
|
const zipped = await deflate(await swiftIcuData(toolchainBin, sdk));
|
|
11661
|
-
return { sha256: (0,
|
|
12121
|
+
return { sha256: (0, import_node_crypto13.createHash)("sha256").update(zipped).digest("hex"), gzip: zipped };
|
|
11662
12122
|
}
|
|
11663
12123
|
);
|
|
11664
12124
|
}
|
|
11665
12125
|
async function load(toolchainBin, sdk) {
|
|
11666
|
-
const swift =
|
|
11667
|
-
if (!(0,
|
|
12126
|
+
const swift = import_node_path22.default.join(toolchainBin, "swift");
|
|
12127
|
+
if (!(0, import_node_fs20.existsSync)(swift))
|
|
11668
12128
|
throw new Error(`swift-icu: no swift at ${swift} for the ${sdk} SDK's icu data`);
|
|
11669
12129
|
const { stdout: listed } = await run(swift, ["sdk", "list", ...swiftSdkOptions()], {
|
|
11670
12130
|
env: swiftEnvironment()
|
|
@@ -11686,7 +12146,7 @@ async function load(toolchainBin, sdk) {
|
|
|
11686
12146
|
const resources = /^swiftStaticResourcesPath: (.+)$/m.exec(stdout)?.[1]?.trim();
|
|
11687
12147
|
if (!resources) throw new Error(`swift-icu: ${sdk} names no static resources`);
|
|
11688
12148
|
return Buffer.from(
|
|
11689
|
-
icuSegment(archiveMember((0,
|
|
12149
|
+
icuSegment(archiveMember((0, import_node_fs20.readFileSync)(import_node_path22.default.join(resources, ARCHIVE)), MEMBER))
|
|
11690
12150
|
);
|
|
11691
12151
|
}
|
|
11692
12152
|
function archiveMember(archive, name2) {
|
|
@@ -11746,22 +12206,22 @@ function swiftIcuAddress(icu) {
|
|
|
11746
12206
|
var packedFiles = /* @__PURE__ */ new Map();
|
|
11747
12207
|
function swiftIcuPacked(icu) {
|
|
11748
12208
|
return memo(packedFiles, icu.sha256, async () => {
|
|
11749
|
-
const file =
|
|
12209
|
+
const file = import_node_path22.default.join(
|
|
11750
12210
|
import_node_os7.default.homedir(),
|
|
11751
12211
|
".peach",
|
|
11752
12212
|
"cache",
|
|
11753
12213
|
"swift-brotli",
|
|
11754
12214
|
swiftIcuAddress(icu)
|
|
11755
12215
|
);
|
|
11756
|
-
if ((0,
|
|
12216
|
+
if ((0, import_node_fs20.existsSync)(file)) return (0, import_promises4.readFile)(file);
|
|
11757
12217
|
const packed = Buffer.from(
|
|
11758
12218
|
swiftIcuPack(
|
|
11759
12219
|
await inflateGzip(icu.gzip),
|
|
11760
12220
|
(bytes) => (0, import_node_zlib2.deflateRawSync)(bytes, { level: 9 })
|
|
11761
12221
|
)
|
|
11762
12222
|
);
|
|
11763
|
-
await (0, import_promises4.mkdir)(
|
|
11764
|
-
const tmp = `${file}.${(0,
|
|
12223
|
+
await (0, import_promises4.mkdir)(import_node_path22.default.dirname(file), { recursive: true });
|
|
12224
|
+
const tmp = `${file}.${(0, import_node_crypto13.randomUUID)()}.tmp`;
|
|
11765
12225
|
await (0, import_promises4.writeFile)(tmp, packed);
|
|
11766
12226
|
await (0, import_promises4.rename)(tmp, file);
|
|
11767
12227
|
return packed;
|
|
@@ -11776,8 +12236,8 @@ async function swiftIcuBundleAsset(icu) {
|
|
|
11776
12236
|
}
|
|
11777
12237
|
|
|
11778
12238
|
// src/swift-link-roots.ts
|
|
11779
|
-
var
|
|
11780
|
-
var
|
|
12239
|
+
var import_node_fs21 = __toESM(require("node:fs"), 1);
|
|
12240
|
+
var import_node_path23 = __toESM(require("node:path"), 1);
|
|
11781
12241
|
var leb = (bytes, at) => {
|
|
11782
12242
|
let value = 0;
|
|
11783
12243
|
let scale = 1;
|
|
@@ -11872,7 +12332,7 @@ function swiftObjcRootObjects(id, root, objects) {
|
|
|
11872
12332
|
const cached = rootsByDistribution.get(id);
|
|
11873
12333
|
if (cached) return cached;
|
|
11874
12334
|
const measured = objects.map(
|
|
11875
|
-
(object3) => [object3, objcRootInfo(
|
|
12335
|
+
(object3) => [object3, objcRootInfo(import_node_fs21.default.readFileSync(import_node_path23.default.join(root, object3)))]
|
|
11876
12336
|
);
|
|
11877
12337
|
const roots = new Set(
|
|
11878
12338
|
measured.filter(
|
|
@@ -11999,33 +12459,33 @@ function swiftObjCModuleMap(module2, headers, submodules = /* @__PURE__ */ new S
|
|
|
11999
12459
|
|
|
12000
12460
|
// src/swift-project-user.ts
|
|
12001
12461
|
var import_node_child_process16 = require("node:child_process");
|
|
12002
|
-
var
|
|
12003
|
-
var
|
|
12462
|
+
var import_node_fs22 = require("node:fs");
|
|
12463
|
+
var import_node_path24 = __toESM(require("node:path"), 1);
|
|
12004
12464
|
function prepareSwiftProjectProcess(root, user) {
|
|
12005
12465
|
const home = `${root}.project-home`;
|
|
12006
|
-
(0,
|
|
12007
|
-
const tmp =
|
|
12008
|
-
const swiftpm =
|
|
12009
|
-
(0,
|
|
12010
|
-
const caches = ["cache", "config", "security"].map((name2) =>
|
|
12011
|
-
for (const directory of caches) (0,
|
|
12466
|
+
(0, import_node_fs22.rmSync)(home, { recursive: true, force: true });
|
|
12467
|
+
const tmp = import_node_path24.default.join(home, "tmp");
|
|
12468
|
+
const swiftpm = import_node_path24.default.join(home, "swiftpm");
|
|
12469
|
+
(0, import_node_fs22.mkdirSync)(tmp, { recursive: true });
|
|
12470
|
+
const caches = ["cache", "config", "security"].map((name2) => import_node_path24.default.join(swiftpm, name2));
|
|
12471
|
+
for (const directory of caches) (0, import_node_fs22.mkdirSync)(directory, { recursive: true });
|
|
12012
12472
|
(0, import_node_child_process16.execFileSync)("chown", ["-R", "-P", `${user.uid}:${user.gid}`, root, home]);
|
|
12013
|
-
(0,
|
|
12014
|
-
(0,
|
|
12473
|
+
(0, import_node_fs22.chmodSync)(root, 448);
|
|
12474
|
+
(0, import_node_fs22.chmodSync)(home, 448);
|
|
12015
12475
|
return {
|
|
12016
12476
|
uid: user.uid,
|
|
12017
12477
|
gid: user.gid,
|
|
12018
12478
|
env: {
|
|
12019
12479
|
HOME: home,
|
|
12020
12480
|
TMPDIR: tmp,
|
|
12021
|
-
XDG_CONFIG_HOME:
|
|
12022
|
-
XDG_CACHE_HOME:
|
|
12023
|
-
XDG_DATA_HOME:
|
|
12481
|
+
XDG_CONFIG_HOME: import_node_path24.default.join(home, ".config"),
|
|
12482
|
+
XDG_CACHE_HOME: import_node_path24.default.join(home, ".cache"),
|
|
12483
|
+
XDG_DATA_HOME: import_node_path24.default.join(home, ".local", "share")
|
|
12024
12484
|
},
|
|
12025
12485
|
cacheOptions: [
|
|
12026
12486
|
...["cache", "config", "security"].flatMap((name2) => [
|
|
12027
12487
|
`--${name2}-path`,
|
|
12028
|
-
|
|
12488
|
+
import_node_path24.default.join(swiftpm, name2)
|
|
12029
12489
|
]),
|
|
12030
12490
|
"--disable-keychain"
|
|
12031
12491
|
]
|
|
@@ -12038,10 +12498,10 @@ function endSwiftProjectProcesses(user) {
|
|
|
12038
12498
|
});
|
|
12039
12499
|
}
|
|
12040
12500
|
function projectOutputFile(root, file, user) {
|
|
12041
|
-
const real = (0,
|
|
12042
|
-
const base = (0,
|
|
12043
|
-
const stat = (0,
|
|
12044
|
-
if (!real.startsWith(base +
|
|
12501
|
+
const real = (0, import_node_fs22.realpathSync)(file);
|
|
12502
|
+
const base = (0, import_node_fs22.realpathSync)(root);
|
|
12503
|
+
const stat = (0, import_node_fs22.statSync)(real);
|
|
12504
|
+
if (!real.startsWith(base + import_node_path24.default.sep) || !stat.isFile() || stat.uid !== user.uid) {
|
|
12045
12505
|
throw new Error(`swift-compile: project output ${file} is not a file of its build`);
|
|
12046
12506
|
}
|
|
12047
12507
|
return real;
|
|
@@ -12049,23 +12509,23 @@ function projectOutputFile(root, file, user) {
|
|
|
12049
12509
|
function removeProjectLinks(root) {
|
|
12050
12510
|
const pending = [root];
|
|
12051
12511
|
for (let directory = pending.pop(); directory; directory = pending.pop()) {
|
|
12052
|
-
for (const entry of (0,
|
|
12053
|
-
const full =
|
|
12512
|
+
for (const entry of (0, import_node_fs22.readdirSync)(directory, { withFileTypes: true })) {
|
|
12513
|
+
const full = import_node_path24.default.join(directory, entry.name);
|
|
12054
12514
|
if (directory === root && entry.name === ".build") continue;
|
|
12055
12515
|
if (directory === root && entry.name.startsWith(".peach-modules-")) {
|
|
12056
|
-
(0,
|
|
12057
|
-
} else if (entry.isSymbolicLink()) (0,
|
|
12516
|
+
(0, import_node_fs22.rmSync)(full, { recursive: true, force: true });
|
|
12517
|
+
} else if (entry.isSymbolicLink()) (0, import_node_fs22.rmSync)(full);
|
|
12058
12518
|
else if (entry.isDirectory()) pending.push(full);
|
|
12059
12519
|
}
|
|
12060
12520
|
}
|
|
12061
12521
|
}
|
|
12062
12522
|
|
|
12063
12523
|
// src/swift-reproducible.ts
|
|
12064
|
-
var
|
|
12524
|
+
var import_node_fs23 = require("node:fs");
|
|
12065
12525
|
var import_node_os8 = __toESM(require("node:os"), 1);
|
|
12066
12526
|
function swiftReproducibleBuildFlags(roots) {
|
|
12067
12527
|
return [[import_node_os8.default.homedir(), "home"], ...roots].flatMap(
|
|
12068
|
-
([root, name2]) => [.../* @__PURE__ */ new Set([root, (0,
|
|
12528
|
+
([root, name2]) => [.../* @__PURE__ */ new Set([root, (0, import_node_fs23.realpathSync)(root)])].map((from) => `${from}=/peach/${name2}`)
|
|
12069
12529
|
).flatMap((map) => [
|
|
12070
12530
|
"-Xswiftc",
|
|
12071
12531
|
"-file-prefix-map",
|
|
@@ -12080,10 +12540,10 @@ function swiftReproducibleBuildFlags(roots) {
|
|
|
12080
12540
|
|
|
12081
12541
|
// src/swift-root-lock.ts
|
|
12082
12542
|
var import_node_child_process17 = require("node:child_process");
|
|
12083
|
-
var
|
|
12084
|
-
var
|
|
12543
|
+
var import_node_crypto14 = require("node:crypto");
|
|
12544
|
+
var import_node_fs24 = require("node:fs");
|
|
12085
12545
|
var import_node_os9 = require("node:os");
|
|
12086
|
-
var
|
|
12546
|
+
var import_node_path25 = __toESM(require("node:path"), 1);
|
|
12087
12547
|
var POLL_MS = 250;
|
|
12088
12548
|
var INSPECT_ATTEMPTS = 5;
|
|
12089
12549
|
var START_TOLERANCE_MS = 2e3;
|
|
@@ -12140,7 +12600,7 @@ function pause(ms, signal) {
|
|
|
12140
12600
|
var name = (number3, suffix) => `${String(number3).padStart(12, "0")}.${suffix}`;
|
|
12141
12601
|
function generationNumbers(directory) {
|
|
12142
12602
|
const numbers = /* @__PURE__ */ new Set();
|
|
12143
|
-
for (const entry of (0,
|
|
12603
|
+
for (const entry of (0, import_node_fs24.readdirSync)(directory)) {
|
|
12144
12604
|
const match = /^(\d{12})\./.exec(entry);
|
|
12145
12605
|
if (match) numbers.add(Number(match[1]));
|
|
12146
12606
|
}
|
|
@@ -12149,7 +12609,7 @@ function generationNumbers(directory) {
|
|
|
12149
12609
|
function readGeneration(directory, number3) {
|
|
12150
12610
|
let owner;
|
|
12151
12611
|
try {
|
|
12152
|
-
owner = (0,
|
|
12612
|
+
owner = (0, import_node_fs24.readFileSync)(import_node_path25.default.join(directory, name(number3, "owner")), "utf8");
|
|
12153
12613
|
} catch (error) {
|
|
12154
12614
|
if (errorCode(error) === "ENOENT") return null;
|
|
12155
12615
|
throw error;
|
|
@@ -12157,12 +12617,12 @@ function readGeneration(directory, number3) {
|
|
|
12157
12617
|
return {
|
|
12158
12618
|
number: number3,
|
|
12159
12619
|
holder: parseIdentity(owner),
|
|
12160
|
-
released: (0,
|
|
12620
|
+
released: (0, import_node_fs24.readdirSync)(directory).includes(name(number3, "released"))
|
|
12161
12621
|
};
|
|
12162
12622
|
}
|
|
12163
12623
|
function readChildren(directory, number3) {
|
|
12164
12624
|
const prefix = name(number3, "child.");
|
|
12165
|
-
return (0,
|
|
12625
|
+
return (0, import_node_fs24.readdirSync)(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity((0, import_node_fs24.readFileSync)(import_node_path25.default.join(directory, entry), "utf8")));
|
|
12166
12626
|
}
|
|
12167
12627
|
function groupAlive(table, leader) {
|
|
12168
12628
|
const row = table.find((candidate) => candidate.pid === leader.pid);
|
|
@@ -12170,30 +12630,30 @@ function groupAlive(table, leader) {
|
|
|
12170
12630
|
return table.some((candidate) => candidate.pgid === leader.pid && !candidate.zombie);
|
|
12171
12631
|
}
|
|
12172
12632
|
function canonicalRoot(root) {
|
|
12173
|
-
let existing =
|
|
12633
|
+
let existing = import_node_path25.default.resolve(root);
|
|
12174
12634
|
const missing = [];
|
|
12175
|
-
while (!(0,
|
|
12176
|
-
missing.unshift(
|
|
12177
|
-
existing =
|
|
12635
|
+
while (!(0, import_node_fs24.existsSync)(existing) && import_node_path25.default.dirname(existing) !== existing) {
|
|
12636
|
+
missing.unshift(import_node_path25.default.basename(existing));
|
|
12637
|
+
existing = import_node_path25.default.dirname(existing);
|
|
12178
12638
|
}
|
|
12179
|
-
return
|
|
12639
|
+
return import_node_path25.default.join((0, import_node_fs24.realpathSync)(existing), ...missing);
|
|
12180
12640
|
}
|
|
12181
12641
|
function swiftRootLocksDir() {
|
|
12182
|
-
return
|
|
12642
|
+
return import_node_path25.default.join((0, import_node_os9.homedir)(), ".peach", "cache", "swift-root-locks");
|
|
12183
12643
|
}
|
|
12184
12644
|
async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
12185
|
-
const directory =
|
|
12645
|
+
const directory = import_node_path25.default.join(
|
|
12186
12646
|
swiftRootLocksDir(),
|
|
12187
|
-
(0,
|
|
12647
|
+
(0, import_node_crypto14.createHash)("sha256").update(canonicalRoot(root)).digest("hex").slice(0, 32)
|
|
12188
12648
|
);
|
|
12189
|
-
(0,
|
|
12190
|
-
const token = (0,
|
|
12649
|
+
(0, import_node_fs24.mkdirSync)(directory, { recursive: true });
|
|
12650
|
+
const token = (0, import_node_crypto14.randomUUID)();
|
|
12191
12651
|
const ownRow = (await processTableWithRetry(process.pid, signal)).find(
|
|
12192
12652
|
(candidate) => candidate.pid === process.pid && !candidate.zombie
|
|
12193
12653
|
);
|
|
12194
12654
|
if (!ownRow) throw new Error(`swift root lock cannot find process ${process.pid}`);
|
|
12195
12655
|
const owner = JSON.stringify({ pid: process.pid, start: ownRow.start });
|
|
12196
|
-
const pending =
|
|
12656
|
+
const pending = import_node_path25.default.join(directory, `pending.${token}`);
|
|
12197
12657
|
let held = 0;
|
|
12198
12658
|
let announced = 0;
|
|
12199
12659
|
let current = null;
|
|
@@ -12232,26 +12692,26 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
12232
12692
|
}
|
|
12233
12693
|
}
|
|
12234
12694
|
}
|
|
12235
|
-
(0,
|
|
12695
|
+
(0, import_node_fs24.writeFileSync)(pending, owner);
|
|
12236
12696
|
try {
|
|
12237
|
-
(0,
|
|
12697
|
+
(0, import_node_fs24.linkSync)(pending, import_node_path25.default.join(directory, name(newest + 1, "owner")));
|
|
12238
12698
|
} catch (error) {
|
|
12239
12699
|
if (errorCode(error) === "EEXIST") continue;
|
|
12240
12700
|
throw error;
|
|
12241
12701
|
} finally {
|
|
12242
|
-
(0,
|
|
12702
|
+
(0, import_node_fs24.rmSync)(pending, { force: true });
|
|
12243
12703
|
}
|
|
12244
12704
|
const numbers = generationNumbers(directory);
|
|
12245
12705
|
if (numbers.at(-1) !== newest + 1) {
|
|
12246
|
-
(0,
|
|
12706
|
+
(0, import_node_fs24.rmSync)(import_node_path25.default.join(directory, name(newest + 1, "owner")), { force: true });
|
|
12247
12707
|
continue;
|
|
12248
12708
|
}
|
|
12249
12709
|
held = newest + 1;
|
|
12250
12710
|
for (const number3 of numbers)
|
|
12251
12711
|
if (number3 < held) {
|
|
12252
|
-
for (const entry of (0,
|
|
12712
|
+
for (const entry of (0, import_node_fs24.readdirSync)(directory))
|
|
12253
12713
|
if (entry.startsWith(name(number3, "")))
|
|
12254
|
-
(0,
|
|
12714
|
+
(0, import_node_fs24.rmSync)(import_node_path25.default.join(directory, entry), { force: true });
|
|
12255
12715
|
}
|
|
12256
12716
|
break;
|
|
12257
12717
|
}
|
|
@@ -12262,10 +12722,10 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
12262
12722
|
if (child.pid === void 0) throw new Error("could not register compiler process");
|
|
12263
12723
|
const childPending = `${pending}.child.${index}`;
|
|
12264
12724
|
try {
|
|
12265
|
-
(0,
|
|
12266
|
-
(0,
|
|
12725
|
+
(0, import_node_fs24.writeFileSync)(childPending, JSON.stringify(ownIdentity(child.pid)));
|
|
12726
|
+
(0, import_node_fs24.linkSync)(childPending, import_node_path25.default.join(directory, name(held, `child.${index}`)));
|
|
12267
12727
|
} finally {
|
|
12268
|
-
(0,
|
|
12728
|
+
(0, import_node_fs24.rmSync)(childPending, { force: true });
|
|
12269
12729
|
}
|
|
12270
12730
|
},
|
|
12271
12731
|
spawn(command, args, options, companion) {
|
|
@@ -12295,18 +12755,18 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
12295
12755
|
return await work(lease);
|
|
12296
12756
|
} finally {
|
|
12297
12757
|
await Promise.all(children.map((child) => terminateProcessGroup(child, "SIGKILL", 0)));
|
|
12298
|
-
(0,
|
|
12758
|
+
(0, import_node_fs24.writeFileSync)(import_node_path25.default.join(directory, name(held, "released")), "");
|
|
12299
12759
|
}
|
|
12300
12760
|
}
|
|
12301
12761
|
|
|
12302
12762
|
// src/swift-uniform-type-constants.ts
|
|
12303
12763
|
var import_node_child_process18 = require("node:child_process");
|
|
12304
|
-
var
|
|
12764
|
+
var import_node_path26 = __toESM(require("node:path"), 1);
|
|
12305
12765
|
function compileUniformTypeConstants(args) {
|
|
12306
|
-
const source =
|
|
12307
|
-
const object3 =
|
|
12766
|
+
const source = import_node_path26.default.join(args.packageRoot, "runtime/UniformTypeIdentifiersConstants.m");
|
|
12767
|
+
const object3 = import_node_path26.default.join(args.out, "UniformTypeIdentifiers-NativeConstants.o");
|
|
12308
12768
|
(0, import_node_child_process18.execFileSync)(
|
|
12309
|
-
|
|
12769
|
+
import_node_path26.default.join(args.bin, "clang"),
|
|
12310
12770
|
[
|
|
12311
12771
|
"--target=wasm64-unknown-wasip1",
|
|
12312
12772
|
`--sysroot=${args.sysroot}`,
|
|
@@ -12315,7 +12775,7 @@ function compileUniformTypeConstants(args) {
|
|
|
12315
12775
|
...swiftObjCRuntimeFlags,
|
|
12316
12776
|
"-fwasm-exceptions",
|
|
12317
12777
|
"-F",
|
|
12318
|
-
|
|
12778
|
+
import_node_path26.default.resolve(args.packageRoot, "../peachsim/sdk/ios/System/Library/Frameworks"),
|
|
12319
12779
|
...objcSdkIntakeFlags(args.darwin, args.bin, args.minimum),
|
|
12320
12780
|
"-c",
|
|
12321
12781
|
source,
|
|
@@ -12327,174 +12787,14 @@ function compileUniformTypeConstants(args) {
|
|
|
12327
12787
|
return object3;
|
|
12328
12788
|
}
|
|
12329
12789
|
|
|
12330
|
-
// src/swiftContract.ts
|
|
12331
|
-
function isSwiftSourceLinkGraph(value) {
|
|
12332
|
-
if (!value || typeof value !== "object") return false;
|
|
12333
|
-
const text2 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
|
|
12334
|
-
const entry = Reflect.get(value, "entry");
|
|
12335
|
-
const targets = Reflect.get(value, "targets");
|
|
12336
|
-
if (!text2(entry) || !Array.isArray(targets) || targets.length > 1024) return false;
|
|
12337
|
-
const ids = /* @__PURE__ */ new Set();
|
|
12338
|
-
for (const target of targets) {
|
|
12339
|
-
if (!target || typeof target !== "object") return false;
|
|
12340
|
-
const id = Reflect.get(target, "id");
|
|
12341
|
-
const source = Reflect.get(target, "sourceTarget");
|
|
12342
|
-
const flags = Reflect.get(target, "linkerFlags");
|
|
12343
|
-
const dependencies = Reflect.get(target, "dependencies");
|
|
12344
|
-
const build = Reflect.get(target, "buildVersion");
|
|
12345
|
-
const nullableText = (value2) => value2 === null || text2(value2);
|
|
12346
|
-
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(
|
|
12347
|
-
(key) => nullableText(Reflect.get(build, key))
|
|
12348
|
-
) || !(Reflect.get(target, "machOType") === null || text2(Reflect.get(target, "machOType"))) || !Array.isArray(flags) || !flags.every(text2) || !Array.isArray(dependencies) || !dependencies.every(
|
|
12349
|
-
(link) => link && typeof link === "object" && text2(Reflect.get(link, "target")) && Array.isArray(Reflect.get(link, "attributes")) && Reflect.get(link, "attributes").every(text2)
|
|
12350
|
-
))
|
|
12351
|
-
return false;
|
|
12352
|
-
ids.add(id);
|
|
12353
|
-
}
|
|
12354
|
-
return ids.has(entry) && targets.every(
|
|
12355
|
-
(target) => Reflect.get(target, "dependencies").every(
|
|
12356
|
-
(link) => ids.has(link.target)
|
|
12357
|
-
)
|
|
12358
|
-
);
|
|
12359
|
-
}
|
|
12360
|
-
var SWIFT_REMOTE_PACKAGES_DIR = "__packages__";
|
|
12361
|
-
var SWIFT_LOCAL_PACKAGES_DIR = "__local_packages__";
|
|
12362
|
-
var SWIFT_XCODE_BUILD_CONDITION = "__PEACH_XCODE_BUILD";
|
|
12363
|
-
function isBase64Bytes(value) {
|
|
12364
|
-
return value.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}(?![\s\S])/.test(value);
|
|
12365
|
-
}
|
|
12366
|
-
function isSwiftPackageFiles(value) {
|
|
12367
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
12368
|
-
([file, bytes]) => isSwiftResourcePath(file) && (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`)) && typeof bytes === "string" && isBase64Bytes(bytes)
|
|
12369
|
-
);
|
|
12370
|
-
}
|
|
12371
|
-
function swiftProjectFileProblem(file) {
|
|
12372
|
-
if (!isSwiftResourcePath(file)) return "not a relative path of plain segments";
|
|
12373
|
-
if (file === "Package.swift") return "would replace the generated manifest";
|
|
12374
|
-
if (file.split("/").includes(".build")) return "is build output (.build)";
|
|
12375
|
-
if (file.startsWith(".")) return 'starts with "." (hidden file or peach output)';
|
|
12376
|
-
if (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`))
|
|
12377
|
-
return "collides with a transported package checkout";
|
|
12378
|
-
return void 0;
|
|
12379
|
-
}
|
|
12380
|
-
function swiftProjectEntryProblem(file, bytes) {
|
|
12381
|
-
return swiftProjectFileProblem(file) ?? (typeof bytes === "string" && isBase64Bytes(bytes) ? void 0 : "bytes are not base64");
|
|
12382
|
-
}
|
|
12383
|
-
function isSwiftProjectFiles(value) {
|
|
12384
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
12385
|
-
([file, bytes]) => swiftProjectEntryProblem(file, bytes) === void 0
|
|
12386
|
-
);
|
|
12387
|
-
}
|
|
12388
|
-
function swiftProjectFilesProblems(value) {
|
|
12389
|
-
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
12390
|
-
return ["projectFiles is not an object"];
|
|
12391
|
-
return Object.entries(value).flatMap(([file, bytes]) => {
|
|
12392
|
-
const problem = swiftProjectEntryProblem(file, bytes);
|
|
12393
|
-
return problem ? [`${file}: ${problem}`] : [];
|
|
12394
|
-
});
|
|
12395
|
-
}
|
|
12396
|
-
var SWIFT_NATIVE_INPUT_ROOT = "$(PEACH_INPUT_ROOT)";
|
|
12397
|
-
var SWIFT_NATIVE_SDK_INCLUDE = "$(PEACH_SDK_INCLUDE)";
|
|
12398
|
-
function isSwiftHeaderAliases(value) {
|
|
12399
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
|
|
12400
|
-
([alias, file]) => isSwiftResourcePath(alias) && isSwiftResourcePath(file)
|
|
12401
|
-
);
|
|
12402
|
-
}
|
|
12403
|
-
function isSwiftNativeTargets(value) {
|
|
12404
|
-
return swiftNativeTargetsRefusal(value) === null;
|
|
12405
|
-
}
|
|
12406
|
-
function swiftNativeTargetsRefusal(value) {
|
|
12407
|
-
const strings = (value2) => Array.isArray(value2) && value2.every((item) => typeof item === "string" && !item.includes("\0"));
|
|
12408
|
-
const paths = (value2) => strings(value2) && value2.every(isSwiftResourcePath);
|
|
12409
|
-
if (!Array.isArray(value)) return "nativeTargets";
|
|
12410
|
-
if (value.length > 128) return "nativeTargets:length";
|
|
12411
|
-
for (const target of value) {
|
|
12412
|
-
if (!target || typeof target !== "object") return "nativeTargets:shape";
|
|
12413
|
-
const field = (name3) => Reflect.get(target, name3);
|
|
12414
|
-
const name2 = typeof field("name") === "string" ? String(field("name")) : "?";
|
|
12415
|
-
const at = (shape) => `nativeTargets:${name2}:${shape}`;
|
|
12416
|
-
const nullablePath = (key) => field(key) === null || isSwiftResourcePath(field(key));
|
|
12417
|
-
const perFile = field("fileFlags");
|
|
12418
|
-
const directories = field("sourceDirectories");
|
|
12419
|
-
const searches = field("headerSearchPaths");
|
|
12420
|
-
const userSearches = field("userHeaderSearchPaths");
|
|
12421
|
-
const frameworks = field("frameworkSearchPaths");
|
|
12422
|
-
const maps = field("headerMaps");
|
|
12423
|
-
const products = field("productHeaders");
|
|
12424
|
-
const inputPath = (value2) => typeof value2 === "string" && value2.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) && isSwiftResourcePath(value2.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1));
|
|
12425
|
-
const deployment = field("deploymentTarget");
|
|
12426
|
-
const targetName = field("name");
|
|
12427
|
-
if (typeof targetName !== "string" || targetName.length === 0 || targetName.length > 4096 || targetName.includes("\0") || targetName.includes("/") || targetName.includes("\\") || targetName === "." || targetName === "..")
|
|
12428
|
-
return at("name");
|
|
12429
|
-
if (!(deployment === null || typeof deployment === "string" && /^\d+(?:\.\d+){0,2}$/.test(deployment)))
|
|
12430
|
-
return at("deploymentTarget");
|
|
12431
|
-
if (!paths(field("headers"))) return at("headers");
|
|
12432
|
-
if (!paths(field("publicHeaders"))) return at("publicHeaders");
|
|
12433
|
-
if (typeof field("flattensPublicHeaders") !== "boolean")
|
|
12434
|
-
return at("flattensPublicHeaders");
|
|
12435
|
-
if (!nullablePath("bridgingHeader")) return at("bridgingHeader");
|
|
12436
|
-
if (!nullablePath("prefixHeader")) return at("prefixHeader");
|
|
12437
|
-
if (!strings(searches) || !searches.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
12438
|
-
return at("headerSearchPaths");
|
|
12439
|
-
const moduleMaps = field("moduleMaps");
|
|
12440
|
-
if (moduleMaps !== void 0 && (!Array.isArray(moduleMaps) || moduleMaps.length > 128 || !moduleMaps.every((map) => {
|
|
12441
|
-
if (!map || typeof map !== "object") return false;
|
|
12442
|
-
const module2 = Reflect.get(map, "module");
|
|
12443
|
-
const headers = Reflect.get(map, "headers");
|
|
12444
|
-
return typeof module2 === "string" && module2.length > 0 && module2.length <= 4096 && !module2.includes("\0") && (headers === "." || isSwiftResourcePath(headers));
|
|
12445
|
-
})))
|
|
12446
|
-
return at("moduleMaps");
|
|
12447
|
-
if (!strings(userSearches) || !userSearches.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
12448
|
-
return at("userHeaderSearchPaths");
|
|
12449
|
-
if (!strings(frameworks) || !frameworks.every((item) => item === "." || isSwiftResourcePath(item)))
|
|
12450
|
-
return at("frameworkSearchPaths");
|
|
12451
|
-
if (!Array.isArray(maps) || !maps.every((map) => {
|
|
12452
|
-
if (!map || typeof map !== "object") return false;
|
|
12453
|
-
const flag = Reflect.get(map, "flag");
|
|
12454
|
-
const entries = Reflect.get(map, "entries");
|
|
12455
|
-
return (flag === "-I" || flag === "-iquote") && Array.isArray(entries) && entries.every(
|
|
12456
|
-
(entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && !entry[0].includes("\0") && (inputPath(entry[1]) || isSwiftResourcePath(entry[1]))
|
|
12457
|
-
);
|
|
12458
|
-
}))
|
|
12459
|
-
return at("headerMaps");
|
|
12460
|
-
if (!products || typeof products !== "object" || Array.isArray(products) || !Object.entries(products).every(
|
|
12461
|
-
([product, file]) => isSwiftResourcePath(product) && isSwiftResourcePath(file)
|
|
12462
|
-
))
|
|
12463
|
-
return at("productHeaders");
|
|
12464
|
-
if (!strings(field("flags"))) return at("flags");
|
|
12465
|
-
if (!strings(field("importerFlags"))) return at("importerFlags");
|
|
12466
|
-
if (!strings(field("cxxFlags"))) return at("cxxFlags");
|
|
12467
|
-
if (!perFile || typeof perFile !== "object" || Array.isArray(perFile) || !Object.entries(perFile).every(
|
|
12468
|
-
([file, flags]) => isSwiftResourcePath(file) && strings(flags)
|
|
12469
|
-
))
|
|
12470
|
-
return at("fileFlags");
|
|
12471
|
-
if (!directories || typeof directories !== "object" || Array.isArray(directories) || !Object.entries(directories).every(
|
|
12472
|
-
([file, directory]) => isSwiftResourcePath(file) && (directory === "." || isSwiftResourcePath(directory))
|
|
12473
|
-
))
|
|
12474
|
-
return at("sourceDirectories");
|
|
12475
|
-
}
|
|
12476
|
-
return null;
|
|
12477
|
-
}
|
|
12478
|
-
function isSwiftResourcePath(value) {
|
|
12479
|
-
return typeof value === "string" && value.length <= 4096 && !value.startsWith("/") && !value.includes("\\") && !value.includes("\0") && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
12480
|
-
}
|
|
12481
|
-
function isSwiftBundlePath(value) {
|
|
12482
|
-
return typeof value === "string" && (value === "." || isSwiftResourcePath(value) && /\.(bundle|framework)$/.test(value));
|
|
12483
|
-
}
|
|
12484
|
-
function isSwiftResourceBundles(value) {
|
|
12485
|
-
return Array.isArray(value) && value.every(
|
|
12486
|
-
(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)
|
|
12487
|
-
) && new Set(value.map((bundle) => bundle.target)).size === value.length && new Set(value.map((bundle) => bundle.path)).size === value.length;
|
|
12488
|
-
}
|
|
12489
|
-
|
|
12490
12790
|
// src/xcode-header-search.ts
|
|
12491
|
-
var
|
|
12492
|
-
var
|
|
12791
|
+
var import_node_fs25 = __toESM(require("node:fs"), 1);
|
|
12792
|
+
var import_node_path27 = __toESM(require("node:path"), 1);
|
|
12493
12793
|
function coalescibleHeaderOverlays(files) {
|
|
12494
12794
|
const aliases = /* @__PURE__ */ new Map();
|
|
12495
12795
|
const key = (file) => file.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
|
|
12496
12796
|
const index = (directory, entry) => {
|
|
12497
|
-
const name2 =
|
|
12797
|
+
const name2 = import_node_path27.default.resolve(directory, entry.name);
|
|
12498
12798
|
if (entry.type === "directory")
|
|
12499
12799
|
return entry.contents.every((child) => index(name2, child));
|
|
12500
12800
|
const source = entry["external-contents"];
|
|
@@ -12504,12 +12804,12 @@ function coalescibleHeaderOverlays(files) {
|
|
|
12504
12804
|
return true;
|
|
12505
12805
|
};
|
|
12506
12806
|
for (const file of files) {
|
|
12507
|
-
const overlay = JSON.parse(
|
|
12508
|
-
if (!overlay.roots.every((entry) => index(
|
|
12807
|
+
const overlay = JSON.parse(import_node_fs25.default.readFileSync(file, "utf8"));
|
|
12808
|
+
if (!overlay.roots.every((entry) => index(import_node_path27.default.dirname(file), entry)))
|
|
12509
12809
|
return /* @__PURE__ */ new Set();
|
|
12510
12810
|
}
|
|
12511
12811
|
for (const file of [...files, ...aliases.values()]) {
|
|
12512
|
-
const source = aliases.get(key(
|
|
12812
|
+
const source = aliases.get(key(import_node_path27.default.normalize(file)));
|
|
12513
12813
|
if (source !== void 0 && source !== file) return /* @__PURE__ */ new Set();
|
|
12514
12814
|
}
|
|
12515
12815
|
return files;
|
|
@@ -12556,7 +12856,7 @@ function headerMap(entries) {
|
|
|
12556
12856
|
return Buffer.concat([table, ...strings]);
|
|
12557
12857
|
}
|
|
12558
12858
|
function writeXcodeHeaderSearch(directory, targets, headerAliases = {}) {
|
|
12559
|
-
|
|
12859
|
+
import_node_fs25.default.mkdirSync(directory, { recursive: true });
|
|
12560
12860
|
const productDirectories = /* @__PURE__ */ new Map();
|
|
12561
12861
|
for (const [product, original] of new Map([
|
|
12562
12862
|
...Object.entries(headerAliases),
|
|
@@ -12569,11 +12869,11 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}) {
|
|
|
12569
12869
|
seen.add(file);
|
|
12570
12870
|
file = headerAliases[file];
|
|
12571
12871
|
}
|
|
12572
|
-
const listed = productDirectories.get(
|
|
12573
|
-
productDirectories.set(
|
|
12574
|
-
listed.push({ name:
|
|
12872
|
+
const listed = productDirectories.get(import_node_path27.default.dirname(product)) ?? [];
|
|
12873
|
+
productDirectories.set(import_node_path27.default.dirname(product), listed);
|
|
12874
|
+
listed.push({ name: import_node_path27.default.basename(product), file });
|
|
12575
12875
|
}
|
|
12576
|
-
const overlay =
|
|
12876
|
+
const overlay = import_node_path27.default.join(directory, "all-product-headers.yaml");
|
|
12577
12877
|
writeBuildFile(
|
|
12578
12878
|
overlay,
|
|
12579
12879
|
JSON.stringify({
|
|
@@ -12593,7 +12893,7 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}) {
|
|
|
12593
12893
|
const files = [overlay];
|
|
12594
12894
|
const flags = targets.map((target, index) => {
|
|
12595
12895
|
const maps = target.headerMaps.map((map, order) => {
|
|
12596
|
-
const file =
|
|
12896
|
+
const file = import_node_path27.default.join(directory, `${index}-${order}.hmap`);
|
|
12597
12897
|
writeBuildFile(file, headerMap(map.entries));
|
|
12598
12898
|
files.push(file);
|
|
12599
12899
|
return { flag: map.flag, file };
|
|
@@ -12713,37 +13013,37 @@ function swiftBuildJobs() {
|
|
|
12713
13013
|
);
|
|
12714
13014
|
}
|
|
12715
13015
|
function swiftDistributionAt(root) {
|
|
12716
|
-
const file =
|
|
12717
|
-
if (!(0,
|
|
12718
|
-
return parseSwiftDistributionManifest(JSON.parse((0,
|
|
13016
|
+
const file = import_node_path28.default.join(root, SWIFT_DISTRIBUTION_MANIFEST);
|
|
13017
|
+
if (!(0, import_node_fs26.existsSync)(file)) return null;
|
|
13018
|
+
return parseSwiftDistributionManifest(JSON.parse((0, import_node_fs26.readFileSync)(file, "utf8")));
|
|
12719
13019
|
}
|
|
12720
13020
|
var REACH_STAGED_FRAMEWORKS = /* @__PURE__ */ new Set(["React"]);
|
|
12721
13021
|
function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
|
|
12722
13022
|
if (REACH_STAGED_FRAMEWORKS.has(name2)) return null;
|
|
12723
13023
|
if (swiftDistributionAt(moduleRoot)) {
|
|
12724
|
-
const file =
|
|
12725
|
-
interfaceRoot ??
|
|
13024
|
+
const file = import_node_path28.default.join(
|
|
13025
|
+
interfaceRoot ?? import_node_path28.default.join(moduleRoot, "modules"),
|
|
12726
13026
|
`${name2}-Swift.h`
|
|
12727
13027
|
);
|
|
12728
|
-
if (!(0,
|
|
12729
|
-
const header = clangInterfaceHeader((0,
|
|
13028
|
+
if (!(0, import_node_fs26.existsSync)(file)) return null;
|
|
13029
|
+
const header = clangInterfaceHeader((0, import_node_fs26.readFileSync)(file, "utf8"));
|
|
12730
13030
|
return { declared: swiftInterfaceDeclarations(header), header };
|
|
12731
13031
|
}
|
|
12732
|
-
const sources =
|
|
12733
|
-
const built =
|
|
12734
|
-
if (!(0,
|
|
13032
|
+
const sources = import_node_path28.default.join(moduleRoot, "Sources", name2);
|
|
13033
|
+
const built = import_node_path28.default.join(moduleRoot, ".build/host", `${name2}-Swift.h`);
|
|
13034
|
+
if (!(0, import_node_fs26.existsSync)(sources) || !(0, import_node_fs26.existsSync)(built)) return null;
|
|
12735
13035
|
const declared = /* @__PURE__ */ new Set();
|
|
12736
|
-
for (const file of (0,
|
|
13036
|
+
for (const file of (0, import_node_fs26.readdirSync)(sources, { recursive: true, encoding: "utf8" }))
|
|
12737
13037
|
if (file.endsWith(".swift"))
|
|
12738
|
-
for (const [, objc, subclass] of (0,
|
|
12739
|
-
|
|
13038
|
+
for (const [, objc, subclass] of (0, import_node_fs26.readFileSync)(
|
|
13039
|
+
import_node_path28.default.join(sources, file),
|
|
12740
13040
|
"utf8"
|
|
12741
13041
|
).matchAll(
|
|
12742
13042
|
/@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s|^(?:public|open)\s+(?:final\s+)?class\s+(\w+)\s*:\s*NSObject\b/gm
|
|
12743
13043
|
))
|
|
12744
13044
|
declared.add(objc ?? subclass);
|
|
12745
13045
|
if (declared.size === 0) return null;
|
|
12746
|
-
return { declared, header: clangInterfaceHeader((0,
|
|
13046
|
+
return { declared, header: clangInterfaceHeader((0, import_node_fs26.readFileSync)(built, "utf8")) };
|
|
12747
13047
|
}
|
|
12748
13048
|
var clangInterfaceHeader = (header) => header.replace(/^@import (?:UIKitCore|UIKitText);$/gm, "@import UIKit;").replace(
|
|
12749
13049
|
/^@import (?:CoreFoundation|FoundationNetworking);$/gm,
|
|
@@ -12774,13 +13074,13 @@ function sdkObjCDeclarationOwners(frameworks) {
|
|
|
12774
13074
|
const known = sdkDeclarationOwners.get(frameworks);
|
|
12775
13075
|
if (known) return known;
|
|
12776
13076
|
const owners = /* @__PURE__ */ new Map();
|
|
12777
|
-
for (const framework of (0,
|
|
13077
|
+
for (const framework of (0, import_node_fs26.readdirSync)(frameworks))
|
|
12778
13078
|
if (framework.endsWith(".framework")) {
|
|
12779
|
-
const headers =
|
|
12780
|
-
if ((0,
|
|
12781
|
-
for (const file of (0,
|
|
13079
|
+
const headers = import_node_path28.default.join(frameworks, framework, "Headers");
|
|
13080
|
+
if ((0, import_node_fs26.existsSync)(headers)) {
|
|
13081
|
+
for (const file of (0, import_node_fs26.readdirSync)(headers, { recursive: true, encoding: "utf8" }))
|
|
12782
13082
|
if (file.endsWith(".h")) {
|
|
12783
|
-
const header = (0,
|
|
13083
|
+
const header = (0, import_node_fs26.readFileSync)(import_node_path28.default.join(headers, file), "utf8");
|
|
12784
13084
|
for (const name2 of [
|
|
12785
13085
|
...swiftInterfaceDeclarations(header),
|
|
12786
13086
|
...objcEnumerations(header),
|
|
@@ -12876,25 +13176,25 @@ function swiftCompileSdkOptions(moduleRoot, toolchainBin) {
|
|
|
12876
13176
|
);
|
|
12877
13177
|
}
|
|
12878
13178
|
function swiftObjCSelectorOptions(moduleRoot) {
|
|
12879
|
-
let map =
|
|
13179
|
+
let map = import_node_path28.default.join(moduleRoot, SWIFT_DISTRIBUTION_OBJC_SELECTORS);
|
|
12880
13180
|
if (!swiftDistributionAt(moduleRoot)) {
|
|
12881
13181
|
const classes = {};
|
|
12882
13182
|
for (const framework of ["UIKitCore", "WebKit"])
|
|
12883
13183
|
for (const [name2, members] of Object.entries(
|
|
12884
13184
|
JSON.parse(
|
|
12885
|
-
(0,
|
|
12886
|
-
|
|
13185
|
+
(0, import_node_fs26.readFileSync)(
|
|
13186
|
+
import_node_path28.default.join(moduleRoot, "Sources", framework, "ObjCSelectors.json"),
|
|
12887
13187
|
"utf8"
|
|
12888
13188
|
)
|
|
12889
13189
|
).classes
|
|
12890
13190
|
))
|
|
12891
13191
|
classes[name2] = [...classes[name2] ?? [], ...members];
|
|
12892
|
-
map =
|
|
12893
|
-
(0,
|
|
12894
|
-
const partial = `${map}.${(0,
|
|
12895
|
-
(0,
|
|
13192
|
+
map = import_node_path28.default.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
|
|
13193
|
+
(0, import_node_fs26.mkdirSync)(import_node_path28.default.dirname(map), { recursive: true });
|
|
13194
|
+
const partial = `${map}.${(0, import_node_crypto15.randomUUID)()}`;
|
|
13195
|
+
(0, import_node_fs26.writeFileSync)(partial, `${JSON.stringify({ classes }, null, 2)}
|
|
12896
13196
|
`);
|
|
12897
|
-
(0,
|
|
13197
|
+
(0, import_node_fs26.renameSync)(partial, map);
|
|
12898
13198
|
}
|
|
12899
13199
|
return ["-Xswiftc", "-Xllvm", "-Xswiftc", `-peach-objc-selector-map=${map}`];
|
|
12900
13200
|
}
|
|
@@ -12928,7 +13228,7 @@ function swiftModuleInputFiles(root) {
|
|
|
12928
13228
|
"toolchain.json"
|
|
12929
13229
|
];
|
|
12930
13230
|
const walk = (dir) => {
|
|
12931
|
-
for (const entry of (0,
|
|
13231
|
+
for (const entry of (0, import_node_fs26.readdirSync)(import_node_path28.default.join(root, dir), {
|
|
12932
13232
|
withFileTypes: true
|
|
12933
13233
|
})) {
|
|
12934
13234
|
const relative = `${dir}/${entry.name}`;
|
|
@@ -12942,46 +13242,46 @@ function swiftModuleInputFiles(root) {
|
|
|
12942
13242
|
walk("ios-simulator-stdlib");
|
|
12943
13243
|
return files.sort();
|
|
12944
13244
|
}
|
|
12945
|
-
function swiftMacroPlugins(moduleRoot, dir =
|
|
13245
|
+
function swiftMacroPlugins(moduleRoot, dir = import_node_path28.default.join(moduleRoot, ".build/host/RnxPreviewMacros")) {
|
|
12946
13246
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
12947
13247
|
if (distribution)
|
|
12948
13248
|
return {
|
|
12949
|
-
libraries: distribution.plugins.filter((plugin) =>
|
|
12950
|
-
executables: distribution.plugins.filter((plugin) =>
|
|
13249
|
+
libraries: distribution.plugins.filter((plugin) => import_node_path28.default.basename(plugin) !== "ExpoModulesMacros").map((plugin) => import_node_path28.default.join(moduleRoot, plugin)),
|
|
13250
|
+
executables: distribution.plugins.filter((plugin) => import_node_path28.default.basename(plugin) === "ExpoModulesMacros").map((plugin) => import_node_path28.default.join(moduleRoot, plugin)),
|
|
12951
13251
|
stale: false
|
|
12952
13252
|
};
|
|
12953
13253
|
const release = JSON.parse(
|
|
12954
|
-
(0,
|
|
13254
|
+
(0, import_node_fs26.readFileSync)(import_node_path28.default.join(moduleRoot, "toolchain.json"), "utf8")
|
|
12955
13255
|
).release;
|
|
12956
|
-
const compilerStamp =
|
|
12957
|
-
const pluginScript =
|
|
12958
|
-
const expoPlugin =
|
|
13256
|
+
const compilerStamp = import_node_path28.default.join(dir, "compiler-release");
|
|
13257
|
+
const pluginScript = import_node_path28.default.join(moduleRoot, "scripts/build-preview-plugin.sh");
|
|
13258
|
+
const expoPlugin = import_node_path28.default.join(dir, "ExpoModulesMacros");
|
|
12959
13259
|
const ext = process.platform === "darwin" ? "dylib" : "so";
|
|
12960
13260
|
const plugins = [
|
|
12961
13261
|
{
|
|
12962
|
-
library:
|
|
12963
|
-
sources: [
|
|
13262
|
+
library: import_node_path28.default.join(dir, `libRnxPreviewMacros.${ext}`),
|
|
13263
|
+
sources: [import_node_path28.default.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
|
|
12964
13264
|
},
|
|
12965
13265
|
{
|
|
12966
|
-
library:
|
|
13266
|
+
library: import_node_path28.default.join(dir, `libFoundationMacros.${ext}`),
|
|
12967
13267
|
sources: [
|
|
12968
|
-
|
|
12969
|
-
|
|
13268
|
+
import_node_path28.default.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
|
|
13269
|
+
import_node_path28.default.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
|
|
12970
13270
|
]
|
|
12971
13271
|
},
|
|
12972
13272
|
{
|
|
12973
|
-
library:
|
|
13273
|
+
library: import_node_path28.default.join(dir, `libTipKitMacros.${ext}`),
|
|
12974
13274
|
sources: [
|
|
12975
|
-
|
|
12976
|
-
|
|
13275
|
+
import_node_path28.default.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
|
|
13276
|
+
import_node_path28.default.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
|
|
12977
13277
|
]
|
|
12978
13278
|
}
|
|
12979
13279
|
];
|
|
12980
13280
|
return {
|
|
12981
13281
|
libraries: plugins.map(({ library }) => library),
|
|
12982
13282
|
executables: [expoPlugin],
|
|
12983
|
-
stale: !(0,
|
|
12984
|
-
({ library, sources }) => !(0,
|
|
13283
|
+
stale: !(0, import_node_fs26.existsSync)(compilerStamp) || !(0, import_node_fs26.existsSync)(expoPlugin) || (0, import_node_fs26.statSync)(pluginScript).mtimeMs > (0, import_node_fs26.statSync)(expoPlugin).mtimeMs || (0, import_node_fs26.readFileSync)(compilerStamp, "utf8").trim() !== release || plugins.some(
|
|
13284
|
+
({ library, sources }) => !(0, import_node_fs26.existsSync)(library) || sources.some((source) => (0, import_node_fs26.statSync)(source).mtimeMs > (0, import_node_fs26.statSync)(library).mtimeMs)
|
|
12985
13285
|
)
|
|
12986
13286
|
};
|
|
12987
13287
|
}
|
|
@@ -12991,14 +13291,14 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal, lea
|
|
|
12991
13291
|
await runCompiler(
|
|
12992
13292
|
"sh",
|
|
12993
13293
|
[
|
|
12994
|
-
|
|
13294
|
+
import_node_path28.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
12995
13295
|
toolchainBin,
|
|
12996
13296
|
libraries[0]
|
|
12997
13297
|
],
|
|
12998
13298
|
{ signal, lease }
|
|
12999
13299
|
);
|
|
13000
|
-
(0,
|
|
13001
|
-
|
|
13300
|
+
(0, import_node_fs26.writeFileSync)(
|
|
13301
|
+
import_node_path28.default.join(import_node_path28.default.dirname(libraries[0]), "compiler-release"),
|
|
13002
13302
|
`${release}
|
|
13003
13303
|
`
|
|
13004
13304
|
);
|
|
@@ -13012,9 +13312,9 @@ function clearLinkedModuleDigests(root) {
|
|
|
13012
13312
|
}
|
|
13013
13313
|
function swiftModuleDigest(root) {
|
|
13014
13314
|
const files = swiftModuleInputFiles(root);
|
|
13015
|
-
const stampHash = (0,
|
|
13315
|
+
const stampHash = (0, import_node_crypto15.createHash)("sha256");
|
|
13016
13316
|
for (const file of files) {
|
|
13017
|
-
const stat = (0,
|
|
13317
|
+
const stat = (0, import_node_fs26.statSync)(import_node_path28.default.join(root, file), { bigint: true });
|
|
13018
13318
|
stampHash.update(file);
|
|
13019
13319
|
stampHash.update(
|
|
13020
13320
|
`${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
|
|
@@ -13024,36 +13324,36 @@ function swiftModuleDigest(root) {
|
|
|
13024
13324
|
const stamp = stampHash.digest("hex");
|
|
13025
13325
|
const cached = linkedModuleDigests.get(root);
|
|
13026
13326
|
if (cached?.stamp === stamp) return cached.digest;
|
|
13027
|
-
const record =
|
|
13327
|
+
const record = import_node_path28.default.join(
|
|
13028
13328
|
swiftCacheDir(),
|
|
13029
13329
|
"swift-module-digests",
|
|
13030
|
-
`${(0,
|
|
13330
|
+
`${(0, import_node_crypto15.createHash)("sha256").update(root).digest("hex")}.json`
|
|
13031
13331
|
);
|
|
13032
|
-
if ((0,
|
|
13033
|
-
const saved = JSON.parse((0,
|
|
13332
|
+
if ((0, import_node_fs26.existsSync)(record)) {
|
|
13333
|
+
const saved = JSON.parse((0, import_node_fs26.readFileSync)(record, "utf8"));
|
|
13034
13334
|
if (saved && typeof saved === "object" && Reflect.get(saved, "stamp") === stamp && typeof Reflect.get(saved, "digest") === "string") {
|
|
13035
13335
|
const digest2 = Buffer.from(String(Reflect.get(saved, "digest")), "hex");
|
|
13036
13336
|
linkedModuleDigests.set(root, { stamp, digest: digest2 });
|
|
13037
13337
|
return digest2;
|
|
13038
13338
|
}
|
|
13039
13339
|
}
|
|
13040
|
-
const hash = (0,
|
|
13340
|
+
const hash = (0, import_node_crypto15.createHash)("sha256");
|
|
13041
13341
|
for (const file of files) {
|
|
13042
|
-
hash.update((0,
|
|
13342
|
+
hash.update((0, import_node_crypto15.createHash)("sha256").update(file).digest());
|
|
13043
13343
|
hash.update(
|
|
13044
|
-
(0,
|
|
13344
|
+
(0, import_node_crypto15.createHash)("sha256").update((0, import_node_fs26.readFileSync)(import_node_path28.default.join(root, file))).digest()
|
|
13045
13345
|
);
|
|
13046
13346
|
}
|
|
13047
13347
|
const digest = hash.digest();
|
|
13048
13348
|
linkedModuleDigests.set(root, { stamp, digest });
|
|
13049
|
-
(0,
|
|
13050
|
-
const partial = `${record}.${process.pid}.${(0,
|
|
13051
|
-
(0,
|
|
13052
|
-
(0,
|
|
13349
|
+
(0, import_node_fs26.mkdirSync)(import_node_path28.default.dirname(record), { recursive: true });
|
|
13350
|
+
const partial = `${record}.${process.pid}.${(0, import_node_crypto15.randomUUID)()}`;
|
|
13351
|
+
(0, import_node_fs26.writeFileSync)(partial, JSON.stringify({ stamp, digest: digest.toString("hex") }));
|
|
13352
|
+
(0, import_node_fs26.renameSync)(partial, record);
|
|
13053
13353
|
return digest;
|
|
13054
13354
|
}
|
|
13055
13355
|
function swiftProjectBuildKey(moduleRoot, release) {
|
|
13056
|
-
return (0,
|
|
13356
|
+
return (0, import_node_crypto15.createHash)("sha256").update(`swift-framework/v2\0${release}\0${swiftModuleSdk(moduleRoot).wasmSdkId}`).update(swiftModuleDigest(moduleRoot)).digest("hex").slice(0, 32);
|
|
13057
13357
|
}
|
|
13058
13358
|
var SYSTEM_MODULE_LIBRARIES = {
|
|
13059
13359
|
"sqlite3.h": "sqlite3",
|
|
@@ -13100,7 +13400,7 @@ function withNativeSourceGlue(input, glue) {
|
|
|
13100
13400
|
...input,
|
|
13101
13401
|
files: {
|
|
13102
13402
|
...input.files,
|
|
13103
|
-
[
|
|
13403
|
+
[import_node_path28.default.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
|
|
13104
13404
|
},
|
|
13105
13405
|
oneModule: true
|
|
13106
13406
|
};
|
|
@@ -13192,12 +13492,12 @@ function swiftCondition(text2, available) {
|
|
|
13192
13492
|
if (token === "false") return false;
|
|
13193
13493
|
const call = /^(\w+)\s*\(\s*([^,()]*?)\s*(?:,[^()]*)?\)$/.exec(token ?? "");
|
|
13194
13494
|
if (!call) return void 0;
|
|
13195
|
-
const [, name2,
|
|
13196
|
-
if (name2 === "os") return
|
|
13495
|
+
const [, name2, argument2] = call;
|
|
13496
|
+
if (name2 === "os") return argument2 === "iOS";
|
|
13197
13497
|
if (name2 === "canImport")
|
|
13198
|
-
return
|
|
13199
|
-
if (name2 === "targetEnvironment") return
|
|
13200
|
-
if (name2 === "arch") return
|
|
13498
|
+
return argument2 !== "FoundationNetworking" && available?.has(argument2);
|
|
13499
|
+
if (name2 === "targetEnvironment") return argument2 === "simulator";
|
|
13500
|
+
if (name2 === "arch") return argument2 === "wasm64" || argument2 === "arm64";
|
|
13201
13501
|
return void 0;
|
|
13202
13502
|
};
|
|
13203
13503
|
const both = () => {
|
|
@@ -13256,7 +13556,7 @@ function swiftImportNames(contents2, available) {
|
|
|
13256
13556
|
function swiftPeachModules(moduleRoot) {
|
|
13257
13557
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
13258
13558
|
return distribution ? distribution.modules : swiftManifestDeclarations(
|
|
13259
|
-
(0,
|
|
13559
|
+
(0, import_node_fs26.readFileSync)(import_node_path28.default.join(moduleRoot, "Package.swift"), "utf8")
|
|
13260
13560
|
).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
|
|
13261
13561
|
}
|
|
13262
13562
|
var sdkPaths = /* @__PURE__ */ new Map();
|
|
@@ -13267,7 +13567,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
13267
13567
|
const cached = sdkPaths.get(key);
|
|
13268
13568
|
if (cached) return cached;
|
|
13269
13569
|
const configuration = (0, import_node_child_process19.execFileSync)(
|
|
13270
|
-
|
|
13570
|
+
import_node_path28.default.join(toolchainBin, "swift"),
|
|
13271
13571
|
[
|
|
13272
13572
|
"sdk",
|
|
13273
13573
|
"configure",
|
|
@@ -13292,7 +13592,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
13292
13592
|
if (!Array.isArray(toolsets) || !toolsets.every((value) => typeof value === "string"))
|
|
13293
13593
|
throw new Error(`swift sdk ${sdk} reports invalid toolset paths`);
|
|
13294
13594
|
for (const toolset of toolsets) {
|
|
13295
|
-
const config = JSON.parse((0,
|
|
13595
|
+
const config = JSON.parse((0, import_node_fs26.readFileSync)(toolset, "utf8"));
|
|
13296
13596
|
if (!config || typeof config !== "object" || !("swiftCompiler" in config)) continue;
|
|
13297
13597
|
const compiler = config.swiftCompiler;
|
|
13298
13598
|
if (!compiler || typeof compiler !== "object" || !("extraCLIOptions" in compiler))
|
|
@@ -13308,7 +13608,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
13308
13608
|
if (flag !== "-fwasm-exceptions") cFlags.push(flag);
|
|
13309
13609
|
if (flag === "-iframeworkwithsysroot" && options2[index + 2] === "-Xcc" && typeof options2[index + 3] === "string") {
|
|
13310
13610
|
cFlags.push(options2[index + 3]);
|
|
13311
|
-
frameworks.push(
|
|
13611
|
+
frameworks.push(import_node_path28.default.join(sysroot, options2[index + 3]));
|
|
13312
13612
|
index += 3;
|
|
13313
13613
|
continue;
|
|
13314
13614
|
}
|
|
@@ -13325,7 +13625,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
13325
13625
|
}
|
|
13326
13626
|
const paths = {
|
|
13327
13627
|
sysroot,
|
|
13328
|
-
darwin:
|
|
13628
|
+
darwin: import_node_path28.default.join(sysroot, "darwin"),
|
|
13329
13629
|
resources: field("swiftResourcesPath"),
|
|
13330
13630
|
frameworks,
|
|
13331
13631
|
cFlags
|
|
@@ -13353,24 +13653,24 @@ function swiftOverlayFrameworks(moduleRoot, toolchainBin) {
|
|
|
13353
13653
|
const { darwin, resources, frameworks } = swiftSdkPaths(moduleRoot, toolchainBin);
|
|
13354
13654
|
const swiftModules = new Set(swiftPeachModules(moduleRoot));
|
|
13355
13655
|
const result = /* @__PURE__ */ new Set();
|
|
13356
|
-
const include =
|
|
13357
|
-
for (const entry of (0,
|
|
13656
|
+
const include = import_node_path28.default.join(darwin, "usr/include");
|
|
13657
|
+
for (const entry of (0, import_node_fs26.readdirSync)(include))
|
|
13358
13658
|
if (entry.endsWith(".modulemap"))
|
|
13359
13659
|
addSwiftOverlayFrameworks(
|
|
13360
|
-
(0,
|
|
13660
|
+
(0, import_node_fs26.readFileSync)(import_node_path28.default.join(include, entry), "utf8"),
|
|
13361
13661
|
swiftModules,
|
|
13362
13662
|
result
|
|
13363
13663
|
);
|
|
13364
|
-
for (const entry of (0,
|
|
13365
|
-
const map =
|
|
13366
|
-
if ((0,
|
|
13367
|
-
addSwiftOverlayFrameworks((0,
|
|
13664
|
+
for (const entry of (0, import_node_fs26.readdirSync)(resources)) {
|
|
13665
|
+
const map = import_node_path28.default.join(resources, entry, "module.modulemap");
|
|
13666
|
+
if ((0, import_node_fs26.existsSync)(map))
|
|
13667
|
+
addSwiftOverlayFrameworks((0, import_node_fs26.readFileSync)(map, "utf8"), swiftModules, result);
|
|
13368
13668
|
}
|
|
13369
13669
|
for (const directory of frameworks)
|
|
13370
|
-
for (const entry of (0,
|
|
13371
|
-
const map =
|
|
13372
|
-
if ((0,
|
|
13373
|
-
addSwiftOverlayFrameworks((0,
|
|
13670
|
+
for (const entry of (0, import_node_fs26.readdirSync)(directory)) {
|
|
13671
|
+
const map = import_node_path28.default.join(directory, entry, "Modules/module.modulemap");
|
|
13672
|
+
if ((0, import_node_fs26.existsSync)(map))
|
|
13673
|
+
addSwiftOverlayFrameworks((0, import_node_fs26.readFileSync)(map, "utf8"), swiftModules, result);
|
|
13374
13674
|
}
|
|
13375
13675
|
sdkOverlayFrameworks.set(key, result);
|
|
13376
13676
|
return result;
|
|
@@ -13386,51 +13686,51 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
13386
13686
|
toolchainBin
|
|
13387
13687
|
);
|
|
13388
13688
|
const maps = /* @__PURE__ */ new Set([
|
|
13389
|
-
|
|
13689
|
+
import_node_path28.default.join(darwin, "usr/include/module.modulemap"),
|
|
13390
13690
|
...cFlags.filter((flag) => flag.startsWith("-fmodule-map-file=")).map((flag) => {
|
|
13391
13691
|
const file = flag.slice("-fmodule-map-file=".length);
|
|
13392
|
-
return file.startsWith("=") ?
|
|
13692
|
+
return file.startsWith("=") ? import_node_path28.default.join(sysroot, file.slice(1)) : file;
|
|
13393
13693
|
})
|
|
13394
13694
|
]);
|
|
13395
13695
|
for (const map of maps) {
|
|
13396
|
-
if (!(0,
|
|
13397
|
-
const contents2 = (0,
|
|
13696
|
+
if (!(0, import_node_fs26.existsSync)(map)) continue;
|
|
13697
|
+
const contents2 = (0, import_node_fs26.readFileSync)(map, "utf8");
|
|
13398
13698
|
for (const match of contents2.matchAll(
|
|
13399
13699
|
/^(?:explicit\s+)?(?:framework\s+)?module\s+([A-Za-z_]\w*)/gm
|
|
13400
13700
|
))
|
|
13401
13701
|
modules.add(match[1]);
|
|
13402
13702
|
for (const match of contents2.matchAll(/^\s*extern\s+module\s+\w+\s+"([^"]+)"/gm))
|
|
13403
|
-
maps.add(
|
|
13703
|
+
maps.add(import_node_path28.default.resolve(import_node_path28.default.dirname(map), match[1]));
|
|
13404
13704
|
}
|
|
13405
|
-
for (const entry of (0,
|
|
13705
|
+
for (const entry of (0, import_node_fs26.readdirSync)(import_node_path28.default.join(resources, "wasi"))) {
|
|
13406
13706
|
if (entry.endsWith(".swiftmodule"))
|
|
13407
13707
|
modules.add(entry.slice(0, -".swiftmodule".length));
|
|
13408
13708
|
}
|
|
13409
|
-
for (const entry of (0,
|
|
13410
|
-
const map =
|
|
13411
|
-
if (!(0,
|
|
13412
|
-
for (const match of (0,
|
|
13709
|
+
for (const entry of (0, import_node_fs26.readdirSync)(resources)) {
|
|
13710
|
+
const map = import_node_path28.default.join(resources, entry, "module.modulemap");
|
|
13711
|
+
if (!(0, import_node_fs26.existsSync)(map)) continue;
|
|
13712
|
+
for (const match of (0, import_node_fs26.readFileSync)(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
|
|
13413
13713
|
modules.add(match[1]);
|
|
13414
13714
|
}
|
|
13415
13715
|
for (const libc of [
|
|
13416
|
-
|
|
13417
|
-
|
|
13716
|
+
import_node_path28.default.join(darwin, "usr/include"),
|
|
13717
|
+
import_node_path28.default.join(
|
|
13418
13718
|
swiftSharedSdkRoot(moduleRoot, swiftDistributionAt(moduleRoot) !== null),
|
|
13419
13719
|
"usr/include"
|
|
13420
13720
|
)
|
|
13421
13721
|
])
|
|
13422
|
-
for (const entry of (0,
|
|
13722
|
+
for (const entry of (0, import_node_fs26.readdirSync)(libc)) {
|
|
13423
13723
|
if (!entry.endsWith(".modulemap")) continue;
|
|
13424
|
-
for (const match of (0,
|
|
13724
|
+
for (const match of (0, import_node_fs26.readFileSync)(import_node_path28.default.join(libc, entry), "utf8").matchAll(
|
|
13425
13725
|
/^module\s+([A-Za-z_]\w*)/gm
|
|
13426
13726
|
))
|
|
13427
13727
|
modules.add(match[1]);
|
|
13428
13728
|
}
|
|
13429
13729
|
for (const directory of frameworks) {
|
|
13430
|
-
for (const entry of (0,
|
|
13431
|
-
const map =
|
|
13432
|
-
if (!(0,
|
|
13433
|
-
for (const match of (0,
|
|
13730
|
+
for (const entry of (0, import_node_fs26.readdirSync)(directory)) {
|
|
13731
|
+
const map = import_node_path28.default.join(directory, entry, "Modules/module.modulemap");
|
|
13732
|
+
if (!(0, import_node_fs26.existsSync)(map)) continue;
|
|
13733
|
+
for (const match of (0, import_node_fs26.readFileSync)(map, "utf8").matchAll(
|
|
13434
13734
|
/^framework\s+module\s+([A-Za-z_]\w*)/gm
|
|
13435
13735
|
))
|
|
13436
13736
|
modules.add(match[1]);
|
|
@@ -13528,23 +13828,23 @@ int EXUpdatesApplyBSDiffPatch(const char * _Nonnull oldFilePath,
|
|
|
13528
13828
|
}
|
|
13529
13829
|
];
|
|
13530
13830
|
function distributionClangModulePresent(modules, name2) {
|
|
13531
|
-
return (0,
|
|
13831
|
+
return (0, import_node_fs26.existsSync)(import_node_path28.default.join(modules, `${name2}.swiftmodule`)) || (0, import_node_fs26.existsSync)(import_node_path28.default.join(modules, name2, "module.modulemap"));
|
|
13532
13832
|
}
|
|
13533
13833
|
function distributionClangModuleMap(root, modules) {
|
|
13534
13834
|
const missing = DISTRIBUTION_CLANG_MODULES.filter(
|
|
13535
13835
|
(mod) => !distributionClangModulePresent(modules, mod.name)
|
|
13536
13836
|
);
|
|
13537
13837
|
if (missing.length === 0) return null;
|
|
13538
|
-
const key = (0,
|
|
13539
|
-
const directory =
|
|
13540
|
-
const mapPath =
|
|
13541
|
-
if (!(0,
|
|
13542
|
-
(0,
|
|
13838
|
+
const key = (0, import_node_crypto15.createHash)("sha256").update(modules).update(missing.map((mod) => `${mod.name}\0${mod.source}`).join("\0")).digest("hex").slice(0, 16);
|
|
13839
|
+
const directory = import_node_path28.default.join(root, `.peach-clang-modules-${key}`);
|
|
13840
|
+
const mapPath = import_node_path28.default.join(directory, "module.modulemap");
|
|
13841
|
+
if (!(0, import_node_fs26.existsSync)(mapPath)) {
|
|
13842
|
+
(0, import_node_fs26.mkdirSync)(directory, { recursive: true });
|
|
13543
13843
|
const parts = [];
|
|
13544
13844
|
for (const mod of missing) {
|
|
13545
|
-
const destination =
|
|
13546
|
-
(0,
|
|
13547
|
-
(0,
|
|
13845
|
+
const destination = import_node_path28.default.join(directory, mod.header);
|
|
13846
|
+
(0, import_node_fs26.mkdirSync)(import_node_path28.default.dirname(destination), { recursive: true });
|
|
13847
|
+
(0, import_node_fs26.writeFileSync)(destination, mod.source);
|
|
13548
13848
|
parts.push(
|
|
13549
13849
|
`module ${mod.name} {
|
|
13550
13850
|
requires objc
|
|
@@ -13554,7 +13854,7 @@ function distributionClangModuleMap(root, modules) {
|
|
|
13554
13854
|
`
|
|
13555
13855
|
);
|
|
13556
13856
|
}
|
|
13557
|
-
(0,
|
|
13857
|
+
(0, import_node_fs26.writeFileSync)(mapPath, parts.join("\n"));
|
|
13558
13858
|
}
|
|
13559
13859
|
return mapPath;
|
|
13560
13860
|
}
|
|
@@ -13564,18 +13864,18 @@ function distributionClangModuleOptions(root, modules) {
|
|
|
13564
13864
|
}
|
|
13565
13865
|
function providedModulesPath(root, modules, excluded) {
|
|
13566
13866
|
if (!excluded || excluded.size === 0) return modules;
|
|
13567
|
-
const entries = (0,
|
|
13568
|
-
const key = (0,
|
|
13569
|
-
const directory =
|
|
13570
|
-
const complete =
|
|
13571
|
-
if (!(0,
|
|
13572
|
-
(0,
|
|
13573
|
-
for (const entry of (0,
|
|
13574
|
-
(0,
|
|
13867
|
+
const entries = (0, import_node_fs26.readdirSync)(modules).filter((entry) => !excluded.has(entry.replace(/\..*$/, ""))).sort();
|
|
13868
|
+
const key = (0, import_node_crypto15.createHash)("sha256").update(JSON.stringify([modules, entries])).update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
|
|
13869
|
+
const directory = import_node_path28.default.join(root, `.peach-modules-${key}`);
|
|
13870
|
+
const complete = import_node_path28.default.join(directory, ".complete");
|
|
13871
|
+
if (!(0, import_node_fs26.existsSync)(complete)) {
|
|
13872
|
+
(0, import_node_fs26.mkdirSync)(directory, { recursive: true });
|
|
13873
|
+
for (const entry of (0, import_node_fs26.readdirSync)(directory))
|
|
13874
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(directory, entry), { recursive: true, force: true });
|
|
13575
13875
|
for (const entry of entries) {
|
|
13576
|
-
(0,
|
|
13876
|
+
(0, import_node_fs26.symlinkSync)(import_node_path28.default.join(modules, entry), import_node_path28.default.join(directory, entry));
|
|
13577
13877
|
}
|
|
13578
|
-
(0,
|
|
13878
|
+
(0, import_node_fs26.writeFileSync)(complete, "");
|
|
13579
13879
|
}
|
|
13580
13880
|
return directory;
|
|
13581
13881
|
}
|
|
@@ -13587,7 +13887,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
|
|
|
13587
13887
|
);
|
|
13588
13888
|
const names = /* @__PURE__ */ new Set([...frameworks, ...targets.map((target) => target.name)]);
|
|
13589
13889
|
const entriesByPrefix = new Map(
|
|
13590
|
-
targets.map(({ path:
|
|
13890
|
+
targets.map(({ path: path27 }) => [path27 === "." ? "" : `${path27}/`, []])
|
|
13591
13891
|
);
|
|
13592
13892
|
for (const entry of Object.entries(files)) {
|
|
13593
13893
|
const [file] = entry;
|
|
@@ -13622,7 +13922,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
|
|
|
13622
13922
|
(excluded) => relative === excluded || relative.startsWith(`${excluded}/`)
|
|
13623
13923
|
))
|
|
13624
13924
|
continue;
|
|
13625
|
-
if (nested.some((
|
|
13925
|
+
if (nested.some((path27) => file.startsWith(path27))) continue;
|
|
13626
13926
|
const imports = file.endsWith(".swift") ? swiftImportNames(contents2) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents2, ownsHeader) : [];
|
|
13627
13927
|
for (const name2 of imports) {
|
|
13628
13928
|
if (names.has(name2) && name2 !== target.name && !(target.dependencies !== void 0 && localNames.has(name2)))
|
|
@@ -13669,7 +13969,7 @@ var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
|
|
|
13669
13969
|
).join("");
|
|
13670
13970
|
var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
13671
13971
|
var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
13672
|
-
"-Xclang-linker", ${JSON.stringify(`-fuse-ld=${
|
|
13972
|
+
"-Xclang-linker", ${JSON.stringify(`-fuse-ld=${import_node_path28.default.join(root, SWIFT_AUTOLINK_LINKER)}`)},
|
|
13673
13973
|
"-Xlinker", "-z", "-Xlinker", "stack-size=8372224",
|
|
13674
13974
|
"-Xlinker", "--stack-first",
|
|
13675
13975
|
"-Xlinker", "--global-base=8372224",
|
|
@@ -13683,11 +13983,11 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
|
13683
13983
|
`;
|
|
13684
13984
|
var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...quoted2, "-Wl,--end-lib"] : [];
|
|
13685
13985
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
13686
|
-
var MULTI_MANIFEST_VERSION =
|
|
13986
|
+
var MULTI_MANIFEST_VERSION = 72;
|
|
13687
13987
|
var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
13688
|
-
var compilerSourceDigest = true ? "
|
|
13988
|
+
var compilerSourceDigest = true ? "886349932526d72a5a1493acbcd1799ec941afd89998ad0eab64bbe9c48afb95" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
|
|
13689
13989
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
13690
|
-
const hash = (0,
|
|
13990
|
+
const hash = (0, import_node_crypto15.createHash)("sha256");
|
|
13691
13991
|
hash.update(`swift-compile
|
|
13692
13992
|
${release}
|
|
13693
13993
|
`);
|
|
@@ -13700,32 +14000,32 @@ ${WASM_LOWER_IDENTITY}
|
|
|
13700
14000
|
`);
|
|
13701
14001
|
if (input.optimize) hash.update("optimize\n");
|
|
13702
14002
|
for (const file of Object.keys(input.files).sort()) {
|
|
13703
|
-
hash.update((0,
|
|
13704
|
-
hash.update((0,
|
|
14003
|
+
hash.update((0, import_node_crypto15.createHash)("sha256").update(file).digest());
|
|
14004
|
+
hash.update((0, import_node_crypto15.createHash)("sha256").update(input.files[file]).digest());
|
|
13705
14005
|
}
|
|
13706
14006
|
for (const file of Object.keys(input.metalSources ?? {}).sort()) {
|
|
13707
14007
|
hash.update("metal-source\n");
|
|
13708
|
-
hash.update((0,
|
|
14008
|
+
hash.update((0, import_node_crypto15.createHash)("sha256").update(file).digest());
|
|
13709
14009
|
hash.update(
|
|
13710
|
-
(0,
|
|
14010
|
+
(0, import_node_crypto15.createHash)("sha256").update(input.metalSources?.[file] ?? "").digest()
|
|
13711
14011
|
);
|
|
13712
14012
|
}
|
|
13713
14013
|
for (const base of Object.keys(input.resources ?? {}).sort()) {
|
|
13714
|
-
hash.update((0,
|
|
14014
|
+
hash.update((0, import_node_crypto15.createHash)("sha256").update(base).digest());
|
|
13715
14015
|
hash.update(
|
|
13716
|
-
(0,
|
|
14016
|
+
(0, import_node_crypto15.createHash)("sha256").update(input.resources?.[base] ?? "").digest()
|
|
13717
14017
|
);
|
|
13718
14018
|
}
|
|
13719
14019
|
for (const name2 of Object.keys(input.images ?? {}).sort()) {
|
|
13720
14020
|
const image = input.images?.[name2];
|
|
13721
14021
|
if (!image) continue;
|
|
13722
|
-
hash.update((0,
|
|
13723
|
-
hash.update((0,
|
|
13724
|
-
hash.update((0,
|
|
14022
|
+
hash.update((0, import_node_crypto15.createHash)("sha256").update(name2).digest());
|
|
14023
|
+
hash.update((0, import_node_crypto15.createHash)("sha256").update(image.file).digest());
|
|
14024
|
+
hash.update((0, import_node_crypto15.createHash)("sha256").update(image.data).digest());
|
|
13725
14025
|
}
|
|
13726
14026
|
for (const file of [...new Set(input.resourcePaths ?? [])].sort()) {
|
|
13727
14027
|
hash.update("resource-path\n");
|
|
13728
|
-
hash.update((0,
|
|
14028
|
+
hash.update((0, import_node_crypto15.createHash)("sha256").update(file).digest());
|
|
13729
14029
|
}
|
|
13730
14030
|
hash.update(
|
|
13731
14031
|
JSON.stringify(
|
|
@@ -13743,18 +14043,18 @@ ${input.defaultLocalization}
|
|
|
13743
14043
|
`);
|
|
13744
14044
|
for (const file of Object.keys(input.packageFiles ?? {}).sort()) {
|
|
13745
14045
|
hash.update(`package-file\0${file}\0`);
|
|
13746
|
-
hash.update((0,
|
|
14046
|
+
hash.update((0, import_node_crypto15.createHash)("sha256").update(input.packageFiles[file]).digest());
|
|
13747
14047
|
}
|
|
13748
14048
|
for (const file of Object.keys(input.projectFiles ?? {}).sort()) {
|
|
13749
14049
|
hash.update(`project-file\0${file}\0`);
|
|
13750
|
-
hash.update((0,
|
|
14050
|
+
hash.update((0, import_node_crypto15.createHash)("sha256").update(input.projectFiles[file]).digest());
|
|
13751
14051
|
}
|
|
13752
14052
|
for (const target of Object.keys(input.libraries ?? {}).sort()) {
|
|
13753
14053
|
hash.update(`library
|
|
13754
14054
|
${target}
|
|
13755
14055
|
`);
|
|
13756
14056
|
hash.update(
|
|
13757
|
-
(0,
|
|
14057
|
+
(0, import_node_crypto15.createHash)("sha256").update(input.libraries?.[target] ?? "").digest()
|
|
13758
14058
|
);
|
|
13759
14059
|
}
|
|
13760
14060
|
for (const [name2, bytes] of Object.entries(input.binaryModules ?? {}).sort())
|
|
@@ -13778,17 +14078,17 @@ var nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
|
13778
14078
|
var cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|
|
13779
14079
|
var cxxFlagArray = (flags) => JSON.stringify([...nativeCxxCompilerFlags, ...withoutGlogModuleMap(flags)]);
|
|
13780
14080
|
function swiftCrossImportFlags(moduleRoot, distribution) {
|
|
13781
|
-
const overlayRoot =
|
|
14081
|
+
const overlayRoot = import_node_path28.default.join(
|
|
13782
14082
|
moduleRoot,
|
|
13783
14083
|
distribution ? "modules" : "cross-import-overlays"
|
|
13784
14084
|
);
|
|
13785
|
-
return (0,
|
|
14085
|
+
return (0, import_node_fs26.readdirSync)(overlayRoot, { encoding: "utf8", recursive: true }).filter((file) => file.endsWith(".swiftoverlay")).sort((left, right) => left.localeCompare(right)).flatMap((file) => [
|
|
13786
14086
|
"-Xfrontend",
|
|
13787
14087
|
"-swift-module-cross-import",
|
|
13788
14088
|
"-Xfrontend",
|
|
13789
|
-
|
|
14089
|
+
import_node_path28.default.basename(import_node_path28.default.dirname(file), ".swiftcrossimport"),
|
|
13790
14090
|
"-Xfrontend",
|
|
13791
|
-
|
|
14091
|
+
import_node_path28.default.join(overlayRoot, file)
|
|
13792
14092
|
]);
|
|
13793
14093
|
}
|
|
13794
14094
|
function withoutWasmOverlayIsystem(flags) {
|
|
@@ -13828,7 +14128,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13828
14128
|
if (!flag.startsWith("-fmodule-map-file=")) return false;
|
|
13829
14129
|
const file = flag.slice("-fmodule-map-file=".length).replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root);
|
|
13830
14130
|
if (!file.includes("/Pods/Headers/")) return false;
|
|
13831
|
-
const map = args.files.get(file) ?? ((0,
|
|
14131
|
+
const map = args.files.get(file) ?? ((0, import_node_fs26.existsSync)(file) ? (0, import_node_fs26.readFileSync)(file) : void 0);
|
|
13832
14132
|
const name2 = map === void 0 ? void 0 : moduleMapName(map.toString());
|
|
13833
14133
|
return name2 !== void 0 && packageModules.has(name2);
|
|
13834
14134
|
};
|
|
@@ -13860,7 +14160,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13860
14160
|
const product = v5.parse(
|
|
13861
14161
|
swiftFrameworkProductSchema,
|
|
13862
14162
|
JSON.parse(
|
|
13863
|
-
(0,
|
|
14163
|
+
(0, import_node_fs26.readFileSync)(import_node_path28.default.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
|
|
13864
14164
|
)
|
|
13865
14165
|
);
|
|
13866
14166
|
const replacedObjects = new Set(
|
|
@@ -13874,7 +14174,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13874
14174
|
(name2) => !object3.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
|
|
13875
14175
|
)
|
|
13876
14176
|
);
|
|
13877
|
-
const quoted2 = (object3) => `"${
|
|
14177
|
+
const quoted2 = (object3) => `"${import_node_path28.default.join(moduleRoot, object3).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
13878
14178
|
const categoryObjects = new Set(
|
|
13879
14179
|
foundationCategoryObjects.map((name2) => `lib/Foundation-${name2}.o`)
|
|
13880
14180
|
);
|
|
@@ -13891,7 +14191,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13891
14191
|
].join("\n") + "\n";
|
|
13892
14192
|
distributionLinkPath = distributionLink.path.replace(
|
|
13893
14193
|
/\.rsp$/,
|
|
13894
|
-
`-${(0,
|
|
14194
|
+
`-${(0, import_node_crypto15.createHash)("sha256").update(list).digest("hex").slice(0, 12)}.rsp`
|
|
13895
14195
|
);
|
|
13896
14196
|
distributionLink.files.set(distributionLinkPath, list);
|
|
13897
14197
|
}
|
|
@@ -13908,8 +14208,8 @@ function emitSwiftPackageManifest(args) {
|
|
|
13908
14208
|
const macroSettings = (values) => (values ?? []).map((value) => ` ${clangMacroSetting(value)},`).join("");
|
|
13909
14209
|
const flagArray = (literal2) => {
|
|
13910
14210
|
const content = literal2.replace(/,\s*]$/, "]");
|
|
13911
|
-
const digest = (0,
|
|
13912
|
-
const file =
|
|
14211
|
+
const digest = (0, import_node_crypto15.createHash)("sha256").update(content).digest("hex");
|
|
14212
|
+
const file = import_node_path28.default.join(args.root, ".peach-manifest-arguments", `${digest}.json`);
|
|
13913
14213
|
args.files.set(file, content);
|
|
13914
14214
|
return `peachCompilerArguments(${JSON.stringify(file)})`;
|
|
13915
14215
|
};
|
|
@@ -13920,8 +14220,8 @@ function emitSwiftPackageManifest(args) {
|
|
|
13920
14220
|
const macros = compactSwiftClangDefines(flags);
|
|
13921
14221
|
const compact = args.coalescibleOverlays ? compactSwiftClangOverlays(macros, args.coalescibleOverlays) : macros;
|
|
13922
14222
|
const content = compact.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
|
|
13923
|
-
const digest = (0,
|
|
13924
|
-
const file =
|
|
14223
|
+
const digest = (0, import_node_crypto15.createHash)("sha256").update(content).digest("hex");
|
|
14224
|
+
const file = import_node_path28.default.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
|
|
13925
14225
|
args.files.set(file, content);
|
|
13926
14226
|
return JSON.stringify([`@${file}`]);
|
|
13927
14227
|
};
|
|
@@ -13933,7 +14233,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13933
14233
|
owner?.publicHeadersPath ?? ""
|
|
13934
14234
|
);
|
|
13935
14235
|
return [
|
|
13936
|
-
...owner && framework ? [
|
|
14236
|
+
...owner && framework ? [import_node_path28.default.posix.join(args.root, owner.path, framework[1])] : [],
|
|
13937
14237
|
...frameworkDirectories(dependency, seen)
|
|
13938
14238
|
];
|
|
13939
14239
|
});
|
|
@@ -13955,7 +14255,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
13955
14255
|
const stanza = (target) => {
|
|
13956
14256
|
const native = args.native?.get(target.name);
|
|
13957
14257
|
if (target.systemLibrary || native?.clang?.sources.length === 0)
|
|
13958
|
-
return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ?
|
|
14258
|
+
return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? import_node_path28.default.posix.dirname(native.clang.modulemap) : target.path)}),`;
|
|
13959
14259
|
const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
|
|
13960
14260
|
const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
|
|
13961
14261
|
const defines = (target.defines ?? []).map((name2) => ` .define(${JSON.stringify(name2)}),`).join("");
|
|
@@ -13968,10 +14268,10 @@ function emitSwiftPackageManifest(args) {
|
|
|
13968
14268
|
const imports = binaryImports + (distribution ? `, "-Isystem", ${JSON.stringify(
|
|
13969
14269
|
providedModulesPath(
|
|
13970
14270
|
args.root,
|
|
13971
|
-
|
|
14271
|
+
import_node_path28.default.join(moduleRoot, "modules"),
|
|
13972
14272
|
args.moduleExcludes
|
|
13973
14273
|
)
|
|
13974
|
-
)}${distributionClangModuleOptions(args.root,
|
|
14274
|
+
)}${distributionClangModuleOptions(args.root, import_node_path28.default.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("")}` : "");
|
|
13975
14275
|
const nativeFlags = [
|
|
13976
14276
|
...args.nativeFlags?.get(target.name) ?? [],
|
|
13977
14277
|
...args.nativeHeaderFlags ?? []
|
|
@@ -14010,7 +14310,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
14010
14310
|
].map((flag) => `, ${JSON.stringify(flag)}`).join("");
|
|
14011
14311
|
const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || [...args.native?.values() ?? []].some(
|
|
14012
14312
|
(value) => value.late?.producers.includes(target.name)
|
|
14013
|
-
)) ? `, "-emit-objc-header-path", ${JSON.stringify(
|
|
14313
|
+
)) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path28.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
|
|
14014
14314
|
const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
|
|
14015
14315
|
const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
|
|
14016
14316
|
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}]`)})]`;
|
|
@@ -14179,19 +14479,19 @@ function emitSwiftPackageManifest(args) {
|
|
|
14179
14479
|
].join("\n");
|
|
14180
14480
|
}
|
|
14181
14481
|
function syncSwiftTree(base, files) {
|
|
14182
|
-
(0,
|
|
14482
|
+
(0, import_node_fs26.mkdirSync)(base, { recursive: true });
|
|
14183
14483
|
const kept = /* @__PURE__ */ new Set();
|
|
14184
|
-
for (const file of files.keys()) if ((0,
|
|
14484
|
+
for (const file of files.keys()) if ((0, import_node_fs26.existsSync)(file)) kept.add((0, import_node_fs26.statSync)(file).ino);
|
|
14185
14485
|
const walk = (dir) => {
|
|
14186
|
-
for (const entry of (0,
|
|
14187
|
-
const full =
|
|
14486
|
+
for (const entry of (0, import_node_fs26.readdirSync)(dir, { withFileTypes: true })) {
|
|
14487
|
+
const full = import_node_path28.default.join(dir, entry.name);
|
|
14188
14488
|
if (dir === base && (entry.name === ".build" || entry.name.startsWith(".peach-modules-") || // distribution clang maps are written beside the project and named
|
|
14189
14489
|
// from the compiler flags, so a sync must not remove them.
|
|
14190
14490
|
entry.name.startsWith(".peach-clang-modules-") || entry.name === SWIFT_LINK_STAMP))
|
|
14191
14491
|
continue;
|
|
14192
14492
|
if (entry.isDirectory()) walk(full);
|
|
14193
|
-
else if (!files.has(full) && !kept.has((0,
|
|
14194
|
-
(0,
|
|
14493
|
+
else if (!files.has(full) && !kept.has((0, import_node_fs26.lstatSync)(full).ino))
|
|
14494
|
+
(0, import_node_fs26.rmSync)(full, { force: true });
|
|
14195
14495
|
}
|
|
14196
14496
|
};
|
|
14197
14497
|
walk(base);
|
|
@@ -14339,7 +14639,7 @@ function compiledSwiftSources(files, targets, overlayFrameworks, headers, native
|
|
|
14339
14639
|
const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
|
|
14340
14640
|
return new Map(
|
|
14341
14641
|
[...owners].map(([file, { source, owner }]) => {
|
|
14342
|
-
if (nativeSourceGlue &&
|
|
14642
|
+
if (nativeSourceGlue && import_node_path28.default.posix.basename(file) === "OneNativeSource.generated.swift")
|
|
14343
14643
|
return [file, source];
|
|
14344
14644
|
const manifest = /(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file);
|
|
14345
14645
|
if (manifest && (!owner || /^Package(?:@swift-[\d.]+)?\.swift$/.test(file)))
|
|
@@ -14536,7 +14836,6 @@ var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
|
|
|
14536
14836
|
"NSSwappedDouble",
|
|
14537
14837
|
"NSSwappedFloat",
|
|
14538
14838
|
"NSUbiquitousKeyValueStore",
|
|
14539
|
-
"NSValueTransformerName",
|
|
14540
14839
|
"NSXPCCoder",
|
|
14541
14840
|
"NSXPCConnection",
|
|
14542
14841
|
"NSXPCInterface",
|
|
@@ -14559,7 +14858,6 @@ var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
|
|
|
14559
14858
|
]);
|
|
14560
14859
|
var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
14561
14860
|
"CFBridgingRetain",
|
|
14562
|
-
"NSASCIIStringEncoding",
|
|
14563
14861
|
"NSAllHashTableObjects",
|
|
14564
14862
|
"NSAllMapTableKeys",
|
|
14565
14863
|
"NSAllMapTableValues",
|
|
@@ -14638,21 +14936,16 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14638
14936
|
"NSHashTableWeakMemory",
|
|
14639
14937
|
"NSHebrewCalendar",
|
|
14640
14938
|
"NSHostByteOrder",
|
|
14641
|
-
"NSISO2022JPStringEncoding",
|
|
14642
14939
|
"NSISO8601Calendar",
|
|
14643
|
-
"NSISOLatin1StringEncoding",
|
|
14644
|
-
"NSISOLatin2StringEncoding",
|
|
14645
14940
|
"NSIndianCalendar",
|
|
14646
14941
|
"NSIslamicCalendar",
|
|
14647
14942
|
"NSIslamicCivilCalendar",
|
|
14648
14943
|
"NSItemProviderPreferredImageSizeKey",
|
|
14649
14944
|
"NSJapaneseCalendar",
|
|
14650
|
-
"NSJapaneseEUCStringEncoding",
|
|
14651
14945
|
"NSLoadedClasses",
|
|
14652
14946
|
"NSLocalizedFailureErrorKey",
|
|
14653
14947
|
"NSLogPageSize",
|
|
14654
14948
|
"NSMACHOperatingSystem",
|
|
14655
|
-
"NSMacOSRomanStringEncoding",
|
|
14656
14949
|
"NSMapGet",
|
|
14657
14950
|
"NSMapInsert",
|
|
14658
14951
|
"NSMapInsertIfAbsent",
|
|
@@ -14664,10 +14957,8 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14664
14957
|
"NSMapTableStrongMemory",
|
|
14665
14958
|
"NSMapTableWeakMemory",
|
|
14666
14959
|
"NSMultipleUnderlyingErrorsKey",
|
|
14667
|
-
"NSNEXTSTEPStringEncoding",
|
|
14668
14960
|
"NSNextHashEnumeratorItem",
|
|
14669
14961
|
"NSNextMapEnumeratorPair",
|
|
14670
|
-
"NSNonLossyASCIIStringEncoding",
|
|
14671
14962
|
"NSNonOwnedPointerHashCallBacks",
|
|
14672
14963
|
"NSNonOwnedPointerMapKeyCallBacks",
|
|
14673
14964
|
"NSNonOwnedPointerMapValueCallBacks",
|
|
@@ -14689,12 +14980,10 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14689
14980
|
"NSPointerToStructHashCallBacks",
|
|
14690
14981
|
"NSPropertyListErrorMaximum",
|
|
14691
14982
|
"NSPropertyListErrorMinimum",
|
|
14692
|
-
"NSProprietaryStringEncoding",
|
|
14693
14983
|
"NSProtocolFromString",
|
|
14694
14984
|
"NSRepublicOfChinaCalendar",
|
|
14695
14985
|
"NSResetHashTable",
|
|
14696
14986
|
"NSResetMapTable",
|
|
14697
|
-
"NSShiftJISStringEncoding",
|
|
14698
14987
|
"NSSolarisOperatingSystem",
|
|
14699
14988
|
"NSStringFromHashTable",
|
|
14700
14989
|
"NSStringFromMapTable",
|
|
@@ -14730,7 +15019,6 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14730
15019
|
"NSSwapLong",
|
|
14731
15020
|
"NSSwapLongLong",
|
|
14732
15021
|
"NSSwapShort",
|
|
14733
|
-
"NSSymbolStringEncoding",
|
|
14734
15022
|
"NSTextCheckingAllCustomTypes",
|
|
14735
15023
|
"NSTextCheckingAllSystemTypes",
|
|
14736
15024
|
"NSTextCheckingAllTypes",
|
|
@@ -14748,13 +15036,6 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14748
15036
|
"NSURLProtectionSpaceHTTPSProxy",
|
|
14749
15037
|
"NSURLProtectionSpaceSOCKSProxy",
|
|
14750
15038
|
"NSURLSessionUploadTaskResumeData",
|
|
14751
|
-
"NSUTF16BigEndianStringEncoding",
|
|
14752
|
-
"NSUTF16LittleEndianStringEncoding",
|
|
14753
|
-
"NSUTF16StringEncoding",
|
|
14754
|
-
"NSUTF32BigEndianStringEncoding",
|
|
14755
|
-
"NSUTF32LittleEndianStringEncoding",
|
|
14756
|
-
"NSUTF32StringEncoding",
|
|
14757
|
-
"NSUTF8StringEncoding",
|
|
14758
15039
|
"NSUbiquitousFileErrorMaximum",
|
|
14759
15040
|
"NSUbiquitousFileErrorMinimum",
|
|
14760
15041
|
"NSUbiquitousKeyValueStoreAccountChange",
|
|
@@ -14766,17 +15047,11 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14766
15047
|
"NSUndefinedDateComponent",
|
|
14767
15048
|
"NSUndoCloseGroupingRunLoopOrdering",
|
|
14768
15049
|
"NSUndoManagerGroupIsDiscardableKey",
|
|
14769
|
-
"NSUnicodeStringEncoding",
|
|
14770
15050
|
"NSUserActivityErrorMaximum",
|
|
14771
15051
|
"NSUserActivityErrorMinimum",
|
|
14772
15052
|
"NSValidationErrorMaximum",
|
|
14773
15053
|
"NSValidationErrorMinimum",
|
|
14774
15054
|
"NSWindows95OperatingSystem",
|
|
14775
|
-
"NSWindowsCP1250StringEncoding",
|
|
14776
|
-
"NSWindowsCP1251StringEncoding",
|
|
14777
|
-
"NSWindowsCP1252StringEncoding",
|
|
14778
|
-
"NSWindowsCP1253StringEncoding",
|
|
14779
|
-
"NSWindowsCP1254StringEncoding",
|
|
14780
15055
|
"NSWindowsNTOperatingSystem",
|
|
14781
15056
|
"NSWrapCalendarComponents",
|
|
14782
15057
|
"NSXPCConnectionCodeSigningRequirementFailure",
|
|
@@ -15097,7 +15372,7 @@ function swiftApplicationEntry(file, source) {
|
|
|
15097
15372
|
else if (source[at] === "}") depth--;
|
|
15098
15373
|
else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
|
|
15099
15374
|
return true;
|
|
15100
|
-
else if (depth === 0 &&
|
|
15375
|
+
else if (depth === 0 && import_node_path28.default.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
|
|
15101
15376
|
return true;
|
|
15102
15377
|
}
|
|
15103
15378
|
return false;
|
|
@@ -15212,11 +15487,11 @@ function objcApplicationMainCall(source) {
|
|
|
15212
15487
|
if (principal === null || delegate === null) return null;
|
|
15213
15488
|
return { principal, delegate };
|
|
15214
15489
|
}
|
|
15215
|
-
function objcMainCallArgument(
|
|
15216
|
-
if (/^(?:nil|NULL|Nil)$/.test(
|
|
15217
|
-
const literal2 = /^@"((?:[^"\\]|\\.)*)"$/.exec(
|
|
15490
|
+
function objcMainCallArgument(argument2) {
|
|
15491
|
+
if (/^(?:nil|NULL|Nil)$/.test(argument2)) return "nil";
|
|
15492
|
+
const literal2 = /^@"((?:[^"\\]|\\.)*)"$/.exec(argument2);
|
|
15218
15493
|
if (literal2) return `"${literal2[1]}"`;
|
|
15219
|
-
const name2 = /^NSStringFromClass\(\[([A-Za-z_]\w*) class\]\)$/.exec(
|
|
15494
|
+
const name2 = /^NSStringFromClass\(\[([A-Za-z_]\w*) class\]\)$/.exec(argument2);
|
|
15220
15495
|
if (name2) return `"${name2[1]}"`;
|
|
15221
15496
|
return null;
|
|
15222
15497
|
}
|
|
@@ -15485,6 +15760,18 @@ function swiftCMainEntry(file, source, env = emptyMacroEnvironment) {
|
|
|
15485
15760
|
}
|
|
15486
15761
|
return false;
|
|
15487
15762
|
}
|
|
15763
|
+
var SWIFT_SCAN_KEYWORDS = {
|
|
15764
|
+
c: "class",
|
|
15765
|
+
e: "extension",
|
|
15766
|
+
o: "override",
|
|
15767
|
+
i: "import",
|
|
15768
|
+
f: "func",
|
|
15769
|
+
U: "UIApplicationMain",
|
|
15770
|
+
F: "Foundation",
|
|
15771
|
+
C: "CoreFoundation",
|
|
15772
|
+
O: "ObjectiveC",
|
|
15773
|
+
_: "_LocationEssentials"
|
|
15774
|
+
};
|
|
15488
15775
|
function swiftCodeScan(source) {
|
|
15489
15776
|
const starts = /* @__PURE__ */ new Set();
|
|
15490
15777
|
const tokens = [];
|
|
@@ -15567,8 +15854,8 @@ function swiftCodeScan(source) {
|
|
|
15567
15854
|
else top.parens--;
|
|
15568
15855
|
i++;
|
|
15569
15856
|
} else {
|
|
15570
|
-
const keyword =
|
|
15571
|
-
if (keyword && !/[\w$]/.test(source[i - 1] ?? "") && !/[\w$]/.test(source[i + keyword.length] ?? "")) {
|
|
15857
|
+
const keyword = SWIFT_SCAN_KEYWORDS[char];
|
|
15858
|
+
if (keyword && source.startsWith(keyword, i) && !/[\w$]/.test(source[i - 1] ?? "") && !/[\w$]/.test(source[i + keyword.length] ?? "")) {
|
|
15572
15859
|
tokens.push(i);
|
|
15573
15860
|
i += keyword.length;
|
|
15574
15861
|
} else {
|
|
@@ -15580,27 +15867,27 @@ function swiftCodeScan(source) {
|
|
|
15580
15867
|
return { lineStarts: starts, tokens };
|
|
15581
15868
|
}
|
|
15582
15869
|
function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
15583
|
-
(0,
|
|
15870
|
+
(0, import_node_fs26.rmSync)(destination, { recursive: true, force: true });
|
|
15584
15871
|
const origins = {};
|
|
15585
15872
|
const moduleMaps = [];
|
|
15586
15873
|
const gather = (from) => {
|
|
15587
|
-
for (const entry of (0,
|
|
15874
|
+
for (const entry of (0, import_node_fs26.readdirSync)(from, { withFileTypes: true })) {
|
|
15588
15875
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
15589
15876
|
continue;
|
|
15590
|
-
const file =
|
|
15877
|
+
const file = import_node_path28.default.join(from, entry.name);
|
|
15591
15878
|
if (entry.isDirectory()) gather(file);
|
|
15592
15879
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
15593
|
-
origins[
|
|
15880
|
+
origins[import_node_path28.default.relative(source, file)] = (0, import_node_fs26.readFileSync)(file, "utf8");
|
|
15594
15881
|
else if (entry.isFile() && entry.name.endsWith(".modulemap"))
|
|
15595
|
-
moduleMaps.push((0,
|
|
15882
|
+
moduleMaps.push((0, import_node_fs26.readFileSync)(file, "utf8"));
|
|
15596
15883
|
}
|
|
15597
15884
|
};
|
|
15598
15885
|
gather(source);
|
|
15599
|
-
const manifest =
|
|
15600
|
-
const targets = (0,
|
|
15601
|
-
(0,
|
|
15886
|
+
const manifest = import_node_path28.default.join(source, "Package.swift");
|
|
15887
|
+
const targets = (0, import_node_fs26.existsSync)(manifest) ? swiftManifestTargets(
|
|
15888
|
+
(0, import_node_fs26.readFileSync)(manifest, "utf8"),
|
|
15602
15889
|
[],
|
|
15603
|
-
(file) => (0,
|
|
15890
|
+
(file) => (0, import_node_fs26.readFileSync)(file, "utf8")
|
|
15604
15891
|
) : [];
|
|
15605
15892
|
let dependencyOverlays;
|
|
15606
15893
|
const compiled = compiledSwiftSources(
|
|
@@ -15624,16 +15911,16 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
|
15624
15911
|
() => []
|
|
15625
15912
|
);
|
|
15626
15913
|
const copy = (from, to) => {
|
|
15627
|
-
(0,
|
|
15628
|
-
for (const entry of (0,
|
|
15914
|
+
(0, import_node_fs26.mkdirSync)(to, { recursive: true });
|
|
15915
|
+
for (const entry of (0, import_node_fs26.readdirSync)(from, { withFileTypes: true })) {
|
|
15629
15916
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
15630
15917
|
continue;
|
|
15631
|
-
const file =
|
|
15632
|
-
const target =
|
|
15918
|
+
const file = import_node_path28.default.join(from, entry.name);
|
|
15919
|
+
const target = import_node_path28.default.join(to, entry.name);
|
|
15633
15920
|
if (entry.isDirectory()) copy(file, target);
|
|
15634
15921
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
15635
|
-
(0,
|
|
15636
|
-
else (0,
|
|
15922
|
+
(0, import_node_fs26.writeFileSync)(target, compiled.get(import_node_path28.default.relative(source, file)));
|
|
15923
|
+
else (0, import_node_fs26.cpSync)(file, target, { verbatimSymlinks: true });
|
|
15637
15924
|
}
|
|
15638
15925
|
};
|
|
15639
15926
|
copy(source, destination);
|
|
@@ -15654,18 +15941,18 @@ function swiftWholeFileArm64Guard(source) {
|
|
|
15654
15941
|
}
|
|
15655
15942
|
function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
|
|
15656
15943
|
const searched = new Set(settings.headerSearchPaths);
|
|
15657
|
-
const directory =
|
|
15944
|
+
const directory = import_node_path28.default.join(layoutRoot, ".build", "peach-clang-modulemaps");
|
|
15658
15945
|
return (settings.moduleMaps ?? []).flatMap((map) => {
|
|
15659
|
-
const headers =
|
|
15660
|
-
if (!(0,
|
|
15661
|
-
const published =
|
|
15662
|
-
if (searched.has(map.headers) && (0,
|
|
15663
|
-
if (!searched.has(map.headers) && (0,
|
|
15946
|
+
const headers = import_node_path28.default.join(layoutRoot, map.headers);
|
|
15947
|
+
if (!(0, import_node_fs26.existsSync)(headers)) return [];
|
|
15948
|
+
const published = import_node_path28.default.join(headers, "module.modulemap");
|
|
15949
|
+
if (searched.has(map.headers) && (0, import_node_fs26.existsSync)(published)) return [];
|
|
15950
|
+
if (!searched.has(map.headers) && (0, import_node_fs26.existsSync)(published))
|
|
15664
15951
|
return [`-fmodule-map-file=${published}`];
|
|
15665
15952
|
const cached = written.get(headers);
|
|
15666
15953
|
if (cached) return [cached];
|
|
15667
|
-
(0,
|
|
15668
|
-
const output =
|
|
15954
|
+
(0, import_node_fs26.mkdirSync)(directory, { recursive: true });
|
|
15955
|
+
const output = import_node_path28.default.join(directory, `module-${written.size}.modulemap`);
|
|
15669
15956
|
writeBuildFile(
|
|
15670
15957
|
output,
|
|
15671
15958
|
swiftPackageClangModuleMap(swiftTargetModuleName(map.module), {
|
|
@@ -15699,7 +15986,7 @@ function needsNativeToolset(input, prebuilt) {
|
|
|
15699
15986
|
input.packageFiles || prebuilt || Object.keys(input.files).some(isSwiftNativeTranslationUnit)
|
|
15700
15987
|
);
|
|
15701
15988
|
}
|
|
15702
|
-
function writeSwiftProject(layout2, input, moduleRoot, prebuilt) {
|
|
15989
|
+
function writeSwiftProject(layout2, input, moduleRoot, prebuilt, allowHeaderCompiler = false) {
|
|
15703
15990
|
const nativeToolset = needsNativeToolset(input, prebuilt);
|
|
15704
15991
|
if (input.headerAliases !== void 0 && !isSwiftHeaderAliases(input.headerAliases))
|
|
15705
15992
|
throw new Error("swift compile input has invalid original header aliases");
|
|
@@ -15730,7 +16017,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15730
16017
|
const targets = distribution && compileTargets(input).length === 0 ? [
|
|
15731
16018
|
{
|
|
15732
16019
|
name: "App",
|
|
15733
|
-
path:
|
|
16020
|
+
path: import_node_path28.default.relative(layout2.root, layout2.sources),
|
|
15734
16021
|
executable: true,
|
|
15735
16022
|
languageMode: 5,
|
|
15736
16023
|
mainActorIsolation: false,
|
|
@@ -15738,7 +16025,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15738
16025
|
}
|
|
15739
16026
|
] : compileTargets(input);
|
|
15740
16027
|
const generatedOwners = new Map(targets.map((target) => [target.name, target.name]));
|
|
15741
|
-
const providedModules = distribution?.modules ?? (prebuilt ? (0,
|
|
16028
|
+
const providedModules = distribution?.modules ?? (prebuilt ? (0, import_node_fs26.readdirSync)(prebuilt.modules).filter((entry) => entry.endsWith(".swiftmodule")).map((entry) => entry.slice(0, -".swiftmodule".length)) : []);
|
|
15742
16029
|
const moduleExcludes = distribution || prebuilt ? /* @__PURE__ */ new Set([
|
|
15743
16030
|
...swiftSystemLibraryExclusions(input.files, targets, providedModules),
|
|
15744
16031
|
...providedModules.filter(
|
|
@@ -15756,12 +16043,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15756
16043
|
if (!file.endsWith(".swift")) continue;
|
|
15757
16044
|
const target = bySourcePath.find(
|
|
15758
16045
|
(candidate) => (candidate.path === "." || file.startsWith(`${candidate.path}/`)) && (candidate.sources === void 0 || candidate.sources.some((source) => {
|
|
15759
|
-
const selected =
|
|
16046
|
+
const selected = import_node_path28.default.posix.join(candidate.path, source);
|
|
15760
16047
|
return file === selected || file.startsWith(`${selected}/`);
|
|
15761
16048
|
}))
|
|
15762
16049
|
);
|
|
15763
16050
|
const excluded = target?.exclude?.some(
|
|
15764
|
-
(name2) => file ===
|
|
16051
|
+
(name2) => file === import_node_path28.default.posix.join(target.path, name2)
|
|
15765
16052
|
);
|
|
15766
16053
|
if (target && !excluded) swiftTargets.add(target.name);
|
|
15767
16054
|
}
|
|
@@ -15787,24 +16074,24 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15787
16074
|
([file, contents2]) => file.endsWith(".swift") ? [contents2] : []
|
|
15788
16075
|
)
|
|
15789
16076
|
);
|
|
15790
|
-
const headerDirectory =
|
|
16077
|
+
const headerDirectory = import_node_path28.default.join(layout2.root, ".build", "peach-cxx-headers");
|
|
15791
16078
|
const flattenedHeaders = /* @__PURE__ */ new Set();
|
|
15792
|
-
if ((0,
|
|
15793
|
-
for (const entry of (0,
|
|
16079
|
+
if ((0, import_node_fs26.existsSync)(headerDirectory)) {
|
|
16080
|
+
for (const entry of (0, import_node_fs26.readdirSync)(headerDirectory, { withFileTypes: true }))
|
|
15794
16081
|
if (entry.isDirectory() && !targets.some((target) => target.name === entry.name))
|
|
15795
|
-
(0,
|
|
16082
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(headerDirectory, entry.name), { recursive: true, force: true });
|
|
15796
16083
|
}
|
|
15797
16084
|
let checkedToolchain;
|
|
15798
16085
|
const nativeToolchain = () => {
|
|
15799
16086
|
if (checkedToolchain) return checkedToolchain;
|
|
15800
|
-
const pin = distribution ?? JSON.parse((0,
|
|
16087
|
+
const pin = distribution ?? JSON.parse((0, import_node_fs26.readFileSync)(import_node_path28.default.join(moduleRoot, "toolchain.json"), "utf8"));
|
|
15801
16088
|
checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
|
|
15802
16089
|
return checkedToolchain;
|
|
15803
16090
|
};
|
|
15804
16091
|
const deploymentTarget = (name2) => input.nativeTargets?.find((value) => value.name === name2)?.deploymentTarget ?? targets.find((value) => value.name === name2)?.iosDeploymentTarget ?? null;
|
|
15805
16092
|
const targetStagedFiles = /* @__PURE__ */ new Map();
|
|
15806
16093
|
const stageTargetFile = (target, file, contents2, options) => {
|
|
15807
|
-
const relative =
|
|
16094
|
+
const relative = import_node_path28.default.relative(layout2.root, file).split(import_node_path28.default.sep).join(import_node_path28.default.posix.sep);
|
|
15808
16095
|
const prior = files.has(file) ? files.get(file) : Object.hasOwn(input.files, relative) ? input.files[relative] : void 0;
|
|
15809
16096
|
if (!options?.allowExisting && prior !== void 0)
|
|
15810
16097
|
throw new Error(`target ${target} already contains generated output ${relative}`);
|
|
@@ -15817,7 +16104,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15817
16104
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
15818
16105
|
return Object.entries(input.files).filter(
|
|
15819
16106
|
([file]) => file.startsWith(prefix) && (target.sources === void 0 || !(file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) || target.sources.some((source) => {
|
|
15820
|
-
const selected =
|
|
16107
|
+
const selected = import_node_path28.default.posix.join(prefix, source);
|
|
15821
16108
|
return file === selected || file.startsWith(`${selected}/`);
|
|
15822
16109
|
})) && !target.exclude?.some(
|
|
15823
16110
|
(excluded) => file === `${prefix}${excluded}` || file.startsWith(`${prefix}${excluded}/`)
|
|
@@ -15838,7 +16125,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15838
16125
|
targetStagedFiles.delete(target.name);
|
|
15839
16126
|
if (entries.some(([file]) => isSwiftNativeTranslationUnit(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name))) {
|
|
15840
16127
|
if (!swift) {
|
|
15841
|
-
const unprepared =
|
|
16128
|
+
const unprepared = import_node_path28.default.join(
|
|
15842
16129
|
layout2.root,
|
|
15843
16130
|
target.path,
|
|
15844
16131
|
"PeachUnprepared.generated.swift"
|
|
@@ -15853,7 +16140,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15853
16140
|
native.set(target.name, {
|
|
15854
16141
|
mixed: true,
|
|
15855
16142
|
path: target.path,
|
|
15856
|
-
includeDirectory:
|
|
16143
|
+
includeDirectory: import_node_path28.default.join(layout2.root, target.path, "include"),
|
|
15857
16144
|
sources: [],
|
|
15858
16145
|
lateSources: [],
|
|
15859
16146
|
exclude: entries.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length))
|
|
@@ -15875,15 +16162,15 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15875
16162
|
file
|
|
15876
16163
|
)?.[1];
|
|
15877
16164
|
if (owner)
|
|
15878
|
-
podHeaders.set(
|
|
15879
|
-
...podHeaders.get(
|
|
16165
|
+
podHeaders.set(import_node_path28.default.basename(file), [
|
|
16166
|
+
...podHeaders.get(import_node_path28.default.basename(file)) ?? [],
|
|
15880
16167
|
{ owner, content: input.files[file] }
|
|
15881
16168
|
]);
|
|
15882
16169
|
}
|
|
15883
|
-
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(
|
|
16170
|
+
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(import_node_path28.default.basename(file))?.find((header) => header.content === content)?.owner;
|
|
15884
16171
|
for (const settings of input.nativeTargets ?? []) {
|
|
15885
16172
|
for (const file of settings.headers) {
|
|
15886
|
-
const destination =
|
|
16173
|
+
const destination = import_node_path28.default.join(layout2.root, file);
|
|
15887
16174
|
if (files.has(destination)) continue;
|
|
15888
16175
|
const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
|
|
15889
16176
|
const frameworkHeader = !interfaceModule && /(?:^|\/)(\w+)\.framework\/Headers\/[\w+.-]+\.h$/.exec(file)?.[1];
|
|
@@ -15902,10 +16189,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15902
16189
|
}
|
|
15903
16190
|
if (settings.flattensPublicHeaders)
|
|
15904
16191
|
for (const header of settings.publicHeaders) {
|
|
15905
|
-
const destination =
|
|
16192
|
+
const destination = import_node_path28.default.join(
|
|
15906
16193
|
headerDirectory,
|
|
15907
16194
|
settings.name,
|
|
15908
|
-
|
|
16195
|
+
import_node_path28.default.basename(header)
|
|
15909
16196
|
);
|
|
15910
16197
|
if (flattenedHeaders.has(destination))
|
|
15911
16198
|
throw new Error(`duplicate product header ${destination}`);
|
|
@@ -15913,9 +16200,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15913
16200
|
}
|
|
15914
16201
|
}
|
|
15915
16202
|
const nativeTargets = input.nativeTargets ?? [];
|
|
15916
|
-
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ?
|
|
16203
|
+
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? import_node_path28.default.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
|
|
15917
16204
|
const headerSearch = writeXcodeHeaderSearch(
|
|
15918
|
-
|
|
16205
|
+
import_node_path28.default.join(layout2.root, ".build", "peach-xcode-headers"),
|
|
15919
16206
|
nativeTargets.map((settings) => ({
|
|
15920
16207
|
headerMaps: settings.headerMaps.map((map) => ({
|
|
15921
16208
|
flag: map.flag,
|
|
@@ -15926,26 +16213,26 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15926
16213
|
})),
|
|
15927
16214
|
productHeaders: Object.fromEntries([
|
|
15928
16215
|
...Object.entries(settings.productHeaders).map(([product, file]) => [
|
|
15929
|
-
|
|
15930
|
-
|
|
16216
|
+
import_node_path28.default.join(layout2.root, product),
|
|
16217
|
+
import_node_path28.default.join(layout2.root, file)
|
|
15931
16218
|
]),
|
|
15932
16219
|
...settings.flattensPublicHeaders ? settings.publicHeaders.map((header) => [
|
|
15933
|
-
|
|
15934
|
-
|
|
16220
|
+
import_node_path28.default.join(headerDirectory, settings.name, import_node_path28.default.basename(header)),
|
|
16221
|
+
import_node_path28.default.join(layout2.root, header)
|
|
15935
16222
|
]) : []
|
|
15936
16223
|
]),
|
|
15937
16224
|
userHeaderSearchPaths: settings.userHeaderSearchPaths.map(
|
|
15938
|
-
(directory) =>
|
|
16225
|
+
(directory) => import_node_path28.default.join(layout2.root, directory)
|
|
15939
16226
|
),
|
|
15940
16227
|
searchDirectories: [
|
|
15941
16228
|
...settings.headerSearchPaths,
|
|
15942
16229
|
...settings.frameworkSearchPaths
|
|
15943
|
-
].map((directory) =>
|
|
16230
|
+
].map((directory) => import_node_path28.default.join(layout2.root, directory))
|
|
15944
16231
|
})),
|
|
15945
16232
|
Object.fromEntries(
|
|
15946
16233
|
Object.entries(input.headerAliases ?? {}).map(([alias, file]) => [
|
|
15947
|
-
|
|
15948
|
-
|
|
16234
|
+
import_node_path28.default.join(layout2.root, alias),
|
|
16235
|
+
import_node_path28.default.join(layout2.root, file)
|
|
15949
16236
|
])
|
|
15950
16237
|
)
|
|
15951
16238
|
);
|
|
@@ -15974,16 +16261,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15974
16261
|
for (const [file, contents2] of entries) {
|
|
15975
16262
|
const producers2 = /* @__PURE__ */ new Set();
|
|
15976
16263
|
const source = contents2.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
15977
|
-
for (const
|
|
15978
|
-
/^\s*#\s*(?:include|import)\s*[<"]([^>"]+)[>"]/gm
|
|
15979
|
-
)) {
|
|
15980
|
-
const include = match[1];
|
|
16264
|
+
for (const include of nativeHeaderIncludes(contents2)) {
|
|
15981
16265
|
const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include)?.[1];
|
|
15982
16266
|
if (producer && swiftTargets.has(producer)) producers2.add(producer);
|
|
15983
16267
|
const local = [
|
|
15984
|
-
|
|
16268
|
+
import_node_path28.default.posix.join(import_node_path28.default.posix.dirname(file), include),
|
|
15985
16269
|
`${includes}${include}`,
|
|
15986
|
-
...searchRoots.map((root) =>
|
|
16270
|
+
...searchRoots.map((root) => import_node_path28.default.posix.join(root, include))
|
|
15987
16271
|
].find((candidate) => input.files[candidate] !== void 0);
|
|
15988
16272
|
if (local) {
|
|
15989
16273
|
reverse.set(local, [...reverse.get(local) ?? [], file]);
|
|
@@ -16014,7 +16298,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16014
16298
|
);
|
|
16015
16299
|
const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : entries.some(([file]) => file.endsWith(".swift")) || importedModules.has(swiftTargetModuleName(target.name)) ? settings.publicHeaders : [];
|
|
16016
16300
|
const search = [.../* @__PURE__ */ new Set([...settings?.headerSearchPaths ?? []])].flatMap(
|
|
16017
|
-
(dir) => ["-I",
|
|
16301
|
+
(dir) => ["-I", import_node_path28.default.join(layout2.root, dir)]
|
|
16018
16302
|
);
|
|
16019
16303
|
const toolchainBin = nativeToolchain();
|
|
16020
16304
|
const stageFlags = (flags2, sdkInclude2) => flags2.map(
|
|
@@ -16026,7 +16310,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16026
16310
|
...search,
|
|
16027
16311
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
16028
16312
|
"-F",
|
|
16029
|
-
|
|
16313
|
+
import_node_path28.default.join(layout2.root, dir)
|
|
16030
16314
|
]),
|
|
16031
16315
|
"-I",
|
|
16032
16316
|
headerDirectory
|
|
@@ -16037,7 +16321,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16037
16321
|
...search,
|
|
16038
16322
|
...settings.frameworkSearchPaths.flatMap((dir) => [
|
|
16039
16323
|
"-F",
|
|
16040
|
-
|
|
16324
|
+
import_node_path28.default.join(layout2.root, dir)
|
|
16041
16325
|
]),
|
|
16042
16326
|
"-I",
|
|
16043
16327
|
headerDirectory
|
|
@@ -16047,13 +16331,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16047
16331
|
const flag = settings.importerFlags[index];
|
|
16048
16332
|
if (flag === "-I" || flag === "-iquote") {
|
|
16049
16333
|
const directory = settings.importerFlags[index + 1];
|
|
16050
|
-
if (directory === void 0 || !
|
|
16334
|
+
if (directory === void 0 || !import_node_path28.default.isAbsolute(directory)) {
|
|
16051
16335
|
index++;
|
|
16052
16336
|
continue;
|
|
16053
16337
|
}
|
|
16054
16338
|
}
|
|
16055
16339
|
const joined = /^-(?:I|iquote)(.+)$/.exec(flag);
|
|
16056
|
-
if (joined && !
|
|
16340
|
+
if (joined && !import_node_path28.default.isAbsolute(joined[1])) continue;
|
|
16057
16341
|
kept.push(flag);
|
|
16058
16342
|
}
|
|
16059
16343
|
return [
|
|
@@ -16062,13 +16346,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16062
16346
|
...search,
|
|
16063
16347
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
16064
16348
|
"-F",
|
|
16065
|
-
|
|
16349
|
+
import_node_path28.default.join(layout2.root, dir)
|
|
16066
16350
|
]),
|
|
16067
16351
|
"-I",
|
|
16068
16352
|
headerDirectory
|
|
16069
16353
|
];
|
|
16070
16354
|
})();
|
|
16071
|
-
const sdkInclude =
|
|
16355
|
+
const sdkInclude = import_node_path28.default.join(
|
|
16072
16356
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
16073
16357
|
"darwin/usr/include"
|
|
16074
16358
|
);
|
|
@@ -16083,7 +16367,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16083
16367
|
...dependencyModuleMaps,
|
|
16084
16368
|
...target.defines?.includes(SWIFT_XCODE_BUILD_CONDITION) && !target.defines.includes("SWIFT_PACKAGE") ? ["-USWIFT_PACKAGE"] : []
|
|
16085
16369
|
];
|
|
16086
|
-
const prefixHeader = settings?.prefixHeader ? ["-include",
|
|
16370
|
+
const prefixHeader = settings?.prefixHeader ? ["-include", import_node_path28.default.join(layout2.root, settings.prefixHeader)] : [];
|
|
16087
16371
|
const bundleName = entries.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
|
|
16088
16372
|
target: target.name,
|
|
16089
16373
|
path: target.path,
|
|
@@ -16094,7 +16378,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16094
16378
|
bundles: input.resourceBundles
|
|
16095
16379
|
});
|
|
16096
16380
|
const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
|
|
16097
|
-
const accessorHeader =
|
|
16381
|
+
const accessorHeader = import_node_path28.default.join(
|
|
16098
16382
|
layout2.root,
|
|
16099
16383
|
target.path,
|
|
16100
16384
|
OBJC_RESOURCE_ACCESSOR_HEADER
|
|
@@ -16105,7 +16389,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16105
16389
|
const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
|
|
16106
16390
|
const unitSource = (file) => {
|
|
16107
16391
|
const relative = file.slice(prefix.length);
|
|
16108
|
-
return relative.split("/").some((part) => part.startsWith(".")) ?
|
|
16392
|
+
return relative.split("/").some((part) => part.startsWith(".")) ? import_node_path28.default.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
|
|
16109
16393
|
};
|
|
16110
16394
|
const accessorFlags = accessor ? ["-include", accessorHeader] : [];
|
|
16111
16395
|
const nativeC = !entries.some(([file]) => file.endsWith(".swift"));
|
|
@@ -16135,20 +16419,20 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16135
16419
|
)
|
|
16136
16420
|
].sort();
|
|
16137
16421
|
const topHeaders = settings.publicHeaders.filter(
|
|
16138
|
-
(file) =>
|
|
16422
|
+
(file) => import_node_path28.default.posix.dirname(file) === headerDir
|
|
16139
16423
|
);
|
|
16140
16424
|
if (input.files[custom] !== void 0) {
|
|
16141
16425
|
swiftpmModuleMap = { path: custom, contents: input.files[custom] };
|
|
16142
16426
|
} else if (input.files[umbrella] !== void 0) {
|
|
16143
16427
|
if (siblingDirs.length > 0)
|
|
16144
16428
|
throw new Error(
|
|
16145
|
-
`target ${target.name} has invalid header layout: umbrella header found at '${
|
|
16429
|
+
`target ${target.name} has invalid header layout: umbrella header found at '${import_node_path28.default.join(layout2.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name2) => import_node_path28.default.join(layout2.root, headerDir, name2)).join(", ")}; consider removing them`
|
|
16146
16430
|
);
|
|
16147
16431
|
swiftpmModuleMap = {
|
|
16148
16432
|
path: custom,
|
|
16149
16433
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
16150
16434
|
kind: "header",
|
|
16151
|
-
path:
|
|
16435
|
+
path: import_node_path28.default.join(layout2.root, umbrella)
|
|
16152
16436
|
})
|
|
16153
16437
|
};
|
|
16154
16438
|
} else if (input.files[nestedUmbrella] !== void 0 && siblingDirs.length === 1 && siblingDirs[0] === moduleName && topHeaders.length === 0) {
|
|
@@ -16156,7 +16440,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16156
16440
|
path: custom,
|
|
16157
16441
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
16158
16442
|
kind: "header",
|
|
16159
|
-
path:
|
|
16443
|
+
path: import_node_path28.default.join(layout2.root, nestedUmbrella)
|
|
16160
16444
|
})
|
|
16161
16445
|
};
|
|
16162
16446
|
} else {
|
|
@@ -16164,12 +16448,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16164
16448
|
path: custom,
|
|
16165
16449
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
16166
16450
|
kind: "directory",
|
|
16167
|
-
path:
|
|
16451
|
+
path: import_node_path28.default.join(layout2.root, headerDir)
|
|
16168
16452
|
})
|
|
16169
16453
|
};
|
|
16170
16454
|
}
|
|
16171
16455
|
}
|
|
16172
|
-
const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ??
|
|
16456
|
+
const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? import_node_path28.default.posix.join(
|
|
16173
16457
|
".build",
|
|
16174
16458
|
"peach-objc-originals",
|
|
16175
16459
|
target.name,
|
|
@@ -16177,79 +16461,79 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16177
16461
|
);
|
|
16178
16462
|
const moduleContents = originalModuleMap ? input.files[originalModuleMap[1]] : swiftpmModuleMap?.contents ?? packageModuleMap?.[1] ?? swiftObjCModuleMap(
|
|
16179
16463
|
swiftTargetModuleName(target.name),
|
|
16180
|
-
roots2.map((file) =>
|
|
16464
|
+
roots2.map((file) => import_node_path28.default.join(layout2.root, file)),
|
|
16181
16465
|
submoduleImports.get(swiftTargetModuleName(target.name))
|
|
16182
16466
|
);
|
|
16183
16467
|
if (moduleContents === void 0)
|
|
16184
16468
|
throw new Error("missing original module map " + modulemap);
|
|
16185
|
-
stageTargetFile(target.name,
|
|
16469
|
+
stageTargetFile(target.name, import_node_path28.default.join(layout2.root, modulemap), moduleContents, {
|
|
16186
16470
|
allowExisting: true
|
|
16187
16471
|
});
|
|
16188
16472
|
sourceModuleMaps.set(swiftTargetModuleName(target.name), {
|
|
16189
|
-
path:
|
|
16473
|
+
path: import_node_path28.default.join(layout2.root, modulemap),
|
|
16190
16474
|
contents: moduleContents.toString()
|
|
16191
16475
|
});
|
|
16192
16476
|
if (modulemap.endsWith("/Modules/module.modulemap")) {
|
|
16193
|
-
const framework =
|
|
16477
|
+
const framework = import_node_path28.default.posix.dirname(import_node_path28.default.posix.dirname(modulemap));
|
|
16194
16478
|
for (const [, header] of moduleContents.toString().matchAll(/\bheader\s+"([^"]+)"/g))
|
|
16195
16479
|
for (const folder of ["Headers", "PrivateHeaders"]) {
|
|
16196
|
-
const source = settings.productHeaders[
|
|
16480
|
+
const source = settings.productHeaders[import_node_path28.default.posix.join(framework, folder, header)];
|
|
16197
16481
|
const contents2 = source === void 0 ? void 0 : input.files[source];
|
|
16198
16482
|
if (contents2 !== void 0)
|
|
16199
16483
|
stageTargetFile(
|
|
16200
16484
|
target.name,
|
|
16201
|
-
|
|
16485
|
+
import_node_path28.default.join(layout2.root, import_node_path28.default.posix.dirname(modulemap), folder, header),
|
|
16202
16486
|
contents2,
|
|
16203
16487
|
{ allowExisting: true }
|
|
16204
16488
|
);
|
|
16205
16489
|
}
|
|
16206
16490
|
}
|
|
16207
|
-
if (nativeC &&
|
|
16491
|
+
if (nativeC && import_node_path28.default.posix.basename(modulemap) !== "module.modulemap") {
|
|
16208
16492
|
stageTargetFile(
|
|
16209
16493
|
target.name,
|
|
16210
|
-
|
|
16211
|
-
`extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(
|
|
16494
|
+
import_node_path28.default.join(layout2.root, import_node_path28.default.posix.dirname(modulemap), "module.modulemap"),
|
|
16495
|
+
`extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(import_node_path28.default.join(layout2.root, modulemap))}
|
|
16212
16496
|
`
|
|
16213
16497
|
);
|
|
16214
16498
|
}
|
|
16215
16499
|
const importFlags = [
|
|
16216
16500
|
...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
|
|
16217
|
-
"-fmodule-map-file=" +
|
|
16501
|
+
"-fmodule-map-file=" + import_node_path28.default.join(layout2.root, modulemap),
|
|
16218
16502
|
...dependencyModuleMaps
|
|
16219
16503
|
];
|
|
16220
16504
|
const groups = /* @__PURE__ */ new Map();
|
|
16221
16505
|
for (const [file, contents2] of nativeUnits) {
|
|
16222
16506
|
const origin = settings?.sourceDirectories[file];
|
|
16223
16507
|
if (origin) {
|
|
16224
|
-
const original =
|
|
16225
|
-
(0,
|
|
16508
|
+
const original = import_node_path28.default.join(layout2.root, origin, import_node_path28.default.posix.basename(file));
|
|
16509
|
+
(0, import_node_fs26.mkdirSync)(import_node_path28.default.dirname(original), { recursive: true });
|
|
16226
16510
|
stageTargetFile(target.name, original, contents2, { allowExisting: true });
|
|
16227
16511
|
}
|
|
16228
16512
|
const source = unitSource(file);
|
|
16229
16513
|
if (source !== file.slice(prefix.length))
|
|
16230
16514
|
stageTargetFile(
|
|
16231
16515
|
target.name,
|
|
16232
|
-
|
|
16516
|
+
import_node_path28.default.join(layout2.root, target.path, source),
|
|
16233
16517
|
contents2,
|
|
16234
16518
|
{
|
|
16235
16519
|
allowExisting: true
|
|
16236
16520
|
}
|
|
16237
16521
|
);
|
|
16238
|
-
const stagedDir =
|
|
16522
|
+
const stagedDir = import_node_path28.default.posix.dirname(file);
|
|
16239
16523
|
const quoteDirs = [
|
|
16240
16524
|
...stagedDir !== "." ? [stagedDir] : [],
|
|
16241
16525
|
...origin && origin !== stagedDir ? [origin] : []
|
|
16242
16526
|
];
|
|
16243
16527
|
const quoteFlags = quoteDirs.flatMap((dir) => [
|
|
16244
16528
|
"-iquote",
|
|
16245
|
-
|
|
16529
|
+
import_node_path28.default.join(layout2.root, dir)
|
|
16246
16530
|
]);
|
|
16247
16531
|
const perFile = [
|
|
16248
16532
|
...file.endsWith(".c") && swiftWholeFileArm64Guard(contents2) ? ["-D__arm64__=1"] : [],
|
|
16249
16533
|
.../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
|
|
16250
16534
|
...stageFlags(
|
|
16251
16535
|
settings?.fileFlags[file] ?? [],
|
|
16252
|
-
|
|
16536
|
+
import_node_path28.default.join(
|
|
16253
16537
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
16254
16538
|
"darwin/usr/include"
|
|
16255
16539
|
)
|
|
@@ -16257,7 +16541,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16257
16541
|
];
|
|
16258
16542
|
const cxx = /\.(?:cc|cpp|cxx|mm)$/.test(file);
|
|
16259
16543
|
const moduleFlag = perFile.some((flag) => flag.startsWith("-fmodule-name=")) ? [] : [`-fmodule-name=${swiftTargetModuleName(target.name)}`];
|
|
16260
|
-
const identity = (0,
|
|
16544
|
+
const identity = (0, import_node_crypto15.createHash)("sha256").update(
|
|
16261
16545
|
JSON.stringify([
|
|
16262
16546
|
cxx,
|
|
16263
16547
|
quoteFlags,
|
|
@@ -16266,12 +16550,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16266
16550
|
])
|
|
16267
16551
|
).digest("hex").slice(0, 12);
|
|
16268
16552
|
const name2 = `${target.name}${nativeC ? "Native" : "Swift"}Implementation_${identity}`;
|
|
16269
|
-
const groupPath =
|
|
16270
|
-
const canonicalTargetPath =
|
|
16553
|
+
const groupPath = import_node_path28.default.posix.join("PeachNativeSources", name2);
|
|
16554
|
+
const canonicalTargetPath = import_node_path28.default.posix.join("/peach/build", target.path);
|
|
16271
16555
|
const sourceIdentity = [
|
|
16272
|
-
`-ffile-prefix-map=${
|
|
16556
|
+
`-ffile-prefix-map=${import_node_path28.default.join(layout2.root, groupPath)}=${canonicalTargetPath}`,
|
|
16273
16557
|
...nativeToolset ? [
|
|
16274
|
-
`-ffile-prefix-map=${
|
|
16558
|
+
`-ffile-prefix-map=${import_node_path28.default.posix.join("/peach/build", groupPath)}=${canonicalTargetPath}`
|
|
16275
16559
|
] : []
|
|
16276
16560
|
];
|
|
16277
16561
|
const group = groups.get(identity) ?? {
|
|
@@ -16295,7 +16579,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16295
16579
|
...accessorFlags,
|
|
16296
16580
|
...stageFlags(
|
|
16297
16581
|
cxx ? settings.cxxFlags : [],
|
|
16298
|
-
|
|
16582
|
+
import_node_path28.default.join(
|
|
16299
16583
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
16300
16584
|
"darwin/usr/include"
|
|
16301
16585
|
)
|
|
@@ -16306,12 +16590,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16306
16590
|
};
|
|
16307
16591
|
stageTargetFile(
|
|
16308
16592
|
target.name,
|
|
16309
|
-
|
|
16593
|
+
import_node_path28.default.join(layout2.root, group.path, source),
|
|
16310
16594
|
contents2
|
|
16311
16595
|
);
|
|
16312
16596
|
stageTargetFile(
|
|
16313
16597
|
target.name,
|
|
16314
|
-
|
|
16598
|
+
import_node_path28.default.join(layout2.root, group.path, "include/module.modulemap"),
|
|
16315
16599
|
`module ${swiftTargetModuleName(group.name)} { export * }
|
|
16316
16600
|
`,
|
|
16317
16601
|
{ allowExisting: true }
|
|
@@ -16323,7 +16607,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16323
16607
|
stageTargetFile(target.name, accessorHeader, accessor.header);
|
|
16324
16608
|
stageTargetFile(
|
|
16325
16609
|
target.name,
|
|
16326
|
-
|
|
16610
|
+
import_node_path28.default.join(layout2.root, accessorUnit),
|
|
16327
16611
|
accessor.body
|
|
16328
16612
|
);
|
|
16329
16613
|
}
|
|
@@ -16338,7 +16622,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16338
16622
|
].sort();
|
|
16339
16623
|
native.set(target.name, {
|
|
16340
16624
|
path: target.path,
|
|
16341
|
-
includeDirectory:
|
|
16625
|
+
includeDirectory: import_node_path28.default.dirname(import_node_path28.default.join(layout2.root, modulemap)),
|
|
16342
16626
|
importFlags,
|
|
16343
16627
|
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
16344
16628
|
lateSources: implementations.flatMap((group) => group.sources),
|
|
@@ -16361,23 +16645,23 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16361
16645
|
throw new Error(`original module map declares no module: ${modulemap}`);
|
|
16362
16646
|
stageTargetFile(
|
|
16363
16647
|
target.name,
|
|
16364
|
-
|
|
16365
|
-
`extern module ${exportedModule} ${JSON.stringify(
|
|
16648
|
+
import_node_path28.default.join(layout2.root, owner.path, "include/module.modulemap"),
|
|
16649
|
+
`extern module ${exportedModule} ${JSON.stringify(import_node_path28.default.join(layout2.root, modulemap))}
|
|
16366
16650
|
`,
|
|
16367
16651
|
{ allowExisting: true }
|
|
16368
16652
|
);
|
|
16369
16653
|
}
|
|
16370
16654
|
continue;
|
|
16371
16655
|
}
|
|
16372
|
-
const implementationHeaders =
|
|
16656
|
+
const implementationHeaders = import_node_path28.default.posix.join(
|
|
16373
16657
|
".build",
|
|
16374
16658
|
"peach-objc-implementations",
|
|
16375
16659
|
target.name
|
|
16376
16660
|
);
|
|
16377
|
-
const include =
|
|
16661
|
+
const include = import_node_path28.default.join(layout2.root, implementationHeaders);
|
|
16378
16662
|
stageTargetFile(
|
|
16379
16663
|
target.name,
|
|
16380
|
-
|
|
16664
|
+
import_node_path28.default.join(include, "module.modulemap"),
|
|
16381
16665
|
`module ${target.name}ImplementationDeclarations { export * }
|
|
16382
16666
|
`
|
|
16383
16667
|
);
|
|
@@ -16387,7 +16671,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16387
16671
|
includeDirectory: include,
|
|
16388
16672
|
importFlags,
|
|
16389
16673
|
swiftFlags: [
|
|
16390
|
-
...settings.bridgingHeader ? ["-import-objc-header",
|
|
16674
|
+
...settings.bridgingHeader ? ["-import-objc-header", import_node_path28.default.join(layout2.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
|
|
16391
16675
|
...importFlags.flatMap((flag) => ["-Xcc", flag])
|
|
16392
16676
|
],
|
|
16393
16677
|
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
@@ -16417,7 +16701,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16417
16701
|
}
|
|
16418
16702
|
native.set(target.name, {
|
|
16419
16703
|
path: target.path,
|
|
16420
|
-
includeDirectory:
|
|
16704
|
+
includeDirectory: import_node_path28.default.join(layout2.root, includes),
|
|
16421
16705
|
sources: units.map(([file]) => file.slice(prefix.length)),
|
|
16422
16706
|
lateSources: late.map(([file]) => file.slice(prefix.length)),
|
|
16423
16707
|
...late.length > 0 ? {
|
|
@@ -16431,7 +16715,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16431
16715
|
});
|
|
16432
16716
|
if (late.length > 0)
|
|
16433
16717
|
files.set(
|
|
16434
|
-
|
|
16718
|
+
import_node_path28.default.join(layout2.root, target.path, "PeachSwiftImplementation/module.modulemap"),
|
|
16435
16719
|
`module ${swiftTargetModuleName(`${target.name}SwiftImplementation`)} { export * }
|
|
16436
16720
|
`
|
|
16437
16721
|
);
|
|
@@ -16443,7 +16727,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16443
16727
|
([file]) => file.startsWith(includes) && /\.(?:h|hpp|hh|hxx)$/.test(file) && consumers.get(file).size === 0
|
|
16444
16728
|
);
|
|
16445
16729
|
files.set(
|
|
16446
|
-
|
|
16730
|
+
import_node_path28.default.join(layout2.root, includes, "module.modulemap"),
|
|
16447
16731
|
[
|
|
16448
16732
|
`module ${target.name} {`,
|
|
16449
16733
|
...roots.map(
|
|
@@ -16458,14 +16742,14 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16458
16742
|
for (const map of generatedModuleMaps)
|
|
16459
16743
|
if (files.has(map.published) || Object.hasOwn(
|
|
16460
16744
|
input.files,
|
|
16461
|
-
|
|
16745
|
+
import_node_path28.default.relative(layout2.root, map.published).split(import_node_path28.default.sep).join(import_node_path28.default.posix.sep)
|
|
16462
16746
|
))
|
|
16463
16747
|
writeBuildFile(
|
|
16464
16748
|
map.output,
|
|
16465
16749
|
`extern module ${map.module} ${JSON.stringify(map.published)}
|
|
16466
16750
|
`
|
|
16467
16751
|
);
|
|
16468
|
-
if (native.size > 0) (0,
|
|
16752
|
+
if (native.size > 0) (0, import_node_fs26.mkdirSync)(headerDirectory, { recursive: true });
|
|
16469
16753
|
const headerAliasFlags = Object.keys(input.headerAliases ?? {}).length > 0 ? ["-ivfsoverlay", headerSearch.files[0]] : [];
|
|
16470
16754
|
const nativeHeaderFlags = [...headerAliasFlags];
|
|
16471
16755
|
const nativeSwiftHeaderMaps = /* @__PURE__ */ new Map();
|
|
@@ -16487,10 +16771,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16487
16771
|
[...native.values()].flatMap((value) => value.late?.producers ?? [])
|
|
16488
16772
|
)) {
|
|
16489
16773
|
files.set(
|
|
16490
|
-
|
|
16774
|
+
import_node_path28.default.join(headerDirectory, name2, name2 + "-Swift.h"),
|
|
16491
16775
|
'#include "../' + name2 + '-Swift.h"\n'
|
|
16492
16776
|
);
|
|
16493
|
-
const modulemap =
|
|
16777
|
+
const modulemap = import_node_path28.default.join(
|
|
16494
16778
|
layout2.root,
|
|
16495
16779
|
".build",
|
|
16496
16780
|
"peach-objc-swift-headers",
|
|
@@ -16500,7 +16784,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16500
16784
|
const moduleName = swiftTargetModuleName(name2);
|
|
16501
16785
|
const originalMap = originalMaps.get(moduleName);
|
|
16502
16786
|
const stagedMap = sourceModuleMaps.get(moduleName);
|
|
16503
|
-
const originalPath = stagedMap?.path ?? (originalMap ?
|
|
16787
|
+
const originalPath = stagedMap?.path ?? (originalMap ? import_node_path28.default.join(layout2.root, originalMap) : void 0);
|
|
16504
16788
|
const originalContents = stagedMap?.contents ?? (originalMap && input.files[originalMap]);
|
|
16505
16789
|
const originalTokens = originalContents ? moduleMapTokens(originalContents) : [];
|
|
16506
16790
|
if (originalPath && originalTokens.some(
|
|
@@ -16514,29 +16798,29 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16514
16798
|
modulemap,
|
|
16515
16799
|
originalPath ? `extern module ${moduleName} ${JSON.stringify(originalPath)}
|
|
16516
16800
|
module ${moduleName}.Swift {
|
|
16517
|
-
header ${JSON.stringify(
|
|
16801
|
+
header ${JSON.stringify(import_node_path28.default.join(headerDirectory, name2 + "-Swift.h"))}
|
|
16518
16802
|
requires objc
|
|
16519
16803
|
}
|
|
16520
16804
|
` : swiftObjCModuleMap(
|
|
16521
16805
|
moduleName,
|
|
16522
|
-
(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) =>
|
|
16806
|
+
(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) => import_node_path28.default.join(layout2.root, header)),
|
|
16523
16807
|
submoduleImports.get(moduleName),
|
|
16524
|
-
|
|
16808
|
+
import_node_path28.default.join(headerDirectory, name2 + "-Swift.h")
|
|
16525
16809
|
)
|
|
16526
16810
|
);
|
|
16527
16811
|
nativeHeaderFlags.push("-fmodule-map-file=" + modulemap);
|
|
16528
16812
|
nativeSwiftHeaderMaps.set(name2, modulemap);
|
|
16529
16813
|
}
|
|
16530
|
-
const modulePlan = (0,
|
|
16814
|
+
const modulePlan = (0, import_node_crypto15.createHash)("sha256").update(
|
|
16531
16815
|
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
16532
16816
|
);
|
|
16533
16817
|
if (!distribution) {
|
|
16534
|
-
modulePlan.update((0,
|
|
16818
|
+
modulePlan.update((0, import_node_fs26.readFileSync)(import_node_path28.default.join(moduleRoot, "Package.swift")));
|
|
16535
16819
|
}
|
|
16536
16820
|
modulePlan.update(
|
|
16537
16821
|
Object.keys(input.files).filter((file) => file.endsWith(".swift")).sort().join("\n")
|
|
16538
16822
|
);
|
|
16539
|
-
const resourcePlan = (0,
|
|
16823
|
+
const resourcePlan = (0, import_node_crypto15.createHash)("sha256").update(
|
|
16540
16824
|
JSON.stringify(
|
|
16541
16825
|
resourceTargets.filter((target) => target.resources).map((target) => [
|
|
16542
16826
|
target.name,
|
|
@@ -16586,7 +16870,7 @@ module ${moduleName}.Swift {
|
|
|
16586
16870
|
(target) => {
|
|
16587
16871
|
const native2 = input.nativeTargets?.find(({ name: name2 }) => name2 === target.name);
|
|
16588
16872
|
if (native2) return native2.publicHeaders.map((file) => input.files[file] ?? "");
|
|
16589
|
-
const directory =
|
|
16873
|
+
const directory = import_node_path28.default.posix.join(
|
|
16590
16874
|
target.path,
|
|
16591
16875
|
target.publicHeadersPath ?? "include"
|
|
16592
16876
|
);
|
|
@@ -16622,7 +16906,7 @@ module ${moduleName}.Swift {
|
|
|
16622
16906
|
`;
|
|
16623
16907
|
} else if (mains.length === 0) {
|
|
16624
16908
|
const procedural = entries.filter(
|
|
16625
|
-
([file, source]) =>
|
|
16909
|
+
([file, source]) => import_node_path28.default.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
|
|
16626
16910
|
);
|
|
16627
16911
|
const wrapped = procedural.length === 1 ? wrapUIApplicationMainEntry(procedural[0][1]) : null;
|
|
16628
16912
|
if (wrapped) {
|
|
@@ -16643,7 +16927,7 @@ module ${moduleName}.Swift {
|
|
|
16643
16927
|
`mixed executable ${target.name} requires one typed Swift application entry`
|
|
16644
16928
|
);
|
|
16645
16929
|
files.set(
|
|
16646
|
-
|
|
16930
|
+
import_node_path28.default.join(layout2.root, nativeMains[0][0]),
|
|
16647
16931
|
neutralizedNativeMain(nativeMains[0][1])
|
|
16648
16932
|
);
|
|
16649
16933
|
nativeEntry = true;
|
|
@@ -16655,9 +16939,9 @@ module ${moduleName}.Swift {
|
|
|
16655
16939
|
}
|
|
16656
16940
|
if (!nativeEntry) {
|
|
16657
16941
|
compiled.set(entryFile, entrySource);
|
|
16658
|
-
if (
|
|
16659
|
-
const libraryEntry =
|
|
16660
|
-
|
|
16942
|
+
if (import_node_path28.default.basename(entryFile) === "main.swift") {
|
|
16943
|
+
const libraryEntry = import_node_path28.default.posix.join(
|
|
16944
|
+
import_node_path28.default.posix.dirname(entryFile),
|
|
16661
16945
|
"PeachApplicationEntry.generated.swift"
|
|
16662
16946
|
);
|
|
16663
16947
|
if (Object.hasOwn(input.files, libraryEntry))
|
|
@@ -16681,7 +16965,7 @@ module ${moduleName}.Swift {
|
|
|
16681
16965
|
exclude: []
|
|
16682
16966
|
});
|
|
16683
16967
|
files.set(
|
|
16684
|
-
|
|
16968
|
+
import_node_path28.default.join(layout2.root, `PeachApplication/${name2}/Entry.swift`),
|
|
16685
16969
|
!nativeEntry ? `import ${swiftTargetModuleName(target.name)}
|
|
16686
16970
|
@main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }
|
|
16687
16971
|
` : `import ${swiftTargetModuleName(target.name)}
|
|
@@ -16713,7 +16997,7 @@ module ${moduleName}.Swift {
|
|
|
16713
16997
|
);
|
|
16714
16998
|
if (nativeFlags) {
|
|
16715
16999
|
const toolchainBin = nativeToolchain();
|
|
16716
|
-
const headers =
|
|
17000
|
+
const headers = import_node_path28.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
|
|
16717
17001
|
const dependencies2 = swiftTargetDependencies(input.files, targets);
|
|
16718
17002
|
const reachesNative = (name2, seen = /* @__PURE__ */ new Set()) => {
|
|
16719
17003
|
if (native.has(name2)) return true;
|
|
@@ -16758,10 +17042,10 @@ module ${moduleName}.Swift {
|
|
|
16758
17042
|
if (targets.length === 0 && !prebuilt) {
|
|
16759
17043
|
for (const [file, contents2] of Object.entries(input.files)) {
|
|
16760
17044
|
if (file === "Package.swift") continue;
|
|
16761
|
-
files.set(
|
|
17045
|
+
files.set(import_node_path28.default.join(layout2.sources, file), compiled.get(file) ?? contents2);
|
|
16762
17046
|
}
|
|
16763
|
-
let manifest2 = (0,
|
|
16764
|
-
|
|
17047
|
+
let manifest2 = (0, import_node_fs26.readFileSync)(
|
|
17048
|
+
import_node_path28.default.join(moduleRoot, "scripts/contrast-app-Package.swift"),
|
|
16765
17049
|
"utf8"
|
|
16766
17050
|
).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
|
|
16767
17051
|
const reactor = ` ${REACTOR_FLAG}`;
|
|
@@ -16808,35 +17092,35 @@ module ${moduleName}.Swift {
|
|
|
16808
17092
|
[anchor, ...games.map((name2) => `${gameProduct(name2)},`)].join("\n ")
|
|
16809
17093
|
);
|
|
16810
17094
|
}
|
|
16811
|
-
files.set(
|
|
17095
|
+
files.set(import_node_path28.default.join(layout2.root, "Package.swift"), manifest2 + moduleFiles);
|
|
16812
17096
|
} else {
|
|
16813
17097
|
const base = layout2.multi ? layout2.root : layout2.sources;
|
|
16814
17098
|
const libraries = /* @__PURE__ */ new Map();
|
|
16815
|
-
const binaryModules =
|
|
17099
|
+
const binaryModules = import_node_path28.default.join(layout2.root, ".peach-binary-modules");
|
|
16816
17100
|
for (const [name2, data] of Object.entries(input.binaryModules ?? {})) {
|
|
16817
17101
|
if (!/^[A-Za-z_]\w*$/.test(name2) || !input.libraries?.[name2])
|
|
16818
17102
|
throw new Error(`invalid native Swift module ${name2}: its library is required`);
|
|
16819
17103
|
files.set(
|
|
16820
|
-
|
|
17104
|
+
import_node_path28.default.join(binaryModules, `${name2}.swiftmodule`),
|
|
16821
17105
|
Buffer.from(data, "base64")
|
|
16822
17106
|
);
|
|
16823
17107
|
}
|
|
16824
17108
|
for (const [target, data] of Object.entries(input.libraries ?? {})) {
|
|
16825
17109
|
const bytes = Buffer.from(data, "base64");
|
|
16826
|
-
const digest = (0,
|
|
16827
|
-
const file =
|
|
17110
|
+
const digest = (0, import_node_crypto15.createHash)("sha256").update(bytes).digest("hex");
|
|
17111
|
+
const file = import_node_path28.default.join(layout2.root, ".peach-libraries", `lib${target}-${digest}.a`);
|
|
16828
17112
|
files.set(file, bytes);
|
|
16829
17113
|
libraries.set(target, file);
|
|
16830
17114
|
}
|
|
16831
17115
|
for (const [file, contents2] of Object.entries(input.files)) {
|
|
16832
17116
|
if (file === "Package.swift") continue;
|
|
16833
|
-
const destination =
|
|
17117
|
+
const destination = import_node_path28.default.join(base, libraryEntryFiles.get(file) ?? file);
|
|
16834
17118
|
const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
|
|
16835
17119
|
const localInterface = interfaceModule && swiftTargets.has(interfaceModule) ? `#include ${JSON.stringify(
|
|
16836
|
-
|
|
16837
|
-
|
|
16838
|
-
|
|
16839
|
-
).split(
|
|
17120
|
+
import_node_path28.default.relative(
|
|
17121
|
+
import_node_path28.default.dirname(destination),
|
|
17122
|
+
import_node_path28.default.join(headerDirectory, `${interfaceModule}-Swift.h`)
|
|
17123
|
+
).split(import_node_path28.default.sep).join("/")
|
|
16840
17124
|
)}
|
|
16841
17125
|
` : void 0;
|
|
16842
17126
|
files.set(
|
|
@@ -16844,10 +17128,10 @@ module ${moduleName}.Swift {
|
|
|
16844
17128
|
localInterface ?? compiled.get(file) ?? files.get(destination) ?? (interfaceModule && moduleInterface(interfaceModule)?.header) ?? contents2
|
|
16845
17129
|
);
|
|
16846
17130
|
}
|
|
16847
|
-
const
|
|
17131
|
+
const manifestTargets2 = targets.length > 0 ? targets : [
|
|
16848
17132
|
{
|
|
16849
17133
|
name: "App",
|
|
16850
|
-
path:
|
|
17134
|
+
path: import_node_path28.default.relative(layout2.root, layout2.sources).split(import_node_path28.default.sep).join("/"),
|
|
16851
17135
|
executable: true,
|
|
16852
17136
|
languageMode: 5,
|
|
16853
17137
|
mainActorIsolation: false,
|
|
@@ -16857,11 +17141,11 @@ module ${moduleName}.Swift {
|
|
|
16857
17141
|
const reachesFrameworks = !distribution || swiftImportedModules.has("Foundation") || Object.entries(input.files).some(
|
|
16858
17142
|
([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
|
|
16859
17143
|
) || [...importedModules].some(
|
|
16860
|
-
(name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2) && !(clangImportedModules.has(name2) && !swiftImportedModules.has(name2) && (0,
|
|
16861
|
-
|
|
17144
|
+
(name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2) && !(clangImportedModules.has(name2) && !swiftImportedModules.has(name2) && (0, import_node_fs26.existsSync)(
|
|
17145
|
+
import_node_path28.default.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name2)
|
|
16862
17146
|
))
|
|
16863
17147
|
);
|
|
16864
|
-
const frameworkLink = prebuilt ?
|
|
17148
|
+
const frameworkLink = prebuilt ? import_node_path28.default.join(layout2.root, ".peach-framework-objects.rsp") : void 0;
|
|
16865
17149
|
if (prebuilt && frameworkLink) {
|
|
16866
17150
|
const quote = (object3) => `"${object3.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
16867
17151
|
files.set(
|
|
@@ -16877,10 +17161,10 @@ module ${moduleName}.Swift {
|
|
|
16877
17161
|
}
|
|
16878
17162
|
const moduleSiblings = swiftTargetDependencies(
|
|
16879
17163
|
input.files,
|
|
16880
|
-
layout2.multi ?
|
|
17164
|
+
layout2.multi ? manifestTargets2 : manifestTargets2.map((target) => ({ ...target, path: "." }))
|
|
16881
17165
|
);
|
|
16882
|
-
if (namesLibxml2(input) && !
|
|
16883
|
-
const executable =
|
|
17166
|
+
if (namesLibxml2(input) && !manifestTargets2.some((target) => target.name === "libxml2")) {
|
|
17167
|
+
const executable = manifestTargets2.find((target) => target.executable);
|
|
16884
17168
|
if (executable) {
|
|
16885
17169
|
const reached = moduleSiblings.get(executable.name) ?? [];
|
|
16886
17170
|
if (!reached.includes("libxml2"))
|
|
@@ -16888,15 +17172,15 @@ module ${moduleName}.Swift {
|
|
|
16888
17172
|
}
|
|
16889
17173
|
}
|
|
16890
17174
|
files.set(
|
|
16891
|
-
|
|
17175
|
+
import_node_path28.default.join(layout2.root, "Package.swift"),
|
|
16892
17176
|
emitSwiftPackageManifest({
|
|
16893
17177
|
root: layout2.root,
|
|
16894
17178
|
files,
|
|
16895
|
-
targets:
|
|
17179
|
+
targets: manifestTargets2.map((target) => ({
|
|
16896
17180
|
...target,
|
|
16897
17181
|
sources: target.sources?.map((source) => {
|
|
16898
|
-
const entry = libraryEntryFiles.get(
|
|
16899
|
-
return entry ?
|
|
17182
|
+
const entry = libraryEntryFiles.get(import_node_path28.default.posix.join(target.path, source));
|
|
17183
|
+
return entry ? import_node_path28.default.posix.relative(target.path, entry) : source;
|
|
16900
17184
|
})
|
|
16901
17185
|
})),
|
|
16902
17186
|
packages,
|
|
@@ -16930,7 +17214,7 @@ module ${moduleName}.Swift {
|
|
|
16930
17214
|
),
|
|
16931
17215
|
...reachesFrameworks ? {
|
|
16932
17216
|
distributionLink: {
|
|
16933
|
-
path:
|
|
17217
|
+
path: import_node_path28.default.join(layout2.root, ".peach-distribution-objects.rsp"),
|
|
16934
17218
|
files
|
|
16935
17219
|
}
|
|
16936
17220
|
} : {},
|
|
@@ -16951,14 +17235,14 @@ module ${moduleName}.Swift {
|
|
|
16951
17235
|
for (const [file, bytes] of Object.entries(input.packageFiles ?? {})) {
|
|
16952
17236
|
const contents2 = Buffer.from(bytes, "base64");
|
|
16953
17237
|
files.set(
|
|
16954
|
-
|
|
17238
|
+
import_node_path28.default.join(layout2.root, file),
|
|
16955
17239
|
file.endsWith(".swift") && !/(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file) ? withPreconcurrencyFoundationModules(
|
|
16956
17240
|
swiftPackageSourceAsIOS(contents2.toString("utf8"))
|
|
16957
17241
|
) : contents2
|
|
16958
17242
|
);
|
|
16959
17243
|
}
|
|
16960
17244
|
for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
|
|
16961
|
-
const destination =
|
|
17245
|
+
const destination = import_node_path28.default.join(layout2.root, file);
|
|
16962
17246
|
if (files.has(destination)) continue;
|
|
16963
17247
|
files.set(destination, Buffer.from(bytes, "base64"));
|
|
16964
17248
|
}
|
|
@@ -16967,13 +17251,13 @@ module ${moduleName}.Swift {
|
|
|
16967
17251
|
const nativeToolsetFlags = [
|
|
16968
17252
|
...headerAliasFlags,
|
|
16969
17253
|
...native.size > 0 ? [
|
|
16970
|
-
"-fmodule-map-file=" +
|
|
17254
|
+
"-fmodule-map-file=" + import_node_path28.default.join(
|
|
16971
17255
|
swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
|
|
16972
17256
|
"darwin/wasm/include/module.modulemap"
|
|
16973
17257
|
)
|
|
16974
17258
|
] : []
|
|
16975
17259
|
];
|
|
16976
|
-
const clangWrapper2 =
|
|
17260
|
+
const clangWrapper2 = import_node_path28.default.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
|
|
16977
17261
|
files.set(
|
|
16978
17262
|
clangWrapper2,
|
|
16979
17263
|
[
|
|
@@ -17014,21 +17298,21 @@ module ${moduleName}.Swift {
|
|
|
17014
17298
|
" done",
|
|
17015
17299
|
"fi",
|
|
17016
17300
|
'if [ -n "$name" ] && [ -z "$explicit" ]; then',
|
|
17017
|
-
` exec '${
|
|
17301
|
+
` exec '${import_node_path28.default.join(nativeToolchain(), "clang")}' "-fmodule-name=$name" "$@"`,
|
|
17018
17302
|
"fi",
|
|
17019
|
-
`exec '${
|
|
17303
|
+
`exec '${import_node_path28.default.join(nativeToolchain(), "clang")}' "$@"`,
|
|
17020
17304
|
""
|
|
17021
17305
|
].join("\n")
|
|
17022
17306
|
);
|
|
17023
17307
|
files.set(
|
|
17024
|
-
|
|
17308
|
+
import_node_path28.default.join(layout2.root, ".peach-target-toolset.json"),
|
|
17025
17309
|
JSON.stringify({
|
|
17026
17310
|
schemaVersion: "1.0",
|
|
17027
17311
|
cCompiler: {
|
|
17028
17312
|
extraCLIOptions: [
|
|
17029
17313
|
...nativeToolsetFlags,
|
|
17030
17314
|
"-fmodules",
|
|
17031
|
-
`-fmodules-cache-path=${
|
|
17315
|
+
`-fmodules-cache-path=${import_node_path28.default.join(layout2.root, ".build", "ModuleCache")}`
|
|
17032
17316
|
]
|
|
17033
17317
|
},
|
|
17034
17318
|
...nativeToolsetFlags.length > 0 ? { cxxCompiler: { extraCLIOptions: nativeToolsetFlags } } : {},
|
|
@@ -17038,12 +17322,12 @@ module ${moduleName}.Swift {
|
|
|
17038
17322
|
distribution || prebuilt ? "-Isystem" : "-I",
|
|
17039
17323
|
distribution ? providedModulesPath(
|
|
17040
17324
|
layout2.root,
|
|
17041
|
-
|
|
17325
|
+
import_node_path28.default.join(moduleRoot, "modules"),
|
|
17042
17326
|
moduleExcludes
|
|
17043
|
-
) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) :
|
|
17327
|
+
) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) : import_node_path28.default.join(layout2.root, ".build", WASM_TRIPLE, "release", "Modules"),
|
|
17044
17328
|
...distribution ? distributionClangModuleOptions(
|
|
17045
17329
|
layout2.root,
|
|
17046
|
-
|
|
17330
|
+
import_node_path28.default.join(moduleRoot, "modules")
|
|
17047
17331
|
) : [],
|
|
17048
17332
|
...prebuilt?.moduleMaps.flatMap((map) => [
|
|
17049
17333
|
"-Xcc",
|
|
@@ -17073,9 +17357,9 @@ module ${moduleName}.Swift {
|
|
|
17073
17357
|
throw new Error(
|
|
17074
17358
|
`swift resource target ${target.name} has no matching bundle assignment`
|
|
17075
17359
|
);
|
|
17076
|
-
const directory = layout2.multi ?
|
|
17360
|
+
const directory = layout2.multi ? import_node_path28.default.join(layout2.root, target.path) : layout2.sources;
|
|
17077
17361
|
files.set(
|
|
17078
|
-
|
|
17362
|
+
import_node_path28.default.join(directory, "ResourceBundleAccessor.generated.swift"),
|
|
17079
17363
|
[
|
|
17080
17364
|
"import Foundation",
|
|
17081
17365
|
"",
|
|
@@ -17092,7 +17376,7 @@ module ${moduleName}.Swift {
|
|
|
17092
17376
|
}
|
|
17093
17377
|
for (const [file, source] of compiled)
|
|
17094
17378
|
if (!Object.hasOwn(input.files, file))
|
|
17095
|
-
files.set(
|
|
17379
|
+
files.set(import_node_path28.default.join(layout2.multi ? layout2.root : layout2.sources, file), source);
|
|
17096
17380
|
const producers = [
|
|
17097
17381
|
.../* @__PURE__ */ new Set([...[...native.values()].flatMap((value) => value.late?.producers ?? [])])
|
|
17098
17382
|
];
|
|
@@ -17105,14 +17389,15 @@ module ${moduleName}.Swift {
|
|
|
17105
17389
|
generatedOwners.set(group.name, owner);
|
|
17106
17390
|
}
|
|
17107
17391
|
}
|
|
17108
|
-
const manifestPath =
|
|
17392
|
+
const manifestPath = import_node_path28.default.join(layout2.root, "Package.swift");
|
|
17109
17393
|
let manifest = files.get(manifestPath).toString();
|
|
17394
|
+
const manifestTargets = swiftManifestTargets(manifest, [], (file) => {
|
|
17395
|
+
const contents2 = files.get(file);
|
|
17396
|
+
if (contents2 === void 0) throw new Error(`missing compiler arguments ${file}`);
|
|
17397
|
+
return contents2.toString();
|
|
17398
|
+
});
|
|
17110
17399
|
const dependencies = new Map(
|
|
17111
|
-
|
|
17112
|
-
const contents2 = files.get(file);
|
|
17113
|
-
if (contents2 === void 0) throw new Error(`missing compiler arguments ${file}`);
|
|
17114
|
-
return contents2.toString();
|
|
17115
|
-
}).map((target) => [
|
|
17400
|
+
manifestTargets.map((target) => [
|
|
17116
17401
|
target.name,
|
|
17117
17402
|
(target.dependencies ?? []).flatMap(
|
|
17118
17403
|
(dependency) => dependency.kind === "target" ? [dependency.name] : []
|
|
@@ -17120,6 +17405,62 @@ module ${moduleName}.Swift {
|
|
|
17120
17405
|
])
|
|
17121
17406
|
);
|
|
17122
17407
|
const producerSet = /* @__PURE__ */ new Set([...Object.keys(nativeHeaderDeclarations), ...producers]);
|
|
17408
|
+
let headerCompiler = allowHeaderCompiler && packages.size === 0 && producerSet.size > 0;
|
|
17409
|
+
if (headerCompiler) {
|
|
17410
|
+
const clang = new Set(
|
|
17411
|
+
manifestTargets.filter(
|
|
17412
|
+
(target) => target.systemLibrary || !swiftTargets.has(target.name) && native.has(target.name)
|
|
17413
|
+
).map(({ name: name2 }) => name2)
|
|
17414
|
+
);
|
|
17415
|
+
const headers = swiftHeaderDependencies(
|
|
17416
|
+
layout2.root,
|
|
17417
|
+
files,
|
|
17418
|
+
manifestTargets,
|
|
17419
|
+
nativeTargets,
|
|
17420
|
+
producerSet,
|
|
17421
|
+
input.headerAliases ?? {}
|
|
17422
|
+
);
|
|
17423
|
+
const nativeEdges = /* @__PURE__ */ new Map();
|
|
17424
|
+
const dependsOn = (from, to, seen = /* @__PURE__ */ new Set()) => {
|
|
17425
|
+
if (from === to) return true;
|
|
17426
|
+
if (seen.has(from)) return false;
|
|
17427
|
+
seen.add(from);
|
|
17428
|
+
return [...dependencies.get(from) ?? [], ...nativeEdges.get(from) ?? []].some(
|
|
17429
|
+
(dependency) => dependsOn(dependency, to, seen)
|
|
17430
|
+
);
|
|
17431
|
+
};
|
|
17432
|
+
for (const target of manifestTargets) {
|
|
17433
|
+
if (target.systemLibrary) continue;
|
|
17434
|
+
const required = new Set(headers.get(target.name));
|
|
17435
|
+
const visited = /* @__PURE__ */ new Set();
|
|
17436
|
+
const imports = (name2) => {
|
|
17437
|
+
if (!clang.has(name2) || visited.has(name2)) return;
|
|
17438
|
+
visited.add(name2);
|
|
17439
|
+
for (const header of headers.get(name2) ?? []) required.add(header);
|
|
17440
|
+
for (const dependency of dependencies.get(name2) ?? []) imports(dependency);
|
|
17441
|
+
};
|
|
17442
|
+
for (const dependency of dependencies.get(target.name) ?? []) imports(dependency);
|
|
17443
|
+
for (const producer of required) {
|
|
17444
|
+
if (dependsOn(target.name, producer)) continue;
|
|
17445
|
+
if (dependsOn(producer, target.name)) {
|
|
17446
|
+
headerCompiler = false;
|
|
17447
|
+
break;
|
|
17448
|
+
}
|
|
17449
|
+
const edges = nativeEdges.get(target.name) ?? [];
|
|
17450
|
+
edges.push(producer);
|
|
17451
|
+
nativeEdges.set(target.name, edges);
|
|
17452
|
+
}
|
|
17453
|
+
if (!headerCompiler) break;
|
|
17454
|
+
}
|
|
17455
|
+
if (headerCompiler)
|
|
17456
|
+
for (const [target, producers2] of nativeEdges) {
|
|
17457
|
+
const additions = producers2.map((producer) => `.target(name: ${JSON.stringify(producer)})`).join(", ");
|
|
17458
|
+
manifest += `
|
|
17459
|
+
package.targets.first(where: { $0.name == ${JSON.stringify(target)} })!.dependencies += [${additions}]
|
|
17460
|
+
`;
|
|
17461
|
+
dependencies.get(target).push(...producers2);
|
|
17462
|
+
}
|
|
17463
|
+
}
|
|
17123
17464
|
const depths = /* @__PURE__ */ new Map();
|
|
17124
17465
|
const orderedProducers = [];
|
|
17125
17466
|
const depth = (name2) => {
|
|
@@ -17148,13 +17489,18 @@ module ${moduleName}.Swift {
|
|
|
17148
17489
|
if (members.length === 1) return members[0];
|
|
17149
17490
|
if (dependencies.has(name2))
|
|
17150
17491
|
throw new Error(`generated build target collides with ${name2}`);
|
|
17151
|
-
files.set(
|
|
17492
|
+
files.set(import_node_path28.default.join(layout2.root, name2, "Products.swift"), "");
|
|
17152
17493
|
manifest += `
|
|
17153
17494
|
package.targets += [.target(name: ${JSON.stringify(name2)}, dependencies: ${JSON.stringify(members)}, path: ${JSON.stringify(name2)}, swiftSettings: [.swiftLanguageMode(.v5)])]
|
|
17154
17495
|
`;
|
|
17155
17496
|
return name2;
|
|
17156
17497
|
};
|
|
17157
|
-
const headerBuilds =
|
|
17498
|
+
const headerBuilds = headerCompiler ? [
|
|
17499
|
+
{
|
|
17500
|
+
target: buildProduct(SWIFT_HEADER_PRODUCTS_TARGET, orderedProducers),
|
|
17501
|
+
producers: orderedProducers
|
|
17502
|
+
}
|
|
17503
|
+
] : [...stages].sort(([left], [right]) => left - right).map(([level, producers2]) => ({
|
|
17158
17504
|
target: buildProduct(`${SWIFT_HEADER_PRODUCTS_TARGET}${level}`, producers2),
|
|
17159
17505
|
producers: producers2
|
|
17160
17506
|
}));
|
|
@@ -17172,16 +17518,17 @@ package.targets += [.target(name: ${JSON.stringify(name2)}, dependencies: ${JSON
|
|
|
17172
17518
|
syncSwiftTree(layout2.root, files);
|
|
17173
17519
|
if (layout2.multi)
|
|
17174
17520
|
for (const target of targets)
|
|
17175
|
-
(0,
|
|
17176
|
-
const clangWrapper =
|
|
17177
|
-
if (files.has(clangWrapper)) (0,
|
|
17521
|
+
(0, import_node_fs26.mkdirSync)(import_node_path28.default.join(layout2.root, target.path), { recursive: true });
|
|
17522
|
+
const clangWrapper = import_node_path28.default.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
|
|
17523
|
+
if (files.has(clangWrapper)) (0, import_node_fs26.chmodSync)(clangWrapper, 493);
|
|
17178
17524
|
return {
|
|
17179
17525
|
headerBuilds,
|
|
17180
17526
|
nativeHeaderDeclarations,
|
|
17181
17527
|
nativeProductTarget,
|
|
17182
17528
|
targetFailures,
|
|
17183
17529
|
generatedOwners,
|
|
17184
|
-
targetToolset
|
|
17530
|
+
targetToolset,
|
|
17531
|
+
headerCompiler
|
|
17185
17532
|
};
|
|
17186
17533
|
}
|
|
17187
17534
|
function streamText(value) {
|
|
@@ -17201,21 +17548,21 @@ function outputOf(error) {
|
|
|
17201
17548
|
return error instanceof Error ? error.message : String(error);
|
|
17202
17549
|
}
|
|
17203
17550
|
function builtArtifact(layout2) {
|
|
17204
|
-
const binDir =
|
|
17205
|
-
const manifest = (0,
|
|
17551
|
+
const binDir = import_node_path28.default.join(layout2.root, ".build", WASM_TRIPLE, "release");
|
|
17552
|
+
const manifest = (0, import_node_fs26.readFileSync)(import_node_path28.default.join(layout2.root, "Package.swift"), "utf8");
|
|
17206
17553
|
const executable = swiftManifestTargets(
|
|
17207
17554
|
manifest,
|
|
17208
17555
|
[],
|
|
17209
|
-
(file) => (0,
|
|
17556
|
+
(file) => (0, import_node_fs26.readFileSync)(file, "utf8")
|
|
17210
17557
|
).find((target) => target.executable);
|
|
17211
17558
|
if (executable === void 0) {
|
|
17212
17559
|
throw new Error("swift-compile: the written manifest names no executable target");
|
|
17213
17560
|
}
|
|
17214
|
-
return
|
|
17561
|
+
return import_node_path28.default.join(binDir, `${executable.name}.wasm`);
|
|
17215
17562
|
}
|
|
17216
17563
|
function projectDiagnostic(output, layout2, files) {
|
|
17217
17564
|
const base = layout2.multi ? layout2.root : layout2.sources;
|
|
17218
|
-
const prefix = `${base}${
|
|
17565
|
+
const prefix = `${base}${import_node_path28.default.sep}`;
|
|
17219
17566
|
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();
|
|
17220
17567
|
}
|
|
17221
17568
|
var ROOT_LOCKS = Symbol.for("peachsim.swiftCompile.rootLocks");
|
|
@@ -17251,13 +17598,13 @@ function serialize(root, work, signal) {
|
|
|
17251
17598
|
function readCompiledArtifact(directory, hash) {
|
|
17252
17599
|
try {
|
|
17253
17600
|
const receipt = JSON.parse(
|
|
17254
|
-
(0,
|
|
17601
|
+
(0, import_node_fs26.readFileSync)(import_node_path28.default.join(directory, "artifact.json"), "utf8")
|
|
17255
17602
|
);
|
|
17256
17603
|
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")
|
|
17257
17604
|
return null;
|
|
17258
|
-
const bytes = (0,
|
|
17259
|
-
const gzip2 = (0,
|
|
17260
|
-
if ((0,
|
|
17605
|
+
const bytes = (0, import_node_fs26.readFileSync)(import_node_path28.default.join(directory, "app.wasm"));
|
|
17606
|
+
const gzip2 = (0, import_node_fs26.readFileSync)(import_node_path28.default.join(directory, "icu.gz"));
|
|
17607
|
+
if ((0, import_node_crypto15.createHash)("sha256").update(bytes).digest("hex") !== receipt.wasm || (0, import_node_crypto15.createHash)("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length <= 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
|
|
17261
17608
|
return null;
|
|
17262
17609
|
return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 } };
|
|
17263
17610
|
} catch (error) {
|
|
@@ -17267,25 +17614,25 @@ function readCompiledArtifact(directory, hash) {
|
|
|
17267
17614
|
}
|
|
17268
17615
|
}
|
|
17269
17616
|
function saveCompiledArtifact(root, artifact) {
|
|
17270
|
-
const directory =
|
|
17271
|
-
(0,
|
|
17272
|
-
const pending = (0,
|
|
17617
|
+
const directory = import_node_path28.default.join(root, "artifact");
|
|
17618
|
+
(0, import_node_fs26.mkdirSync)(directory, { recursive: true });
|
|
17619
|
+
const pending = (0, import_node_fs26.mkdtempSync)(import_node_path28.default.join(root, ".artifact-"));
|
|
17273
17620
|
try {
|
|
17274
|
-
(0,
|
|
17275
|
-
(0,
|
|
17276
|
-
(0,
|
|
17277
|
-
|
|
17621
|
+
(0, import_node_fs26.writeFileSync)(import_node_path28.default.join(pending, "app.wasm"), artifact.bytes);
|
|
17622
|
+
(0, import_node_fs26.writeFileSync)(import_node_path28.default.join(pending, "icu.gz"), artifact.icu.gzip);
|
|
17623
|
+
(0, import_node_fs26.writeFileSync)(
|
|
17624
|
+
import_node_path28.default.join(pending, "artifact.json"),
|
|
17278
17625
|
JSON.stringify({
|
|
17279
17626
|
hash: artifact.hash,
|
|
17280
|
-
wasm: (0,
|
|
17627
|
+
wasm: (0, import_node_crypto15.createHash)("sha256").update(artifact.bytes).digest("hex"),
|
|
17281
17628
|
icu: artifact.icu.sha256
|
|
17282
17629
|
})
|
|
17283
17630
|
);
|
|
17284
17631
|
for (const file of ["app.wasm", "icu.gz", "artifact.json"]) {
|
|
17285
|
-
(0,
|
|
17632
|
+
(0, import_node_fs26.renameSync)(import_node_path28.default.join(pending, file), import_node_path28.default.join(directory, file));
|
|
17286
17633
|
}
|
|
17287
17634
|
} finally {
|
|
17288
|
-
(0,
|
|
17635
|
+
(0, import_node_fs26.rmSync)(pending, { recursive: true, force: true });
|
|
17289
17636
|
}
|
|
17290
17637
|
}
|
|
17291
17638
|
var SHARED_ARTIFACT_BUDGET_BYTES = 4 * 1024 ** 3;
|
|
@@ -17296,29 +17643,29 @@ function vanished(error) {
|
|
|
17296
17643
|
}
|
|
17297
17644
|
function renewSharedArtifact(sharedRoot) {
|
|
17298
17645
|
try {
|
|
17299
|
-
(0,
|
|
17646
|
+
(0, import_node_fs26.utimesSync)(sharedRoot, /* @__PURE__ */ new Date(), /* @__PURE__ */ new Date());
|
|
17300
17647
|
} catch (error) {
|
|
17301
17648
|
if (!vanished(error)) throw error;
|
|
17302
17649
|
}
|
|
17303
17650
|
}
|
|
17304
17651
|
function pruneSharedArtifacts(parent, keep) {
|
|
17305
17652
|
const entries = [];
|
|
17306
|
-
for (const name2 of (0,
|
|
17307
|
-
const directory =
|
|
17653
|
+
for (const name2 of (0, import_node_fs26.readdirSync)(parent)) {
|
|
17654
|
+
const directory = import_node_path28.default.join(parent, name2);
|
|
17308
17655
|
if (name2.startsWith(RETIRED_PREFIX)) {
|
|
17309
17656
|
reapRetiredCacheDirectory(parent, name2);
|
|
17310
17657
|
continue;
|
|
17311
17658
|
}
|
|
17312
17659
|
try {
|
|
17313
17660
|
let bytes = 0;
|
|
17314
|
-
for (const file of (0,
|
|
17661
|
+
for (const file of (0, import_node_fs26.readdirSync)(import_node_path28.default.join(directory, "artifact"))) {
|
|
17315
17662
|
try {
|
|
17316
|
-
bytes += (0,
|
|
17663
|
+
bytes += (0, import_node_fs26.statSync)(import_node_path28.default.join(directory, "artifact", file)).size;
|
|
17317
17664
|
} catch (error) {
|
|
17318
17665
|
if (!vanished(error)) throw error;
|
|
17319
17666
|
}
|
|
17320
17667
|
}
|
|
17321
|
-
entries.push({ directory, used: (0,
|
|
17668
|
+
entries.push({ directory, used: (0, import_node_fs26.statSync)(directory).mtimeMs, bytes });
|
|
17322
17669
|
} catch (error) {
|
|
17323
17670
|
if (!vanished(error)) throw error;
|
|
17324
17671
|
}
|
|
@@ -17328,13 +17675,13 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
17328
17675
|
if (total <= SHARED_ARTIFACT_BUDGET_BYTES) break;
|
|
17329
17676
|
if (entry.directory === keep || Date.now() - entry.used < SHARED_ARTIFACT_GRACE_MS)
|
|
17330
17677
|
continue;
|
|
17331
|
-
const retired =
|
|
17678
|
+
const retired = import_node_path28.default.join(
|
|
17332
17679
|
parent,
|
|
17333
|
-
`${RETIRED_PREFIX}${process.pid}-${
|
|
17680
|
+
`${RETIRED_PREFIX}${process.pid}-${import_node_path28.default.basename(entry.directory)}`
|
|
17334
17681
|
);
|
|
17335
17682
|
try {
|
|
17336
|
-
if ((0,
|
|
17337
|
-
(0,
|
|
17683
|
+
if ((0, import_node_fs26.statSync)(entry.directory).mtimeMs !== entry.used) continue;
|
|
17684
|
+
(0, import_node_fs26.renameSync)(entry.directory, retired);
|
|
17338
17685
|
} catch (error) {
|
|
17339
17686
|
if (vanished(error)) continue;
|
|
17340
17687
|
throw error;
|
|
@@ -17346,7 +17693,7 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
17346
17693
|
function saveSharedArtifact(sharedRoot, artifact) {
|
|
17347
17694
|
saveCompiledArtifact(sharedRoot, artifact);
|
|
17348
17695
|
renewSharedArtifact(sharedRoot);
|
|
17349
|
-
pruneSharedArtifacts(
|
|
17696
|
+
pruneSharedArtifacts(import_node_path28.default.dirname(sharedRoot), sharedRoot);
|
|
17350
17697
|
}
|
|
17351
17698
|
var retainedArtifacts = /* @__PURE__ */ new Map();
|
|
17352
17699
|
function retain(root, artifact) {
|
|
@@ -17374,7 +17721,7 @@ function frameworkLibraryTargets(manifest) {
|
|
|
17374
17721
|
}
|
|
17375
17722
|
function linkedFrameworkTargets(moduleRoot, input) {
|
|
17376
17723
|
const libraries = frameworkLibraryTargets(
|
|
17377
|
-
(0,
|
|
17724
|
+
(0, import_node_fs26.readFileSync)(import_node_path28.default.join(moduleRoot, "Package.swift"), "utf8")
|
|
17378
17725
|
);
|
|
17379
17726
|
const targets = compileTargets(input);
|
|
17380
17727
|
const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
|
|
@@ -17397,7 +17744,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
17397
17744
|
for (const name2 of [...siblings.values()].flat())
|
|
17398
17745
|
if (libraries.has(name2) && !planning.some((target) => target.name === name2))
|
|
17399
17746
|
reach(name2);
|
|
17400
|
-
const manifest = (0,
|
|
17747
|
+
const manifest = (0, import_node_fs26.readFileSync)(import_node_path28.default.join(moduleRoot, "Package.swift"), "utf8");
|
|
17401
17748
|
const targetDependencies = /* @__PURE__ */ new Map();
|
|
17402
17749
|
for (const match of manifest.matchAll(
|
|
17403
17750
|
/\.target\(\s*name:\s*"([^"]+)"\s*,\s*dependencies:\s*\[([^\]]*)\]/g
|
|
@@ -17414,12 +17761,12 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
17414
17761
|
};
|
|
17415
17762
|
for (const name2 of reached)
|
|
17416
17763
|
for (const member of libraries.get(name2) ?? []) build(member);
|
|
17417
|
-
const overlays =
|
|
17418
|
-
for (const directory of (0,
|
|
17419
|
-
const companion =
|
|
17764
|
+
const overlays = import_node_path28.default.join(moduleRoot, "cross-import-overlays");
|
|
17765
|
+
for (const directory of (0, import_node_fs26.readdirSync)(overlays)) {
|
|
17766
|
+
const companion = import_node_path28.default.basename(directory, ".swiftcrossimport");
|
|
17420
17767
|
if (!built.has(companion)) continue;
|
|
17421
|
-
const declaration =
|
|
17422
|
-
for (const match of (0,
|
|
17768
|
+
const declaration = import_node_path28.default.join(overlays, directory, "SwiftUI.swiftoverlay");
|
|
17769
|
+
for (const match of (0, import_node_fs26.readFileSync)(declaration, "utf8").matchAll(
|
|
17423
17770
|
/^\s*- name: ([A-Za-z_]\w*)\s*$/gm
|
|
17424
17771
|
))
|
|
17425
17772
|
reach(match[1]);
|
|
@@ -17445,7 +17792,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
17445
17792
|
return { products: linked, targets: linkedMembers };
|
|
17446
17793
|
}
|
|
17447
17794
|
function writeFrameworkLinkPackage(linkRoot, moduleRoot, products) {
|
|
17448
|
-
const identity =
|
|
17795
|
+
const identity = import_node_path28.default.basename(moduleRoot).toLowerCase();
|
|
17449
17796
|
const swiftString = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
17450
17797
|
const dependencies = products.map(
|
|
17451
17798
|
(name2) => ` .product(name: ${swiftString(name2)}, package: ${swiftString(identity)}),`
|
|
@@ -17467,13 +17814,13 @@ ${dependencies}
|
|
|
17467
17814
|
]
|
|
17468
17815
|
)
|
|
17469
17816
|
`;
|
|
17470
|
-
const sourceDir =
|
|
17471
|
-
(0,
|
|
17472
|
-
const manifestPath =
|
|
17473
|
-
if (!(0,
|
|
17474
|
-
(0,
|
|
17475
|
-
const source =
|
|
17476
|
-
if (!(0,
|
|
17817
|
+
const sourceDir = import_node_path28.default.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
|
|
17818
|
+
(0, import_node_fs26.mkdirSync)(sourceDir, { recursive: true });
|
|
17819
|
+
const manifestPath = import_node_path28.default.join(linkRoot, "Package.swift");
|
|
17820
|
+
if (!(0, import_node_fs26.existsSync)(manifestPath) || (0, import_node_fs26.readFileSync)(manifestPath, "utf8") !== manifest)
|
|
17821
|
+
(0, import_node_fs26.writeFileSync)(manifestPath, manifest);
|
|
17822
|
+
const source = import_node_path28.default.join(sourceDir, "Link.swift");
|
|
17823
|
+
if (!(0, import_node_fs26.existsSync)(source)) (0, import_node_fs26.writeFileSync)(source, "");
|
|
17477
17824
|
}
|
|
17478
17825
|
function frameworkLinkClosure(scratch2, roots) {
|
|
17479
17826
|
const suffix = `${WASM_TRIPLE}-release`;
|
|
@@ -17484,7 +17831,7 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
17484
17831
|
const moduleMaps = /* @__PURE__ */ new Map();
|
|
17485
17832
|
let pending = null;
|
|
17486
17833
|
let compiling = null;
|
|
17487
|
-
for (const line of (0,
|
|
17834
|
+
for (const line of (0, import_node_fs26.readFileSync)(import_node_path28.default.join(scratch2, "release.yaml"), "utf8").split(
|
|
17488
17835
|
"\n"
|
|
17489
17836
|
)) {
|
|
17490
17837
|
const phony = phonyHeader.exec(line);
|
|
@@ -17548,7 +17895,7 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
17548
17895
|
owners.set(file, name2);
|
|
17549
17896
|
if (seen.has(file)) continue;
|
|
17550
17897
|
seen.add(file);
|
|
17551
|
-
if (!(0,
|
|
17898
|
+
if (!(0, import_node_fs26.existsSync)(file))
|
|
17552
17899
|
throw new Error(`swift-compile: framework object ${file} was not built`);
|
|
17553
17900
|
files.push(file);
|
|
17554
17901
|
}
|
|
@@ -17558,19 +17905,19 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
17558
17905
|
return { objects: files, owners, modules, moduleMaps: [...maps].sort() };
|
|
17559
17906
|
}
|
|
17560
17907
|
function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
|
|
17561
|
-
if (!(0,
|
|
17908
|
+
if (!(0, import_node_fs26.existsSync)(modulesDir)) return;
|
|
17562
17909
|
const folded = new Set([...keep].map((name2) => name2.toLowerCase()));
|
|
17563
|
-
for (const name2 of (0,
|
|
17910
|
+
for (const name2 of (0, import_node_fs26.readdirSync)(modulesDir)) {
|
|
17564
17911
|
const dot = name2.indexOf(".");
|
|
17565
17912
|
if (dot <= 0) continue;
|
|
17566
17913
|
const module2 = name2.slice(0, dot);
|
|
17567
17914
|
if (keep.has(module2) || !folded.has(module2.toLowerCase())) continue;
|
|
17568
|
-
(0,
|
|
17915
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(modulesDir, name2), { recursive: true, force: true });
|
|
17569
17916
|
}
|
|
17570
17917
|
}
|
|
17571
17918
|
async function buildFrameworkProducts(scratch2, args) {
|
|
17572
17919
|
const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input);
|
|
17573
|
-
const linkRoot =
|
|
17920
|
+
const linkRoot = import_node_path28.default.join(scratch2, "link");
|
|
17574
17921
|
writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products);
|
|
17575
17922
|
await runCompiler(
|
|
17576
17923
|
args.swift,
|
|
@@ -17603,7 +17950,7 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17603
17950
|
"-Xswiftc",
|
|
17604
17951
|
String(swiftBuildJobs()),
|
|
17605
17952
|
...swiftReproducibleBuildFlags([
|
|
17606
|
-
[
|
|
17953
|
+
[import_node_path28.default.dirname(args.toolchainBin), "toolchain"],
|
|
17607
17954
|
[args.moduleRoot, "framework"],
|
|
17608
17955
|
[scratch2, "framework-scratch"]
|
|
17609
17956
|
]),
|
|
@@ -17628,16 +17975,16 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17628
17975
|
).catch((error) => {
|
|
17629
17976
|
throw new Error(outputOf(error), { cause: error });
|
|
17630
17977
|
});
|
|
17631
|
-
const release =
|
|
17978
|
+
const release = import_node_path28.default.join(scratch2, WASM_TRIPLE, "release");
|
|
17632
17979
|
const linked = frameworkLinkClosure(scratch2, linkedTargets.targets);
|
|
17633
17980
|
const objects = linked.objects;
|
|
17634
17981
|
if (linked.modules.has("UniformTypeIdentifiers")) {
|
|
17635
|
-
const constantsDir =
|
|
17636
|
-
const constantsStamp =
|
|
17637
|
-
const object3 =
|
|
17638
|
-
if (!(0,
|
|
17639
|
-
(0,
|
|
17640
|
-
(0,
|
|
17982
|
+
const constantsDir = import_node_path28.default.join(scratch2, "uniform-type-constants");
|
|
17983
|
+
const constantsStamp = import_node_path28.default.join(constantsDir, ".complete");
|
|
17984
|
+
const object3 = import_node_path28.default.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
|
|
17985
|
+
if (!(0, import_node_fs26.existsSync)(constantsStamp) || (0, import_node_fs26.readFileSync)(constantsStamp, "utf8") !== args.frameworkKey) {
|
|
17986
|
+
(0, import_node_fs26.rmSync)(constantsDir, { recursive: true, force: true });
|
|
17987
|
+
(0, import_node_fs26.mkdirSync)(constantsDir);
|
|
17641
17988
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
17642
17989
|
compileUniformTypeConstants({
|
|
17643
17990
|
bin: args.toolchainBin,
|
|
@@ -17647,35 +17994,35 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17647
17994
|
minimum: darwinRecordsMinimum(),
|
|
17648
17995
|
out: constantsDir
|
|
17649
17996
|
});
|
|
17650
|
-
(0,
|
|
17997
|
+
(0, import_node_fs26.writeFileSync)(constantsStamp, args.frameworkKey);
|
|
17651
17998
|
}
|
|
17652
17999
|
objects.push(object3);
|
|
17653
18000
|
linked.owners.set(object3, "UniformTypeIdentifiers");
|
|
17654
18001
|
}
|
|
17655
|
-
removeCaseCollidingModuleArtifacts(
|
|
17656
|
-
const response =
|
|
17657
|
-
(0,
|
|
18002
|
+
removeCaseCollidingModuleArtifacts(import_node_path28.default.join(release, "Modules"), linked.modules);
|
|
18003
|
+
const response = import_node_path28.default.join(scratch2, "autolink-objects.rsp");
|
|
18004
|
+
(0, import_node_fs26.writeFileSync)(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
|
|
17658
18005
|
const extracted = await runCompiler(
|
|
17659
|
-
|
|
18006
|
+
import_node_path28.default.join(args.toolchainBin, "swift-autolink-extract"),
|
|
17660
18007
|
[`@${response}`, "-o", "-"],
|
|
17661
18008
|
args.buildOptions
|
|
17662
18009
|
);
|
|
17663
|
-
(0,
|
|
18010
|
+
(0, import_node_fs26.rmSync)(response, { force: true });
|
|
17664
18011
|
const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
|
|
17665
18012
|
if (link.includes("-lFoundation"))
|
|
17666
18013
|
for (const name2 of foundationCategoryObjects) {
|
|
17667
|
-
const object3 =
|
|
18014
|
+
const object3 = import_node_path28.default.join(
|
|
17668
18015
|
swiftSdkPaths(args.moduleRoot, args.toolchainBin).resources,
|
|
17669
18016
|
`wasi/${name2}.objc.o`
|
|
17670
18017
|
);
|
|
17671
18018
|
objects.push(object3);
|
|
17672
18019
|
linked.owners.set(object3, "Foundation");
|
|
17673
18020
|
}
|
|
17674
|
-
const providerDir =
|
|
17675
|
-
const providerStamp =
|
|
17676
|
-
if (!(0,
|
|
17677
|
-
(0,
|
|
17678
|
-
(0,
|
|
18021
|
+
const providerDir = import_node_path28.default.join(scratch2, "darwin-records");
|
|
18022
|
+
const providerStamp = import_node_path28.default.join(providerDir, ".complete");
|
|
18023
|
+
if (!(0, import_node_fs26.existsSync)(providerStamp) || (0, import_node_fs26.readFileSync)(providerStamp, "utf8") !== args.frameworkKey) {
|
|
18024
|
+
(0, import_node_fs26.rmSync)(providerDir, { recursive: true, force: true });
|
|
18025
|
+
(0, import_node_fs26.mkdirSync)(providerDir);
|
|
17679
18026
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
17680
18027
|
compileDarwinRecords({
|
|
17681
18028
|
bin: args.toolchainBin,
|
|
@@ -17685,20 +18032,20 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17685
18032
|
minimum: darwinRecordsMinimum(),
|
|
17686
18033
|
out: providerDir
|
|
17687
18034
|
});
|
|
17688
|
-
(0,
|
|
18035
|
+
(0, import_node_fs26.writeFileSync)(providerStamp, args.frameworkKey);
|
|
17689
18036
|
}
|
|
17690
|
-
const providers = (0,
|
|
18037
|
+
const providers = (0, import_node_fs26.readdirSync)(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => import_node_path28.default.join(providerDir, file));
|
|
17691
18038
|
for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
|
|
17692
|
-
const archive =
|
|
17693
|
-
(0,
|
|
17694
|
-
(0,
|
|
18039
|
+
const archive = import_node_path28.default.join(scratch2, "lib");
|
|
18040
|
+
(0, import_node_fs26.rmSync)(archive, { recursive: true, force: true });
|
|
18041
|
+
(0, import_node_fs26.mkdirSync)(archive);
|
|
17695
18042
|
const archived = /* @__PURE__ */ new Map();
|
|
17696
18043
|
for (const object3 of objects) {
|
|
17697
18044
|
const target = linked.owners.get(object3);
|
|
17698
|
-
const dir =
|
|
17699
|
-
if (!target || target === "Darwin" || !object3.startsWith(dir +
|
|
17700
|
-
const name2 = `${target}-${
|
|
17701
|
-
(0,
|
|
18045
|
+
const dir = import_node_path28.default.join(release, `${target}.build`);
|
|
18046
|
+
if (!target || target === "Darwin" || !object3.startsWith(dir + import_node_path28.default.sep)) continue;
|
|
18047
|
+
const name2 = `${target}-${import_node_path28.default.relative(dir, object3).replaceAll(import_node_path28.default.sep, "-").replace(/\.swift\.o$/, ".o")}`;
|
|
18048
|
+
(0, import_node_fs26.symlinkSync)(object3, import_node_path28.default.join(archive, name2));
|
|
17702
18049
|
archived.set(object3, `lib/${name2}`);
|
|
17703
18050
|
}
|
|
17704
18051
|
const roots = swiftObjcRootObjects(`${scratch2}
|
|
@@ -17707,11 +18054,11 @@ ${args.frameworkKey}`, scratch2, [
|
|
|
17707
18054
|
]);
|
|
17708
18055
|
const linkedObjects = objects.map((object3) => {
|
|
17709
18056
|
const name2 = archived.get(object3);
|
|
17710
|
-
return name2 ? { path:
|
|
18057
|
+
return name2 ? { path: import_node_path28.default.join(scratch2, name2), lazy: !roots.has(name2) } : { path: object3, lazy: false };
|
|
17711
18058
|
});
|
|
17712
18059
|
return {
|
|
17713
18060
|
root: scratch2,
|
|
17714
|
-
modules:
|
|
18061
|
+
modules: import_node_path28.default.join(release, "Modules"),
|
|
17715
18062
|
objects: linkedObjects.filter((object3) => !object3.lazy).map((object3) => object3.path),
|
|
17716
18063
|
lazyObjects: linkedObjects.filter((object3) => object3.lazy).map((object3) => object3.path),
|
|
17717
18064
|
owners: linked.owners,
|
|
@@ -17725,14 +18072,14 @@ var SWIFT_FRAMEWORK_SLOTS = 8;
|
|
|
17725
18072
|
var SWIFT_FRAMEWORK_SLOT_KEY = ".peach-framework-key";
|
|
17726
18073
|
var SWIFT_FRAMEWORK_SLOT_ORIGIN = ".peach-framework-origin";
|
|
17727
18074
|
function swiftFrameworksDir() {
|
|
17728
|
-
return
|
|
18075
|
+
return import_node_path28.default.join(swiftCacheDir(), "swift-frameworks");
|
|
17729
18076
|
}
|
|
17730
18077
|
function swiftFrameworkScratch(frameworkKey) {
|
|
17731
|
-
return
|
|
18078
|
+
return import_node_path28.default.join(swiftFrameworksDir(), frameworkKey);
|
|
17732
18079
|
}
|
|
17733
18080
|
function swiftFrameworkSlotRecord(slot, record) {
|
|
17734
18081
|
try {
|
|
17735
|
-
return (0,
|
|
18082
|
+
return (0, import_node_fs26.readFileSync)(import_node_path28.default.join(slot, record), "utf8").trim();
|
|
17736
18083
|
} catch (error) {
|
|
17737
18084
|
if (!vanished(error)) throw error;
|
|
17738
18085
|
return null;
|
|
@@ -17743,32 +18090,32 @@ function swiftFrameworkSlotKey(slot) {
|
|
|
17743
18090
|
}
|
|
17744
18091
|
async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
17745
18092
|
const slots = Array.from({ length: SWIFT_FRAMEWORK_SLOTS }, (_, index) => {
|
|
17746
|
-
const slot =
|
|
17747
|
-
(0,
|
|
18093
|
+
const slot = import_node_path28.default.join(swiftFrameworksDir(), `slot-${index}`);
|
|
18094
|
+
(0, import_node_fs26.mkdirSync)(slot, { recursive: true });
|
|
17748
18095
|
return slot;
|
|
17749
18096
|
});
|
|
17750
18097
|
const run2 = (slot) => (lease) => {
|
|
17751
18098
|
const now = /* @__PURE__ */ new Date();
|
|
17752
|
-
(0,
|
|
18099
|
+
(0, import_node_fs26.utimesSync)(slot, now, now);
|
|
17753
18100
|
return work(slot, lease);
|
|
17754
18101
|
};
|
|
17755
18102
|
const staged = slots.find((slot) => swiftFrameworkSlotKey(slot) === frameworkKey);
|
|
17756
18103
|
if (staged) return withSwiftRootLock(staged, run2(staged), signal);
|
|
17757
|
-
const built = new Map(slots.map((slot) => [slot, (0,
|
|
18104
|
+
const built = new Map(slots.map((slot) => [slot, (0, import_node_fs26.statSync)(slot).mtimeMs]));
|
|
17758
18105
|
const own = (slot) => swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN) === moduleRoot;
|
|
17759
18106
|
const inputs = new Map(
|
|
17760
18107
|
swiftModuleInputFiles(moduleRoot).map((file) => [
|
|
17761
18108
|
file,
|
|
17762
|
-
(0,
|
|
18109
|
+
(0, import_node_fs26.readFileSync)(import_node_path28.default.join(moduleRoot, file))
|
|
17763
18110
|
])
|
|
17764
18111
|
);
|
|
17765
18112
|
const ranked = slots.map((slot) => {
|
|
17766
18113
|
let changes = 0;
|
|
17767
18114
|
if (swiftFrameworkSlotKey(slot) === null) return { slot, changes: Infinity };
|
|
17768
|
-
const source =
|
|
18115
|
+
const source = import_node_path28.default.join(slot, "source", "packages", import_node_path28.default.basename(moduleRoot));
|
|
17769
18116
|
for (const [file, contents2] of inputs) {
|
|
17770
18117
|
try {
|
|
17771
|
-
if (!(0,
|
|
18118
|
+
if (!(0, import_node_fs26.readFileSync)(import_node_path28.default.join(source, file)).equals(contents2)) changes++;
|
|
17772
18119
|
} catch (error) {
|
|
17773
18120
|
if (!vanished(error)) throw error;
|
|
17774
18121
|
changes++;
|
|
@@ -17783,7 +18130,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
|
17783
18130
|
slot,
|
|
17784
18131
|
async (lease) => {
|
|
17785
18132
|
console.error(
|
|
17786
|
-
`[swift-framework-cache] ${
|
|
18133
|
+
`[swift-framework-cache] ${import_node_path28.default.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`
|
|
17787
18134
|
);
|
|
17788
18135
|
return { value: await run2(slot)(lease) };
|
|
17789
18136
|
},
|
|
@@ -17796,91 +18143,91 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
|
17796
18143
|
return withSwiftRootLock(nearest, run2(nearest), signal);
|
|
17797
18144
|
}
|
|
17798
18145
|
function mirrorTree2(source, target, skip) {
|
|
17799
|
-
(0,
|
|
18146
|
+
(0, import_node_fs26.mkdirSync)(target, { recursive: true });
|
|
17800
18147
|
const wanted = /* @__PURE__ */ new Set();
|
|
17801
18148
|
let restructured = false;
|
|
17802
|
-
for (const entry of (0,
|
|
18149
|
+
for (const entry of (0, import_node_fs26.readdirSync)(source, { withFileTypes: true })) {
|
|
17803
18150
|
if (entry.name === skip) continue;
|
|
17804
18151
|
wanted.add(entry.name);
|
|
17805
|
-
const from =
|
|
17806
|
-
const to =
|
|
18152
|
+
const from = import_node_path28.default.join(source, entry.name);
|
|
18153
|
+
const to = import_node_path28.default.join(target, entry.name);
|
|
17807
18154
|
let existing = null;
|
|
17808
18155
|
try {
|
|
17809
|
-
existing = (0,
|
|
18156
|
+
existing = (0, import_node_fs26.lstatSync)(to);
|
|
17810
18157
|
} catch (error) {
|
|
17811
18158
|
if (!vanished(error)) throw error;
|
|
17812
18159
|
}
|
|
17813
18160
|
if (!existing) restructured = true;
|
|
17814
18161
|
if (entry.isDirectory()) {
|
|
17815
|
-
if (existing && !existing.isDirectory()) (0,
|
|
18162
|
+
if (existing && !existing.isDirectory()) (0, import_node_fs26.rmSync)(to, { force: true });
|
|
17816
18163
|
if (mirrorTree2(from, to)) restructured = true;
|
|
17817
18164
|
} else if (entry.isSymbolicLink()) {
|
|
17818
|
-
const link = (0,
|
|
17819
|
-
if (existing?.isSymbolicLink() && (0,
|
|
17820
|
-
if (existing) (0,
|
|
17821
|
-
(0,
|
|
18165
|
+
const link = (0, import_node_fs26.readlinkSync)(from);
|
|
18166
|
+
if (existing?.isSymbolicLink() && (0, import_node_fs26.readlinkSync)(to) === link) continue;
|
|
18167
|
+
if (existing) (0, import_node_fs26.rmSync)(to, { recursive: true, force: true });
|
|
18168
|
+
(0, import_node_fs26.symlinkSync)(link, to);
|
|
17822
18169
|
} else {
|
|
17823
|
-
const stat = (0,
|
|
17824
|
-
if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs || (0,
|
|
18170
|
+
const stat = (0, import_node_fs26.statSync)(from);
|
|
18171
|
+
if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs || (0, import_node_fs26.readFileSync)(from).equals((0, import_node_fs26.readFileSync)(to))))
|
|
17825
18172
|
continue;
|
|
17826
|
-
if (existing) (0,
|
|
17827
|
-
const partial = `${to}.${(0,
|
|
17828
|
-
(0,
|
|
17829
|
-
(0,
|
|
17830
|
-
(0,
|
|
18173
|
+
if (existing) (0, import_node_fs26.rmSync)(to, { recursive: true, force: true });
|
|
18174
|
+
const partial = `${to}.${(0, import_node_crypto15.randomUUID)()}`;
|
|
18175
|
+
(0, import_node_fs26.copyFileSync)(from, partial);
|
|
18176
|
+
(0, import_node_fs26.utimesSync)(partial, stat.atime, stat.mtime);
|
|
18177
|
+
(0, import_node_fs26.renameSync)(partial, to);
|
|
17831
18178
|
}
|
|
17832
18179
|
}
|
|
17833
|
-
for (const name2 of (0,
|
|
18180
|
+
for (const name2 of (0, import_node_fs26.readdirSync)(target))
|
|
17834
18181
|
if (!wanted.has(name2) && name2 !== skip) {
|
|
17835
|
-
(0,
|
|
18182
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(target, name2), { recursive: true, force: true });
|
|
17836
18183
|
restructured = true;
|
|
17837
18184
|
}
|
|
17838
18185
|
return restructured;
|
|
17839
18186
|
}
|
|
17840
18187
|
function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
17841
18188
|
if (!slot) return moduleRoot;
|
|
17842
|
-
const staged =
|
|
17843
|
-
const stagedModule =
|
|
18189
|
+
const staged = import_node_path28.default.join(slot, "source");
|
|
18190
|
+
const stagedModule = import_node_path28.default.join(staged, "packages", import_node_path28.default.basename(moduleRoot));
|
|
17844
18191
|
if (swiftFrameworkSlotKey(slot) !== frameworkKey) {
|
|
17845
|
-
(0,
|
|
18192
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
|
|
17846
18193
|
const moduleRestructured = mirrorTree2(moduleRoot, stagedModule, ".build");
|
|
17847
18194
|
const sdkRestructured = mirrorTree2(
|
|
17848
18195
|
swiftSharedSdkRoot(moduleRoot, false),
|
|
17849
|
-
|
|
18196
|
+
import_node_path28.default.join(staged, "packages/peachsim/sdk/ios")
|
|
17850
18197
|
);
|
|
17851
18198
|
if (moduleRestructured || sdkRestructured) {
|
|
17852
|
-
(0,
|
|
17853
|
-
(0,
|
|
18199
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(slot, "release.yaml"), { force: true });
|
|
18200
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(slot, "release", "description.json"), { force: true });
|
|
17854
18201
|
}
|
|
17855
18202
|
for (const file of swiftModuleInputFiles(moduleRoot)) {
|
|
17856
18203
|
if (!file.startsWith("../")) continue;
|
|
17857
|
-
const from =
|
|
17858
|
-
const to =
|
|
17859
|
-
if ((0,
|
|
17860
|
-
(0,
|
|
17861
|
-
(0,
|
|
18204
|
+
const from = import_node_path28.default.resolve(moduleRoot, file);
|
|
18205
|
+
const to = import_node_path28.default.resolve(stagedModule, file);
|
|
18206
|
+
if ((0, import_node_fs26.existsSync)(to) && (0, import_node_fs26.readFileSync)(from).equals((0, import_node_fs26.readFileSync)(to))) continue;
|
|
18207
|
+
(0, import_node_fs26.mkdirSync)(import_node_path28.default.dirname(to), { recursive: true });
|
|
18208
|
+
(0, import_node_fs26.copyFileSync)(from, to);
|
|
17862
18209
|
}
|
|
17863
18210
|
if (swiftProjectBuildKey(stagedModule, release) !== frameworkKey)
|
|
17864
18211
|
throw new Error("Swift staged framework source differs from the caller");
|
|
17865
|
-
const modules =
|
|
17866
|
-
const target = (0,
|
|
17867
|
-
if (!(0,
|
|
17868
|
-
(0,
|
|
17869
|
-
(0,
|
|
18212
|
+
const modules = import_node_path28.default.join(staged, "node_modules");
|
|
18213
|
+
const target = (0, import_node_fs26.realpathSync)(import_node_path28.default.join(moduleRoot, "../../node_modules"));
|
|
18214
|
+
if (!(0, import_node_fs26.existsSync)(modules) || (0, import_node_fs26.readlinkSync)(modules) !== target) {
|
|
18215
|
+
(0, import_node_fs26.rmSync)(modules, { recursive: true, force: true });
|
|
18216
|
+
(0, import_node_fs26.symlinkSync)(target, modules);
|
|
17870
18217
|
}
|
|
17871
|
-
(0,
|
|
17872
|
-
(0,
|
|
18218
|
+
(0, import_node_fs26.writeFileSync)(import_node_path28.default.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
|
|
18219
|
+
(0, import_node_fs26.writeFileSync)(import_node_path28.default.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
|
|
17873
18220
|
}
|
|
17874
18221
|
return stagedModule;
|
|
17875
18222
|
}
|
|
17876
18223
|
function swiftLinkStamp(args) {
|
|
17877
|
-
const hash = (0,
|
|
18224
|
+
const hash = (0, import_node_crypto15.createHash)("sha256");
|
|
17878
18225
|
hash.update(`swift-link/v1
|
|
17879
18226
|
${args.frameworkKey}
|
|
17880
18227
|
`);
|
|
17881
18228
|
if (!args.prebuilt) return hash.digest("hex");
|
|
17882
18229
|
const statOf = (file) => {
|
|
17883
|
-
const stat = (0,
|
|
18230
|
+
const stat = (0, import_node_fs26.statSync)(file, { bigint: true });
|
|
17884
18231
|
return `${stat.size}:${stat.mtimeNs}`;
|
|
17885
18232
|
};
|
|
17886
18233
|
for (const object3 of args.prebuilt.objects)
|
|
@@ -17905,25 +18252,25 @@ ${args.prebuilt.link.join("\n")}
|
|
|
17905
18252
|
hash.update(`modules
|
|
17906
18253
|
${args.prebuilt.modules}
|
|
17907
18254
|
`);
|
|
17908
|
-
for (const entry of (0,
|
|
18255
|
+
for (const entry of (0, import_node_fs26.readdirSync)(args.prebuilt.modules).sort())
|
|
17909
18256
|
hash.update(`${entry}
|
|
17910
|
-
${statOf(
|
|
18257
|
+
${statOf(import_node_path28.default.join(args.prebuilt.modules, entry))}`);
|
|
17911
18258
|
return hash.digest("hex");
|
|
17912
18259
|
}
|
|
17913
18260
|
function retireStaleSwiftLink(root, stamp) {
|
|
17914
|
-
const receipt =
|
|
18261
|
+
const receipt = import_node_path28.default.join(root, SWIFT_LINK_STAMP);
|
|
17915
18262
|
let previous = null;
|
|
17916
18263
|
try {
|
|
17917
|
-
previous = (0,
|
|
18264
|
+
previous = (0, import_node_fs26.readFileSync)(receipt, "utf8").trim();
|
|
17918
18265
|
} catch (error) {
|
|
17919
18266
|
if (!vanished(error)) throw error;
|
|
17920
18267
|
}
|
|
17921
|
-
(0,
|
|
17922
|
-
(0,
|
|
18268
|
+
(0, import_node_fs26.mkdirSync)(root, { recursive: true });
|
|
18269
|
+
(0, import_node_fs26.writeFileSync)(receipt, `${stamp}
|
|
17923
18270
|
`);
|
|
17924
|
-
const retired =
|
|
17925
|
-
if (previous === stamp || !(0,
|
|
17926
|
-
(0,
|
|
18271
|
+
const retired = import_node_path28.default.join(root, ".build");
|
|
18272
|
+
if (previous === stamp || !(0, import_node_fs26.existsSync)(retired)) return false;
|
|
18273
|
+
(0, import_node_fs26.rmSync)(retired, { recursive: true, force: true });
|
|
17927
18274
|
return true;
|
|
17928
18275
|
}
|
|
17929
18276
|
async function compileSwiftProjectUnit(input, options) {
|
|
@@ -17938,21 +18285,21 @@ async function compileSwiftProjectUnit(input, options) {
|
|
|
17938
18285
|
}
|
|
17939
18286
|
function compileSwiftProjectOnce(input, options) {
|
|
17940
18287
|
options.signal?.throwIfAborted();
|
|
17941
|
-
(0,
|
|
17942
|
-
const root = (0,
|
|
17943
|
-
const moduleRoot =
|
|
18288
|
+
(0, import_node_fs26.mkdirSync)(options.buildRoot, { recursive: true });
|
|
18289
|
+
const root = (0, import_node_fs26.realpathSync)(options.buildRoot);
|
|
18290
|
+
const moduleRoot = import_node_path28.default.resolve(options.moduleRoot);
|
|
17944
18291
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
17945
18292
|
const guestGraph = distribution ? input.sourceLinkGraph : void 0;
|
|
17946
18293
|
if (options.linkOnly && guestGraph)
|
|
17947
18294
|
throw new Error("swift-compile: link-only builds do not support guest image graphs");
|
|
17948
18295
|
const layout2 = {
|
|
17949
18296
|
root,
|
|
17950
|
-
sources:
|
|
18297
|
+
sources: import_node_path28.default.join(root, "Sources", "App"),
|
|
17951
18298
|
multi: compileTargets(input).length > 0
|
|
17952
18299
|
};
|
|
17953
18300
|
const hash = swiftArtifactHash(input, options.release, moduleRoot);
|
|
17954
18301
|
const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
|
|
17955
|
-
const sharedRoot =
|
|
18302
|
+
const sharedRoot = import_node_path28.default.join(swiftCacheDir(), "swift-projects", hash);
|
|
17956
18303
|
const report = (message) => {
|
|
17957
18304
|
console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
|
|
17958
18305
|
options.onStage?.(message);
|
|
@@ -17967,8 +18314,8 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
17967
18314
|
report("reusing memory artifact");
|
|
17968
18315
|
return retain(root, retained);
|
|
17969
18316
|
}
|
|
17970
|
-
const cached = readCompiledArtifact(
|
|
17971
|
-
const previous = cached ?? (options.project ? null : readCompiledArtifact(
|
|
18317
|
+
const cached = readCompiledArtifact(import_node_path28.default.join(sharedRoot, "artifact"), hash);
|
|
18318
|
+
const previous = cached ?? (options.project ? null : readCompiledArtifact(import_node_path28.default.join(root, "artifact"), hash));
|
|
17972
18319
|
if (previous) {
|
|
17973
18320
|
if (cached) renewSharedArtifact(sharedRoot);
|
|
17974
18321
|
else saveSharedArtifact(sharedRoot, previous);
|
|
@@ -17977,10 +18324,10 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
17977
18324
|
}
|
|
17978
18325
|
}
|
|
17979
18326
|
if (!options.intermediates && process.platform === "darwin" && process.env.TM_SESSION && !windowAdmission() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
|
|
17980
|
-
const requestRoot = (0,
|
|
17981
|
-
const output =
|
|
17982
|
-
const request =
|
|
17983
|
-
(0,
|
|
18327
|
+
const requestRoot = (0, import_node_fs26.mkdtempSync)(`${root}.builder-request-`);
|
|
18328
|
+
const output = import_node_path28.default.join(requestRoot, "output");
|
|
18329
|
+
const request = import_node_path28.default.join(requestRoot, "request.json");
|
|
18330
|
+
(0, import_node_fs26.writeFileSync)(
|
|
17984
18331
|
request,
|
|
17985
18332
|
JSON.stringify({
|
|
17986
18333
|
input,
|
|
@@ -17993,12 +18340,12 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
17993
18340
|
})
|
|
17994
18341
|
);
|
|
17995
18342
|
try {
|
|
17996
|
-
const repo =
|
|
18343
|
+
const repo = import_node_path28.default.resolve(moduleRoot, "../..");
|
|
17997
18344
|
report("requesting builder admission or cached result");
|
|
17998
18345
|
await runCompiler(
|
|
17999
18346
|
"bun",
|
|
18000
18347
|
[
|
|
18001
|
-
|
|
18348
|
+
import_node_path28.default.join(repo, "scripts/build/swift-project.ts"),
|
|
18002
18349
|
"--request",
|
|
18003
18350
|
request,
|
|
18004
18351
|
"--output",
|
|
@@ -18026,7 +18373,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18026
18373
|
report("builder artifact verified");
|
|
18027
18374
|
return retain(root, artifact);
|
|
18028
18375
|
} finally {
|
|
18029
|
-
(0,
|
|
18376
|
+
(0, import_node_fs26.rmSync)(requestRoot, { recursive: true, force: true });
|
|
18030
18377
|
}
|
|
18031
18378
|
}
|
|
18032
18379
|
return withSwiftCompileBudget(options.timeoutMs, options.signal, async (budget) => {
|
|
@@ -18034,14 +18381,14 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18034
18381
|
root,
|
|
18035
18382
|
async (lease) => {
|
|
18036
18383
|
if (!options.intermediates) {
|
|
18037
|
-
const built = readCompiledArtifact(
|
|
18384
|
+
const built = readCompiledArtifact(import_node_path28.default.join(sharedRoot, "artifact"), hash);
|
|
18038
18385
|
if (built) {
|
|
18039
18386
|
report("reusing verified disk artifact");
|
|
18040
18387
|
return retain(root, built);
|
|
18041
18388
|
}
|
|
18042
18389
|
}
|
|
18043
|
-
const swift =
|
|
18044
|
-
if (!(0,
|
|
18390
|
+
const swift = import_node_path28.default.join(options.toolchainBin, "swift");
|
|
18391
|
+
if (!(0, import_node_fs26.existsSync)(swift)) {
|
|
18045
18392
|
throw new Error(
|
|
18046
18393
|
`swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
|
|
18047
18394
|
);
|
|
@@ -18075,8 +18422,8 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18075
18422
|
// shipped host plugins resolve against the selected compiler's runtime.
|
|
18076
18423
|
...process.platform === "linux" ? {
|
|
18077
18424
|
LD_LIBRARY_PATH: [
|
|
18078
|
-
|
|
18079
|
-
|
|
18425
|
+
import_node_path28.default.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
18426
|
+
import_node_path28.default.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
18080
18427
|
process.env.LD_LIBRARY_PATH
|
|
18081
18428
|
].filter(Boolean).join(":")
|
|
18082
18429
|
} : {},
|
|
@@ -18115,21 +18462,22 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18115
18462
|
layout2,
|
|
18116
18463
|
input,
|
|
18117
18464
|
frameworkRoot,
|
|
18118
|
-
prebuilt
|
|
18465
|
+
prebuilt,
|
|
18466
|
+
!options.project
|
|
18119
18467
|
);
|
|
18120
|
-
const productFile =
|
|
18468
|
+
const productFile = import_node_path28.default.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
|
|
18121
18469
|
writeSwiftAutolinkLinker(
|
|
18122
18470
|
root,
|
|
18123
18471
|
options.toolchainBin,
|
|
18124
|
-
(0,
|
|
18472
|
+
(0, import_node_fs26.existsSync)(productFile) ? [
|
|
18125
18473
|
v5.parse(
|
|
18126
18474
|
swiftFrameworkProductSchema,
|
|
18127
|
-
JSON.parse((0,
|
|
18475
|
+
JSON.parse((0, import_node_fs26.readFileSync)(productFile, "utf8"))
|
|
18128
18476
|
).product.name
|
|
18129
18477
|
] : []
|
|
18130
18478
|
);
|
|
18131
18479
|
const projectProcess = options.project ? prepareSwiftProjectProcess(root, options.project) : void 0;
|
|
18132
|
-
const compiler = preparation.targetToolset ? { CC:
|
|
18480
|
+
const compiler = preparation.targetToolset ? { CC: import_node_path28.default.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
|
|
18133
18481
|
const appOptions = projectProcess ? {
|
|
18134
18482
|
...buildOptions,
|
|
18135
18483
|
uid: projectProcess.uid,
|
|
@@ -18143,10 +18491,10 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18143
18491
|
for (const [file, text2] of Object.entries(input.files)) {
|
|
18144
18492
|
const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text2)?.[1];
|
|
18145
18493
|
if (!parents) continue;
|
|
18146
|
-
const directory =
|
|
18494
|
+
const directory = import_node_path28.default.posix.dirname(file);
|
|
18147
18495
|
forwarders.set(
|
|
18148
|
-
`${
|
|
18149
|
-
|
|
18496
|
+
`${import_node_path28.default.join(root, directory)}/${parents.slice(0, -1)}`,
|
|
18497
|
+
import_node_path28.default.posix.join("build", directory, parents).replace(/\/$/, "")
|
|
18150
18498
|
);
|
|
18151
18499
|
}
|
|
18152
18500
|
const buildArgs = [
|
|
@@ -18162,7 +18510,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18162
18510
|
...swiftObjCSelectorOptions(frameworkRoot),
|
|
18163
18511
|
"--swift-sdk",
|
|
18164
18512
|
sdk,
|
|
18165
|
-
...preparation.targetToolset ? ["--toolset",
|
|
18513
|
+
...preparation.targetToolset ? ["--toolset", import_node_path28.default.join(root, ".peach-target-toolset.json")] : [],
|
|
18166
18514
|
"-c",
|
|
18167
18515
|
"release",
|
|
18168
18516
|
// the link strips debug info, so none is generated (as for the framework)
|
|
@@ -18173,21 +18521,21 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18173
18521
|
"-Xswiftc",
|
|
18174
18522
|
String(swiftBuildJobs()),
|
|
18175
18523
|
...swiftReproducibleBuildFlags([
|
|
18176
|
-
[
|
|
18524
|
+
[import_node_path28.default.dirname(options.toolchainBin), "toolchain"],
|
|
18177
18525
|
[frameworkRoot, "framework"],
|
|
18178
18526
|
[root, "build"],
|
|
18179
18527
|
...forwarders
|
|
18180
18528
|
]).flatMap((flag, index, flags) => {
|
|
18181
18529
|
if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
|
|
18182
18530
|
return [flag];
|
|
18183
|
-
const toolchainDir =
|
|
18531
|
+
const toolchainDir = import_node_path28.default.dirname(options.toolchainBin);
|
|
18184
18532
|
let mapped = flag;
|
|
18185
18533
|
for (const [dir, target] of [
|
|
18186
18534
|
[root, "/peach/build"],
|
|
18187
18535
|
[frameworkRoot, "/peach/framework"],
|
|
18188
|
-
[(0,
|
|
18536
|
+
[(0, import_node_fs26.realpathSync)(frameworkRoot), "/peach/framework"],
|
|
18189
18537
|
[toolchainDir, "/peach/toolchain"],
|
|
18190
|
-
[(0,
|
|
18538
|
+
[(0, import_node_fs26.realpathSync)(toolchainDir), "/peach/toolchain"]
|
|
18191
18539
|
]) {
|
|
18192
18540
|
mapped = mapped.replaceAll(dir, target);
|
|
18193
18541
|
}
|
|
@@ -18209,9 +18557,9 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18209
18557
|
])
|
|
18210
18558
|
];
|
|
18211
18559
|
const linked = builtArtifact(layout2);
|
|
18212
|
-
(0,
|
|
18213
|
-
if (options.linkOnly || (0,
|
|
18214
|
-
(0,
|
|
18560
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(root, ".peach-link.rsp"), { force: true });
|
|
18561
|
+
if (options.linkOnly || (0, import_node_fs26.existsSync)(linked) && (0, import_node_fs26.statSync)(linked).size <= 8)
|
|
18562
|
+
(0, import_node_fs26.rmSync)(linked, { force: true });
|
|
18215
18563
|
report("compiling and linking Swift modules");
|
|
18216
18564
|
const frameworkInterfaces = /* @__PURE__ */ new Map();
|
|
18217
18565
|
const nativeDeclarations = /* @__PURE__ */ new Map();
|
|
@@ -18221,58 +18569,58 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18221
18569
|
const name2 = moduleMapName(contents2);
|
|
18222
18570
|
const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
|
|
18223
18571
|
if (!name2 || !umbrella) continue;
|
|
18224
|
-
const header = input.files[
|
|
18572
|
+
const header = input.files[import_node_path28.default.posix.join(import_node_path28.default.posix.dirname(file), umbrella)];
|
|
18225
18573
|
if (header === void 0) continue;
|
|
18226
18574
|
const included = new Set(
|
|
18227
18575
|
[
|
|
18228
18576
|
...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
|
|
18229
|
-
].map((match) =>
|
|
18577
|
+
].map((match) => import_node_path28.default.posix.basename(match[1]))
|
|
18230
18578
|
);
|
|
18231
18579
|
const declarations = nativeDeclarations.get(name2) ?? /* @__PURE__ */ new Set();
|
|
18232
18580
|
for (const declaration of swiftInterfaceDeclarations(header))
|
|
18233
18581
|
declarations.add(declaration);
|
|
18234
18582
|
for (const [candidate, source] of Object.entries(input.files))
|
|
18235
|
-
if (included.has(
|
|
18583
|
+
if (included.has(import_node_path28.default.posix.basename(candidate)))
|
|
18236
18584
|
for (const declaration of swiftInterfaceDeclarations(source))
|
|
18237
18585
|
declarations.add(declaration);
|
|
18238
18586
|
nativeDeclarations.set(name2, declarations);
|
|
18239
18587
|
}
|
|
18240
18588
|
const frameworkInterface = (name2) => {
|
|
18241
18589
|
if (frameworkInterfaces.has(name2)) return frameworkInterfaces.get(name2);
|
|
18242
|
-
const source = distribution ?
|
|
18590
|
+
const source = distribution ? import_node_path28.default.join(frameworkRoot, "modules", `${name2}-Swift.h`) : import_node_path28.default.join(
|
|
18243
18591
|
prebuilt.modules,
|
|
18244
18592
|
"..",
|
|
18245
18593
|
`${name2}.build/include/${name2}-Swift.h`
|
|
18246
18594
|
);
|
|
18247
|
-
if (!(0,
|
|
18595
|
+
if (!(0, import_node_fs26.existsSync)(source)) {
|
|
18248
18596
|
frameworkInterfaces.set(name2, null);
|
|
18249
18597
|
return null;
|
|
18250
18598
|
}
|
|
18251
|
-
const headers =
|
|
18599
|
+
const headers = import_node_path28.default.join(
|
|
18252
18600
|
swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
|
|
18253
18601
|
`System/Library/Frameworks/${name2}.framework/Headers`
|
|
18254
18602
|
);
|
|
18255
18603
|
const declared = /* @__PURE__ */ new Set();
|
|
18256
|
-
if ((0,
|
|
18257
|
-
for (const file of (0,
|
|
18604
|
+
if ((0, import_node_fs26.existsSync)(headers)) {
|
|
18605
|
+
for (const file of (0, import_node_fs26.readdirSync)(headers, {
|
|
18258
18606
|
recursive: true,
|
|
18259
18607
|
encoding: "utf8"
|
|
18260
18608
|
}))
|
|
18261
18609
|
if (file.endsWith(".h"))
|
|
18262
18610
|
for (const name3 of swiftInterfaceDeclarations(
|
|
18263
|
-
(0,
|
|
18611
|
+
(0, import_node_fs26.readFileSync)(import_node_path28.default.join(headers, file), "utf8")
|
|
18264
18612
|
))
|
|
18265
18613
|
declared.add(name3);
|
|
18266
18614
|
}
|
|
18267
18615
|
for (const declaration of nativeDeclarations.get(name2) ?? [])
|
|
18268
18616
|
declared.add(declaration);
|
|
18269
18617
|
const own = withoutSwiftDeclarations(
|
|
18270
|
-
clangInterfaceHeader((0,
|
|
18618
|
+
clangInterfaceHeader((0, import_node_fs26.readFileSync)(source, "utf8")),
|
|
18271
18619
|
declared,
|
|
18272
18620
|
nativeDeclarations.has(name2) ? `@import ${name2};` : `#import <${name2}/${name2}.h>`
|
|
18273
18621
|
);
|
|
18274
18622
|
const owners = sdkObjCDeclarationOwners(
|
|
18275
|
-
|
|
18623
|
+
import_node_path28.default.dirname(import_node_path28.default.dirname(headers))
|
|
18276
18624
|
);
|
|
18277
18625
|
const foreign = /* @__PURE__ */ new Map();
|
|
18278
18626
|
for (const declaration of [
|
|
@@ -18291,117 +18639,140 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18291
18639
|
[...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
|
|
18292
18640
|
) : own;
|
|
18293
18641
|
const value = {
|
|
18294
|
-
file:
|
|
18642
|
+
file: import_node_path28.default.join(root, ".build/peach-framework-objc", `${name2}-Swift.h`),
|
|
18295
18643
|
header,
|
|
18296
|
-
module: (0,
|
|
18644
|
+
module: (0, import_node_fs26.existsSync)(headers)
|
|
18297
18645
|
};
|
|
18298
18646
|
frameworkInterfaces.set(name2, value);
|
|
18299
18647
|
writeBuildFile(
|
|
18300
18648
|
value.file,
|
|
18301
|
-
((0,
|
|
18649
|
+
((0, import_node_fs26.existsSync)(import_node_path28.default.join(headers, `${name2}.h`)) ? `#import <${name2}/${name2}.h>
|
|
18302
18650
|
` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
|
|
18303
18651
|
);
|
|
18304
18652
|
return value;
|
|
18305
18653
|
};
|
|
18306
|
-
const
|
|
18654
|
+
const headerPaths = (producer) => {
|
|
18655
|
+
const stem = import_node_path28.default.join(
|
|
18656
|
+
root,
|
|
18657
|
+
".build",
|
|
18658
|
+
"peach-cxx-headers",
|
|
18659
|
+
`${producer}-Swift`
|
|
18660
|
+
);
|
|
18661
|
+
return { producer, original: `${stem}.original.h`, emitted: `${stem}.h` };
|
|
18662
|
+
};
|
|
18663
|
+
const publishHeader = ({
|
|
18664
|
+
producer,
|
|
18665
|
+
original,
|
|
18666
|
+
emitted
|
|
18667
|
+
}) => {
|
|
18668
|
+
const generated = clangInterfaceHeader((0, import_node_fs26.readFileSync)(original, "utf8"));
|
|
18669
|
+
writeBuildFile(
|
|
18670
|
+
emitted,
|
|
18671
|
+
withoutSwiftDeclarations(
|
|
18672
|
+
swiftHeaderWithSuperclassImports(generated, frameworkInterface),
|
|
18673
|
+
/* @__PURE__ */ new Set([
|
|
18674
|
+
...preparation.nativeHeaderDeclarations[producer] ?? [],
|
|
18675
|
+
...nativelyDeclaredFunctions(generated, nativeHeaders)
|
|
18676
|
+
]),
|
|
18677
|
+
`#import <${producer}/${producer}.h>`
|
|
18678
|
+
)
|
|
18679
|
+
);
|
|
18680
|
+
};
|
|
18681
|
+
const recipe = (0, import_node_crypto15.createHash)("sha256").update(hash).update((0, import_node_fs26.readFileSync)(import_node_path28.default.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
|
|
18682
|
+
const runApp = async (compiler2) => {
|
|
18683
|
+
const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
|
|
18307
18684
|
const stages = [
|
|
18308
18685
|
...preparation.headerBuilds,
|
|
18309
18686
|
...preparation.nativeProductTarget ? [{ target: preparation.nativeProductTarget, producers: [] }] : []
|
|
18310
18687
|
];
|
|
18311
|
-
const checkpoints =
|
|
18312
|
-
const recipe = (0, import_node_crypto14.createHash)("sha256").update(hash).update((0, import_node_fs25.readFileSync)(import_node_path26.default.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
|
|
18688
|
+
const checkpoints = import_node_path28.default.join(root, ".build", "peach-product-checkpoints");
|
|
18313
18689
|
for (const { target, producers } of stages) {
|
|
18314
|
-
const receipt =
|
|
18690
|
+
const receipt = import_node_path28.default.join(
|
|
18315
18691
|
checkpoints,
|
|
18316
|
-
(0,
|
|
18692
|
+
(0, import_node_crypto15.createHash)("sha256").update(target).digest("hex")
|
|
18317
18693
|
);
|
|
18318
|
-
const headers = producers.map(
|
|
18319
|
-
const stem = import_node_path26.default.join(
|
|
18320
|
-
root,
|
|
18321
|
-
".build",
|
|
18322
|
-
"peach-cxx-headers",
|
|
18323
|
-
`${producer}-Swift`
|
|
18324
|
-
);
|
|
18325
|
-
return {
|
|
18326
|
-
producer,
|
|
18327
|
-
original: `${stem}.original.h`,
|
|
18328
|
-
emitted: `${stem}.h`
|
|
18329
|
-
};
|
|
18330
|
-
});
|
|
18694
|
+
const headers = producers.map(headerPaths);
|
|
18331
18695
|
const fingerprint = () => {
|
|
18332
|
-
const digest = (0,
|
|
18333
|
-
for (const { emitted } of headers) {
|
|
18334
|
-
if (!(0,
|
|
18696
|
+
const digest = (0, import_node_crypto15.createHash)("sha256").update(recipe);
|
|
18697
|
+
for (const { original, emitted } of headers) {
|
|
18698
|
+
if (!(0, import_node_fs26.existsSync)(original) || !(0, import_node_fs26.existsSync)(emitted)) return;
|
|
18335
18699
|
digest.update(
|
|
18336
|
-
(0,
|
|
18700
|
+
(0, import_node_crypto15.createHash)("sha256").update((0, import_node_fs26.readFileSync)(emitted)).digest()
|
|
18337
18701
|
);
|
|
18338
18702
|
}
|
|
18339
18703
|
return digest.digest("hex");
|
|
18340
18704
|
};
|
|
18341
|
-
if (!options.project && (0,
|
|
18705
|
+
if (!options.project && (0, import_node_fs26.existsSync)(receipt) && (0, import_node_fs26.readFileSync)(receipt, "utf8") === fingerprint())
|
|
18342
18706
|
continue;
|
|
18343
|
-
if (!options.project) (0,
|
|
18344
|
-
for (const
|
|
18345
|
-
if (
|
|
18346
|
-
|
|
18347
|
-
|
|
18348
|
-
|
|
18349
|
-
|
|
18350
|
-
WASM_TRIPLE,
|
|
18351
|
-
"release",
|
|
18707
|
+
if (!options.project) (0, import_node_fs26.rmSync)(receipt, { force: true });
|
|
18708
|
+
for (const header of headers) {
|
|
18709
|
+
if (compiler2 && (0, import_node_fs26.existsSync)(header.original)) publishHeader(header);
|
|
18710
|
+
if (!(0, import_node_fs26.existsSync)(header.original))
|
|
18711
|
+
(0, import_node_fs26.rmSync)(
|
|
18712
|
+
import_node_path28.default.join(
|
|
18713
|
+
import_node_path28.default.dirname(linked),
|
|
18352
18714
|
"Modules",
|
|
18353
|
-
`${swiftTargetModuleName(producer)}.swiftmodule`
|
|
18715
|
+
`${swiftTargetModuleName(header.producer)}.swiftmodule`
|
|
18354
18716
|
),
|
|
18355
18717
|
{ force: true }
|
|
18356
18718
|
);
|
|
18719
|
+
}
|
|
18357
18720
|
await runCompiler(
|
|
18358
18721
|
swift,
|
|
18359
18722
|
[...buildArgs, "--target", target],
|
|
18360
|
-
|
|
18723
|
+
optionsWithCompiler,
|
|
18361
18724
|
SWIFTPM_PROGRESS,
|
|
18362
18725
|
SWIFTPM_NOISE
|
|
18363
18726
|
);
|
|
18364
|
-
for (const
|
|
18365
|
-
const generated = clangInterfaceHeader((0, import_node_fs25.readFileSync)(original, "utf8"));
|
|
18366
|
-
writeBuildFile(
|
|
18367
|
-
emitted,
|
|
18368
|
-
withoutSwiftDeclarations(
|
|
18369
|
-
swiftHeaderWithSuperclassImports(generated, frameworkInterface),
|
|
18370
|
-
/* @__PURE__ */ new Set([
|
|
18371
|
-
...preparation.nativeHeaderDeclarations[producer] ?? [],
|
|
18372
|
-
...nativelyDeclaredFunctions(generated, nativeHeaders)
|
|
18373
|
-
]),
|
|
18374
|
-
`#import <${producer}/${producer}.h>`
|
|
18375
|
-
)
|
|
18376
|
-
);
|
|
18377
|
-
}
|
|
18727
|
+
if (!compiler2) for (const header of headers) publishHeader(header);
|
|
18378
18728
|
if (!options.project) {
|
|
18379
|
-
|
|
18380
|
-
|
|
18381
|
-
|
|
18729
|
+
const checkpoint = fingerprint();
|
|
18730
|
+
if (checkpoint === void 0)
|
|
18731
|
+
throw new Error(`missing Swift headers after building ${target}`);
|
|
18732
|
+
(0, import_node_fs26.mkdirSync)(checkpoints, { recursive: true });
|
|
18733
|
+
(0, import_node_fs26.writeFileSync)(`${receipt}.partial`, checkpoint);
|
|
18734
|
+
(0, import_node_fs26.renameSync)(`${receipt}.partial`, receipt);
|
|
18382
18735
|
}
|
|
18383
18736
|
}
|
|
18384
18737
|
await runCompiler(
|
|
18385
18738
|
swift,
|
|
18386
18739
|
buildArgs,
|
|
18387
|
-
|
|
18740
|
+
optionsWithCompiler,
|
|
18388
18741
|
SWIFTPM_PROGRESS,
|
|
18389
18742
|
SWIFTPM_NOISE
|
|
18390
18743
|
);
|
|
18391
18744
|
};
|
|
18745
|
+
const compileApp = () => preparation.headerCompiler ? withSwiftHeaderCompiler(
|
|
18746
|
+
root,
|
|
18747
|
+
options.toolchainBin,
|
|
18748
|
+
recipe,
|
|
18749
|
+
new Map(
|
|
18750
|
+
preparation.headerBuilds[0].producers.map((producer) => {
|
|
18751
|
+
const paths = headerPaths(producer);
|
|
18752
|
+
return [
|
|
18753
|
+
swiftTargetModuleName(producer),
|
|
18754
|
+
{
|
|
18755
|
+
header: paths.original,
|
|
18756
|
+
publish: () => publishHeader(paths)
|
|
18757
|
+
}
|
|
18758
|
+
];
|
|
18759
|
+
})
|
|
18760
|
+
),
|
|
18761
|
+
runApp
|
|
18762
|
+
) : runApp();
|
|
18392
18763
|
try {
|
|
18393
18764
|
await compileApp();
|
|
18394
18765
|
} catch (error) {
|
|
18395
18766
|
const output2 = outputOf(error);
|
|
18396
|
-
const moduleCache =
|
|
18767
|
+
const moduleCache = import_node_path28.default.join(
|
|
18397
18768
|
root,
|
|
18398
18769
|
".build",
|
|
18399
18770
|
WASM_TRIPLE,
|
|
18400
18771
|
"release",
|
|
18401
18772
|
"ModuleCache"
|
|
18402
18773
|
);
|
|
18403
|
-
if (output2.includes("was compiled with module cache path") && (0,
|
|
18404
|
-
(0,
|
|
18774
|
+
if (output2.includes("was compiled with module cache path") && (0, import_node_fs26.existsSync)(moduleCache)) {
|
|
18775
|
+
(0, import_node_fs26.rmSync)(moduleCache, { recursive: true, force: true });
|
|
18405
18776
|
try {
|
|
18406
18777
|
await compileApp();
|
|
18407
18778
|
} catch (retryError) {
|
|
@@ -18425,11 +18796,11 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18425
18796
|
if (options.project) endSwiftProjectProcesses(options.project);
|
|
18426
18797
|
}
|
|
18427
18798
|
if (unprepared.length) throw new Error(unprepared.join("\n"));
|
|
18428
|
-
if (!(0,
|
|
18429
|
-
const binDir =
|
|
18430
|
-
const found = (0,
|
|
18799
|
+
if (!(0, import_node_fs26.existsSync)(linked)) {
|
|
18800
|
+
const binDir = import_node_path28.default.dirname(linked);
|
|
18801
|
+
const found = (0, import_node_fs26.existsSync)(binDir) ? (0, import_node_fs26.readdirSync)(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
|
|
18431
18802
|
throw new Error(
|
|
18432
|
-
`swift-compile: the build produced no ${
|
|
18803
|
+
`swift-compile: the build produced no ${import_node_path28.default.basename(linked)} (found: ${found.join(", ") || "none"})`
|
|
18433
18804
|
);
|
|
18434
18805
|
}
|
|
18435
18806
|
if (options.project) removeProjectLinks(root);
|
|
@@ -18447,7 +18818,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18447
18818
|
resourceReferences
|
|
18448
18819
|
);
|
|
18449
18820
|
if (options.linkOnly) {
|
|
18450
|
-
if ((0,
|
|
18821
|
+
if ((0, import_node_fs26.statSync)(linked).size <= 8)
|
|
18451
18822
|
throw new Error("swift-compile: deferred linker produced no executable");
|
|
18452
18823
|
report("project link verified");
|
|
18453
18824
|
return;
|
|
@@ -18458,9 +18829,10 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18458
18829
|
await compileGuestLink({
|
|
18459
18830
|
graph: guestGraph,
|
|
18460
18831
|
buildDirectory: root,
|
|
18461
|
-
releaseDirectory:
|
|
18832
|
+
releaseDirectory: import_node_path28.default.dirname(linked),
|
|
18462
18833
|
moduleRoot: frameworkRoot,
|
|
18463
18834
|
toolchainBin: options.toolchainBin,
|
|
18835
|
+
swiftCompiler: preparation.headerCompiler ? import_node_path28.default.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : import_node_path28.default.join(options.toolchainBin, "swiftc"),
|
|
18464
18836
|
sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
|
|
18465
18837
|
sdk: swiftModuleSdk(frameworkRoot),
|
|
18466
18838
|
staticClangTargets: input.staticClangTargets ?? [],
|
|
@@ -18473,13 +18845,13 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18473
18845
|
else
|
|
18474
18846
|
await lowerWasm(output, optimized, { optimize: input.optimize === true });
|
|
18475
18847
|
await runCompiler(
|
|
18476
|
-
|
|
18848
|
+
import_node_path28.default.join(options.toolchainBin, "llvm-objcopy"),
|
|
18477
18849
|
["--remove-section=.swift1_autolink_entries", optimized],
|
|
18478
18850
|
buildOptions
|
|
18479
18851
|
);
|
|
18480
18852
|
const artifact = {
|
|
18481
18853
|
hash,
|
|
18482
|
-
bytes: (0,
|
|
18854
|
+
bytes: (0, import_node_fs26.readFileSync)(optimized),
|
|
18483
18855
|
icu: await icu
|
|
18484
18856
|
};
|
|
18485
18857
|
if (artifact.bytes.length <= 8)
|