peachsim 0.1.1808 → 0.1.1812
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 +148 -76
- 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 +69 -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 +71 -60
- 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 +42897 -40755
- 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 +15889 -15553
- 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 +20891 -18714
- package/dist-lib/host/fetch-proxy-handler.cjs +10 -11
- 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 +620 -553
- 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 +57 -28
- package/dist-lib/native-app-identity-project.cjs +47 -14
- package/dist-lib/native-app-identity-project.mjs +55 -20
- 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 +30700 -24410
- package/dist-lib/swift-compile.cjs +336 -222
- package/dist-lib/swift-compile.mjs +378 -263
- package/dist-lib/swift-package.cjs +19 -7
- package/dist-lib/swift-package.mjs +16 -6
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +49 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +19213 -18937
- package/dist-lib/vite.cjs +11 -12
- 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/System/Library/Frameworks/UIKit.framework/Headers/UISlider.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISplitViewController.h +12 -50
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISplitViewControllerLayoutEnvironment.h +2 -8
- package/sdk/ios/System/Library/Frameworks/UIKitTypes.framework/Headers/UIKitTypes.h +62 -0
- package/sdk/ios/usr/include/dispatch.modulemap +22 -0
- package/sdk/ios/usr/include/module.modulemap +8 -3
- 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 +113 -46
- 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 +272 -272
- 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 +3 -0
- package/src/podspec-sources.ts +1966 -0
- package/src/storageSnapshotContract.ts +40 -0
- package/src/swift-compile.ts +77 -26
- package/src/swift-design-time.ts +18 -1
- package/src/swift-distribution.lock.json +12 -12
- package/src/swift-distribution.ts +9 -6
- package/src/swift-host.ts +1 -2
- package/src/swift-link-roots.ts +13 -2
- package/src/swift-objc-compile.ts +12 -0
- package/src/swift-objc-standin.ts +321 -114
- package/src/swift-package-manifest.ts +4 -3
- package/src/swift-package.ts +31 -4
- 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 +59 -0
- package/src/swift-wasm-prune.ts +53 -21
- package/src/turbo-bundle.ts +4 -5
- package/src/turbo-codegen-intake.ts +111 -108
- package/src/turbo-compile.ts +63 -33
- package/src/turbo-runtime.lock.json +22 -22
- package/src/turbo-source.ts +171 -76
- package/src/wasm-optimize.ts +31 -2
- package/src/xcode-project.ts +65 -15
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.1812 | (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 [];
|
|
@@ -2792,6 +2754,23 @@ var compilerArchives = {
|
|
|
2792
2754
|
}
|
|
2793
2755
|
}
|
|
2794
2756
|
},
|
|
2757
|
+
"swift-6.4.0-RELEASE-custom-a560ff35bf882b5c": {
|
|
2758
|
+
identity: "a560ff35bf882b5c",
|
|
2759
|
+
hosts: {
|
|
2760
|
+
"darwin-arm64": {
|
|
2761
|
+
checksum: "ec20a41851ac558fe663d78def6b93d0d47c5a0cb69688ee270fd85de637a522",
|
|
2762
|
+
manifest: "253e891527d2213f54eace768b902de89de5e9495a3c5f4018de1985516bd553"
|
|
2763
|
+
},
|
|
2764
|
+
"linux-x64": {
|
|
2765
|
+
checksum: "f0126a2e63d275895036d02d75a901070da0343dbf03bf17342e10cb6f893dee",
|
|
2766
|
+
manifest: "6f951cc4071dd0d6054d85711a7c5fe272273658847831b477a8b24be7254ca0"
|
|
2767
|
+
},
|
|
2768
|
+
"linux-arm64": {
|
|
2769
|
+
checksum: "315fa766559a6e69bfd10dcddf40e04c91155f0db3047d210d74ac87652fb7e6",
|
|
2770
|
+
manifest: "b6f62fca2ec37593e274ee5bac474f21ffc5db14cd82f492ccbc774f8e9b75d8"
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
},
|
|
2795
2774
|
[SWIFT_HOST_COMPILER_RELEASE]: {
|
|
2796
2775
|
identity: SWIFT_HOST_COMPILER_ID,
|
|
2797
2776
|
hosts: {
|
|
@@ -2813,13 +2792,13 @@ var compilerArchives = {
|
|
|
2813
2792
|
var SWIFT_PRIVATE_DISTRIBUTION_ENV = "PEACH_SWIFT_PRIVATE_DISTRIBUTION";
|
|
2814
2793
|
function privateSwiftDistributionRoot() {
|
|
2815
2794
|
const root = process.env[SWIFT_PRIVATE_DISTRIBUTION_ENV]?.trim();
|
|
2816
|
-
return root ?
|
|
2795
|
+
return root ? path4.resolve(root) : null;
|
|
2817
2796
|
}
|
|
2818
2797
|
function privateSwiftRelease() {
|
|
2819
2798
|
const root = privateSwiftDistributionRoot();
|
|
2820
2799
|
if (!root) return null;
|
|
2821
2800
|
const manifest = JSON.parse(
|
|
2822
|
-
|
|
2801
|
+
fs.readFileSync(path4.join(root, "distribution.json"), "utf8")
|
|
2823
2802
|
);
|
|
2824
2803
|
const release = manifest && typeof manifest === "object" && Reflect.get(manifest, "release");
|
|
2825
2804
|
if (typeof release !== "string")
|
|
@@ -2849,22 +2828,22 @@ function swiftCompilerRelease(release) {
|
|
|
2849
2828
|
function swiftToolchainBin(release) {
|
|
2850
2829
|
if (process.platform === "darwin") {
|
|
2851
2830
|
const dirs = [os.homedir(), "/"].map(
|
|
2852
|
-
(base) =>
|
|
2831
|
+
(base) => path4.join(base, `Library/Developer/Toolchains/${release}.xctoolchain/usr/bin`)
|
|
2853
2832
|
);
|
|
2854
|
-
return dirs.find((dir) =>
|
|
2833
|
+
return dirs.find((dir) => fs.existsSync(path4.join(dir, "swift"))) ?? dirs[0];
|
|
2855
2834
|
}
|
|
2856
2835
|
if (process.env.CONTRAST_SWIFT_TOOLCHAINS) {
|
|
2857
|
-
return
|
|
2836
|
+
return path4.join(process.env.CONTRAST_SWIFT_TOOLCHAINS, release, "usr/bin");
|
|
2858
2837
|
}
|
|
2859
|
-
const image =
|
|
2860
|
-
if (
|
|
2838
|
+
const image = path4.join("/opt/swift", release, "usr/bin");
|
|
2839
|
+
if (fs.existsSync(path4.join(image, "swift"))) return image;
|
|
2861
2840
|
if (release.includes("-custom-"))
|
|
2862
|
-
return
|
|
2863
|
-
return (process.env.PATH ?? "").split(
|
|
2841
|
+
return path4.join(peachHome(), "swift", "toolchains", release, "usr/bin");
|
|
2842
|
+
return (process.env.PATH ?? "").split(path4.delimiter).find((dir) => dir && fs.existsSync(path4.join(dir, "swift"))) ?? image;
|
|
2864
2843
|
}
|
|
2865
2844
|
var SWIFT_AUTOLINK_LINKER = ".peach-wasm-ld";
|
|
2866
2845
|
function writeSwiftAutolinkLinker(directory, toolchainBin) {
|
|
2867
|
-
const linker =
|
|
2846
|
+
const linker = path4.join(directory, SWIFT_AUTOLINK_LINKER);
|
|
2868
2847
|
const script = `#!/bin/sh
|
|
2869
2848
|
set -eu
|
|
2870
2849
|
for arg in "$@"; do
|
|
@@ -2874,7 +2853,7 @@ for arg in "$@"; do
|
|
|
2874
2853
|
awk 'BEGIN { RS = " "; ORS = " " } /^"-l/ { if (seen[$0]++) next } { print }' "$rsp" > "$rsp.dedup"
|
|
2875
2854
|
mv "$rsp.dedup" "$rsp"
|
|
2876
2855
|
if [ "\${PEACH_DEFER_WASM_LINK:-}" = "1" ] && grep -q '"--start-lib"' "$rsp"; then
|
|
2877
|
-
cp "$rsp" ${JSON.stringify(
|
|
2856
|
+
cp "$rsp" ${JSON.stringify(path4.join(directory, ".peach-link.rsp"))}
|
|
2878
2857
|
out=$(awk 'BEGIN { RS = " " } prev == "\\"'-o'\\"" { gsub(/^"|"[[:space:]]*$/, ""); print; exit } { prev = $0 }' "$rsp")
|
|
2879
2858
|
if [ -n "$out" ]; then
|
|
2880
2859
|
printf '\\000asm\\001\\000\\000\\000' > "$out"
|
|
@@ -2884,18 +2863,37 @@ for arg in "$@"; do
|
|
|
2884
2863
|
;;
|
|
2885
2864
|
esac
|
|
2886
2865
|
done
|
|
2887
|
-
exec ${JSON.stringify(
|
|
2866
|
+
exec ${JSON.stringify(path4.join(toolchainBin, "wasm-ld"))} "$@"
|
|
2888
2867
|
`;
|
|
2889
|
-
if (
|
|
2890
|
-
|
|
2868
|
+
if (fs.existsSync(linker) && fs.readFileSync(linker, "utf8") === script) return linker;
|
|
2869
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
2891
2870
|
const next = `${linker}.${process.pid}`;
|
|
2892
|
-
|
|
2893
|
-
|
|
2871
|
+
fs.writeFileSync(next, script, { mode: 493 });
|
|
2872
|
+
fs.renameSync(next, linker);
|
|
2894
2873
|
return linker;
|
|
2895
2874
|
}
|
|
2896
2875
|
function peachHome() {
|
|
2897
2876
|
const override = process.env.PEACH_HOME;
|
|
2898
|
-
return override ?
|
|
2877
|
+
return override ? path4.resolve(override) : path4.join(os.homedir(), ".peach");
|
|
2878
|
+
}
|
|
2879
|
+
var BUILDERS_ROOT_ENV = "CONTRAST_BUILDERS_ROOT";
|
|
2880
|
+
function buildersRootEnv() {
|
|
2881
|
+
const root = process.env[BUILDERS_ROOT_ENV]?.trim();
|
|
2882
|
+
return root ? root : null;
|
|
2883
|
+
}
|
|
2884
|
+
function swiftCacheDir() {
|
|
2885
|
+
const root = buildersRootEnv();
|
|
2886
|
+
return root ? path4.join(root, "peach-cache") : path4.join(peachHome(), "cache");
|
|
2887
|
+
}
|
|
2888
|
+
function swiftPackageCacheOptions() {
|
|
2889
|
+
const root = path4.join(swiftCacheDir(), "swiftpm");
|
|
2890
|
+
return [
|
|
2891
|
+
...["cache", "config", "security"].flatMap((name2) => [
|
|
2892
|
+
`--${name2}-path`,
|
|
2893
|
+
path4.join(root, name2)
|
|
2894
|
+
]),
|
|
2895
|
+
"--disable-keychain"
|
|
2896
|
+
];
|
|
2899
2897
|
}
|
|
2900
2898
|
var scratch;
|
|
2901
2899
|
var linuxLibraryPath;
|
|
@@ -2909,16 +2907,16 @@ function swiftEnvironment(base = process.env) {
|
|
|
2909
2907
|
} : {},
|
|
2910
2908
|
...scratch ? {
|
|
2911
2909
|
TMPDIR: scratch.directory,
|
|
2912
|
-
XDG_CONFIG_HOME:
|
|
2913
|
-
XDG_CACHE_HOME:
|
|
2914
|
-
XDG_DATA_HOME:
|
|
2910
|
+
XDG_CONFIG_HOME: path4.join(scratch.home, ".config"),
|
|
2911
|
+
XDG_CACHE_HOME: path4.join(scratch.home, ".cache"),
|
|
2912
|
+
XDG_DATA_HOME: path4.join(scratch.home, ".local", "share"),
|
|
2915
2913
|
...process.platform === "linux" ? { HOME: scratch.home } : {}
|
|
2916
2914
|
} : {}
|
|
2917
2915
|
};
|
|
2918
2916
|
}
|
|
2919
2917
|
function swiftSourceSdk(root) {
|
|
2920
2918
|
const pin = JSON.parse(
|
|
2921
|
-
|
|
2919
|
+
fs.readFileSync(path4.join(root, "toolchain.json"), "utf8")
|
|
2922
2920
|
);
|
|
2923
2921
|
if (!pin || typeof pin !== "object" || typeof Reflect.get(pin, "wasmSdkId") !== "string" || typeof Reflect.get(pin, "wasmSdkUrl") !== "string" || typeof Reflect.get(pin, "wasmSdkChecksum") !== "string")
|
|
2924
2922
|
throw new Error(`${root} pins no wasm SDK id, url and checksum`);
|
|
@@ -2940,7 +2938,7 @@ function swiftToolchain(release, sdk) {
|
|
|
2940
2938
|
${swiftInstallSteps(release, sdk)}`
|
|
2941
2939
|
);
|
|
2942
2940
|
}
|
|
2943
|
-
const swift =
|
|
2941
|
+
const swift = path4.join(bin, "swift");
|
|
2944
2942
|
const sdks = execFileSync(swift, ["sdk", "list", ...swiftSdkOptions()], {
|
|
2945
2943
|
encoding: "utf8",
|
|
2946
2944
|
env: swiftEnvironment(),
|
|
@@ -2972,31 +2970,31 @@ function swiftSdkBundle(swift, id, options) {
|
|
|
2972
2970
|
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
2973
2971
|
);
|
|
2974
2972
|
const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim();
|
|
2975
|
-
if (!sysroot || !
|
|
2973
|
+
if (!sysroot || !path4.isAbsolute(sysroot))
|
|
2976
2974
|
throw new Error(`Swift SDK ${id} reports no absolute sdkRootPath`);
|
|
2977
2975
|
let bundle = sysroot;
|
|
2978
2976
|
while (!bundle.endsWith(".artifactbundle")) {
|
|
2979
|
-
const parent =
|
|
2977
|
+
const parent = path4.dirname(bundle);
|
|
2980
2978
|
if (parent === bundle)
|
|
2981
2979
|
throw new Error(`Swift SDK ${id} is outside an artifact bundle`);
|
|
2982
2980
|
bundle = parent;
|
|
2983
2981
|
}
|
|
2984
|
-
return
|
|
2982
|
+
return fs.realpathSync(bundle);
|
|
2985
2983
|
}
|
|
2986
2984
|
var sdkFileHashes = /* @__PURE__ */ new Map();
|
|
2987
2985
|
function swiftSdkPayloadChecksum(bundle) {
|
|
2988
2986
|
const hash = createHash2("sha256");
|
|
2989
2987
|
function visit(relative) {
|
|
2990
|
-
const file =
|
|
2991
|
-
const stat =
|
|
2988
|
+
const file = path4.join(bundle, relative);
|
|
2989
|
+
const stat = fs.lstatSync(file, { bigint: true });
|
|
2992
2990
|
if (stat.isSymbolicLink()) {
|
|
2993
|
-
const resolved =
|
|
2994
|
-
if (resolved === ".." || resolved.startsWith(`..${
|
|
2991
|
+
const resolved = path4.relative(bundle, fs.realpathSync(file));
|
|
2992
|
+
if (resolved === ".." || resolved.startsWith(`..${path4.sep}`) || path4.isAbsolute(resolved))
|
|
2995
2993
|
throw new Error(`Swift SDK symlink escapes its bundle: ${relative}`);
|
|
2996
|
-
hash.update(JSON.stringify([relative, "link",
|
|
2994
|
+
hash.update(JSON.stringify([relative, "link", fs.readlinkSync(file)]) + "\n");
|
|
2997
2995
|
} else if (stat.isDirectory()) {
|
|
2998
2996
|
hash.update(JSON.stringify([relative, "directory"]) + "\n");
|
|
2999
|
-
for (const name2 of
|
|
2997
|
+
for (const name2 of fs.readdirSync(file).sort()) visit(path4.join(relative, name2));
|
|
3000
2998
|
} else if (stat.isFile()) {
|
|
3001
2999
|
const stamp = [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(":");
|
|
3002
3000
|
let cached = sdkFileHashes.get(file);
|
|
@@ -3013,8 +3011,8 @@ function swiftSdkPayloadChecksum(bundle) {
|
|
|
3013
3011
|
return hash.digest("hex");
|
|
3014
3012
|
}
|
|
3015
3013
|
function swiftSdkVerificationFile(bundle, sdk) {
|
|
3016
|
-
return
|
|
3017
|
-
|
|
3014
|
+
return path4.join(
|
|
3015
|
+
path4.dirname(bundle),
|
|
3018
3016
|
".peach-sdk-checksums",
|
|
3019
3017
|
`${sdk.wasmSdkId}-${sdk.wasmSdkChecksum}.json`
|
|
3020
3018
|
);
|
|
@@ -3022,11 +3020,11 @@ function swiftSdkVerificationFile(bundle, sdk) {
|
|
|
3022
3020
|
function verifySwiftSdk(swift, sdk) {
|
|
3023
3021
|
const bundle = swiftSdkBundle(swift, sdk.wasmSdkId, swiftSdkOptions());
|
|
3024
3022
|
const file = swiftSdkVerificationFile(bundle, sdk);
|
|
3025
|
-
if (!
|
|
3023
|
+
if (!fs.existsSync(file))
|
|
3026
3024
|
throw new Error(
|
|
3027
3025
|
`Swift SDK ${sdk.wasmSdkId} has no verified archive binding for ${sdk.wasmSdkChecksum}. Hydrate it with installSwiftWasmSdk before compiling.`
|
|
3028
3026
|
);
|
|
3029
|
-
const receipt = JSON.parse(
|
|
3027
|
+
const receipt = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
3030
3028
|
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
3029
|
throw new Error(
|
|
3032
3030
|
`Swift SDK ${sdk.wasmSdkId} installed payload differs from its verified archive ${sdk.wasmSdkChecksum}`
|
|
@@ -3034,28 +3032,28 @@ function verifySwiftSdk(swift, sdk) {
|
|
|
3034
3032
|
}
|
|
3035
3033
|
function swiftFileChecksum(file) {
|
|
3036
3034
|
const hash = createHash2("sha256");
|
|
3037
|
-
const fd =
|
|
3035
|
+
const fd = fs.openSync(file, "r");
|
|
3038
3036
|
const buffer = Buffer.allocUnsafe(1024 * 1024);
|
|
3039
3037
|
try {
|
|
3040
|
-
let size =
|
|
3038
|
+
let size = fs.readSync(fd, buffer, 0, buffer.length, null);
|
|
3041
3039
|
while (size > 0) {
|
|
3042
3040
|
hash.update(buffer.subarray(0, size));
|
|
3043
|
-
size =
|
|
3041
|
+
size = fs.readSync(fd, buffer, 0, buffer.length, null);
|
|
3044
3042
|
}
|
|
3045
3043
|
} finally {
|
|
3046
|
-
|
|
3044
|
+
fs.closeSync(fd);
|
|
3047
3045
|
}
|
|
3048
3046
|
return hash.digest("hex");
|
|
3049
3047
|
}
|
|
3050
3048
|
function swiftHostCompilerFiles(release, root) {
|
|
3051
|
-
const file =
|
|
3049
|
+
const file = path4.join(root, "compiler.json");
|
|
3052
3050
|
const pin = release === privateSwiftRelease() ? {
|
|
3053
3051
|
identity: release.replace(/^.*-custom-/, ""),
|
|
3054
3052
|
manifest: swiftFileChecksum(file)
|
|
3055
3053
|
} : swiftHostCompilerArchive(release);
|
|
3056
3054
|
if (swiftFileChecksum(file) !== pin.manifest)
|
|
3057
3055
|
throw new Error(`Swift compiler manifest mismatch at ${root}`);
|
|
3058
|
-
const manifest = JSON.parse(
|
|
3056
|
+
const manifest = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
3059
3057
|
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
3058
|
throw new Error(`Swift compiler identity mismatch at ${root}`);
|
|
3061
3059
|
}
|
|
@@ -3069,7 +3067,7 @@ function swiftHostCompilerFiles(release, root) {
|
|
|
3069
3067
|
}
|
|
3070
3068
|
function verifySwiftHostCompiler(release, root) {
|
|
3071
3069
|
for (const [relative, checksum] of swiftHostCompilerFiles(release, root)) {
|
|
3072
|
-
if (swiftFileChecksum(
|
|
3070
|
+
if (swiftFileChecksum(path4.join(root, relative)) !== checksum)
|
|
3073
3071
|
throw new Error(`Swift compiler binary mismatch: ${relative}`);
|
|
3074
3072
|
}
|
|
3075
3073
|
}
|
|
@@ -3079,8 +3077,8 @@ function swiftCompiler(release) {
|
|
|
3079
3077
|
if (cached) return cached;
|
|
3080
3078
|
const bin = swiftToolchainBin(release);
|
|
3081
3079
|
if (release.includes("-custom-"))
|
|
3082
|
-
verifySwiftHostCompiler(release,
|
|
3083
|
-
const version = execFileSync(
|
|
3080
|
+
verifySwiftHostCompiler(release, path4.resolve(bin, "../.."));
|
|
3081
|
+
const version = execFileSync(path4.join(bin, "swift"), ["--version"], {
|
|
3084
3082
|
encoding: "utf8",
|
|
3085
3083
|
env: swiftEnvironment(),
|
|
3086
3084
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -3098,7 +3096,7 @@ function swiftSdkInstallCommand(release, wasmSdk) {
|
|
|
3098
3096
|
const { wasmSdkId, wasmSdkUrl, wasmSdkChecksum } = wasmSdk;
|
|
3099
3097
|
const program = `import { installSwiftWasmSdk } from "peachsim/swift-toolchain"; installSwiftWasmSdk(${JSON.stringify(release)}, ${JSON.stringify({ wasmSdkId, wasmSdkUrl, wasmSdkChecksum })})`;
|
|
3100
3098
|
const directory = process.env.PEACH_SWIFT_SDKS_PATH;
|
|
3101
|
-
const environment = directory ? `PEACH_SWIFT_SDKS_PATH='${
|
|
3099
|
+
const environment = directory ? `PEACH_SWIFT_SDKS_PATH='${path4.resolve(directory).replaceAll("'", "'\\''")}' ` : "";
|
|
3102
3100
|
return `${environment}node --input-type=module -e '${program.replaceAll("'", "'\\''")}'`;
|
|
3103
3101
|
}
|
|
3104
3102
|
function swiftInstallSteps(release, wasmSdk) {
|
|
@@ -3113,7 +3111,7 @@ function swiftCompilerInstall(release) {
|
|
|
3113
3111
|
return { note: " (private: its builder installs it)", commands: [] };
|
|
3114
3112
|
if (release.includes("-custom-")) {
|
|
3115
3113
|
const archive = swiftHostCompilerArchive(release);
|
|
3116
|
-
const directory =
|
|
3114
|
+
const directory = path4.resolve(swiftToolchainBin(release), "../..");
|
|
3117
3115
|
return {
|
|
3118
3116
|
note: "",
|
|
3119
3117
|
commands: [
|
|
@@ -3158,7 +3156,7 @@ function swiftObjCPlatformFlags(toolchainBin, minimum) {
|
|
|
3158
3156
|
minimum % 100
|
|
3159
3157
|
].join(".");
|
|
3160
3158
|
const result = spawnSync4(
|
|
3161
|
-
|
|
3159
|
+
path5.join(toolchainBin, "clang"),
|
|
3162
3160
|
[
|
|
3163
3161
|
"-target",
|
|
3164
3162
|
`arm64-apple-ios${version}-simulator`,
|
|
@@ -3202,14 +3200,19 @@ var swiftObjCRuntimeFlags = [
|
|
|
3202
3200
|
// src/swift-objc-standin.ts
|
|
3203
3201
|
import { execFileSync as execFileSync2, spawnSync as spawnSync5 } from "node:child_process";
|
|
3204
3202
|
import { createHash as createHash3 } from "node:crypto";
|
|
3205
|
-
import
|
|
3206
|
-
import
|
|
3203
|
+
import fs2 from "node:fs";
|
|
3204
|
+
import path7 from "node:path";
|
|
3205
|
+
|
|
3206
|
+
// src/is-record.ts
|
|
3207
|
+
function isRecord(value) {
|
|
3208
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3209
|
+
}
|
|
3207
3210
|
|
|
3208
3211
|
// src/swift-objc-sdk.ts
|
|
3209
|
-
import
|
|
3212
|
+
import path6 from "node:path";
|
|
3210
3213
|
var IOS_SDK_TARGET = "arm64-apple-ios16.0-simulator";
|
|
3211
3214
|
var OVERLAY_PATH = /^usr\/lib\/swift\/([^/]+)\.swiftmodule\/arm64-apple-ios-simulator\.swiftinterface$/;
|
|
3212
|
-
var tree = typeof __PEACH_BUNDLED_IOS_SDK__ === "undefined" ? readIosSdkTree(
|
|
3215
|
+
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
3216
|
var IOS_SDK_HEADERS = {};
|
|
3214
3217
|
var IOS_SDK_OVERLAYS = {};
|
|
3215
3218
|
for (const [file, text2] of tree) {
|
|
@@ -3359,10 +3362,14 @@ var SWIFT_NATIVE_SOURCE_EXTENSIONS = [
|
|
|
3359
3362
|
".def",
|
|
3360
3363
|
".modulemap"
|
|
3361
3364
|
];
|
|
3362
|
-
function clangImportNames(text2) {
|
|
3365
|
+
function clangImportNames(text2, isLocalHeader) {
|
|
3363
3366
|
return [
|
|
3364
|
-
...text2.matchAll(
|
|
3365
|
-
|
|
3367
|
+
...text2.matchAll(
|
|
3368
|
+
/^\s*(?:#\s*(?:import|include)\s*<((\w+)\/[^>]+)>|@import\s+(\w+))/gm
|
|
3369
|
+
)
|
|
3370
|
+
].flatMap(
|
|
3371
|
+
(match) => match[1] && isLocalHeader?.(match[1]) ? [] : [match[2] ?? match[3]]
|
|
3372
|
+
);
|
|
3366
3373
|
}
|
|
3367
3374
|
function moduleMapTokens(text2) {
|
|
3368
3375
|
return (text2.match(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|"[^"]*"|[\w.*]+|[{}\[\]]/g) ?? []).filter((token) => !token.startsWith("/"));
|
|
@@ -3385,9 +3392,13 @@ ${declaration}
|
|
|
3385
3392
|
export *
|
|
3386
3393
|
}`;
|
|
3387
3394
|
}
|
|
3395
|
+
var fmtConstantInterpreterFlags = (flags) => flags.some((flag) => flag.includes("/fmt/")) ? ["-fexperimental-new-constant-interpreter"] : [];
|
|
3396
|
+
var withoutGlogModuleMap = (flags) => flags.filter(
|
|
3397
|
+
(flag) => !(flag.startsWith("-fmodule-map-file=") && flag.endsWith("/glog.modulemap"))
|
|
3398
|
+
);
|
|
3388
3399
|
function clangSettingEntries(settings, tool) {
|
|
3389
3400
|
return (settings ?? []).flatMap(
|
|
3390
|
-
(setting) => setting.tool !== tool ? [] : "headerSearchPath" in setting ? [`.headerSearchPath(${JSON.stringify(setting.headerSearchPath)})`] : [`.unsafeFlags(${JSON.stringify(setting.flags)})`]
|
|
3401
|
+
(setting) => setting.tool !== tool ? [] : "headerSearchPath" in setting ? [`.headerSearchPath(${JSON.stringify(setting.headerSearchPath)})`] : [`.unsafeFlags(${JSON.stringify(withoutGlogModuleMap(setting.flags))})`]
|
|
3391
3402
|
);
|
|
3392
3403
|
}
|
|
3393
3404
|
function clangMacroSetting(macro) {
|
|
@@ -3756,9 +3767,12 @@ var IOS_SDK_ID = createHash3("sha256").update(JSON.stringify(iosSdkEntries())).d
|
|
|
3756
3767
|
function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
|
|
3757
3768
|
return [
|
|
3758
3769
|
...swiftObjCPlatformFlags(toolchainBin, minimum),
|
|
3759
|
-
// AvailabilityInternal.h derives
|
|
3760
|
-
// is false for wasm32.
|
|
3770
|
+
// AvailabilityInternal.h derives these through __is_target_os(ios), which
|
|
3771
|
+
// is false for wasm32. the maximum is the sdk the headers come from, as
|
|
3772
|
+
// xcode defines it, so `#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_26_0`
|
|
3773
|
+
// sources see the members the sdk declares instead of a 17.0 default.
|
|
3761
3774
|
`-D__IPHONE_OS_VERSION_MIN_REQUIRED=${minimum}`,
|
|
3775
|
+
`-D__IPHONE_OS_VERSION_MAX_ALLOWED=__IPHONE_${NATIVE_GRAPH_SDK_VERSION.replace(".", "_")}`,
|
|
3762
3776
|
// apple's build setting for a 32-bit target to keep NSInteger and
|
|
3763
3777
|
// NSUInteger long, the nominal types they have on arm64.
|
|
3764
3778
|
"-DNS_BUILD_32_LIKE_64=1",
|
|
@@ -3774,15 +3788,15 @@ function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
|
|
|
3774
3788
|
"-fblocks",
|
|
3775
3789
|
...WASI_EMULATION_FLAGS,
|
|
3776
3790
|
"-iframework",
|
|
3777
|
-
|
|
3791
|
+
path7.join(headers, "System/Library/Frameworks"),
|
|
3778
3792
|
"-isystem",
|
|
3779
|
-
|
|
3793
|
+
path7.join(headers, "wasm/include"),
|
|
3780
3794
|
// libxml2 headers sit one level deeper, as in the iOS sdk: a unit
|
|
3781
3795
|
// includes <libxml/parser.h> through usr/include/libxml2, never the parent.
|
|
3782
3796
|
"-I",
|
|
3783
|
-
|
|
3797
|
+
path7.join(headers, "usr/include/libxml2"),
|
|
3784
3798
|
"-idirafter",
|
|
3785
|
-
|
|
3799
|
+
path7.join(headers, "usr/include")
|
|
3786
3800
|
];
|
|
3787
3801
|
}
|
|
3788
3802
|
function iosDeploymentMinimum(version) {
|
|
@@ -3794,49 +3808,49 @@ function iosDeploymentMinimum(version) {
|
|
|
3794
3808
|
// src/swift-shared-sdk.ts
|
|
3795
3809
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
3796
3810
|
import { createHash as createHash4 } from "node:crypto";
|
|
3797
|
-
import
|
|
3798
|
-
import
|
|
3811
|
+
import fs3, { readdirSync as readdirSync4, readFileSync as readFileSync6 } from "node:fs";
|
|
3812
|
+
import path8 from "node:path";
|
|
3799
3813
|
var distributionHeaderRoots = /* @__PURE__ */ new Map();
|
|
3800
3814
|
function swiftSharedSdkRoot(moduleRoot, distribution) {
|
|
3801
|
-
const root =
|
|
3815
|
+
const root = path8.resolve(moduleRoot, distribution ? "sdk/ios" : "../peachsim/sdk/ios");
|
|
3802
3816
|
if (!distribution) return root;
|
|
3803
3817
|
let headers = distributionHeaderRoots.get(root);
|
|
3804
|
-
if (!headers || !
|
|
3805
|
-
const files = readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) =>
|
|
3818
|
+
if (!headers || !fs3.existsSync(headers)) {
|
|
3819
|
+
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
3820
|
const hash = createHash4("sha256");
|
|
3807
3821
|
for (const file of files) {
|
|
3808
|
-
const bytes = readFileSync6(
|
|
3822
|
+
const bytes = readFileSync6(path8.join(root, file));
|
|
3809
3823
|
hash.update(JSON.stringify([file, bytes.length])).update(bytes);
|
|
3810
3824
|
}
|
|
3811
|
-
headers =
|
|
3825
|
+
headers = path8.join(
|
|
3812
3826
|
swiftCacheDir(),
|
|
3813
3827
|
"swift-sdk-views",
|
|
3814
3828
|
`headers-${hash.digest("hex")}`
|
|
3815
3829
|
);
|
|
3816
|
-
if (!
|
|
3817
|
-
|
|
3818
|
-
const staging =
|
|
3819
|
-
|
|
3830
|
+
if (!fs3.existsSync(headers)) {
|
|
3831
|
+
fs3.mkdirSync(path8.dirname(headers), { recursive: true });
|
|
3832
|
+
const staging = fs3.mkdtempSync(`${headers}-`);
|
|
3833
|
+
fs3.cpSync(root, staging, { recursive: true, preserveTimestamps: true });
|
|
3820
3834
|
try {
|
|
3821
|
-
|
|
3835
|
+
fs3.renameSync(staging, headers);
|
|
3822
3836
|
} catch (error) {
|
|
3823
|
-
|
|
3824
|
-
if (!
|
|
3837
|
+
fs3.rmSync(staging, { recursive: true, force: true });
|
|
3838
|
+
if (!fs3.existsSync(headers)) throw error;
|
|
3825
3839
|
}
|
|
3826
3840
|
}
|
|
3827
3841
|
distributionHeaderRoots.set(root, headers);
|
|
3828
3842
|
}
|
|
3829
3843
|
const now = /* @__PURE__ */ new Date();
|
|
3830
|
-
|
|
3844
|
+
fs3.utimesSync(headers, now, now);
|
|
3831
3845
|
return headers;
|
|
3832
3846
|
}
|
|
3833
3847
|
function swiftSharedSdkFlags(moduleRoot, distribution) {
|
|
3834
3848
|
const root = swiftSharedSdkRoot(moduleRoot, distribution);
|
|
3835
3849
|
return [
|
|
3836
3850
|
"-isystem",
|
|
3837
|
-
|
|
3851
|
+
path8.join(root, "wasm/storage-include"),
|
|
3838
3852
|
"-idirafter",
|
|
3839
|
-
|
|
3853
|
+
path8.join(root, "usr/include")
|
|
3840
3854
|
];
|
|
3841
3855
|
}
|
|
3842
3856
|
function readULEB(b, o) {
|
|
@@ -3959,53 +3973,53 @@ function weakenBundleInArchive(arBuf) {
|
|
|
3959
3973
|
}
|
|
3960
3974
|
}
|
|
3961
3975
|
function mirrorTree(real, mirror, overrides) {
|
|
3962
|
-
|
|
3963
|
-
for (const entry of
|
|
3964
|
-
const from =
|
|
3965
|
-
const to =
|
|
3976
|
+
fs3.mkdirSync(mirror);
|
|
3977
|
+
for (const entry of fs3.readdirSync(real, { withFileTypes: true })) {
|
|
3978
|
+
const from = path8.join(real, entry.name);
|
|
3979
|
+
const to = path8.join(mirror, entry.name);
|
|
3966
3980
|
const override = overrides.get(from);
|
|
3967
|
-
if (override)
|
|
3968
|
-
else if (
|
|
3969
|
-
else
|
|
3981
|
+
if (override) fs3.symlinkSync(override, to);
|
|
3982
|
+
else if (fs3.statSync(from).isDirectory()) mirrorTree(from, to, overrides);
|
|
3983
|
+
else fs3.symlinkSync(from, to);
|
|
3970
3984
|
}
|
|
3971
3985
|
}
|
|
3972
3986
|
function stageOverlaySlot(realRoot, stagingRoot, relPath) {
|
|
3973
|
-
const segments = relPath.split(
|
|
3987
|
+
const segments = relPath.split(path8.sep);
|
|
3974
3988
|
let real = realRoot;
|
|
3975
3989
|
let mirror = stagingRoot;
|
|
3976
3990
|
for (let i = 0; i < segments.length; i++) {
|
|
3977
3991
|
const segment = segments[i];
|
|
3978
3992
|
for (const entry of readdirSync4(real)) {
|
|
3979
3993
|
if (entry === segment) continue;
|
|
3980
|
-
const dest =
|
|
3981
|
-
if (!
|
|
3982
|
-
|
|
3994
|
+
const dest = path8.join(mirror, entry);
|
|
3995
|
+
if (!fs3.lstatSync(dest, { throwIfNoEntry: false })) {
|
|
3996
|
+
fs3.symlinkSync(path8.join(real, entry), dest);
|
|
3983
3997
|
}
|
|
3984
3998
|
}
|
|
3985
|
-
real =
|
|
3986
|
-
mirror =
|
|
3999
|
+
real = path8.join(real, segment);
|
|
4000
|
+
mirror = path8.join(mirror, segment);
|
|
3987
4001
|
if (i < segments.length - 1) {
|
|
3988
|
-
if (
|
|
3989
|
-
|
|
4002
|
+
if (fs3.lstatSync(mirror, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
4003
|
+
fs3.unlinkSync(mirror);
|
|
3990
4004
|
}
|
|
3991
|
-
|
|
4005
|
+
fs3.mkdirSync(mirror, { recursive: true });
|
|
3992
4006
|
}
|
|
3993
4007
|
}
|
|
3994
|
-
if (
|
|
3995
|
-
|
|
4008
|
+
if (fs3.lstatSync(mirror, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
4009
|
+
fs3.unlinkSync(mirror);
|
|
3996
4010
|
}
|
|
3997
4011
|
return mirror;
|
|
3998
4012
|
}
|
|
3999
4013
|
var sdkViews = /* @__PURE__ */ new Map();
|
|
4000
4014
|
function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk) {
|
|
4001
|
-
const frameworks =
|
|
4015
|
+
const frameworks = path8.join(
|
|
4002
4016
|
swiftSharedSdkRoot(moduleRoot, distribution),
|
|
4003
4017
|
"System/Library/Frameworks"
|
|
4004
4018
|
);
|
|
4005
|
-
const overlay =
|
|
4006
|
-
const overlayFiles = readdirSync4(overlay, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) =>
|
|
4019
|
+
const overlay = path8.join(swiftSharedSdkRoot(moduleRoot, distribution), "wasm/include");
|
|
4020
|
+
const overlayFiles = readdirSync4(overlay, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path8.join(entry.parentPath, entry.name)).sort();
|
|
4007
4021
|
const key = JSON.stringify([
|
|
4008
|
-
"
|
|
4022
|
+
"v11",
|
|
4009
4023
|
toolchainBin,
|
|
4010
4024
|
sdk,
|
|
4011
4025
|
frameworks,
|
|
@@ -4013,9 +4027,9 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
|
|
|
4013
4027
|
swiftSdkOptions()
|
|
4014
4028
|
]);
|
|
4015
4029
|
const cached = sdkViews.get(key);
|
|
4016
|
-
if (cached &&
|
|
4030
|
+
if (cached && fs3.existsSync(cached.manifest)) return touchSdkView(cached.options);
|
|
4017
4031
|
const configuration = execFileSync3(
|
|
4018
|
-
|
|
4032
|
+
path8.join(toolchainBin, "swift"),
|
|
4019
4033
|
[
|
|
4020
4034
|
"sdk",
|
|
4021
4035
|
"configure",
|
|
@@ -4027,67 +4041,67 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
|
|
|
4027
4041
|
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
4028
4042
|
);
|
|
4029
4043
|
const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim();
|
|
4030
|
-
if (!sysroot || !
|
|
4044
|
+
if (!sysroot || !path8.isAbsolute(sysroot))
|
|
4031
4045
|
throw new Error(`swift sdk ${sdk} reports no absolute sdkRootPath`);
|
|
4032
4046
|
let bundle = sysroot;
|
|
4033
4047
|
while (!bundle.endsWith(".artifactbundle")) {
|
|
4034
|
-
if (
|
|
4048
|
+
if (path8.dirname(bundle) === bundle)
|
|
4035
4049
|
throw new Error(`swift sdk ${sdk} is outside an artifact bundle`);
|
|
4036
|
-
bundle =
|
|
4050
|
+
bundle = path8.dirname(bundle);
|
|
4037
4051
|
}
|
|
4038
|
-
const view =
|
|
4052
|
+
const view = path8.join(
|
|
4039
4053
|
swiftCacheDir(),
|
|
4040
4054
|
"swift-sdk-views",
|
|
4041
4055
|
createHash4("sha256").update(key).digest("hex").slice(0, 16)
|
|
4042
4056
|
);
|
|
4043
|
-
const manifest =
|
|
4044
|
-
if (!
|
|
4045
|
-
|
|
4046
|
-
const staging =
|
|
4047
|
-
const realRoot =
|
|
4048
|
-
const overrides =
|
|
4049
|
-
[
|
|
4050
|
-
[
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
]
|
|
4057
|
+
const manifest = path8.join(view, path8.basename(bundle), "info.json");
|
|
4058
|
+
if (!fs3.existsSync(manifest)) {
|
|
4059
|
+
fs3.mkdirSync(path8.dirname(view), { recursive: true });
|
|
4060
|
+
const staging = fs3.mkdtempSync(`${view}-`);
|
|
4061
|
+
const realRoot = path8.dirname(bundle);
|
|
4062
|
+
const overrides = new Map([
|
|
4063
|
+
[path8.join(sysroot, "darwin/System/Library/Frameworks"), frameworks],
|
|
4064
|
+
...["MacTypes.h", "net/if.h"].map((header) => [
|
|
4065
|
+
path8.join(sysroot, "darwin/usr/include", header),
|
|
4066
|
+
path8.join(swiftSharedSdkRoot(moduleRoot, distribution), "usr/include", header)
|
|
4067
|
+
])
|
|
4054
4068
|
]);
|
|
4055
4069
|
for (const file of overlayFiles) {
|
|
4056
4070
|
overrides.set(
|
|
4057
|
-
|
|
4071
|
+
path8.join(sysroot, "darwin/wasm/include", path8.relative(overlay, file)),
|
|
4058
4072
|
file
|
|
4059
4073
|
);
|
|
4060
4074
|
}
|
|
4061
4075
|
mirrorTree(
|
|
4062
4076
|
sysroot,
|
|
4063
|
-
stageOverlaySlot(realRoot, staging,
|
|
4077
|
+
stageOverlaySlot(realRoot, staging, path8.relative(realRoot, sysroot)),
|
|
4064
4078
|
overrides
|
|
4065
4079
|
);
|
|
4066
4080
|
for (const [file, shared] of overrides) {
|
|
4067
|
-
const destination =
|
|
4068
|
-
if (
|
|
4069
|
-
|
|
4070
|
-
|
|
4081
|
+
const destination = path8.join(staging, path8.relative(realRoot, file));
|
|
4082
|
+
if (fs3.lstatSync(destination, { throwIfNoEntry: false })) continue;
|
|
4083
|
+
fs3.mkdirSync(path8.dirname(destination), { recursive: true });
|
|
4084
|
+
fs3.symlinkSync(shared, destination);
|
|
4071
4085
|
}
|
|
4072
|
-
const foundationArchive =
|
|
4073
|
-
|
|
4086
|
+
const foundationArchive = path8.join(
|
|
4087
|
+
path8.dirname(sysroot),
|
|
4074
4088
|
"swift.xctoolchain/usr/lib/swift_static/wasi/libFoundation.a"
|
|
4075
4089
|
);
|
|
4076
|
-
if (
|
|
4090
|
+
if (fs3.existsSync(foundationArchive)) {
|
|
4077
4091
|
const foundationSlot = stageOverlaySlot(
|
|
4078
4092
|
realRoot,
|
|
4079
4093
|
staging,
|
|
4080
|
-
|
|
4094
|
+
path8.relative(realRoot, foundationArchive)
|
|
4081
4095
|
);
|
|
4082
|
-
const arBuf = new Uint8Array(
|
|
4096
|
+
const arBuf = new Uint8Array(fs3.readFileSync(foundationArchive));
|
|
4083
4097
|
weakenBundleInArchive(arBuf);
|
|
4084
|
-
|
|
4098
|
+
fs3.writeFileSync(foundationSlot, arBuf);
|
|
4085
4099
|
}
|
|
4086
4100
|
try {
|
|
4087
|
-
|
|
4101
|
+
fs3.renameSync(staging, view);
|
|
4088
4102
|
} catch (error) {
|
|
4089
|
-
|
|
4090
|
-
if (!
|
|
4103
|
+
fs3.rmSync(staging, { recursive: true, force: true });
|
|
4104
|
+
if (!fs3.existsSync(manifest)) throw error;
|
|
4091
4105
|
}
|
|
4092
4106
|
}
|
|
4093
4107
|
const options = ["--swift-sdks-path", view];
|
|
@@ -4096,28 +4110,28 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
|
|
|
4096
4110
|
}
|
|
4097
4111
|
function touchSdkView(options) {
|
|
4098
4112
|
const now = /* @__PURE__ */ new Date();
|
|
4099
|
-
|
|
4113
|
+
fs3.utimesSync(options[1], now, now);
|
|
4100
4114
|
return options;
|
|
4101
4115
|
}
|
|
4102
4116
|
function swiftSharedSdkInputFiles(moduleRoot) {
|
|
4103
4117
|
const root = swiftSharedSdkRoot(moduleRoot, false);
|
|
4104
|
-
return readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) =>
|
|
4118
|
+
return readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path8.relative(moduleRoot, path8.join(entry.parentPath, entry.name))).sort();
|
|
4105
4119
|
}
|
|
4106
4120
|
|
|
4107
4121
|
// src/swift-darwin-records.ts
|
|
4108
4122
|
var DARWIN_RECORDS_PREFIX = "DarwinRecords-";
|
|
4109
4123
|
var darwinRecordsMinimum = () => iosDeploymentMinimum(NATIVE_GRAPH_SDK_VERSION) ?? 0;
|
|
4110
4124
|
function compileDarwinRecords(args) {
|
|
4111
|
-
const records =
|
|
4112
|
-
const runtime = mkdtempSync2(
|
|
4113
|
-
symlinkSync(
|
|
4125
|
+
const records = path9.join(args.packageRoot, "Sources/DarwinRecords");
|
|
4126
|
+
const runtime = mkdtempSync2(path9.join(tmpdir2(), "peach-objc-runtime-"));
|
|
4127
|
+
symlinkSync(path9.join(args.darwin, "usr/include/objc"), path9.join(runtime, "objc"));
|
|
4114
4128
|
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 =
|
|
4129
|
+
const object = path9.join(
|
|
4116
4130
|
args.out,
|
|
4117
4131
|
`${DARWIN_RECORDS_PREFIX}${file.replace(/\.[cm]$/, ".o")}`
|
|
4118
4132
|
);
|
|
4119
4133
|
execFileSync4(
|
|
4120
|
-
|
|
4134
|
+
path9.join(args.bin, "clang"),
|
|
4121
4135
|
[
|
|
4122
4136
|
"--target=wasm32-unknown-wasip1",
|
|
4123
4137
|
`--sysroot=${args.sysroot}`,
|
|
@@ -4127,7 +4141,7 @@ function compileDarwinRecords(args) {
|
|
|
4127
4141
|
// __BLOCKS__, as ios builds libmalloc
|
|
4128
4142
|
...file.endsWith(".m") ? [...swiftObjCRuntimeFlags, "-fwasm-exceptions"] : ["-fblocks"],
|
|
4129
4143
|
// assert() keeps __FILE__, which would carry the builder's checkout
|
|
4130
|
-
`-ffile-prefix-map=${records}${
|
|
4144
|
+
`-ffile-prefix-map=${records}${path9.sep}=DarwinRecords/`,
|
|
4131
4145
|
// apple's headers select on the ios identity original units compile
|
|
4132
4146
|
// with, and TargetConditionals.h refuses a compiler without it
|
|
4133
4147
|
...file.endsWith(".m") ? objcSdkIntakeFlags(args.darwin, args.bin, args.minimum) : [
|
|
@@ -4140,7 +4154,7 @@ function compileDarwinRecords(args) {
|
|
|
4140
4154
|
...swiftSharedSdkFlags(args.packageRoot, false)
|
|
4141
4155
|
],
|
|
4142
4156
|
"-c",
|
|
4143
|
-
|
|
4157
|
+
path9.join(records, file),
|
|
4144
4158
|
"-o",
|
|
4145
4159
|
object
|
|
4146
4160
|
],
|
|
@@ -4376,7 +4390,18 @@ function designTimeSites(source) {
|
|
|
4376
4390
|
while (t < to && tokens[t].kind !== "newline") t++;
|
|
4377
4391
|
continue;
|
|
4378
4392
|
}
|
|
4379
|
-
|
|
4393
|
+
const availability = word === "#available" || word === "#unavailable";
|
|
4394
|
+
t++;
|
|
4395
|
+
if (!availability && text(source, tokens[t]) === "<" && tokens[t].start === token.end) {
|
|
4396
|
+
let depth = 0;
|
|
4397
|
+
do {
|
|
4398
|
+
const p = text(source, tokens[t++]);
|
|
4399
|
+
if (p === "<") depth++;
|
|
4400
|
+
else if (p === ">") depth--;
|
|
4401
|
+
} while (t < to && depth > 0);
|
|
4402
|
+
}
|
|
4403
|
+
if (text(source, tokens[t]) === "(") t = skipGroup(t);
|
|
4404
|
+
if (!availability && text(source, tokens[t]) === "{") t = skipGroup(t);
|
|
4380
4405
|
continue;
|
|
4381
4406
|
}
|
|
4382
4407
|
if (token.kind === "at") {
|
|
@@ -4543,11 +4568,6 @@ function designTimeDiagnostic(output, files) {
|
|
|
4543
4568
|
}).join("\n");
|
|
4544
4569
|
}
|
|
4545
4570
|
|
|
4546
|
-
// src/is-record.ts
|
|
4547
|
-
function isRecord(value) {
|
|
4548
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4549
|
-
}
|
|
4550
|
-
|
|
4551
4571
|
// src/swift-distribution-contract.ts
|
|
4552
4572
|
var SWIFT_DISTRIBUTION_MANIFEST = "distribution.json";
|
|
4553
4573
|
var SWIFT_DISTRIBUTION_HOSTS = [
|
|
@@ -4595,7 +4615,7 @@ import { createHash as createHash5 } from "node:crypto";
|
|
|
4595
4615
|
import { existsSync, readFileSync as readFileSync7 } from "node:fs";
|
|
4596
4616
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
4597
4617
|
import os2 from "node:os";
|
|
4598
|
-
import
|
|
4618
|
+
import path10 from "node:path";
|
|
4599
4619
|
import { promisify as promisify2 } from "node:util";
|
|
4600
4620
|
import { brotliCompress, constants as zlibConstants, gunzip, gzip } from "node:zlib";
|
|
4601
4621
|
var run = promisify2(execFile2);
|
|
@@ -4612,8 +4632,8 @@ function cachedBrotli(bytes, quality, cacheKey) {
|
|
|
4612
4632
|
const cacheId = `${quality}:${key}`;
|
|
4613
4633
|
const cached = brotliMemoryCache.get(cacheId);
|
|
4614
4634
|
if (cached) return cached;
|
|
4615
|
-
const dir =
|
|
4616
|
-
const file =
|
|
4635
|
+
const dir = path10.join(os2.homedir(), ".peach", "cache", "swift-brotli");
|
|
4636
|
+
const file = path10.join(dir, `${key}${quality === 11 ? "" : "-q4"}.br`);
|
|
4617
4637
|
const pending = (async () => {
|
|
4618
4638
|
try {
|
|
4619
4639
|
return await readFile(file);
|
|
@@ -4677,7 +4697,7 @@ function swiftIcuAsset(toolchainBin, sdk) {
|
|
|
4677
4697
|
);
|
|
4678
4698
|
}
|
|
4679
4699
|
async function load(toolchainBin, sdk) {
|
|
4680
|
-
const swift =
|
|
4700
|
+
const swift = path10.join(toolchainBin, "swift");
|
|
4681
4701
|
if (!existsSync(swift))
|
|
4682
4702
|
throw new Error(`swift-icu: no swift at ${swift} for the ${sdk} SDK's icu data`);
|
|
4683
4703
|
const { stdout: listed } = await run(swift, ["sdk", "list", ...swiftSdkOptions()], {
|
|
@@ -4700,7 +4720,7 @@ async function load(toolchainBin, sdk) {
|
|
|
4700
4720
|
const resources = /^swiftStaticResourcesPath: (.+)$/m.exec(stdout)?.[1]?.trim();
|
|
4701
4721
|
if (!resources) throw new Error(`swift-icu: ${sdk} names no static resources`);
|
|
4702
4722
|
return Buffer.from(
|
|
4703
|
-
icuSegment(archiveMember(readFileSync7(
|
|
4723
|
+
icuSegment(archiveMember(readFileSync7(path10.join(resources, ARCHIVE)), MEMBER))
|
|
4704
4724
|
);
|
|
4705
4725
|
}
|
|
4706
4726
|
function archiveMember(archive, name2) {
|
|
@@ -4756,8 +4776,8 @@ function icuSegment(object) {
|
|
|
4756
4776
|
}
|
|
4757
4777
|
|
|
4758
4778
|
// src/swift-link-roots.ts
|
|
4759
|
-
import
|
|
4760
|
-
import
|
|
4779
|
+
import fs4 from "node:fs";
|
|
4780
|
+
import path11 from "node:path";
|
|
4761
4781
|
var OBJC_SEGMENTS = ["__objc_cats", "__objc_class_aliases"];
|
|
4762
4782
|
var leb = (bytes, at) => {
|
|
4763
4783
|
let value = 0;
|
|
@@ -4774,6 +4794,7 @@ function objcSegmentSizes(bytes) {
|
|
|
4774
4794
|
const names = [];
|
|
4775
4795
|
const sizes = [];
|
|
4776
4796
|
let hasExportedSymbol = false;
|
|
4797
|
+
let definesCategory = false;
|
|
4777
4798
|
while (at.offset < bytes.length) {
|
|
4778
4799
|
const id = bytes[at.offset++];
|
|
4779
4800
|
const size = leb(bytes, at);
|
|
@@ -4813,6 +4834,8 @@ function objcSegmentSizes(bytes) {
|
|
|
4813
4834
|
}
|
|
4814
4835
|
} else if (symKind === 1) {
|
|
4815
4836
|
const sLen = leb(bytes, at);
|
|
4837
|
+
if (!isUndef && Buffer.from(bytes.subarray(at.offset, at.offset + sLen)).toString().startsWith(".objc_category_"))
|
|
4838
|
+
definesCategory = true;
|
|
4816
4839
|
at.offset += sLen;
|
|
4817
4840
|
if (!isUndef) {
|
|
4818
4841
|
leb(bytes, at);
|
|
@@ -4849,6 +4872,7 @@ function objcSegmentSizes(bytes) {
|
|
|
4849
4872
|
result.set(name2, (result.get(name2) ?? 0) + (sizes[index] ?? 0));
|
|
4850
4873
|
});
|
|
4851
4874
|
result.set("__wasm_exported", hasExportedSymbol ? 1 : 0);
|
|
4875
|
+
result.set("__objc_category", definesCategory ? 1 : 0);
|
|
4852
4876
|
return result;
|
|
4853
4877
|
}
|
|
4854
4878
|
var rootsByDistribution = /* @__PURE__ */ new Map();
|
|
@@ -4856,7 +4880,7 @@ function swiftObjcRootObjects(id, root, objects) {
|
|
|
4856
4880
|
const cached = rootsByDistribution.get(id);
|
|
4857
4881
|
if (cached) return cached;
|
|
4858
4882
|
const measured = objects.map(
|
|
4859
|
-
(object) => [object, objcSegmentSizes(
|
|
4883
|
+
(object) => [object, objcSegmentSizes(fs4.readFileSync(path11.join(root, object)))]
|
|
4860
4884
|
);
|
|
4861
4885
|
const empty = /* @__PURE__ */ new Map();
|
|
4862
4886
|
for (const [, sizes] of measured)
|
|
@@ -4911,14 +4935,14 @@ import {
|
|
|
4911
4935
|
rmSync as rmSync3,
|
|
4912
4936
|
statSync
|
|
4913
4937
|
} from "node:fs";
|
|
4914
|
-
import
|
|
4938
|
+
import path12 from "node:path";
|
|
4915
4939
|
function prepareSwiftProjectProcess(root, user) {
|
|
4916
4940
|
const home = `${root}.project-home`;
|
|
4917
4941
|
rmSync3(home, { recursive: true, force: true });
|
|
4918
|
-
const tmp =
|
|
4919
|
-
const swiftpm =
|
|
4942
|
+
const tmp = path12.join(home, "tmp");
|
|
4943
|
+
const swiftpm = path12.join(home, "swiftpm");
|
|
4920
4944
|
mkdirSync(tmp, { recursive: true });
|
|
4921
|
-
const caches = ["cache", "config", "security"].map((name2) =>
|
|
4945
|
+
const caches = ["cache", "config", "security"].map((name2) => path12.join(swiftpm, name2));
|
|
4922
4946
|
for (const directory of caches) mkdirSync(directory, { recursive: true });
|
|
4923
4947
|
execFileSync5("chown", ["-R", "-P", `${user.uid}:${user.gid}`, root, home]);
|
|
4924
4948
|
chmodSync(root, 448);
|
|
@@ -4929,14 +4953,14 @@ function prepareSwiftProjectProcess(root, user) {
|
|
|
4929
4953
|
env: {
|
|
4930
4954
|
HOME: home,
|
|
4931
4955
|
TMPDIR: tmp,
|
|
4932
|
-
XDG_CONFIG_HOME:
|
|
4933
|
-
XDG_CACHE_HOME:
|
|
4934
|
-
XDG_DATA_HOME:
|
|
4956
|
+
XDG_CONFIG_HOME: path12.join(home, ".config"),
|
|
4957
|
+
XDG_CACHE_HOME: path12.join(home, ".cache"),
|
|
4958
|
+
XDG_DATA_HOME: path12.join(home, ".local", "share")
|
|
4935
4959
|
},
|
|
4936
4960
|
cacheOptions: [
|
|
4937
4961
|
...["cache", "config", "security"].flatMap((name2) => [
|
|
4938
4962
|
`--${name2}-path`,
|
|
4939
|
-
|
|
4963
|
+
path12.join(swiftpm, name2)
|
|
4940
4964
|
]),
|
|
4941
4965
|
"--disable-keychain"
|
|
4942
4966
|
]
|
|
@@ -4952,7 +4976,7 @@ function projectOutputFile(root, file, user) {
|
|
|
4952
4976
|
const real = realpathSync(file);
|
|
4953
4977
|
const base = realpathSync(root);
|
|
4954
4978
|
const stat = statSync(real);
|
|
4955
|
-
if (!real.startsWith(base +
|
|
4979
|
+
if (!real.startsWith(base + path12.sep) || !stat.isFile() || stat.uid !== user.uid) {
|
|
4956
4980
|
throw new Error(`swift-compile: project output ${file} is not a file of its build`);
|
|
4957
4981
|
}
|
|
4958
4982
|
return real;
|
|
@@ -4961,7 +4985,7 @@ function removeProjectLinks(root) {
|
|
|
4961
4985
|
const pending = [root];
|
|
4962
4986
|
for (let directory = pending.pop(); directory; directory = pending.pop()) {
|
|
4963
4987
|
for (const entry of readdirSync6(directory, { withFileTypes: true })) {
|
|
4964
|
-
const full =
|
|
4988
|
+
const full = path12.join(directory, entry.name);
|
|
4965
4989
|
if (directory === root && entry.name === ".build") continue;
|
|
4966
4990
|
if (directory === root && entry.name.startsWith(".peach-modules-")) {
|
|
4967
4991
|
rmSync3(full, { recursive: true, force: true });
|
|
@@ -5002,7 +5026,26 @@ import {
|
|
|
5002
5026
|
rmSync as rmSync4,
|
|
5003
5027
|
writeFileSync as writeFileSync2
|
|
5004
5028
|
} from "node:fs";
|
|
5029
|
+
import { homedir as homedir2 } from "node:os";
|
|
5005
5030
|
import path14 from "node:path";
|
|
5031
|
+
|
|
5032
|
+
// src/home-paths.ts
|
|
5033
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
5034
|
+
import fs5 from "node:fs";
|
|
5035
|
+
import { homedir } from "node:os";
|
|
5036
|
+
import path13 from "node:path";
|
|
5037
|
+
var PEACH_HOME_ENV = "PEACH_HOME";
|
|
5038
|
+
function ambientHomeDir() {
|
|
5039
|
+
return path13.join(homedir(), ".peach");
|
|
5040
|
+
}
|
|
5041
|
+
function rnxHomeDir() {
|
|
5042
|
+
const override = process.env[PEACH_HOME_ENV];
|
|
5043
|
+
if (override && override.length > 0) return path13.resolve(override);
|
|
5044
|
+
return ambientHomeDir();
|
|
5045
|
+
}
|
|
5046
|
+
var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
|
|
5047
|
+
|
|
5048
|
+
// src/swift-root-lock.ts
|
|
5006
5049
|
var POLL_MS = 250;
|
|
5007
5050
|
var START_TOLERANCE_MS = 2e3;
|
|
5008
5051
|
function errorCode(error) {
|
|
@@ -5775,11 +5818,9 @@ function parseWasmObjectBytes(file, buf, isDist) {
|
|
|
5775
5818
|
}
|
|
5776
5819
|
}
|
|
5777
5820
|
const typePrefixesInObj = /* @__PURE__ */ new Set();
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
typePrefixesInObj.add(symNames[i].slice(0, -2));
|
|
5782
|
-
}
|
|
5821
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
5822
|
+
if ((symFlags[i] & 16) === 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mn")) {
|
|
5823
|
+
typePrefixesInObj.add(symNames[i].slice(0, -2));
|
|
5783
5824
|
}
|
|
5784
5825
|
}
|
|
5785
5826
|
const objcRegisterFuncToTypePrefix = /* @__PURE__ */ new Map();
|
|
@@ -6061,15 +6102,16 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6061
6102
|
set.add(symIdx);
|
|
6062
6103
|
workQueue.push({ kind: "datasym", obj, symIdx });
|
|
6063
6104
|
};
|
|
6064
|
-
const
|
|
6105
|
+
const knownTypes = /* @__PURE__ */ new Set();
|
|
6065
6106
|
for (const o of distObjs.values())
|
|
6066
|
-
for (const t of o.typePrefixesInObj)
|
|
6107
|
+
for (const t of o.typePrefixesInObj) knownTypes.add(t);
|
|
6067
6108
|
const globalLiveTypes = /* @__PURE__ */ new Set();
|
|
6068
6109
|
const pendingConformances = /* @__PURE__ */ new Map();
|
|
6110
|
+
const eagerConformanceObjects = /* @__PURE__ */ new Set();
|
|
6069
6111
|
const conformingType = (name2) => {
|
|
6070
6112
|
for (let n = name2.length - 1; n > 2; n--) {
|
|
6071
6113
|
const prefix = name2.slice(0, n);
|
|
6072
|
-
if (
|
|
6114
|
+
if (knownTypes.has(prefix)) return prefix;
|
|
6073
6115
|
}
|
|
6074
6116
|
return void 0;
|
|
6075
6117
|
};
|
|
@@ -6081,7 +6123,11 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6081
6123
|
const waiting = pendingConformances.get(pref);
|
|
6082
6124
|
if (waiting) {
|
|
6083
6125
|
pendingConformances.delete(pref);
|
|
6084
|
-
for (const w of waiting)
|
|
6126
|
+
for (const w of waiting) {
|
|
6127
|
+
eagerConformanceObjects.add(w.obj);
|
|
6128
|
+
extractObject(w.obj);
|
|
6129
|
+
activateSymbolInObj(w.obj, w.symIdx);
|
|
6130
|
+
}
|
|
6085
6131
|
}
|
|
6086
6132
|
const mnName = `${pref}Mn`;
|
|
6087
6133
|
for (let i = 0; i < obj.symNames.length; i++) {
|
|
@@ -6108,7 +6154,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6108
6154
|
}
|
|
6109
6155
|
};
|
|
6110
6156
|
const checkTypeTrigger = (obj, rawSymName) => {
|
|
6111
|
-
if (!
|
|
6157
|
+
if (!rawSymName) return;
|
|
6112
6158
|
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
6113
6159
|
const objcPref = obj.objcClassSymToTypePrefix.get(sName);
|
|
6114
6160
|
if (objcPref) {
|
|
@@ -6199,6 +6245,13 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6199
6245
|
}
|
|
6200
6246
|
for (const fIdx of obj.rootFuncs) markFuncLive(obj, fIdx);
|
|
6201
6247
|
for (const sIdx of obj.rootSegs) markSegLive(obj, sIdx);
|
|
6248
|
+
for (const name2 of obj.symNames) {
|
|
6249
|
+
const loaded = name2?.match(/^_c_(\w+)__load$/)?.[1];
|
|
6250
|
+
if (!loaded) continue;
|
|
6251
|
+
const classSym = obj.symNames.indexOf(`._OBJC_CLASS_${loaded}`);
|
|
6252
|
+
if (classSym !== -1 && (obj.symFlags[classSym] & 16) === 0)
|
|
6253
|
+
activateSymbolInObj(obj, classSym);
|
|
6254
|
+
}
|
|
6202
6255
|
if (obj.file.endsWith("libswiftCore__Swift.o")) {
|
|
6203
6256
|
for (const pref of obj.typePrefixesInObj) {
|
|
6204
6257
|
if (!pref.startsWith("$ss")) {
|
|
@@ -6223,11 +6276,6 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6223
6276
|
const type = conformingType(mcName);
|
|
6224
6277
|
if (type === void 0 || globalLiveTypes.has(type))
|
|
6225
6278
|
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
6279
|
}
|
|
6232
6280
|
}
|
|
6233
6281
|
}
|
|
@@ -6235,6 +6283,17 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6235
6283
|
}
|
|
6236
6284
|
}
|
|
6237
6285
|
};
|
|
6286
|
+
for (const obj of distObjs.values()) {
|
|
6287
|
+
if (!obj.isDist) continue;
|
|
6288
|
+
for (const r of obj.dataRelocList) {
|
|
6289
|
+
if (obj.segNames[r.segIdx] !== "swift5_protocol_conformances") continue;
|
|
6290
|
+
const type = conformingType(obj.symNames[r.rs]);
|
|
6291
|
+
if (type === void 0 || obj.typePrefixesInObj.has(type)) continue;
|
|
6292
|
+
let list = pendingConformances.get(type);
|
|
6293
|
+
if (!list) pendingConformances.set(type, list = []);
|
|
6294
|
+
list.push({ obj, symIdx: r.rs });
|
|
6295
|
+
}
|
|
6296
|
+
}
|
|
6238
6297
|
let hasClangObjCEager = false;
|
|
6239
6298
|
const eagerBuildPrunable = [];
|
|
6240
6299
|
for (const f of eagerFiles) {
|
|
@@ -6653,6 +6712,12 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6653
6712
|
emittedPruned.add(ef);
|
|
6654
6713
|
}
|
|
6655
6714
|
}
|
|
6715
|
+
for (const obj of eagerConformanceObjects) {
|
|
6716
|
+
if (!emittedPruned.has(obj.file) && prunedMap.has(obj.file)) {
|
|
6717
|
+
outTokens.push(prunedMap.get(obj.file));
|
|
6718
|
+
emittedPruned.add(obj.file);
|
|
6719
|
+
}
|
|
6720
|
+
}
|
|
6656
6721
|
outTokens.push("--start-lib");
|
|
6657
6722
|
for (const rf of prunableCandidates) {
|
|
6658
6723
|
if (emittedPruned.has(rf)) continue;
|
|
@@ -6828,7 +6893,8 @@ function isSwiftResourceBundles(value) {
|
|
|
6828
6893
|
}
|
|
6829
6894
|
|
|
6830
6895
|
// src/wasm-optimize.ts
|
|
6831
|
-
import {
|
|
6896
|
+
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
6897
|
+
import { BinaryNotFoundError, BINARYEN_VERSION, wasmOpt } from "wasm-opt";
|
|
6832
6898
|
var FEATURES = [
|
|
6833
6899
|
"threads",
|
|
6834
6900
|
"bulk-memory",
|
|
@@ -6842,7 +6908,7 @@ var FEATURES = [
|
|
|
6842
6908
|
"sign-ext"
|
|
6843
6909
|
];
|
|
6844
6910
|
var WASM_OPTIMIZE_IDENTITY = `wasm-opt ${BINARYEN_VERSION} -Oz ${FEATURES.join(",")}`;
|
|
6845
|
-
async function
|
|
6911
|
+
async function runWasmOpt(file, output) {
|
|
6846
6912
|
const result = await wasmOpt([
|
|
6847
6913
|
"-Oz",
|
|
6848
6914
|
...FEATURES.map((feature) => `--enable-${feature}`),
|
|
@@ -6853,6 +6919,29 @@ async function optimizeWasm(file, output) {
|
|
|
6853
6919
|
if (result.status !== 0)
|
|
6854
6920
|
throw new Error(`wasm-opt exited ${result.status}: ${result.stderr}`);
|
|
6855
6921
|
}
|
|
6922
|
+
function installWasmOpt() {
|
|
6923
|
+
try {
|
|
6924
|
+
execFileSync8("npx", ["-y", "wasm-opt", "--wasm-opt-install"], {
|
|
6925
|
+
timeout: 6e5,
|
|
6926
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
6927
|
+
env: { ...process.env, WASM_OPT_VERSION: BINARYEN_VERSION }
|
|
6928
|
+
});
|
|
6929
|
+
} catch (error) {
|
|
6930
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
6931
|
+
throw new Error(`wasm-opt binary missing and on-demand install failed: ${detail}`, {
|
|
6932
|
+
cause: error
|
|
6933
|
+
});
|
|
6934
|
+
}
|
|
6935
|
+
}
|
|
6936
|
+
async function optimizeWasm(file, output) {
|
|
6937
|
+
try {
|
|
6938
|
+
await runWasmOpt(file, output);
|
|
6939
|
+
} catch (error) {
|
|
6940
|
+
if (!(error instanceof BinaryNotFoundError)) throw error;
|
|
6941
|
+
installWasmOpt();
|
|
6942
|
+
await runWasmOpt(file, output);
|
|
6943
|
+
}
|
|
6944
|
+
}
|
|
6856
6945
|
|
|
6857
6946
|
// src/write-build-file.ts
|
|
6858
6947
|
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync10, writeFileSync as writeFileSync3 } from "node:fs";
|
|
@@ -7079,21 +7168,20 @@ function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
|
|
|
7079
7168
|
return { declared: swiftInterfaceDeclarations(header), header };
|
|
7080
7169
|
}
|
|
7081
7170
|
const sources = path19.join(moduleRoot, "Sources", name2);
|
|
7082
|
-
|
|
7171
|
+
const built = path19.join(moduleRoot, ".build/host", `${name2}-Swift.h`);
|
|
7172
|
+
if (!existsSync4(sources) || !existsSync4(built)) return null;
|
|
7083
7173
|
const declared = /* @__PURE__ */ new Set();
|
|
7084
7174
|
for (const file of readdirSync8(sources, { recursive: true, encoding: "utf8" }))
|
|
7085
7175
|
if (file.endsWith(".swift"))
|
|
7086
|
-
for (const [, objc] of readFileSync11(
|
|
7087
|
-
|
|
7176
|
+
for (const [, objc, subclass] of readFileSync11(
|
|
7177
|
+
path19.join(sources, file),
|
|
7178
|
+
"utf8"
|
|
7179
|
+
).matchAll(
|
|
7180
|
+
/@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s|^(?:public|open)\s+(?:final\s+)?class\s+(\w+)\s*:\s*NSObject\b/gm
|
|
7088
7181
|
))
|
|
7089
|
-
declared.add(objc);
|
|
7182
|
+
declared.add(objc ?? subclass);
|
|
7090
7183
|
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
|
-
};
|
|
7184
|
+
return { declared, header: clangInterfaceHeader(readFileSync11(built, "utf8")) };
|
|
7097
7185
|
}
|
|
7098
7186
|
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
7187
|
var swiftInterfaceDeclarations = (header) => /* @__PURE__ */ new Set([
|
|
@@ -7309,9 +7397,10 @@ function swiftProjectBuildKey(moduleRoot, release) {
|
|
|
7309
7397
|
var SYSTEM_MODULE_LIBRARIES = {
|
|
7310
7398
|
"sqlite3.h": "sqlite3",
|
|
7311
7399
|
"sqlite3ext.h": "sqlite3",
|
|
7400
|
+
"bzlib.h": "bz2",
|
|
7312
7401
|
SQLite3: "sqlite3"
|
|
7313
7402
|
};
|
|
7314
|
-
var SYSTEM_MODULE_IMPORT = /^\s*(?:#\s*(?:import|include)\s*<(sqlite3(?:ext)?\.h)>|@import\s+(SQLite3)\b)/gm;
|
|
7403
|
+
var SYSTEM_MODULE_IMPORT = /^\s*(?:#\s*(?:import|include)\s*<(sqlite3(?:ext)?\.h|bzlib\.h)>|@import\s+(SQLite3)\b)/gm;
|
|
7315
7404
|
function compileTargets(input) {
|
|
7316
7405
|
const manifest = input.files["Package.swift"];
|
|
7317
7406
|
if (manifest === void 0) return [];
|
|
@@ -7507,7 +7596,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
7507
7596
|
const key = JSON.stringify([toolchainBin, sdk, options]);
|
|
7508
7597
|
const cached = sdkPaths.get(key);
|
|
7509
7598
|
if (cached) return cached;
|
|
7510
|
-
const configuration =
|
|
7599
|
+
const configuration = execFileSync9(
|
|
7511
7600
|
path19.join(toolchainBin, "swift"),
|
|
7512
7601
|
[
|
|
7513
7602
|
"sdk",
|
|
@@ -7677,6 +7766,11 @@ function swiftTargetDependencies(files, targets) {
|
|
|
7677
7766
|
const siblings = /* @__PURE__ */ new Map();
|
|
7678
7767
|
for (const target of targets) {
|
|
7679
7768
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
7769
|
+
const ownsHeader = (header) => [`${prefix}${header}`, `${prefix}include/${header}`].some(
|
|
7770
|
+
(file) => Object.hasOwn(files, file) && !targets.some(
|
|
7771
|
+
(candidate) => candidate.name !== target.name && candidate.path !== "." && file.startsWith(`${candidate.path}/`)
|
|
7772
|
+
)
|
|
7773
|
+
);
|
|
7680
7774
|
const deps = new Set(
|
|
7681
7775
|
(target.dependencies ?? []).flatMap(
|
|
7682
7776
|
(dependency) => dependency.kind === "target" && dependency.name !== target.name && names.has(dependency.name) ? [dependency.name] : []
|
|
@@ -7688,7 +7782,7 @@ function swiftTargetDependencies(files, targets) {
|
|
|
7688
7782
|
(candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
|
|
7689
7783
|
))
|
|
7690
7784
|
continue;
|
|
7691
|
-
const imports = file.endsWith(".swift") ? swiftImportNames(contents) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents) : [];
|
|
7785
|
+
const imports = file.endsWith(".swift") ? swiftImportNames(contents) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents, ownsHeader) : [];
|
|
7692
7786
|
for (const name2 of imports) {
|
|
7693
7787
|
if (names.has(name2) && name2 !== target.name) deps.add(name2);
|
|
7694
7788
|
}
|
|
@@ -7724,9 +7818,9 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
|
7724
7818
|
`;
|
|
7725
7819
|
var darwinRecordsRegion = (quoted) => quoted.length ? ["-Wl,--start-lib", ...quoted, "-Wl,--end-lib"] : [];
|
|
7726
7820
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
7727
|
-
var MULTI_MANIFEST_VERSION =
|
|
7821
|
+
var MULTI_MANIFEST_VERSION = 65;
|
|
7728
7822
|
var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
7729
|
-
var compilerSourceDigest = true ? "
|
|
7823
|
+
var compilerSourceDigest = true ? "c1407efb75c18328e37b50abfe396dce388c41563443b4c3a1485a800114a92c" : swiftCompilerSourceDigest(import.meta.dirname);
|
|
7730
7824
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
7731
7825
|
const hash = createHash8("sha256");
|
|
7732
7826
|
hash.update(`swift-compile
|
|
@@ -7811,6 +7905,13 @@ ${target}
|
|
|
7811
7905
|
}
|
|
7812
7906
|
return hash.digest("hex");
|
|
7813
7907
|
}
|
|
7908
|
+
var nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
7909
|
+
var cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|
|
7910
|
+
var cxxFlagArray = (flags) => JSON.stringify([
|
|
7911
|
+
...nativeCxxCompilerFlags,
|
|
7912
|
+
...fmtConstantInterpreterFlags(flags),
|
|
7913
|
+
...withoutGlogModuleMap(flags)
|
|
7914
|
+
]);
|
|
7814
7915
|
function swiftCrossImportFlags(moduleRoot, distribution) {
|
|
7815
7916
|
const overlayRoot = path19.join(
|
|
7816
7917
|
moduleRoot,
|
|
@@ -8043,13 +8144,13 @@ function emitSwiftPackageManifest(args) {
|
|
|
8043
8144
|
(source) => /\.(?:cc|cpp|cxx|mm)$/.test(source)
|
|
8044
8145
|
);
|
|
8045
8146
|
const nativeSettings = native?.clang ? [
|
|
8046
|
-
`cSettings: [${cDefines} .unsafeFlags(${flagArray(
|
|
8147
|
+
`cSettings: [${cDefines} .unsafeFlags(${flagArray(cFlagArray([...nativeFlags, ...native.clang.flags]))})]`,
|
|
8047
8148
|
...nativeCxx ? [
|
|
8048
|
-
`cxxSettings: [${cxxDefines} .unsafeFlags(${flagArray(
|
|
8149
|
+
`cxxSettings: [${cxxDefines} .unsafeFlags(${flagArray(cxxFlagArray([...cxxFlagsFor(nativeFlags), ...native.clang.cxxFlags]))})]`
|
|
8049
8150
|
] : []
|
|
8050
8151
|
].join(", ") : [
|
|
8051
|
-
`cSettings: [${cDefines}${declaredClangSettings(target, "c")} .unsafeFlags(${flagArray(
|
|
8052
|
-
`cxxSettings: [${cxxDefines}${declaredClangSettings(target, "cxx")} .unsafeFlags(${flagArray(
|
|
8152
|
+
`cSettings: [${cDefines}${declaredClangSettings(target, "c")} .unsafeFlags(${flagArray(cFlagArray([...nativeFlags, ...native?.flags ?? []]))})]`,
|
|
8153
|
+
`cxxSettings: [${cxxDefines}${declaredClangSettings(target, "cxx")} .unsafeFlags(${flagArray(cxxFlagArray([...cxxFlagsFor(nativeFlags), ...native?.cxxFlags ?? []]))})]`
|
|
8053
8154
|
].join(", ");
|
|
8054
8155
|
const exclusions = native?.clang ? [] : [
|
|
8055
8156
|
...native ? native.exclude ?? native.lateSources : [],
|
|
@@ -8118,9 +8219,9 @@ function emitSwiftPackageManifest(args) {
|
|
|
8118
8219
|
` path: ${JSON.stringify(group.path)},`,
|
|
8119
8220
|
` sources: ${JSON.stringify(group.sources)},`,
|
|
8120
8221
|
' publicHeadersPath: "include",',
|
|
8121
|
-
` cSettings: [${macroSettings(owner?.cDefines)}${declaredClangSettings(owner, "c")} .unsafeFlags(${flagArray(
|
|
8222
|
+
` cSettings: [${macroSettings(owner?.cDefines)}${declaredClangSettings(owner, "c")} .unsafeFlags(${flagArray(cFlagArray([...nativeFlags, "-I", native.includeDirectory, ...args.headerDirectory ? ["-I", args.headerDirectory] : [], ...group.flags]))})],`,
|
|
8122
8223
|
...group.sources.some((source) => /\.(?:cc|cpp|cxx|mm)$/.test(source)) ? [
|
|
8123
|
-
` cxxSettings: [${macroSettings(owner?.cxxDefines)}${declaredClangSettings(owner, "cxx")} .unsafeFlags(${flagArray(
|
|
8224
|
+
` cxxSettings: [${macroSettings(owner?.cxxDefines)}${declaredClangSettings(owner, "cxx")} .unsafeFlags(${flagArray(cxxFlagArray([...cxxFlagsFor(nativeFlags), ...group.cxxFlags]))})]),`
|
|
8124
8225
|
] : [" ),"]
|
|
8125
8226
|
]) : [];
|
|
8126
8227
|
}),
|
|
@@ -9828,20 +9929,34 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
9828
9929
|
moduleInterfaces.set(name2, value);
|
|
9829
9930
|
return value;
|
|
9830
9931
|
};
|
|
9932
|
+
const podHeaders = /* @__PURE__ */ new Map();
|
|
9933
|
+
for (const settings of input.nativeTargets ?? [])
|
|
9934
|
+
for (const file of settings.headers) {
|
|
9935
|
+
const owner = /\/Headers\/(?:Public|Private)\/([\w+-]+)\/(?:\1\/)?[^/]+\.h$/.exec(
|
|
9936
|
+
file
|
|
9937
|
+
)?.[1];
|
|
9938
|
+
if (owner)
|
|
9939
|
+
podHeaders.set(path19.basename(file), [
|
|
9940
|
+
...podHeaders.get(path19.basename(file)) ?? [],
|
|
9941
|
+
{ owner, content: input.files[file] }
|
|
9942
|
+
]);
|
|
9943
|
+
}
|
|
9944
|
+
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(path19.basename(file))?.find((header) => header.content === content)?.owner;
|
|
9831
9945
|
for (const settings of input.nativeTargets ?? []) {
|
|
9832
9946
|
for (const file of settings.headers) {
|
|
9833
9947
|
const destination = path19.join(layout.root, file);
|
|
9834
9948
|
if (files.has(destination)) continue;
|
|
9835
9949
|
const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
|
|
9836
9950
|
const frameworkHeader = !interfaceModule && /(?:^|\/)(\w+)\.framework\/Headers\/[\w+.-]+\.h$/.exec(file)?.[1];
|
|
9837
|
-
const
|
|
9951
|
+
const interfaceOwner = frameworkHeader || (interfaceModule ? void 0 : podHeaderOwner(file, input.files[file]));
|
|
9952
|
+
const frameworkInterface = interfaceOwner ? moduleInterface(interfaceOwner) : null;
|
|
9838
9953
|
const rawContents = interfaceModule && moduleInterface(interfaceModule)?.header || input.files[file];
|
|
9839
9954
|
if (rawContents === void 0)
|
|
9840
9955
|
throw new Error(`missing original Objective-C header ${file}`);
|
|
9841
9956
|
const contents = frameworkInterface && typeof rawContents === "string" ? withoutSwiftDeclarations(
|
|
9842
9957
|
rawContents,
|
|
9843
9958
|
frameworkInterface.declared,
|
|
9844
|
-
`#import <${
|
|
9959
|
+
`#import <${interfaceOwner}/${interfaceOwner}-Swift.h>`
|
|
9845
9960
|
) : rawContents;
|
|
9846
9961
|
writeBuildFile(destination, contents);
|
|
9847
9962
|
files.set(destination, contents);
|