peachsim 0.1.2421 → 0.1.2422
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +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 +4317 -3935
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -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 +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +3343 -2961
- 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 +4199 -3817
- package/dist-lib/host/fetch-proxy-handler.cjs +24 -3
- 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 +24 -3
- 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 +24 -3
- 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 +77 -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 +4851 -4468
- package/dist-lib/swift-compile.cjs +1261 -888
- package/dist-lib/swift-compile.mjs +1231 -848
- 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 -2347
- package/dist-lib/vite.cjs +24 -3
- 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/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/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/src/expo-kotlin-bundle.ts +1 -1
- package/src/native-static-libraries.ts +51 -4
- package/src/swift-compile.ts +184 -107
- 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/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.2422 | (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 ? "63f37c4a87253305166cb52435207eb3f74394734f1a77e562d79ab7d5d7dfc1" : 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)))
|
|
@@ -14559,7 +14859,6 @@ var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
|
|
|
14559
14859
|
]);
|
|
14560
14860
|
var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
14561
14861
|
"CFBridgingRetain",
|
|
14562
|
-
"NSASCIIStringEncoding",
|
|
14563
14862
|
"NSAllHashTableObjects",
|
|
14564
14863
|
"NSAllMapTableKeys",
|
|
14565
14864
|
"NSAllMapTableValues",
|
|
@@ -14638,21 +14937,16 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14638
14937
|
"NSHashTableWeakMemory",
|
|
14639
14938
|
"NSHebrewCalendar",
|
|
14640
14939
|
"NSHostByteOrder",
|
|
14641
|
-
"NSISO2022JPStringEncoding",
|
|
14642
14940
|
"NSISO8601Calendar",
|
|
14643
|
-
"NSISOLatin1StringEncoding",
|
|
14644
|
-
"NSISOLatin2StringEncoding",
|
|
14645
14941
|
"NSIndianCalendar",
|
|
14646
14942
|
"NSIslamicCalendar",
|
|
14647
14943
|
"NSIslamicCivilCalendar",
|
|
14648
14944
|
"NSItemProviderPreferredImageSizeKey",
|
|
14649
14945
|
"NSJapaneseCalendar",
|
|
14650
|
-
"NSJapaneseEUCStringEncoding",
|
|
14651
14946
|
"NSLoadedClasses",
|
|
14652
14947
|
"NSLocalizedFailureErrorKey",
|
|
14653
14948
|
"NSLogPageSize",
|
|
14654
14949
|
"NSMACHOperatingSystem",
|
|
14655
|
-
"NSMacOSRomanStringEncoding",
|
|
14656
14950
|
"NSMapGet",
|
|
14657
14951
|
"NSMapInsert",
|
|
14658
14952
|
"NSMapInsertIfAbsent",
|
|
@@ -14664,10 +14958,8 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14664
14958
|
"NSMapTableStrongMemory",
|
|
14665
14959
|
"NSMapTableWeakMemory",
|
|
14666
14960
|
"NSMultipleUnderlyingErrorsKey",
|
|
14667
|
-
"NSNEXTSTEPStringEncoding",
|
|
14668
14961
|
"NSNextHashEnumeratorItem",
|
|
14669
14962
|
"NSNextMapEnumeratorPair",
|
|
14670
|
-
"NSNonLossyASCIIStringEncoding",
|
|
14671
14963
|
"NSNonOwnedPointerHashCallBacks",
|
|
14672
14964
|
"NSNonOwnedPointerMapKeyCallBacks",
|
|
14673
14965
|
"NSNonOwnedPointerMapValueCallBacks",
|
|
@@ -14689,12 +14981,10 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14689
14981
|
"NSPointerToStructHashCallBacks",
|
|
14690
14982
|
"NSPropertyListErrorMaximum",
|
|
14691
14983
|
"NSPropertyListErrorMinimum",
|
|
14692
|
-
"NSProprietaryStringEncoding",
|
|
14693
14984
|
"NSProtocolFromString",
|
|
14694
14985
|
"NSRepublicOfChinaCalendar",
|
|
14695
14986
|
"NSResetHashTable",
|
|
14696
14987
|
"NSResetMapTable",
|
|
14697
|
-
"NSShiftJISStringEncoding",
|
|
14698
14988
|
"NSSolarisOperatingSystem",
|
|
14699
14989
|
"NSStringFromHashTable",
|
|
14700
14990
|
"NSStringFromMapTable",
|
|
@@ -14730,7 +15020,6 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14730
15020
|
"NSSwapLong",
|
|
14731
15021
|
"NSSwapLongLong",
|
|
14732
15022
|
"NSSwapShort",
|
|
14733
|
-
"NSSymbolStringEncoding",
|
|
14734
15023
|
"NSTextCheckingAllCustomTypes",
|
|
14735
15024
|
"NSTextCheckingAllSystemTypes",
|
|
14736
15025
|
"NSTextCheckingAllTypes",
|
|
@@ -14748,13 +15037,6 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14748
15037
|
"NSURLProtectionSpaceHTTPSProxy",
|
|
14749
15038
|
"NSURLProtectionSpaceSOCKSProxy",
|
|
14750
15039
|
"NSURLSessionUploadTaskResumeData",
|
|
14751
|
-
"NSUTF16BigEndianStringEncoding",
|
|
14752
|
-
"NSUTF16LittleEndianStringEncoding",
|
|
14753
|
-
"NSUTF16StringEncoding",
|
|
14754
|
-
"NSUTF32BigEndianStringEncoding",
|
|
14755
|
-
"NSUTF32LittleEndianStringEncoding",
|
|
14756
|
-
"NSUTF32StringEncoding",
|
|
14757
|
-
"NSUTF8StringEncoding",
|
|
14758
15040
|
"NSUbiquitousFileErrorMaximum",
|
|
14759
15041
|
"NSUbiquitousFileErrorMinimum",
|
|
14760
15042
|
"NSUbiquitousKeyValueStoreAccountChange",
|
|
@@ -14766,17 +15048,11 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
14766
15048
|
"NSUndefinedDateComponent",
|
|
14767
15049
|
"NSUndoCloseGroupingRunLoopOrdering",
|
|
14768
15050
|
"NSUndoManagerGroupIsDiscardableKey",
|
|
14769
|
-
"NSUnicodeStringEncoding",
|
|
14770
15051
|
"NSUserActivityErrorMaximum",
|
|
14771
15052
|
"NSUserActivityErrorMinimum",
|
|
14772
15053
|
"NSValidationErrorMaximum",
|
|
14773
15054
|
"NSValidationErrorMinimum",
|
|
14774
15055
|
"NSWindows95OperatingSystem",
|
|
14775
|
-
"NSWindowsCP1250StringEncoding",
|
|
14776
|
-
"NSWindowsCP1251StringEncoding",
|
|
14777
|
-
"NSWindowsCP1252StringEncoding",
|
|
14778
|
-
"NSWindowsCP1253StringEncoding",
|
|
14779
|
-
"NSWindowsCP1254StringEncoding",
|
|
14780
15056
|
"NSWindowsNTOperatingSystem",
|
|
14781
15057
|
"NSWrapCalendarComponents",
|
|
14782
15058
|
"NSXPCConnectionCodeSigningRequirementFailure",
|
|
@@ -15097,7 +15373,7 @@ function swiftApplicationEntry(file, source) {
|
|
|
15097
15373
|
else if (source[at] === "}") depth--;
|
|
15098
15374
|
else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
|
|
15099
15375
|
return true;
|
|
15100
|
-
else if (depth === 0 &&
|
|
15376
|
+
else if (depth === 0 && import_node_path28.default.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
|
|
15101
15377
|
return true;
|
|
15102
15378
|
}
|
|
15103
15379
|
return false;
|
|
@@ -15212,11 +15488,11 @@ function objcApplicationMainCall(source) {
|
|
|
15212
15488
|
if (principal === null || delegate === null) return null;
|
|
15213
15489
|
return { principal, delegate };
|
|
15214
15490
|
}
|
|
15215
|
-
function objcMainCallArgument(
|
|
15216
|
-
if (/^(?:nil|NULL|Nil)$/.test(
|
|
15217
|
-
const literal2 = /^@"((?:[^"\\]|\\.)*)"$/.exec(
|
|
15491
|
+
function objcMainCallArgument(argument2) {
|
|
15492
|
+
if (/^(?:nil|NULL|Nil)$/.test(argument2)) return "nil";
|
|
15493
|
+
const literal2 = /^@"((?:[^"\\]|\\.)*)"$/.exec(argument2);
|
|
15218
15494
|
if (literal2) return `"${literal2[1]}"`;
|
|
15219
|
-
const name2 = /^NSStringFromClass\(\[([A-Za-z_]\w*) class\]\)$/.exec(
|
|
15495
|
+
const name2 = /^NSStringFromClass\(\[([A-Za-z_]\w*) class\]\)$/.exec(argument2);
|
|
15220
15496
|
if (name2) return `"${name2[1]}"`;
|
|
15221
15497
|
return null;
|
|
15222
15498
|
}
|
|
@@ -15485,6 +15761,18 @@ function swiftCMainEntry(file, source, env = emptyMacroEnvironment) {
|
|
|
15485
15761
|
}
|
|
15486
15762
|
return false;
|
|
15487
15763
|
}
|
|
15764
|
+
var SWIFT_SCAN_KEYWORDS = {
|
|
15765
|
+
c: "class",
|
|
15766
|
+
e: "extension",
|
|
15767
|
+
o: "override",
|
|
15768
|
+
i: "import",
|
|
15769
|
+
f: "func",
|
|
15770
|
+
U: "UIApplicationMain",
|
|
15771
|
+
F: "Foundation",
|
|
15772
|
+
C: "CoreFoundation",
|
|
15773
|
+
O: "ObjectiveC",
|
|
15774
|
+
_: "_LocationEssentials"
|
|
15775
|
+
};
|
|
15488
15776
|
function swiftCodeScan(source) {
|
|
15489
15777
|
const starts = /* @__PURE__ */ new Set();
|
|
15490
15778
|
const tokens = [];
|
|
@@ -15567,8 +15855,8 @@ function swiftCodeScan(source) {
|
|
|
15567
15855
|
else top.parens--;
|
|
15568
15856
|
i++;
|
|
15569
15857
|
} else {
|
|
15570
|
-
const keyword =
|
|
15571
|
-
if (keyword && !/[\w$]/.test(source[i - 1] ?? "") && !/[\w$]/.test(source[i + keyword.length] ?? "")) {
|
|
15858
|
+
const keyword = SWIFT_SCAN_KEYWORDS[char];
|
|
15859
|
+
if (keyword && source.startsWith(keyword, i) && !/[\w$]/.test(source[i - 1] ?? "") && !/[\w$]/.test(source[i + keyword.length] ?? "")) {
|
|
15572
15860
|
tokens.push(i);
|
|
15573
15861
|
i += keyword.length;
|
|
15574
15862
|
} else {
|
|
@@ -15580,27 +15868,27 @@ function swiftCodeScan(source) {
|
|
|
15580
15868
|
return { lineStarts: starts, tokens };
|
|
15581
15869
|
}
|
|
15582
15870
|
function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
15583
|
-
(0,
|
|
15871
|
+
(0, import_node_fs26.rmSync)(destination, { recursive: true, force: true });
|
|
15584
15872
|
const origins = {};
|
|
15585
15873
|
const moduleMaps = [];
|
|
15586
15874
|
const gather = (from) => {
|
|
15587
|
-
for (const entry of (0,
|
|
15875
|
+
for (const entry of (0, import_node_fs26.readdirSync)(from, { withFileTypes: true })) {
|
|
15588
15876
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
15589
15877
|
continue;
|
|
15590
|
-
const file =
|
|
15878
|
+
const file = import_node_path28.default.join(from, entry.name);
|
|
15591
15879
|
if (entry.isDirectory()) gather(file);
|
|
15592
15880
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
15593
|
-
origins[
|
|
15881
|
+
origins[import_node_path28.default.relative(source, file)] = (0, import_node_fs26.readFileSync)(file, "utf8");
|
|
15594
15882
|
else if (entry.isFile() && entry.name.endsWith(".modulemap"))
|
|
15595
|
-
moduleMaps.push((0,
|
|
15883
|
+
moduleMaps.push((0, import_node_fs26.readFileSync)(file, "utf8"));
|
|
15596
15884
|
}
|
|
15597
15885
|
};
|
|
15598
15886
|
gather(source);
|
|
15599
|
-
const manifest =
|
|
15600
|
-
const targets = (0,
|
|
15601
|
-
(0,
|
|
15887
|
+
const manifest = import_node_path28.default.join(source, "Package.swift");
|
|
15888
|
+
const targets = (0, import_node_fs26.existsSync)(manifest) ? swiftManifestTargets(
|
|
15889
|
+
(0, import_node_fs26.readFileSync)(manifest, "utf8"),
|
|
15602
15890
|
[],
|
|
15603
|
-
(file) => (0,
|
|
15891
|
+
(file) => (0, import_node_fs26.readFileSync)(file, "utf8")
|
|
15604
15892
|
) : [];
|
|
15605
15893
|
let dependencyOverlays;
|
|
15606
15894
|
const compiled = compiledSwiftSources(
|
|
@@ -15624,16 +15912,16 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
|
|
|
15624
15912
|
() => []
|
|
15625
15913
|
);
|
|
15626
15914
|
const copy = (from, to) => {
|
|
15627
|
-
(0,
|
|
15628
|
-
for (const entry of (0,
|
|
15915
|
+
(0, import_node_fs26.mkdirSync)(to, { recursive: true });
|
|
15916
|
+
for (const entry of (0, import_node_fs26.readdirSync)(from, { withFileTypes: true })) {
|
|
15629
15917
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
15630
15918
|
continue;
|
|
15631
|
-
const file =
|
|
15632
|
-
const target =
|
|
15919
|
+
const file = import_node_path28.default.join(from, entry.name);
|
|
15920
|
+
const target = import_node_path28.default.join(to, entry.name);
|
|
15633
15921
|
if (entry.isDirectory()) copy(file, target);
|
|
15634
15922
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
15635
|
-
(0,
|
|
15636
|
-
else (0,
|
|
15923
|
+
(0, import_node_fs26.writeFileSync)(target, compiled.get(import_node_path28.default.relative(source, file)));
|
|
15924
|
+
else (0, import_node_fs26.cpSync)(file, target, { verbatimSymlinks: true });
|
|
15637
15925
|
}
|
|
15638
15926
|
};
|
|
15639
15927
|
copy(source, destination);
|
|
@@ -15654,18 +15942,18 @@ function swiftWholeFileArm64Guard(source) {
|
|
|
15654
15942
|
}
|
|
15655
15943
|
function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
|
|
15656
15944
|
const searched = new Set(settings.headerSearchPaths);
|
|
15657
|
-
const directory =
|
|
15945
|
+
const directory = import_node_path28.default.join(layoutRoot, ".build", "peach-clang-modulemaps");
|
|
15658
15946
|
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,
|
|
15947
|
+
const headers = import_node_path28.default.join(layoutRoot, map.headers);
|
|
15948
|
+
if (!(0, import_node_fs26.existsSync)(headers)) return [];
|
|
15949
|
+
const published = import_node_path28.default.join(headers, "module.modulemap");
|
|
15950
|
+
if (searched.has(map.headers) && (0, import_node_fs26.existsSync)(published)) return [];
|
|
15951
|
+
if (!searched.has(map.headers) && (0, import_node_fs26.existsSync)(published))
|
|
15664
15952
|
return [`-fmodule-map-file=${published}`];
|
|
15665
15953
|
const cached = written.get(headers);
|
|
15666
15954
|
if (cached) return [cached];
|
|
15667
|
-
(0,
|
|
15668
|
-
const output =
|
|
15955
|
+
(0, import_node_fs26.mkdirSync)(directory, { recursive: true });
|
|
15956
|
+
const output = import_node_path28.default.join(directory, `module-${written.size}.modulemap`);
|
|
15669
15957
|
writeBuildFile(
|
|
15670
15958
|
output,
|
|
15671
15959
|
swiftPackageClangModuleMap(swiftTargetModuleName(map.module), {
|
|
@@ -15699,7 +15987,7 @@ function needsNativeToolset(input, prebuilt) {
|
|
|
15699
15987
|
input.packageFiles || prebuilt || Object.keys(input.files).some(isSwiftNativeTranslationUnit)
|
|
15700
15988
|
);
|
|
15701
15989
|
}
|
|
15702
|
-
function writeSwiftProject(layout2, input, moduleRoot, prebuilt) {
|
|
15990
|
+
function writeSwiftProject(layout2, input, moduleRoot, prebuilt, allowHeaderCompiler = false) {
|
|
15703
15991
|
const nativeToolset = needsNativeToolset(input, prebuilt);
|
|
15704
15992
|
if (input.headerAliases !== void 0 && !isSwiftHeaderAliases(input.headerAliases))
|
|
15705
15993
|
throw new Error("swift compile input has invalid original header aliases");
|
|
@@ -15730,7 +16018,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15730
16018
|
const targets = distribution && compileTargets(input).length === 0 ? [
|
|
15731
16019
|
{
|
|
15732
16020
|
name: "App",
|
|
15733
|
-
path:
|
|
16021
|
+
path: import_node_path28.default.relative(layout2.root, layout2.sources),
|
|
15734
16022
|
executable: true,
|
|
15735
16023
|
languageMode: 5,
|
|
15736
16024
|
mainActorIsolation: false,
|
|
@@ -15738,7 +16026,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15738
16026
|
}
|
|
15739
16027
|
] : compileTargets(input);
|
|
15740
16028
|
const generatedOwners = new Map(targets.map((target) => [target.name, target.name]));
|
|
15741
|
-
const providedModules = distribution?.modules ?? (prebuilt ? (0,
|
|
16029
|
+
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
16030
|
const moduleExcludes = distribution || prebuilt ? /* @__PURE__ */ new Set([
|
|
15743
16031
|
...swiftSystemLibraryExclusions(input.files, targets, providedModules),
|
|
15744
16032
|
...providedModules.filter(
|
|
@@ -15756,12 +16044,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15756
16044
|
if (!file.endsWith(".swift")) continue;
|
|
15757
16045
|
const target = bySourcePath.find(
|
|
15758
16046
|
(candidate) => (candidate.path === "." || file.startsWith(`${candidate.path}/`)) && (candidate.sources === void 0 || candidate.sources.some((source) => {
|
|
15759
|
-
const selected =
|
|
16047
|
+
const selected = import_node_path28.default.posix.join(candidate.path, source);
|
|
15760
16048
|
return file === selected || file.startsWith(`${selected}/`);
|
|
15761
16049
|
}))
|
|
15762
16050
|
);
|
|
15763
16051
|
const excluded = target?.exclude?.some(
|
|
15764
|
-
(name2) => file ===
|
|
16052
|
+
(name2) => file === import_node_path28.default.posix.join(target.path, name2)
|
|
15765
16053
|
);
|
|
15766
16054
|
if (target && !excluded) swiftTargets.add(target.name);
|
|
15767
16055
|
}
|
|
@@ -15787,24 +16075,24 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15787
16075
|
([file, contents2]) => file.endsWith(".swift") ? [contents2] : []
|
|
15788
16076
|
)
|
|
15789
16077
|
);
|
|
15790
|
-
const headerDirectory =
|
|
16078
|
+
const headerDirectory = import_node_path28.default.join(layout2.root, ".build", "peach-cxx-headers");
|
|
15791
16079
|
const flattenedHeaders = /* @__PURE__ */ new Set();
|
|
15792
|
-
if ((0,
|
|
15793
|
-
for (const entry of (0,
|
|
16080
|
+
if ((0, import_node_fs26.existsSync)(headerDirectory)) {
|
|
16081
|
+
for (const entry of (0, import_node_fs26.readdirSync)(headerDirectory, { withFileTypes: true }))
|
|
15794
16082
|
if (entry.isDirectory() && !targets.some((target) => target.name === entry.name))
|
|
15795
|
-
(0,
|
|
16083
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(headerDirectory, entry.name), { recursive: true, force: true });
|
|
15796
16084
|
}
|
|
15797
16085
|
let checkedToolchain;
|
|
15798
16086
|
const nativeToolchain = () => {
|
|
15799
16087
|
if (checkedToolchain) return checkedToolchain;
|
|
15800
|
-
const pin = distribution ?? JSON.parse((0,
|
|
16088
|
+
const pin = distribution ?? JSON.parse((0, import_node_fs26.readFileSync)(import_node_path28.default.join(moduleRoot, "toolchain.json"), "utf8"));
|
|
15801
16089
|
checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
|
|
15802
16090
|
return checkedToolchain;
|
|
15803
16091
|
};
|
|
15804
16092
|
const deploymentTarget = (name2) => input.nativeTargets?.find((value) => value.name === name2)?.deploymentTarget ?? targets.find((value) => value.name === name2)?.iosDeploymentTarget ?? null;
|
|
15805
16093
|
const targetStagedFiles = /* @__PURE__ */ new Map();
|
|
15806
16094
|
const stageTargetFile = (target, file, contents2, options) => {
|
|
15807
|
-
const relative =
|
|
16095
|
+
const relative = import_node_path28.default.relative(layout2.root, file).split(import_node_path28.default.sep).join(import_node_path28.default.posix.sep);
|
|
15808
16096
|
const prior = files.has(file) ? files.get(file) : Object.hasOwn(input.files, relative) ? input.files[relative] : void 0;
|
|
15809
16097
|
if (!options?.allowExisting && prior !== void 0)
|
|
15810
16098
|
throw new Error(`target ${target} already contains generated output ${relative}`);
|
|
@@ -15817,7 +16105,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15817
16105
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
15818
16106
|
return Object.entries(input.files).filter(
|
|
15819
16107
|
([file]) => file.startsWith(prefix) && (target.sources === void 0 || !(file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) || target.sources.some((source) => {
|
|
15820
|
-
const selected =
|
|
16108
|
+
const selected = import_node_path28.default.posix.join(prefix, source);
|
|
15821
16109
|
return file === selected || file.startsWith(`${selected}/`);
|
|
15822
16110
|
})) && !target.exclude?.some(
|
|
15823
16111
|
(excluded) => file === `${prefix}${excluded}` || file.startsWith(`${prefix}${excluded}/`)
|
|
@@ -15838,7 +16126,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15838
16126
|
targetStagedFiles.delete(target.name);
|
|
15839
16127
|
if (entries.some(([file]) => isSwiftNativeTranslationUnit(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name))) {
|
|
15840
16128
|
if (!swift) {
|
|
15841
|
-
const unprepared =
|
|
16129
|
+
const unprepared = import_node_path28.default.join(
|
|
15842
16130
|
layout2.root,
|
|
15843
16131
|
target.path,
|
|
15844
16132
|
"PeachUnprepared.generated.swift"
|
|
@@ -15853,7 +16141,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15853
16141
|
native.set(target.name, {
|
|
15854
16142
|
mixed: true,
|
|
15855
16143
|
path: target.path,
|
|
15856
|
-
includeDirectory:
|
|
16144
|
+
includeDirectory: import_node_path28.default.join(layout2.root, target.path, "include"),
|
|
15857
16145
|
sources: [],
|
|
15858
16146
|
lateSources: [],
|
|
15859
16147
|
exclude: entries.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length))
|
|
@@ -15875,15 +16163,15 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15875
16163
|
file
|
|
15876
16164
|
)?.[1];
|
|
15877
16165
|
if (owner)
|
|
15878
|
-
podHeaders.set(
|
|
15879
|
-
...podHeaders.get(
|
|
16166
|
+
podHeaders.set(import_node_path28.default.basename(file), [
|
|
16167
|
+
...podHeaders.get(import_node_path28.default.basename(file)) ?? [],
|
|
15880
16168
|
{ owner, content: input.files[file] }
|
|
15881
16169
|
]);
|
|
15882
16170
|
}
|
|
15883
|
-
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(
|
|
16171
|
+
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
16172
|
for (const settings of input.nativeTargets ?? []) {
|
|
15885
16173
|
for (const file of settings.headers) {
|
|
15886
|
-
const destination =
|
|
16174
|
+
const destination = import_node_path28.default.join(layout2.root, file);
|
|
15887
16175
|
if (files.has(destination)) continue;
|
|
15888
16176
|
const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
|
|
15889
16177
|
const frameworkHeader = !interfaceModule && /(?:^|\/)(\w+)\.framework\/Headers\/[\w+.-]+\.h$/.exec(file)?.[1];
|
|
@@ -15902,10 +16190,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15902
16190
|
}
|
|
15903
16191
|
if (settings.flattensPublicHeaders)
|
|
15904
16192
|
for (const header of settings.publicHeaders) {
|
|
15905
|
-
const destination =
|
|
16193
|
+
const destination = import_node_path28.default.join(
|
|
15906
16194
|
headerDirectory,
|
|
15907
16195
|
settings.name,
|
|
15908
|
-
|
|
16196
|
+
import_node_path28.default.basename(header)
|
|
15909
16197
|
);
|
|
15910
16198
|
if (flattenedHeaders.has(destination))
|
|
15911
16199
|
throw new Error(`duplicate product header ${destination}`);
|
|
@@ -15913,9 +16201,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15913
16201
|
}
|
|
15914
16202
|
}
|
|
15915
16203
|
const nativeTargets = input.nativeTargets ?? [];
|
|
15916
|
-
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ?
|
|
16204
|
+
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
16205
|
const headerSearch = writeXcodeHeaderSearch(
|
|
15918
|
-
|
|
16206
|
+
import_node_path28.default.join(layout2.root, ".build", "peach-xcode-headers"),
|
|
15919
16207
|
nativeTargets.map((settings) => ({
|
|
15920
16208
|
headerMaps: settings.headerMaps.map((map) => ({
|
|
15921
16209
|
flag: map.flag,
|
|
@@ -15926,26 +16214,26 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15926
16214
|
})),
|
|
15927
16215
|
productHeaders: Object.fromEntries([
|
|
15928
16216
|
...Object.entries(settings.productHeaders).map(([product, file]) => [
|
|
15929
|
-
|
|
15930
|
-
|
|
16217
|
+
import_node_path28.default.join(layout2.root, product),
|
|
16218
|
+
import_node_path28.default.join(layout2.root, file)
|
|
15931
16219
|
]),
|
|
15932
16220
|
...settings.flattensPublicHeaders ? settings.publicHeaders.map((header) => [
|
|
15933
|
-
|
|
15934
|
-
|
|
16221
|
+
import_node_path28.default.join(headerDirectory, settings.name, import_node_path28.default.basename(header)),
|
|
16222
|
+
import_node_path28.default.join(layout2.root, header)
|
|
15935
16223
|
]) : []
|
|
15936
16224
|
]),
|
|
15937
16225
|
userHeaderSearchPaths: settings.userHeaderSearchPaths.map(
|
|
15938
|
-
(directory) =>
|
|
16226
|
+
(directory) => import_node_path28.default.join(layout2.root, directory)
|
|
15939
16227
|
),
|
|
15940
16228
|
searchDirectories: [
|
|
15941
16229
|
...settings.headerSearchPaths,
|
|
15942
16230
|
...settings.frameworkSearchPaths
|
|
15943
|
-
].map((directory) =>
|
|
16231
|
+
].map((directory) => import_node_path28.default.join(layout2.root, directory))
|
|
15944
16232
|
})),
|
|
15945
16233
|
Object.fromEntries(
|
|
15946
16234
|
Object.entries(input.headerAliases ?? {}).map(([alias, file]) => [
|
|
15947
|
-
|
|
15948
|
-
|
|
16235
|
+
import_node_path28.default.join(layout2.root, alias),
|
|
16236
|
+
import_node_path28.default.join(layout2.root, file)
|
|
15949
16237
|
])
|
|
15950
16238
|
)
|
|
15951
16239
|
);
|
|
@@ -15974,16 +16262,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
15974
16262
|
for (const [file, contents2] of entries) {
|
|
15975
16263
|
const producers2 = /* @__PURE__ */ new Set();
|
|
15976
16264
|
const source = contents2.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
15977
|
-
for (const
|
|
15978
|
-
/^\s*#\s*(?:include|import)\s*[<"]([^>"]+)[>"]/gm
|
|
15979
|
-
)) {
|
|
15980
|
-
const include = match[1];
|
|
16265
|
+
for (const include of nativeHeaderIncludes(contents2)) {
|
|
15981
16266
|
const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include)?.[1];
|
|
15982
16267
|
if (producer && swiftTargets.has(producer)) producers2.add(producer);
|
|
15983
16268
|
const local = [
|
|
15984
|
-
|
|
16269
|
+
import_node_path28.default.posix.join(import_node_path28.default.posix.dirname(file), include),
|
|
15985
16270
|
`${includes}${include}`,
|
|
15986
|
-
...searchRoots.map((root) =>
|
|
16271
|
+
...searchRoots.map((root) => import_node_path28.default.posix.join(root, include))
|
|
15987
16272
|
].find((candidate) => input.files[candidate] !== void 0);
|
|
15988
16273
|
if (local) {
|
|
15989
16274
|
reverse.set(local, [...reverse.get(local) ?? [], file]);
|
|
@@ -16014,7 +16299,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16014
16299
|
);
|
|
16015
16300
|
const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : entries.some(([file]) => file.endsWith(".swift")) || importedModules.has(swiftTargetModuleName(target.name)) ? settings.publicHeaders : [];
|
|
16016
16301
|
const search = [.../* @__PURE__ */ new Set([...settings?.headerSearchPaths ?? []])].flatMap(
|
|
16017
|
-
(dir) => ["-I",
|
|
16302
|
+
(dir) => ["-I", import_node_path28.default.join(layout2.root, dir)]
|
|
16018
16303
|
);
|
|
16019
16304
|
const toolchainBin = nativeToolchain();
|
|
16020
16305
|
const stageFlags = (flags2, sdkInclude2) => flags2.map(
|
|
@@ -16026,7 +16311,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16026
16311
|
...search,
|
|
16027
16312
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
16028
16313
|
"-F",
|
|
16029
|
-
|
|
16314
|
+
import_node_path28.default.join(layout2.root, dir)
|
|
16030
16315
|
]),
|
|
16031
16316
|
"-I",
|
|
16032
16317
|
headerDirectory
|
|
@@ -16037,7 +16322,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16037
16322
|
...search,
|
|
16038
16323
|
...settings.frameworkSearchPaths.flatMap((dir) => [
|
|
16039
16324
|
"-F",
|
|
16040
|
-
|
|
16325
|
+
import_node_path28.default.join(layout2.root, dir)
|
|
16041
16326
|
]),
|
|
16042
16327
|
"-I",
|
|
16043
16328
|
headerDirectory
|
|
@@ -16047,13 +16332,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16047
16332
|
const flag = settings.importerFlags[index];
|
|
16048
16333
|
if (flag === "-I" || flag === "-iquote") {
|
|
16049
16334
|
const directory = settings.importerFlags[index + 1];
|
|
16050
|
-
if (directory === void 0 || !
|
|
16335
|
+
if (directory === void 0 || !import_node_path28.default.isAbsolute(directory)) {
|
|
16051
16336
|
index++;
|
|
16052
16337
|
continue;
|
|
16053
16338
|
}
|
|
16054
16339
|
}
|
|
16055
16340
|
const joined = /^-(?:I|iquote)(.+)$/.exec(flag);
|
|
16056
|
-
if (joined && !
|
|
16341
|
+
if (joined && !import_node_path28.default.isAbsolute(joined[1])) continue;
|
|
16057
16342
|
kept.push(flag);
|
|
16058
16343
|
}
|
|
16059
16344
|
return [
|
|
@@ -16062,13 +16347,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16062
16347
|
...search,
|
|
16063
16348
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
16064
16349
|
"-F",
|
|
16065
|
-
|
|
16350
|
+
import_node_path28.default.join(layout2.root, dir)
|
|
16066
16351
|
]),
|
|
16067
16352
|
"-I",
|
|
16068
16353
|
headerDirectory
|
|
16069
16354
|
];
|
|
16070
16355
|
})();
|
|
16071
|
-
const sdkInclude =
|
|
16356
|
+
const sdkInclude = import_node_path28.default.join(
|
|
16072
16357
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
16073
16358
|
"darwin/usr/include"
|
|
16074
16359
|
);
|
|
@@ -16083,7 +16368,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16083
16368
|
...dependencyModuleMaps,
|
|
16084
16369
|
...target.defines?.includes(SWIFT_XCODE_BUILD_CONDITION) && !target.defines.includes("SWIFT_PACKAGE") ? ["-USWIFT_PACKAGE"] : []
|
|
16085
16370
|
];
|
|
16086
|
-
const prefixHeader = settings?.prefixHeader ? ["-include",
|
|
16371
|
+
const prefixHeader = settings?.prefixHeader ? ["-include", import_node_path28.default.join(layout2.root, settings.prefixHeader)] : [];
|
|
16087
16372
|
const bundleName = entries.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
|
|
16088
16373
|
target: target.name,
|
|
16089
16374
|
path: target.path,
|
|
@@ -16094,7 +16379,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16094
16379
|
bundles: input.resourceBundles
|
|
16095
16380
|
});
|
|
16096
16381
|
const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
|
|
16097
|
-
const accessorHeader =
|
|
16382
|
+
const accessorHeader = import_node_path28.default.join(
|
|
16098
16383
|
layout2.root,
|
|
16099
16384
|
target.path,
|
|
16100
16385
|
OBJC_RESOURCE_ACCESSOR_HEADER
|
|
@@ -16105,7 +16390,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16105
16390
|
const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
|
|
16106
16391
|
const unitSource = (file) => {
|
|
16107
16392
|
const relative = file.slice(prefix.length);
|
|
16108
|
-
return relative.split("/").some((part) => part.startsWith(".")) ?
|
|
16393
|
+
return relative.split("/").some((part) => part.startsWith(".")) ? import_node_path28.default.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
|
|
16109
16394
|
};
|
|
16110
16395
|
const accessorFlags = accessor ? ["-include", accessorHeader] : [];
|
|
16111
16396
|
const nativeC = !entries.some(([file]) => file.endsWith(".swift"));
|
|
@@ -16135,20 +16420,20 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16135
16420
|
)
|
|
16136
16421
|
].sort();
|
|
16137
16422
|
const topHeaders = settings.publicHeaders.filter(
|
|
16138
|
-
(file) =>
|
|
16423
|
+
(file) => import_node_path28.default.posix.dirname(file) === headerDir
|
|
16139
16424
|
);
|
|
16140
16425
|
if (input.files[custom] !== void 0) {
|
|
16141
16426
|
swiftpmModuleMap = { path: custom, contents: input.files[custom] };
|
|
16142
16427
|
} else if (input.files[umbrella] !== void 0) {
|
|
16143
16428
|
if (siblingDirs.length > 0)
|
|
16144
16429
|
throw new Error(
|
|
16145
|
-
`target ${target.name} has invalid header layout: umbrella header found at '${
|
|
16430
|
+
`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
16431
|
);
|
|
16147
16432
|
swiftpmModuleMap = {
|
|
16148
16433
|
path: custom,
|
|
16149
16434
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
16150
16435
|
kind: "header",
|
|
16151
|
-
path:
|
|
16436
|
+
path: import_node_path28.default.join(layout2.root, umbrella)
|
|
16152
16437
|
})
|
|
16153
16438
|
};
|
|
16154
16439
|
} else if (input.files[nestedUmbrella] !== void 0 && siblingDirs.length === 1 && siblingDirs[0] === moduleName && topHeaders.length === 0) {
|
|
@@ -16156,7 +16441,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16156
16441
|
path: custom,
|
|
16157
16442
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
16158
16443
|
kind: "header",
|
|
16159
|
-
path:
|
|
16444
|
+
path: import_node_path28.default.join(layout2.root, nestedUmbrella)
|
|
16160
16445
|
})
|
|
16161
16446
|
};
|
|
16162
16447
|
} else {
|
|
@@ -16164,12 +16449,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16164
16449
|
path: custom,
|
|
16165
16450
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
16166
16451
|
kind: "directory",
|
|
16167
|
-
path:
|
|
16452
|
+
path: import_node_path28.default.join(layout2.root, headerDir)
|
|
16168
16453
|
})
|
|
16169
16454
|
};
|
|
16170
16455
|
}
|
|
16171
16456
|
}
|
|
16172
|
-
const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ??
|
|
16457
|
+
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
16458
|
".build",
|
|
16174
16459
|
"peach-objc-originals",
|
|
16175
16460
|
target.name,
|
|
@@ -16177,79 +16462,79 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16177
16462
|
);
|
|
16178
16463
|
const moduleContents = originalModuleMap ? input.files[originalModuleMap[1]] : swiftpmModuleMap?.contents ?? packageModuleMap?.[1] ?? swiftObjCModuleMap(
|
|
16179
16464
|
swiftTargetModuleName(target.name),
|
|
16180
|
-
roots2.map((file) =>
|
|
16465
|
+
roots2.map((file) => import_node_path28.default.join(layout2.root, file)),
|
|
16181
16466
|
submoduleImports.get(swiftTargetModuleName(target.name))
|
|
16182
16467
|
);
|
|
16183
16468
|
if (moduleContents === void 0)
|
|
16184
16469
|
throw new Error("missing original module map " + modulemap);
|
|
16185
|
-
stageTargetFile(target.name,
|
|
16470
|
+
stageTargetFile(target.name, import_node_path28.default.join(layout2.root, modulemap), moduleContents, {
|
|
16186
16471
|
allowExisting: true
|
|
16187
16472
|
});
|
|
16188
16473
|
sourceModuleMaps.set(swiftTargetModuleName(target.name), {
|
|
16189
|
-
path:
|
|
16474
|
+
path: import_node_path28.default.join(layout2.root, modulemap),
|
|
16190
16475
|
contents: moduleContents.toString()
|
|
16191
16476
|
});
|
|
16192
16477
|
if (modulemap.endsWith("/Modules/module.modulemap")) {
|
|
16193
|
-
const framework =
|
|
16478
|
+
const framework = import_node_path28.default.posix.dirname(import_node_path28.default.posix.dirname(modulemap));
|
|
16194
16479
|
for (const [, header] of moduleContents.toString().matchAll(/\bheader\s+"([^"]+)"/g))
|
|
16195
16480
|
for (const folder of ["Headers", "PrivateHeaders"]) {
|
|
16196
|
-
const source = settings.productHeaders[
|
|
16481
|
+
const source = settings.productHeaders[import_node_path28.default.posix.join(framework, folder, header)];
|
|
16197
16482
|
const contents2 = source === void 0 ? void 0 : input.files[source];
|
|
16198
16483
|
if (contents2 !== void 0)
|
|
16199
16484
|
stageTargetFile(
|
|
16200
16485
|
target.name,
|
|
16201
|
-
|
|
16486
|
+
import_node_path28.default.join(layout2.root, import_node_path28.default.posix.dirname(modulemap), folder, header),
|
|
16202
16487
|
contents2,
|
|
16203
16488
|
{ allowExisting: true }
|
|
16204
16489
|
);
|
|
16205
16490
|
}
|
|
16206
16491
|
}
|
|
16207
|
-
if (nativeC &&
|
|
16492
|
+
if (nativeC && import_node_path28.default.posix.basename(modulemap) !== "module.modulemap") {
|
|
16208
16493
|
stageTargetFile(
|
|
16209
16494
|
target.name,
|
|
16210
|
-
|
|
16211
|
-
`extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(
|
|
16495
|
+
import_node_path28.default.join(layout2.root, import_node_path28.default.posix.dirname(modulemap), "module.modulemap"),
|
|
16496
|
+
`extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(import_node_path28.default.join(layout2.root, modulemap))}
|
|
16212
16497
|
`
|
|
16213
16498
|
);
|
|
16214
16499
|
}
|
|
16215
16500
|
const importFlags = [
|
|
16216
16501
|
...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
|
|
16217
|
-
"-fmodule-map-file=" +
|
|
16502
|
+
"-fmodule-map-file=" + import_node_path28.default.join(layout2.root, modulemap),
|
|
16218
16503
|
...dependencyModuleMaps
|
|
16219
16504
|
];
|
|
16220
16505
|
const groups = /* @__PURE__ */ new Map();
|
|
16221
16506
|
for (const [file, contents2] of nativeUnits) {
|
|
16222
16507
|
const origin = settings?.sourceDirectories[file];
|
|
16223
16508
|
if (origin) {
|
|
16224
|
-
const original =
|
|
16225
|
-
(0,
|
|
16509
|
+
const original = import_node_path28.default.join(layout2.root, origin, import_node_path28.default.posix.basename(file));
|
|
16510
|
+
(0, import_node_fs26.mkdirSync)(import_node_path28.default.dirname(original), { recursive: true });
|
|
16226
16511
|
stageTargetFile(target.name, original, contents2, { allowExisting: true });
|
|
16227
16512
|
}
|
|
16228
16513
|
const source = unitSource(file);
|
|
16229
16514
|
if (source !== file.slice(prefix.length))
|
|
16230
16515
|
stageTargetFile(
|
|
16231
16516
|
target.name,
|
|
16232
|
-
|
|
16517
|
+
import_node_path28.default.join(layout2.root, target.path, source),
|
|
16233
16518
|
contents2,
|
|
16234
16519
|
{
|
|
16235
16520
|
allowExisting: true
|
|
16236
16521
|
}
|
|
16237
16522
|
);
|
|
16238
|
-
const stagedDir =
|
|
16523
|
+
const stagedDir = import_node_path28.default.posix.dirname(file);
|
|
16239
16524
|
const quoteDirs = [
|
|
16240
16525
|
...stagedDir !== "." ? [stagedDir] : [],
|
|
16241
16526
|
...origin && origin !== stagedDir ? [origin] : []
|
|
16242
16527
|
];
|
|
16243
16528
|
const quoteFlags = quoteDirs.flatMap((dir) => [
|
|
16244
16529
|
"-iquote",
|
|
16245
|
-
|
|
16530
|
+
import_node_path28.default.join(layout2.root, dir)
|
|
16246
16531
|
]);
|
|
16247
16532
|
const perFile = [
|
|
16248
16533
|
...file.endsWith(".c") && swiftWholeFileArm64Guard(contents2) ? ["-D__arm64__=1"] : [],
|
|
16249
16534
|
.../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
|
|
16250
16535
|
...stageFlags(
|
|
16251
16536
|
settings?.fileFlags[file] ?? [],
|
|
16252
|
-
|
|
16537
|
+
import_node_path28.default.join(
|
|
16253
16538
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
16254
16539
|
"darwin/usr/include"
|
|
16255
16540
|
)
|
|
@@ -16257,7 +16542,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16257
16542
|
];
|
|
16258
16543
|
const cxx = /\.(?:cc|cpp|cxx|mm)$/.test(file);
|
|
16259
16544
|
const moduleFlag = perFile.some((flag) => flag.startsWith("-fmodule-name=")) ? [] : [`-fmodule-name=${swiftTargetModuleName(target.name)}`];
|
|
16260
|
-
const identity = (0,
|
|
16545
|
+
const identity = (0, import_node_crypto15.createHash)("sha256").update(
|
|
16261
16546
|
JSON.stringify([
|
|
16262
16547
|
cxx,
|
|
16263
16548
|
quoteFlags,
|
|
@@ -16266,12 +16551,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16266
16551
|
])
|
|
16267
16552
|
).digest("hex").slice(0, 12);
|
|
16268
16553
|
const name2 = `${target.name}${nativeC ? "Native" : "Swift"}Implementation_${identity}`;
|
|
16269
|
-
const groupPath =
|
|
16270
|
-
const canonicalTargetPath =
|
|
16554
|
+
const groupPath = import_node_path28.default.posix.join("PeachNativeSources", name2);
|
|
16555
|
+
const canonicalTargetPath = import_node_path28.default.posix.join("/peach/build", target.path);
|
|
16271
16556
|
const sourceIdentity = [
|
|
16272
|
-
`-ffile-prefix-map=${
|
|
16557
|
+
`-ffile-prefix-map=${import_node_path28.default.join(layout2.root, groupPath)}=${canonicalTargetPath}`,
|
|
16273
16558
|
...nativeToolset ? [
|
|
16274
|
-
`-ffile-prefix-map=${
|
|
16559
|
+
`-ffile-prefix-map=${import_node_path28.default.posix.join("/peach/build", groupPath)}=${canonicalTargetPath}`
|
|
16275
16560
|
] : []
|
|
16276
16561
|
];
|
|
16277
16562
|
const group = groups.get(identity) ?? {
|
|
@@ -16295,7 +16580,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16295
16580
|
...accessorFlags,
|
|
16296
16581
|
...stageFlags(
|
|
16297
16582
|
cxx ? settings.cxxFlags : [],
|
|
16298
|
-
|
|
16583
|
+
import_node_path28.default.join(
|
|
16299
16584
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
16300
16585
|
"darwin/usr/include"
|
|
16301
16586
|
)
|
|
@@ -16306,12 +16591,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16306
16591
|
};
|
|
16307
16592
|
stageTargetFile(
|
|
16308
16593
|
target.name,
|
|
16309
|
-
|
|
16594
|
+
import_node_path28.default.join(layout2.root, group.path, source),
|
|
16310
16595
|
contents2
|
|
16311
16596
|
);
|
|
16312
16597
|
stageTargetFile(
|
|
16313
16598
|
target.name,
|
|
16314
|
-
|
|
16599
|
+
import_node_path28.default.join(layout2.root, group.path, "include/module.modulemap"),
|
|
16315
16600
|
`module ${swiftTargetModuleName(group.name)} { export * }
|
|
16316
16601
|
`,
|
|
16317
16602
|
{ allowExisting: true }
|
|
@@ -16323,7 +16608,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16323
16608
|
stageTargetFile(target.name, accessorHeader, accessor.header);
|
|
16324
16609
|
stageTargetFile(
|
|
16325
16610
|
target.name,
|
|
16326
|
-
|
|
16611
|
+
import_node_path28.default.join(layout2.root, accessorUnit),
|
|
16327
16612
|
accessor.body
|
|
16328
16613
|
);
|
|
16329
16614
|
}
|
|
@@ -16338,7 +16623,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16338
16623
|
].sort();
|
|
16339
16624
|
native.set(target.name, {
|
|
16340
16625
|
path: target.path,
|
|
16341
|
-
includeDirectory:
|
|
16626
|
+
includeDirectory: import_node_path28.default.dirname(import_node_path28.default.join(layout2.root, modulemap)),
|
|
16342
16627
|
importFlags,
|
|
16343
16628
|
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
16344
16629
|
lateSources: implementations.flatMap((group) => group.sources),
|
|
@@ -16361,23 +16646,23 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16361
16646
|
throw new Error(`original module map declares no module: ${modulemap}`);
|
|
16362
16647
|
stageTargetFile(
|
|
16363
16648
|
target.name,
|
|
16364
|
-
|
|
16365
|
-
`extern module ${exportedModule} ${JSON.stringify(
|
|
16649
|
+
import_node_path28.default.join(layout2.root, owner.path, "include/module.modulemap"),
|
|
16650
|
+
`extern module ${exportedModule} ${JSON.stringify(import_node_path28.default.join(layout2.root, modulemap))}
|
|
16366
16651
|
`,
|
|
16367
16652
|
{ allowExisting: true }
|
|
16368
16653
|
);
|
|
16369
16654
|
}
|
|
16370
16655
|
continue;
|
|
16371
16656
|
}
|
|
16372
|
-
const implementationHeaders =
|
|
16657
|
+
const implementationHeaders = import_node_path28.default.posix.join(
|
|
16373
16658
|
".build",
|
|
16374
16659
|
"peach-objc-implementations",
|
|
16375
16660
|
target.name
|
|
16376
16661
|
);
|
|
16377
|
-
const include =
|
|
16662
|
+
const include = import_node_path28.default.join(layout2.root, implementationHeaders);
|
|
16378
16663
|
stageTargetFile(
|
|
16379
16664
|
target.name,
|
|
16380
|
-
|
|
16665
|
+
import_node_path28.default.join(include, "module.modulemap"),
|
|
16381
16666
|
`module ${target.name}ImplementationDeclarations { export * }
|
|
16382
16667
|
`
|
|
16383
16668
|
);
|
|
@@ -16387,7 +16672,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16387
16672
|
includeDirectory: include,
|
|
16388
16673
|
importFlags,
|
|
16389
16674
|
swiftFlags: [
|
|
16390
|
-
...settings.bridgingHeader ? ["-import-objc-header",
|
|
16675
|
+
...settings.bridgingHeader ? ["-import-objc-header", import_node_path28.default.join(layout2.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
|
|
16391
16676
|
...importFlags.flatMap((flag) => ["-Xcc", flag])
|
|
16392
16677
|
],
|
|
16393
16678
|
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
@@ -16417,7 +16702,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16417
16702
|
}
|
|
16418
16703
|
native.set(target.name, {
|
|
16419
16704
|
path: target.path,
|
|
16420
|
-
includeDirectory:
|
|
16705
|
+
includeDirectory: import_node_path28.default.join(layout2.root, includes),
|
|
16421
16706
|
sources: units.map(([file]) => file.slice(prefix.length)),
|
|
16422
16707
|
lateSources: late.map(([file]) => file.slice(prefix.length)),
|
|
16423
16708
|
...late.length > 0 ? {
|
|
@@ -16431,7 +16716,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16431
16716
|
});
|
|
16432
16717
|
if (late.length > 0)
|
|
16433
16718
|
files.set(
|
|
16434
|
-
|
|
16719
|
+
import_node_path28.default.join(layout2.root, target.path, "PeachSwiftImplementation/module.modulemap"),
|
|
16435
16720
|
`module ${swiftTargetModuleName(`${target.name}SwiftImplementation`)} { export * }
|
|
16436
16721
|
`
|
|
16437
16722
|
);
|
|
@@ -16443,7 +16728,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16443
16728
|
([file]) => file.startsWith(includes) && /\.(?:h|hpp|hh|hxx)$/.test(file) && consumers.get(file).size === 0
|
|
16444
16729
|
);
|
|
16445
16730
|
files.set(
|
|
16446
|
-
|
|
16731
|
+
import_node_path28.default.join(layout2.root, includes, "module.modulemap"),
|
|
16447
16732
|
[
|
|
16448
16733
|
`module ${target.name} {`,
|
|
16449
16734
|
...roots.map(
|
|
@@ -16458,14 +16743,14 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16458
16743
|
for (const map of generatedModuleMaps)
|
|
16459
16744
|
if (files.has(map.published) || Object.hasOwn(
|
|
16460
16745
|
input.files,
|
|
16461
|
-
|
|
16746
|
+
import_node_path28.default.relative(layout2.root, map.published).split(import_node_path28.default.sep).join(import_node_path28.default.posix.sep)
|
|
16462
16747
|
))
|
|
16463
16748
|
writeBuildFile(
|
|
16464
16749
|
map.output,
|
|
16465
16750
|
`extern module ${map.module} ${JSON.stringify(map.published)}
|
|
16466
16751
|
`
|
|
16467
16752
|
);
|
|
16468
|
-
if (native.size > 0) (0,
|
|
16753
|
+
if (native.size > 0) (0, import_node_fs26.mkdirSync)(headerDirectory, { recursive: true });
|
|
16469
16754
|
const headerAliasFlags = Object.keys(input.headerAliases ?? {}).length > 0 ? ["-ivfsoverlay", headerSearch.files[0]] : [];
|
|
16470
16755
|
const nativeHeaderFlags = [...headerAliasFlags];
|
|
16471
16756
|
const nativeSwiftHeaderMaps = /* @__PURE__ */ new Map();
|
|
@@ -16487,10 +16772,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16487
16772
|
[...native.values()].flatMap((value) => value.late?.producers ?? [])
|
|
16488
16773
|
)) {
|
|
16489
16774
|
files.set(
|
|
16490
|
-
|
|
16775
|
+
import_node_path28.default.join(headerDirectory, name2, name2 + "-Swift.h"),
|
|
16491
16776
|
'#include "../' + name2 + '-Swift.h"\n'
|
|
16492
16777
|
);
|
|
16493
|
-
const modulemap =
|
|
16778
|
+
const modulemap = import_node_path28.default.join(
|
|
16494
16779
|
layout2.root,
|
|
16495
16780
|
".build",
|
|
16496
16781
|
"peach-objc-swift-headers",
|
|
@@ -16500,7 +16785,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16500
16785
|
const moduleName = swiftTargetModuleName(name2);
|
|
16501
16786
|
const originalMap = originalMaps.get(moduleName);
|
|
16502
16787
|
const stagedMap = sourceModuleMaps.get(moduleName);
|
|
16503
|
-
const originalPath = stagedMap?.path ?? (originalMap ?
|
|
16788
|
+
const originalPath = stagedMap?.path ?? (originalMap ? import_node_path28.default.join(layout2.root, originalMap) : void 0);
|
|
16504
16789
|
const originalContents = stagedMap?.contents ?? (originalMap && input.files[originalMap]);
|
|
16505
16790
|
const originalTokens = originalContents ? moduleMapTokens(originalContents) : [];
|
|
16506
16791
|
if (originalPath && originalTokens.some(
|
|
@@ -16514,29 +16799,29 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
16514
16799
|
modulemap,
|
|
16515
16800
|
originalPath ? `extern module ${moduleName} ${JSON.stringify(originalPath)}
|
|
16516
16801
|
module ${moduleName}.Swift {
|
|
16517
|
-
header ${JSON.stringify(
|
|
16802
|
+
header ${JSON.stringify(import_node_path28.default.join(headerDirectory, name2 + "-Swift.h"))}
|
|
16518
16803
|
requires objc
|
|
16519
16804
|
}
|
|
16520
16805
|
` : swiftObjCModuleMap(
|
|
16521
16806
|
moduleName,
|
|
16522
|
-
(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) =>
|
|
16807
|
+
(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) => import_node_path28.default.join(layout2.root, header)),
|
|
16523
16808
|
submoduleImports.get(moduleName),
|
|
16524
|
-
|
|
16809
|
+
import_node_path28.default.join(headerDirectory, name2 + "-Swift.h")
|
|
16525
16810
|
)
|
|
16526
16811
|
);
|
|
16527
16812
|
nativeHeaderFlags.push("-fmodule-map-file=" + modulemap);
|
|
16528
16813
|
nativeSwiftHeaderMaps.set(name2, modulemap);
|
|
16529
16814
|
}
|
|
16530
|
-
const modulePlan = (0,
|
|
16815
|
+
const modulePlan = (0, import_node_crypto15.createHash)("sha256").update(
|
|
16531
16816
|
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
16532
16817
|
);
|
|
16533
16818
|
if (!distribution) {
|
|
16534
|
-
modulePlan.update((0,
|
|
16819
|
+
modulePlan.update((0, import_node_fs26.readFileSync)(import_node_path28.default.join(moduleRoot, "Package.swift")));
|
|
16535
16820
|
}
|
|
16536
16821
|
modulePlan.update(
|
|
16537
16822
|
Object.keys(input.files).filter((file) => file.endsWith(".swift")).sort().join("\n")
|
|
16538
16823
|
);
|
|
16539
|
-
const resourcePlan = (0,
|
|
16824
|
+
const resourcePlan = (0, import_node_crypto15.createHash)("sha256").update(
|
|
16540
16825
|
JSON.stringify(
|
|
16541
16826
|
resourceTargets.filter((target) => target.resources).map((target) => [
|
|
16542
16827
|
target.name,
|
|
@@ -16586,7 +16871,7 @@ module ${moduleName}.Swift {
|
|
|
16586
16871
|
(target) => {
|
|
16587
16872
|
const native2 = input.nativeTargets?.find(({ name: name2 }) => name2 === target.name);
|
|
16588
16873
|
if (native2) return native2.publicHeaders.map((file) => input.files[file] ?? "");
|
|
16589
|
-
const directory =
|
|
16874
|
+
const directory = import_node_path28.default.posix.join(
|
|
16590
16875
|
target.path,
|
|
16591
16876
|
target.publicHeadersPath ?? "include"
|
|
16592
16877
|
);
|
|
@@ -16622,7 +16907,7 @@ module ${moduleName}.Swift {
|
|
|
16622
16907
|
`;
|
|
16623
16908
|
} else if (mains.length === 0) {
|
|
16624
16909
|
const procedural = entries.filter(
|
|
16625
|
-
([file, source]) =>
|
|
16910
|
+
([file, source]) => import_node_path28.default.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
|
|
16626
16911
|
);
|
|
16627
16912
|
const wrapped = procedural.length === 1 ? wrapUIApplicationMainEntry(procedural[0][1]) : null;
|
|
16628
16913
|
if (wrapped) {
|
|
@@ -16643,7 +16928,7 @@ module ${moduleName}.Swift {
|
|
|
16643
16928
|
`mixed executable ${target.name} requires one typed Swift application entry`
|
|
16644
16929
|
);
|
|
16645
16930
|
files.set(
|
|
16646
|
-
|
|
16931
|
+
import_node_path28.default.join(layout2.root, nativeMains[0][0]),
|
|
16647
16932
|
neutralizedNativeMain(nativeMains[0][1])
|
|
16648
16933
|
);
|
|
16649
16934
|
nativeEntry = true;
|
|
@@ -16655,9 +16940,9 @@ module ${moduleName}.Swift {
|
|
|
16655
16940
|
}
|
|
16656
16941
|
if (!nativeEntry) {
|
|
16657
16942
|
compiled.set(entryFile, entrySource);
|
|
16658
|
-
if (
|
|
16659
|
-
const libraryEntry =
|
|
16660
|
-
|
|
16943
|
+
if (import_node_path28.default.basename(entryFile) === "main.swift") {
|
|
16944
|
+
const libraryEntry = import_node_path28.default.posix.join(
|
|
16945
|
+
import_node_path28.default.posix.dirname(entryFile),
|
|
16661
16946
|
"PeachApplicationEntry.generated.swift"
|
|
16662
16947
|
);
|
|
16663
16948
|
if (Object.hasOwn(input.files, libraryEntry))
|
|
@@ -16681,7 +16966,7 @@ module ${moduleName}.Swift {
|
|
|
16681
16966
|
exclude: []
|
|
16682
16967
|
});
|
|
16683
16968
|
files.set(
|
|
16684
|
-
|
|
16969
|
+
import_node_path28.default.join(layout2.root, `PeachApplication/${name2}/Entry.swift`),
|
|
16685
16970
|
!nativeEntry ? `import ${swiftTargetModuleName(target.name)}
|
|
16686
16971
|
@main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }
|
|
16687
16972
|
` : `import ${swiftTargetModuleName(target.name)}
|
|
@@ -16713,7 +16998,7 @@ module ${moduleName}.Swift {
|
|
|
16713
16998
|
);
|
|
16714
16999
|
if (nativeFlags) {
|
|
16715
17000
|
const toolchainBin = nativeToolchain();
|
|
16716
|
-
const headers =
|
|
17001
|
+
const headers = import_node_path28.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
|
|
16717
17002
|
const dependencies2 = swiftTargetDependencies(input.files, targets);
|
|
16718
17003
|
const reachesNative = (name2, seen = /* @__PURE__ */ new Set()) => {
|
|
16719
17004
|
if (native.has(name2)) return true;
|
|
@@ -16758,10 +17043,10 @@ module ${moduleName}.Swift {
|
|
|
16758
17043
|
if (targets.length === 0 && !prebuilt) {
|
|
16759
17044
|
for (const [file, contents2] of Object.entries(input.files)) {
|
|
16760
17045
|
if (file === "Package.swift") continue;
|
|
16761
|
-
files.set(
|
|
17046
|
+
files.set(import_node_path28.default.join(layout2.sources, file), compiled.get(file) ?? contents2);
|
|
16762
17047
|
}
|
|
16763
|
-
let manifest2 = (0,
|
|
16764
|
-
|
|
17048
|
+
let manifest2 = (0, import_node_fs26.readFileSync)(
|
|
17049
|
+
import_node_path28.default.join(moduleRoot, "scripts/contrast-app-Package.swift"),
|
|
16765
17050
|
"utf8"
|
|
16766
17051
|
).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
|
|
16767
17052
|
const reactor = ` ${REACTOR_FLAG}`;
|
|
@@ -16808,35 +17093,35 @@ module ${moduleName}.Swift {
|
|
|
16808
17093
|
[anchor, ...games.map((name2) => `${gameProduct(name2)},`)].join("\n ")
|
|
16809
17094
|
);
|
|
16810
17095
|
}
|
|
16811
|
-
files.set(
|
|
17096
|
+
files.set(import_node_path28.default.join(layout2.root, "Package.swift"), manifest2 + moduleFiles);
|
|
16812
17097
|
} else {
|
|
16813
17098
|
const base = layout2.multi ? layout2.root : layout2.sources;
|
|
16814
17099
|
const libraries = /* @__PURE__ */ new Map();
|
|
16815
|
-
const binaryModules =
|
|
17100
|
+
const binaryModules = import_node_path28.default.join(layout2.root, ".peach-binary-modules");
|
|
16816
17101
|
for (const [name2, data] of Object.entries(input.binaryModules ?? {})) {
|
|
16817
17102
|
if (!/^[A-Za-z_]\w*$/.test(name2) || !input.libraries?.[name2])
|
|
16818
17103
|
throw new Error(`invalid native Swift module ${name2}: its library is required`);
|
|
16819
17104
|
files.set(
|
|
16820
|
-
|
|
17105
|
+
import_node_path28.default.join(binaryModules, `${name2}.swiftmodule`),
|
|
16821
17106
|
Buffer.from(data, "base64")
|
|
16822
17107
|
);
|
|
16823
17108
|
}
|
|
16824
17109
|
for (const [target, data] of Object.entries(input.libraries ?? {})) {
|
|
16825
17110
|
const bytes = Buffer.from(data, "base64");
|
|
16826
|
-
const digest = (0,
|
|
16827
|
-
const file =
|
|
17111
|
+
const digest = (0, import_node_crypto15.createHash)("sha256").update(bytes).digest("hex");
|
|
17112
|
+
const file = import_node_path28.default.join(layout2.root, ".peach-libraries", `lib${target}-${digest}.a`);
|
|
16828
17113
|
files.set(file, bytes);
|
|
16829
17114
|
libraries.set(target, file);
|
|
16830
17115
|
}
|
|
16831
17116
|
for (const [file, contents2] of Object.entries(input.files)) {
|
|
16832
17117
|
if (file === "Package.swift") continue;
|
|
16833
|
-
const destination =
|
|
17118
|
+
const destination = import_node_path28.default.join(base, libraryEntryFiles.get(file) ?? file);
|
|
16834
17119
|
const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
|
|
16835
17120
|
const localInterface = interfaceModule && swiftTargets.has(interfaceModule) ? `#include ${JSON.stringify(
|
|
16836
|
-
|
|
16837
|
-
|
|
16838
|
-
|
|
16839
|
-
).split(
|
|
17121
|
+
import_node_path28.default.relative(
|
|
17122
|
+
import_node_path28.default.dirname(destination),
|
|
17123
|
+
import_node_path28.default.join(headerDirectory, `${interfaceModule}-Swift.h`)
|
|
17124
|
+
).split(import_node_path28.default.sep).join("/")
|
|
16840
17125
|
)}
|
|
16841
17126
|
` : void 0;
|
|
16842
17127
|
files.set(
|
|
@@ -16844,10 +17129,10 @@ module ${moduleName}.Swift {
|
|
|
16844
17129
|
localInterface ?? compiled.get(file) ?? files.get(destination) ?? (interfaceModule && moduleInterface(interfaceModule)?.header) ?? contents2
|
|
16845
17130
|
);
|
|
16846
17131
|
}
|
|
16847
|
-
const
|
|
17132
|
+
const manifestTargets2 = targets.length > 0 ? targets : [
|
|
16848
17133
|
{
|
|
16849
17134
|
name: "App",
|
|
16850
|
-
path:
|
|
17135
|
+
path: import_node_path28.default.relative(layout2.root, layout2.sources).split(import_node_path28.default.sep).join("/"),
|
|
16851
17136
|
executable: true,
|
|
16852
17137
|
languageMode: 5,
|
|
16853
17138
|
mainActorIsolation: false,
|
|
@@ -16857,11 +17142,11 @@ module ${moduleName}.Swift {
|
|
|
16857
17142
|
const reachesFrameworks = !distribution || swiftImportedModules.has("Foundation") || Object.entries(input.files).some(
|
|
16858
17143
|
([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
|
|
16859
17144
|
) || [...importedModules].some(
|
|
16860
|
-
(name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2) && !(clangImportedModules.has(name2) && !swiftImportedModules.has(name2) && (0,
|
|
16861
|
-
|
|
17145
|
+
(name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2) && !(clangImportedModules.has(name2) && !swiftImportedModules.has(name2) && (0, import_node_fs26.existsSync)(
|
|
17146
|
+
import_node_path28.default.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name2)
|
|
16862
17147
|
))
|
|
16863
17148
|
);
|
|
16864
|
-
const frameworkLink = prebuilt ?
|
|
17149
|
+
const frameworkLink = prebuilt ? import_node_path28.default.join(layout2.root, ".peach-framework-objects.rsp") : void 0;
|
|
16865
17150
|
if (prebuilt && frameworkLink) {
|
|
16866
17151
|
const quote = (object3) => `"${object3.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
16867
17152
|
files.set(
|
|
@@ -16877,10 +17162,10 @@ module ${moduleName}.Swift {
|
|
|
16877
17162
|
}
|
|
16878
17163
|
const moduleSiblings = swiftTargetDependencies(
|
|
16879
17164
|
input.files,
|
|
16880
|
-
layout2.multi ?
|
|
17165
|
+
layout2.multi ? manifestTargets2 : manifestTargets2.map((target) => ({ ...target, path: "." }))
|
|
16881
17166
|
);
|
|
16882
|
-
if (namesLibxml2(input) && !
|
|
16883
|
-
const executable =
|
|
17167
|
+
if (namesLibxml2(input) && !manifestTargets2.some((target) => target.name === "libxml2")) {
|
|
17168
|
+
const executable = manifestTargets2.find((target) => target.executable);
|
|
16884
17169
|
if (executable) {
|
|
16885
17170
|
const reached = moduleSiblings.get(executable.name) ?? [];
|
|
16886
17171
|
if (!reached.includes("libxml2"))
|
|
@@ -16888,15 +17173,15 @@ module ${moduleName}.Swift {
|
|
|
16888
17173
|
}
|
|
16889
17174
|
}
|
|
16890
17175
|
files.set(
|
|
16891
|
-
|
|
17176
|
+
import_node_path28.default.join(layout2.root, "Package.swift"),
|
|
16892
17177
|
emitSwiftPackageManifest({
|
|
16893
17178
|
root: layout2.root,
|
|
16894
17179
|
files,
|
|
16895
|
-
targets:
|
|
17180
|
+
targets: manifestTargets2.map((target) => ({
|
|
16896
17181
|
...target,
|
|
16897
17182
|
sources: target.sources?.map((source) => {
|
|
16898
|
-
const entry = libraryEntryFiles.get(
|
|
16899
|
-
return entry ?
|
|
17183
|
+
const entry = libraryEntryFiles.get(import_node_path28.default.posix.join(target.path, source));
|
|
17184
|
+
return entry ? import_node_path28.default.posix.relative(target.path, entry) : source;
|
|
16900
17185
|
})
|
|
16901
17186
|
})),
|
|
16902
17187
|
packages,
|
|
@@ -16930,7 +17215,7 @@ module ${moduleName}.Swift {
|
|
|
16930
17215
|
),
|
|
16931
17216
|
...reachesFrameworks ? {
|
|
16932
17217
|
distributionLink: {
|
|
16933
|
-
path:
|
|
17218
|
+
path: import_node_path28.default.join(layout2.root, ".peach-distribution-objects.rsp"),
|
|
16934
17219
|
files
|
|
16935
17220
|
}
|
|
16936
17221
|
} : {},
|
|
@@ -16951,14 +17236,14 @@ module ${moduleName}.Swift {
|
|
|
16951
17236
|
for (const [file, bytes] of Object.entries(input.packageFiles ?? {})) {
|
|
16952
17237
|
const contents2 = Buffer.from(bytes, "base64");
|
|
16953
17238
|
files.set(
|
|
16954
|
-
|
|
17239
|
+
import_node_path28.default.join(layout2.root, file),
|
|
16955
17240
|
file.endsWith(".swift") && !/(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file) ? withPreconcurrencyFoundationModules(
|
|
16956
17241
|
swiftPackageSourceAsIOS(contents2.toString("utf8"))
|
|
16957
17242
|
) : contents2
|
|
16958
17243
|
);
|
|
16959
17244
|
}
|
|
16960
17245
|
for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
|
|
16961
|
-
const destination =
|
|
17246
|
+
const destination = import_node_path28.default.join(layout2.root, file);
|
|
16962
17247
|
if (files.has(destination)) continue;
|
|
16963
17248
|
files.set(destination, Buffer.from(bytes, "base64"));
|
|
16964
17249
|
}
|
|
@@ -16967,13 +17252,13 @@ module ${moduleName}.Swift {
|
|
|
16967
17252
|
const nativeToolsetFlags = [
|
|
16968
17253
|
...headerAliasFlags,
|
|
16969
17254
|
...native.size > 0 ? [
|
|
16970
|
-
"-fmodule-map-file=" +
|
|
17255
|
+
"-fmodule-map-file=" + import_node_path28.default.join(
|
|
16971
17256
|
swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
|
|
16972
17257
|
"darwin/wasm/include/module.modulemap"
|
|
16973
17258
|
)
|
|
16974
17259
|
] : []
|
|
16975
17260
|
];
|
|
16976
|
-
const clangWrapper2 =
|
|
17261
|
+
const clangWrapper2 = import_node_path28.default.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
|
|
16977
17262
|
files.set(
|
|
16978
17263
|
clangWrapper2,
|
|
16979
17264
|
[
|
|
@@ -17014,21 +17299,21 @@ module ${moduleName}.Swift {
|
|
|
17014
17299
|
" done",
|
|
17015
17300
|
"fi",
|
|
17016
17301
|
'if [ -n "$name" ] && [ -z "$explicit" ]; then',
|
|
17017
|
-
` exec '${
|
|
17302
|
+
` exec '${import_node_path28.default.join(nativeToolchain(), "clang")}' "-fmodule-name=$name" "$@"`,
|
|
17018
17303
|
"fi",
|
|
17019
|
-
`exec '${
|
|
17304
|
+
`exec '${import_node_path28.default.join(nativeToolchain(), "clang")}' "$@"`,
|
|
17020
17305
|
""
|
|
17021
17306
|
].join("\n")
|
|
17022
17307
|
);
|
|
17023
17308
|
files.set(
|
|
17024
|
-
|
|
17309
|
+
import_node_path28.default.join(layout2.root, ".peach-target-toolset.json"),
|
|
17025
17310
|
JSON.stringify({
|
|
17026
17311
|
schemaVersion: "1.0",
|
|
17027
17312
|
cCompiler: {
|
|
17028
17313
|
extraCLIOptions: [
|
|
17029
17314
|
...nativeToolsetFlags,
|
|
17030
17315
|
"-fmodules",
|
|
17031
|
-
`-fmodules-cache-path=${
|
|
17316
|
+
`-fmodules-cache-path=${import_node_path28.default.join(layout2.root, ".build", "ModuleCache")}`
|
|
17032
17317
|
]
|
|
17033
17318
|
},
|
|
17034
17319
|
...nativeToolsetFlags.length > 0 ? { cxxCompiler: { extraCLIOptions: nativeToolsetFlags } } : {},
|
|
@@ -17038,12 +17323,12 @@ module ${moduleName}.Swift {
|
|
|
17038
17323
|
distribution || prebuilt ? "-Isystem" : "-I",
|
|
17039
17324
|
distribution ? providedModulesPath(
|
|
17040
17325
|
layout2.root,
|
|
17041
|
-
|
|
17326
|
+
import_node_path28.default.join(moduleRoot, "modules"),
|
|
17042
17327
|
moduleExcludes
|
|
17043
|
-
) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) :
|
|
17328
|
+
) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) : import_node_path28.default.join(layout2.root, ".build", WASM_TRIPLE, "release", "Modules"),
|
|
17044
17329
|
...distribution ? distributionClangModuleOptions(
|
|
17045
17330
|
layout2.root,
|
|
17046
|
-
|
|
17331
|
+
import_node_path28.default.join(moduleRoot, "modules")
|
|
17047
17332
|
) : [],
|
|
17048
17333
|
...prebuilt?.moduleMaps.flatMap((map) => [
|
|
17049
17334
|
"-Xcc",
|
|
@@ -17073,9 +17358,9 @@ module ${moduleName}.Swift {
|
|
|
17073
17358
|
throw new Error(
|
|
17074
17359
|
`swift resource target ${target.name} has no matching bundle assignment`
|
|
17075
17360
|
);
|
|
17076
|
-
const directory = layout2.multi ?
|
|
17361
|
+
const directory = layout2.multi ? import_node_path28.default.join(layout2.root, target.path) : layout2.sources;
|
|
17077
17362
|
files.set(
|
|
17078
|
-
|
|
17363
|
+
import_node_path28.default.join(directory, "ResourceBundleAccessor.generated.swift"),
|
|
17079
17364
|
[
|
|
17080
17365
|
"import Foundation",
|
|
17081
17366
|
"",
|
|
@@ -17092,7 +17377,7 @@ module ${moduleName}.Swift {
|
|
|
17092
17377
|
}
|
|
17093
17378
|
for (const [file, source] of compiled)
|
|
17094
17379
|
if (!Object.hasOwn(input.files, file))
|
|
17095
|
-
files.set(
|
|
17380
|
+
files.set(import_node_path28.default.join(layout2.multi ? layout2.root : layout2.sources, file), source);
|
|
17096
17381
|
const producers = [
|
|
17097
17382
|
.../* @__PURE__ */ new Set([...[...native.values()].flatMap((value) => value.late?.producers ?? [])])
|
|
17098
17383
|
];
|
|
@@ -17105,14 +17390,15 @@ module ${moduleName}.Swift {
|
|
|
17105
17390
|
generatedOwners.set(group.name, owner);
|
|
17106
17391
|
}
|
|
17107
17392
|
}
|
|
17108
|
-
const manifestPath =
|
|
17393
|
+
const manifestPath = import_node_path28.default.join(layout2.root, "Package.swift");
|
|
17109
17394
|
let manifest = files.get(manifestPath).toString();
|
|
17395
|
+
const manifestTargets = swiftManifestTargets(manifest, [], (file) => {
|
|
17396
|
+
const contents2 = files.get(file);
|
|
17397
|
+
if (contents2 === void 0) throw new Error(`missing compiler arguments ${file}`);
|
|
17398
|
+
return contents2.toString();
|
|
17399
|
+
});
|
|
17110
17400
|
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) => [
|
|
17401
|
+
manifestTargets.map((target) => [
|
|
17116
17402
|
target.name,
|
|
17117
17403
|
(target.dependencies ?? []).flatMap(
|
|
17118
17404
|
(dependency) => dependency.kind === "target" ? [dependency.name] : []
|
|
@@ -17120,6 +17406,62 @@ module ${moduleName}.Swift {
|
|
|
17120
17406
|
])
|
|
17121
17407
|
);
|
|
17122
17408
|
const producerSet = /* @__PURE__ */ new Set([...Object.keys(nativeHeaderDeclarations), ...producers]);
|
|
17409
|
+
let headerCompiler = allowHeaderCompiler && packages.size === 0 && producerSet.size > 0;
|
|
17410
|
+
if (headerCompiler) {
|
|
17411
|
+
const clang = new Set(
|
|
17412
|
+
manifestTargets.filter(
|
|
17413
|
+
(target) => target.systemLibrary || !swiftTargets.has(target.name) && native.has(target.name)
|
|
17414
|
+
).map(({ name: name2 }) => name2)
|
|
17415
|
+
);
|
|
17416
|
+
const headers = swiftHeaderDependencies(
|
|
17417
|
+
layout2.root,
|
|
17418
|
+
files,
|
|
17419
|
+
manifestTargets,
|
|
17420
|
+
nativeTargets,
|
|
17421
|
+
producerSet,
|
|
17422
|
+
input.headerAliases ?? {}
|
|
17423
|
+
);
|
|
17424
|
+
const nativeEdges = /* @__PURE__ */ new Map();
|
|
17425
|
+
const dependsOn = (from, to, seen = /* @__PURE__ */ new Set()) => {
|
|
17426
|
+
if (from === to) return true;
|
|
17427
|
+
if (seen.has(from)) return false;
|
|
17428
|
+
seen.add(from);
|
|
17429
|
+
return [...dependencies.get(from) ?? [], ...nativeEdges.get(from) ?? []].some(
|
|
17430
|
+
(dependency) => dependsOn(dependency, to, seen)
|
|
17431
|
+
);
|
|
17432
|
+
};
|
|
17433
|
+
for (const target of manifestTargets) {
|
|
17434
|
+
if (target.systemLibrary) continue;
|
|
17435
|
+
const required = new Set(headers.get(target.name));
|
|
17436
|
+
const visited = /* @__PURE__ */ new Set();
|
|
17437
|
+
const imports = (name2) => {
|
|
17438
|
+
if (!clang.has(name2) || visited.has(name2)) return;
|
|
17439
|
+
visited.add(name2);
|
|
17440
|
+
for (const header of headers.get(name2) ?? []) required.add(header);
|
|
17441
|
+
for (const dependency of dependencies.get(name2) ?? []) imports(dependency);
|
|
17442
|
+
};
|
|
17443
|
+
for (const dependency of dependencies.get(target.name) ?? []) imports(dependency);
|
|
17444
|
+
for (const producer of required) {
|
|
17445
|
+
if (dependsOn(target.name, producer)) continue;
|
|
17446
|
+
if (dependsOn(producer, target.name)) {
|
|
17447
|
+
headerCompiler = false;
|
|
17448
|
+
break;
|
|
17449
|
+
}
|
|
17450
|
+
const edges = nativeEdges.get(target.name) ?? [];
|
|
17451
|
+
edges.push(producer);
|
|
17452
|
+
nativeEdges.set(target.name, edges);
|
|
17453
|
+
}
|
|
17454
|
+
if (!headerCompiler) break;
|
|
17455
|
+
}
|
|
17456
|
+
if (headerCompiler)
|
|
17457
|
+
for (const [target, producers2] of nativeEdges) {
|
|
17458
|
+
const additions = producers2.map((producer) => `.target(name: ${JSON.stringify(producer)})`).join(", ");
|
|
17459
|
+
manifest += `
|
|
17460
|
+
package.targets.first(where: { $0.name == ${JSON.stringify(target)} })!.dependencies += [${additions}]
|
|
17461
|
+
`;
|
|
17462
|
+
dependencies.get(target).push(...producers2);
|
|
17463
|
+
}
|
|
17464
|
+
}
|
|
17123
17465
|
const depths = /* @__PURE__ */ new Map();
|
|
17124
17466
|
const orderedProducers = [];
|
|
17125
17467
|
const depth = (name2) => {
|
|
@@ -17148,13 +17490,18 @@ module ${moduleName}.Swift {
|
|
|
17148
17490
|
if (members.length === 1) return members[0];
|
|
17149
17491
|
if (dependencies.has(name2))
|
|
17150
17492
|
throw new Error(`generated build target collides with ${name2}`);
|
|
17151
|
-
files.set(
|
|
17493
|
+
files.set(import_node_path28.default.join(layout2.root, name2, "Products.swift"), "");
|
|
17152
17494
|
manifest += `
|
|
17153
17495
|
package.targets += [.target(name: ${JSON.stringify(name2)}, dependencies: ${JSON.stringify(members)}, path: ${JSON.stringify(name2)}, swiftSettings: [.swiftLanguageMode(.v5)])]
|
|
17154
17496
|
`;
|
|
17155
17497
|
return name2;
|
|
17156
17498
|
};
|
|
17157
|
-
const headerBuilds =
|
|
17499
|
+
const headerBuilds = headerCompiler ? [
|
|
17500
|
+
{
|
|
17501
|
+
target: buildProduct(SWIFT_HEADER_PRODUCTS_TARGET, orderedProducers),
|
|
17502
|
+
producers: orderedProducers
|
|
17503
|
+
}
|
|
17504
|
+
] : [...stages].sort(([left], [right]) => left - right).map(([level, producers2]) => ({
|
|
17158
17505
|
target: buildProduct(`${SWIFT_HEADER_PRODUCTS_TARGET}${level}`, producers2),
|
|
17159
17506
|
producers: producers2
|
|
17160
17507
|
}));
|
|
@@ -17172,16 +17519,17 @@ package.targets += [.target(name: ${JSON.stringify(name2)}, dependencies: ${JSON
|
|
|
17172
17519
|
syncSwiftTree(layout2.root, files);
|
|
17173
17520
|
if (layout2.multi)
|
|
17174
17521
|
for (const target of targets)
|
|
17175
|
-
(0,
|
|
17176
|
-
const clangWrapper =
|
|
17177
|
-
if (files.has(clangWrapper)) (0,
|
|
17522
|
+
(0, import_node_fs26.mkdirSync)(import_node_path28.default.join(layout2.root, target.path), { recursive: true });
|
|
17523
|
+
const clangWrapper = import_node_path28.default.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
|
|
17524
|
+
if (files.has(clangWrapper)) (0, import_node_fs26.chmodSync)(clangWrapper, 493);
|
|
17178
17525
|
return {
|
|
17179
17526
|
headerBuilds,
|
|
17180
17527
|
nativeHeaderDeclarations,
|
|
17181
17528
|
nativeProductTarget,
|
|
17182
17529
|
targetFailures,
|
|
17183
17530
|
generatedOwners,
|
|
17184
|
-
targetToolset
|
|
17531
|
+
targetToolset,
|
|
17532
|
+
headerCompiler
|
|
17185
17533
|
};
|
|
17186
17534
|
}
|
|
17187
17535
|
function streamText(value) {
|
|
@@ -17201,21 +17549,21 @@ function outputOf(error) {
|
|
|
17201
17549
|
return error instanceof Error ? error.message : String(error);
|
|
17202
17550
|
}
|
|
17203
17551
|
function builtArtifact(layout2) {
|
|
17204
|
-
const binDir =
|
|
17205
|
-
const manifest = (0,
|
|
17552
|
+
const binDir = import_node_path28.default.join(layout2.root, ".build", WASM_TRIPLE, "release");
|
|
17553
|
+
const manifest = (0, import_node_fs26.readFileSync)(import_node_path28.default.join(layout2.root, "Package.swift"), "utf8");
|
|
17206
17554
|
const executable = swiftManifestTargets(
|
|
17207
17555
|
manifest,
|
|
17208
17556
|
[],
|
|
17209
|
-
(file) => (0,
|
|
17557
|
+
(file) => (0, import_node_fs26.readFileSync)(file, "utf8")
|
|
17210
17558
|
).find((target) => target.executable);
|
|
17211
17559
|
if (executable === void 0) {
|
|
17212
17560
|
throw new Error("swift-compile: the written manifest names no executable target");
|
|
17213
17561
|
}
|
|
17214
|
-
return
|
|
17562
|
+
return import_node_path28.default.join(binDir, `${executable.name}.wasm`);
|
|
17215
17563
|
}
|
|
17216
17564
|
function projectDiagnostic(output, layout2, files) {
|
|
17217
17565
|
const base = layout2.multi ? layout2.root : layout2.sources;
|
|
17218
|
-
const prefix = `${base}${
|
|
17566
|
+
const prefix = `${base}${import_node_path28.default.sep}`;
|
|
17219
17567
|
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
17568
|
}
|
|
17221
17569
|
var ROOT_LOCKS = Symbol.for("peachsim.swiftCompile.rootLocks");
|
|
@@ -17251,13 +17599,13 @@ function serialize(root, work, signal) {
|
|
|
17251
17599
|
function readCompiledArtifact(directory, hash) {
|
|
17252
17600
|
try {
|
|
17253
17601
|
const receipt = JSON.parse(
|
|
17254
|
-
(0,
|
|
17602
|
+
(0, import_node_fs26.readFileSync)(import_node_path28.default.join(directory, "artifact.json"), "utf8")
|
|
17255
17603
|
);
|
|
17256
17604
|
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
17605
|
return null;
|
|
17258
|
-
const bytes = (0,
|
|
17259
|
-
const gzip2 = (0,
|
|
17260
|
-
if ((0,
|
|
17606
|
+
const bytes = (0, import_node_fs26.readFileSync)(import_node_path28.default.join(directory, "app.wasm"));
|
|
17607
|
+
const gzip2 = (0, import_node_fs26.readFileSync)(import_node_path28.default.join(directory, "icu.gz"));
|
|
17608
|
+
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
17609
|
return null;
|
|
17262
17610
|
return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 } };
|
|
17263
17611
|
} catch (error) {
|
|
@@ -17267,25 +17615,25 @@ function readCompiledArtifact(directory, hash) {
|
|
|
17267
17615
|
}
|
|
17268
17616
|
}
|
|
17269
17617
|
function saveCompiledArtifact(root, artifact) {
|
|
17270
|
-
const directory =
|
|
17271
|
-
(0,
|
|
17272
|
-
const pending = (0,
|
|
17618
|
+
const directory = import_node_path28.default.join(root, "artifact");
|
|
17619
|
+
(0, import_node_fs26.mkdirSync)(directory, { recursive: true });
|
|
17620
|
+
const pending = (0, import_node_fs26.mkdtempSync)(import_node_path28.default.join(root, ".artifact-"));
|
|
17273
17621
|
try {
|
|
17274
|
-
(0,
|
|
17275
|
-
(0,
|
|
17276
|
-
(0,
|
|
17277
|
-
|
|
17622
|
+
(0, import_node_fs26.writeFileSync)(import_node_path28.default.join(pending, "app.wasm"), artifact.bytes);
|
|
17623
|
+
(0, import_node_fs26.writeFileSync)(import_node_path28.default.join(pending, "icu.gz"), artifact.icu.gzip);
|
|
17624
|
+
(0, import_node_fs26.writeFileSync)(
|
|
17625
|
+
import_node_path28.default.join(pending, "artifact.json"),
|
|
17278
17626
|
JSON.stringify({
|
|
17279
17627
|
hash: artifact.hash,
|
|
17280
|
-
wasm: (0,
|
|
17628
|
+
wasm: (0, import_node_crypto15.createHash)("sha256").update(artifact.bytes).digest("hex"),
|
|
17281
17629
|
icu: artifact.icu.sha256
|
|
17282
17630
|
})
|
|
17283
17631
|
);
|
|
17284
17632
|
for (const file of ["app.wasm", "icu.gz", "artifact.json"]) {
|
|
17285
|
-
(0,
|
|
17633
|
+
(0, import_node_fs26.renameSync)(import_node_path28.default.join(pending, file), import_node_path28.default.join(directory, file));
|
|
17286
17634
|
}
|
|
17287
17635
|
} finally {
|
|
17288
|
-
(0,
|
|
17636
|
+
(0, import_node_fs26.rmSync)(pending, { recursive: true, force: true });
|
|
17289
17637
|
}
|
|
17290
17638
|
}
|
|
17291
17639
|
var SHARED_ARTIFACT_BUDGET_BYTES = 4 * 1024 ** 3;
|
|
@@ -17296,29 +17644,29 @@ function vanished(error) {
|
|
|
17296
17644
|
}
|
|
17297
17645
|
function renewSharedArtifact(sharedRoot) {
|
|
17298
17646
|
try {
|
|
17299
|
-
(0,
|
|
17647
|
+
(0, import_node_fs26.utimesSync)(sharedRoot, /* @__PURE__ */ new Date(), /* @__PURE__ */ new Date());
|
|
17300
17648
|
} catch (error) {
|
|
17301
17649
|
if (!vanished(error)) throw error;
|
|
17302
17650
|
}
|
|
17303
17651
|
}
|
|
17304
17652
|
function pruneSharedArtifacts(parent, keep) {
|
|
17305
17653
|
const entries = [];
|
|
17306
|
-
for (const name2 of (0,
|
|
17307
|
-
const directory =
|
|
17654
|
+
for (const name2 of (0, import_node_fs26.readdirSync)(parent)) {
|
|
17655
|
+
const directory = import_node_path28.default.join(parent, name2);
|
|
17308
17656
|
if (name2.startsWith(RETIRED_PREFIX)) {
|
|
17309
17657
|
reapRetiredCacheDirectory(parent, name2);
|
|
17310
17658
|
continue;
|
|
17311
17659
|
}
|
|
17312
17660
|
try {
|
|
17313
17661
|
let bytes = 0;
|
|
17314
|
-
for (const file of (0,
|
|
17662
|
+
for (const file of (0, import_node_fs26.readdirSync)(import_node_path28.default.join(directory, "artifact"))) {
|
|
17315
17663
|
try {
|
|
17316
|
-
bytes += (0,
|
|
17664
|
+
bytes += (0, import_node_fs26.statSync)(import_node_path28.default.join(directory, "artifact", file)).size;
|
|
17317
17665
|
} catch (error) {
|
|
17318
17666
|
if (!vanished(error)) throw error;
|
|
17319
17667
|
}
|
|
17320
17668
|
}
|
|
17321
|
-
entries.push({ directory, used: (0,
|
|
17669
|
+
entries.push({ directory, used: (0, import_node_fs26.statSync)(directory).mtimeMs, bytes });
|
|
17322
17670
|
} catch (error) {
|
|
17323
17671
|
if (!vanished(error)) throw error;
|
|
17324
17672
|
}
|
|
@@ -17328,13 +17676,13 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
17328
17676
|
if (total <= SHARED_ARTIFACT_BUDGET_BYTES) break;
|
|
17329
17677
|
if (entry.directory === keep || Date.now() - entry.used < SHARED_ARTIFACT_GRACE_MS)
|
|
17330
17678
|
continue;
|
|
17331
|
-
const retired =
|
|
17679
|
+
const retired = import_node_path28.default.join(
|
|
17332
17680
|
parent,
|
|
17333
|
-
`${RETIRED_PREFIX}${process.pid}-${
|
|
17681
|
+
`${RETIRED_PREFIX}${process.pid}-${import_node_path28.default.basename(entry.directory)}`
|
|
17334
17682
|
);
|
|
17335
17683
|
try {
|
|
17336
|
-
if ((0,
|
|
17337
|
-
(0,
|
|
17684
|
+
if ((0, import_node_fs26.statSync)(entry.directory).mtimeMs !== entry.used) continue;
|
|
17685
|
+
(0, import_node_fs26.renameSync)(entry.directory, retired);
|
|
17338
17686
|
} catch (error) {
|
|
17339
17687
|
if (vanished(error)) continue;
|
|
17340
17688
|
throw error;
|
|
@@ -17346,7 +17694,7 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
17346
17694
|
function saveSharedArtifact(sharedRoot, artifact) {
|
|
17347
17695
|
saveCompiledArtifact(sharedRoot, artifact);
|
|
17348
17696
|
renewSharedArtifact(sharedRoot);
|
|
17349
|
-
pruneSharedArtifacts(
|
|
17697
|
+
pruneSharedArtifacts(import_node_path28.default.dirname(sharedRoot), sharedRoot);
|
|
17350
17698
|
}
|
|
17351
17699
|
var retainedArtifacts = /* @__PURE__ */ new Map();
|
|
17352
17700
|
function retain(root, artifact) {
|
|
@@ -17374,7 +17722,7 @@ function frameworkLibraryTargets(manifest) {
|
|
|
17374
17722
|
}
|
|
17375
17723
|
function linkedFrameworkTargets(moduleRoot, input) {
|
|
17376
17724
|
const libraries = frameworkLibraryTargets(
|
|
17377
|
-
(0,
|
|
17725
|
+
(0, import_node_fs26.readFileSync)(import_node_path28.default.join(moduleRoot, "Package.swift"), "utf8")
|
|
17378
17726
|
);
|
|
17379
17727
|
const targets = compileTargets(input);
|
|
17380
17728
|
const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
|
|
@@ -17397,7 +17745,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
17397
17745
|
for (const name2 of [...siblings.values()].flat())
|
|
17398
17746
|
if (libraries.has(name2) && !planning.some((target) => target.name === name2))
|
|
17399
17747
|
reach(name2);
|
|
17400
|
-
const manifest = (0,
|
|
17748
|
+
const manifest = (0, import_node_fs26.readFileSync)(import_node_path28.default.join(moduleRoot, "Package.swift"), "utf8");
|
|
17401
17749
|
const targetDependencies = /* @__PURE__ */ new Map();
|
|
17402
17750
|
for (const match of manifest.matchAll(
|
|
17403
17751
|
/\.target\(\s*name:\s*"([^"]+)"\s*,\s*dependencies:\s*\[([^\]]*)\]/g
|
|
@@ -17414,12 +17762,12 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
17414
17762
|
};
|
|
17415
17763
|
for (const name2 of reached)
|
|
17416
17764
|
for (const member of libraries.get(name2) ?? []) build(member);
|
|
17417
|
-
const overlays =
|
|
17418
|
-
for (const directory of (0,
|
|
17419
|
-
const companion =
|
|
17765
|
+
const overlays = import_node_path28.default.join(moduleRoot, "cross-import-overlays");
|
|
17766
|
+
for (const directory of (0, import_node_fs26.readdirSync)(overlays)) {
|
|
17767
|
+
const companion = import_node_path28.default.basename(directory, ".swiftcrossimport");
|
|
17420
17768
|
if (!built.has(companion)) continue;
|
|
17421
|
-
const declaration =
|
|
17422
|
-
for (const match of (0,
|
|
17769
|
+
const declaration = import_node_path28.default.join(overlays, directory, "SwiftUI.swiftoverlay");
|
|
17770
|
+
for (const match of (0, import_node_fs26.readFileSync)(declaration, "utf8").matchAll(
|
|
17423
17771
|
/^\s*- name: ([A-Za-z_]\w*)\s*$/gm
|
|
17424
17772
|
))
|
|
17425
17773
|
reach(match[1]);
|
|
@@ -17445,7 +17793,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
17445
17793
|
return { products: linked, targets: linkedMembers };
|
|
17446
17794
|
}
|
|
17447
17795
|
function writeFrameworkLinkPackage(linkRoot, moduleRoot, products) {
|
|
17448
|
-
const identity =
|
|
17796
|
+
const identity = import_node_path28.default.basename(moduleRoot).toLowerCase();
|
|
17449
17797
|
const swiftString = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
17450
17798
|
const dependencies = products.map(
|
|
17451
17799
|
(name2) => ` .product(name: ${swiftString(name2)}, package: ${swiftString(identity)}),`
|
|
@@ -17467,13 +17815,13 @@ ${dependencies}
|
|
|
17467
17815
|
]
|
|
17468
17816
|
)
|
|
17469
17817
|
`;
|
|
17470
|
-
const sourceDir =
|
|
17471
|
-
(0,
|
|
17472
|
-
const manifestPath =
|
|
17473
|
-
if (!(0,
|
|
17474
|
-
(0,
|
|
17475
|
-
const source =
|
|
17476
|
-
if (!(0,
|
|
17818
|
+
const sourceDir = import_node_path28.default.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
|
|
17819
|
+
(0, import_node_fs26.mkdirSync)(sourceDir, { recursive: true });
|
|
17820
|
+
const manifestPath = import_node_path28.default.join(linkRoot, "Package.swift");
|
|
17821
|
+
if (!(0, import_node_fs26.existsSync)(manifestPath) || (0, import_node_fs26.readFileSync)(manifestPath, "utf8") !== manifest)
|
|
17822
|
+
(0, import_node_fs26.writeFileSync)(manifestPath, manifest);
|
|
17823
|
+
const source = import_node_path28.default.join(sourceDir, "Link.swift");
|
|
17824
|
+
if (!(0, import_node_fs26.existsSync)(source)) (0, import_node_fs26.writeFileSync)(source, "");
|
|
17477
17825
|
}
|
|
17478
17826
|
function frameworkLinkClosure(scratch2, roots) {
|
|
17479
17827
|
const suffix = `${WASM_TRIPLE}-release`;
|
|
@@ -17484,7 +17832,7 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
17484
17832
|
const moduleMaps = /* @__PURE__ */ new Map();
|
|
17485
17833
|
let pending = null;
|
|
17486
17834
|
let compiling = null;
|
|
17487
|
-
for (const line of (0,
|
|
17835
|
+
for (const line of (0, import_node_fs26.readFileSync)(import_node_path28.default.join(scratch2, "release.yaml"), "utf8").split(
|
|
17488
17836
|
"\n"
|
|
17489
17837
|
)) {
|
|
17490
17838
|
const phony = phonyHeader.exec(line);
|
|
@@ -17548,7 +17896,7 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
17548
17896
|
owners.set(file, name2);
|
|
17549
17897
|
if (seen.has(file)) continue;
|
|
17550
17898
|
seen.add(file);
|
|
17551
|
-
if (!(0,
|
|
17899
|
+
if (!(0, import_node_fs26.existsSync)(file))
|
|
17552
17900
|
throw new Error(`swift-compile: framework object ${file} was not built`);
|
|
17553
17901
|
files.push(file);
|
|
17554
17902
|
}
|
|
@@ -17558,19 +17906,19 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
17558
17906
|
return { objects: files, owners, modules, moduleMaps: [...maps].sort() };
|
|
17559
17907
|
}
|
|
17560
17908
|
function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
|
|
17561
|
-
if (!(0,
|
|
17909
|
+
if (!(0, import_node_fs26.existsSync)(modulesDir)) return;
|
|
17562
17910
|
const folded = new Set([...keep].map((name2) => name2.toLowerCase()));
|
|
17563
|
-
for (const name2 of (0,
|
|
17911
|
+
for (const name2 of (0, import_node_fs26.readdirSync)(modulesDir)) {
|
|
17564
17912
|
const dot = name2.indexOf(".");
|
|
17565
17913
|
if (dot <= 0) continue;
|
|
17566
17914
|
const module2 = name2.slice(0, dot);
|
|
17567
17915
|
if (keep.has(module2) || !folded.has(module2.toLowerCase())) continue;
|
|
17568
|
-
(0,
|
|
17916
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(modulesDir, name2), { recursive: true, force: true });
|
|
17569
17917
|
}
|
|
17570
17918
|
}
|
|
17571
17919
|
async function buildFrameworkProducts(scratch2, args) {
|
|
17572
17920
|
const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input);
|
|
17573
|
-
const linkRoot =
|
|
17921
|
+
const linkRoot = import_node_path28.default.join(scratch2, "link");
|
|
17574
17922
|
writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products);
|
|
17575
17923
|
await runCompiler(
|
|
17576
17924
|
args.swift,
|
|
@@ -17603,7 +17951,7 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17603
17951
|
"-Xswiftc",
|
|
17604
17952
|
String(swiftBuildJobs()),
|
|
17605
17953
|
...swiftReproducibleBuildFlags([
|
|
17606
|
-
[
|
|
17954
|
+
[import_node_path28.default.dirname(args.toolchainBin), "toolchain"],
|
|
17607
17955
|
[args.moduleRoot, "framework"],
|
|
17608
17956
|
[scratch2, "framework-scratch"]
|
|
17609
17957
|
]),
|
|
@@ -17628,16 +17976,16 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17628
17976
|
).catch((error) => {
|
|
17629
17977
|
throw new Error(outputOf(error), { cause: error });
|
|
17630
17978
|
});
|
|
17631
|
-
const release =
|
|
17979
|
+
const release = import_node_path28.default.join(scratch2, WASM_TRIPLE, "release");
|
|
17632
17980
|
const linked = frameworkLinkClosure(scratch2, linkedTargets.targets);
|
|
17633
17981
|
const objects = linked.objects;
|
|
17634
17982
|
if (linked.modules.has("UniformTypeIdentifiers")) {
|
|
17635
|
-
const constantsDir =
|
|
17636
|
-
const constantsStamp =
|
|
17637
|
-
const object3 =
|
|
17638
|
-
if (!(0,
|
|
17639
|
-
(0,
|
|
17640
|
-
(0,
|
|
17983
|
+
const constantsDir = import_node_path28.default.join(scratch2, "uniform-type-constants");
|
|
17984
|
+
const constantsStamp = import_node_path28.default.join(constantsDir, ".complete");
|
|
17985
|
+
const object3 = import_node_path28.default.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
|
|
17986
|
+
if (!(0, import_node_fs26.existsSync)(constantsStamp) || (0, import_node_fs26.readFileSync)(constantsStamp, "utf8") !== args.frameworkKey) {
|
|
17987
|
+
(0, import_node_fs26.rmSync)(constantsDir, { recursive: true, force: true });
|
|
17988
|
+
(0, import_node_fs26.mkdirSync)(constantsDir);
|
|
17641
17989
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
17642
17990
|
compileUniformTypeConstants({
|
|
17643
17991
|
bin: args.toolchainBin,
|
|
@@ -17647,35 +17995,35 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17647
17995
|
minimum: darwinRecordsMinimum(),
|
|
17648
17996
|
out: constantsDir
|
|
17649
17997
|
});
|
|
17650
|
-
(0,
|
|
17998
|
+
(0, import_node_fs26.writeFileSync)(constantsStamp, args.frameworkKey);
|
|
17651
17999
|
}
|
|
17652
18000
|
objects.push(object3);
|
|
17653
18001
|
linked.owners.set(object3, "UniformTypeIdentifiers");
|
|
17654
18002
|
}
|
|
17655
|
-
removeCaseCollidingModuleArtifacts(
|
|
17656
|
-
const response =
|
|
17657
|
-
(0,
|
|
18003
|
+
removeCaseCollidingModuleArtifacts(import_node_path28.default.join(release, "Modules"), linked.modules);
|
|
18004
|
+
const response = import_node_path28.default.join(scratch2, "autolink-objects.rsp");
|
|
18005
|
+
(0, import_node_fs26.writeFileSync)(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
|
|
17658
18006
|
const extracted = await runCompiler(
|
|
17659
|
-
|
|
18007
|
+
import_node_path28.default.join(args.toolchainBin, "swift-autolink-extract"),
|
|
17660
18008
|
[`@${response}`, "-o", "-"],
|
|
17661
18009
|
args.buildOptions
|
|
17662
18010
|
);
|
|
17663
|
-
(0,
|
|
18011
|
+
(0, import_node_fs26.rmSync)(response, { force: true });
|
|
17664
18012
|
const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
|
|
17665
18013
|
if (link.includes("-lFoundation"))
|
|
17666
18014
|
for (const name2 of foundationCategoryObjects) {
|
|
17667
|
-
const object3 =
|
|
18015
|
+
const object3 = import_node_path28.default.join(
|
|
17668
18016
|
swiftSdkPaths(args.moduleRoot, args.toolchainBin).resources,
|
|
17669
18017
|
`wasi/${name2}.objc.o`
|
|
17670
18018
|
);
|
|
17671
18019
|
objects.push(object3);
|
|
17672
18020
|
linked.owners.set(object3, "Foundation");
|
|
17673
18021
|
}
|
|
17674
|
-
const providerDir =
|
|
17675
|
-
const providerStamp =
|
|
17676
|
-
if (!(0,
|
|
17677
|
-
(0,
|
|
17678
|
-
(0,
|
|
18022
|
+
const providerDir = import_node_path28.default.join(scratch2, "darwin-records");
|
|
18023
|
+
const providerStamp = import_node_path28.default.join(providerDir, ".complete");
|
|
18024
|
+
if (!(0, import_node_fs26.existsSync)(providerStamp) || (0, import_node_fs26.readFileSync)(providerStamp, "utf8") !== args.frameworkKey) {
|
|
18025
|
+
(0, import_node_fs26.rmSync)(providerDir, { recursive: true, force: true });
|
|
18026
|
+
(0, import_node_fs26.mkdirSync)(providerDir);
|
|
17679
18027
|
const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
|
|
17680
18028
|
compileDarwinRecords({
|
|
17681
18029
|
bin: args.toolchainBin,
|
|
@@ -17685,20 +18033,20 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
17685
18033
|
minimum: darwinRecordsMinimum(),
|
|
17686
18034
|
out: providerDir
|
|
17687
18035
|
});
|
|
17688
|
-
(0,
|
|
18036
|
+
(0, import_node_fs26.writeFileSync)(providerStamp, args.frameworkKey);
|
|
17689
18037
|
}
|
|
17690
|
-
const providers = (0,
|
|
18038
|
+
const providers = (0, import_node_fs26.readdirSync)(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => import_node_path28.default.join(providerDir, file));
|
|
17691
18039
|
for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
|
|
17692
|
-
const archive =
|
|
17693
|
-
(0,
|
|
17694
|
-
(0,
|
|
18040
|
+
const archive = import_node_path28.default.join(scratch2, "lib");
|
|
18041
|
+
(0, import_node_fs26.rmSync)(archive, { recursive: true, force: true });
|
|
18042
|
+
(0, import_node_fs26.mkdirSync)(archive);
|
|
17695
18043
|
const archived = /* @__PURE__ */ new Map();
|
|
17696
18044
|
for (const object3 of objects) {
|
|
17697
18045
|
const target = linked.owners.get(object3);
|
|
17698
|
-
const dir =
|
|
17699
|
-
if (!target || target === "Darwin" || !object3.startsWith(dir +
|
|
17700
|
-
const name2 = `${target}-${
|
|
17701
|
-
(0,
|
|
18046
|
+
const dir = import_node_path28.default.join(release, `${target}.build`);
|
|
18047
|
+
if (!target || target === "Darwin" || !object3.startsWith(dir + import_node_path28.default.sep)) continue;
|
|
18048
|
+
const name2 = `${target}-${import_node_path28.default.relative(dir, object3).replaceAll(import_node_path28.default.sep, "-").replace(/\.swift\.o$/, ".o")}`;
|
|
18049
|
+
(0, import_node_fs26.symlinkSync)(object3, import_node_path28.default.join(archive, name2));
|
|
17702
18050
|
archived.set(object3, `lib/${name2}`);
|
|
17703
18051
|
}
|
|
17704
18052
|
const roots = swiftObjcRootObjects(`${scratch2}
|
|
@@ -17707,11 +18055,11 @@ ${args.frameworkKey}`, scratch2, [
|
|
|
17707
18055
|
]);
|
|
17708
18056
|
const linkedObjects = objects.map((object3) => {
|
|
17709
18057
|
const name2 = archived.get(object3);
|
|
17710
|
-
return name2 ? { path:
|
|
18058
|
+
return name2 ? { path: import_node_path28.default.join(scratch2, name2), lazy: !roots.has(name2) } : { path: object3, lazy: false };
|
|
17711
18059
|
});
|
|
17712
18060
|
return {
|
|
17713
18061
|
root: scratch2,
|
|
17714
|
-
modules:
|
|
18062
|
+
modules: import_node_path28.default.join(release, "Modules"),
|
|
17715
18063
|
objects: linkedObjects.filter((object3) => !object3.lazy).map((object3) => object3.path),
|
|
17716
18064
|
lazyObjects: linkedObjects.filter((object3) => object3.lazy).map((object3) => object3.path),
|
|
17717
18065
|
owners: linked.owners,
|
|
@@ -17725,14 +18073,14 @@ var SWIFT_FRAMEWORK_SLOTS = 8;
|
|
|
17725
18073
|
var SWIFT_FRAMEWORK_SLOT_KEY = ".peach-framework-key";
|
|
17726
18074
|
var SWIFT_FRAMEWORK_SLOT_ORIGIN = ".peach-framework-origin";
|
|
17727
18075
|
function swiftFrameworksDir() {
|
|
17728
|
-
return
|
|
18076
|
+
return import_node_path28.default.join(swiftCacheDir(), "swift-frameworks");
|
|
17729
18077
|
}
|
|
17730
18078
|
function swiftFrameworkScratch(frameworkKey) {
|
|
17731
|
-
return
|
|
18079
|
+
return import_node_path28.default.join(swiftFrameworksDir(), frameworkKey);
|
|
17732
18080
|
}
|
|
17733
18081
|
function swiftFrameworkSlotRecord(slot, record) {
|
|
17734
18082
|
try {
|
|
17735
|
-
return (0,
|
|
18083
|
+
return (0, import_node_fs26.readFileSync)(import_node_path28.default.join(slot, record), "utf8").trim();
|
|
17736
18084
|
} catch (error) {
|
|
17737
18085
|
if (!vanished(error)) throw error;
|
|
17738
18086
|
return null;
|
|
@@ -17743,32 +18091,32 @@ function swiftFrameworkSlotKey(slot) {
|
|
|
17743
18091
|
}
|
|
17744
18092
|
async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
17745
18093
|
const slots = Array.from({ length: SWIFT_FRAMEWORK_SLOTS }, (_, index) => {
|
|
17746
|
-
const slot =
|
|
17747
|
-
(0,
|
|
18094
|
+
const slot = import_node_path28.default.join(swiftFrameworksDir(), `slot-${index}`);
|
|
18095
|
+
(0, import_node_fs26.mkdirSync)(slot, { recursive: true });
|
|
17748
18096
|
return slot;
|
|
17749
18097
|
});
|
|
17750
18098
|
const run2 = (slot) => (lease) => {
|
|
17751
18099
|
const now = /* @__PURE__ */ new Date();
|
|
17752
|
-
(0,
|
|
18100
|
+
(0, import_node_fs26.utimesSync)(slot, now, now);
|
|
17753
18101
|
return work(slot, lease);
|
|
17754
18102
|
};
|
|
17755
18103
|
const staged = slots.find((slot) => swiftFrameworkSlotKey(slot) === frameworkKey);
|
|
17756
18104
|
if (staged) return withSwiftRootLock(staged, run2(staged), signal);
|
|
17757
|
-
const built = new Map(slots.map((slot) => [slot, (0,
|
|
18105
|
+
const built = new Map(slots.map((slot) => [slot, (0, import_node_fs26.statSync)(slot).mtimeMs]));
|
|
17758
18106
|
const own = (slot) => swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN) === moduleRoot;
|
|
17759
18107
|
const inputs = new Map(
|
|
17760
18108
|
swiftModuleInputFiles(moduleRoot).map((file) => [
|
|
17761
18109
|
file,
|
|
17762
|
-
(0,
|
|
18110
|
+
(0, import_node_fs26.readFileSync)(import_node_path28.default.join(moduleRoot, file))
|
|
17763
18111
|
])
|
|
17764
18112
|
);
|
|
17765
18113
|
const ranked = slots.map((slot) => {
|
|
17766
18114
|
let changes = 0;
|
|
17767
18115
|
if (swiftFrameworkSlotKey(slot) === null) return { slot, changes: Infinity };
|
|
17768
|
-
const source =
|
|
18116
|
+
const source = import_node_path28.default.join(slot, "source", "packages", import_node_path28.default.basename(moduleRoot));
|
|
17769
18117
|
for (const [file, contents2] of inputs) {
|
|
17770
18118
|
try {
|
|
17771
|
-
if (!(0,
|
|
18119
|
+
if (!(0, import_node_fs26.readFileSync)(import_node_path28.default.join(source, file)).equals(contents2)) changes++;
|
|
17772
18120
|
} catch (error) {
|
|
17773
18121
|
if (!vanished(error)) throw error;
|
|
17774
18122
|
changes++;
|
|
@@ -17783,7 +18131,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
|
17783
18131
|
slot,
|
|
17784
18132
|
async (lease) => {
|
|
17785
18133
|
console.error(
|
|
17786
|
-
`[swift-framework-cache] ${
|
|
18134
|
+
`[swift-framework-cache] ${import_node_path28.default.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`
|
|
17787
18135
|
);
|
|
17788
18136
|
return { value: await run2(slot)(lease) };
|
|
17789
18137
|
},
|
|
@@ -17796,91 +18144,91 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
|
|
|
17796
18144
|
return withSwiftRootLock(nearest, run2(nearest), signal);
|
|
17797
18145
|
}
|
|
17798
18146
|
function mirrorTree2(source, target, skip) {
|
|
17799
|
-
(0,
|
|
18147
|
+
(0, import_node_fs26.mkdirSync)(target, { recursive: true });
|
|
17800
18148
|
const wanted = /* @__PURE__ */ new Set();
|
|
17801
18149
|
let restructured = false;
|
|
17802
|
-
for (const entry of (0,
|
|
18150
|
+
for (const entry of (0, import_node_fs26.readdirSync)(source, { withFileTypes: true })) {
|
|
17803
18151
|
if (entry.name === skip) continue;
|
|
17804
18152
|
wanted.add(entry.name);
|
|
17805
|
-
const from =
|
|
17806
|
-
const to =
|
|
18153
|
+
const from = import_node_path28.default.join(source, entry.name);
|
|
18154
|
+
const to = import_node_path28.default.join(target, entry.name);
|
|
17807
18155
|
let existing = null;
|
|
17808
18156
|
try {
|
|
17809
|
-
existing = (0,
|
|
18157
|
+
existing = (0, import_node_fs26.lstatSync)(to);
|
|
17810
18158
|
} catch (error) {
|
|
17811
18159
|
if (!vanished(error)) throw error;
|
|
17812
18160
|
}
|
|
17813
18161
|
if (!existing) restructured = true;
|
|
17814
18162
|
if (entry.isDirectory()) {
|
|
17815
|
-
if (existing && !existing.isDirectory()) (0,
|
|
18163
|
+
if (existing && !existing.isDirectory()) (0, import_node_fs26.rmSync)(to, { force: true });
|
|
17816
18164
|
if (mirrorTree2(from, to)) restructured = true;
|
|
17817
18165
|
} else if (entry.isSymbolicLink()) {
|
|
17818
|
-
const link = (0,
|
|
17819
|
-
if (existing?.isSymbolicLink() && (0,
|
|
17820
|
-
if (existing) (0,
|
|
17821
|
-
(0,
|
|
18166
|
+
const link = (0, import_node_fs26.readlinkSync)(from);
|
|
18167
|
+
if (existing?.isSymbolicLink() && (0, import_node_fs26.readlinkSync)(to) === link) continue;
|
|
18168
|
+
if (existing) (0, import_node_fs26.rmSync)(to, { recursive: true, force: true });
|
|
18169
|
+
(0, import_node_fs26.symlinkSync)(link, to);
|
|
17822
18170
|
} else {
|
|
17823
|
-
const stat = (0,
|
|
17824
|
-
if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs || (0,
|
|
18171
|
+
const stat = (0, import_node_fs26.statSync)(from);
|
|
18172
|
+
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
18173
|
continue;
|
|
17826
|
-
if (existing) (0,
|
|
17827
|
-
const partial = `${to}.${(0,
|
|
17828
|
-
(0,
|
|
17829
|
-
(0,
|
|
17830
|
-
(0,
|
|
18174
|
+
if (existing) (0, import_node_fs26.rmSync)(to, { recursive: true, force: true });
|
|
18175
|
+
const partial = `${to}.${(0, import_node_crypto15.randomUUID)()}`;
|
|
18176
|
+
(0, import_node_fs26.copyFileSync)(from, partial);
|
|
18177
|
+
(0, import_node_fs26.utimesSync)(partial, stat.atime, stat.mtime);
|
|
18178
|
+
(0, import_node_fs26.renameSync)(partial, to);
|
|
17831
18179
|
}
|
|
17832
18180
|
}
|
|
17833
|
-
for (const name2 of (0,
|
|
18181
|
+
for (const name2 of (0, import_node_fs26.readdirSync)(target))
|
|
17834
18182
|
if (!wanted.has(name2) && name2 !== skip) {
|
|
17835
|
-
(0,
|
|
18183
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(target, name2), { recursive: true, force: true });
|
|
17836
18184
|
restructured = true;
|
|
17837
18185
|
}
|
|
17838
18186
|
return restructured;
|
|
17839
18187
|
}
|
|
17840
18188
|
function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
17841
18189
|
if (!slot) return moduleRoot;
|
|
17842
|
-
const staged =
|
|
17843
|
-
const stagedModule =
|
|
18190
|
+
const staged = import_node_path28.default.join(slot, "source");
|
|
18191
|
+
const stagedModule = import_node_path28.default.join(staged, "packages", import_node_path28.default.basename(moduleRoot));
|
|
17844
18192
|
if (swiftFrameworkSlotKey(slot) !== frameworkKey) {
|
|
17845
|
-
(0,
|
|
18193
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
|
|
17846
18194
|
const moduleRestructured = mirrorTree2(moduleRoot, stagedModule, ".build");
|
|
17847
18195
|
const sdkRestructured = mirrorTree2(
|
|
17848
18196
|
swiftSharedSdkRoot(moduleRoot, false),
|
|
17849
|
-
|
|
18197
|
+
import_node_path28.default.join(staged, "packages/peachsim/sdk/ios")
|
|
17850
18198
|
);
|
|
17851
18199
|
if (moduleRestructured || sdkRestructured) {
|
|
17852
|
-
(0,
|
|
17853
|
-
(0,
|
|
18200
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(slot, "release.yaml"), { force: true });
|
|
18201
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(slot, "release", "description.json"), { force: true });
|
|
17854
18202
|
}
|
|
17855
18203
|
for (const file of swiftModuleInputFiles(moduleRoot)) {
|
|
17856
18204
|
if (!file.startsWith("../")) continue;
|
|
17857
|
-
const from =
|
|
17858
|
-
const to =
|
|
17859
|
-
if ((0,
|
|
17860
|
-
(0,
|
|
17861
|
-
(0,
|
|
18205
|
+
const from = import_node_path28.default.resolve(moduleRoot, file);
|
|
18206
|
+
const to = import_node_path28.default.resolve(stagedModule, file);
|
|
18207
|
+
if ((0, import_node_fs26.existsSync)(to) && (0, import_node_fs26.readFileSync)(from).equals((0, import_node_fs26.readFileSync)(to))) continue;
|
|
18208
|
+
(0, import_node_fs26.mkdirSync)(import_node_path28.default.dirname(to), { recursive: true });
|
|
18209
|
+
(0, import_node_fs26.copyFileSync)(from, to);
|
|
17862
18210
|
}
|
|
17863
18211
|
if (swiftProjectBuildKey(stagedModule, release) !== frameworkKey)
|
|
17864
18212
|
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,
|
|
18213
|
+
const modules = import_node_path28.default.join(staged, "node_modules");
|
|
18214
|
+
const target = (0, import_node_fs26.realpathSync)(import_node_path28.default.join(moduleRoot, "../../node_modules"));
|
|
18215
|
+
if (!(0, import_node_fs26.existsSync)(modules) || (0, import_node_fs26.readlinkSync)(modules) !== target) {
|
|
18216
|
+
(0, import_node_fs26.rmSync)(modules, { recursive: true, force: true });
|
|
18217
|
+
(0, import_node_fs26.symlinkSync)(target, modules);
|
|
17870
18218
|
}
|
|
17871
|
-
(0,
|
|
17872
|
-
(0,
|
|
18219
|
+
(0, import_node_fs26.writeFileSync)(import_node_path28.default.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
|
|
18220
|
+
(0, import_node_fs26.writeFileSync)(import_node_path28.default.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
|
|
17873
18221
|
}
|
|
17874
18222
|
return stagedModule;
|
|
17875
18223
|
}
|
|
17876
18224
|
function swiftLinkStamp(args) {
|
|
17877
|
-
const hash = (0,
|
|
18225
|
+
const hash = (0, import_node_crypto15.createHash)("sha256");
|
|
17878
18226
|
hash.update(`swift-link/v1
|
|
17879
18227
|
${args.frameworkKey}
|
|
17880
18228
|
`);
|
|
17881
18229
|
if (!args.prebuilt) return hash.digest("hex");
|
|
17882
18230
|
const statOf = (file) => {
|
|
17883
|
-
const stat = (0,
|
|
18231
|
+
const stat = (0, import_node_fs26.statSync)(file, { bigint: true });
|
|
17884
18232
|
return `${stat.size}:${stat.mtimeNs}`;
|
|
17885
18233
|
};
|
|
17886
18234
|
for (const object3 of args.prebuilt.objects)
|
|
@@ -17905,25 +18253,25 @@ ${args.prebuilt.link.join("\n")}
|
|
|
17905
18253
|
hash.update(`modules
|
|
17906
18254
|
${args.prebuilt.modules}
|
|
17907
18255
|
`);
|
|
17908
|
-
for (const entry of (0,
|
|
18256
|
+
for (const entry of (0, import_node_fs26.readdirSync)(args.prebuilt.modules).sort())
|
|
17909
18257
|
hash.update(`${entry}
|
|
17910
|
-
${statOf(
|
|
18258
|
+
${statOf(import_node_path28.default.join(args.prebuilt.modules, entry))}`);
|
|
17911
18259
|
return hash.digest("hex");
|
|
17912
18260
|
}
|
|
17913
18261
|
function retireStaleSwiftLink(root, stamp) {
|
|
17914
|
-
const receipt =
|
|
18262
|
+
const receipt = import_node_path28.default.join(root, SWIFT_LINK_STAMP);
|
|
17915
18263
|
let previous = null;
|
|
17916
18264
|
try {
|
|
17917
|
-
previous = (0,
|
|
18265
|
+
previous = (0, import_node_fs26.readFileSync)(receipt, "utf8").trim();
|
|
17918
18266
|
} catch (error) {
|
|
17919
18267
|
if (!vanished(error)) throw error;
|
|
17920
18268
|
}
|
|
17921
|
-
(0,
|
|
17922
|
-
(0,
|
|
18269
|
+
(0, import_node_fs26.mkdirSync)(root, { recursive: true });
|
|
18270
|
+
(0, import_node_fs26.writeFileSync)(receipt, `${stamp}
|
|
17923
18271
|
`);
|
|
17924
|
-
const retired =
|
|
17925
|
-
if (previous === stamp || !(0,
|
|
17926
|
-
(0,
|
|
18272
|
+
const retired = import_node_path28.default.join(root, ".build");
|
|
18273
|
+
if (previous === stamp || !(0, import_node_fs26.existsSync)(retired)) return false;
|
|
18274
|
+
(0, import_node_fs26.rmSync)(retired, { recursive: true, force: true });
|
|
17927
18275
|
return true;
|
|
17928
18276
|
}
|
|
17929
18277
|
async function compileSwiftProjectUnit(input, options) {
|
|
@@ -17938,21 +18286,21 @@ async function compileSwiftProjectUnit(input, options) {
|
|
|
17938
18286
|
}
|
|
17939
18287
|
function compileSwiftProjectOnce(input, options) {
|
|
17940
18288
|
options.signal?.throwIfAborted();
|
|
17941
|
-
(0,
|
|
17942
|
-
const root = (0,
|
|
17943
|
-
const moduleRoot =
|
|
18289
|
+
(0, import_node_fs26.mkdirSync)(options.buildRoot, { recursive: true });
|
|
18290
|
+
const root = (0, import_node_fs26.realpathSync)(options.buildRoot);
|
|
18291
|
+
const moduleRoot = import_node_path28.default.resolve(options.moduleRoot);
|
|
17944
18292
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
17945
18293
|
const guestGraph = distribution ? input.sourceLinkGraph : void 0;
|
|
17946
18294
|
if (options.linkOnly && guestGraph)
|
|
17947
18295
|
throw new Error("swift-compile: link-only builds do not support guest image graphs");
|
|
17948
18296
|
const layout2 = {
|
|
17949
18297
|
root,
|
|
17950
|
-
sources:
|
|
18298
|
+
sources: import_node_path28.default.join(root, "Sources", "App"),
|
|
17951
18299
|
multi: compileTargets(input).length > 0
|
|
17952
18300
|
};
|
|
17953
18301
|
const hash = swiftArtifactHash(input, options.release, moduleRoot);
|
|
17954
18302
|
const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
|
|
17955
|
-
const sharedRoot =
|
|
18303
|
+
const sharedRoot = import_node_path28.default.join(swiftCacheDir(), "swift-projects", hash);
|
|
17956
18304
|
const report = (message) => {
|
|
17957
18305
|
console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
|
|
17958
18306
|
options.onStage?.(message);
|
|
@@ -17967,8 +18315,8 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
17967
18315
|
report("reusing memory artifact");
|
|
17968
18316
|
return retain(root, retained);
|
|
17969
18317
|
}
|
|
17970
|
-
const cached = readCompiledArtifact(
|
|
17971
|
-
const previous = cached ?? (options.project ? null : readCompiledArtifact(
|
|
18318
|
+
const cached = readCompiledArtifact(import_node_path28.default.join(sharedRoot, "artifact"), hash);
|
|
18319
|
+
const previous = cached ?? (options.project ? null : readCompiledArtifact(import_node_path28.default.join(root, "artifact"), hash));
|
|
17972
18320
|
if (previous) {
|
|
17973
18321
|
if (cached) renewSharedArtifact(sharedRoot);
|
|
17974
18322
|
else saveSharedArtifact(sharedRoot, previous);
|
|
@@ -17977,10 +18325,10 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
17977
18325
|
}
|
|
17978
18326
|
}
|
|
17979
18327
|
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,
|
|
18328
|
+
const requestRoot = (0, import_node_fs26.mkdtempSync)(`${root}.builder-request-`);
|
|
18329
|
+
const output = import_node_path28.default.join(requestRoot, "output");
|
|
18330
|
+
const request = import_node_path28.default.join(requestRoot, "request.json");
|
|
18331
|
+
(0, import_node_fs26.writeFileSync)(
|
|
17984
18332
|
request,
|
|
17985
18333
|
JSON.stringify({
|
|
17986
18334
|
input,
|
|
@@ -17993,12 +18341,12 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
17993
18341
|
})
|
|
17994
18342
|
);
|
|
17995
18343
|
try {
|
|
17996
|
-
const repo =
|
|
18344
|
+
const repo = import_node_path28.default.resolve(moduleRoot, "../..");
|
|
17997
18345
|
report("requesting builder admission or cached result");
|
|
17998
18346
|
await runCompiler(
|
|
17999
18347
|
"bun",
|
|
18000
18348
|
[
|
|
18001
|
-
|
|
18349
|
+
import_node_path28.default.join(repo, "scripts/build/swift-project.ts"),
|
|
18002
18350
|
"--request",
|
|
18003
18351
|
request,
|
|
18004
18352
|
"--output",
|
|
@@ -18026,7 +18374,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18026
18374
|
report("builder artifact verified");
|
|
18027
18375
|
return retain(root, artifact);
|
|
18028
18376
|
} finally {
|
|
18029
|
-
(0,
|
|
18377
|
+
(0, import_node_fs26.rmSync)(requestRoot, { recursive: true, force: true });
|
|
18030
18378
|
}
|
|
18031
18379
|
}
|
|
18032
18380
|
return withSwiftCompileBudget(options.timeoutMs, options.signal, async (budget) => {
|
|
@@ -18034,14 +18382,14 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18034
18382
|
root,
|
|
18035
18383
|
async (lease) => {
|
|
18036
18384
|
if (!options.intermediates) {
|
|
18037
|
-
const built = readCompiledArtifact(
|
|
18385
|
+
const built = readCompiledArtifact(import_node_path28.default.join(sharedRoot, "artifact"), hash);
|
|
18038
18386
|
if (built) {
|
|
18039
18387
|
report("reusing verified disk artifact");
|
|
18040
18388
|
return retain(root, built);
|
|
18041
18389
|
}
|
|
18042
18390
|
}
|
|
18043
|
-
const swift =
|
|
18044
|
-
if (!(0,
|
|
18391
|
+
const swift = import_node_path28.default.join(options.toolchainBin, "swift");
|
|
18392
|
+
if (!(0, import_node_fs26.existsSync)(swift)) {
|
|
18045
18393
|
throw new Error(
|
|
18046
18394
|
`swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
|
|
18047
18395
|
);
|
|
@@ -18075,8 +18423,8 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18075
18423
|
// shipped host plugins resolve against the selected compiler's runtime.
|
|
18076
18424
|
...process.platform === "linux" ? {
|
|
18077
18425
|
LD_LIBRARY_PATH: [
|
|
18078
|
-
|
|
18079
|
-
|
|
18426
|
+
import_node_path28.default.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
18427
|
+
import_node_path28.default.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
18080
18428
|
process.env.LD_LIBRARY_PATH
|
|
18081
18429
|
].filter(Boolean).join(":")
|
|
18082
18430
|
} : {},
|
|
@@ -18115,21 +18463,22 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18115
18463
|
layout2,
|
|
18116
18464
|
input,
|
|
18117
18465
|
frameworkRoot,
|
|
18118
|
-
prebuilt
|
|
18466
|
+
prebuilt,
|
|
18467
|
+
!options.project
|
|
18119
18468
|
);
|
|
18120
|
-
const productFile =
|
|
18469
|
+
const productFile = import_node_path28.default.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
|
|
18121
18470
|
writeSwiftAutolinkLinker(
|
|
18122
18471
|
root,
|
|
18123
18472
|
options.toolchainBin,
|
|
18124
|
-
(0,
|
|
18473
|
+
(0, import_node_fs26.existsSync)(productFile) ? [
|
|
18125
18474
|
v5.parse(
|
|
18126
18475
|
swiftFrameworkProductSchema,
|
|
18127
|
-
JSON.parse((0,
|
|
18476
|
+
JSON.parse((0, import_node_fs26.readFileSync)(productFile, "utf8"))
|
|
18128
18477
|
).product.name
|
|
18129
18478
|
] : []
|
|
18130
18479
|
);
|
|
18131
18480
|
const projectProcess = options.project ? prepareSwiftProjectProcess(root, options.project) : void 0;
|
|
18132
|
-
const compiler = preparation.targetToolset ? { CC:
|
|
18481
|
+
const compiler = preparation.targetToolset ? { CC: import_node_path28.default.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
|
|
18133
18482
|
const appOptions = projectProcess ? {
|
|
18134
18483
|
...buildOptions,
|
|
18135
18484
|
uid: projectProcess.uid,
|
|
@@ -18143,10 +18492,10 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18143
18492
|
for (const [file, text2] of Object.entries(input.files)) {
|
|
18144
18493
|
const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text2)?.[1];
|
|
18145
18494
|
if (!parents) continue;
|
|
18146
|
-
const directory =
|
|
18495
|
+
const directory = import_node_path28.default.posix.dirname(file);
|
|
18147
18496
|
forwarders.set(
|
|
18148
|
-
`${
|
|
18149
|
-
|
|
18497
|
+
`${import_node_path28.default.join(root, directory)}/${parents.slice(0, -1)}`,
|
|
18498
|
+
import_node_path28.default.posix.join("build", directory, parents).replace(/\/$/, "")
|
|
18150
18499
|
);
|
|
18151
18500
|
}
|
|
18152
18501
|
const buildArgs = [
|
|
@@ -18162,7 +18511,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18162
18511
|
...swiftObjCSelectorOptions(frameworkRoot),
|
|
18163
18512
|
"--swift-sdk",
|
|
18164
18513
|
sdk,
|
|
18165
|
-
...preparation.targetToolset ? ["--toolset",
|
|
18514
|
+
...preparation.targetToolset ? ["--toolset", import_node_path28.default.join(root, ".peach-target-toolset.json")] : [],
|
|
18166
18515
|
"-c",
|
|
18167
18516
|
"release",
|
|
18168
18517
|
// the link strips debug info, so none is generated (as for the framework)
|
|
@@ -18173,21 +18522,21 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18173
18522
|
"-Xswiftc",
|
|
18174
18523
|
String(swiftBuildJobs()),
|
|
18175
18524
|
...swiftReproducibleBuildFlags([
|
|
18176
|
-
[
|
|
18525
|
+
[import_node_path28.default.dirname(options.toolchainBin), "toolchain"],
|
|
18177
18526
|
[frameworkRoot, "framework"],
|
|
18178
18527
|
[root, "build"],
|
|
18179
18528
|
...forwarders
|
|
18180
18529
|
]).flatMap((flag, index, flags) => {
|
|
18181
18530
|
if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
|
|
18182
18531
|
return [flag];
|
|
18183
|
-
const toolchainDir =
|
|
18532
|
+
const toolchainDir = import_node_path28.default.dirname(options.toolchainBin);
|
|
18184
18533
|
let mapped = flag;
|
|
18185
18534
|
for (const [dir, target] of [
|
|
18186
18535
|
[root, "/peach/build"],
|
|
18187
18536
|
[frameworkRoot, "/peach/framework"],
|
|
18188
|
-
[(0,
|
|
18537
|
+
[(0, import_node_fs26.realpathSync)(frameworkRoot), "/peach/framework"],
|
|
18189
18538
|
[toolchainDir, "/peach/toolchain"],
|
|
18190
|
-
[(0,
|
|
18539
|
+
[(0, import_node_fs26.realpathSync)(toolchainDir), "/peach/toolchain"]
|
|
18191
18540
|
]) {
|
|
18192
18541
|
mapped = mapped.replaceAll(dir, target);
|
|
18193
18542
|
}
|
|
@@ -18209,9 +18558,9 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18209
18558
|
])
|
|
18210
18559
|
];
|
|
18211
18560
|
const linked = builtArtifact(layout2);
|
|
18212
|
-
(0,
|
|
18213
|
-
if (options.linkOnly || (0,
|
|
18214
|
-
(0,
|
|
18561
|
+
(0, import_node_fs26.rmSync)(import_node_path28.default.join(root, ".peach-link.rsp"), { force: true });
|
|
18562
|
+
if (options.linkOnly || (0, import_node_fs26.existsSync)(linked) && (0, import_node_fs26.statSync)(linked).size <= 8)
|
|
18563
|
+
(0, import_node_fs26.rmSync)(linked, { force: true });
|
|
18215
18564
|
report("compiling and linking Swift modules");
|
|
18216
18565
|
const frameworkInterfaces = /* @__PURE__ */ new Map();
|
|
18217
18566
|
const nativeDeclarations = /* @__PURE__ */ new Map();
|
|
@@ -18221,58 +18570,58 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18221
18570
|
const name2 = moduleMapName(contents2);
|
|
18222
18571
|
const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
|
|
18223
18572
|
if (!name2 || !umbrella) continue;
|
|
18224
|
-
const header = input.files[
|
|
18573
|
+
const header = input.files[import_node_path28.default.posix.join(import_node_path28.default.posix.dirname(file), umbrella)];
|
|
18225
18574
|
if (header === void 0) continue;
|
|
18226
18575
|
const included = new Set(
|
|
18227
18576
|
[
|
|
18228
18577
|
...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
|
|
18229
|
-
].map((match) =>
|
|
18578
|
+
].map((match) => import_node_path28.default.posix.basename(match[1]))
|
|
18230
18579
|
);
|
|
18231
18580
|
const declarations = nativeDeclarations.get(name2) ?? /* @__PURE__ */ new Set();
|
|
18232
18581
|
for (const declaration of swiftInterfaceDeclarations(header))
|
|
18233
18582
|
declarations.add(declaration);
|
|
18234
18583
|
for (const [candidate, source] of Object.entries(input.files))
|
|
18235
|
-
if (included.has(
|
|
18584
|
+
if (included.has(import_node_path28.default.posix.basename(candidate)))
|
|
18236
18585
|
for (const declaration of swiftInterfaceDeclarations(source))
|
|
18237
18586
|
declarations.add(declaration);
|
|
18238
18587
|
nativeDeclarations.set(name2, declarations);
|
|
18239
18588
|
}
|
|
18240
18589
|
const frameworkInterface = (name2) => {
|
|
18241
18590
|
if (frameworkInterfaces.has(name2)) return frameworkInterfaces.get(name2);
|
|
18242
|
-
const source = distribution ?
|
|
18591
|
+
const source = distribution ? import_node_path28.default.join(frameworkRoot, "modules", `${name2}-Swift.h`) : import_node_path28.default.join(
|
|
18243
18592
|
prebuilt.modules,
|
|
18244
18593
|
"..",
|
|
18245
18594
|
`${name2}.build/include/${name2}-Swift.h`
|
|
18246
18595
|
);
|
|
18247
|
-
if (!(0,
|
|
18596
|
+
if (!(0, import_node_fs26.existsSync)(source)) {
|
|
18248
18597
|
frameworkInterfaces.set(name2, null);
|
|
18249
18598
|
return null;
|
|
18250
18599
|
}
|
|
18251
|
-
const headers =
|
|
18600
|
+
const headers = import_node_path28.default.join(
|
|
18252
18601
|
swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
|
|
18253
18602
|
`System/Library/Frameworks/${name2}.framework/Headers`
|
|
18254
18603
|
);
|
|
18255
18604
|
const declared = /* @__PURE__ */ new Set();
|
|
18256
|
-
if ((0,
|
|
18257
|
-
for (const file of (0,
|
|
18605
|
+
if ((0, import_node_fs26.existsSync)(headers)) {
|
|
18606
|
+
for (const file of (0, import_node_fs26.readdirSync)(headers, {
|
|
18258
18607
|
recursive: true,
|
|
18259
18608
|
encoding: "utf8"
|
|
18260
18609
|
}))
|
|
18261
18610
|
if (file.endsWith(".h"))
|
|
18262
18611
|
for (const name3 of swiftInterfaceDeclarations(
|
|
18263
|
-
(0,
|
|
18612
|
+
(0, import_node_fs26.readFileSync)(import_node_path28.default.join(headers, file), "utf8")
|
|
18264
18613
|
))
|
|
18265
18614
|
declared.add(name3);
|
|
18266
18615
|
}
|
|
18267
18616
|
for (const declaration of nativeDeclarations.get(name2) ?? [])
|
|
18268
18617
|
declared.add(declaration);
|
|
18269
18618
|
const own = withoutSwiftDeclarations(
|
|
18270
|
-
clangInterfaceHeader((0,
|
|
18619
|
+
clangInterfaceHeader((0, import_node_fs26.readFileSync)(source, "utf8")),
|
|
18271
18620
|
declared,
|
|
18272
18621
|
nativeDeclarations.has(name2) ? `@import ${name2};` : `#import <${name2}/${name2}.h>`
|
|
18273
18622
|
);
|
|
18274
18623
|
const owners = sdkObjCDeclarationOwners(
|
|
18275
|
-
|
|
18624
|
+
import_node_path28.default.dirname(import_node_path28.default.dirname(headers))
|
|
18276
18625
|
);
|
|
18277
18626
|
const foreign = /* @__PURE__ */ new Map();
|
|
18278
18627
|
for (const declaration of [
|
|
@@ -18291,117 +18640,140 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18291
18640
|
[...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
|
|
18292
18641
|
) : own;
|
|
18293
18642
|
const value = {
|
|
18294
|
-
file:
|
|
18643
|
+
file: import_node_path28.default.join(root, ".build/peach-framework-objc", `${name2}-Swift.h`),
|
|
18295
18644
|
header,
|
|
18296
|
-
module: (0,
|
|
18645
|
+
module: (0, import_node_fs26.existsSync)(headers)
|
|
18297
18646
|
};
|
|
18298
18647
|
frameworkInterfaces.set(name2, value);
|
|
18299
18648
|
writeBuildFile(
|
|
18300
18649
|
value.file,
|
|
18301
|
-
((0,
|
|
18650
|
+
((0, import_node_fs26.existsSync)(import_node_path28.default.join(headers, `${name2}.h`)) ? `#import <${name2}/${name2}.h>
|
|
18302
18651
|
` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
|
|
18303
18652
|
);
|
|
18304
18653
|
return value;
|
|
18305
18654
|
};
|
|
18306
|
-
const
|
|
18655
|
+
const headerPaths = (producer) => {
|
|
18656
|
+
const stem = import_node_path28.default.join(
|
|
18657
|
+
root,
|
|
18658
|
+
".build",
|
|
18659
|
+
"peach-cxx-headers",
|
|
18660
|
+
`${producer}-Swift`
|
|
18661
|
+
);
|
|
18662
|
+
return { producer, original: `${stem}.original.h`, emitted: `${stem}.h` };
|
|
18663
|
+
};
|
|
18664
|
+
const publishHeader = ({
|
|
18665
|
+
producer,
|
|
18666
|
+
original,
|
|
18667
|
+
emitted
|
|
18668
|
+
}) => {
|
|
18669
|
+
const generated = clangInterfaceHeader((0, import_node_fs26.readFileSync)(original, "utf8"));
|
|
18670
|
+
writeBuildFile(
|
|
18671
|
+
emitted,
|
|
18672
|
+
withoutSwiftDeclarations(
|
|
18673
|
+
swiftHeaderWithSuperclassImports(generated, frameworkInterface),
|
|
18674
|
+
/* @__PURE__ */ new Set([
|
|
18675
|
+
...preparation.nativeHeaderDeclarations[producer] ?? [],
|
|
18676
|
+
...nativelyDeclaredFunctions(generated, nativeHeaders)
|
|
18677
|
+
]),
|
|
18678
|
+
`#import <${producer}/${producer}.h>`
|
|
18679
|
+
)
|
|
18680
|
+
);
|
|
18681
|
+
};
|
|
18682
|
+
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");
|
|
18683
|
+
const runApp = async (compiler2) => {
|
|
18684
|
+
const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
|
|
18307
18685
|
const stages = [
|
|
18308
18686
|
...preparation.headerBuilds,
|
|
18309
18687
|
...preparation.nativeProductTarget ? [{ target: preparation.nativeProductTarget, producers: [] }] : []
|
|
18310
18688
|
];
|
|
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");
|
|
18689
|
+
const checkpoints = import_node_path28.default.join(root, ".build", "peach-product-checkpoints");
|
|
18313
18690
|
for (const { target, producers } of stages) {
|
|
18314
|
-
const receipt =
|
|
18691
|
+
const receipt = import_node_path28.default.join(
|
|
18315
18692
|
checkpoints,
|
|
18316
|
-
(0,
|
|
18693
|
+
(0, import_node_crypto15.createHash)("sha256").update(target).digest("hex")
|
|
18317
18694
|
);
|
|
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
|
-
});
|
|
18695
|
+
const headers = producers.map(headerPaths);
|
|
18331
18696
|
const fingerprint = () => {
|
|
18332
|
-
const digest = (0,
|
|
18333
|
-
for (const { emitted } of headers) {
|
|
18334
|
-
if (!(0,
|
|
18697
|
+
const digest = (0, import_node_crypto15.createHash)("sha256").update(recipe);
|
|
18698
|
+
for (const { original, emitted } of headers) {
|
|
18699
|
+
if (!(0, import_node_fs26.existsSync)(original) || !(0, import_node_fs26.existsSync)(emitted)) return;
|
|
18335
18700
|
digest.update(
|
|
18336
|
-
(0,
|
|
18701
|
+
(0, import_node_crypto15.createHash)("sha256").update((0, import_node_fs26.readFileSync)(emitted)).digest()
|
|
18337
18702
|
);
|
|
18338
18703
|
}
|
|
18339
18704
|
return digest.digest("hex");
|
|
18340
18705
|
};
|
|
18341
|
-
if (!options.project && (0,
|
|
18706
|
+
if (!options.project && (0, import_node_fs26.existsSync)(receipt) && (0, import_node_fs26.readFileSync)(receipt, "utf8") === fingerprint())
|
|
18342
18707
|
continue;
|
|
18343
|
-
if (!options.project) (0,
|
|
18344
|
-
for (const
|
|
18345
|
-
if (
|
|
18346
|
-
|
|
18347
|
-
|
|
18348
|
-
|
|
18349
|
-
|
|
18350
|
-
WASM_TRIPLE,
|
|
18351
|
-
"release",
|
|
18708
|
+
if (!options.project) (0, import_node_fs26.rmSync)(receipt, { force: true });
|
|
18709
|
+
for (const header of headers) {
|
|
18710
|
+
if (compiler2 && (0, import_node_fs26.existsSync)(header.original)) publishHeader(header);
|
|
18711
|
+
if (!(0, import_node_fs26.existsSync)(header.original))
|
|
18712
|
+
(0, import_node_fs26.rmSync)(
|
|
18713
|
+
import_node_path28.default.join(
|
|
18714
|
+
import_node_path28.default.dirname(linked),
|
|
18352
18715
|
"Modules",
|
|
18353
|
-
`${swiftTargetModuleName(producer)}.swiftmodule`
|
|
18716
|
+
`${swiftTargetModuleName(header.producer)}.swiftmodule`
|
|
18354
18717
|
),
|
|
18355
18718
|
{ force: true }
|
|
18356
18719
|
);
|
|
18720
|
+
}
|
|
18357
18721
|
await runCompiler(
|
|
18358
18722
|
swift,
|
|
18359
18723
|
[...buildArgs, "--target", target],
|
|
18360
|
-
|
|
18724
|
+
optionsWithCompiler,
|
|
18361
18725
|
SWIFTPM_PROGRESS,
|
|
18362
18726
|
SWIFTPM_NOISE
|
|
18363
18727
|
);
|
|
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
|
-
}
|
|
18728
|
+
if (!compiler2) for (const header of headers) publishHeader(header);
|
|
18378
18729
|
if (!options.project) {
|
|
18379
|
-
|
|
18380
|
-
|
|
18381
|
-
|
|
18730
|
+
const checkpoint = fingerprint();
|
|
18731
|
+
if (checkpoint === void 0)
|
|
18732
|
+
throw new Error(`missing Swift headers after building ${target}`);
|
|
18733
|
+
(0, import_node_fs26.mkdirSync)(checkpoints, { recursive: true });
|
|
18734
|
+
(0, import_node_fs26.writeFileSync)(`${receipt}.partial`, checkpoint);
|
|
18735
|
+
(0, import_node_fs26.renameSync)(`${receipt}.partial`, receipt);
|
|
18382
18736
|
}
|
|
18383
18737
|
}
|
|
18384
18738
|
await runCompiler(
|
|
18385
18739
|
swift,
|
|
18386
18740
|
buildArgs,
|
|
18387
|
-
|
|
18741
|
+
optionsWithCompiler,
|
|
18388
18742
|
SWIFTPM_PROGRESS,
|
|
18389
18743
|
SWIFTPM_NOISE
|
|
18390
18744
|
);
|
|
18391
18745
|
};
|
|
18746
|
+
const compileApp = () => preparation.headerCompiler ? withSwiftHeaderCompiler(
|
|
18747
|
+
root,
|
|
18748
|
+
options.toolchainBin,
|
|
18749
|
+
recipe,
|
|
18750
|
+
new Map(
|
|
18751
|
+
preparation.headerBuilds[0].producers.map((producer) => {
|
|
18752
|
+
const paths = headerPaths(producer);
|
|
18753
|
+
return [
|
|
18754
|
+
swiftTargetModuleName(producer),
|
|
18755
|
+
{
|
|
18756
|
+
header: paths.original,
|
|
18757
|
+
publish: () => publishHeader(paths)
|
|
18758
|
+
}
|
|
18759
|
+
];
|
|
18760
|
+
})
|
|
18761
|
+
),
|
|
18762
|
+
runApp
|
|
18763
|
+
) : runApp();
|
|
18392
18764
|
try {
|
|
18393
18765
|
await compileApp();
|
|
18394
18766
|
} catch (error) {
|
|
18395
18767
|
const output2 = outputOf(error);
|
|
18396
|
-
const moduleCache =
|
|
18768
|
+
const moduleCache = import_node_path28.default.join(
|
|
18397
18769
|
root,
|
|
18398
18770
|
".build",
|
|
18399
18771
|
WASM_TRIPLE,
|
|
18400
18772
|
"release",
|
|
18401
18773
|
"ModuleCache"
|
|
18402
18774
|
);
|
|
18403
|
-
if (output2.includes("was compiled with module cache path") && (0,
|
|
18404
|
-
(0,
|
|
18775
|
+
if (output2.includes("was compiled with module cache path") && (0, import_node_fs26.existsSync)(moduleCache)) {
|
|
18776
|
+
(0, import_node_fs26.rmSync)(moduleCache, { recursive: true, force: true });
|
|
18405
18777
|
try {
|
|
18406
18778
|
await compileApp();
|
|
18407
18779
|
} catch (retryError) {
|
|
@@ -18425,11 +18797,11 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18425
18797
|
if (options.project) endSwiftProjectProcesses(options.project);
|
|
18426
18798
|
}
|
|
18427
18799
|
if (unprepared.length) throw new Error(unprepared.join("\n"));
|
|
18428
|
-
if (!(0,
|
|
18429
|
-
const binDir =
|
|
18430
|
-
const found = (0,
|
|
18800
|
+
if (!(0, import_node_fs26.existsSync)(linked)) {
|
|
18801
|
+
const binDir = import_node_path28.default.dirname(linked);
|
|
18802
|
+
const found = (0, import_node_fs26.existsSync)(binDir) ? (0, import_node_fs26.readdirSync)(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
|
|
18431
18803
|
throw new Error(
|
|
18432
|
-
`swift-compile: the build produced no ${
|
|
18804
|
+
`swift-compile: the build produced no ${import_node_path28.default.basename(linked)} (found: ${found.join(", ") || "none"})`
|
|
18433
18805
|
);
|
|
18434
18806
|
}
|
|
18435
18807
|
if (options.project) removeProjectLinks(root);
|
|
@@ -18447,7 +18819,7 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18447
18819
|
resourceReferences
|
|
18448
18820
|
);
|
|
18449
18821
|
if (options.linkOnly) {
|
|
18450
|
-
if ((0,
|
|
18822
|
+
if ((0, import_node_fs26.statSync)(linked).size <= 8)
|
|
18451
18823
|
throw new Error("swift-compile: deferred linker produced no executable");
|
|
18452
18824
|
report("project link verified");
|
|
18453
18825
|
return;
|
|
@@ -18458,9 +18830,10 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18458
18830
|
await compileGuestLink({
|
|
18459
18831
|
graph: guestGraph,
|
|
18460
18832
|
buildDirectory: root,
|
|
18461
|
-
releaseDirectory:
|
|
18833
|
+
releaseDirectory: import_node_path28.default.dirname(linked),
|
|
18462
18834
|
moduleRoot: frameworkRoot,
|
|
18463
18835
|
toolchainBin: options.toolchainBin,
|
|
18836
|
+
swiftCompiler: preparation.headerCompiler ? import_node_path28.default.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : import_node_path28.default.join(options.toolchainBin, "swiftc"),
|
|
18464
18837
|
sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
|
|
18465
18838
|
sdk: swiftModuleSdk(frameworkRoot),
|
|
18466
18839
|
staticClangTargets: input.staticClangTargets ?? [],
|
|
@@ -18473,13 +18846,13 @@ function compileSwiftProjectOnce(input, options) {
|
|
|
18473
18846
|
else
|
|
18474
18847
|
await lowerWasm(output, optimized, { optimize: input.optimize === true });
|
|
18475
18848
|
await runCompiler(
|
|
18476
|
-
|
|
18849
|
+
import_node_path28.default.join(options.toolchainBin, "llvm-objcopy"),
|
|
18477
18850
|
["--remove-section=.swift1_autolink_entries", optimized],
|
|
18478
18851
|
buildOptions
|
|
18479
18852
|
);
|
|
18480
18853
|
const artifact = {
|
|
18481
18854
|
hash,
|
|
18482
|
-
bytes: (0,
|
|
18855
|
+
bytes: (0, import_node_fs26.readFileSync)(optimized),
|
|
18483
18856
|
icu: await icu
|
|
18484
18857
|
};
|
|
18485
18858
|
if (artifact.bytes.length <= 8)
|