peachsim 0.1.2605 → 0.1.2607
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/package.ts +71 -39
- package/cli/commands/perf-native.ts +259 -6
- package/cli/commands/shell-url.ts +1 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +2 -2
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +5 -5
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +3 -3
- package/dist-lib/bundle-channel.cjs +1520 -932
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +3 -3
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +3 -3
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +2 -2
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +7 -7
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +5 -5
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-UNOYFUKI.mjs → acorn-KFWXYMX5.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-WSRPZF7M.mjs → chunk-6JPUMAC2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-M4G5YUO7.mjs → chunk-6NDABMDX.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-GT54N3GG.mjs → chunk-7SKDPTZN.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-FXONOT2L.mjs → chunk-ACAXWH62.mjs} +1 -1
- package/dist-lib/esm-chunks/chunk-ARYRQJUB.mjs +326 -0
- package/dist-lib/esm-chunks/{chunk-WB2EBX5Q.mjs → chunk-BNAXRY5Q.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-AST6VA7D.mjs → chunk-CA64UUHF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-B54SPDLA.mjs → chunk-DBW62F4N.mjs} +3 -2
- package/dist-lib/esm-chunks/{chunk-7K33ENH6.mjs → chunk-ESS2CG5G.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-LFN7VAPB.mjs → chunk-IGSLOAPL.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-RJCM34J7.mjs → chunk-KIIALACX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-YO756PYQ.mjs → chunk-LJZ373SO.mjs} +819 -681
- package/dist-lib/esm-chunks/{chunk-VRQPEROV.mjs → chunk-M4ORY3NH.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3XUIDCBF.mjs → chunk-MBWWOGI5.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-M3V4F5OV.mjs → chunk-O5BPZVLB.mjs} +5 -5
- package/dist-lib/esm-chunks/chunk-P5Q5QCTP.mjs +32 -0
- package/dist-lib/esm-chunks/{chunk-O55DZ2EL.mjs → chunk-QJUAWJDB.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-HHS4A7GI.mjs → chunk-RIDXKGBZ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-LG76KUUO.mjs → chunk-TD2DBEKQ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-AYHTHFG4.mjs → chunk-UTSB5CDG.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-UPUOCALX.mjs → chunk-WMWOBH7E.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-6TE7WLSF.mjs → chunk-ZNGLVJYL.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-YRBZCLVD.mjs → metro-layout-parser-UY3B6VGU.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-S7KR6TKE.mjs → swift-package-prebuilt-HDHPWS44.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-3JNA7PCB.mjs → swift-sdk-app-module-U6G5RZV2.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-3P4IUP2A.mjs → swift-sdk-image-PVDA2MVM.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-EA2RYBM4.mjs → swift-sdk-image-producer-YHPS3KNR.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +1519 -931
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +7 -7
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +1677 -947
- package/dist-lib/host/fetch-proxy-handler.cjs +44 -37
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +3 -3
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +3 -3
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +4 -4
- package/dist-lib/native-app-identity-project.cjs +540 -247
- package/dist-lib/native-app-identity-project.mjs +218 -1828
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +6 -6
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +3 -3
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +2 -2
- package/dist-lib/plist.cjs +327 -15
- package/dist-lib/plist.mjs +13 -5
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +82 -129
- package/dist-lib/public-origins-lib.json +69 -140
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +2 -2
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +211 -3
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +8 -8
- package/dist-lib/skills.cjs +1693 -963
- package/dist-lib/swift-compile.cjs +812 -673
- package/dist-lib/swift-compile.mjs +10 -10
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +3 -3
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +6 -6
- package/dist-lib/swift-svg-raster.cjs +1 -1
- package/dist-lib/swift-svg-raster.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +3 -2
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
- package/dist-lib/vendor/acorn.cjs +1 -1
- package/dist-lib/vendor/magic-string.cjs +1 -1
- package/dist-lib/vendor/stream-json.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
- package/dist-lib/vendor/sucrase.cjs +1 -1
- package/dist-lib/vendor/terser.cjs +1 -1
- package/dist-lib/vendor/valibot.cjs +1 -1
- package/dist-lib/vendor/ws.cjs +1 -1
- package/dist-lib/vendor/zod.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +3 -3
- package/dist-types/packages/peach-engine/src/ios/apps/canvas-map-data.d.ts +38 -2
- package/dist-types/packages/peach-globals/src/canvasAgentContract.d.ts +8 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
- package/package.json +1 -6
- package/src/agent-prompt.ts +5 -1
- package/src/bazel-project.ts +1 -1
- package/src/expo-native-prebuilt.ts +1 -1
- package/src/expo-workspace-exclusion.ts +1 -1
- package/src/gitignore.ts +175 -0
- package/src/intent-definition/plist-reader.ts +22 -168
- package/src/one-native-controls-package.ts +143 -1
- package/src/oneNativeControlsContract.ts +1 -0
- package/src/plist-bytes.ts +144 -2
- package/src/plist.ts +359 -2
- package/src/swift-compile-budget.ts +28 -7
- package/src/swift-compile.ts +972 -809
- package/src/swift-guest-compile.ts +3 -0
- package/src/swift-toolchain.ts +4 -1
- package/src/xcode-project.ts +1 -1
- package/dist-lib/esm-chunks/chunk-OW4VRQKO.mjs +0 -10993
- package/dist-lib/esm-chunks/chunk-ZSHGFGW7.mjs +0 -65
- package/dist-lib/vendor/@xmldom/xmldom.cjs +0 -6481
- package/dist-lib/vendor/bplist-parser.cjs +0 -1589
- package/dist-lib/vendor/ignore.cjs +0 -455
- package/dist-lib/vendor/plist.cjs +0 -10978
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2607 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
import {
|
|
3
3
|
SWIFT_AUTOLINK_LINKER,
|
|
4
4
|
SWIFT_CACHE_HOLD_MARKER,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
windowAdmission,
|
|
22
22
|
withSwiftRootLock,
|
|
23
23
|
writeSwiftAutolinkLinker
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-DBW62F4N.mjs";
|
|
25
25
|
import {
|
|
26
26
|
SWIFT_BINARY_TREES_DIR,
|
|
27
27
|
SWIFT_NATIVE_INPUT_ROOT,
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
isSwiftResourcePath,
|
|
37
37
|
isSwiftSourceLinkGraph,
|
|
38
38
|
swiftProjectFilesProblems
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-TD2DBEKQ.mjs";
|
|
40
40
|
import {
|
|
41
41
|
OBJC_RESOURCE_ACCESSOR_BODY,
|
|
42
42
|
OBJC_RESOURCE_ACCESSOR_HEADER,
|
|
@@ -60,16 +60,16 @@ import {
|
|
|
60
60
|
swiftPackagePartition,
|
|
61
61
|
swiftTargetModuleName,
|
|
62
62
|
withoutGlogModuleMap
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-7SKDPTZN.mjs";
|
|
64
64
|
import {
|
|
65
65
|
rnxPublicBrand
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-RIDXKGBZ.mjs";
|
|
67
67
|
import {
|
|
68
68
|
isRecord
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-M4ORY3NH.mjs";
|
|
70
70
|
import {
|
|
71
71
|
__publicField
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-P5Q5QCTP.mjs";
|
|
73
73
|
|
|
74
74
|
// src/swift-compile.ts
|
|
75
75
|
import {
|
|
@@ -2779,24 +2779,37 @@ function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
|
|
|
2779
2779
|
async function withSwiftCompileBudget(compileTimeoutMs, signal, work) {
|
|
2780
2780
|
const deadline = new AbortController();
|
|
2781
2781
|
const combined = signal ? AbortSignal.any([signal, deadline.signal]) : deadline.signal;
|
|
2782
|
+
const stallMs = compileTimeoutMs ?? SWIFT_COMPILE_TIMEOUT_MS;
|
|
2783
|
+
let compiling = false;
|
|
2782
2784
|
let timer = setTimeout(
|
|
2783
2785
|
() => deadline.abort(new Error("Swift build lock wait timed out")),
|
|
2784
2786
|
SWIFT_LOCK_WAIT_TIMEOUT_MS
|
|
2785
2787
|
);
|
|
2788
|
+
const restart = () => {
|
|
2789
|
+
clearTimeout(timer);
|
|
2790
|
+
timer = setTimeout(
|
|
2791
|
+
() => deadline.abort(
|
|
2792
|
+
new Error(
|
|
2793
|
+
`Swift compilation made no progress for ${Math.round(stallMs / 1e3)}s`
|
|
2794
|
+
)
|
|
2795
|
+
),
|
|
2796
|
+
stallMs
|
|
2797
|
+
);
|
|
2798
|
+
};
|
|
2786
2799
|
try {
|
|
2787
2800
|
combined.throwIfAborted();
|
|
2788
2801
|
const result = await work({
|
|
2789
2802
|
signal: combined,
|
|
2790
2803
|
startCompile() {
|
|
2791
2804
|
combined.throwIfAborted();
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
);
|
|
2805
|
+
compiling = true;
|
|
2806
|
+
restart();
|
|
2807
|
+
},
|
|
2808
|
+
progress() {
|
|
2809
|
+
if (compiling && !deadline.signal.aborted) restart();
|
|
2797
2810
|
}
|
|
2798
2811
|
});
|
|
2799
|
-
|
|
2812
|
+
signal?.throwIfAborted();
|
|
2800
2813
|
return result;
|
|
2801
2814
|
} finally {
|
|
2802
2815
|
clearTimeout(timer);
|
|
@@ -15032,7 +15045,7 @@ async function compileGuestLink(options) {
|
|
|
15032
15045
|
};
|
|
15033
15046
|
const sdk = options.sdkImage;
|
|
15034
15047
|
const sdkCallers = sdk?.sdkInterface.guestCallers;
|
|
15035
|
-
const sdkObjects = sdk ? (await import("./swift-sdk-image-
|
|
15048
|
+
const sdkObjects = sdk ? (await import("./swift-sdk-image-PVDA2MVM.mjs")).readSwiftSdkManifestIndex(sdk).guestObjects : void 0;
|
|
15036
15049
|
if (sdk && (!sdkCallers || !sdkObjects))
|
|
15037
15050
|
throw new Error("the SDK image has no guest link manifest");
|
|
15038
15051
|
const result = await linkPrunedGuestImages({
|
|
@@ -15328,7 +15341,7 @@ async function compileGuestLink(options) {
|
|
|
15328
15341
|
linkSwiftAppModule,
|
|
15329
15342
|
readSwiftSdkUsage,
|
|
15330
15343
|
swiftSdkProjectionSpans
|
|
15331
|
-
} = await import("./swift-sdk-app-module-
|
|
15344
|
+
} = await import("./swift-sdk-app-module-U6G5RZV2.mjs");
|
|
15332
15345
|
const project = options.project;
|
|
15333
15346
|
const work = project ? mkdtempSync2(path24.join(directory, "app-module-")) : path24.join(directory, "app-module");
|
|
15334
15347
|
if (project) chownSync(work, project.uid, project.gid);
|
|
@@ -15442,6 +15455,7 @@ async function compileGuestLink(options) {
|
|
|
15442
15455
|
);
|
|
15443
15456
|
continue;
|
|
15444
15457
|
}
|
|
15458
|
+
options.onStage("lowering the app image");
|
|
15445
15459
|
const lowerPromise = link.lower();
|
|
15446
15460
|
await new Promise((resolve) => setImmediate(resolve));
|
|
15447
15461
|
let binding;
|
|
@@ -15472,6 +15486,7 @@ async function compileGuestLink(options) {
|
|
|
15472
15486
|
return binding;
|
|
15473
15487
|
}
|
|
15474
15488
|
}
|
|
15489
|
+
options.onStage("lowering the app image");
|
|
15475
15490
|
await lowerWasm(options.output, options.optimized, {
|
|
15476
15491
|
optimize: options.optimize,
|
|
15477
15492
|
skipPasses: ["duplicate-function-elimination"],
|
|
@@ -16733,8 +16748,18 @@ async function runCompiler(command, args, options, stream = false, quiet) {
|
|
|
16733
16748
|
void stopping.catch(() => {
|
|
16734
16749
|
});
|
|
16735
16750
|
};
|
|
16751
|
+
const restartTimeout = () => {
|
|
16752
|
+
if (!options.timeout) return;
|
|
16753
|
+
clearTimeout(timeout);
|
|
16754
|
+
timeout = setTimeout(() => {
|
|
16755
|
+
failure = new Error(`Swift compiler was silent for ${options.timeout}ms`);
|
|
16756
|
+
stop();
|
|
16757
|
+
}, options.timeout);
|
|
16758
|
+
};
|
|
16736
16759
|
for (const name of ["stdout", "stderr"]) {
|
|
16737
16760
|
child[name].on("data", (bytes) => {
|
|
16761
|
+
restartTimeout();
|
|
16762
|
+
options.onOutput?.();
|
|
16738
16763
|
if (stream === true) process[name].write(bytes);
|
|
16739
16764
|
else if (stream) {
|
|
16740
16765
|
const lines = (partial[name] + bytes.toString()).split("\n");
|
|
@@ -16783,11 +16808,7 @@ async function runCompiler(command, args, options, stream = false, quiet) {
|
|
|
16783
16808
|
resolve(Buffer.concat(chunks.stdout).toString());
|
|
16784
16809
|
}
|
|
16785
16810
|
});
|
|
16786
|
-
|
|
16787
|
-
timeout = setTimeout(() => {
|
|
16788
|
-
failure = new Error("Swift compiler timed out");
|
|
16789
|
-
stop();
|
|
16790
|
-
}, options.timeout);
|
|
16811
|
+
restartTimeout();
|
|
16791
16812
|
if (signal?.aborted) stop();
|
|
16792
16813
|
});
|
|
16793
16814
|
} finally {
|
|
@@ -18058,7 +18079,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
|
|
|
18058
18079
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
18059
18080
|
var MULTI_MANIFEST_VERSION = 76;
|
|
18060
18081
|
var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
18061
|
-
var compilerSourceDigest = true ? "
|
|
18082
|
+
var compilerSourceDigest = true ? "203439fc20df8d328b0c245496fc6db90092265409adb61b593725e82ce837de" : swiftCompilerSourceDigest(import.meta.dirname);
|
|
18062
18083
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
18063
18084
|
return swiftCompileInputHash(input, release).update(swiftModuleDigest(moduleRoot)).digest("hex");
|
|
18064
18085
|
}
|
|
@@ -20116,7 +20137,6 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
20116
20137
|
(left, right) => right.path.length - left.path.length
|
|
20117
20138
|
);
|
|
20118
20139
|
const targetsByDir = indexTargetsByDirectory(bySourcePath);
|
|
20119
|
-
const targetByName = new Map(targets.map((target) => [target.name, target]));
|
|
20120
20140
|
const nativeTargets = input.nativeTargets ?? [];
|
|
20121
20141
|
const nativeTargetByName = new Map(nativeTargets.map((target) => [target.name, target]));
|
|
20122
20142
|
const nativeTargetIndex = new Map(
|
|
@@ -20192,7 +20212,6 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
20192
20212
|
checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
|
|
20193
20213
|
return checkedToolchain;
|
|
20194
20214
|
};
|
|
20195
|
-
const deploymentTarget = (name) => nativeTargetByName.get(name)?.deploymentTarget ?? targetByName.get(name)?.iosDeploymentTarget ?? null;
|
|
20196
20215
|
const targetStagedFiles = /* @__PURE__ */ new Map();
|
|
20197
20216
|
const stageTargetFile = (target, file, contents2, options) => {
|
|
20198
20217
|
const relative = path33.relative(layout2.root, file).split(path33.sep).join(path33.posix.sep);
|
|
@@ -21267,7 +21286,7 @@ ${entry}`);
|
|
|
21267
21286
|
};
|
|
21268
21287
|
for (const target of targets) {
|
|
21269
21288
|
if (!target.executable && !reachesNative(target.name)) continue;
|
|
21270
|
-
const version2 =
|
|
21289
|
+
const version2 = nativeTargetByName.get(target.name)?.deploymentTarget ?? target.iosDeploymentTarget ?? null;
|
|
21271
21290
|
const minimum = iosDeploymentMinimum(version2);
|
|
21272
21291
|
if (minimum === void 0)
|
|
21273
21292
|
throw new Error(
|
|
@@ -22376,6 +22395,7 @@ function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
|
|
|
22376
22395
|
}
|
|
22377
22396
|
}
|
|
22378
22397
|
var frameworkProductsReceiptSchema = object({
|
|
22398
|
+
root: string(),
|
|
22379
22399
|
modules: string(),
|
|
22380
22400
|
objects: array(string()),
|
|
22381
22401
|
lazyObjects: array(string()),
|
|
@@ -22398,24 +22418,18 @@ function readFrameworkProductsReceipt(scratch, receiptKey) {
|
|
|
22398
22418
|
} catch {
|
|
22399
22419
|
return null;
|
|
22400
22420
|
}
|
|
22401
|
-
const
|
|
22402
|
-
|
|
22403
|
-
const archiveMatches = existsSync9(archiveStamp) && readFileSync16(archiveStamp, "utf8") === receiptKey;
|
|
22421
|
+
const archiveRoot = path33.join(scratch, "products-lib", receiptKey);
|
|
22422
|
+
if (parsed.root !== archiveRoot) return null;
|
|
22404
22423
|
if (!existsSync9(parsed.modules)) return null;
|
|
22405
|
-
for (const [object2] of parsed.archived)
|
|
22424
|
+
for (const [object2, rel] of parsed.archived) {
|
|
22425
|
+
if (!existsSync9(object2) || !existsSync9(path33.join(archiveRoot, rel))) return null;
|
|
22426
|
+
}
|
|
22406
22427
|
for (const file of parsed.providers) if (!existsSync9(file)) return null;
|
|
22407
22428
|
for (const file of parsed.moduleMaps) if (!existsSync9(file)) return null;
|
|
22408
|
-
if (!archiveMatches) {
|
|
22409
|
-
rmSync7(archive, { recursive: true, force: true });
|
|
22410
|
-
mkdirSync8(archive, { recursive: true });
|
|
22411
|
-
for (const [object2, rel] of parsed.archived)
|
|
22412
|
-
symlinkSync2(object2, path33.join(scratch, rel));
|
|
22413
|
-
writeFileSync8(archiveStamp, receiptKey);
|
|
22414
|
-
}
|
|
22415
22429
|
for (const file of parsed.objects) if (!existsSync9(file)) return null;
|
|
22416
22430
|
for (const file of parsed.lazyObjects) if (!existsSync9(file)) return null;
|
|
22417
22431
|
return {
|
|
22418
|
-
root:
|
|
22432
|
+
root: parsed.root,
|
|
22419
22433
|
modules: parsed.modules,
|
|
22420
22434
|
objects: parsed.objects,
|
|
22421
22435
|
lazyObjects: parsed.lazyObjects,
|
|
@@ -22433,7 +22447,7 @@ async function buildFrameworkProducts(scratch, args) {
|
|
|
22433
22447
|
const selectorOptions = swiftObjCSelectorOptions(args.moduleRoot);
|
|
22434
22448
|
const receiptKey = createHash18("sha256").update(
|
|
22435
22449
|
JSON.stringify([
|
|
22436
|
-
"framework-products/
|
|
22450
|
+
"framework-products/v2",
|
|
22437
22451
|
args.frameworkKey,
|
|
22438
22452
|
unoptimized,
|
|
22439
22453
|
args.sdk,
|
|
@@ -22591,28 +22605,40 @@ async function buildFrameworkProducts(scratch, args) {
|
|
|
22591
22605
|
}
|
|
22592
22606
|
const providers = readdirSync6(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path33.join(providerDir, file));
|
|
22593
22607
|
for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
|
|
22594
|
-
const
|
|
22595
|
-
|
|
22596
|
-
|
|
22608
|
+
const archiveBase = path33.join(scratch, "products-lib");
|
|
22609
|
+
mkdirSync8(archiveBase, { recursive: true });
|
|
22610
|
+
const archiveRoot = path33.join(archiveBase, receiptKey);
|
|
22611
|
+
const stagedArchiveRoot = `${archiveRoot}.tmp-${process.pid}-${randomUUID5()}`;
|
|
22612
|
+
const stagedArchive = path33.join(stagedArchiveRoot, "lib");
|
|
22613
|
+
mkdirSync8(stagedArchive, { recursive: true });
|
|
22597
22614
|
const archived = /* @__PURE__ */ new Map();
|
|
22598
|
-
|
|
22599
|
-
const
|
|
22600
|
-
|
|
22601
|
-
|
|
22602
|
-
|
|
22603
|
-
|
|
22604
|
-
|
|
22605
|
-
|
|
22606
|
-
|
|
22607
|
-
|
|
22608
|
-
|
|
22609
|
-
|
|
22615
|
+
try {
|
|
22616
|
+
for (const object2 of objects) {
|
|
22617
|
+
const target = linked.owners.get(object2);
|
|
22618
|
+
const dir = path33.join(release, `${target}.build`);
|
|
22619
|
+
if (!target || target === "Darwin" || !object2.startsWith(dir + path33.sep)) continue;
|
|
22620
|
+
const name = `${target}-${path33.relative(dir, object2).replaceAll(path33.sep, "-").replace(/\.swift\.o$/, ".o")}`;
|
|
22621
|
+
symlinkSync2(object2, path33.join(stagedArchive, name));
|
|
22622
|
+
archived.set(object2, `lib/${name}`);
|
|
22623
|
+
}
|
|
22624
|
+
rmSync7(archiveRoot, { recursive: true, force: true });
|
|
22625
|
+
renameSync5(stagedArchiveRoot, archiveRoot);
|
|
22626
|
+
} catch (error) {
|
|
22627
|
+
rmSync7(stagedArchiveRoot, { recursive: true, force: true });
|
|
22628
|
+
throw error;
|
|
22629
|
+
}
|
|
22630
|
+
const roots = swiftObjcRootObjects(
|
|
22631
|
+
`${archiveRoot}
|
|
22632
|
+
${args.frameworkKey}`,
|
|
22633
|
+
archiveRoot,
|
|
22634
|
+
[...archived.values()]
|
|
22635
|
+
);
|
|
22610
22636
|
const linkedObjects = objects.map((object2) => {
|
|
22611
22637
|
const name = archived.get(object2);
|
|
22612
|
-
return name ? { path: path33.join(
|
|
22638
|
+
return name ? { path: path33.join(archiveRoot, name), lazy: !roots.has(name) } : { path: object2, lazy: false };
|
|
22613
22639
|
});
|
|
22614
22640
|
const result = {
|
|
22615
|
-
root:
|
|
22641
|
+
root: archiveRoot,
|
|
22616
22642
|
modules: path33.join(release, "Modules"),
|
|
22617
22643
|
objects: linkedObjects.filter((object2) => !object2.lazy).map((object2) => object2.path),
|
|
22618
22644
|
lazyObjects: linkedObjects.filter((object2) => object2.lazy).map((object2) => object2.path),
|
|
@@ -22622,7 +22648,6 @@ ${args.frameworkKey}`, scratch, [
|
|
|
22622
22648
|
moduleMaps: linked.moduleMaps,
|
|
22623
22649
|
objcHeaders: linked.objcHeaders
|
|
22624
22650
|
};
|
|
22625
|
-
writeFileSync8(path33.join(archive, ".receipt"), receiptKey);
|
|
22626
22651
|
const receiptsDir = path33.join(scratch, "products-ready");
|
|
22627
22652
|
mkdirSync8(receiptsDir, { recursive: true });
|
|
22628
22653
|
const receiptFile = path33.join(receiptsDir, `${receiptKey}.json`);
|
|
@@ -22630,6 +22655,7 @@ ${args.frameworkKey}`, scratch, [
|
|
|
22630
22655
|
writeFileSync8(
|
|
22631
22656
|
partialReceipt,
|
|
22632
22657
|
JSON.stringify({
|
|
22658
|
+
root: result.root,
|
|
22633
22659
|
modules: result.modules,
|
|
22634
22660
|
objects: result.objects,
|
|
22635
22661
|
lazyObjects: result.lazyObjects,
|
|
@@ -22650,6 +22676,9 @@ var SWIFT_FRAMEWORK_SLOTS = 8;
|
|
|
22650
22676
|
var SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS = 4;
|
|
22651
22677
|
var SWIFT_FRAMEWORK_SLOT_KEY = ".peach-framework-key";
|
|
22652
22678
|
var SWIFT_FRAMEWORK_SLOT_ORIGIN = ".peach-framework-origin";
|
|
22679
|
+
var SWIFT_FRAMEWORK_SLOT_RELEASE = ".peach-framework-release";
|
|
22680
|
+
var SWIFT_BUILD_ROOT_SLOTS = 4;
|
|
22681
|
+
var SWIFT_BUILD_ROOT_SHAPE = ".peach-build-shape";
|
|
22653
22682
|
function swiftFrameworksDir(unoptimized = false) {
|
|
22654
22683
|
return path33.join(
|
|
22655
22684
|
swiftCacheDir(),
|
|
@@ -22667,7 +22696,10 @@ function swiftFrameworkSlotRecord(slot, record) {
|
|
|
22667
22696
|
function swiftFrameworkSlotKey(slot) {
|
|
22668
22697
|
return swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_KEY);
|
|
22669
22698
|
}
|
|
22670
|
-
|
|
22699
|
+
function swiftFrameworkSlotRelease(slot) {
|
|
22700
|
+
return swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_RELEASE);
|
|
22701
|
+
}
|
|
22702
|
+
async function withSwiftFrameworkSlot(frameworkKey, release, moduleRoot, signal, work, unoptimized = false) {
|
|
22671
22703
|
const slotCount = unoptimized ? SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS : SWIFT_FRAMEWORK_SLOTS;
|
|
22672
22704
|
const slotsDir = swiftFrameworksDir(unoptimized);
|
|
22673
22705
|
const slots = Array.from({ length: slotCount }, (_, index) => {
|
|
@@ -22690,9 +22722,12 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
|
|
|
22690
22722
|
readFileSync16(path33.join(moduleRoot, file))
|
|
22691
22723
|
])
|
|
22692
22724
|
);
|
|
22693
|
-
const ranked = slots.map((slot) => {
|
|
22725
|
+
const ranked = slots.map((slot, index) => {
|
|
22726
|
+
const slotKey = swiftFrameworkSlotKey(slot);
|
|
22727
|
+
if (slotKey === null) return { slot, index, tier: 1, changes: Infinity };
|
|
22728
|
+
if (swiftFrameworkSlotRelease(slot) !== release)
|
|
22729
|
+
return { slot, index, tier: 2, changes: Infinity };
|
|
22694
22730
|
let changes = 0;
|
|
22695
|
-
if (swiftFrameworkSlotKey(slot) === null) return { slot, changes: Infinity };
|
|
22696
22731
|
const source = path33.join(slot, "source", "packages", path33.basename(moduleRoot));
|
|
22697
22732
|
for (const [file, contents2] of inputs) {
|
|
22698
22733
|
try {
|
|
@@ -22704,18 +22739,22 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
|
|
|
22704
22739
|
changes++;
|
|
22705
22740
|
}
|
|
22706
22741
|
}
|
|
22707
|
-
return { slot, changes };
|
|
22708
|
-
}).sort(
|
|
22709
|
-
(left
|
|
22710
|
-
|
|
22711
|
-
|
|
22742
|
+
return { slot, index, tier: 0, changes };
|
|
22743
|
+
}).sort((left, right) => {
|
|
22744
|
+
if (left.tier !== right.tier) return left.tier - right.tier;
|
|
22745
|
+
if (left.tier === 0)
|
|
22746
|
+
return left.changes - right.changes || Number(own(right.slot)) - Number(own(left.slot)) || (built.get(right.slot) ?? 0) - (built.get(left.slot) ?? 0);
|
|
22747
|
+
if (left.tier === 1) return left.index - right.index;
|
|
22748
|
+
return (built.get(left.slot) ?? 0) - (built.get(right.slot) ?? 0);
|
|
22749
|
+
});
|
|
22750
|
+
for (const { slot, tier, changes } of ranked) {
|
|
22712
22751
|
if (await hasLiveSwiftRootReaders(slot, signal)) continue;
|
|
22713
22752
|
const result = await withSwiftRootLock(
|
|
22714
22753
|
slot,
|
|
22715
22754
|
async (lease) => {
|
|
22716
22755
|
if (await hasLiveSwiftRootReaders(slot, signal)) return void 0;
|
|
22717
22756
|
console.error(
|
|
22718
|
-
`[swift-framework-cache] ${path33.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`
|
|
22757
|
+
`[swift-framework-cache] ${path33.basename(slot)} release=${release} tier=${tier} changedInputs=${changes} totalInputs=${inputs.size}`
|
|
22719
22758
|
);
|
|
22720
22759
|
return { value: await run2(slot)(lease) };
|
|
22721
22760
|
},
|
|
@@ -22727,6 +22766,43 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
|
|
|
22727
22766
|
const nearest = ranked[0].slot;
|
|
22728
22767
|
return withSwiftRootLock(nearest, run2(nearest), signal);
|
|
22729
22768
|
}
|
|
22769
|
+
async function withSwiftBuildRootSlot(baseRoot, buildShape, signal, work) {
|
|
22770
|
+
const slots = Array.from({ length: SWIFT_BUILD_ROOT_SLOTS }, (_, index) => {
|
|
22771
|
+
const slot = index === 0 ? baseRoot : `${baseRoot}-s${index}`;
|
|
22772
|
+
mkdirSync8(slot, { recursive: true });
|
|
22773
|
+
return slot;
|
|
22774
|
+
});
|
|
22775
|
+
const runInSlot = (slot, waitStart2) => (lease) => {
|
|
22776
|
+
const waitedMs = Date.now() - waitStart2;
|
|
22777
|
+
const now = /* @__PURE__ */ new Date();
|
|
22778
|
+
utimesSync(slot, now, now);
|
|
22779
|
+
return work(slot, lease, waitedMs);
|
|
22780
|
+
};
|
|
22781
|
+
const built = new Map(slots.map((slot) => [slot, statSync5(slot).mtimeMs]));
|
|
22782
|
+
const ranked = slots.map((slot, index) => {
|
|
22783
|
+
const shape = swiftFrameworkSlotRecord(slot, SWIFT_BUILD_ROOT_SHAPE);
|
|
22784
|
+
const tier = shape === buildShape ? 0 : shape === null ? 1 : 2;
|
|
22785
|
+
return { slot, index, tier };
|
|
22786
|
+
}).sort((left, right) => {
|
|
22787
|
+
if (left.tier !== right.tier) return left.tier - right.tier;
|
|
22788
|
+
if (left.tier === 0)
|
|
22789
|
+
return (built.get(right.slot) ?? 0) - (built.get(left.slot) ?? 0);
|
|
22790
|
+
if (left.tier === 1) return left.index - right.index;
|
|
22791
|
+
return (built.get(left.slot) ?? 0) - (built.get(right.slot) ?? 0);
|
|
22792
|
+
});
|
|
22793
|
+
for (const { slot } of ranked) {
|
|
22794
|
+
const result = await withSwiftRootLock(
|
|
22795
|
+
slot,
|
|
22796
|
+
async (lease) => ({ value: await runInSlot(slot, Date.now())(lease) }),
|
|
22797
|
+
signal,
|
|
22798
|
+
false
|
|
22799
|
+
);
|
|
22800
|
+
if (result) return result.value;
|
|
22801
|
+
}
|
|
22802
|
+
const nearest = ranked[0].slot;
|
|
22803
|
+
const waitStart = Date.now();
|
|
22804
|
+
return withSwiftRootLock(nearest, runInSlot(nearest, waitStart), signal);
|
|
22805
|
+
}
|
|
22730
22806
|
function mirrorTree2(source, target, skip) {
|
|
22731
22807
|
mkdirSync8(target, { recursive: true });
|
|
22732
22808
|
const wanted = /* @__PURE__ */ new Set();
|
|
@@ -22776,8 +22852,10 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
|
22776
22852
|
const hadKey = swiftFrameworkSlotKey(slot);
|
|
22777
22853
|
if (hadKey !== frameworkKey) {
|
|
22778
22854
|
rmSync7(path33.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
|
|
22855
|
+
rmSync7(path33.join(slot, SWIFT_FRAMEWORK_SLOT_RELEASE), { force: true });
|
|
22779
22856
|
rmSync7(path33.join(slot, "products-ready"), { recursive: true, force: true });
|
|
22780
|
-
rmSync7(path33.join(slot, "lib"
|
|
22857
|
+
rmSync7(path33.join(slot, "products-lib"), { recursive: true, force: true });
|
|
22858
|
+
rmSync7(path33.join(slot, "lib"), { recursive: true, force: true });
|
|
22781
22859
|
const moduleRestructured = mirrorTree2(moduleRoot, stagedModule, ".build");
|
|
22782
22860
|
const sdkRestructured = mirrorTree2(
|
|
22783
22861
|
swiftSharedSdkRoot(moduleRoot, false),
|
|
@@ -22805,8 +22883,11 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
|
22805
22883
|
rmSync7(modules, { recursive: true, force: true });
|
|
22806
22884
|
symlinkSync2(target, modules);
|
|
22807
22885
|
}
|
|
22886
|
+
writeFileSync8(path33.join(slot, SWIFT_FRAMEWORK_SLOT_RELEASE), release);
|
|
22808
22887
|
writeFileSync8(path33.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
|
|
22809
22888
|
writeFileSync8(path33.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
|
|
22889
|
+
} else if (swiftFrameworkSlotRelease(slot) !== release) {
|
|
22890
|
+
writeFileSync8(path33.join(slot, SWIFT_FRAMEWORK_SLOT_RELEASE), release);
|
|
22810
22891
|
}
|
|
22811
22892
|
return stagedModule;
|
|
22812
22893
|
}
|
|
@@ -22916,7 +22997,7 @@ async function compileSwiftProjectOnce(sources, options) {
|
|
|
22916
22997
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
22917
22998
|
const mirrorDistribution = options.linkOnly || options.project ? null : distribution;
|
|
22918
22999
|
if (distribution) refreshSwiftCacheHold(moduleRoot);
|
|
22919
|
-
const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-
|
|
23000
|
+
const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-HDHPWS44.mjs")).useSwiftPackagePrebuilts(
|
|
22920
23001
|
sources,
|
|
22921
23002
|
moduleRoot,
|
|
22922
23003
|
options.toolchainBin
|
|
@@ -22930,7 +23011,7 @@ async function compileSwiftProjectOnce(sources, options) {
|
|
|
22930
23011
|
multi: compileTargets(input).length > 0
|
|
22931
23012
|
};
|
|
22932
23013
|
const sdkModule = options.sdkModule && !options.linkOnly;
|
|
22933
|
-
const sdkImage = sdkModule ? await (await import("./swift-sdk-image-
|
|
23014
|
+
const sdkImage = sdkModule ? await (await import("./swift-sdk-image-PVDA2MVM.mjs")).buildSwiftSdkImage(
|
|
22934
23015
|
moduleRoot,
|
|
22935
23016
|
!!guestGraph,
|
|
22936
23017
|
distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
|
|
@@ -23034,654 +23115,711 @@ ${cap}` : "";
|
|
|
23034
23115
|
rmSync7(requestRoot, { recursive: true, force: true });
|
|
23035
23116
|
}
|
|
23036
23117
|
}
|
|
23118
|
+
const baseRoot = root;
|
|
23119
|
+
const canPoolBuildRoot = !options.intermediates && !options.project && !options.linkOnly && path33.basename(path33.dirname(baseRoot)) === "swift-builds";
|
|
23120
|
+
const buildShape = canPoolBuildRoot ? createHash18("sha256").update(
|
|
23121
|
+
JSON.stringify([
|
|
23122
|
+
frameworkKey,
|
|
23123
|
+
Boolean(sdkImage),
|
|
23124
|
+
compileTargets(input).map((target) => target.name).sort(),
|
|
23125
|
+
input.oneModule === true,
|
|
23126
|
+
input.optimize === true,
|
|
23127
|
+
input.unoptimized === true,
|
|
23128
|
+
Object.keys(input.files).sort()
|
|
23129
|
+
])
|
|
23130
|
+
).digest("hex").slice(0, 16) : "";
|
|
23037
23131
|
return withSwiftCompileBudget(options.timeoutMs, options.signal, async (budget) => {
|
|
23038
|
-
|
|
23039
|
-
|
|
23040
|
-
|
|
23041
|
-
|
|
23042
|
-
|
|
23043
|
-
|
|
23044
|
-
|
|
23045
|
-
|
|
23046
|
-
|
|
23047
|
-
|
|
23048
|
-
|
|
23049
|
-
|
|
23050
|
-
|
|
23051
|
-
|
|
23052
|
-
|
|
23132
|
+
const stage = (message) => {
|
|
23133
|
+
budget.progress();
|
|
23134
|
+
report(message);
|
|
23135
|
+
};
|
|
23136
|
+
const runLocked = (work) => {
|
|
23137
|
+
if (canPoolBuildRoot) {
|
|
23138
|
+
mkdirSync8(sharedRoot, { recursive: true });
|
|
23139
|
+
return withSwiftRootLock(
|
|
23140
|
+
sharedRoot,
|
|
23141
|
+
async () => {
|
|
23142
|
+
const built = readCompiledArtifact(
|
|
23143
|
+
path33.join(sharedRoot, "artifact"),
|
|
23144
|
+
hash
|
|
23145
|
+
);
|
|
23146
|
+
if (built) {
|
|
23147
|
+
stage("reusing verified disk artifact");
|
|
23148
|
+
return retain(baseRoot, built);
|
|
23149
|
+
}
|
|
23150
|
+
return withSwiftBuildRootSlot(baseRoot, buildShape, budget.signal, work);
|
|
23151
|
+
},
|
|
23152
|
+
budget.signal
|
|
23153
|
+
);
|
|
23154
|
+
}
|
|
23155
|
+
const waitStart = Date.now();
|
|
23156
|
+
return withSwiftRootLock(
|
|
23157
|
+
baseRoot,
|
|
23158
|
+
(lease) => work(baseRoot, lease, Date.now() - waitStart),
|
|
23159
|
+
budget.signal
|
|
23160
|
+
);
|
|
23161
|
+
};
|
|
23162
|
+
return runLocked(async (slotRoot, lease, waitedMs) => {
|
|
23163
|
+
const root2 = slotRoot;
|
|
23164
|
+
const layout3 = {
|
|
23165
|
+
root: root2,
|
|
23166
|
+
sources: path33.join(root2, "Sources", "App"),
|
|
23167
|
+
multi: compileTargets(input).length > 0
|
|
23168
|
+
};
|
|
23169
|
+
if (!options.intermediates) {
|
|
23170
|
+
const built = readCompiledArtifact(path33.join(sharedRoot, "artifact"), hash);
|
|
23171
|
+
if (built) {
|
|
23172
|
+
stage("reusing verified disk artifact");
|
|
23173
|
+
return retain(baseRoot, built);
|
|
23053
23174
|
}
|
|
23054
|
-
|
|
23055
|
-
|
|
23056
|
-
|
|
23057
|
-
|
|
23175
|
+
}
|
|
23176
|
+
if (waitedMs >= 1e3)
|
|
23177
|
+
report(`acquired build root ${path33.basename(root2)} after ${waitedMs}ms`);
|
|
23178
|
+
if (canPoolBuildRoot) {
|
|
23179
|
+
refreshSwiftCacheHold(root2);
|
|
23180
|
+
writeFileSync8(path33.join(root2, SWIFT_BUILD_ROOT_SHAPE), buildShape);
|
|
23181
|
+
}
|
|
23182
|
+
const swift = path33.join(options.toolchainBin, "swift");
|
|
23183
|
+
if (!existsSync9(swift)) {
|
|
23184
|
+
throw new Error(
|
|
23185
|
+
`swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
|
|
23186
|
+
);
|
|
23187
|
+
}
|
|
23188
|
+
const unoptimized = input.unoptimized === true;
|
|
23189
|
+
const withFrameworkLock = (work) => distribution ? work(null) : withSwiftFrameworkSlot(
|
|
23190
|
+
frameworkKey,
|
|
23191
|
+
options.release,
|
|
23192
|
+
moduleRoot,
|
|
23193
|
+
budget.signal,
|
|
23194
|
+
work,
|
|
23195
|
+
unoptimized
|
|
23196
|
+
);
|
|
23197
|
+
const baseBuildEnv = options.project?.env ? {
|
|
23198
|
+
...options.project.env,
|
|
23199
|
+
// shipped host plugins resolve against the selected compiler's runtime.
|
|
23200
|
+
...process.platform === "linux" ? {
|
|
23201
|
+
LD_LIBRARY_PATH: [
|
|
23202
|
+
path33.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
23203
|
+
path33.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
23204
|
+
process.env.LD_LIBRARY_PATH
|
|
23205
|
+
].filter(Boolean).join(":")
|
|
23206
|
+
} : {},
|
|
23207
|
+
PEACH_DEFER_WASM_LINK: "1"
|
|
23208
|
+
} : swiftCompilerBaseEnv(options.toolchainBin, process.env);
|
|
23209
|
+
const {
|
|
23210
|
+
frameworkRoot,
|
|
23211
|
+
compileFrameworkRoot,
|
|
23212
|
+
macroPlugins,
|
|
23213
|
+
sdk,
|
|
23214
|
+
icu,
|
|
23215
|
+
prebuilt,
|
|
23216
|
+
readHold
|
|
23217
|
+
} = await withFrameworkLock(async (slot, frameworkLease) => {
|
|
23218
|
+
budget.startCompile();
|
|
23219
|
+
if (slot && swiftFrameworkSlotKey(slot) !== frameworkKey)
|
|
23220
|
+
await waitForNoSwiftRootReaders(slot, budget.signal);
|
|
23221
|
+
const frameworkRoot2 = mirrorDistribution ? syncSwiftDistributionMirror(root2, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(moduleRoot, slot, frameworkKey, options.release);
|
|
23222
|
+
if (!swiftModuleDigest(frameworkRoot2).equals(moduleDigest))
|
|
23223
|
+
throw new Error("Swift staged project source differs from the caller");
|
|
23224
|
+
stage("preparing compiler plugins");
|
|
23225
|
+
const macroPlugins2 = await ensureMacroPlugins(
|
|
23226
|
+
frameworkRoot2,
|
|
23227
|
+
options.toolchainBin,
|
|
23228
|
+
options.release,
|
|
23058
23229
|
budget.signal,
|
|
23059
|
-
|
|
23060
|
-
unoptimized
|
|
23230
|
+
frameworkLease
|
|
23061
23231
|
);
|
|
23062
|
-
const
|
|
23063
|
-
|
|
23064
|
-
|
|
23065
|
-
|
|
23066
|
-
|
|
23067
|
-
|
|
23068
|
-
|
|
23069
|
-
|
|
23070
|
-
|
|
23071
|
-
|
|
23072
|
-
|
|
23073
|
-
|
|
23074
|
-
|
|
23232
|
+
const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
|
|
23233
|
+
const sdk2 = swiftModuleSdk(frameworkRoot2).wasmSdkId;
|
|
23234
|
+
const icu2 = options.linkOnly ? null : swiftIcuAsset(options.toolchainBin, sdk2);
|
|
23235
|
+
let prebuilt2;
|
|
23236
|
+
if (!distribution) {
|
|
23237
|
+
stage("compiling framework products");
|
|
23238
|
+
prebuilt2 = await buildFrameworkProducts(slot, {
|
|
23239
|
+
moduleRoot: frameworkRoot2,
|
|
23240
|
+
frameworkKey,
|
|
23241
|
+
input,
|
|
23242
|
+
swift,
|
|
23243
|
+
sdk: sdk2,
|
|
23244
|
+
toolchainBin: options.toolchainBin,
|
|
23245
|
+
plugins: macroPlugins2,
|
|
23246
|
+
buildOptions: {
|
|
23247
|
+
env: baseBuildEnv,
|
|
23248
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
23249
|
+
signal: budget.signal,
|
|
23250
|
+
onOutput: budget.progress,
|
|
23251
|
+
lease,
|
|
23252
|
+
frameworkLease
|
|
23253
|
+
}
|
|
23254
|
+
});
|
|
23255
|
+
}
|
|
23256
|
+
const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
|
|
23257
|
+
return {
|
|
23258
|
+
frameworkRoot: frameworkRoot2,
|
|
23259
|
+
compileFrameworkRoot: compileFrameworkRoot2,
|
|
23260
|
+
macroPlugins: macroPlugins2,
|
|
23261
|
+
sdk: sdk2,
|
|
23262
|
+
icu: icu2,
|
|
23263
|
+
prebuilt: prebuilt2,
|
|
23264
|
+
readHold: readHold2
|
|
23265
|
+
};
|
|
23266
|
+
});
|
|
23267
|
+
const buildOptions = {
|
|
23268
|
+
env: baseBuildEnv,
|
|
23269
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
23270
|
+
signal: budget.signal,
|
|
23271
|
+
onOutput: budget.progress,
|
|
23272
|
+
lease
|
|
23273
|
+
};
|
|
23274
|
+
try {
|
|
23275
|
+
if (options.project) removeProjectLinks(root2);
|
|
23276
|
+
const packageHostMacros = process.platform === "linux" ? input.packageHostMacros : void 0;
|
|
23277
|
+
if (retireStaleSwiftLink(
|
|
23278
|
+
root2,
|
|
23279
|
+
swiftLinkStamp({
|
|
23280
|
+
frameworkKey: `${options.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
|
|
23281
|
+
packageHostMacros
|
|
23282
|
+
}),
|
|
23283
|
+
swiftLinkStamp({
|
|
23284
|
+
// a distribution's objects reach only the deferred link, and
|
|
23285
|
+
// the root's mirror keeps its compile inputs at fixed paths
|
|
23286
|
+
frameworkKey: distribution ? `${options.release}\0${distribution.wasmSdkChecksum}` : frameworkKey,
|
|
23287
|
+
prebuilt,
|
|
23288
|
+
packageHostMacros
|
|
23289
|
+
}),
|
|
23290
|
+
Boolean(options.linkOnly)
|
|
23291
|
+
))
|
|
23292
|
+
stage("framework revision changed; rebuilding the app link");
|
|
23293
|
+
const nativeToolset = needsNativeToolset(input, prebuilt);
|
|
23294
|
+
const preparation = writeSwiftProject(
|
|
23295
|
+
layout3,
|
|
23296
|
+
input,
|
|
23075
23297
|
frameworkRoot,
|
|
23076
|
-
compileFrameworkRoot,
|
|
23077
|
-
macroPlugins,
|
|
23078
|
-
sdk,
|
|
23079
|
-
icu,
|
|
23080
23298
|
prebuilt,
|
|
23081
|
-
|
|
23082
|
-
|
|
23083
|
-
|
|
23084
|
-
|
|
23085
|
-
|
|
23086
|
-
|
|
23087
|
-
|
|
23088
|
-
|
|
23089
|
-
|
|
23090
|
-
|
|
23091
|
-
|
|
23092
|
-
|
|
23093
|
-
|
|
23094
|
-
|
|
23095
|
-
|
|
23299
|
+
!options.project,
|
|
23300
|
+
options.project ? false : options.objcPrebuiltStage ?? (options.intermediates ? false : void 0)
|
|
23301
|
+
);
|
|
23302
|
+
const productFile = path33.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
|
|
23303
|
+
writeSwiftAutolinkLinker(
|
|
23304
|
+
root2,
|
|
23305
|
+
options.toolchainBin,
|
|
23306
|
+
existsSync9(productFile) ? [
|
|
23307
|
+
parse(
|
|
23308
|
+
swiftFrameworkProductSchema,
|
|
23309
|
+
JSON.parse(readFileSync16(productFile, "utf8"))
|
|
23310
|
+
).product.name
|
|
23311
|
+
] : []
|
|
23312
|
+
);
|
|
23313
|
+
const compiler = preparation.targetToolset ? { CC: path33.join(root2, CLANG_TARGET_MODULE_WRAPPER) } : {};
|
|
23314
|
+
if (packageHostMacros?.length) {
|
|
23315
|
+
const swiftc = path33.join(root2, SWIFT_HOST_COMPILER_WRAPPER);
|
|
23316
|
+
writeBuildFile(
|
|
23317
|
+
swiftc,
|
|
23318
|
+
[
|
|
23319
|
+
"#!/bin/sh",
|
|
23320
|
+
"target=",
|
|
23321
|
+
"module=",
|
|
23322
|
+
"compile=",
|
|
23323
|
+
"previous=",
|
|
23324
|
+
"for argument do",
|
|
23325
|
+
' case "$previous" in -target) target=$argument ;; -module-name) module=$argument ;; esac',
|
|
23326
|
+
' case "$argument" in -c|-emit-module|-scan-dependencies|-typecheck) compile=1 ;; esac',
|
|
23327
|
+
" previous=$argument",
|
|
23328
|
+
"done",
|
|
23329
|
+
'case "$target/$compile" in',
|
|
23330
|
+
" *-*-linux*/1)",
|
|
23331
|
+
' case ",$PEACH_SWIFT_HOST_MACROS," in',
|
|
23332
|
+
' *",$module,"*) set -- "$@" -Xfrontend -import-module -Xfrontend Foundation ;;',
|
|
23333
|
+
" esac ;;",
|
|
23334
|
+
"esac",
|
|
23335
|
+
'exec "$PEACH_SWIFTC" "$@"',
|
|
23336
|
+
""
|
|
23337
|
+
].join("\n")
|
|
23096
23338
|
);
|
|
23097
|
-
|
|
23098
|
-
|
|
23099
|
-
|
|
23100
|
-
|
|
23101
|
-
|
|
23102
|
-
|
|
23103
|
-
|
|
23104
|
-
|
|
23105
|
-
|
|
23106
|
-
|
|
23107
|
-
|
|
23108
|
-
|
|
23109
|
-
|
|
23110
|
-
|
|
23111
|
-
|
|
23112
|
-
|
|
23113
|
-
|
|
23114
|
-
|
|
23115
|
-
|
|
23116
|
-
frameworkLease
|
|
23117
|
-
}
|
|
23118
|
-
});
|
|
23339
|
+
chmodSync3(swiftc, 493);
|
|
23340
|
+
compiler.SWIFT_EXEC = swiftc;
|
|
23341
|
+
compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
|
|
23342
|
+
compiler.PEACH_SWIFTC = path33.join(options.toolchainBin, "swiftc");
|
|
23343
|
+
}
|
|
23344
|
+
const projectProcess = options.project ? prepareSwiftProjectProcess(root2, options.project) : void 0;
|
|
23345
|
+
const temporaryDirectory = projectProcess ? void 0 : path33.join(root2, ".build", "peach-compiler-tmp");
|
|
23346
|
+
const appOptions = projectProcess ? {
|
|
23347
|
+
...buildOptions,
|
|
23348
|
+
uid: projectProcess.uid,
|
|
23349
|
+
gid: projectProcess.gid,
|
|
23350
|
+
confined: { ...projectProcess.env, ...compiler }
|
|
23351
|
+
} : {
|
|
23352
|
+
...buildOptions,
|
|
23353
|
+
temporaryDirectory,
|
|
23354
|
+
env: {
|
|
23355
|
+
...buildOptions.env,
|
|
23356
|
+
...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
|
|
23357
|
+
...compiler
|
|
23119
23358
|
}
|
|
23120
|
-
const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
|
|
23121
|
-
return {
|
|
23122
|
-
frameworkRoot: frameworkRoot2,
|
|
23123
|
-
compileFrameworkRoot: compileFrameworkRoot2,
|
|
23124
|
-
macroPlugins: macroPlugins2,
|
|
23125
|
-
sdk: sdk2,
|
|
23126
|
-
icu: icu2,
|
|
23127
|
-
prebuilt: prebuilt2,
|
|
23128
|
-
readHold: readHold2
|
|
23129
|
-
};
|
|
23130
|
-
});
|
|
23131
|
-
const buildOptions = {
|
|
23132
|
-
env: baseBuildEnv,
|
|
23133
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
23134
|
-
signal: budget.signal,
|
|
23135
|
-
lease
|
|
23136
23359
|
};
|
|
23137
|
-
|
|
23138
|
-
|
|
23139
|
-
|
|
23140
|
-
|
|
23141
|
-
|
|
23142
|
-
|
|
23143
|
-
|
|
23144
|
-
|
|
23145
|
-
|
|
23146
|
-
|
|
23147
|
-
|
|
23148
|
-
// the root's mirror keeps its compile inputs at fixed paths
|
|
23149
|
-
frameworkKey: distribution ? `${options.release}\0${distribution.wasmSdkChecksum}` : frameworkKey,
|
|
23150
|
-
prebuilt,
|
|
23151
|
-
packageHostMacros
|
|
23152
|
-
}),
|
|
23153
|
-
Boolean(options.linkOnly)
|
|
23154
|
-
))
|
|
23155
|
-
report("framework revision changed; rebuilding the app link");
|
|
23156
|
-
const nativeToolset = needsNativeToolset(input, prebuilt);
|
|
23157
|
-
const preparation = writeSwiftProject(
|
|
23158
|
-
layout2,
|
|
23159
|
-
input,
|
|
23160
|
-
frameworkRoot,
|
|
23161
|
-
prebuilt,
|
|
23162
|
-
!options.project,
|
|
23163
|
-
options.project ? false : options.objcPrebuiltStage ?? (options.intermediates ? false : void 0)
|
|
23360
|
+
const unprepared = preparation.targetFailures.map(
|
|
23361
|
+
(failure) => `error: target ${failure}`
|
|
23362
|
+
);
|
|
23363
|
+
const forwarders = /* @__PURE__ */ new Map();
|
|
23364
|
+
for (const [file, text2] of Object.entries(input.files)) {
|
|
23365
|
+
const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text2)?.[1];
|
|
23366
|
+
if (!parents) continue;
|
|
23367
|
+
const directory = path33.posix.dirname(file);
|
|
23368
|
+
forwarders.set(
|
|
23369
|
+
`${path33.join(root2, directory)}/${parents.slice(0, -1)}`,
|
|
23370
|
+
path33.posix.join("build", directory, parents).replace(/\/$/, "")
|
|
23164
23371
|
);
|
|
23165
|
-
|
|
23166
|
-
|
|
23167
|
-
|
|
23168
|
-
|
|
23169
|
-
|
|
23170
|
-
|
|
23171
|
-
|
|
23172
|
-
|
|
23173
|
-
|
|
23174
|
-
|
|
23372
|
+
}
|
|
23373
|
+
const jobs = swiftCompilerJobs();
|
|
23374
|
+
const incrementalPreview = sdkImage !== void 0 && !guestGraph && !options.project && !input.optimize && !input.unoptimized;
|
|
23375
|
+
const perFile = input.unoptimized || incrementalPreview;
|
|
23376
|
+
const buildArgs = [
|
|
23377
|
+
"build",
|
|
23378
|
+
...projectProcess?.cacheOptions ?? swiftPackageCacheOptions(),
|
|
23379
|
+
"--build-system",
|
|
23380
|
+
"native",
|
|
23381
|
+
"-j",
|
|
23382
|
+
String(jobs),
|
|
23383
|
+
"--package-path",
|
|
23384
|
+
root2,
|
|
23385
|
+
...swiftCompileSdkOptions(frameworkRoot, options.toolchainBin),
|
|
23386
|
+
...swiftObjCSelectorOptions(frameworkRoot),
|
|
23387
|
+
"--swift-sdk",
|
|
23388
|
+
sdk,
|
|
23389
|
+
...preparation.targetToolset ? ["--toolset", path33.join(root2, ".peach-target-toolset.json")] : [],
|
|
23390
|
+
"-c",
|
|
23391
|
+
"release",
|
|
23392
|
+
...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
|
|
23393
|
+
...perFile ? [
|
|
23394
|
+
"-Xswiftc",
|
|
23395
|
+
"-no-whole-module-optimization",
|
|
23396
|
+
"-Xswiftc",
|
|
23397
|
+
"-j",
|
|
23398
|
+
"-Xswiftc",
|
|
23399
|
+
String(jobs)
|
|
23400
|
+
] : [],
|
|
23401
|
+
...incrementalPreview ? ["-Xswiftc", "-incremental", "-Xswiftc", "-enable-batch-mode"] : [],
|
|
23402
|
+
// the mirror finds a changed sdk header's readers in their
|
|
23403
|
+
// dependency files, which omit system headers by default
|
|
23404
|
+
...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
|
|
23405
|
+
// the link strips debug info, so none is generated (as for the framework).
|
|
23406
|
+
// keep -num-threads fixed across caller core caps so llbuild does not
|
|
23407
|
+
// rebuild every target when callers alternate --cores, and bound backend
|
|
23408
|
+
// fan-out under high -j.
|
|
23409
|
+
"-Xswiftc",
|
|
23410
|
+
"-gnone",
|
|
23411
|
+
...incrementalPreview ? [] : [
|
|
23412
|
+
"-Xswiftc",
|
|
23413
|
+
"-num-threads",
|
|
23414
|
+
"-Xswiftc",
|
|
23415
|
+
String(perFile ? 1 : Math.min(8, os4.availableParallelism()))
|
|
23416
|
+
],
|
|
23417
|
+
...swiftReproducibleBuildFlags([
|
|
23418
|
+
[path33.dirname(options.toolchainBin), "toolchain"],
|
|
23419
|
+
[compileFrameworkRoot, "framework"],
|
|
23420
|
+
[root2, "build"],
|
|
23421
|
+
...forwarders
|
|
23422
|
+
]).flatMap((flag, index, flags) => {
|
|
23423
|
+
if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
|
|
23424
|
+
return [flag];
|
|
23425
|
+
const toolchainDir = path33.dirname(options.toolchainBin);
|
|
23426
|
+
let mapped = flag;
|
|
23427
|
+
for (const [dir, target] of [
|
|
23428
|
+
[root2, "/peach/build"],
|
|
23429
|
+
[compileFrameworkRoot, "/peach/framework"],
|
|
23430
|
+
[realpathSync6(compileFrameworkRoot), "/peach/framework"],
|
|
23431
|
+
[toolchainDir, "/peach/toolchain"],
|
|
23432
|
+
[realpathSync6(toolchainDir), "/peach/toolchain"]
|
|
23433
|
+
]) {
|
|
23434
|
+
mapped = mapped.replaceAll(dir, target);
|
|
23435
|
+
}
|
|
23436
|
+
const [, from, to] = /^-ffile-prefix-map=([^=]+)=(.+)$/.exec(mapped) ?? [];
|
|
23437
|
+
const tool = flags[index - 1];
|
|
23438
|
+
return mapped !== flag && from !== to ? [flag, tool, mapped] : [flag];
|
|
23439
|
+
}),
|
|
23440
|
+
...macroPlugins.libraries.flatMap((plugin) => [
|
|
23441
|
+
"-Xswiftc",
|
|
23442
|
+
"-load-plugin-library",
|
|
23443
|
+
"-Xswiftc",
|
|
23444
|
+
plugin
|
|
23445
|
+
]),
|
|
23446
|
+
...macroPlugins.executables.flatMap((plugin) => [
|
|
23447
|
+
"-Xswiftc",
|
|
23448
|
+
"-load-plugin-executable",
|
|
23449
|
+
"-Xswiftc",
|
|
23450
|
+
`${plugin}#ExpoModulesMacros`
|
|
23451
|
+
])
|
|
23452
|
+
];
|
|
23453
|
+
const linked = builtArtifact(layout3);
|
|
23454
|
+
rmSync7(path33.join(root2, ".peach-link.rsp"), { force: true });
|
|
23455
|
+
if (options.linkOnly || existsSync9(linked) && statSync5(linked).size <= 8)
|
|
23456
|
+
rmSync7(linked, { force: true });
|
|
23457
|
+
stage("compiling and linking Swift modules");
|
|
23458
|
+
const frameworkInterfaces = /* @__PURE__ */ new Map();
|
|
23459
|
+
const sdkFrameworks = path33.join(
|
|
23460
|
+
swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
|
|
23461
|
+
"System/Library/Frameworks"
|
|
23462
|
+
);
|
|
23463
|
+
const generatedInterface = (source) => withoutImportedSdkEnumForwards(
|
|
23464
|
+
clangInterfaceHeader(readFileSync16(source, "utf8"), frameworkRoot),
|
|
23465
|
+
sdkObjCDeclarationOwners(sdkFrameworks)
|
|
23466
|
+
);
|
|
23467
|
+
const nativeDeclarations = /* @__PURE__ */ new Map();
|
|
23468
|
+
const nativeHeaders = Object.entries(input.files).filter(([name]) => name.endsWith(".h") && !name.endsWith("-Swift.h")).map(([, source]) => source);
|
|
23469
|
+
for (const [file, contents2] of Object.entries(input.files)) {
|
|
23470
|
+
if (!file.endsWith(".modulemap")) continue;
|
|
23471
|
+
const name = moduleMapName(contents2);
|
|
23472
|
+
const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
|
|
23473
|
+
if (!name || !umbrella) continue;
|
|
23474
|
+
const header = input.files[path33.posix.join(path33.posix.dirname(file), umbrella)];
|
|
23475
|
+
if (header === void 0) continue;
|
|
23476
|
+
const included = new Set(
|
|
23477
|
+
[
|
|
23478
|
+
...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
|
|
23479
|
+
].map((match) => path33.posix.basename(match[1]))
|
|
23175
23480
|
);
|
|
23176
|
-
const
|
|
23177
|
-
|
|
23178
|
-
|
|
23179
|
-
|
|
23180
|
-
|
|
23181
|
-
|
|
23182
|
-
|
|
23183
|
-
|
|
23184
|
-
|
|
23185
|
-
|
|
23186
|
-
|
|
23187
|
-
|
|
23188
|
-
|
|
23189
|
-
|
|
23190
|
-
|
|
23191
|
-
"done",
|
|
23192
|
-
'case "$target/$compile" in',
|
|
23193
|
-
" *-*-linux*/1)",
|
|
23194
|
-
' case ",$PEACH_SWIFT_HOST_MACROS," in',
|
|
23195
|
-
' *",$module,"*) set -- "$@" -Xfrontend -import-module -Xfrontend Foundation ;;',
|
|
23196
|
-
" esac ;;",
|
|
23197
|
-
"esac",
|
|
23198
|
-
'exec "$PEACH_SWIFTC" "$@"',
|
|
23199
|
-
""
|
|
23200
|
-
].join("\n")
|
|
23201
|
-
);
|
|
23202
|
-
chmodSync3(swiftc, 493);
|
|
23203
|
-
compiler.SWIFT_EXEC = swiftc;
|
|
23204
|
-
compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
|
|
23205
|
-
compiler.PEACH_SWIFTC = path33.join(options.toolchainBin, "swiftc");
|
|
23481
|
+
const declarations = nativeDeclarations.get(name) ?? /* @__PURE__ */ new Set();
|
|
23482
|
+
for (const declaration of swiftInterfaceDeclarations(header))
|
|
23483
|
+
declarations.add(declaration);
|
|
23484
|
+
for (const [candidate, source] of Object.entries(input.files))
|
|
23485
|
+
if (included.has(path33.posix.basename(candidate)))
|
|
23486
|
+
for (const declaration of swiftInterfaceDeclarations(source))
|
|
23487
|
+
declarations.add(declaration);
|
|
23488
|
+
nativeDeclarations.set(name, declarations);
|
|
23489
|
+
}
|
|
23490
|
+
const frameworkInterface = (name) => {
|
|
23491
|
+
if (frameworkInterfaces.has(name)) return frameworkInterfaces.get(name);
|
|
23492
|
+
const source = distribution ? path33.join(frameworkRoot, "modules", `${name}-Swift.h`) : prebuilt.objcHeaders.get(name);
|
|
23493
|
+
if (!source || !existsSync9(source)) {
|
|
23494
|
+
frameworkInterfaces.set(name, null);
|
|
23495
|
+
return null;
|
|
23206
23496
|
}
|
|
23207
|
-
const
|
|
23208
|
-
const
|
|
23209
|
-
|
|
23210
|
-
|
|
23211
|
-
|
|
23212
|
-
|
|
23213
|
-
|
|
23214
|
-
|
|
23215
|
-
|
|
23216
|
-
|
|
23217
|
-
|
|
23218
|
-
|
|
23219
|
-
|
|
23220
|
-
|
|
23221
|
-
|
|
23222
|
-
|
|
23223
|
-
|
|
23224
|
-
|
|
23497
|
+
const headers = path33.join(sdkFrameworks, `${name}.framework/Headers`);
|
|
23498
|
+
const declared = /* @__PURE__ */ new Set();
|
|
23499
|
+
if (existsSync9(headers)) {
|
|
23500
|
+
for (const file of readdirSync6(headers, {
|
|
23501
|
+
recursive: true,
|
|
23502
|
+
encoding: "utf8"
|
|
23503
|
+
}))
|
|
23504
|
+
if (file.endsWith(".h"))
|
|
23505
|
+
for (const name2 of swiftInterfaceDeclarations(
|
|
23506
|
+
readFileSync16(path33.join(headers, file), "utf8")
|
|
23507
|
+
))
|
|
23508
|
+
declared.add(name2);
|
|
23509
|
+
}
|
|
23510
|
+
for (const declaration of nativeDeclarations.get(name) ?? [])
|
|
23511
|
+
declared.add(declaration);
|
|
23512
|
+
const own = withoutSwiftDeclarations(
|
|
23513
|
+
generatedInterface(source),
|
|
23514
|
+
declared,
|
|
23515
|
+
nativeDeclarations.has(name) ? `@import ${name};` : `#import <${name}/${name}.h>`
|
|
23225
23516
|
);
|
|
23226
|
-
const
|
|
23227
|
-
|
|
23228
|
-
|
|
23229
|
-
|
|
23230
|
-
|
|
23231
|
-
|
|
23232
|
-
|
|
23233
|
-
|
|
23234
|
-
|
|
23517
|
+
const owners = sdkObjCDeclarationOwners(sdkFrameworks);
|
|
23518
|
+
const foreign = /* @__PURE__ */ new Map();
|
|
23519
|
+
for (const declaration of [
|
|
23520
|
+
...swiftInterfaceDeclarations(own),
|
|
23521
|
+
...objcEnumerations(own),
|
|
23522
|
+
...[...own.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
|
|
23523
|
+
(match) => match[1]
|
|
23524
|
+
)
|
|
23525
|
+
]) {
|
|
23526
|
+
const owner = owners.get(declaration);
|
|
23527
|
+
if (owner && owner !== name) foreign.set(declaration, owner);
|
|
23235
23528
|
}
|
|
23236
|
-
const
|
|
23237
|
-
|
|
23238
|
-
|
|
23239
|
-
|
|
23240
|
-
|
|
23241
|
-
|
|
23242
|
-
"
|
|
23243
|
-
|
|
23244
|
-
|
|
23245
|
-
|
|
23246
|
-
|
|
23247
|
-
|
|
23248
|
-
|
|
23249
|
-
|
|
23250
|
-
|
|
23251
|
-
sdk,
|
|
23252
|
-
...preparation.targetToolset ? ["--toolset", path33.join(root, ".peach-target-toolset.json")] : [],
|
|
23253
|
-
"-c",
|
|
23254
|
-
"release",
|
|
23255
|
-
...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
|
|
23256
|
-
...perFile ? [
|
|
23257
|
-
"-Xswiftc",
|
|
23258
|
-
"-no-whole-module-optimization",
|
|
23259
|
-
"-Xswiftc",
|
|
23260
|
-
"-j",
|
|
23261
|
-
"-Xswiftc",
|
|
23262
|
-
String(jobs)
|
|
23263
|
-
] : [],
|
|
23264
|
-
...incrementalPreview ? ["-Xswiftc", "-incremental", "-Xswiftc", "-enable-batch-mode"] : [],
|
|
23265
|
-
// the mirror finds a changed sdk header's readers in their
|
|
23266
|
-
// dependency files, which omit system headers by default
|
|
23267
|
-
...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
|
|
23268
|
-
// the link strips debug info, so none is generated (as for the framework).
|
|
23269
|
-
// keep -num-threads fixed across caller core caps so llbuild does not
|
|
23270
|
-
// rebuild every target when callers alternate --cores, and bound backend
|
|
23271
|
-
// fan-out under high -j.
|
|
23272
|
-
"-Xswiftc",
|
|
23273
|
-
"-gnone",
|
|
23274
|
-
...incrementalPreview ? [] : [
|
|
23275
|
-
"-Xswiftc",
|
|
23276
|
-
"-num-threads",
|
|
23277
|
-
"-Xswiftc",
|
|
23278
|
-
String(perFile ? 1 : Math.min(8, os4.availableParallelism()))
|
|
23279
|
-
],
|
|
23280
|
-
...swiftReproducibleBuildFlags([
|
|
23281
|
-
[path33.dirname(options.toolchainBin), "toolchain"],
|
|
23282
|
-
[compileFrameworkRoot, "framework"],
|
|
23283
|
-
[root, "build"],
|
|
23284
|
-
...forwarders
|
|
23285
|
-
]).flatMap((flag, index, flags) => {
|
|
23286
|
-
if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
|
|
23287
|
-
return [flag];
|
|
23288
|
-
const toolchainDir = path33.dirname(options.toolchainBin);
|
|
23289
|
-
let mapped = flag;
|
|
23290
|
-
for (const [dir, target] of [
|
|
23291
|
-
[root, "/peach/build"],
|
|
23292
|
-
[compileFrameworkRoot, "/peach/framework"],
|
|
23293
|
-
[realpathSync6(compileFrameworkRoot), "/peach/framework"],
|
|
23294
|
-
[toolchainDir, "/peach/toolchain"],
|
|
23295
|
-
[realpathSync6(toolchainDir), "/peach/toolchain"]
|
|
23296
|
-
]) {
|
|
23297
|
-
mapped = mapped.replaceAll(dir, target);
|
|
23298
|
-
}
|
|
23299
|
-
const [, from, to] = /^-ffile-prefix-map=([^=]+)=(.+)$/.exec(mapped) ?? [];
|
|
23300
|
-
const tool = flags[index - 1];
|
|
23301
|
-
return mapped !== flag && from !== to ? [flag, tool, mapped] : [flag];
|
|
23302
|
-
}),
|
|
23303
|
-
...macroPlugins.libraries.flatMap((plugin) => [
|
|
23304
|
-
"-Xswiftc",
|
|
23305
|
-
"-load-plugin-library",
|
|
23306
|
-
"-Xswiftc",
|
|
23307
|
-
plugin
|
|
23308
|
-
]),
|
|
23309
|
-
...macroPlugins.executables.flatMap((plugin) => [
|
|
23310
|
-
"-Xswiftc",
|
|
23311
|
-
"-load-plugin-executable",
|
|
23312
|
-
"-Xswiftc",
|
|
23313
|
-
`${plugin}#ExpoModulesMacros`
|
|
23314
|
-
])
|
|
23315
|
-
];
|
|
23316
|
-
const linked = builtArtifact(layout2);
|
|
23317
|
-
rmSync7(path33.join(root, ".peach-link.rsp"), { force: true });
|
|
23318
|
-
if (options.linkOnly || existsSync9(linked) && statSync5(linked).size <= 8)
|
|
23319
|
-
rmSync7(linked, { force: true });
|
|
23320
|
-
report("compiling and linking Swift modules");
|
|
23321
|
-
const frameworkInterfaces = /* @__PURE__ */ new Map();
|
|
23322
|
-
const sdkFrameworks = path33.join(
|
|
23323
|
-
swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
|
|
23324
|
-
"System/Library/Frameworks"
|
|
23529
|
+
const header = foreign.size ? withoutSwiftDeclarations(
|
|
23530
|
+
own,
|
|
23531
|
+
new Set(foreign.keys()),
|
|
23532
|
+
[...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
|
|
23533
|
+
) : own;
|
|
23534
|
+
const value = {
|
|
23535
|
+
file: path33.join(root2, ".build/peach-framework-objc", `${name}-Swift.h`),
|
|
23536
|
+
header,
|
|
23537
|
+
module: existsSync9(headers)
|
|
23538
|
+
};
|
|
23539
|
+
frameworkInterfaces.set(name, value);
|
|
23540
|
+
writeBuildFile(
|
|
23541
|
+
value.file,
|
|
23542
|
+
(existsSync9(path33.join(headers, `${name}.h`)) ? `#import <${name}/${name}.h>
|
|
23543
|
+
` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
|
|
23325
23544
|
);
|
|
23326
|
-
|
|
23327
|
-
|
|
23328
|
-
|
|
23545
|
+
return value;
|
|
23546
|
+
};
|
|
23547
|
+
const headerPaths = (producer) => {
|
|
23548
|
+
const stem = path33.join(
|
|
23549
|
+
root2,
|
|
23550
|
+
".build",
|
|
23551
|
+
"peach-cxx-headers",
|
|
23552
|
+
`${producer}-Swift`
|
|
23329
23553
|
);
|
|
23330
|
-
|
|
23331
|
-
|
|
23332
|
-
|
|
23333
|
-
|
|
23334
|
-
|
|
23335
|
-
|
|
23336
|
-
|
|
23337
|
-
|
|
23338
|
-
|
|
23339
|
-
|
|
23340
|
-
|
|
23341
|
-
|
|
23342
|
-
|
|
23343
|
-
|
|
23344
|
-
|
|
23345
|
-
|
|
23346
|
-
|
|
23347
|
-
|
|
23348
|
-
|
|
23349
|
-
|
|
23350
|
-
|
|
23351
|
-
|
|
23352
|
-
|
|
23353
|
-
|
|
23354
|
-
|
|
23355
|
-
|
|
23356
|
-
|
|
23357
|
-
|
|
23358
|
-
|
|
23359
|
-
}
|
|
23360
|
-
|
|
23361
|
-
|
|
23362
|
-
|
|
23363
|
-
|
|
23364
|
-
|
|
23365
|
-
|
|
23366
|
-
|
|
23367
|
-
|
|
23368
|
-
|
|
23369
|
-
|
|
23370
|
-
|
|
23371
|
-
|
|
23554
|
+
return { producer, original: `${stem}.original.h`, emitted: `${stem}.h` };
|
|
23555
|
+
};
|
|
23556
|
+
const publishHeader = ({
|
|
23557
|
+
producer,
|
|
23558
|
+
original,
|
|
23559
|
+
emitted
|
|
23560
|
+
}) => {
|
|
23561
|
+
const generated = generatedInterface(original);
|
|
23562
|
+
writeBuildFile(
|
|
23563
|
+
emitted,
|
|
23564
|
+
withoutSwiftDeclarations(
|
|
23565
|
+
swiftHeaderWithSuperclassImports(generated, frameworkInterface),
|
|
23566
|
+
/* @__PURE__ */ new Set([
|
|
23567
|
+
...preparation.nativeHeaderDeclarations[producer] ?? [],
|
|
23568
|
+
...nativelyDeclaredFunctions(generated, nativeHeaders)
|
|
23569
|
+
]),
|
|
23570
|
+
`#import <${producer}/${producer}.h>`
|
|
23571
|
+
)
|
|
23572
|
+
);
|
|
23573
|
+
};
|
|
23574
|
+
const recipe = inputHash.copy().update(
|
|
23575
|
+
distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
|
|
23576
|
+
).update(readFileSync16(path33.join(root2, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
|
|
23577
|
+
const runApp = async (compiler2) => {
|
|
23578
|
+
const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
|
|
23579
|
+
const stages = [
|
|
23580
|
+
...(preparation.nativePrerequisiteTargets ?? []).map((target) => ({
|
|
23581
|
+
target,
|
|
23582
|
+
producers: []
|
|
23583
|
+
})),
|
|
23584
|
+
...preparation.headerBuilds,
|
|
23585
|
+
...(preparation.nativeProductTargets ?? []).map((target) => ({
|
|
23586
|
+
target,
|
|
23587
|
+
producers: []
|
|
23588
|
+
}))
|
|
23589
|
+
];
|
|
23590
|
+
const checkpoints = path33.join(root2, ".build", "peach-product-checkpoints");
|
|
23591
|
+
const buildDbExists = existsSync9(path33.join(root2, ".build", "build.db"));
|
|
23592
|
+
const releaseDir = path33.dirname(linked);
|
|
23593
|
+
for (const { target, producers } of stages) {
|
|
23594
|
+
if (!options.project && producers.length === 0 && buildDbExists) {
|
|
23595
|
+
const expectedObjects = preparation.nativeStageObjects.get(target);
|
|
23596
|
+
if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
|
|
23597
|
+
(relative) => statSync5(path33.join(releaseDir, relative), {
|
|
23598
|
+
throwIfNoEntry: false
|
|
23599
|
+
})?.isFile()
|
|
23600
|
+
))
|
|
23601
|
+
continue;
|
|
23372
23602
|
}
|
|
23373
|
-
|
|
23374
|
-
|
|
23375
|
-
|
|
23376
|
-
generatedInterface(source),
|
|
23377
|
-
declared,
|
|
23378
|
-
nativeDeclarations.has(name) ? `@import ${name};` : `#import <${name}/${name}.h>`
|
|
23603
|
+
const receipt = path33.join(
|
|
23604
|
+
checkpoints,
|
|
23605
|
+
createHash18("sha256").update(target).digest("hex")
|
|
23379
23606
|
);
|
|
23380
|
-
const
|
|
23381
|
-
const
|
|
23382
|
-
|
|
23383
|
-
|
|
23384
|
-
|
|
23385
|
-
|
|
23386
|
-
(
|
|
23387
|
-
|
|
23388
|
-
|
|
23389
|
-
|
|
23390
|
-
if (owner && owner !== name) foreign.set(declaration, owner);
|
|
23391
|
-
}
|
|
23392
|
-
const header = foreign.size ? withoutSwiftDeclarations(
|
|
23393
|
-
own,
|
|
23394
|
-
new Set(foreign.keys()),
|
|
23395
|
-
[...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
|
|
23396
|
-
) : own;
|
|
23397
|
-
const value = {
|
|
23398
|
-
file: path33.join(root, ".build/peach-framework-objc", `${name}-Swift.h`),
|
|
23399
|
-
header,
|
|
23400
|
-
module: existsSync9(headers)
|
|
23401
|
-
};
|
|
23402
|
-
frameworkInterfaces.set(name, value);
|
|
23403
|
-
writeBuildFile(
|
|
23404
|
-
value.file,
|
|
23405
|
-
(existsSync9(path33.join(headers, `${name}.h`)) ? `#import <${name}/${name}.h>
|
|
23406
|
-
` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
|
|
23407
|
-
);
|
|
23408
|
-
return value;
|
|
23409
|
-
};
|
|
23410
|
-
const headerPaths = (producer) => {
|
|
23411
|
-
const stem = path33.join(
|
|
23412
|
-
root,
|
|
23413
|
-
".build",
|
|
23414
|
-
"peach-cxx-headers",
|
|
23415
|
-
`${producer}-Swift`
|
|
23416
|
-
);
|
|
23417
|
-
return { producer, original: `${stem}.original.h`, emitted: `${stem}.h` };
|
|
23418
|
-
};
|
|
23419
|
-
const publishHeader = ({
|
|
23420
|
-
producer,
|
|
23421
|
-
original,
|
|
23422
|
-
emitted
|
|
23423
|
-
}) => {
|
|
23424
|
-
const generated = generatedInterface(original);
|
|
23425
|
-
writeBuildFile(
|
|
23426
|
-
emitted,
|
|
23427
|
-
withoutSwiftDeclarations(
|
|
23428
|
-
swiftHeaderWithSuperclassImports(generated, frameworkInterface),
|
|
23429
|
-
/* @__PURE__ */ new Set([
|
|
23430
|
-
...preparation.nativeHeaderDeclarations[producer] ?? [],
|
|
23431
|
-
...nativelyDeclaredFunctions(generated, nativeHeaders)
|
|
23432
|
-
]),
|
|
23433
|
-
`#import <${producer}/${producer}.h>`
|
|
23434
|
-
)
|
|
23435
|
-
);
|
|
23436
|
-
};
|
|
23437
|
-
const recipe = inputHash.copy().update(
|
|
23438
|
-
distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
|
|
23439
|
-
).update(readFileSync16(path33.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
|
|
23440
|
-
const runApp = async (compiler2) => {
|
|
23441
|
-
const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
|
|
23442
|
-
const stages = [
|
|
23443
|
-
...(preparation.nativePrerequisiteTargets ?? []).map((target) => ({
|
|
23444
|
-
target,
|
|
23445
|
-
producers: []
|
|
23446
|
-
})),
|
|
23447
|
-
...preparation.headerBuilds,
|
|
23448
|
-
...(preparation.nativeProductTargets ?? []).map((target) => ({
|
|
23449
|
-
target,
|
|
23450
|
-
producers: []
|
|
23451
|
-
}))
|
|
23452
|
-
];
|
|
23453
|
-
const checkpoints = path33.join(root, ".build", "peach-product-checkpoints");
|
|
23454
|
-
const buildDbExists = existsSync9(path33.join(root, ".build", "build.db"));
|
|
23455
|
-
const releaseDir = path33.dirname(linked);
|
|
23456
|
-
for (const { target, producers } of stages) {
|
|
23457
|
-
if (!options.project && producers.length === 0 && buildDbExists) {
|
|
23458
|
-
const expectedObjects = preparation.nativeStageObjects.get(target);
|
|
23459
|
-
if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
|
|
23460
|
-
(relative) => statSync5(path33.join(releaseDir, relative), {
|
|
23461
|
-
throwIfNoEntry: false
|
|
23462
|
-
})?.isFile()
|
|
23463
|
-
))
|
|
23464
|
-
continue;
|
|
23465
|
-
}
|
|
23466
|
-
const receipt = path33.join(
|
|
23467
|
-
checkpoints,
|
|
23468
|
-
createHash18("sha256").update(target).digest("hex")
|
|
23469
|
-
);
|
|
23470
|
-
const headers = producers.map(headerPaths);
|
|
23471
|
-
for (const header of headers)
|
|
23472
|
-
if (existsSync9(header.original)) publishHeader(header);
|
|
23473
|
-
const fingerprint = () => {
|
|
23474
|
-
const digest = createHash18("sha256").update(recipe);
|
|
23475
|
-
for (const { original, emitted } of headers) {
|
|
23476
|
-
if (!existsSync9(original) || !existsSync9(emitted)) return;
|
|
23477
|
-
digest.update(
|
|
23478
|
-
createHash18("sha256").update(readFileSync16(emitted)).digest()
|
|
23479
|
-
);
|
|
23480
|
-
}
|
|
23481
|
-
return digest.digest("hex");
|
|
23482
|
-
};
|
|
23483
|
-
if (!options.project && existsSync9(receipt) && readFileSync16(receipt, "utf8") === fingerprint())
|
|
23484
|
-
continue;
|
|
23485
|
-
if (!options.project) rmSync7(receipt, { force: true });
|
|
23486
|
-
for (const header of headers) {
|
|
23487
|
-
if (!existsSync9(header.original))
|
|
23488
|
-
rmSync7(
|
|
23489
|
-
path33.join(
|
|
23490
|
-
path33.dirname(linked),
|
|
23491
|
-
"Modules",
|
|
23492
|
-
`${swiftTargetModuleName(header.producer)}.swiftmodule`
|
|
23493
|
-
),
|
|
23494
|
-
{ force: true }
|
|
23495
|
-
);
|
|
23496
|
-
}
|
|
23497
|
-
await runCompiler(
|
|
23498
|
-
swift,
|
|
23499
|
-
[...buildArgs, "--target", target],
|
|
23500
|
-
optionsWithCompiler,
|
|
23501
|
-
/^(?:\[swift-prebuilt\]|\[\d+\/\d+\] )/,
|
|
23502
|
-
SWIFTPM_NOISE
|
|
23503
|
-
);
|
|
23504
|
-
if (!compiler2) for (const header of headers) publishHeader(header);
|
|
23505
|
-
if (!options.project) {
|
|
23506
|
-
const checkpoint = fingerprint();
|
|
23507
|
-
if (checkpoint === void 0)
|
|
23508
|
-
throw new Error(`missing Swift headers after building ${target}`);
|
|
23509
|
-
mkdirSync8(checkpoints, { recursive: true });
|
|
23510
|
-
writeFileSync8(`${receipt}.partial`, checkpoint);
|
|
23511
|
-
renameSync5(`${receipt}.partial`, receipt);
|
|
23607
|
+
const headers = producers.map(headerPaths);
|
|
23608
|
+
for (const header of headers)
|
|
23609
|
+
if (existsSync9(header.original)) publishHeader(header);
|
|
23610
|
+
const fingerprint = () => {
|
|
23611
|
+
const digest = createHash18("sha256").update(recipe);
|
|
23612
|
+
for (const { original, emitted } of headers) {
|
|
23613
|
+
if (!existsSync9(original) || !existsSync9(emitted)) return;
|
|
23614
|
+
digest.update(
|
|
23615
|
+
createHash18("sha256").update(readFileSync16(emitted)).digest()
|
|
23616
|
+
);
|
|
23512
23617
|
}
|
|
23618
|
+
return digest.digest("hex");
|
|
23619
|
+
};
|
|
23620
|
+
if (!options.project && existsSync9(receipt) && readFileSync16(receipt, "utf8") === fingerprint())
|
|
23621
|
+
continue;
|
|
23622
|
+
if (!options.project) rmSync7(receipt, { force: true });
|
|
23623
|
+
for (const header of headers) {
|
|
23624
|
+
if (!existsSync9(header.original))
|
|
23625
|
+
rmSync7(
|
|
23626
|
+
path33.join(
|
|
23627
|
+
path33.dirname(linked),
|
|
23628
|
+
"Modules",
|
|
23629
|
+
`${swiftTargetModuleName(header.producer)}.swiftmodule`
|
|
23630
|
+
),
|
|
23631
|
+
{ force: true }
|
|
23632
|
+
);
|
|
23513
23633
|
}
|
|
23514
23634
|
await runCompiler(
|
|
23515
23635
|
swift,
|
|
23516
|
-
buildArgs,
|
|
23636
|
+
[...buildArgs, "--target", target],
|
|
23517
23637
|
optionsWithCompiler,
|
|
23518
|
-
|
|
23638
|
+
/^(?:\[swift-prebuilt\]|\[\d+\/\d+\] )/,
|
|
23519
23639
|
SWIFTPM_NOISE
|
|
23520
23640
|
);
|
|
23521
|
-
|
|
23522
|
-
|
|
23523
|
-
|
|
23524
|
-
|
|
23525
|
-
|
|
23526
|
-
|
|
23527
|
-
|
|
23528
|
-
|
|
23529
|
-
|
|
23530
|
-
|
|
23531
|
-
|
|
23532
|
-
|
|
23533
|
-
|
|
23534
|
-
|
|
23535
|
-
|
|
23536
|
-
|
|
23537
|
-
|
|
23538
|
-
|
|
23539
|
-
|
|
23540
|
-
|
|
23541
|
-
|
|
23542
|
-
|
|
23543
|
-
|
|
23544
|
-
|
|
23545
|
-
|
|
23546
|
-
|
|
23547
|
-
|
|
23548
|
-
|
|
23549
|
-
|
|
23550
|
-
|
|
23551
|
-
|
|
23552
|
-
|
|
23553
|
-
|
|
23554
|
-
|
|
23555
|
-
|
|
23556
|
-
|
|
23557
|
-
|
|
23558
|
-
|
|
23559
|
-
|
|
23560
|
-
|
|
23561
|
-
|
|
23562
|
-
|
|
23563
|
-
|
|
23564
|
-
|
|
23565
|
-
|
|
23641
|
+
if (!compiler2) for (const header of headers) publishHeader(header);
|
|
23642
|
+
if (!options.project) {
|
|
23643
|
+
const checkpoint = fingerprint();
|
|
23644
|
+
if (checkpoint === void 0)
|
|
23645
|
+
throw new Error(`missing Swift headers after building ${target}`);
|
|
23646
|
+
mkdirSync8(checkpoints, { recursive: true });
|
|
23647
|
+
writeFileSync8(`${receipt}.partial`, checkpoint);
|
|
23648
|
+
renameSync5(`${receipt}.partial`, receipt);
|
|
23649
|
+
}
|
|
23650
|
+
}
|
|
23651
|
+
await runCompiler(
|
|
23652
|
+
swift,
|
|
23653
|
+
buildArgs,
|
|
23654
|
+
optionsWithCompiler,
|
|
23655
|
+
SWIFTPM_PROGRESS,
|
|
23656
|
+
SWIFTPM_NOISE
|
|
23657
|
+
);
|
|
23658
|
+
};
|
|
23659
|
+
const compileApp = () => preparation.headerCompiler ? withSwiftHeaderCompiler(
|
|
23660
|
+
root2,
|
|
23661
|
+
options.toolchainBin,
|
|
23662
|
+
recipe,
|
|
23663
|
+
new Map(
|
|
23664
|
+
preparation.headerBuilds[0].producers.map((producer) => {
|
|
23665
|
+
const paths = headerPaths(producer);
|
|
23666
|
+
return [
|
|
23667
|
+
swiftTargetModuleName(producer),
|
|
23668
|
+
{
|
|
23669
|
+
header: paths.original,
|
|
23670
|
+
publish: () => publishHeader(paths)
|
|
23671
|
+
}
|
|
23672
|
+
];
|
|
23673
|
+
})
|
|
23674
|
+
),
|
|
23675
|
+
runApp
|
|
23676
|
+
) : runApp();
|
|
23677
|
+
try {
|
|
23678
|
+
if (temporaryDirectory) mkdirSync8(temporaryDirectory, { recursive: true });
|
|
23679
|
+
await compileApp();
|
|
23680
|
+
} catch (error) {
|
|
23681
|
+
const output2 = outputOf(error);
|
|
23682
|
+
const moduleCache = path33.join(
|
|
23683
|
+
root2,
|
|
23684
|
+
".build",
|
|
23685
|
+
WASM_TRIPLE,
|
|
23686
|
+
"release",
|
|
23687
|
+
"ModuleCache"
|
|
23688
|
+
);
|
|
23689
|
+
if (output2.includes("was compiled with module cache path") && existsSync9(moduleCache)) {
|
|
23690
|
+
rmSync7(moduleCache, { recursive: true, force: true });
|
|
23691
|
+
try {
|
|
23692
|
+
await compileApp();
|
|
23693
|
+
} catch (retryError) {
|
|
23566
23694
|
throw new Error(
|
|
23567
|
-
[
|
|
23568
|
-
|
|
23569
|
-
|
|
23570
|
-
|
|
23695
|
+
[
|
|
23696
|
+
...unprepared,
|
|
23697
|
+
projectDiagnostic(outputOf(retryError), layout3, input.files)
|
|
23698
|
+
].join("\n"),
|
|
23699
|
+
{ cause: retryError }
|
|
23571
23700
|
);
|
|
23572
23701
|
}
|
|
23573
|
-
}
|
|
23574
|
-
if (temporaryDirectory)
|
|
23575
|
-
rmSync7(temporaryDirectory, { recursive: true, force: true });
|
|
23576
|
-
if (options.project) endSwiftProjectProcesses(options.project);
|
|
23577
|
-
}
|
|
23578
|
-
if (unprepared.length) throw new Error(unprepared.join("\n"));
|
|
23579
|
-
if (!existsSync9(linked)) {
|
|
23580
|
-
const binDir = path33.dirname(linked);
|
|
23581
|
-
const found = existsSync9(binDir) ? readdirSync6(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
|
|
23702
|
+
} else {
|
|
23582
23703
|
throw new Error(
|
|
23583
|
-
|
|
23704
|
+
[...unprepared, projectDiagnostic(output2, layout3, input.files)].join(
|
|
23705
|
+
"\n"
|
|
23706
|
+
),
|
|
23707
|
+
{ cause: error }
|
|
23584
23708
|
);
|
|
23585
23709
|
}
|
|
23586
|
-
|
|
23587
|
-
|
|
23588
|
-
(
|
|
23710
|
+
} finally {
|
|
23711
|
+
if (temporaryDirectory)
|
|
23712
|
+
rmSync7(temporaryDirectory, { recursive: true, force: true });
|
|
23713
|
+
if (options.project) endSwiftProjectProcesses(options.project);
|
|
23714
|
+
}
|
|
23715
|
+
if (unprepared.length) throw new Error(unprepared.join("\n"));
|
|
23716
|
+
if (!existsSync9(linked)) {
|
|
23717
|
+
const binDir = path33.dirname(linked);
|
|
23718
|
+
const found = existsSync9(binDir) ? readdirSync6(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
|
|
23719
|
+
throw new Error(
|
|
23720
|
+
`swift-compile: the build produced no ${path33.basename(linked)} (found: ${found.join(", ") || "none"})`
|
|
23589
23721
|
);
|
|
23590
|
-
|
|
23591
|
-
|
|
23592
|
-
|
|
23593
|
-
|
|
23594
|
-
|
|
23595
|
-
|
|
23596
|
-
|
|
23597
|
-
|
|
23598
|
-
|
|
23599
|
-
|
|
23600
|
-
|
|
23601
|
-
|
|
23602
|
-
|
|
23603
|
-
|
|
23604
|
-
|
|
23605
|
-
|
|
23606
|
-
|
|
23607
|
-
const optimized = `${output}.optimized`;
|
|
23608
|
-
if (sdkImage && options.project) rmSync7(optimized, { force: true });
|
|
23609
|
-
let sdkAsset;
|
|
23610
|
-
if (guestGraph) {
|
|
23611
|
-
const binding = await compileGuestLink({
|
|
23612
|
-
graph: guestGraph,
|
|
23613
|
-
buildDirectory: root,
|
|
23614
|
-
releaseDirectory: path33.dirname(linked),
|
|
23615
|
-
moduleRoot: frameworkRoot,
|
|
23616
|
-
toolchainBin: options.toolchainBin,
|
|
23617
|
-
swiftCompiler: preparation.headerCompiler ? path33.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? path33.join(options.toolchainBin, "swiftc"),
|
|
23618
|
-
sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
|
|
23619
|
-
sdk: swiftModuleSdk(frameworkRoot),
|
|
23620
|
-
sdkImage,
|
|
23621
|
-
compilerDigest: compilerSourceDigest,
|
|
23622
|
-
project: options.project && {
|
|
23623
|
-
...options.project,
|
|
23624
|
-
env: { ...options.project.env, ...projectProcess?.env }
|
|
23625
|
-
},
|
|
23626
|
-
staticClangTargets: input.staticClangTargets ?? [],
|
|
23627
|
-
resourceReferences,
|
|
23628
|
-
resourceBundles: input.resourceBundles ?? [],
|
|
23629
|
-
generatedOwners: preparation.generatedOwners,
|
|
23630
|
-
output,
|
|
23631
|
-
optimized,
|
|
23632
|
-
optimize: input.optimize === true,
|
|
23633
|
-
jobs: swiftBuildJobs()
|
|
23634
|
-
});
|
|
23635
|
-
if (sdkImage && binding)
|
|
23636
|
-
sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
|
|
23637
|
-
} else if (sdkImage) {
|
|
23638
|
-
const { buildSwiftAppModule } = await import("./swift-sdk-app-module-3JNA7PCB.mjs");
|
|
23639
|
-
const binding = await buildSwiftAppModule({
|
|
23640
|
-
buildRoot: root,
|
|
23641
|
-
toolchainBin: options.toolchainBin,
|
|
23642
|
-
sdk: sdkImage,
|
|
23643
|
-
output: optimized,
|
|
23644
|
-
optimize: input.optimize === true,
|
|
23645
|
-
project: options.project && {
|
|
23646
|
-
...options.project,
|
|
23647
|
-
env: { ...options.project.env, ...projectProcess?.env },
|
|
23648
|
-
sdkRoot: path33.dirname(
|
|
23649
|
-
swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot
|
|
23650
|
-
),
|
|
23651
|
-
linked: output
|
|
23652
|
-
}
|
|
23653
|
-
});
|
|
23654
|
-
sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
|
|
23655
|
-
} else {
|
|
23656
|
-
const bytes = readFileSync16(output);
|
|
23657
|
-
const ordered = orderObjCConstructors(bytes);
|
|
23658
|
-
if (ordered !== bytes) writeFileSync8(output, ordered);
|
|
23659
|
-
await lowerWasm(output, optimized, { optimize: input.optimize === true });
|
|
23660
|
-
}
|
|
23661
|
-
if (!sdkImage)
|
|
23662
|
-
await runCompiler(
|
|
23663
|
-
path33.join(options.toolchainBin, "llvm-objcopy"),
|
|
23664
|
-
["--remove-section=.swift1_autolink_entries", optimized],
|
|
23665
|
-
buildOptions
|
|
23666
|
-
);
|
|
23667
|
-
const artifact = {
|
|
23668
|
-
hash,
|
|
23669
|
-
bytes: readFileSync16(optimized),
|
|
23670
|
-
icu: await icu,
|
|
23671
|
-
sdk: sdkAsset
|
|
23672
|
-
};
|
|
23673
|
-
if (artifact.bytes.length <= 8)
|
|
23722
|
+
}
|
|
23723
|
+
if (options.project) removeProjectLinks(root2);
|
|
23724
|
+
const resourceReferences = Object.values(input.resources ?? {}).map(
|
|
23725
|
+
(value) => Buffer.from(value, "base64")
|
|
23726
|
+
);
|
|
23727
|
+
if (!guestGraph)
|
|
23728
|
+
pruneSwiftWasmLink(
|
|
23729
|
+
root2,
|
|
23730
|
+
options.toolchainBin,
|
|
23731
|
+
prebuilt?.root ?? frameworkRoot,
|
|
23732
|
+
input.staticClangTargets,
|
|
23733
|
+
options.project,
|
|
23734
|
+
void 0,
|
|
23735
|
+
resourceReferences
|
|
23736
|
+
);
|
|
23737
|
+
if (options.linkOnly) {
|
|
23738
|
+
if (statSync5(linked).size <= 8)
|
|
23674
23739
|
throw new Error("swift-compile: deferred linker produced no executable");
|
|
23675
|
-
|
|
23676
|
-
|
|
23677
|
-
report("compiled artifact verified");
|
|
23678
|
-
return retain(root, artifact);
|
|
23679
|
-
} finally {
|
|
23680
|
-
readHold?.release();
|
|
23740
|
+
stage("project link verified");
|
|
23741
|
+
return;
|
|
23681
23742
|
}
|
|
23682
|
-
|
|
23683
|
-
|
|
23684
|
-
|
|
23743
|
+
const output = options.project ? projectOutputFile(root2, linked, options.project) : linked;
|
|
23744
|
+
const optimized = `${output}.optimized`;
|
|
23745
|
+
if (sdkImage && options.project) rmSync7(optimized, { force: true });
|
|
23746
|
+
let sdkAsset;
|
|
23747
|
+
stage("linking the app image");
|
|
23748
|
+
if (guestGraph) {
|
|
23749
|
+
const binding = await compileGuestLink({
|
|
23750
|
+
graph: guestGraph,
|
|
23751
|
+
buildDirectory: root2,
|
|
23752
|
+
releaseDirectory: path33.dirname(linked),
|
|
23753
|
+
moduleRoot: frameworkRoot,
|
|
23754
|
+
toolchainBin: options.toolchainBin,
|
|
23755
|
+
swiftCompiler: preparation.headerCompiler ? path33.join(root2, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? path33.join(options.toolchainBin, "swiftc"),
|
|
23756
|
+
sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
|
|
23757
|
+
sdk: swiftModuleSdk(frameworkRoot),
|
|
23758
|
+
sdkImage,
|
|
23759
|
+
compilerDigest: compilerSourceDigest,
|
|
23760
|
+
project: options.project && {
|
|
23761
|
+
...options.project,
|
|
23762
|
+
env: { ...options.project.env, ...projectProcess?.env }
|
|
23763
|
+
},
|
|
23764
|
+
staticClangTargets: input.staticClangTargets ?? [],
|
|
23765
|
+
resourceReferences,
|
|
23766
|
+
resourceBundles: input.resourceBundles ?? [],
|
|
23767
|
+
generatedOwners: preparation.generatedOwners,
|
|
23768
|
+
output,
|
|
23769
|
+
optimized,
|
|
23770
|
+
optimize: input.optimize === true,
|
|
23771
|
+
jobs: swiftBuildJobs(),
|
|
23772
|
+
onStage: stage
|
|
23773
|
+
});
|
|
23774
|
+
if (sdkImage && binding)
|
|
23775
|
+
sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
|
|
23776
|
+
} else if (sdkImage) {
|
|
23777
|
+
const { buildSwiftAppModule } = await import("./swift-sdk-app-module-U6G5RZV2.mjs");
|
|
23778
|
+
const binding = await buildSwiftAppModule({
|
|
23779
|
+
buildRoot: root2,
|
|
23780
|
+
toolchainBin: options.toolchainBin,
|
|
23781
|
+
sdk: sdkImage,
|
|
23782
|
+
output: optimized,
|
|
23783
|
+
optimize: input.optimize === true,
|
|
23784
|
+
project: options.project && {
|
|
23785
|
+
...options.project,
|
|
23786
|
+
env: { ...options.project.env, ...projectProcess?.env },
|
|
23787
|
+
sdkRoot: path33.dirname(
|
|
23788
|
+
swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot
|
|
23789
|
+
),
|
|
23790
|
+
linked: output
|
|
23791
|
+
}
|
|
23792
|
+
});
|
|
23793
|
+
sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
|
|
23794
|
+
} else {
|
|
23795
|
+
const bytes = readFileSync16(output);
|
|
23796
|
+
const ordered = orderObjCConstructors(bytes);
|
|
23797
|
+
if (ordered !== bytes) writeFileSync8(output, ordered);
|
|
23798
|
+
stage("lowering the app image");
|
|
23799
|
+
await lowerWasm(output, optimized, { optimize: input.optimize === true });
|
|
23800
|
+
}
|
|
23801
|
+
if (!sdkImage)
|
|
23802
|
+
await runCompiler(
|
|
23803
|
+
path33.join(options.toolchainBin, "llvm-objcopy"),
|
|
23804
|
+
["--remove-section=.swift1_autolink_entries", optimized],
|
|
23805
|
+
buildOptions
|
|
23806
|
+
);
|
|
23807
|
+
const artifact = {
|
|
23808
|
+
hash,
|
|
23809
|
+
bytes: readFileSync16(optimized),
|
|
23810
|
+
icu: await icu,
|
|
23811
|
+
sdk: sdkAsset
|
|
23812
|
+
};
|
|
23813
|
+
if (artifact.bytes.length <= 8)
|
|
23814
|
+
throw new Error("swift-compile: deferred linker produced no executable");
|
|
23815
|
+
if (!options.project) saveCompiledArtifact(root2, artifact);
|
|
23816
|
+
saveSharedArtifact(sharedRoot, artifact);
|
|
23817
|
+
stage("compiled artifact verified");
|
|
23818
|
+
return retain(baseRoot, artifact);
|
|
23819
|
+
} finally {
|
|
23820
|
+
readHold?.release();
|
|
23821
|
+
}
|
|
23822
|
+
});
|
|
23685
23823
|
});
|
|
23686
23824
|
},
|
|
23687
23825
|
options.signal
|