peachsim 0.1.2606 → 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 +815 -674
- 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-UL7Z3WUQ.mjs → acorn-KFWXYMX5.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-EXB4QSQI.mjs → chunk-6JPUMAC2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-CPMK3DA6.mjs → chunk-6NDABMDX.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-5JMW5G3U.mjs → chunk-7SKDPTZN.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-MBCSJQRY.mjs → chunk-ACAXWH62.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-25LYRBSX.mjs → chunk-ARYRQJUB.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-KWLQDES2.mjs → chunk-BNAXRY5Q.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-VTZJPPTE.mjs → chunk-CA64UUHF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-OB5XSLW6.mjs → chunk-DBW62F4N.mjs} +3 -2
- package/dist-lib/esm-chunks/{chunk-RTPUFY2K.mjs → chunk-ESS2CG5G.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-O6NRI4T2.mjs → chunk-IGSLOAPL.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5ANQR24T.mjs → chunk-KIIALACX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-66ESCMV3.mjs → chunk-LJZ373SO.mjs} +818 -678
- package/dist-lib/esm-chunks/{chunk-TVICD24H.mjs → chunk-M4ORY3NH.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-34CIYRB7.mjs → chunk-MBWWOGI5.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-QFASF6EH.mjs → chunk-O5BPZVLB.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-L7FPUZZO.mjs → chunk-P5Q5QCTP.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-B7AXR7WA.mjs → chunk-QJUAWJDB.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-O6ZNRBLB.mjs → chunk-RIDXKGBZ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WJKACRMG.mjs → chunk-TD2DBEKQ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-E2TASYAA.mjs → chunk-UTSB5CDG.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-PLOV7VQQ.mjs → chunk-WMWOBH7E.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-XUWYWP35.mjs → chunk-ZNGLVJYL.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-OMUFYOJI.mjs → metro-layout-parser-UY3B6VGU.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-X7EZCX34.mjs → swift-package-prebuilt-HDHPWS44.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-E3IF2XPD.mjs → swift-sdk-app-module-U6G5RZV2.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-57YYLNU6.mjs → swift-sdk-image-PVDA2MVM.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-DZOZTTDZ.mjs → swift-sdk-image-producer-YHPS3KNR.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +814 -673
- 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 +959 -676
- package/dist-lib/host/fetch-proxy-handler.cjs +6 -5
- 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 +6 -4
- package/dist-lib/native-app-identity-project.mjs +17 -17
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +6 -6
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +3 -3
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +2 -2
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +3 -3
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +81 -81
- package/dist-lib/public-origins-lib.json +64 -64
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +2 -2
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +8 -8
- package/dist-lib/skills.cjs +959 -676
- package/dist-lib/swift-compile.cjs +811 -670
- 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 -1
- package/src/agent-prompt.ts +5 -1
- package/src/one-native-controls-package.ts +143 -1
- package/src/oneNativeControlsContract.ts +1 -0
- package/src/swift-compile-budget.ts +28 -7
- package/src/swift-compile.ts +968 -803
- package/src/swift-guest-compile.ts +3 -0
- package/src/swift-toolchain.ts +4 -1
|
@@ -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
|
}
|
|
@@ -22374,6 +22395,7 @@ function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
|
|
|
22374
22395
|
}
|
|
22375
22396
|
}
|
|
22376
22397
|
var frameworkProductsReceiptSchema = object({
|
|
22398
|
+
root: string(),
|
|
22377
22399
|
modules: string(),
|
|
22378
22400
|
objects: array(string()),
|
|
22379
22401
|
lazyObjects: array(string()),
|
|
@@ -22396,24 +22418,18 @@ function readFrameworkProductsReceipt(scratch, receiptKey) {
|
|
|
22396
22418
|
} catch {
|
|
22397
22419
|
return null;
|
|
22398
22420
|
}
|
|
22399
|
-
const
|
|
22400
|
-
|
|
22401
|
-
const archiveMatches = existsSync9(archiveStamp) && readFileSync16(archiveStamp, "utf8") === receiptKey;
|
|
22421
|
+
const archiveRoot = path33.join(scratch, "products-lib", receiptKey);
|
|
22422
|
+
if (parsed.root !== archiveRoot) return null;
|
|
22402
22423
|
if (!existsSync9(parsed.modules)) return null;
|
|
22403
|
-
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
|
+
}
|
|
22404
22427
|
for (const file of parsed.providers) if (!existsSync9(file)) return null;
|
|
22405
22428
|
for (const file of parsed.moduleMaps) if (!existsSync9(file)) return null;
|
|
22406
|
-
if (!archiveMatches) {
|
|
22407
|
-
rmSync7(archive, { recursive: true, force: true });
|
|
22408
|
-
mkdirSync8(archive, { recursive: true });
|
|
22409
|
-
for (const [object2, rel] of parsed.archived)
|
|
22410
|
-
symlinkSync2(object2, path33.join(scratch, rel));
|
|
22411
|
-
writeFileSync8(archiveStamp, receiptKey);
|
|
22412
|
-
}
|
|
22413
22429
|
for (const file of parsed.objects) if (!existsSync9(file)) return null;
|
|
22414
22430
|
for (const file of parsed.lazyObjects) if (!existsSync9(file)) return null;
|
|
22415
22431
|
return {
|
|
22416
|
-
root:
|
|
22432
|
+
root: parsed.root,
|
|
22417
22433
|
modules: parsed.modules,
|
|
22418
22434
|
objects: parsed.objects,
|
|
22419
22435
|
lazyObjects: parsed.lazyObjects,
|
|
@@ -22431,7 +22447,7 @@ async function buildFrameworkProducts(scratch, args) {
|
|
|
22431
22447
|
const selectorOptions = swiftObjCSelectorOptions(args.moduleRoot);
|
|
22432
22448
|
const receiptKey = createHash18("sha256").update(
|
|
22433
22449
|
JSON.stringify([
|
|
22434
|
-
"framework-products/
|
|
22450
|
+
"framework-products/v2",
|
|
22435
22451
|
args.frameworkKey,
|
|
22436
22452
|
unoptimized,
|
|
22437
22453
|
args.sdk,
|
|
@@ -22589,28 +22605,40 @@ async function buildFrameworkProducts(scratch, args) {
|
|
|
22589
22605
|
}
|
|
22590
22606
|
const providers = readdirSync6(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path33.join(providerDir, file));
|
|
22591
22607
|
for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
|
|
22592
|
-
const
|
|
22593
|
-
|
|
22594
|
-
|
|
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 });
|
|
22595
22614
|
const archived = /* @__PURE__ */ new Map();
|
|
22596
|
-
|
|
22597
|
-
const
|
|
22598
|
-
|
|
22599
|
-
|
|
22600
|
-
|
|
22601
|
-
|
|
22602
|
-
|
|
22603
|
-
|
|
22604
|
-
|
|
22605
|
-
|
|
22606
|
-
|
|
22607
|
-
|
|
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
|
+
);
|
|
22608
22636
|
const linkedObjects = objects.map((object2) => {
|
|
22609
22637
|
const name = archived.get(object2);
|
|
22610
|
-
return name ? { path: path33.join(
|
|
22638
|
+
return name ? { path: path33.join(archiveRoot, name), lazy: !roots.has(name) } : { path: object2, lazy: false };
|
|
22611
22639
|
});
|
|
22612
22640
|
const result = {
|
|
22613
|
-
root:
|
|
22641
|
+
root: archiveRoot,
|
|
22614
22642
|
modules: path33.join(release, "Modules"),
|
|
22615
22643
|
objects: linkedObjects.filter((object2) => !object2.lazy).map((object2) => object2.path),
|
|
22616
22644
|
lazyObjects: linkedObjects.filter((object2) => object2.lazy).map((object2) => object2.path),
|
|
@@ -22620,7 +22648,6 @@ ${args.frameworkKey}`, scratch, [
|
|
|
22620
22648
|
moduleMaps: linked.moduleMaps,
|
|
22621
22649
|
objcHeaders: linked.objcHeaders
|
|
22622
22650
|
};
|
|
22623
|
-
writeFileSync8(path33.join(archive, ".receipt"), receiptKey);
|
|
22624
22651
|
const receiptsDir = path33.join(scratch, "products-ready");
|
|
22625
22652
|
mkdirSync8(receiptsDir, { recursive: true });
|
|
22626
22653
|
const receiptFile = path33.join(receiptsDir, `${receiptKey}.json`);
|
|
@@ -22628,6 +22655,7 @@ ${args.frameworkKey}`, scratch, [
|
|
|
22628
22655
|
writeFileSync8(
|
|
22629
22656
|
partialReceipt,
|
|
22630
22657
|
JSON.stringify({
|
|
22658
|
+
root: result.root,
|
|
22631
22659
|
modules: result.modules,
|
|
22632
22660
|
objects: result.objects,
|
|
22633
22661
|
lazyObjects: result.lazyObjects,
|
|
@@ -22648,6 +22676,9 @@ var SWIFT_FRAMEWORK_SLOTS = 8;
|
|
|
22648
22676
|
var SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS = 4;
|
|
22649
22677
|
var SWIFT_FRAMEWORK_SLOT_KEY = ".peach-framework-key";
|
|
22650
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";
|
|
22651
22682
|
function swiftFrameworksDir(unoptimized = false) {
|
|
22652
22683
|
return path33.join(
|
|
22653
22684
|
swiftCacheDir(),
|
|
@@ -22665,7 +22696,10 @@ function swiftFrameworkSlotRecord(slot, record) {
|
|
|
22665
22696
|
function swiftFrameworkSlotKey(slot) {
|
|
22666
22697
|
return swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_KEY);
|
|
22667
22698
|
}
|
|
22668
|
-
|
|
22699
|
+
function swiftFrameworkSlotRelease(slot) {
|
|
22700
|
+
return swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_RELEASE);
|
|
22701
|
+
}
|
|
22702
|
+
async function withSwiftFrameworkSlot(frameworkKey, release, moduleRoot, signal, work, unoptimized = false) {
|
|
22669
22703
|
const slotCount = unoptimized ? SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS : SWIFT_FRAMEWORK_SLOTS;
|
|
22670
22704
|
const slotsDir = swiftFrameworksDir(unoptimized);
|
|
22671
22705
|
const slots = Array.from({ length: slotCount }, (_, index) => {
|
|
@@ -22688,9 +22722,12 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
|
|
|
22688
22722
|
readFileSync16(path33.join(moduleRoot, file))
|
|
22689
22723
|
])
|
|
22690
22724
|
);
|
|
22691
|
-
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 };
|
|
22692
22730
|
let changes = 0;
|
|
22693
|
-
if (swiftFrameworkSlotKey(slot) === null) return { slot, changes: Infinity };
|
|
22694
22731
|
const source = path33.join(slot, "source", "packages", path33.basename(moduleRoot));
|
|
22695
22732
|
for (const [file, contents2] of inputs) {
|
|
22696
22733
|
try {
|
|
@@ -22702,18 +22739,22 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
|
|
|
22702
22739
|
changes++;
|
|
22703
22740
|
}
|
|
22704
22741
|
}
|
|
22705
|
-
return { slot, changes };
|
|
22706
|
-
}).sort(
|
|
22707
|
-
(left
|
|
22708
|
-
|
|
22709
|
-
|
|
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) {
|
|
22710
22751
|
if (await hasLiveSwiftRootReaders(slot, signal)) continue;
|
|
22711
22752
|
const result = await withSwiftRootLock(
|
|
22712
22753
|
slot,
|
|
22713
22754
|
async (lease) => {
|
|
22714
22755
|
if (await hasLiveSwiftRootReaders(slot, signal)) return void 0;
|
|
22715
22756
|
console.error(
|
|
22716
|
-
`[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}`
|
|
22717
22758
|
);
|
|
22718
22759
|
return { value: await run2(slot)(lease) };
|
|
22719
22760
|
},
|
|
@@ -22725,6 +22766,43 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
|
|
|
22725
22766
|
const nearest = ranked[0].slot;
|
|
22726
22767
|
return withSwiftRootLock(nearest, run2(nearest), signal);
|
|
22727
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
|
+
}
|
|
22728
22806
|
function mirrorTree2(source, target, skip) {
|
|
22729
22807
|
mkdirSync8(target, { recursive: true });
|
|
22730
22808
|
const wanted = /* @__PURE__ */ new Set();
|
|
@@ -22774,8 +22852,10 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
|
22774
22852
|
const hadKey = swiftFrameworkSlotKey(slot);
|
|
22775
22853
|
if (hadKey !== frameworkKey) {
|
|
22776
22854
|
rmSync7(path33.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
|
|
22855
|
+
rmSync7(path33.join(slot, SWIFT_FRAMEWORK_SLOT_RELEASE), { force: true });
|
|
22777
22856
|
rmSync7(path33.join(slot, "products-ready"), { recursive: true, force: true });
|
|
22778
|
-
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 });
|
|
22779
22859
|
const moduleRestructured = mirrorTree2(moduleRoot, stagedModule, ".build");
|
|
22780
22860
|
const sdkRestructured = mirrorTree2(
|
|
22781
22861
|
swiftSharedSdkRoot(moduleRoot, false),
|
|
@@ -22803,8 +22883,11 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
|
|
|
22803
22883
|
rmSync7(modules, { recursive: true, force: true });
|
|
22804
22884
|
symlinkSync2(target, modules);
|
|
22805
22885
|
}
|
|
22886
|
+
writeFileSync8(path33.join(slot, SWIFT_FRAMEWORK_SLOT_RELEASE), release);
|
|
22806
22887
|
writeFileSync8(path33.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
|
|
22807
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);
|
|
22808
22891
|
}
|
|
22809
22892
|
return stagedModule;
|
|
22810
22893
|
}
|
|
@@ -22914,7 +22997,7 @@ async function compileSwiftProjectOnce(sources, options) {
|
|
|
22914
22997
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
22915
22998
|
const mirrorDistribution = options.linkOnly || options.project ? null : distribution;
|
|
22916
22999
|
if (distribution) refreshSwiftCacheHold(moduleRoot);
|
|
22917
|
-
const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-
|
|
23000
|
+
const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-HDHPWS44.mjs")).useSwiftPackagePrebuilts(
|
|
22918
23001
|
sources,
|
|
22919
23002
|
moduleRoot,
|
|
22920
23003
|
options.toolchainBin
|
|
@@ -22928,7 +23011,7 @@ async function compileSwiftProjectOnce(sources, options) {
|
|
|
22928
23011
|
multi: compileTargets(input).length > 0
|
|
22929
23012
|
};
|
|
22930
23013
|
const sdkModule = options.sdkModule && !options.linkOnly;
|
|
22931
|
-
const sdkImage = sdkModule ? await (await import("./swift-sdk-image-
|
|
23014
|
+
const sdkImage = sdkModule ? await (await import("./swift-sdk-image-PVDA2MVM.mjs")).buildSwiftSdkImage(
|
|
22932
23015
|
moduleRoot,
|
|
22933
23016
|
!!guestGraph,
|
|
22934
23017
|
distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
|
|
@@ -23032,654 +23115,711 @@ ${cap}` : "";
|
|
|
23032
23115
|
rmSync7(requestRoot, { recursive: true, force: true });
|
|
23033
23116
|
}
|
|
23034
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) : "";
|
|
23035
23131
|
return withSwiftCompileBudget(options.timeoutMs, options.signal, async (budget) => {
|
|
23036
|
-
|
|
23037
|
-
|
|
23038
|
-
|
|
23039
|
-
|
|
23040
|
-
|
|
23041
|
-
|
|
23042
|
-
|
|
23043
|
-
|
|
23044
|
-
|
|
23045
|
-
|
|
23046
|
-
|
|
23047
|
-
|
|
23048
|
-
|
|
23049
|
-
|
|
23050
|
-
|
|
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);
|
|
23051
23174
|
}
|
|
23052
|
-
|
|
23053
|
-
|
|
23054
|
-
|
|
23055
|
-
|
|
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,
|
|
23056
23229
|
budget.signal,
|
|
23057
|
-
|
|
23058
|
-
unoptimized
|
|
23230
|
+
frameworkLease
|
|
23059
23231
|
);
|
|
23060
|
-
const
|
|
23061
|
-
|
|
23062
|
-
|
|
23063
|
-
|
|
23064
|
-
|
|
23065
|
-
|
|
23066
|
-
|
|
23067
|
-
|
|
23068
|
-
|
|
23069
|
-
|
|
23070
|
-
|
|
23071
|
-
|
|
23072
|
-
|
|
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,
|
|
23073
23297
|
frameworkRoot,
|
|
23074
|
-
compileFrameworkRoot,
|
|
23075
|
-
macroPlugins,
|
|
23076
|
-
sdk,
|
|
23077
|
-
icu,
|
|
23078
23298
|
prebuilt,
|
|
23079
|
-
|
|
23080
|
-
|
|
23081
|
-
|
|
23082
|
-
|
|
23083
|
-
|
|
23084
|
-
|
|
23085
|
-
|
|
23086
|
-
|
|
23087
|
-
|
|
23088
|
-
|
|
23089
|
-
|
|
23090
|
-
|
|
23091
|
-
|
|
23092
|
-
|
|
23093
|
-
|
|
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")
|
|
23094
23338
|
);
|
|
23095
|
-
|
|
23096
|
-
|
|
23097
|
-
|
|
23098
|
-
|
|
23099
|
-
|
|
23100
|
-
|
|
23101
|
-
|
|
23102
|
-
|
|
23103
|
-
|
|
23104
|
-
|
|
23105
|
-
|
|
23106
|
-
|
|
23107
|
-
|
|
23108
|
-
|
|
23109
|
-
|
|
23110
|
-
|
|
23111
|
-
|
|
23112
|
-
|
|
23113
|
-
|
|
23114
|
-
frameworkLease
|
|
23115
|
-
}
|
|
23116
|
-
});
|
|
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
|
|
23117
23358
|
}
|
|
23118
|
-
const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
|
|
23119
|
-
return {
|
|
23120
|
-
frameworkRoot: frameworkRoot2,
|
|
23121
|
-
compileFrameworkRoot: compileFrameworkRoot2,
|
|
23122
|
-
macroPlugins: macroPlugins2,
|
|
23123
|
-
sdk: sdk2,
|
|
23124
|
-
icu: icu2,
|
|
23125
|
-
prebuilt: prebuilt2,
|
|
23126
|
-
readHold: readHold2
|
|
23127
|
-
};
|
|
23128
|
-
});
|
|
23129
|
-
const buildOptions = {
|
|
23130
|
-
env: baseBuildEnv,
|
|
23131
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
23132
|
-
signal: budget.signal,
|
|
23133
|
-
lease
|
|
23134
23359
|
};
|
|
23135
|
-
|
|
23136
|
-
|
|
23137
|
-
|
|
23138
|
-
|
|
23139
|
-
|
|
23140
|
-
|
|
23141
|
-
|
|
23142
|
-
|
|
23143
|
-
|
|
23144
|
-
|
|
23145
|
-
|
|
23146
|
-
// the root's mirror keeps its compile inputs at fixed paths
|
|
23147
|
-
frameworkKey: distribution ? `${options.release}\0${distribution.wasmSdkChecksum}` : frameworkKey,
|
|
23148
|
-
prebuilt,
|
|
23149
|
-
packageHostMacros
|
|
23150
|
-
}),
|
|
23151
|
-
Boolean(options.linkOnly)
|
|
23152
|
-
))
|
|
23153
|
-
report("framework revision changed; rebuilding the app link");
|
|
23154
|
-
const nativeToolset = needsNativeToolset(input, prebuilt);
|
|
23155
|
-
const preparation = writeSwiftProject(
|
|
23156
|
-
layout2,
|
|
23157
|
-
input,
|
|
23158
|
-
frameworkRoot,
|
|
23159
|
-
prebuilt,
|
|
23160
|
-
!options.project,
|
|
23161
|
-
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(/\/$/, "")
|
|
23162
23371
|
);
|
|
23163
|
-
|
|
23164
|
-
|
|
23165
|
-
|
|
23166
|
-
|
|
23167
|
-
|
|
23168
|
-
|
|
23169
|
-
|
|
23170
|
-
|
|
23171
|
-
|
|
23172
|
-
|
|
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]))
|
|
23173
23480
|
);
|
|
23174
|
-
const
|
|
23175
|
-
|
|
23176
|
-
|
|
23177
|
-
|
|
23178
|
-
|
|
23179
|
-
|
|
23180
|
-
|
|
23181
|
-
|
|
23182
|
-
|
|
23183
|
-
|
|
23184
|
-
|
|
23185
|
-
|
|
23186
|
-
|
|
23187
|
-
|
|
23188
|
-
|
|
23189
|
-
"done",
|
|
23190
|
-
'case "$target/$compile" in',
|
|
23191
|
-
" *-*-linux*/1)",
|
|
23192
|
-
' case ",$PEACH_SWIFT_HOST_MACROS," in',
|
|
23193
|
-
' *",$module,"*) set -- "$@" -Xfrontend -import-module -Xfrontend Foundation ;;',
|
|
23194
|
-
" esac ;;",
|
|
23195
|
-
"esac",
|
|
23196
|
-
'exec "$PEACH_SWIFTC" "$@"',
|
|
23197
|
-
""
|
|
23198
|
-
].join("\n")
|
|
23199
|
-
);
|
|
23200
|
-
chmodSync3(swiftc, 493);
|
|
23201
|
-
compiler.SWIFT_EXEC = swiftc;
|
|
23202
|
-
compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
|
|
23203
|
-
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;
|
|
23204
23496
|
}
|
|
23205
|
-
const
|
|
23206
|
-
const
|
|
23207
|
-
|
|
23208
|
-
|
|
23209
|
-
|
|
23210
|
-
|
|
23211
|
-
|
|
23212
|
-
|
|
23213
|
-
|
|
23214
|
-
|
|
23215
|
-
|
|
23216
|
-
|
|
23217
|
-
|
|
23218
|
-
|
|
23219
|
-
|
|
23220
|
-
|
|
23221
|
-
|
|
23222
|
-
|
|
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>`
|
|
23223
23516
|
);
|
|
23224
|
-
const
|
|
23225
|
-
|
|
23226
|
-
|
|
23227
|
-
|
|
23228
|
-
|
|
23229
|
-
|
|
23230
|
-
|
|
23231
|
-
|
|
23232
|
-
|
|
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);
|
|
23233
23528
|
}
|
|
23234
|
-
const
|
|
23235
|
-
|
|
23236
|
-
|
|
23237
|
-
|
|
23238
|
-
|
|
23239
|
-
|
|
23240
|
-
"
|
|
23241
|
-
|
|
23242
|
-
|
|
23243
|
-
|
|
23244
|
-
|
|
23245
|
-
|
|
23246
|
-
|
|
23247
|
-
|
|
23248
|
-
|
|
23249
|
-
sdk,
|
|
23250
|
-
...preparation.targetToolset ? ["--toolset", path33.join(root, ".peach-target-toolset.json")] : [],
|
|
23251
|
-
"-c",
|
|
23252
|
-
"release",
|
|
23253
|
-
...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
|
|
23254
|
-
...perFile ? [
|
|
23255
|
-
"-Xswiftc",
|
|
23256
|
-
"-no-whole-module-optimization",
|
|
23257
|
-
"-Xswiftc",
|
|
23258
|
-
"-j",
|
|
23259
|
-
"-Xswiftc",
|
|
23260
|
-
String(jobs)
|
|
23261
|
-
] : [],
|
|
23262
|
-
...incrementalPreview ? ["-Xswiftc", "-incremental", "-Xswiftc", "-enable-batch-mode"] : [],
|
|
23263
|
-
// the mirror finds a changed sdk header's readers in their
|
|
23264
|
-
// dependency files, which omit system headers by default
|
|
23265
|
-
...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
|
|
23266
|
-
// the link strips debug info, so none is generated (as for the framework).
|
|
23267
|
-
// keep -num-threads fixed across caller core caps so llbuild does not
|
|
23268
|
-
// rebuild every target when callers alternate --cores, and bound backend
|
|
23269
|
-
// fan-out under high -j.
|
|
23270
|
-
"-Xswiftc",
|
|
23271
|
-
"-gnone",
|
|
23272
|
-
...incrementalPreview ? [] : [
|
|
23273
|
-
"-Xswiftc",
|
|
23274
|
-
"-num-threads",
|
|
23275
|
-
"-Xswiftc",
|
|
23276
|
-
String(perFile ? 1 : Math.min(8, os4.availableParallelism()))
|
|
23277
|
-
],
|
|
23278
|
-
...swiftReproducibleBuildFlags([
|
|
23279
|
-
[path33.dirname(options.toolchainBin), "toolchain"],
|
|
23280
|
-
[compileFrameworkRoot, "framework"],
|
|
23281
|
-
[root, "build"],
|
|
23282
|
-
...forwarders
|
|
23283
|
-
]).flatMap((flag, index, flags) => {
|
|
23284
|
-
if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
|
|
23285
|
-
return [flag];
|
|
23286
|
-
const toolchainDir = path33.dirname(options.toolchainBin);
|
|
23287
|
-
let mapped = flag;
|
|
23288
|
-
for (const [dir, target] of [
|
|
23289
|
-
[root, "/peach/build"],
|
|
23290
|
-
[compileFrameworkRoot, "/peach/framework"],
|
|
23291
|
-
[realpathSync6(compileFrameworkRoot), "/peach/framework"],
|
|
23292
|
-
[toolchainDir, "/peach/toolchain"],
|
|
23293
|
-
[realpathSync6(toolchainDir), "/peach/toolchain"]
|
|
23294
|
-
]) {
|
|
23295
|
-
mapped = mapped.replaceAll(dir, target);
|
|
23296
|
-
}
|
|
23297
|
-
const [, from, to] = /^-ffile-prefix-map=([^=]+)=(.+)$/.exec(mapped) ?? [];
|
|
23298
|
-
const tool = flags[index - 1];
|
|
23299
|
-
return mapped !== flag && from !== to ? [flag, tool, mapped] : [flag];
|
|
23300
|
-
}),
|
|
23301
|
-
...macroPlugins.libraries.flatMap((plugin) => [
|
|
23302
|
-
"-Xswiftc",
|
|
23303
|
-
"-load-plugin-library",
|
|
23304
|
-
"-Xswiftc",
|
|
23305
|
-
plugin
|
|
23306
|
-
]),
|
|
23307
|
-
...macroPlugins.executables.flatMap((plugin) => [
|
|
23308
|
-
"-Xswiftc",
|
|
23309
|
-
"-load-plugin-executable",
|
|
23310
|
-
"-Xswiftc",
|
|
23311
|
-
`${plugin}#ExpoModulesMacros`
|
|
23312
|
-
])
|
|
23313
|
-
];
|
|
23314
|
-
const linked = builtArtifact(layout2);
|
|
23315
|
-
rmSync7(path33.join(root, ".peach-link.rsp"), { force: true });
|
|
23316
|
-
if (options.linkOnly || existsSync9(linked) && statSync5(linked).size <= 8)
|
|
23317
|
-
rmSync7(linked, { force: true });
|
|
23318
|
-
report("compiling and linking Swift modules");
|
|
23319
|
-
const frameworkInterfaces = /* @__PURE__ */ new Map();
|
|
23320
|
-
const sdkFrameworks = path33.join(
|
|
23321
|
-
swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
|
|
23322
|
-
"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)
|
|
23323
23544
|
);
|
|
23324
|
-
|
|
23325
|
-
|
|
23326
|
-
|
|
23545
|
+
return value;
|
|
23546
|
+
};
|
|
23547
|
+
const headerPaths = (producer) => {
|
|
23548
|
+
const stem = path33.join(
|
|
23549
|
+
root2,
|
|
23550
|
+
".build",
|
|
23551
|
+
"peach-cxx-headers",
|
|
23552
|
+
`${producer}-Swift`
|
|
23327
23553
|
);
|
|
23328
|
-
|
|
23329
|
-
|
|
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
|
-
|
|
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;
|
|
23370
23602
|
}
|
|
23371
|
-
|
|
23372
|
-
|
|
23373
|
-
|
|
23374
|
-
generatedInterface(source),
|
|
23375
|
-
declared,
|
|
23376
|
-
nativeDeclarations.has(name) ? `@import ${name};` : `#import <${name}/${name}.h>`
|
|
23603
|
+
const receipt = path33.join(
|
|
23604
|
+
checkpoints,
|
|
23605
|
+
createHash18("sha256").update(target).digest("hex")
|
|
23377
23606
|
);
|
|
23378
|
-
const
|
|
23379
|
-
const
|
|
23380
|
-
|
|
23381
|
-
|
|
23382
|
-
|
|
23383
|
-
|
|
23384
|
-
(
|
|
23385
|
-
|
|
23386
|
-
|
|
23387
|
-
|
|
23388
|
-
if (owner && owner !== name) foreign.set(declaration, owner);
|
|
23389
|
-
}
|
|
23390
|
-
const header = foreign.size ? withoutSwiftDeclarations(
|
|
23391
|
-
own,
|
|
23392
|
-
new Set(foreign.keys()),
|
|
23393
|
-
[...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
|
|
23394
|
-
) : own;
|
|
23395
|
-
const value = {
|
|
23396
|
-
file: path33.join(root, ".build/peach-framework-objc", `${name}-Swift.h`),
|
|
23397
|
-
header,
|
|
23398
|
-
module: existsSync9(headers)
|
|
23399
|
-
};
|
|
23400
|
-
frameworkInterfaces.set(name, value);
|
|
23401
|
-
writeBuildFile(
|
|
23402
|
-
value.file,
|
|
23403
|
-
(existsSync9(path33.join(headers, `${name}.h`)) ? `#import <${name}/${name}.h>
|
|
23404
|
-
` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
|
|
23405
|
-
);
|
|
23406
|
-
return value;
|
|
23407
|
-
};
|
|
23408
|
-
const headerPaths = (producer) => {
|
|
23409
|
-
const stem = path33.join(
|
|
23410
|
-
root,
|
|
23411
|
-
".build",
|
|
23412
|
-
"peach-cxx-headers",
|
|
23413
|
-
`${producer}-Swift`
|
|
23414
|
-
);
|
|
23415
|
-
return { producer, original: `${stem}.original.h`, emitted: `${stem}.h` };
|
|
23416
|
-
};
|
|
23417
|
-
const publishHeader = ({
|
|
23418
|
-
producer,
|
|
23419
|
-
original,
|
|
23420
|
-
emitted
|
|
23421
|
-
}) => {
|
|
23422
|
-
const generated = generatedInterface(original);
|
|
23423
|
-
writeBuildFile(
|
|
23424
|
-
emitted,
|
|
23425
|
-
withoutSwiftDeclarations(
|
|
23426
|
-
swiftHeaderWithSuperclassImports(generated, frameworkInterface),
|
|
23427
|
-
/* @__PURE__ */ new Set([
|
|
23428
|
-
...preparation.nativeHeaderDeclarations[producer] ?? [],
|
|
23429
|
-
...nativelyDeclaredFunctions(generated, nativeHeaders)
|
|
23430
|
-
]),
|
|
23431
|
-
`#import <${producer}/${producer}.h>`
|
|
23432
|
-
)
|
|
23433
|
-
);
|
|
23434
|
-
};
|
|
23435
|
-
const recipe = inputHash.copy().update(
|
|
23436
|
-
distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
|
|
23437
|
-
).update(readFileSync16(path33.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
|
|
23438
|
-
const runApp = async (compiler2) => {
|
|
23439
|
-
const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
|
|
23440
|
-
const stages = [
|
|
23441
|
-
...(preparation.nativePrerequisiteTargets ?? []).map((target) => ({
|
|
23442
|
-
target,
|
|
23443
|
-
producers: []
|
|
23444
|
-
})),
|
|
23445
|
-
...preparation.headerBuilds,
|
|
23446
|
-
...(preparation.nativeProductTargets ?? []).map((target) => ({
|
|
23447
|
-
target,
|
|
23448
|
-
producers: []
|
|
23449
|
-
}))
|
|
23450
|
-
];
|
|
23451
|
-
const checkpoints = path33.join(root, ".build", "peach-product-checkpoints");
|
|
23452
|
-
const buildDbExists = existsSync9(path33.join(root, ".build", "build.db"));
|
|
23453
|
-
const releaseDir = path33.dirname(linked);
|
|
23454
|
-
for (const { target, producers } of stages) {
|
|
23455
|
-
if (!options.project && producers.length === 0 && buildDbExists) {
|
|
23456
|
-
const expectedObjects = preparation.nativeStageObjects.get(target);
|
|
23457
|
-
if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
|
|
23458
|
-
(relative) => statSync5(path33.join(releaseDir, relative), {
|
|
23459
|
-
throwIfNoEntry: false
|
|
23460
|
-
})?.isFile()
|
|
23461
|
-
))
|
|
23462
|
-
continue;
|
|
23463
|
-
}
|
|
23464
|
-
const receipt = path33.join(
|
|
23465
|
-
checkpoints,
|
|
23466
|
-
createHash18("sha256").update(target).digest("hex")
|
|
23467
|
-
);
|
|
23468
|
-
const headers = producers.map(headerPaths);
|
|
23469
|
-
for (const header of headers)
|
|
23470
|
-
if (existsSync9(header.original)) publishHeader(header);
|
|
23471
|
-
const fingerprint = () => {
|
|
23472
|
-
const digest = createHash18("sha256").update(recipe);
|
|
23473
|
-
for (const { original, emitted } of headers) {
|
|
23474
|
-
if (!existsSync9(original) || !existsSync9(emitted)) return;
|
|
23475
|
-
digest.update(
|
|
23476
|
-
createHash18("sha256").update(readFileSync16(emitted)).digest()
|
|
23477
|
-
);
|
|
23478
|
-
}
|
|
23479
|
-
return digest.digest("hex");
|
|
23480
|
-
};
|
|
23481
|
-
if (!options.project && existsSync9(receipt) && readFileSync16(receipt, "utf8") === fingerprint())
|
|
23482
|
-
continue;
|
|
23483
|
-
if (!options.project) rmSync7(receipt, { force: true });
|
|
23484
|
-
for (const header of headers) {
|
|
23485
|
-
if (!existsSync9(header.original))
|
|
23486
|
-
rmSync7(
|
|
23487
|
-
path33.join(
|
|
23488
|
-
path33.dirname(linked),
|
|
23489
|
-
"Modules",
|
|
23490
|
-
`${swiftTargetModuleName(header.producer)}.swiftmodule`
|
|
23491
|
-
),
|
|
23492
|
-
{ force: true }
|
|
23493
|
-
);
|
|
23494
|
-
}
|
|
23495
|
-
await runCompiler(
|
|
23496
|
-
swift,
|
|
23497
|
-
[...buildArgs, "--target", target],
|
|
23498
|
-
optionsWithCompiler,
|
|
23499
|
-
/^(?:\[swift-prebuilt\]|\[\d+\/\d+\] )/,
|
|
23500
|
-
SWIFTPM_NOISE
|
|
23501
|
-
);
|
|
23502
|
-
if (!compiler2) for (const header of headers) publishHeader(header);
|
|
23503
|
-
if (!options.project) {
|
|
23504
|
-
const checkpoint = fingerprint();
|
|
23505
|
-
if (checkpoint === void 0)
|
|
23506
|
-
throw new Error(`missing Swift headers after building ${target}`);
|
|
23507
|
-
mkdirSync8(checkpoints, { recursive: true });
|
|
23508
|
-
writeFileSync8(`${receipt}.partial`, checkpoint);
|
|
23509
|
-
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
|
+
);
|
|
23510
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
|
+
);
|
|
23511
23633
|
}
|
|
23512
23634
|
await runCompiler(
|
|
23513
23635
|
swift,
|
|
23514
|
-
buildArgs,
|
|
23636
|
+
[...buildArgs, "--target", target],
|
|
23515
23637
|
optionsWithCompiler,
|
|
23516
|
-
|
|
23638
|
+
/^(?:\[swift-prebuilt\]|\[\d+\/\d+\] )/,
|
|
23517
23639
|
SWIFTPM_NOISE
|
|
23518
23640
|
);
|
|
23519
|
-
|
|
23520
|
-
|
|
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
|
-
|
|
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) {
|
|
23564
23694
|
throw new Error(
|
|
23565
|
-
[
|
|
23566
|
-
|
|
23567
|
-
|
|
23568
|
-
|
|
23695
|
+
[
|
|
23696
|
+
...unprepared,
|
|
23697
|
+
projectDiagnostic(outputOf(retryError), layout3, input.files)
|
|
23698
|
+
].join("\n"),
|
|
23699
|
+
{ cause: retryError }
|
|
23569
23700
|
);
|
|
23570
23701
|
}
|
|
23571
|
-
}
|
|
23572
|
-
if (temporaryDirectory)
|
|
23573
|
-
rmSync7(temporaryDirectory, { recursive: true, force: true });
|
|
23574
|
-
if (options.project) endSwiftProjectProcesses(options.project);
|
|
23575
|
-
}
|
|
23576
|
-
if (unprepared.length) throw new Error(unprepared.join("\n"));
|
|
23577
|
-
if (!existsSync9(linked)) {
|
|
23578
|
-
const binDir = path33.dirname(linked);
|
|
23579
|
-
const found = existsSync9(binDir) ? readdirSync6(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
|
|
23702
|
+
} else {
|
|
23580
23703
|
throw new Error(
|
|
23581
|
-
|
|
23704
|
+
[...unprepared, projectDiagnostic(output2, layout3, input.files)].join(
|
|
23705
|
+
"\n"
|
|
23706
|
+
),
|
|
23707
|
+
{ cause: error }
|
|
23582
23708
|
);
|
|
23583
23709
|
}
|
|
23584
|
-
|
|
23585
|
-
|
|
23586
|
-
(
|
|
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"})`
|
|
23587
23721
|
);
|
|
23588
|
-
|
|
23589
|
-
|
|
23590
|
-
|
|
23591
|
-
|
|
23592
|
-
|
|
23593
|
-
|
|
23594
|
-
|
|
23595
|
-
|
|
23596
|
-
|
|
23597
|
-
|
|
23598
|
-
|
|
23599
|
-
|
|
23600
|
-
|
|
23601
|
-
|
|
23602
|
-
|
|
23603
|
-
|
|
23604
|
-
|
|
23605
|
-
const optimized = `${output}.optimized`;
|
|
23606
|
-
if (sdkImage && options.project) rmSync7(optimized, { force: true });
|
|
23607
|
-
let sdkAsset;
|
|
23608
|
-
if (guestGraph) {
|
|
23609
|
-
const binding = await compileGuestLink({
|
|
23610
|
-
graph: guestGraph,
|
|
23611
|
-
buildDirectory: root,
|
|
23612
|
-
releaseDirectory: path33.dirname(linked),
|
|
23613
|
-
moduleRoot: frameworkRoot,
|
|
23614
|
-
toolchainBin: options.toolchainBin,
|
|
23615
|
-
swiftCompiler: preparation.headerCompiler ? path33.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? path33.join(options.toolchainBin, "swiftc"),
|
|
23616
|
-
sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
|
|
23617
|
-
sdk: swiftModuleSdk(frameworkRoot),
|
|
23618
|
-
sdkImage,
|
|
23619
|
-
compilerDigest: compilerSourceDigest,
|
|
23620
|
-
project: options.project && {
|
|
23621
|
-
...options.project,
|
|
23622
|
-
env: { ...options.project.env, ...projectProcess?.env }
|
|
23623
|
-
},
|
|
23624
|
-
staticClangTargets: input.staticClangTargets ?? [],
|
|
23625
|
-
resourceReferences,
|
|
23626
|
-
resourceBundles: input.resourceBundles ?? [],
|
|
23627
|
-
generatedOwners: preparation.generatedOwners,
|
|
23628
|
-
output,
|
|
23629
|
-
optimized,
|
|
23630
|
-
optimize: input.optimize === true,
|
|
23631
|
-
jobs: swiftBuildJobs()
|
|
23632
|
-
});
|
|
23633
|
-
if (sdkImage && binding)
|
|
23634
|
-
sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
|
|
23635
|
-
} else if (sdkImage) {
|
|
23636
|
-
const { buildSwiftAppModule } = await import("./swift-sdk-app-module-E3IF2XPD.mjs");
|
|
23637
|
-
const binding = await buildSwiftAppModule({
|
|
23638
|
-
buildRoot: root,
|
|
23639
|
-
toolchainBin: options.toolchainBin,
|
|
23640
|
-
sdk: sdkImage,
|
|
23641
|
-
output: optimized,
|
|
23642
|
-
optimize: input.optimize === true,
|
|
23643
|
-
project: options.project && {
|
|
23644
|
-
...options.project,
|
|
23645
|
-
env: { ...options.project.env, ...projectProcess?.env },
|
|
23646
|
-
sdkRoot: path33.dirname(
|
|
23647
|
-
swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot
|
|
23648
|
-
),
|
|
23649
|
-
linked: output
|
|
23650
|
-
}
|
|
23651
|
-
});
|
|
23652
|
-
sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
|
|
23653
|
-
} else {
|
|
23654
|
-
const bytes = readFileSync16(output);
|
|
23655
|
-
const ordered = orderObjCConstructors(bytes);
|
|
23656
|
-
if (ordered !== bytes) writeFileSync8(output, ordered);
|
|
23657
|
-
await lowerWasm(output, optimized, { optimize: input.optimize === true });
|
|
23658
|
-
}
|
|
23659
|
-
if (!sdkImage)
|
|
23660
|
-
await runCompiler(
|
|
23661
|
-
path33.join(options.toolchainBin, "llvm-objcopy"),
|
|
23662
|
-
["--remove-section=.swift1_autolink_entries", optimized],
|
|
23663
|
-
buildOptions
|
|
23664
|
-
);
|
|
23665
|
-
const artifact = {
|
|
23666
|
-
hash,
|
|
23667
|
-
bytes: readFileSync16(optimized),
|
|
23668
|
-
icu: await icu,
|
|
23669
|
-
sdk: sdkAsset
|
|
23670
|
-
};
|
|
23671
|
-
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)
|
|
23672
23739
|
throw new Error("swift-compile: deferred linker produced no executable");
|
|
23673
|
-
|
|
23674
|
-
|
|
23675
|
-
report("compiled artifact verified");
|
|
23676
|
-
return retain(root, artifact);
|
|
23677
|
-
} finally {
|
|
23678
|
-
readHold?.release();
|
|
23740
|
+
stage("project link verified");
|
|
23741
|
+
return;
|
|
23679
23742
|
}
|
|
23680
|
-
|
|
23681
|
-
|
|
23682
|
-
|
|
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
|
+
});
|
|
23683
23823
|
});
|
|
23684
23824
|
},
|
|
23685
23825
|
options.signal
|