peachsim 0.1.1808 → 0.1.1811
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/README.md +4 -2
- package/cli/app-bundle-resources.ts +15 -2
- package/cli/cloud-box-artifact.ts +115 -0
- package/cli/cloud-client.ts +95 -53
- package/cli/cloud-dispatch.ts +4 -4
- package/cli/cloud-session.ts +60 -22
- package/cli/commands/box.ts +8 -2
- package/cli/commands/compat.ts +7 -4
- package/cli/commands/control.ts +60 -3
- package/cli/commands/coverage.ts +14 -4
- package/cli/commands/daemon.ts +41 -0
- package/cli/commands/no-bridge-hint.ts +9 -0
- package/cli/commands/package.ts +31 -56
- package/cli/commands/platform.ts +70 -52
- package/cli/commands/preview.ts +73 -24
- package/cli/commands/record.ts +10 -2
- package/cli/commands/screenshot.ts +17 -60
- package/cli/commands/setup.ts +3 -1
- package/cli/commands/three-mode.ts +22 -12
- package/cli/commands/upload.ts +2 -1
- package/cli/desktop-companion.ts +6 -1
- package/cli/drivers/desktop.ts +4 -1
- package/cli/main.ts +12 -2
- package/cli/metro-bundle-assets.ts +14 -4
- package/cli/outbound-endpoints.ts +7 -3
- package/cli/output-redaction.ts +38 -0
- package/cli/privacy.ts +2 -2
- package/cli/recording-access.ts +5 -0
- package/cli/remote-project-bundle.ts +83 -0
- package/cli/shell-init.ts +7 -11
- package/cli/telemetry.ts +41 -4
- package/cli/usage-error.ts +3 -0
- package/cli/ws-bridge.ts +42 -6
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +42783 -40717
- package/dist-lib/capture-contract.cjs +7 -8
- package/dist-lib/capture-contract.mjs +7 -8
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +13 -7
- package/dist-lib/dev-bundle-resolution.cjs +10 -4
- package/dist-lib/expo-swift-bundle.cjs +15819 -15559
- package/dist-lib/expo-swift-metadata.cjs +2 -1
- package/dist-lib/expo-swift-metadata.mjs +2 -1
- package/dist-lib/home-paths.cjs +2 -33
- package/dist-lib/host/bridge-host.cjs +20857 -18756
- package/dist-lib/host/fetch-proxy-handler.cjs +10 -10
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +588 -544
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +25 -19
- package/dist-lib/native-app-identity-project.cjs +15 -6
- package/dist-lib/native-app-identity-project.mjs +23 -12
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +27 -26
- package/dist-lib/public-origins-lib.json +104 -81
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +30496 -24309
- package/dist-lib/swift-compile.cjs +292 -213
- package/dist-lib/swift-compile.mjs +334 -254
- package/dist-lib/swift-package.cjs +8 -4
- package/dist-lib/swift-package.mjs +8 -4
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +32 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +19172 -18941
- package/dist-lib/vite.cjs +11 -11
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/animated.d.ts +4 -0
- package/dist-types/packages/peach-engine/src/engine/animation-graph.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/expo-manifest.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +8 -1
- package/dist-types/packages/peach-globals/src/electronBridgeContract.d.ts +2 -1
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCall.h +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCallCenter.h +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCarrier.h +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTSubscriber.h +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTSubscriberInfo.h +1 -1
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h +1 -1
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSDictionary.h +1 -1
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSExtensionItem.h +1 -1
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/AVFoundation+MPNowPlayingInfoLanguageOptionAdditions.h +39 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/AVPlayerItem+MediaPlayerAdditions.h +26 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPContentItem.h +67 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPError.h +33 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaEntity.h +53 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaItem.h +346 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaItemCollection.h +42 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaLibrary.h +76 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPickerController.h +64 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPlayback.h +47 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPlaylist.h +82 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaQuery.h +120 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaQuerySection.h +26 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMoviePlayerController.h +444 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMoviePlayerViewController.h +43 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerApplicationController.h +47 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerController.h +147 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerQueueDescriptor.h +75 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingInfoCenter.h +197 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingInfoLanguageOption.h +107 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingSession.h +89 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentDataSource.h +59 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentDelegate.h +64 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentManager.h +46 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentManagerContext.h +32 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommand.h +143 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommandCenter.h +66 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommandEvent.h +128 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteControlTypes.h +27 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPVolumeSettings.h +20 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPVolumeView.h +82 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayer.apinotes +74 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayer.h +40 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayerDefines.h +84 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/NSUserActivity+MediaPlayerAdditions.h +20 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityCustomRotor.h +2 -2
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAction.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBackgroundConfiguration.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIButtonConfiguration.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIContextMenuConfiguration.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIContextMenuInteraction.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDeferredMenuElement.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIMenu.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIPointerStyle.h +5 -5
- package/sdk/ios/usr/include/dispatch.modulemap +22 -0
- package/sdk/ios/usr/include/net/if.h +24 -0
- package/sdk/ios/usr/include/sys/time.h +1 -1
- package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +265 -0
- package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2 -0
- package/sdk/ios/wasm/include/fcntl.h +2 -0
- package/sdk/ios/wasm/include/pthread.h +3 -0
- package/sdk/ios/wasm/include/stdlib.h +2 -0
- package/sdk/ios/wasm/include/unistd.h +2 -2
- package/skills/contrast/SKILL.md +2 -2
- package/src/bundle-channel.mjs +9 -72
- package/src/capture-contract.ts +12 -9
- package/src/desktop-host-delivery.ts +16 -2
- package/src/dev-bundle-resolution.ts +12 -3
- package/src/expo-native-workspace.ts +57 -19
- package/src/expo-swift-host.ts +17 -12
- package/src/expo-swift-ready.ts +4 -1
- package/src/expoSwiftContract.ts +1 -0
- package/src/home-paths.ts +4 -48
- package/src/host/bridge-host.ts +1 -0
- package/src/installed-native-libraries.ts +2 -8
- package/src/metro-project-root.ts +2 -1
- package/src/native-bundles.ts +122 -0
- package/src/native-static-libraries.ts +65 -8
- package/src/nitro-adapter.lock.json +278 -278
- package/src/nitro-bundle.ts +2 -2
- package/src/nitro-compile.ts +68 -28
- package/src/nitro-source.ts +24 -6
- package/src/nitro-superset.lock.json +94 -34
- package/src/nitroContract.ts +2 -0
- package/src/podspec-sources.ts +1966 -0
- package/src/storageSnapshotContract.ts +40 -0
- package/src/swift-compile.ts +57 -20
- package/src/swift-design-time.ts +18 -1
- package/src/swift-distribution.lock.json +11 -11
- package/src/swift-distribution.ts +9 -6
- package/src/swift-host.ts +1 -2
- package/src/swift-objc-standin.ts +316 -112
- package/src/swift-package-manifest.ts +4 -3
- package/src/swift-package.ts +10 -3
- package/src/swift-root-lock.ts +11 -0
- package/src/swift-shared-sdk.ts +10 -9
- package/src/swift-source-pods.ts +2 -2
- package/src/swift-standins.ts +40 -143
- package/src/swift-toolchain.ts +42 -0
- package/src/swift-wasm-prune.ts +53 -21
- package/src/turbo-bundle.ts +2 -2
- package/src/turbo-codegen-intake.ts +111 -108
- package/src/turbo-compile.ts +63 -33
- package/src/turbo-runtime.lock.json +21 -21
- package/src/turbo-source.ts +171 -76
- package/src/wasm-optimize.ts +31 -2
- package/src/xcode-project.ts +36 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.1811 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
|
|
3
3
|
// src/swift-compile.ts
|
|
4
4
|
import {
|
|
5
5
|
spawn as spawn3,
|
|
6
|
-
execFileSync as
|
|
6
|
+
execFileSync as execFileSync9
|
|
7
7
|
} from "node:child_process";
|
|
8
8
|
import { createHash as createHash8, randomUUID as randomUUID4 } from "node:crypto";
|
|
9
9
|
import {
|
|
@@ -2094,44 +2094,6 @@ var swift_c_predefines_default = {
|
|
|
2094
2094
|
}
|
|
2095
2095
|
};
|
|
2096
2096
|
|
|
2097
|
-
// src/home-paths.ts
|
|
2098
|
-
import { randomUUID } from "node:crypto";
|
|
2099
|
-
import fs from "node:fs";
|
|
2100
|
-
import { homedir } from "node:os";
|
|
2101
|
-
import path from "node:path";
|
|
2102
|
-
var PEACH_HOME_ENV = "PEACH_HOME";
|
|
2103
|
-
function ambientHomeDir() {
|
|
2104
|
-
return path.join(homedir(), ".peach");
|
|
2105
|
-
}
|
|
2106
|
-
function rnxHomeDir() {
|
|
2107
|
-
const override = process.env[PEACH_HOME_ENV];
|
|
2108
|
-
if (override && override.length > 0) return path.resolve(override);
|
|
2109
|
-
return ambientHomeDir();
|
|
2110
|
-
}
|
|
2111
|
-
function cacheDir() {
|
|
2112
|
-
return path.join(rnxHomeDir(), "cache");
|
|
2113
|
-
}
|
|
2114
|
-
var BUILDERS_ROOT_ENV = "CONTRAST_BUILDERS_ROOT";
|
|
2115
|
-
function buildersRootEnv() {
|
|
2116
|
-
const root = process.env[BUILDERS_ROOT_ENV]?.trim();
|
|
2117
|
-
return root ? root : null;
|
|
2118
|
-
}
|
|
2119
|
-
function swiftCacheDir() {
|
|
2120
|
-
const root = buildersRootEnv();
|
|
2121
|
-
return root ? path.join(root, "peach-cache") : cacheDir();
|
|
2122
|
-
}
|
|
2123
|
-
function swiftPackageCacheOptions() {
|
|
2124
|
-
const root = path.join(swiftCacheDir(), "swiftpm");
|
|
2125
|
-
return [
|
|
2126
|
-
...["cache", "config", "security"].flatMap((name2) => [
|
|
2127
|
-
`--${name2}-path`,
|
|
2128
|
-
path.join(root, name2)
|
|
2129
|
-
]),
|
|
2130
|
-
"--disable-keychain"
|
|
2131
|
-
];
|
|
2132
|
-
}
|
|
2133
|
-
var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
|
|
2134
|
-
|
|
2135
2097
|
// src/process-group.ts
|
|
2136
2098
|
import { spawn, spawnSync as spawnSync3 } from "node:child_process";
|
|
2137
2099
|
import {
|
|
@@ -2547,10 +2509,10 @@ async function terminateProcessGroup(child, signal = "SIGTERM", gracefulTimeoutM
|
|
|
2547
2509
|
}
|
|
2548
2510
|
|
|
2549
2511
|
// src/retired-cache-directory.ts
|
|
2550
|
-
import { randomUUID
|
|
2512
|
+
import { randomUUID } from "node:crypto";
|
|
2551
2513
|
import { renameSync } from "node:fs";
|
|
2552
2514
|
import { rm } from "node:fs/promises";
|
|
2553
|
-
import
|
|
2515
|
+
import path from "node:path";
|
|
2554
2516
|
|
|
2555
2517
|
// src/process-liveness.ts
|
|
2556
2518
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
@@ -2583,8 +2545,8 @@ function removeRetiredDirectory(directory) {
|
|
|
2583
2545
|
function reapRetiredCacheDirectory(parent, name2) {
|
|
2584
2546
|
const owner = /^\.retired-(\d+)-/.exec(name2);
|
|
2585
2547
|
if (!owner || isProcessRunning(Number(owner[1]))) return;
|
|
2586
|
-
const directory =
|
|
2587
|
-
const claimed =
|
|
2548
|
+
const directory = path.join(parent, name2);
|
|
2549
|
+
const claimed = path.join(parent, `.retired-${process.pid}-${randomUUID()}`);
|
|
2588
2550
|
try {
|
|
2589
2551
|
renameSync(directory, claimed);
|
|
2590
2552
|
} catch (error) {
|
|
@@ -2597,16 +2559,16 @@ function reapRetiredCacheDirectory(parent, name2) {
|
|
|
2597
2559
|
// src/swift-compiler-digest.ts
|
|
2598
2560
|
import { createHash } from "node:crypto";
|
|
2599
2561
|
import { readFileSync as readFileSync5 } from "node:fs";
|
|
2600
|
-
import
|
|
2562
|
+
import path3 from "node:path";
|
|
2601
2563
|
|
|
2602
2564
|
// src/swift-objc-sdk-tree.ts
|
|
2603
2565
|
import { readdirSync as readdirSync3, readFileSync as readFileSync4 } from "node:fs";
|
|
2604
|
-
import
|
|
2566
|
+
import path2 from "node:path";
|
|
2605
2567
|
function readIosSdkTree(root) {
|
|
2606
2568
|
return readdirSync3(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => {
|
|
2607
|
-
const file =
|
|
2569
|
+
const file = path2.join(entry.parentPath, entry.name);
|
|
2608
2570
|
return [
|
|
2609
|
-
|
|
2571
|
+
path2.relative(root, file).split(path2.sep).join("/"),
|
|
2610
2572
|
readFileSync4(file, "utf8")
|
|
2611
2573
|
];
|
|
2612
2574
|
}).sort(([a], [b]) => a < b ? -1 : 1);
|
|
@@ -2616,39 +2578,39 @@ function readIosSdkTree(root) {
|
|
|
2616
2578
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
2617
2579
|
import { mkdtempSync as mkdtempSync2, readdirSync as readdirSync5, rmSync as rmSync2, symlinkSync } from "node:fs";
|
|
2618
2580
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
2619
|
-
import
|
|
2581
|
+
import path9 from "node:path";
|
|
2620
2582
|
|
|
2621
2583
|
// src/swift-objc-platform.ts
|
|
2622
2584
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
2623
|
-
import
|
|
2585
|
+
import path5 from "node:path";
|
|
2624
2586
|
|
|
2625
2587
|
// src/swift-toolchain.ts
|
|
2626
2588
|
import { execFile, execFileSync } from "node:child_process";
|
|
2627
2589
|
import { createHash as createHash2 } from "node:crypto";
|
|
2628
|
-
import
|
|
2590
|
+
import fs from "node:fs";
|
|
2629
2591
|
import os from "node:os";
|
|
2630
|
-
import
|
|
2592
|
+
import path4 from "node:path";
|
|
2631
2593
|
import { fileURLToPath } from "node:url";
|
|
2632
2594
|
import { promisify } from "node:util";
|
|
2633
2595
|
function peachsimPackageRoot() {
|
|
2634
2596
|
let dir = import.meta.dirname;
|
|
2635
|
-
while (!
|
|
2636
|
-
dir =
|
|
2597
|
+
while (!fs.existsSync(path4.join(dir, "package.json")) && dir !== path4.dirname(dir))
|
|
2598
|
+
dir = path4.dirname(dir);
|
|
2637
2599
|
return dir;
|
|
2638
2600
|
}
|
|
2639
2601
|
function sourceSwiftCheckout() {
|
|
2640
|
-
return
|
|
2602
|
+
return path4.resolve(peachsimPackageRoot(), "../sootsim-swift");
|
|
2641
2603
|
}
|
|
2642
2604
|
function swiftSdkOptions() {
|
|
2643
2605
|
const directory = process.env.PEACH_SWIFT_SDKS_PATH;
|
|
2644
|
-
if (directory) return ["--swift-sdks-path",
|
|
2606
|
+
if (directory) return ["--swift-sdks-path", path4.resolve(directory)];
|
|
2645
2607
|
if (scratch && process.platform === "linux") {
|
|
2646
2608
|
const config = process.env.XDG_CONFIG_HOME;
|
|
2647
|
-
if (config !== void 0 && !
|
|
2609
|
+
if (config !== void 0 && !path4.isAbsolute(config))
|
|
2648
2610
|
throw new Error("XDG_CONFIG_HOME must be an absolute path");
|
|
2649
2611
|
return [
|
|
2650
2612
|
"--swift-sdks-path",
|
|
2651
|
-
config === void 0 ?
|
|
2613
|
+
config === void 0 ? path4.join(os.userInfo().homedir, ".swiftpm", "swift-sdks") : path4.join(config, "swiftpm", "swift-sdks")
|
|
2652
2614
|
];
|
|
2653
2615
|
}
|
|
2654
2616
|
return [];
|
|
@@ -2813,13 +2775,13 @@ var compilerArchives = {
|
|
|
2813
2775
|
var SWIFT_PRIVATE_DISTRIBUTION_ENV = "PEACH_SWIFT_PRIVATE_DISTRIBUTION";
|
|
2814
2776
|
function privateSwiftDistributionRoot() {
|
|
2815
2777
|
const root = process.env[SWIFT_PRIVATE_DISTRIBUTION_ENV]?.trim();
|
|
2816
|
-
return root ?
|
|
2778
|
+
return root ? path4.resolve(root) : null;
|
|
2817
2779
|
}
|
|
2818
2780
|
function privateSwiftRelease() {
|
|
2819
2781
|
const root = privateSwiftDistributionRoot();
|
|
2820
2782
|
if (!root) return null;
|
|
2821
2783
|
const manifest = JSON.parse(
|
|
2822
|
-
|
|
2784
|
+
fs.readFileSync(path4.join(root, "distribution.json"), "utf8")
|
|
2823
2785
|
);
|
|
2824
2786
|
const release = manifest && typeof manifest === "object" && Reflect.get(manifest, "release");
|
|
2825
2787
|
if (typeof release !== "string")
|
|
@@ -2849,22 +2811,22 @@ function swiftCompilerRelease(release) {
|
|
|
2849
2811
|
function swiftToolchainBin(release) {
|
|
2850
2812
|
if (process.platform === "darwin") {
|
|
2851
2813
|
const dirs = [os.homedir(), "/"].map(
|
|
2852
|
-
(base) =>
|
|
2814
|
+
(base) => path4.join(base, `Library/Developer/Toolchains/${release}.xctoolchain/usr/bin`)
|
|
2853
2815
|
);
|
|
2854
|
-
return dirs.find((dir) =>
|
|
2816
|
+
return dirs.find((dir) => fs.existsSync(path4.join(dir, "swift"))) ?? dirs[0];
|
|
2855
2817
|
}
|
|
2856
2818
|
if (process.env.CONTRAST_SWIFT_TOOLCHAINS) {
|
|
2857
|
-
return
|
|
2819
|
+
return path4.join(process.env.CONTRAST_SWIFT_TOOLCHAINS, release, "usr/bin");
|
|
2858
2820
|
}
|
|
2859
|
-
const image =
|
|
2860
|
-
if (
|
|
2821
|
+
const image = path4.join("/opt/swift", release, "usr/bin");
|
|
2822
|
+
if (fs.existsSync(path4.join(image, "swift"))) return image;
|
|
2861
2823
|
if (release.includes("-custom-"))
|
|
2862
|
-
return
|
|
2863
|
-
return (process.env.PATH ?? "").split(
|
|
2824
|
+
return path4.join(peachHome(), "swift", "toolchains", release, "usr/bin");
|
|
2825
|
+
return (process.env.PATH ?? "").split(path4.delimiter).find((dir) => dir && fs.existsSync(path4.join(dir, "swift"))) ?? image;
|
|
2864
2826
|
}
|
|
2865
2827
|
var SWIFT_AUTOLINK_LINKER = ".peach-wasm-ld";
|
|
2866
2828
|
function writeSwiftAutolinkLinker(directory, toolchainBin) {
|
|
2867
|
-
const linker =
|
|
2829
|
+
const linker = path4.join(directory, SWIFT_AUTOLINK_LINKER);
|
|
2868
2830
|
const script = `#!/bin/sh
|
|
2869
2831
|
set -eu
|
|
2870
2832
|
for arg in "$@"; do
|
|
@@ -2874,7 +2836,7 @@ for arg in "$@"; do
|
|
|
2874
2836
|
awk 'BEGIN { RS = " "; ORS = " " } /^"-l/ { if (seen[$0]++) next } { print }' "$rsp" > "$rsp.dedup"
|
|
2875
2837
|
mv "$rsp.dedup" "$rsp"
|
|
2876
2838
|
if [ "\${PEACH_DEFER_WASM_LINK:-}" = "1" ] && grep -q '"--start-lib"' "$rsp"; then
|
|
2877
|
-
cp "$rsp" ${JSON.stringify(
|
|
2839
|
+
cp "$rsp" ${JSON.stringify(path4.join(directory, ".peach-link.rsp"))}
|
|
2878
2840
|
out=$(awk 'BEGIN { RS = " " } prev == "\\"'-o'\\"" { gsub(/^"|"[[:space:]]*$/, ""); print; exit } { prev = $0 }' "$rsp")
|
|
2879
2841
|
if [ -n "$out" ]; then
|
|
2880
2842
|
printf '\\000asm\\001\\000\\000\\000' > "$out"
|
|
@@ -2884,18 +2846,37 @@ for arg in "$@"; do
|
|
|
2884
2846
|
;;
|
|
2885
2847
|
esac
|
|
2886
2848
|
done
|
|
2887
|
-
exec ${JSON.stringify(
|
|
2849
|
+
exec ${JSON.stringify(path4.join(toolchainBin, "wasm-ld"))} "$@"
|
|
2888
2850
|
`;
|
|
2889
|
-
if (
|
|
2890
|
-
|
|
2851
|
+
if (fs.existsSync(linker) && fs.readFileSync(linker, "utf8") === script) return linker;
|
|
2852
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
2891
2853
|
const next = `${linker}.${process.pid}`;
|
|
2892
|
-
|
|
2893
|
-
|
|
2854
|
+
fs.writeFileSync(next, script, { mode: 493 });
|
|
2855
|
+
fs.renameSync(next, linker);
|
|
2894
2856
|
return linker;
|
|
2895
2857
|
}
|
|
2896
2858
|
function peachHome() {
|
|
2897
2859
|
const override = process.env.PEACH_HOME;
|
|
2898
|
-
return override ?
|
|
2860
|
+
return override ? path4.resolve(override) : path4.join(os.homedir(), ".peach");
|
|
2861
|
+
}
|
|
2862
|
+
var BUILDERS_ROOT_ENV = "CONTRAST_BUILDERS_ROOT";
|
|
2863
|
+
function buildersRootEnv() {
|
|
2864
|
+
const root = process.env[BUILDERS_ROOT_ENV]?.trim();
|
|
2865
|
+
return root ? root : null;
|
|
2866
|
+
}
|
|
2867
|
+
function swiftCacheDir() {
|
|
2868
|
+
const root = buildersRootEnv();
|
|
2869
|
+
return root ? path4.join(root, "peach-cache") : path4.join(peachHome(), "cache");
|
|
2870
|
+
}
|
|
2871
|
+
function swiftPackageCacheOptions() {
|
|
2872
|
+
const root = path4.join(swiftCacheDir(), "swiftpm");
|
|
2873
|
+
return [
|
|
2874
|
+
...["cache", "config", "security"].flatMap((name2) => [
|
|
2875
|
+
`--${name2}-path`,
|
|
2876
|
+
path4.join(root, name2)
|
|
2877
|
+
]),
|
|
2878
|
+
"--disable-keychain"
|
|
2879
|
+
];
|
|
2899
2880
|
}
|
|
2900
2881
|
var scratch;
|
|
2901
2882
|
var linuxLibraryPath;
|
|
@@ -2909,16 +2890,16 @@ function swiftEnvironment(base = process.env) {
|
|
|
2909
2890
|
} : {},
|
|
2910
2891
|
...scratch ? {
|
|
2911
2892
|
TMPDIR: scratch.directory,
|
|
2912
|
-
XDG_CONFIG_HOME:
|
|
2913
|
-
XDG_CACHE_HOME:
|
|
2914
|
-
XDG_DATA_HOME:
|
|
2893
|
+
XDG_CONFIG_HOME: path4.join(scratch.home, ".config"),
|
|
2894
|
+
XDG_CACHE_HOME: path4.join(scratch.home, ".cache"),
|
|
2895
|
+
XDG_DATA_HOME: path4.join(scratch.home, ".local", "share"),
|
|
2915
2896
|
...process.platform === "linux" ? { HOME: scratch.home } : {}
|
|
2916
2897
|
} : {}
|
|
2917
2898
|
};
|
|
2918
2899
|
}
|
|
2919
2900
|
function swiftSourceSdk(root) {
|
|
2920
2901
|
const pin = JSON.parse(
|
|
2921
|
-
|
|
2902
|
+
fs.readFileSync(path4.join(root, "toolchain.json"), "utf8")
|
|
2922
2903
|
);
|
|
2923
2904
|
if (!pin || typeof pin !== "object" || typeof Reflect.get(pin, "wasmSdkId") !== "string" || typeof Reflect.get(pin, "wasmSdkUrl") !== "string" || typeof Reflect.get(pin, "wasmSdkChecksum") !== "string")
|
|
2924
2905
|
throw new Error(`${root} pins no wasm SDK id, url and checksum`);
|
|
@@ -2940,7 +2921,7 @@ function swiftToolchain(release, sdk) {
|
|
|
2940
2921
|
${swiftInstallSteps(release, sdk)}`
|
|
2941
2922
|
);
|
|
2942
2923
|
}
|
|
2943
|
-
const swift =
|
|
2924
|
+
const swift = path4.join(bin, "swift");
|
|
2944
2925
|
const sdks = execFileSync(swift, ["sdk", "list", ...swiftSdkOptions()], {
|
|
2945
2926
|
encoding: "utf8",
|
|
2946
2927
|
env: swiftEnvironment(),
|
|
@@ -2972,31 +2953,31 @@ function swiftSdkBundle(swift, id, options) {
|
|
|
2972
2953
|
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
2973
2954
|
);
|
|
2974
2955
|
const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim();
|
|
2975
|
-
if (!sysroot || !
|
|
2956
|
+
if (!sysroot || !path4.isAbsolute(sysroot))
|
|
2976
2957
|
throw new Error(`Swift SDK ${id} reports no absolute sdkRootPath`);
|
|
2977
2958
|
let bundle = sysroot;
|
|
2978
2959
|
while (!bundle.endsWith(".artifactbundle")) {
|
|
2979
|
-
const parent =
|
|
2960
|
+
const parent = path4.dirname(bundle);
|
|
2980
2961
|
if (parent === bundle)
|
|
2981
2962
|
throw new Error(`Swift SDK ${id} is outside an artifact bundle`);
|
|
2982
2963
|
bundle = parent;
|
|
2983
2964
|
}
|
|
2984
|
-
return
|
|
2965
|
+
return fs.realpathSync(bundle);
|
|
2985
2966
|
}
|
|
2986
2967
|
var sdkFileHashes = /* @__PURE__ */ new Map();
|
|
2987
2968
|
function swiftSdkPayloadChecksum(bundle) {
|
|
2988
2969
|
const hash = createHash2("sha256");
|
|
2989
2970
|
function visit(relative) {
|
|
2990
|
-
const file =
|
|
2991
|
-
const stat =
|
|
2971
|
+
const file = path4.join(bundle, relative);
|
|
2972
|
+
const stat = fs.lstatSync(file, { bigint: true });
|
|
2992
2973
|
if (stat.isSymbolicLink()) {
|
|
2993
|
-
const resolved =
|
|
2994
|
-
if (resolved === ".." || resolved.startsWith(`..${
|
|
2974
|
+
const resolved = path4.relative(bundle, fs.realpathSync(file));
|
|
2975
|
+
if (resolved === ".." || resolved.startsWith(`..${path4.sep}`) || path4.isAbsolute(resolved))
|
|
2995
2976
|
throw new Error(`Swift SDK symlink escapes its bundle: ${relative}`);
|
|
2996
|
-
hash.update(JSON.stringify([relative, "link",
|
|
2977
|
+
hash.update(JSON.stringify([relative, "link", fs.readlinkSync(file)]) + "\n");
|
|
2997
2978
|
} else if (stat.isDirectory()) {
|
|
2998
2979
|
hash.update(JSON.stringify([relative, "directory"]) + "\n");
|
|
2999
|
-
for (const name2 of
|
|
2980
|
+
for (const name2 of fs.readdirSync(file).sort()) visit(path4.join(relative, name2));
|
|
3000
2981
|
} else if (stat.isFile()) {
|
|
3001
2982
|
const stamp = [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(":");
|
|
3002
2983
|
let cached = sdkFileHashes.get(file);
|
|
@@ -3013,8 +2994,8 @@ function swiftSdkPayloadChecksum(bundle) {
|
|
|
3013
2994
|
return hash.digest("hex");
|
|
3014
2995
|
}
|
|
3015
2996
|
function swiftSdkVerificationFile(bundle, sdk) {
|
|
3016
|
-
return
|
|
3017
|
-
|
|
2997
|
+
return path4.join(
|
|
2998
|
+
path4.dirname(bundle),
|
|
3018
2999
|
".peach-sdk-checksums",
|
|
3019
3000
|
`${sdk.wasmSdkId}-${sdk.wasmSdkChecksum}.json`
|
|
3020
3001
|
);
|
|
@@ -3022,11 +3003,11 @@ function swiftSdkVerificationFile(bundle, sdk) {
|
|
|
3022
3003
|
function verifySwiftSdk(swift, sdk) {
|
|
3023
3004
|
const bundle = swiftSdkBundle(swift, sdk.wasmSdkId, swiftSdkOptions());
|
|
3024
3005
|
const file = swiftSdkVerificationFile(bundle, sdk);
|
|
3025
|
-
if (!
|
|
3006
|
+
if (!fs.existsSync(file))
|
|
3026
3007
|
throw new Error(
|
|
3027
3008
|
`Swift SDK ${sdk.wasmSdkId} has no verified archive binding for ${sdk.wasmSdkChecksum}. Hydrate it with installSwiftWasmSdk before compiling.`
|
|
3028
3009
|
);
|
|
3029
|
-
const receipt = JSON.parse(
|
|
3010
|
+
const receipt = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
3030
3011
|
if (!receipt || typeof receipt !== "object" || !("wasmSdkId" in receipt) || receipt.wasmSdkId !== sdk.wasmSdkId || !("wasmSdkChecksum" in receipt) || receipt.wasmSdkChecksum !== sdk.wasmSdkChecksum || !("payloadChecksum" in receipt) || receipt.payloadChecksum !== swiftSdkPayloadChecksum(bundle))
|
|
3031
3012
|
throw new Error(
|
|
3032
3013
|
`Swift SDK ${sdk.wasmSdkId} installed payload differs from its verified archive ${sdk.wasmSdkChecksum}`
|
|
@@ -3034,28 +3015,28 @@ function verifySwiftSdk(swift, sdk) {
|
|
|
3034
3015
|
}
|
|
3035
3016
|
function swiftFileChecksum(file) {
|
|
3036
3017
|
const hash = createHash2("sha256");
|
|
3037
|
-
const fd =
|
|
3018
|
+
const fd = fs.openSync(file, "r");
|
|
3038
3019
|
const buffer = Buffer.allocUnsafe(1024 * 1024);
|
|
3039
3020
|
try {
|
|
3040
|
-
let size =
|
|
3021
|
+
let size = fs.readSync(fd, buffer, 0, buffer.length, null);
|
|
3041
3022
|
while (size > 0) {
|
|
3042
3023
|
hash.update(buffer.subarray(0, size));
|
|
3043
|
-
size =
|
|
3024
|
+
size = fs.readSync(fd, buffer, 0, buffer.length, null);
|
|
3044
3025
|
}
|
|
3045
3026
|
} finally {
|
|
3046
|
-
|
|
3027
|
+
fs.closeSync(fd);
|
|
3047
3028
|
}
|
|
3048
3029
|
return hash.digest("hex");
|
|
3049
3030
|
}
|
|
3050
3031
|
function swiftHostCompilerFiles(release, root) {
|
|
3051
|
-
const file =
|
|
3032
|
+
const file = path4.join(root, "compiler.json");
|
|
3052
3033
|
const pin = release === privateSwiftRelease() ? {
|
|
3053
3034
|
identity: release.replace(/^.*-custom-/, ""),
|
|
3054
3035
|
manifest: swiftFileChecksum(file)
|
|
3055
3036
|
} : swiftHostCompilerArchive(release);
|
|
3056
3037
|
if (swiftFileChecksum(file) !== pin.manifest)
|
|
3057
3038
|
throw new Error(`Swift compiler manifest mismatch at ${root}`);
|
|
3058
|
-
const manifest = JSON.parse(
|
|
3039
|
+
const manifest = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
3059
3040
|
if (!manifest || typeof manifest !== "object" || !("identity" in manifest) || manifest.identity !== pin.identity || !("host" in manifest) || manifest.host !== `${process.platform}-${process.arch}` || !("files" in manifest) || !manifest.files || typeof manifest.files !== "object") {
|
|
3060
3041
|
throw new Error(`Swift compiler identity mismatch at ${root}`);
|
|
3061
3042
|
}
|
|
@@ -3069,7 +3050,7 @@ function swiftHostCompilerFiles(release, root) {
|
|
|
3069
3050
|
}
|
|
3070
3051
|
function verifySwiftHostCompiler(release, root) {
|
|
3071
3052
|
for (const [relative, checksum] of swiftHostCompilerFiles(release, root)) {
|
|
3072
|
-
if (swiftFileChecksum(
|
|
3053
|
+
if (swiftFileChecksum(path4.join(root, relative)) !== checksum)
|
|
3073
3054
|
throw new Error(`Swift compiler binary mismatch: ${relative}`);
|
|
3074
3055
|
}
|
|
3075
3056
|
}
|
|
@@ -3079,8 +3060,8 @@ function swiftCompiler(release) {
|
|
|
3079
3060
|
if (cached) return cached;
|
|
3080
3061
|
const bin = swiftToolchainBin(release);
|
|
3081
3062
|
if (release.includes("-custom-"))
|
|
3082
|
-
verifySwiftHostCompiler(release,
|
|
3083
|
-
const version = execFileSync(
|
|
3063
|
+
verifySwiftHostCompiler(release, path4.resolve(bin, "../.."));
|
|
3064
|
+
const version = execFileSync(path4.join(bin, "swift"), ["--version"], {
|
|
3084
3065
|
encoding: "utf8",
|
|
3085
3066
|
env: swiftEnvironment(),
|
|
3086
3067
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -3098,7 +3079,7 @@ function swiftSdkInstallCommand(release, wasmSdk) {
|
|
|
3098
3079
|
const { wasmSdkId, wasmSdkUrl, wasmSdkChecksum } = wasmSdk;
|
|
3099
3080
|
const program = `import { installSwiftWasmSdk } from "peachsim/swift-toolchain"; installSwiftWasmSdk(${JSON.stringify(release)}, ${JSON.stringify({ wasmSdkId, wasmSdkUrl, wasmSdkChecksum })})`;
|
|
3100
3081
|
const directory = process.env.PEACH_SWIFT_SDKS_PATH;
|
|
3101
|
-
const environment = directory ? `PEACH_SWIFT_SDKS_PATH='${
|
|
3082
|
+
const environment = directory ? `PEACH_SWIFT_SDKS_PATH='${path4.resolve(directory).replaceAll("'", "'\\''")}' ` : "";
|
|
3102
3083
|
return `${environment}node --input-type=module -e '${program.replaceAll("'", "'\\''")}'`;
|
|
3103
3084
|
}
|
|
3104
3085
|
function swiftInstallSteps(release, wasmSdk) {
|
|
@@ -3113,7 +3094,7 @@ function swiftCompilerInstall(release) {
|
|
|
3113
3094
|
return { note: " (private: its builder installs it)", commands: [] };
|
|
3114
3095
|
if (release.includes("-custom-")) {
|
|
3115
3096
|
const archive = swiftHostCompilerArchive(release);
|
|
3116
|
-
const directory =
|
|
3097
|
+
const directory = path4.resolve(swiftToolchainBin(release), "../..");
|
|
3117
3098
|
return {
|
|
3118
3099
|
note: "",
|
|
3119
3100
|
commands: [
|
|
@@ -3158,7 +3139,7 @@ function swiftObjCPlatformFlags(toolchainBin, minimum) {
|
|
|
3158
3139
|
minimum % 100
|
|
3159
3140
|
].join(".");
|
|
3160
3141
|
const result = spawnSync4(
|
|
3161
|
-
|
|
3142
|
+
path5.join(toolchainBin, "clang"),
|
|
3162
3143
|
[
|
|
3163
3144
|
"-target",
|
|
3164
3145
|
`arm64-apple-ios${version}-simulator`,
|
|
@@ -3202,14 +3183,19 @@ var swiftObjCRuntimeFlags = [
|
|
|
3202
3183
|
// src/swift-objc-standin.ts
|
|
3203
3184
|
import { execFileSync as execFileSync2, spawnSync as spawnSync5 } from "node:child_process";
|
|
3204
3185
|
import { createHash as createHash3 } from "node:crypto";
|
|
3205
|
-
import
|
|
3206
|
-
import
|
|
3186
|
+
import fs2 from "node:fs";
|
|
3187
|
+
import path7 from "node:path";
|
|
3188
|
+
|
|
3189
|
+
// src/is-record.ts
|
|
3190
|
+
function isRecord(value) {
|
|
3191
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3192
|
+
}
|
|
3207
3193
|
|
|
3208
3194
|
// src/swift-objc-sdk.ts
|
|
3209
|
-
import
|
|
3195
|
+
import path6 from "node:path";
|
|
3210
3196
|
var IOS_SDK_TARGET = "arm64-apple-ios16.0-simulator";
|
|
3211
3197
|
var OVERLAY_PATH = /^usr\/lib\/swift\/([^/]+)\.swiftmodule\/arm64-apple-ios-simulator\.swiftinterface$/;
|
|
3212
|
-
var tree = typeof __PEACH_BUNDLED_IOS_SDK__ === "undefined" ? readIosSdkTree(
|
|
3198
|
+
var tree = typeof __PEACH_BUNDLED_IOS_SDK__ === "undefined" ? readIosSdkTree(path6.join(peachsimPackageRoot(), "sdk", "ios")) : Object.entries(__PEACH_BUNDLED_IOS_SDK__).sort(([a], [b]) => a < b ? -1 : 1);
|
|
3213
3199
|
var IOS_SDK_HEADERS = {};
|
|
3214
3200
|
var IOS_SDK_OVERLAYS = {};
|
|
3215
3201
|
for (const [file, text2] of tree) {
|
|
@@ -3359,10 +3345,14 @@ var SWIFT_NATIVE_SOURCE_EXTENSIONS = [
|
|
|
3359
3345
|
".def",
|
|
3360
3346
|
".modulemap"
|
|
3361
3347
|
];
|
|
3362
|
-
function clangImportNames(text2) {
|
|
3348
|
+
function clangImportNames(text2, isLocalHeader) {
|
|
3363
3349
|
return [
|
|
3364
|
-
...text2.matchAll(
|
|
3365
|
-
|
|
3350
|
+
...text2.matchAll(
|
|
3351
|
+
/^\s*(?:#\s*(?:import|include)\s*<((\w+)\/[^>]+)>|@import\s+(\w+))/gm
|
|
3352
|
+
)
|
|
3353
|
+
].flatMap(
|
|
3354
|
+
(match) => match[1] && isLocalHeader?.(match[1]) ? [] : [match[2] ?? match[3]]
|
|
3355
|
+
);
|
|
3366
3356
|
}
|
|
3367
3357
|
function moduleMapTokens(text2) {
|
|
3368
3358
|
return (text2.match(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|"[^"]*"|[\w.*]+|[{}\[\]]/g) ?? []).filter((token) => !token.startsWith("/"));
|
|
@@ -3774,15 +3764,15 @@ function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
|
|
|
3774
3764
|
"-fblocks",
|
|
3775
3765
|
...WASI_EMULATION_FLAGS,
|
|
3776
3766
|
"-iframework",
|
|
3777
|
-
|
|
3767
|
+
path7.join(headers, "System/Library/Frameworks"),
|
|
3778
3768
|
"-isystem",
|
|
3779
|
-
|
|
3769
|
+
path7.join(headers, "wasm/include"),
|
|
3780
3770
|
// libxml2 headers sit one level deeper, as in the iOS sdk: a unit
|
|
3781
3771
|
// includes <libxml/parser.h> through usr/include/libxml2, never the parent.
|
|
3782
3772
|
"-I",
|
|
3783
|
-
|
|
3773
|
+
path7.join(headers, "usr/include/libxml2"),
|
|
3784
3774
|
"-idirafter",
|
|
3785
|
-
|
|
3775
|
+
path7.join(headers, "usr/include")
|
|
3786
3776
|
];
|
|
3787
3777
|
}
|
|
3788
3778
|
function iosDeploymentMinimum(version) {
|
|
@@ -3794,49 +3784,49 @@ function iosDeploymentMinimum(version) {
|
|
|
3794
3784
|
// src/swift-shared-sdk.ts
|
|
3795
3785
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
3796
3786
|
import { createHash as createHash4 } from "node:crypto";
|
|
3797
|
-
import
|
|
3798
|
-
import
|
|
3787
|
+
import fs3, { readdirSync as readdirSync4, readFileSync as readFileSync6 } from "node:fs";
|
|
3788
|
+
import path8 from "node:path";
|
|
3799
3789
|
var distributionHeaderRoots = /* @__PURE__ */ new Map();
|
|
3800
3790
|
function swiftSharedSdkRoot(moduleRoot, distribution) {
|
|
3801
|
-
const root =
|
|
3791
|
+
const root = path8.resolve(moduleRoot, distribution ? "sdk/ios" : "../peachsim/sdk/ios");
|
|
3802
3792
|
if (!distribution) return root;
|
|
3803
3793
|
let headers = distributionHeaderRoots.get(root);
|
|
3804
|
-
if (!headers || !
|
|
3805
|
-
const files = readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) =>
|
|
3794
|
+
if (!headers || !fs3.existsSync(headers)) {
|
|
3795
|
+
const files = readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path8.relative(root, path8.join(entry.parentPath, entry.name))).sort();
|
|
3806
3796
|
const hash = createHash4("sha256");
|
|
3807
3797
|
for (const file of files) {
|
|
3808
|
-
const bytes = readFileSync6(
|
|
3798
|
+
const bytes = readFileSync6(path8.join(root, file));
|
|
3809
3799
|
hash.update(JSON.stringify([file, bytes.length])).update(bytes);
|
|
3810
3800
|
}
|
|
3811
|
-
headers =
|
|
3801
|
+
headers = path8.join(
|
|
3812
3802
|
swiftCacheDir(),
|
|
3813
3803
|
"swift-sdk-views",
|
|
3814
3804
|
`headers-${hash.digest("hex")}`
|
|
3815
3805
|
);
|
|
3816
|
-
if (!
|
|
3817
|
-
|
|
3818
|
-
const staging =
|
|
3819
|
-
|
|
3806
|
+
if (!fs3.existsSync(headers)) {
|
|
3807
|
+
fs3.mkdirSync(path8.dirname(headers), { recursive: true });
|
|
3808
|
+
const staging = fs3.mkdtempSync(`${headers}-`);
|
|
3809
|
+
fs3.cpSync(root, staging, { recursive: true, preserveTimestamps: true });
|
|
3820
3810
|
try {
|
|
3821
|
-
|
|
3811
|
+
fs3.renameSync(staging, headers);
|
|
3822
3812
|
} catch (error) {
|
|
3823
|
-
|
|
3824
|
-
if (!
|
|
3813
|
+
fs3.rmSync(staging, { recursive: true, force: true });
|
|
3814
|
+
if (!fs3.existsSync(headers)) throw error;
|
|
3825
3815
|
}
|
|
3826
3816
|
}
|
|
3827
3817
|
distributionHeaderRoots.set(root, headers);
|
|
3828
3818
|
}
|
|
3829
3819
|
const now = /* @__PURE__ */ new Date();
|
|
3830
|
-
|
|
3820
|
+
fs3.utimesSync(headers, now, now);
|
|
3831
3821
|
return headers;
|
|
3832
3822
|
}
|
|
3833
3823
|
function swiftSharedSdkFlags(moduleRoot, distribution) {
|
|
3834
3824
|
const root = swiftSharedSdkRoot(moduleRoot, distribution);
|
|
3835
3825
|
return [
|
|
3836
3826
|
"-isystem",
|
|
3837
|
-
|
|
3827
|
+
path8.join(root, "wasm/storage-include"),
|
|
3838
3828
|
"-idirafter",
|
|
3839
|
-
|
|
3829
|
+
path8.join(root, "usr/include")
|
|
3840
3830
|
];
|
|
3841
3831
|
}
|
|
3842
3832
|
function readULEB(b, o) {
|
|
@@ -3959,53 +3949,53 @@ function weakenBundleInArchive(arBuf) {
|
|
|
3959
3949
|
}
|
|
3960
3950
|
}
|
|
3961
3951
|
function mirrorTree(real, mirror, overrides) {
|
|
3962
|
-
|
|
3963
|
-
for (const entry of
|
|
3964
|
-
const from =
|
|
3965
|
-
const to =
|
|
3952
|
+
fs3.mkdirSync(mirror);
|
|
3953
|
+
for (const entry of fs3.readdirSync(real, { withFileTypes: true })) {
|
|
3954
|
+
const from = path8.join(real, entry.name);
|
|
3955
|
+
const to = path8.join(mirror, entry.name);
|
|
3966
3956
|
const override = overrides.get(from);
|
|
3967
|
-
if (override)
|
|
3968
|
-
else if (
|
|
3969
|
-
else
|
|
3957
|
+
if (override) fs3.symlinkSync(override, to);
|
|
3958
|
+
else if (fs3.statSync(from).isDirectory()) mirrorTree(from, to, overrides);
|
|
3959
|
+
else fs3.symlinkSync(from, to);
|
|
3970
3960
|
}
|
|
3971
3961
|
}
|
|
3972
3962
|
function stageOverlaySlot(realRoot, stagingRoot, relPath) {
|
|
3973
|
-
const segments = relPath.split(
|
|
3963
|
+
const segments = relPath.split(path8.sep);
|
|
3974
3964
|
let real = realRoot;
|
|
3975
3965
|
let mirror = stagingRoot;
|
|
3976
3966
|
for (let i = 0; i < segments.length; i++) {
|
|
3977
3967
|
const segment = segments[i];
|
|
3978
3968
|
for (const entry of readdirSync4(real)) {
|
|
3979
3969
|
if (entry === segment) continue;
|
|
3980
|
-
const dest =
|
|
3981
|
-
if (!
|
|
3982
|
-
|
|
3970
|
+
const dest = path8.join(mirror, entry);
|
|
3971
|
+
if (!fs3.lstatSync(dest, { throwIfNoEntry: false })) {
|
|
3972
|
+
fs3.symlinkSync(path8.join(real, entry), dest);
|
|
3983
3973
|
}
|
|
3984
3974
|
}
|
|
3985
|
-
real =
|
|
3986
|
-
mirror =
|
|
3975
|
+
real = path8.join(real, segment);
|
|
3976
|
+
mirror = path8.join(mirror, segment);
|
|
3987
3977
|
if (i < segments.length - 1) {
|
|
3988
|
-
if (
|
|
3989
|
-
|
|
3978
|
+
if (fs3.lstatSync(mirror, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
3979
|
+
fs3.unlinkSync(mirror);
|
|
3990
3980
|
}
|
|
3991
|
-
|
|
3981
|
+
fs3.mkdirSync(mirror, { recursive: true });
|
|
3992
3982
|
}
|
|
3993
3983
|
}
|
|
3994
|
-
if (
|
|
3995
|
-
|
|
3984
|
+
if (fs3.lstatSync(mirror, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
3985
|
+
fs3.unlinkSync(mirror);
|
|
3996
3986
|
}
|
|
3997
3987
|
return mirror;
|
|
3998
3988
|
}
|
|
3999
3989
|
var sdkViews = /* @__PURE__ */ new Map();
|
|
4000
3990
|
function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk) {
|
|
4001
|
-
const frameworks =
|
|
3991
|
+
const frameworks = path8.join(
|
|
4002
3992
|
swiftSharedSdkRoot(moduleRoot, distribution),
|
|
4003
3993
|
"System/Library/Frameworks"
|
|
4004
3994
|
);
|
|
4005
|
-
const overlay =
|
|
4006
|
-
const overlayFiles = readdirSync4(overlay, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) =>
|
|
3995
|
+
const overlay = path8.join(swiftSharedSdkRoot(moduleRoot, distribution), "wasm/include");
|
|
3996
|
+
const overlayFiles = readdirSync4(overlay, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path8.join(entry.parentPath, entry.name)).sort();
|
|
4007
3997
|
const key = JSON.stringify([
|
|
4008
|
-
"
|
|
3998
|
+
"v11",
|
|
4009
3999
|
toolchainBin,
|
|
4010
4000
|
sdk,
|
|
4011
4001
|
frameworks,
|
|
@@ -4013,9 +4003,9 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
|
|
|
4013
4003
|
swiftSdkOptions()
|
|
4014
4004
|
]);
|
|
4015
4005
|
const cached = sdkViews.get(key);
|
|
4016
|
-
if (cached &&
|
|
4006
|
+
if (cached && fs3.existsSync(cached.manifest)) return touchSdkView(cached.options);
|
|
4017
4007
|
const configuration = execFileSync3(
|
|
4018
|
-
|
|
4008
|
+
path8.join(toolchainBin, "swift"),
|
|
4019
4009
|
[
|
|
4020
4010
|
"sdk",
|
|
4021
4011
|
"configure",
|
|
@@ -4027,67 +4017,67 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
|
|
|
4027
4017
|
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
4028
4018
|
);
|
|
4029
4019
|
const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim();
|
|
4030
|
-
if (!sysroot || !
|
|
4020
|
+
if (!sysroot || !path8.isAbsolute(sysroot))
|
|
4031
4021
|
throw new Error(`swift sdk ${sdk} reports no absolute sdkRootPath`);
|
|
4032
4022
|
let bundle = sysroot;
|
|
4033
4023
|
while (!bundle.endsWith(".artifactbundle")) {
|
|
4034
|
-
if (
|
|
4024
|
+
if (path8.dirname(bundle) === bundle)
|
|
4035
4025
|
throw new Error(`swift sdk ${sdk} is outside an artifact bundle`);
|
|
4036
|
-
bundle =
|
|
4026
|
+
bundle = path8.dirname(bundle);
|
|
4037
4027
|
}
|
|
4038
|
-
const view =
|
|
4028
|
+
const view = path8.join(
|
|
4039
4029
|
swiftCacheDir(),
|
|
4040
4030
|
"swift-sdk-views",
|
|
4041
4031
|
createHash4("sha256").update(key).digest("hex").slice(0, 16)
|
|
4042
4032
|
);
|
|
4043
|
-
const manifest =
|
|
4044
|
-
if (!
|
|
4045
|
-
|
|
4046
|
-
const staging =
|
|
4047
|
-
const realRoot =
|
|
4048
|
-
const overrides =
|
|
4049
|
-
[
|
|
4050
|
-
[
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
]
|
|
4033
|
+
const manifest = path8.join(view, path8.basename(bundle), "info.json");
|
|
4034
|
+
if (!fs3.existsSync(manifest)) {
|
|
4035
|
+
fs3.mkdirSync(path8.dirname(view), { recursive: true });
|
|
4036
|
+
const staging = fs3.mkdtempSync(`${view}-`);
|
|
4037
|
+
const realRoot = path8.dirname(bundle);
|
|
4038
|
+
const overrides = new Map([
|
|
4039
|
+
[path8.join(sysroot, "darwin/System/Library/Frameworks"), frameworks],
|
|
4040
|
+
...["MacTypes.h", "net/if.h"].map((header) => [
|
|
4041
|
+
path8.join(sysroot, "darwin/usr/include", header),
|
|
4042
|
+
path8.join(swiftSharedSdkRoot(moduleRoot, distribution), "usr/include", header)
|
|
4043
|
+
])
|
|
4054
4044
|
]);
|
|
4055
4045
|
for (const file of overlayFiles) {
|
|
4056
4046
|
overrides.set(
|
|
4057
|
-
|
|
4047
|
+
path8.join(sysroot, "darwin/wasm/include", path8.relative(overlay, file)),
|
|
4058
4048
|
file
|
|
4059
4049
|
);
|
|
4060
4050
|
}
|
|
4061
4051
|
mirrorTree(
|
|
4062
4052
|
sysroot,
|
|
4063
|
-
stageOverlaySlot(realRoot, staging,
|
|
4053
|
+
stageOverlaySlot(realRoot, staging, path8.relative(realRoot, sysroot)),
|
|
4064
4054
|
overrides
|
|
4065
4055
|
);
|
|
4066
4056
|
for (const [file, shared] of overrides) {
|
|
4067
|
-
const destination =
|
|
4068
|
-
if (
|
|
4069
|
-
|
|
4070
|
-
|
|
4057
|
+
const destination = path8.join(staging, path8.relative(realRoot, file));
|
|
4058
|
+
if (fs3.lstatSync(destination, { throwIfNoEntry: false })) continue;
|
|
4059
|
+
fs3.mkdirSync(path8.dirname(destination), { recursive: true });
|
|
4060
|
+
fs3.symlinkSync(shared, destination);
|
|
4071
4061
|
}
|
|
4072
|
-
const foundationArchive =
|
|
4073
|
-
|
|
4062
|
+
const foundationArchive = path8.join(
|
|
4063
|
+
path8.dirname(sysroot),
|
|
4074
4064
|
"swift.xctoolchain/usr/lib/swift_static/wasi/libFoundation.a"
|
|
4075
4065
|
);
|
|
4076
|
-
if (
|
|
4066
|
+
if (fs3.existsSync(foundationArchive)) {
|
|
4077
4067
|
const foundationSlot = stageOverlaySlot(
|
|
4078
4068
|
realRoot,
|
|
4079
4069
|
staging,
|
|
4080
|
-
|
|
4070
|
+
path8.relative(realRoot, foundationArchive)
|
|
4081
4071
|
);
|
|
4082
|
-
const arBuf = new Uint8Array(
|
|
4072
|
+
const arBuf = new Uint8Array(fs3.readFileSync(foundationArchive));
|
|
4083
4073
|
weakenBundleInArchive(arBuf);
|
|
4084
|
-
|
|
4074
|
+
fs3.writeFileSync(foundationSlot, arBuf);
|
|
4085
4075
|
}
|
|
4086
4076
|
try {
|
|
4087
|
-
|
|
4077
|
+
fs3.renameSync(staging, view);
|
|
4088
4078
|
} catch (error) {
|
|
4089
|
-
|
|
4090
|
-
if (!
|
|
4079
|
+
fs3.rmSync(staging, { recursive: true, force: true });
|
|
4080
|
+
if (!fs3.existsSync(manifest)) throw error;
|
|
4091
4081
|
}
|
|
4092
4082
|
}
|
|
4093
4083
|
const options = ["--swift-sdks-path", view];
|
|
@@ -4096,28 +4086,28 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
|
|
|
4096
4086
|
}
|
|
4097
4087
|
function touchSdkView(options) {
|
|
4098
4088
|
const now = /* @__PURE__ */ new Date();
|
|
4099
|
-
|
|
4089
|
+
fs3.utimesSync(options[1], now, now);
|
|
4100
4090
|
return options;
|
|
4101
4091
|
}
|
|
4102
4092
|
function swiftSharedSdkInputFiles(moduleRoot) {
|
|
4103
4093
|
const root = swiftSharedSdkRoot(moduleRoot, false);
|
|
4104
|
-
return readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) =>
|
|
4094
|
+
return readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path8.relative(moduleRoot, path8.join(entry.parentPath, entry.name))).sort();
|
|
4105
4095
|
}
|
|
4106
4096
|
|
|
4107
4097
|
// src/swift-darwin-records.ts
|
|
4108
4098
|
var DARWIN_RECORDS_PREFIX = "DarwinRecords-";
|
|
4109
4099
|
var darwinRecordsMinimum = () => iosDeploymentMinimum(NATIVE_GRAPH_SDK_VERSION) ?? 0;
|
|
4110
4100
|
function compileDarwinRecords(args) {
|
|
4111
|
-
const records =
|
|
4112
|
-
const runtime = mkdtempSync2(
|
|
4113
|
-
symlinkSync(
|
|
4101
|
+
const records = path9.join(args.packageRoot, "Sources/DarwinRecords");
|
|
4102
|
+
const runtime = mkdtempSync2(path9.join(tmpdir2(), "peach-objc-runtime-"));
|
|
4103
|
+
symlinkSync(path9.join(args.darwin, "usr/include/objc"), path9.join(runtime, "objc"));
|
|
4114
4104
|
const objects = readdirSync5(records).filter((file) => file.endsWith(".c") || file.endsWith(".m")).sort((a, b) => a < b ? -1 : a > b ? 1 : 0).map((file) => {
|
|
4115
|
-
const object =
|
|
4105
|
+
const object = path9.join(
|
|
4116
4106
|
args.out,
|
|
4117
4107
|
`${DARWIN_RECORDS_PREFIX}${file.replace(/\.[cm]$/, ".o")}`
|
|
4118
4108
|
);
|
|
4119
4109
|
execFileSync4(
|
|
4120
|
-
|
|
4110
|
+
path9.join(args.bin, "clang"),
|
|
4121
4111
|
[
|
|
4122
4112
|
"--target=wasm32-unknown-wasip1",
|
|
4123
4113
|
`--sysroot=${args.sysroot}`,
|
|
@@ -4127,7 +4117,7 @@ function compileDarwinRecords(args) {
|
|
|
4127
4117
|
// __BLOCKS__, as ios builds libmalloc
|
|
4128
4118
|
...file.endsWith(".m") ? [...swiftObjCRuntimeFlags, "-fwasm-exceptions"] : ["-fblocks"],
|
|
4129
4119
|
// assert() keeps __FILE__, which would carry the builder's checkout
|
|
4130
|
-
`-ffile-prefix-map=${records}${
|
|
4120
|
+
`-ffile-prefix-map=${records}${path9.sep}=DarwinRecords/`,
|
|
4131
4121
|
// apple's headers select on the ios identity original units compile
|
|
4132
4122
|
// with, and TargetConditionals.h refuses a compiler without it
|
|
4133
4123
|
...file.endsWith(".m") ? objcSdkIntakeFlags(args.darwin, args.bin, args.minimum) : [
|
|
@@ -4140,7 +4130,7 @@ function compileDarwinRecords(args) {
|
|
|
4140
4130
|
...swiftSharedSdkFlags(args.packageRoot, false)
|
|
4141
4131
|
],
|
|
4142
4132
|
"-c",
|
|
4143
|
-
|
|
4133
|
+
path9.join(records, file),
|
|
4144
4134
|
"-o",
|
|
4145
4135
|
object
|
|
4146
4136
|
],
|
|
@@ -4376,7 +4366,18 @@ function designTimeSites(source) {
|
|
|
4376
4366
|
while (t < to && tokens[t].kind !== "newline") t++;
|
|
4377
4367
|
continue;
|
|
4378
4368
|
}
|
|
4379
|
-
|
|
4369
|
+
const availability = word === "#available" || word === "#unavailable";
|
|
4370
|
+
t++;
|
|
4371
|
+
if (!availability && text(source, tokens[t]) === "<" && tokens[t].start === token.end) {
|
|
4372
|
+
let depth = 0;
|
|
4373
|
+
do {
|
|
4374
|
+
const p = text(source, tokens[t++]);
|
|
4375
|
+
if (p === "<") depth++;
|
|
4376
|
+
else if (p === ">") depth--;
|
|
4377
|
+
} while (t < to && depth > 0);
|
|
4378
|
+
}
|
|
4379
|
+
if (text(source, tokens[t]) === "(") t = skipGroup(t);
|
|
4380
|
+
if (!availability && text(source, tokens[t]) === "{") t = skipGroup(t);
|
|
4380
4381
|
continue;
|
|
4381
4382
|
}
|
|
4382
4383
|
if (token.kind === "at") {
|
|
@@ -4543,11 +4544,6 @@ function designTimeDiagnostic(output, files) {
|
|
|
4543
4544
|
}).join("\n");
|
|
4544
4545
|
}
|
|
4545
4546
|
|
|
4546
|
-
// src/is-record.ts
|
|
4547
|
-
function isRecord(value) {
|
|
4548
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4549
|
-
}
|
|
4550
|
-
|
|
4551
4547
|
// src/swift-distribution-contract.ts
|
|
4552
4548
|
var SWIFT_DISTRIBUTION_MANIFEST = "distribution.json";
|
|
4553
4549
|
var SWIFT_DISTRIBUTION_HOSTS = [
|
|
@@ -4595,7 +4591,7 @@ import { createHash as createHash5 } from "node:crypto";
|
|
|
4595
4591
|
import { existsSync, readFileSync as readFileSync7 } from "node:fs";
|
|
4596
4592
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
4597
4593
|
import os2 from "node:os";
|
|
4598
|
-
import
|
|
4594
|
+
import path10 from "node:path";
|
|
4599
4595
|
import { promisify as promisify2 } from "node:util";
|
|
4600
4596
|
import { brotliCompress, constants as zlibConstants, gunzip, gzip } from "node:zlib";
|
|
4601
4597
|
var run = promisify2(execFile2);
|
|
@@ -4612,8 +4608,8 @@ function cachedBrotli(bytes, quality, cacheKey) {
|
|
|
4612
4608
|
const cacheId = `${quality}:${key}`;
|
|
4613
4609
|
const cached = brotliMemoryCache.get(cacheId);
|
|
4614
4610
|
if (cached) return cached;
|
|
4615
|
-
const dir =
|
|
4616
|
-
const file =
|
|
4611
|
+
const dir = path10.join(os2.homedir(), ".peach", "cache", "swift-brotli");
|
|
4612
|
+
const file = path10.join(dir, `${key}${quality === 11 ? "" : "-q4"}.br`);
|
|
4617
4613
|
const pending = (async () => {
|
|
4618
4614
|
try {
|
|
4619
4615
|
return await readFile(file);
|
|
@@ -4677,7 +4673,7 @@ function swiftIcuAsset(toolchainBin, sdk) {
|
|
|
4677
4673
|
);
|
|
4678
4674
|
}
|
|
4679
4675
|
async function load(toolchainBin, sdk) {
|
|
4680
|
-
const swift =
|
|
4676
|
+
const swift = path10.join(toolchainBin, "swift");
|
|
4681
4677
|
if (!existsSync(swift))
|
|
4682
4678
|
throw new Error(`swift-icu: no swift at ${swift} for the ${sdk} SDK's icu data`);
|
|
4683
4679
|
const { stdout: listed } = await run(swift, ["sdk", "list", ...swiftSdkOptions()], {
|
|
@@ -4700,7 +4696,7 @@ async function load(toolchainBin, sdk) {
|
|
|
4700
4696
|
const resources = /^swiftStaticResourcesPath: (.+)$/m.exec(stdout)?.[1]?.trim();
|
|
4701
4697
|
if (!resources) throw new Error(`swift-icu: ${sdk} names no static resources`);
|
|
4702
4698
|
return Buffer.from(
|
|
4703
|
-
icuSegment(archiveMember(readFileSync7(
|
|
4699
|
+
icuSegment(archiveMember(readFileSync7(path10.join(resources, ARCHIVE)), MEMBER))
|
|
4704
4700
|
);
|
|
4705
4701
|
}
|
|
4706
4702
|
function archiveMember(archive, name2) {
|
|
@@ -4756,8 +4752,8 @@ function icuSegment(object) {
|
|
|
4756
4752
|
}
|
|
4757
4753
|
|
|
4758
4754
|
// src/swift-link-roots.ts
|
|
4759
|
-
import
|
|
4760
|
-
import
|
|
4755
|
+
import fs4 from "node:fs";
|
|
4756
|
+
import path11 from "node:path";
|
|
4761
4757
|
var OBJC_SEGMENTS = ["__objc_cats", "__objc_class_aliases"];
|
|
4762
4758
|
var leb = (bytes, at) => {
|
|
4763
4759
|
let value = 0;
|
|
@@ -4856,7 +4852,7 @@ function swiftObjcRootObjects(id, root, objects) {
|
|
|
4856
4852
|
const cached = rootsByDistribution.get(id);
|
|
4857
4853
|
if (cached) return cached;
|
|
4858
4854
|
const measured = objects.map(
|
|
4859
|
-
(object) => [object, objcSegmentSizes(
|
|
4855
|
+
(object) => [object, objcSegmentSizes(fs4.readFileSync(path11.join(root, object)))]
|
|
4860
4856
|
);
|
|
4861
4857
|
const empty = /* @__PURE__ */ new Map();
|
|
4862
4858
|
for (const [, sizes] of measured)
|
|
@@ -4911,14 +4907,14 @@ import {
|
|
|
4911
4907
|
rmSync as rmSync3,
|
|
4912
4908
|
statSync
|
|
4913
4909
|
} from "node:fs";
|
|
4914
|
-
import
|
|
4910
|
+
import path12 from "node:path";
|
|
4915
4911
|
function prepareSwiftProjectProcess(root, user) {
|
|
4916
4912
|
const home = `${root}.project-home`;
|
|
4917
4913
|
rmSync3(home, { recursive: true, force: true });
|
|
4918
|
-
const tmp =
|
|
4919
|
-
const swiftpm =
|
|
4914
|
+
const tmp = path12.join(home, "tmp");
|
|
4915
|
+
const swiftpm = path12.join(home, "swiftpm");
|
|
4920
4916
|
mkdirSync(tmp, { recursive: true });
|
|
4921
|
-
const caches = ["cache", "config", "security"].map((name2) =>
|
|
4917
|
+
const caches = ["cache", "config", "security"].map((name2) => path12.join(swiftpm, name2));
|
|
4922
4918
|
for (const directory of caches) mkdirSync(directory, { recursive: true });
|
|
4923
4919
|
execFileSync5("chown", ["-R", "-P", `${user.uid}:${user.gid}`, root, home]);
|
|
4924
4920
|
chmodSync(root, 448);
|
|
@@ -4929,14 +4925,14 @@ function prepareSwiftProjectProcess(root, user) {
|
|
|
4929
4925
|
env: {
|
|
4930
4926
|
HOME: home,
|
|
4931
4927
|
TMPDIR: tmp,
|
|
4932
|
-
XDG_CONFIG_HOME:
|
|
4933
|
-
XDG_CACHE_HOME:
|
|
4934
|
-
XDG_DATA_HOME:
|
|
4928
|
+
XDG_CONFIG_HOME: path12.join(home, ".config"),
|
|
4929
|
+
XDG_CACHE_HOME: path12.join(home, ".cache"),
|
|
4930
|
+
XDG_DATA_HOME: path12.join(home, ".local", "share")
|
|
4935
4931
|
},
|
|
4936
4932
|
cacheOptions: [
|
|
4937
4933
|
...["cache", "config", "security"].flatMap((name2) => [
|
|
4938
4934
|
`--${name2}-path`,
|
|
4939
|
-
|
|
4935
|
+
path12.join(swiftpm, name2)
|
|
4940
4936
|
]),
|
|
4941
4937
|
"--disable-keychain"
|
|
4942
4938
|
]
|
|
@@ -4952,7 +4948,7 @@ function projectOutputFile(root, file, user) {
|
|
|
4952
4948
|
const real = realpathSync(file);
|
|
4953
4949
|
const base = realpathSync(root);
|
|
4954
4950
|
const stat = statSync(real);
|
|
4955
|
-
if (!real.startsWith(base +
|
|
4951
|
+
if (!real.startsWith(base + path12.sep) || !stat.isFile() || stat.uid !== user.uid) {
|
|
4956
4952
|
throw new Error(`swift-compile: project output ${file} is not a file of its build`);
|
|
4957
4953
|
}
|
|
4958
4954
|
return real;
|
|
@@ -4961,7 +4957,7 @@ function removeProjectLinks(root) {
|
|
|
4961
4957
|
const pending = [root];
|
|
4962
4958
|
for (let directory = pending.pop(); directory; directory = pending.pop()) {
|
|
4963
4959
|
for (const entry of readdirSync6(directory, { withFileTypes: true })) {
|
|
4964
|
-
const full =
|
|
4960
|
+
const full = path12.join(directory, entry.name);
|
|
4965
4961
|
if (directory === root && entry.name === ".build") continue;
|
|
4966
4962
|
if (directory === root && entry.name.startsWith(".peach-modules-")) {
|
|
4967
4963
|
rmSync3(full, { recursive: true, force: true });
|
|
@@ -5002,7 +4998,26 @@ import {
|
|
|
5002
4998
|
rmSync as rmSync4,
|
|
5003
4999
|
writeFileSync as writeFileSync2
|
|
5004
5000
|
} from "node:fs";
|
|
5001
|
+
import { homedir as homedir2 } from "node:os";
|
|
5005
5002
|
import path14 from "node:path";
|
|
5003
|
+
|
|
5004
|
+
// src/home-paths.ts
|
|
5005
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
5006
|
+
import fs5 from "node:fs";
|
|
5007
|
+
import { homedir } from "node:os";
|
|
5008
|
+
import path13 from "node:path";
|
|
5009
|
+
var PEACH_HOME_ENV = "PEACH_HOME";
|
|
5010
|
+
function ambientHomeDir() {
|
|
5011
|
+
return path13.join(homedir(), ".peach");
|
|
5012
|
+
}
|
|
5013
|
+
function rnxHomeDir() {
|
|
5014
|
+
const override = process.env[PEACH_HOME_ENV];
|
|
5015
|
+
if (override && override.length > 0) return path13.resolve(override);
|
|
5016
|
+
return ambientHomeDir();
|
|
5017
|
+
}
|
|
5018
|
+
var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
|
|
5019
|
+
|
|
5020
|
+
// src/swift-root-lock.ts
|
|
5006
5021
|
var POLL_MS = 250;
|
|
5007
5022
|
var START_TOLERANCE_MS = 2e3;
|
|
5008
5023
|
function errorCode(error) {
|
|
@@ -5775,11 +5790,9 @@ function parseWasmObjectBytes(file, buf, isDist) {
|
|
|
5775
5790
|
}
|
|
5776
5791
|
}
|
|
5777
5792
|
const typePrefixesInObj = /* @__PURE__ */ new Set();
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
typePrefixesInObj.add(symNames[i].slice(0, -2));
|
|
5782
|
-
}
|
|
5793
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
5794
|
+
if ((symFlags[i] & 16) === 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mn")) {
|
|
5795
|
+
typePrefixesInObj.add(symNames[i].slice(0, -2));
|
|
5783
5796
|
}
|
|
5784
5797
|
}
|
|
5785
5798
|
const objcRegisterFuncToTypePrefix = /* @__PURE__ */ new Map();
|
|
@@ -6061,15 +6074,16 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6061
6074
|
set.add(symIdx);
|
|
6062
6075
|
workQueue.push({ kind: "datasym", obj, symIdx });
|
|
6063
6076
|
};
|
|
6064
|
-
const
|
|
6077
|
+
const knownTypes = /* @__PURE__ */ new Set();
|
|
6065
6078
|
for (const o of distObjs.values())
|
|
6066
|
-
for (const t of o.typePrefixesInObj)
|
|
6079
|
+
for (const t of o.typePrefixesInObj) knownTypes.add(t);
|
|
6067
6080
|
const globalLiveTypes = /* @__PURE__ */ new Set();
|
|
6068
6081
|
const pendingConformances = /* @__PURE__ */ new Map();
|
|
6082
|
+
const eagerConformanceObjects = /* @__PURE__ */ new Set();
|
|
6069
6083
|
const conformingType = (name2) => {
|
|
6070
6084
|
for (let n = name2.length - 1; n > 2; n--) {
|
|
6071
6085
|
const prefix = name2.slice(0, n);
|
|
6072
|
-
if (
|
|
6086
|
+
if (knownTypes.has(prefix)) return prefix;
|
|
6073
6087
|
}
|
|
6074
6088
|
return void 0;
|
|
6075
6089
|
};
|
|
@@ -6081,7 +6095,11 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6081
6095
|
const waiting = pendingConformances.get(pref);
|
|
6082
6096
|
if (waiting) {
|
|
6083
6097
|
pendingConformances.delete(pref);
|
|
6084
|
-
for (const w of waiting)
|
|
6098
|
+
for (const w of waiting) {
|
|
6099
|
+
eagerConformanceObjects.add(w.obj);
|
|
6100
|
+
extractObject(w.obj);
|
|
6101
|
+
activateSymbolInObj(w.obj, w.symIdx);
|
|
6102
|
+
}
|
|
6085
6103
|
}
|
|
6086
6104
|
const mnName = `${pref}Mn`;
|
|
6087
6105
|
for (let i = 0; i < obj.symNames.length; i++) {
|
|
@@ -6108,7 +6126,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6108
6126
|
}
|
|
6109
6127
|
};
|
|
6110
6128
|
const checkTypeTrigger = (obj, rawSymName) => {
|
|
6111
|
-
if (!
|
|
6129
|
+
if (!rawSymName) return;
|
|
6112
6130
|
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
6113
6131
|
const objcPref = obj.objcClassSymToTypePrefix.get(sName);
|
|
6114
6132
|
if (objcPref) {
|
|
@@ -6199,6 +6217,13 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6199
6217
|
}
|
|
6200
6218
|
for (const fIdx of obj.rootFuncs) markFuncLive(obj, fIdx);
|
|
6201
6219
|
for (const sIdx of obj.rootSegs) markSegLive(obj, sIdx);
|
|
6220
|
+
for (const name2 of obj.symNames) {
|
|
6221
|
+
const loaded = name2?.match(/^_c_(\w+)__load$/)?.[1];
|
|
6222
|
+
if (!loaded) continue;
|
|
6223
|
+
const classSym = obj.symNames.indexOf(`._OBJC_CLASS_${loaded}`);
|
|
6224
|
+
if (classSym !== -1 && (obj.symFlags[classSym] & 16) === 0)
|
|
6225
|
+
activateSymbolInObj(obj, classSym);
|
|
6226
|
+
}
|
|
6202
6227
|
if (obj.file.endsWith("libswiftCore__Swift.o")) {
|
|
6203
6228
|
for (const pref of obj.typePrefixesInObj) {
|
|
6204
6229
|
if (!pref.startsWith("$ss")) {
|
|
@@ -6223,11 +6248,6 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6223
6248
|
const type = conformingType(mcName);
|
|
6224
6249
|
if (type === void 0 || globalLiveTypes.has(type))
|
|
6225
6250
|
activateSymbolInObj(obj, r.rs);
|
|
6226
|
-
else {
|
|
6227
|
-
let list = pendingConformances.get(type);
|
|
6228
|
-
if (!list) pendingConformances.set(type, list = []);
|
|
6229
|
-
list.push({ obj, symIdx: r.rs });
|
|
6230
|
-
}
|
|
6231
6251
|
}
|
|
6232
6252
|
}
|
|
6233
6253
|
}
|
|
@@ -6235,6 +6255,17 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6235
6255
|
}
|
|
6236
6256
|
}
|
|
6237
6257
|
};
|
|
6258
|
+
for (const obj of distObjs.values()) {
|
|
6259
|
+
if (!obj.isDist) continue;
|
|
6260
|
+
for (const r of obj.dataRelocList) {
|
|
6261
|
+
if (obj.segNames[r.segIdx] !== "swift5_protocol_conformances") continue;
|
|
6262
|
+
const type = conformingType(obj.symNames[r.rs]);
|
|
6263
|
+
if (type === void 0 || obj.typePrefixesInObj.has(type)) continue;
|
|
6264
|
+
let list = pendingConformances.get(type);
|
|
6265
|
+
if (!list) pendingConformances.set(type, list = []);
|
|
6266
|
+
list.push({ obj, symIdx: r.rs });
|
|
6267
|
+
}
|
|
6268
|
+
}
|
|
6238
6269
|
let hasClangObjCEager = false;
|
|
6239
6270
|
const eagerBuildPrunable = [];
|
|
6240
6271
|
for (const f of eagerFiles) {
|
|
@@ -6653,6 +6684,12 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6653
6684
|
emittedPruned.add(ef);
|
|
6654
6685
|
}
|
|
6655
6686
|
}
|
|
6687
|
+
for (const obj of eagerConformanceObjects) {
|
|
6688
|
+
if (!emittedPruned.has(obj.file) && prunedMap.has(obj.file)) {
|
|
6689
|
+
outTokens.push(prunedMap.get(obj.file));
|
|
6690
|
+
emittedPruned.add(obj.file);
|
|
6691
|
+
}
|
|
6692
|
+
}
|
|
6656
6693
|
outTokens.push("--start-lib");
|
|
6657
6694
|
for (const rf of prunableCandidates) {
|
|
6658
6695
|
if (emittedPruned.has(rf)) continue;
|
|
@@ -6828,7 +6865,8 @@ function isSwiftResourceBundles(value) {
|
|
|
6828
6865
|
}
|
|
6829
6866
|
|
|
6830
6867
|
// src/wasm-optimize.ts
|
|
6831
|
-
import {
|
|
6868
|
+
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
6869
|
+
import { BinaryNotFoundError, BINARYEN_VERSION, wasmOpt } from "wasm-opt";
|
|
6832
6870
|
var FEATURES = [
|
|
6833
6871
|
"threads",
|
|
6834
6872
|
"bulk-memory",
|
|
@@ -6842,7 +6880,7 @@ var FEATURES = [
|
|
|
6842
6880
|
"sign-ext"
|
|
6843
6881
|
];
|
|
6844
6882
|
var WASM_OPTIMIZE_IDENTITY = `wasm-opt ${BINARYEN_VERSION} -Oz ${FEATURES.join(",")}`;
|
|
6845
|
-
async function
|
|
6883
|
+
async function runWasmOpt(file, output) {
|
|
6846
6884
|
const result = await wasmOpt([
|
|
6847
6885
|
"-Oz",
|
|
6848
6886
|
...FEATURES.map((feature) => `--enable-${feature}`),
|
|
@@ -6853,6 +6891,29 @@ async function optimizeWasm(file, output) {
|
|
|
6853
6891
|
if (result.status !== 0)
|
|
6854
6892
|
throw new Error(`wasm-opt exited ${result.status}: ${result.stderr}`);
|
|
6855
6893
|
}
|
|
6894
|
+
function installWasmOpt() {
|
|
6895
|
+
try {
|
|
6896
|
+
execFileSync8("npx", ["-y", "wasm-opt", "--wasm-opt-install"], {
|
|
6897
|
+
timeout: 6e5,
|
|
6898
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
6899
|
+
env: { ...process.env, WASM_OPT_VERSION: BINARYEN_VERSION }
|
|
6900
|
+
});
|
|
6901
|
+
} catch (error) {
|
|
6902
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
6903
|
+
throw new Error(`wasm-opt binary missing and on-demand install failed: ${detail}`, {
|
|
6904
|
+
cause: error
|
|
6905
|
+
});
|
|
6906
|
+
}
|
|
6907
|
+
}
|
|
6908
|
+
async function optimizeWasm(file, output) {
|
|
6909
|
+
try {
|
|
6910
|
+
await runWasmOpt(file, output);
|
|
6911
|
+
} catch (error) {
|
|
6912
|
+
if (!(error instanceof BinaryNotFoundError)) throw error;
|
|
6913
|
+
installWasmOpt();
|
|
6914
|
+
await runWasmOpt(file, output);
|
|
6915
|
+
}
|
|
6916
|
+
}
|
|
6856
6917
|
|
|
6857
6918
|
// src/write-build-file.ts
|
|
6858
6919
|
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync10, writeFileSync as writeFileSync3 } from "node:fs";
|
|
@@ -7079,21 +7140,20 @@ function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
|
|
|
7079
7140
|
return { declared: swiftInterfaceDeclarations(header), header };
|
|
7080
7141
|
}
|
|
7081
7142
|
const sources = path19.join(moduleRoot, "Sources", name2);
|
|
7082
|
-
|
|
7143
|
+
const built = path19.join(moduleRoot, ".build/host", `${name2}-Swift.h`);
|
|
7144
|
+
if (!existsSync4(sources) || !existsSync4(built)) return null;
|
|
7083
7145
|
const declared = /* @__PURE__ */ new Set();
|
|
7084
7146
|
for (const file of readdirSync8(sources, { recursive: true, encoding: "utf8" }))
|
|
7085
7147
|
if (file.endsWith(".swift"))
|
|
7086
|
-
for (const [, objc] of readFileSync11(
|
|
7087
|
-
|
|
7148
|
+
for (const [, objc, subclass] of readFileSync11(
|
|
7149
|
+
path19.join(sources, file),
|
|
7150
|
+
"utf8"
|
|
7151
|
+
).matchAll(
|
|
7152
|
+
/@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s|^(?:public|open)\s+(?:final\s+)?class\s+(\w+)\s*:\s*NSObject\b/gm
|
|
7088
7153
|
))
|
|
7089
|
-
declared.add(objc);
|
|
7154
|
+
declared.add(objc ?? subclass);
|
|
7090
7155
|
if (declared.size === 0) return null;
|
|
7091
|
-
|
|
7092
|
-
return {
|
|
7093
|
-
declared,
|
|
7094
|
-
header: existsSync4(built) ? clangInterfaceHeader(readFileSync11(built, "utf8")) : `// ${name2}-Swift.h is generated when ${name2} builds
|
|
7095
|
-
`
|
|
7096
|
-
};
|
|
7156
|
+
return { declared, header: clangInterfaceHeader(readFileSync11(built, "utf8")) };
|
|
7097
7157
|
}
|
|
7098
7158
|
var clangInterfaceHeader = (header) => header.replace(/^@import (?:UIKitCore|UIKitText);$/gm, "@import UIKit;").replace(/^@import CoreFoundation;$/gm, "@import Foundation;").replace(/\b_TtC10Foundation\d+(NS\w+)\b/g, "$1");
|
|
7099
7159
|
var swiftInterfaceDeclarations = (header) => /* @__PURE__ */ new Set([
|
|
@@ -7309,9 +7369,10 @@ function swiftProjectBuildKey(moduleRoot, release) {
|
|
|
7309
7369
|
var SYSTEM_MODULE_LIBRARIES = {
|
|
7310
7370
|
"sqlite3.h": "sqlite3",
|
|
7311
7371
|
"sqlite3ext.h": "sqlite3",
|
|
7372
|
+
"bzlib.h": "bz2",
|
|
7312
7373
|
SQLite3: "sqlite3"
|
|
7313
7374
|
};
|
|
7314
|
-
var SYSTEM_MODULE_IMPORT = /^\s*(?:#\s*(?:import|include)\s*<(sqlite3(?:ext)?\.h)>|@import\s+(SQLite3)\b)/gm;
|
|
7375
|
+
var SYSTEM_MODULE_IMPORT = /^\s*(?:#\s*(?:import|include)\s*<(sqlite3(?:ext)?\.h|bzlib\.h)>|@import\s+(SQLite3)\b)/gm;
|
|
7315
7376
|
function compileTargets(input) {
|
|
7316
7377
|
const manifest = input.files["Package.swift"];
|
|
7317
7378
|
if (manifest === void 0) return [];
|
|
@@ -7507,7 +7568,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
7507
7568
|
const key = JSON.stringify([toolchainBin, sdk, options]);
|
|
7508
7569
|
const cached = sdkPaths.get(key);
|
|
7509
7570
|
if (cached) return cached;
|
|
7510
|
-
const configuration =
|
|
7571
|
+
const configuration = execFileSync9(
|
|
7511
7572
|
path19.join(toolchainBin, "swift"),
|
|
7512
7573
|
[
|
|
7513
7574
|
"sdk",
|
|
@@ -7677,6 +7738,11 @@ function swiftTargetDependencies(files, targets) {
|
|
|
7677
7738
|
const siblings = /* @__PURE__ */ new Map();
|
|
7678
7739
|
for (const target of targets) {
|
|
7679
7740
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
7741
|
+
const ownsHeader = (header) => [`${prefix}${header}`, `${prefix}include/${header}`].some(
|
|
7742
|
+
(file) => Object.hasOwn(files, file) && !targets.some(
|
|
7743
|
+
(candidate) => candidate.name !== target.name && candidate.path !== "." && file.startsWith(`${candidate.path}/`)
|
|
7744
|
+
)
|
|
7745
|
+
);
|
|
7680
7746
|
const deps = new Set(
|
|
7681
7747
|
(target.dependencies ?? []).flatMap(
|
|
7682
7748
|
(dependency) => dependency.kind === "target" && dependency.name !== target.name && names.has(dependency.name) ? [dependency.name] : []
|
|
@@ -7688,7 +7754,7 @@ function swiftTargetDependencies(files, targets) {
|
|
|
7688
7754
|
(candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
|
|
7689
7755
|
))
|
|
7690
7756
|
continue;
|
|
7691
|
-
const imports = file.endsWith(".swift") ? swiftImportNames(contents) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents) : [];
|
|
7757
|
+
const imports = file.endsWith(".swift") ? swiftImportNames(contents) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents, ownsHeader) : [];
|
|
7692
7758
|
for (const name2 of imports) {
|
|
7693
7759
|
if (names.has(name2) && name2 !== target.name) deps.add(name2);
|
|
7694
7760
|
}
|
|
@@ -7724,9 +7790,9 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
|
7724
7790
|
`;
|
|
7725
7791
|
var darwinRecordsRegion = (quoted) => quoted.length ? ["-Wl,--start-lib", ...quoted, "-Wl,--end-lib"] : [];
|
|
7726
7792
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
7727
|
-
var MULTI_MANIFEST_VERSION =
|
|
7793
|
+
var MULTI_MANIFEST_VERSION = 65;
|
|
7728
7794
|
var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
7729
|
-
var compilerSourceDigest = true ? "
|
|
7795
|
+
var compilerSourceDigest = true ? "5bed84d1d29562932f8ef8e54d9dae7b5b378ffb937861030ae5b732eda8dafd" : swiftCompilerSourceDigest(import.meta.dirname);
|
|
7730
7796
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
7731
7797
|
const hash = createHash8("sha256");
|
|
7732
7798
|
hash.update(`swift-compile
|
|
@@ -9828,20 +9894,34 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
9828
9894
|
moduleInterfaces.set(name2, value);
|
|
9829
9895
|
return value;
|
|
9830
9896
|
};
|
|
9897
|
+
const podHeaders = /* @__PURE__ */ new Map();
|
|
9898
|
+
for (const settings of input.nativeTargets ?? [])
|
|
9899
|
+
for (const file of settings.headers) {
|
|
9900
|
+
const owner = /\/Headers\/(?:Public|Private)\/([\w+-]+)\/(?:\1\/)?[^/]+\.h$/.exec(
|
|
9901
|
+
file
|
|
9902
|
+
)?.[1];
|
|
9903
|
+
if (owner)
|
|
9904
|
+
podHeaders.set(path19.basename(file), [
|
|
9905
|
+
...podHeaders.get(path19.basename(file)) ?? [],
|
|
9906
|
+
{ owner, content: input.files[file] }
|
|
9907
|
+
]);
|
|
9908
|
+
}
|
|
9909
|
+
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(path19.basename(file))?.find((header) => header.content === content)?.owner;
|
|
9831
9910
|
for (const settings of input.nativeTargets ?? []) {
|
|
9832
9911
|
for (const file of settings.headers) {
|
|
9833
9912
|
const destination = path19.join(layout.root, file);
|
|
9834
9913
|
if (files.has(destination)) continue;
|
|
9835
9914
|
const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
|
|
9836
9915
|
const frameworkHeader = !interfaceModule && /(?:^|\/)(\w+)\.framework\/Headers\/[\w+.-]+\.h$/.exec(file)?.[1];
|
|
9837
|
-
const
|
|
9916
|
+
const interfaceOwner = frameworkHeader || (interfaceModule ? void 0 : podHeaderOwner(file, input.files[file]));
|
|
9917
|
+
const frameworkInterface = interfaceOwner ? moduleInterface(interfaceOwner) : null;
|
|
9838
9918
|
const rawContents = interfaceModule && moduleInterface(interfaceModule)?.header || input.files[file];
|
|
9839
9919
|
if (rawContents === void 0)
|
|
9840
9920
|
throw new Error(`missing original Objective-C header ${file}`);
|
|
9841
9921
|
const contents = frameworkInterface && typeof rawContents === "string" ? withoutSwiftDeclarations(
|
|
9842
9922
|
rawContents,
|
|
9843
9923
|
frameworkInterface.declared,
|
|
9844
|
-
`#import <${
|
|
9924
|
+
`#import <${interfaceOwner}/${interfaceOwner}-Swift.h>`
|
|
9845
9925
|
) : rawContents;
|
|
9846
9926
|
writeBuildFile(destination, contents);
|
|
9847
9927
|
files.set(destination, contents);
|