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,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.1812 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -86,7 +86,7 @@ __export(swift_compile_exports, {
|
|
|
86
86
|
writeSwiftProject: () => writeSwiftProject
|
|
87
87
|
});
|
|
88
88
|
module.exports = __toCommonJS(swift_compile_exports);
|
|
89
|
-
var
|
|
89
|
+
var import_node_child_process14 = require("node:child_process");
|
|
90
90
|
var import_node_crypto8 = require("node:crypto");
|
|
91
91
|
var import_node_fs17 = require("node:fs");
|
|
92
92
|
var import_node_os9 = __toESM(require("node:os"), 1);
|
|
@@ -2162,57 +2162,21 @@ var swift_c_predefines_default = {
|
|
|
2162
2162
|
}
|
|
2163
2163
|
};
|
|
2164
2164
|
|
|
2165
|
-
// src/home-paths.ts
|
|
2166
|
-
var import_node_os = require("node:os");
|
|
2167
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
2168
|
-
var PEACH_HOME_ENV = "PEACH_HOME";
|
|
2169
|
-
function ambientHomeDir() {
|
|
2170
|
-
return import_node_path.default.join((0, import_node_os.homedir)(), ".peach");
|
|
2171
|
-
}
|
|
2172
|
-
function rnxHomeDir() {
|
|
2173
|
-
const override = process.env[PEACH_HOME_ENV];
|
|
2174
|
-
if (override && override.length > 0) return import_node_path.default.resolve(override);
|
|
2175
|
-
return ambientHomeDir();
|
|
2176
|
-
}
|
|
2177
|
-
function cacheDir() {
|
|
2178
|
-
return import_node_path.default.join(rnxHomeDir(), "cache");
|
|
2179
|
-
}
|
|
2180
|
-
var BUILDERS_ROOT_ENV = "CONTRAST_BUILDERS_ROOT";
|
|
2181
|
-
function buildersRootEnv() {
|
|
2182
|
-
const root = process.env[BUILDERS_ROOT_ENV]?.trim();
|
|
2183
|
-
return root ? root : null;
|
|
2184
|
-
}
|
|
2185
|
-
function swiftCacheDir() {
|
|
2186
|
-
const root = buildersRootEnv();
|
|
2187
|
-
return root ? import_node_path.default.join(root, "peach-cache") : cacheDir();
|
|
2188
|
-
}
|
|
2189
|
-
function swiftPackageCacheOptions() {
|
|
2190
|
-
const root = import_node_path.default.join(swiftCacheDir(), "swiftpm");
|
|
2191
|
-
return [
|
|
2192
|
-
...["cache", "config", "security"].flatMap((name2) => [
|
|
2193
|
-
`--${name2}-path`,
|
|
2194
|
-
import_node_path.default.join(root, name2)
|
|
2195
|
-
]),
|
|
2196
|
-
"--disable-keychain"
|
|
2197
|
-
];
|
|
2198
|
-
}
|
|
2199
|
-
var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
|
|
2200
|
-
|
|
2201
2165
|
// src/process-group.ts
|
|
2202
2166
|
var import_node_child_process3 = require("node:child_process");
|
|
2203
2167
|
var import_node_fs2 = require("node:fs");
|
|
2204
|
-
var
|
|
2205
|
-
var
|
|
2168
|
+
var import_node_os2 = require("node:os");
|
|
2169
|
+
var import_node_path = require("node:path");
|
|
2206
2170
|
var import_node_stream = require("node:stream");
|
|
2207
2171
|
var import_promises = require("node:timers/promises");
|
|
2208
2172
|
|
|
2209
2173
|
// src/process-table.ts
|
|
2210
2174
|
var import_node_child_process2 = require("node:child_process");
|
|
2211
2175
|
var import_node_fs = require("node:fs");
|
|
2212
|
-
var
|
|
2176
|
+
var import_node_os = require("node:os");
|
|
2213
2177
|
function linuxClockTicks() {
|
|
2214
2178
|
const auxv = (0, import_node_fs.readFileSync)("/proc/self/auxv");
|
|
2215
|
-
const word = (offset) => (0,
|
|
2179
|
+
const word = (offset) => (0, import_node_os.endianness)() === "LE" ? auxv.readBigUInt64LE(offset) : auxv.readBigUInt64BE(offset);
|
|
2216
2180
|
for (let offset = 0; offset + 16 <= auxv.length; offset += 16) {
|
|
2217
2181
|
if (word(offset) !== 17n) continue;
|
|
2218
2182
|
const ticks = Number(word(offset + 8));
|
|
@@ -2355,8 +2319,8 @@ function signalProcessGroup(child, signal) {
|
|
|
2355
2319
|
}
|
|
2356
2320
|
}
|
|
2357
2321
|
async function protectProcessFreeze(rootPid) {
|
|
2358
|
-
const directory = (0, import_node_fs2.mkdtempSync)((0,
|
|
2359
|
-
const journal = (0,
|
|
2322
|
+
const directory = (0, import_node_fs2.mkdtempSync)((0, import_node_path.join)((0, import_node_os2.tmpdir)(), "peach-process-freeze-"));
|
|
2323
|
+
const journal = (0, import_node_path.join)(directory, "targets");
|
|
2360
2324
|
(0, import_node_fs2.writeFileSync)(journal, `group ${rootPid}
|
|
2361
2325
|
pid ${rootPid}
|
|
2362
2326
|
`, { mode: 384 });
|
|
@@ -2609,7 +2573,7 @@ async function terminateProcessGroup(child, signal = "SIGTERM", gracefulTimeoutM
|
|
|
2609
2573
|
var import_node_crypto = require("node:crypto");
|
|
2610
2574
|
var import_node_fs4 = require("node:fs");
|
|
2611
2575
|
var import_promises2 = require("node:fs/promises");
|
|
2612
|
-
var
|
|
2576
|
+
var import_node_path2 = __toESM(require("node:path"), 1);
|
|
2613
2577
|
|
|
2614
2578
|
// src/process-liveness.ts
|
|
2615
2579
|
var import_node_fs3 = require("node:fs");
|
|
@@ -2642,8 +2606,8 @@ function removeRetiredDirectory(directory) {
|
|
|
2642
2606
|
function reapRetiredCacheDirectory(parent, name2) {
|
|
2643
2607
|
const owner = /^\.retired-(\d+)-/.exec(name2);
|
|
2644
2608
|
if (!owner || isProcessRunning(Number(owner[1]))) return;
|
|
2645
|
-
const directory =
|
|
2646
|
-
const claimed =
|
|
2609
|
+
const directory = import_node_path2.default.join(parent, name2);
|
|
2610
|
+
const claimed = import_node_path2.default.join(parent, `.retired-${process.pid}-${(0, import_node_crypto.randomUUID)()}`);
|
|
2647
2611
|
try {
|
|
2648
2612
|
(0, import_node_fs4.renameSync)(directory, claimed);
|
|
2649
2613
|
} catch (error) {
|
|
@@ -2655,12 +2619,12 @@ function reapRetiredCacheDirectory(parent, name2) {
|
|
|
2655
2619
|
|
|
2656
2620
|
// src/swift-objc-sdk-tree.ts
|
|
2657
2621
|
var import_node_fs5 = require("node:fs");
|
|
2658
|
-
var
|
|
2622
|
+
var import_node_path3 = __toESM(require("node:path"), 1);
|
|
2659
2623
|
function readIosSdkTree(root) {
|
|
2660
2624
|
return (0, import_node_fs5.readdirSync)(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => {
|
|
2661
|
-
const file =
|
|
2625
|
+
const file = import_node_path3.default.join(entry.parentPath, entry.name);
|
|
2662
2626
|
return [
|
|
2663
|
-
|
|
2627
|
+
import_node_path3.default.relative(root, file).split(import_node_path3.default.sep).join("/"),
|
|
2664
2628
|
(0, import_node_fs5.readFileSync)(file, "utf8")
|
|
2665
2629
|
];
|
|
2666
2630
|
}).sort(([a], [b]) => a < b ? -1 : 1);
|
|
@@ -2669,38 +2633,38 @@ function readIosSdkTree(root) {
|
|
|
2669
2633
|
// src/swift-darwin-records.ts
|
|
2670
2634
|
var import_node_child_process7 = require("node:child_process");
|
|
2671
2635
|
var import_node_fs8 = require("node:fs");
|
|
2672
|
-
var
|
|
2673
|
-
var
|
|
2636
|
+
var import_node_os4 = require("node:os");
|
|
2637
|
+
var import_node_path9 = __toESM(require("node:path"), 1);
|
|
2674
2638
|
|
|
2675
2639
|
// src/swift-objc-platform.ts
|
|
2676
2640
|
var import_node_child_process5 = require("node:child_process");
|
|
2677
|
-
var
|
|
2641
|
+
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
2678
2642
|
|
|
2679
2643
|
// src/swift-toolchain.ts
|
|
2680
2644
|
var import_node_child_process4 = require("node:child_process");
|
|
2681
2645
|
var import_node_crypto2 = require("node:crypto");
|
|
2682
2646
|
var import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
2683
|
-
var
|
|
2684
|
-
var
|
|
2647
|
+
var import_node_os3 = __toESM(require("node:os"), 1);
|
|
2648
|
+
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
2685
2649
|
function peachsimPackageRoot() {
|
|
2686
2650
|
let dir = __sootsim_import_meta_dirname;
|
|
2687
|
-
while (!import_node_fs6.default.existsSync(
|
|
2688
|
-
dir =
|
|
2651
|
+
while (!import_node_fs6.default.existsSync(import_node_path4.default.join(dir, "package.json")) && dir !== import_node_path4.default.dirname(dir))
|
|
2652
|
+
dir = import_node_path4.default.dirname(dir);
|
|
2689
2653
|
return dir;
|
|
2690
2654
|
}
|
|
2691
2655
|
function sourceSwiftCheckout() {
|
|
2692
|
-
return
|
|
2656
|
+
return import_node_path4.default.resolve(peachsimPackageRoot(), "../sootsim-swift");
|
|
2693
2657
|
}
|
|
2694
2658
|
function swiftSdkOptions() {
|
|
2695
2659
|
const directory = process.env.PEACH_SWIFT_SDKS_PATH;
|
|
2696
|
-
if (directory) return ["--swift-sdks-path",
|
|
2660
|
+
if (directory) return ["--swift-sdks-path", import_node_path4.default.resolve(directory)];
|
|
2697
2661
|
if (scratch && process.platform === "linux") {
|
|
2698
2662
|
const config = process.env.XDG_CONFIG_HOME;
|
|
2699
|
-
if (config !== void 0 && !
|
|
2663
|
+
if (config !== void 0 && !import_node_path4.default.isAbsolute(config))
|
|
2700
2664
|
throw new Error("XDG_CONFIG_HOME must be an absolute path");
|
|
2701
2665
|
return [
|
|
2702
2666
|
"--swift-sdks-path",
|
|
2703
|
-
config === void 0 ?
|
|
2667
|
+
config === void 0 ? import_node_path4.default.join(import_node_os3.default.userInfo().homedir, ".swiftpm", "swift-sdks") : import_node_path4.default.join(config, "swiftpm", "swift-sdks")
|
|
2704
2668
|
];
|
|
2705
2669
|
}
|
|
2706
2670
|
return [];
|
|
@@ -2844,6 +2808,23 @@ var compilerArchives = {
|
|
|
2844
2808
|
}
|
|
2845
2809
|
}
|
|
2846
2810
|
},
|
|
2811
|
+
"swift-6.4.0-RELEASE-custom-a560ff35bf882b5c": {
|
|
2812
|
+
identity: "a560ff35bf882b5c",
|
|
2813
|
+
hosts: {
|
|
2814
|
+
"darwin-arm64": {
|
|
2815
|
+
checksum: "ec20a41851ac558fe663d78def6b93d0d47c5a0cb69688ee270fd85de637a522",
|
|
2816
|
+
manifest: "253e891527d2213f54eace768b902de89de5e9495a3c5f4018de1985516bd553"
|
|
2817
|
+
},
|
|
2818
|
+
"linux-x64": {
|
|
2819
|
+
checksum: "f0126a2e63d275895036d02d75a901070da0343dbf03bf17342e10cb6f893dee",
|
|
2820
|
+
manifest: "6f951cc4071dd0d6054d85711a7c5fe272273658847831b477a8b24be7254ca0"
|
|
2821
|
+
},
|
|
2822
|
+
"linux-arm64": {
|
|
2823
|
+
checksum: "315fa766559a6e69bfd10dcddf40e04c91155f0db3047d210d74ac87652fb7e6",
|
|
2824
|
+
manifest: "b6f62fca2ec37593e274ee5bac474f21ffc5db14cd82f492ccbc774f8e9b75d8"
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
},
|
|
2847
2828
|
[SWIFT_HOST_COMPILER_RELEASE]: {
|
|
2848
2829
|
identity: SWIFT_HOST_COMPILER_ID,
|
|
2849
2830
|
hosts: {
|
|
@@ -2865,13 +2846,13 @@ var compilerArchives = {
|
|
|
2865
2846
|
var SWIFT_PRIVATE_DISTRIBUTION_ENV = "PEACH_SWIFT_PRIVATE_DISTRIBUTION";
|
|
2866
2847
|
function privateSwiftDistributionRoot() {
|
|
2867
2848
|
const root = process.env[SWIFT_PRIVATE_DISTRIBUTION_ENV]?.trim();
|
|
2868
|
-
return root ?
|
|
2849
|
+
return root ? import_node_path4.default.resolve(root) : null;
|
|
2869
2850
|
}
|
|
2870
2851
|
function privateSwiftRelease() {
|
|
2871
2852
|
const root = privateSwiftDistributionRoot();
|
|
2872
2853
|
if (!root) return null;
|
|
2873
2854
|
const manifest = JSON.parse(
|
|
2874
|
-
import_node_fs6.default.readFileSync(
|
|
2855
|
+
import_node_fs6.default.readFileSync(import_node_path4.default.join(root, "distribution.json"), "utf8")
|
|
2875
2856
|
);
|
|
2876
2857
|
const release = manifest && typeof manifest === "object" && Reflect.get(manifest, "release");
|
|
2877
2858
|
if (typeof release !== "string")
|
|
@@ -2900,23 +2881,23 @@ function swiftCompilerRelease(release) {
|
|
|
2900
2881
|
}
|
|
2901
2882
|
function swiftToolchainBin(release) {
|
|
2902
2883
|
if (process.platform === "darwin") {
|
|
2903
|
-
const dirs = [
|
|
2904
|
-
(base) =>
|
|
2884
|
+
const dirs = [import_node_os3.default.homedir(), "/"].map(
|
|
2885
|
+
(base) => import_node_path4.default.join(base, `Library/Developer/Toolchains/${release}.xctoolchain/usr/bin`)
|
|
2905
2886
|
);
|
|
2906
|
-
return dirs.find((dir) => import_node_fs6.default.existsSync(
|
|
2887
|
+
return dirs.find((dir) => import_node_fs6.default.existsSync(import_node_path4.default.join(dir, "swift"))) ?? dirs[0];
|
|
2907
2888
|
}
|
|
2908
2889
|
if (process.env.CONTRAST_SWIFT_TOOLCHAINS) {
|
|
2909
|
-
return
|
|
2890
|
+
return import_node_path4.default.join(process.env.CONTRAST_SWIFT_TOOLCHAINS, release, "usr/bin");
|
|
2910
2891
|
}
|
|
2911
|
-
const image =
|
|
2912
|
-
if (import_node_fs6.default.existsSync(
|
|
2892
|
+
const image = import_node_path4.default.join("/opt/swift", release, "usr/bin");
|
|
2893
|
+
if (import_node_fs6.default.existsSync(import_node_path4.default.join(image, "swift"))) return image;
|
|
2913
2894
|
if (release.includes("-custom-"))
|
|
2914
|
-
return
|
|
2915
|
-
return (process.env.PATH ?? "").split(
|
|
2895
|
+
return import_node_path4.default.join(peachHome(), "swift", "toolchains", release, "usr/bin");
|
|
2896
|
+
return (process.env.PATH ?? "").split(import_node_path4.default.delimiter).find((dir) => dir && import_node_fs6.default.existsSync(import_node_path4.default.join(dir, "swift"))) ?? image;
|
|
2916
2897
|
}
|
|
2917
2898
|
var SWIFT_AUTOLINK_LINKER = ".peach-wasm-ld";
|
|
2918
2899
|
function writeSwiftAutolinkLinker(directory, toolchainBin) {
|
|
2919
|
-
const linker =
|
|
2900
|
+
const linker = import_node_path4.default.join(directory, SWIFT_AUTOLINK_LINKER);
|
|
2920
2901
|
const script = `#!/bin/sh
|
|
2921
2902
|
set -eu
|
|
2922
2903
|
for arg in "$@"; do
|
|
@@ -2926,7 +2907,7 @@ for arg in "$@"; do
|
|
|
2926
2907
|
awk 'BEGIN { RS = " "; ORS = " " } /^"-l/ { if (seen[$0]++) next } { print }' "$rsp" > "$rsp.dedup"
|
|
2927
2908
|
mv "$rsp.dedup" "$rsp"
|
|
2928
2909
|
if [ "\${PEACH_DEFER_WASM_LINK:-}" = "1" ] && grep -q '"--start-lib"' "$rsp"; then
|
|
2929
|
-
cp "$rsp" ${JSON.stringify(
|
|
2910
|
+
cp "$rsp" ${JSON.stringify(import_node_path4.default.join(directory, ".peach-link.rsp"))}
|
|
2930
2911
|
out=$(awk 'BEGIN { RS = " " } prev == "\\"'-o'\\"" { gsub(/^"|"[[:space:]]*$/, ""); print; exit } { prev = $0 }' "$rsp")
|
|
2931
2912
|
if [ -n "$out" ]; then
|
|
2932
2913
|
printf '\\000asm\\001\\000\\000\\000' > "$out"
|
|
@@ -2936,7 +2917,7 @@ for arg in "$@"; do
|
|
|
2936
2917
|
;;
|
|
2937
2918
|
esac
|
|
2938
2919
|
done
|
|
2939
|
-
exec ${JSON.stringify(
|
|
2920
|
+
exec ${JSON.stringify(import_node_path4.default.join(toolchainBin, "wasm-ld"))} "$@"
|
|
2940
2921
|
`;
|
|
2941
2922
|
if (import_node_fs6.default.existsSync(linker) && import_node_fs6.default.readFileSync(linker, "utf8") === script) return linker;
|
|
2942
2923
|
import_node_fs6.default.mkdirSync(directory, { recursive: true });
|
|
@@ -2947,7 +2928,26 @@ exec ${JSON.stringify(import_node_path5.default.join(toolchainBin, "wasm-ld"))}
|
|
|
2947
2928
|
}
|
|
2948
2929
|
function peachHome() {
|
|
2949
2930
|
const override = process.env.PEACH_HOME;
|
|
2950
|
-
return override ?
|
|
2931
|
+
return override ? import_node_path4.default.resolve(override) : import_node_path4.default.join(import_node_os3.default.homedir(), ".peach");
|
|
2932
|
+
}
|
|
2933
|
+
var BUILDERS_ROOT_ENV = "CONTRAST_BUILDERS_ROOT";
|
|
2934
|
+
function buildersRootEnv() {
|
|
2935
|
+
const root = process.env[BUILDERS_ROOT_ENV]?.trim();
|
|
2936
|
+
return root ? root : null;
|
|
2937
|
+
}
|
|
2938
|
+
function swiftCacheDir() {
|
|
2939
|
+
const root = buildersRootEnv();
|
|
2940
|
+
return root ? import_node_path4.default.join(root, "peach-cache") : import_node_path4.default.join(peachHome(), "cache");
|
|
2941
|
+
}
|
|
2942
|
+
function swiftPackageCacheOptions() {
|
|
2943
|
+
const root = import_node_path4.default.join(swiftCacheDir(), "swiftpm");
|
|
2944
|
+
return [
|
|
2945
|
+
...["cache", "config", "security"].flatMap((name2) => [
|
|
2946
|
+
`--${name2}-path`,
|
|
2947
|
+
import_node_path4.default.join(root, name2)
|
|
2948
|
+
]),
|
|
2949
|
+
"--disable-keychain"
|
|
2950
|
+
];
|
|
2951
2951
|
}
|
|
2952
2952
|
var scratch;
|
|
2953
2953
|
var linuxLibraryPath;
|
|
@@ -2961,16 +2961,16 @@ function swiftEnvironment(base = process.env) {
|
|
|
2961
2961
|
} : {},
|
|
2962
2962
|
...scratch ? {
|
|
2963
2963
|
TMPDIR: scratch.directory,
|
|
2964
|
-
XDG_CONFIG_HOME:
|
|
2965
|
-
XDG_CACHE_HOME:
|
|
2966
|
-
XDG_DATA_HOME:
|
|
2964
|
+
XDG_CONFIG_HOME: import_node_path4.default.join(scratch.home, ".config"),
|
|
2965
|
+
XDG_CACHE_HOME: import_node_path4.default.join(scratch.home, ".cache"),
|
|
2966
|
+
XDG_DATA_HOME: import_node_path4.default.join(scratch.home, ".local", "share"),
|
|
2967
2967
|
...process.platform === "linux" ? { HOME: scratch.home } : {}
|
|
2968
2968
|
} : {}
|
|
2969
2969
|
};
|
|
2970
2970
|
}
|
|
2971
2971
|
function swiftSourceSdk(root) {
|
|
2972
2972
|
const pin = JSON.parse(
|
|
2973
|
-
import_node_fs6.default.readFileSync(
|
|
2973
|
+
import_node_fs6.default.readFileSync(import_node_path4.default.join(root, "toolchain.json"), "utf8")
|
|
2974
2974
|
);
|
|
2975
2975
|
if (!pin || typeof pin !== "object" || typeof Reflect.get(pin, "wasmSdkId") !== "string" || typeof Reflect.get(pin, "wasmSdkUrl") !== "string" || typeof Reflect.get(pin, "wasmSdkChecksum") !== "string")
|
|
2976
2976
|
throw new Error(`${root} pins no wasm SDK id, url and checksum`);
|
|
@@ -2992,7 +2992,7 @@ function swiftToolchain(release, sdk) {
|
|
|
2992
2992
|
${swiftInstallSteps(release, sdk)}`
|
|
2993
2993
|
);
|
|
2994
2994
|
}
|
|
2995
|
-
const swift =
|
|
2995
|
+
const swift = import_node_path4.default.join(bin, "swift");
|
|
2996
2996
|
const sdks = (0, import_node_child_process4.execFileSync)(swift, ["sdk", "list", ...swiftSdkOptions()], {
|
|
2997
2997
|
encoding: "utf8",
|
|
2998
2998
|
env: swiftEnvironment(),
|
|
@@ -3024,11 +3024,11 @@ function swiftSdkBundle(swift, id, options) {
|
|
|
3024
3024
|
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
3025
3025
|
);
|
|
3026
3026
|
const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim();
|
|
3027
|
-
if (!sysroot || !
|
|
3027
|
+
if (!sysroot || !import_node_path4.default.isAbsolute(sysroot))
|
|
3028
3028
|
throw new Error(`Swift SDK ${id} reports no absolute sdkRootPath`);
|
|
3029
3029
|
let bundle = sysroot;
|
|
3030
3030
|
while (!bundle.endsWith(".artifactbundle")) {
|
|
3031
|
-
const parent =
|
|
3031
|
+
const parent = import_node_path4.default.dirname(bundle);
|
|
3032
3032
|
if (parent === bundle)
|
|
3033
3033
|
throw new Error(`Swift SDK ${id} is outside an artifact bundle`);
|
|
3034
3034
|
bundle = parent;
|
|
@@ -3039,16 +3039,16 @@ var sdkFileHashes = /* @__PURE__ */ new Map();
|
|
|
3039
3039
|
function swiftSdkPayloadChecksum(bundle) {
|
|
3040
3040
|
const hash = (0, import_node_crypto2.createHash)("sha256");
|
|
3041
3041
|
function visit(relative) {
|
|
3042
|
-
const file =
|
|
3042
|
+
const file = import_node_path4.default.join(bundle, relative);
|
|
3043
3043
|
const stat = import_node_fs6.default.lstatSync(file, { bigint: true });
|
|
3044
3044
|
if (stat.isSymbolicLink()) {
|
|
3045
|
-
const resolved =
|
|
3046
|
-
if (resolved === ".." || resolved.startsWith(`..${
|
|
3045
|
+
const resolved = import_node_path4.default.relative(bundle, import_node_fs6.default.realpathSync(file));
|
|
3046
|
+
if (resolved === ".." || resolved.startsWith(`..${import_node_path4.default.sep}`) || import_node_path4.default.isAbsolute(resolved))
|
|
3047
3047
|
throw new Error(`Swift SDK symlink escapes its bundle: ${relative}`);
|
|
3048
3048
|
hash.update(JSON.stringify([relative, "link", import_node_fs6.default.readlinkSync(file)]) + "\n");
|
|
3049
3049
|
} else if (stat.isDirectory()) {
|
|
3050
3050
|
hash.update(JSON.stringify([relative, "directory"]) + "\n");
|
|
3051
|
-
for (const name2 of import_node_fs6.default.readdirSync(file).sort()) visit(
|
|
3051
|
+
for (const name2 of import_node_fs6.default.readdirSync(file).sort()) visit(import_node_path4.default.join(relative, name2));
|
|
3052
3052
|
} else if (stat.isFile()) {
|
|
3053
3053
|
const stamp = [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(":");
|
|
3054
3054
|
let cached = sdkFileHashes.get(file);
|
|
@@ -3065,8 +3065,8 @@ function swiftSdkPayloadChecksum(bundle) {
|
|
|
3065
3065
|
return hash.digest("hex");
|
|
3066
3066
|
}
|
|
3067
3067
|
function swiftSdkVerificationFile(bundle, sdk) {
|
|
3068
|
-
return
|
|
3069
|
-
|
|
3068
|
+
return import_node_path4.default.join(
|
|
3069
|
+
import_node_path4.default.dirname(bundle),
|
|
3070
3070
|
".peach-sdk-checksums",
|
|
3071
3071
|
`${sdk.wasmSdkId}-${sdk.wasmSdkChecksum}.json`
|
|
3072
3072
|
);
|
|
@@ -3100,7 +3100,7 @@ function swiftFileChecksum(file) {
|
|
|
3100
3100
|
return hash.digest("hex");
|
|
3101
3101
|
}
|
|
3102
3102
|
function swiftHostCompilerFiles(release, root) {
|
|
3103
|
-
const file =
|
|
3103
|
+
const file = import_node_path4.default.join(root, "compiler.json");
|
|
3104
3104
|
const pin = release === privateSwiftRelease() ? {
|
|
3105
3105
|
identity: release.replace(/^.*-custom-/, ""),
|
|
3106
3106
|
manifest: swiftFileChecksum(file)
|
|
@@ -3121,7 +3121,7 @@ function swiftHostCompilerFiles(release, root) {
|
|
|
3121
3121
|
}
|
|
3122
3122
|
function verifySwiftHostCompiler(release, root) {
|
|
3123
3123
|
for (const [relative, checksum] of swiftHostCompilerFiles(release, root)) {
|
|
3124
|
-
if (swiftFileChecksum(
|
|
3124
|
+
if (swiftFileChecksum(import_node_path4.default.join(root, relative)) !== checksum)
|
|
3125
3125
|
throw new Error(`Swift compiler binary mismatch: ${relative}`);
|
|
3126
3126
|
}
|
|
3127
3127
|
}
|
|
@@ -3131,8 +3131,8 @@ function swiftCompiler(release) {
|
|
|
3131
3131
|
if (cached) return cached;
|
|
3132
3132
|
const bin = swiftToolchainBin(release);
|
|
3133
3133
|
if (release.includes("-custom-"))
|
|
3134
|
-
verifySwiftHostCompiler(release,
|
|
3135
|
-
const version = (0, import_node_child_process4.execFileSync)(
|
|
3134
|
+
verifySwiftHostCompiler(release, import_node_path4.default.resolve(bin, "../.."));
|
|
3135
|
+
const version = (0, import_node_child_process4.execFileSync)(import_node_path4.default.join(bin, "swift"), ["--version"], {
|
|
3136
3136
|
encoding: "utf8",
|
|
3137
3137
|
env: swiftEnvironment(),
|
|
3138
3138
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -3150,7 +3150,7 @@ function swiftSdkInstallCommand(release, wasmSdk) {
|
|
|
3150
3150
|
const { wasmSdkId, wasmSdkUrl, wasmSdkChecksum } = wasmSdk;
|
|
3151
3151
|
const program = `import { installSwiftWasmSdk } from "peachsim/swift-toolchain"; installSwiftWasmSdk(${JSON.stringify(release)}, ${JSON.stringify({ wasmSdkId, wasmSdkUrl, wasmSdkChecksum })})`;
|
|
3152
3152
|
const directory = process.env.PEACH_SWIFT_SDKS_PATH;
|
|
3153
|
-
const environment = directory ? `PEACH_SWIFT_SDKS_PATH='${
|
|
3153
|
+
const environment = directory ? `PEACH_SWIFT_SDKS_PATH='${import_node_path4.default.resolve(directory).replaceAll("'", "'\\''")}' ` : "";
|
|
3154
3154
|
return `${environment}node --input-type=module -e '${program.replaceAll("'", "'\\''")}'`;
|
|
3155
3155
|
}
|
|
3156
3156
|
function swiftInstallSteps(release, wasmSdk) {
|
|
@@ -3165,7 +3165,7 @@ function swiftCompilerInstall(release) {
|
|
|
3165
3165
|
return { note: " (private: its builder installs it)", commands: [] };
|
|
3166
3166
|
if (release.includes("-custom-")) {
|
|
3167
3167
|
const archive = swiftHostCompilerArchive(release);
|
|
3168
|
-
const directory =
|
|
3168
|
+
const directory = import_node_path4.default.resolve(swiftToolchainBin(release), "../..");
|
|
3169
3169
|
return {
|
|
3170
3170
|
note: "",
|
|
3171
3171
|
commands: [
|
|
@@ -3210,7 +3210,7 @@ function swiftObjCPlatformFlags(toolchainBin, minimum) {
|
|
|
3210
3210
|
minimum % 100
|
|
3211
3211
|
].join(".");
|
|
3212
3212
|
const result = (0, import_node_child_process5.spawnSync)(
|
|
3213
|
-
|
|
3213
|
+
import_node_path5.default.join(toolchainBin, "clang"),
|
|
3214
3214
|
[
|
|
3215
3215
|
"-target",
|
|
3216
3216
|
`arm64-apple-ios${version}-simulator`,
|
|
@@ -3253,13 +3253,18 @@ var swiftObjCRuntimeFlags = [
|
|
|
3253
3253
|
|
|
3254
3254
|
// src/swift-objc-standin.ts
|
|
3255
3255
|
var import_node_crypto3 = require("node:crypto");
|
|
3256
|
-
var
|
|
3256
|
+
var import_node_path7 = __toESM(require("node:path"), 1);
|
|
3257
|
+
|
|
3258
|
+
// src/is-record.ts
|
|
3259
|
+
function isRecord(value) {
|
|
3260
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3261
|
+
}
|
|
3257
3262
|
|
|
3258
3263
|
// src/swift-objc-sdk.ts
|
|
3259
|
-
var
|
|
3264
|
+
var import_node_path6 = __toESM(require("node:path"), 1);
|
|
3260
3265
|
var IOS_SDK_TARGET = "arm64-apple-ios16.0-simulator";
|
|
3261
3266
|
var OVERLAY_PATH = /^usr\/lib\/swift\/([^/]+)\.swiftmodule\/arm64-apple-ios-simulator\.swiftinterface$/;
|
|
3262
|
-
var tree = typeof __PEACH_BUNDLED_IOS_SDK__ === "undefined" ? readIosSdkTree(
|
|
3267
|
+
var tree = typeof __PEACH_BUNDLED_IOS_SDK__ === "undefined" ? readIosSdkTree(import_node_path6.default.join(peachsimPackageRoot(), "sdk", "ios")) : Object.entries(__PEACH_BUNDLED_IOS_SDK__).sort(([a], [b]) => a < b ? -1 : 1);
|
|
3263
3268
|
var IOS_SDK_HEADERS = {};
|
|
3264
3269
|
var IOS_SDK_OVERLAYS = {};
|
|
3265
3270
|
for (const [file, text2] of tree) {
|
|
@@ -3409,10 +3414,14 @@ var SWIFT_NATIVE_SOURCE_EXTENSIONS = [
|
|
|
3409
3414
|
".def",
|
|
3410
3415
|
".modulemap"
|
|
3411
3416
|
];
|
|
3412
|
-
function clangImportNames(text2) {
|
|
3417
|
+
function clangImportNames(text2, isLocalHeader) {
|
|
3413
3418
|
return [
|
|
3414
|
-
...text2.matchAll(
|
|
3415
|
-
|
|
3419
|
+
...text2.matchAll(
|
|
3420
|
+
/^\s*(?:#\s*(?:import|include)\s*<((\w+)\/[^>]+)>|@import\s+(\w+))/gm
|
|
3421
|
+
)
|
|
3422
|
+
].flatMap(
|
|
3423
|
+
(match) => match[1] && isLocalHeader?.(match[1]) ? [] : [match[2] ?? match[3]]
|
|
3424
|
+
);
|
|
3416
3425
|
}
|
|
3417
3426
|
function moduleMapTokens(text2) {
|
|
3418
3427
|
return (text2.match(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|"[^"]*"|[\w.*]+|[{}\[\]]/g) ?? []).filter((token) => !token.startsWith("/"));
|
|
@@ -3435,9 +3444,13 @@ ${declaration}
|
|
|
3435
3444
|
export *
|
|
3436
3445
|
}`;
|
|
3437
3446
|
}
|
|
3447
|
+
var fmtConstantInterpreterFlags = (flags) => flags.some((flag) => flag.includes("/fmt/")) ? ["-fexperimental-new-constant-interpreter"] : [];
|
|
3448
|
+
var withoutGlogModuleMap = (flags) => flags.filter(
|
|
3449
|
+
(flag) => !(flag.startsWith("-fmodule-map-file=") && flag.endsWith("/glog.modulemap"))
|
|
3450
|
+
);
|
|
3438
3451
|
function clangSettingEntries(settings, tool) {
|
|
3439
3452
|
return (settings ?? []).flatMap(
|
|
3440
|
-
(setting) => setting.tool !== tool ? [] : "headerSearchPath" in setting ? [`.headerSearchPath(${JSON.stringify(setting.headerSearchPath)})`] : [`.unsafeFlags(${JSON.stringify(setting.flags)})`]
|
|
3453
|
+
(setting) => setting.tool !== tool ? [] : "headerSearchPath" in setting ? [`.headerSearchPath(${JSON.stringify(setting.headerSearchPath)})`] : [`.unsafeFlags(${JSON.stringify(withoutGlogModuleMap(setting.flags))})`]
|
|
3441
3454
|
);
|
|
3442
3455
|
}
|
|
3443
3456
|
function clangMacroSetting(macro) {
|
|
@@ -3806,9 +3819,12 @@ var IOS_SDK_ID = (0, import_node_crypto3.createHash)("sha256").update(JSON.strin
|
|
|
3806
3819
|
function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
|
|
3807
3820
|
return [
|
|
3808
3821
|
...swiftObjCPlatformFlags(toolchainBin, minimum),
|
|
3809
|
-
// AvailabilityInternal.h derives
|
|
3810
|
-
// is false for wasm32.
|
|
3822
|
+
// AvailabilityInternal.h derives these through __is_target_os(ios), which
|
|
3823
|
+
// is false for wasm32. the maximum is the sdk the headers come from, as
|
|
3824
|
+
// xcode defines it, so `#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_26_0`
|
|
3825
|
+
// sources see the members the sdk declares instead of a 17.0 default.
|
|
3811
3826
|
`-D__IPHONE_OS_VERSION_MIN_REQUIRED=${minimum}`,
|
|
3827
|
+
`-D__IPHONE_OS_VERSION_MAX_ALLOWED=__IPHONE_${NATIVE_GRAPH_SDK_VERSION.replace(".", "_")}`,
|
|
3812
3828
|
// apple's build setting for a 32-bit target to keep NSInteger and
|
|
3813
3829
|
// NSUInteger long, the nominal types they have on arm64.
|
|
3814
3830
|
"-DNS_BUILD_32_LIKE_64=1",
|
|
@@ -3824,15 +3840,15 @@ function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
|
|
|
3824
3840
|
"-fblocks",
|
|
3825
3841
|
...WASI_EMULATION_FLAGS,
|
|
3826
3842
|
"-iframework",
|
|
3827
|
-
|
|
3843
|
+
import_node_path7.default.join(headers, "System/Library/Frameworks"),
|
|
3828
3844
|
"-isystem",
|
|
3829
|
-
|
|
3845
|
+
import_node_path7.default.join(headers, "wasm/include"),
|
|
3830
3846
|
// libxml2 headers sit one level deeper, as in the iOS sdk: a unit
|
|
3831
3847
|
// includes <libxml/parser.h> through usr/include/libxml2, never the parent.
|
|
3832
3848
|
"-I",
|
|
3833
|
-
|
|
3849
|
+
import_node_path7.default.join(headers, "usr/include/libxml2"),
|
|
3834
3850
|
"-idirafter",
|
|
3835
|
-
|
|
3851
|
+
import_node_path7.default.join(headers, "usr/include")
|
|
3836
3852
|
];
|
|
3837
3853
|
}
|
|
3838
3854
|
function iosDeploymentMinimum(version) {
|
|
@@ -3845,26 +3861,26 @@ function iosDeploymentMinimum(version) {
|
|
|
3845
3861
|
var import_node_child_process6 = require("node:child_process");
|
|
3846
3862
|
var import_node_crypto4 = require("node:crypto");
|
|
3847
3863
|
var import_node_fs7 = __toESM(require("node:fs"), 1);
|
|
3848
|
-
var
|
|
3864
|
+
var import_node_path8 = __toESM(require("node:path"), 1);
|
|
3849
3865
|
var distributionHeaderRoots = /* @__PURE__ */ new Map();
|
|
3850
3866
|
function swiftSharedSdkRoot(moduleRoot, distribution) {
|
|
3851
|
-
const root =
|
|
3867
|
+
const root = import_node_path8.default.resolve(moduleRoot, distribution ? "sdk/ios" : "../peachsim/sdk/ios");
|
|
3852
3868
|
if (!distribution) return root;
|
|
3853
3869
|
let headers = distributionHeaderRoots.get(root);
|
|
3854
3870
|
if (!headers || !import_node_fs7.default.existsSync(headers)) {
|
|
3855
|
-
const files = (0, import_node_fs7.readdirSync)(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) =>
|
|
3871
|
+
const files = (0, import_node_fs7.readdirSync)(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => import_node_path8.default.relative(root, import_node_path8.default.join(entry.parentPath, entry.name))).sort();
|
|
3856
3872
|
const hash = (0, import_node_crypto4.createHash)("sha256");
|
|
3857
3873
|
for (const file of files) {
|
|
3858
|
-
const bytes = (0, import_node_fs7.readFileSync)(
|
|
3874
|
+
const bytes = (0, import_node_fs7.readFileSync)(import_node_path8.default.join(root, file));
|
|
3859
3875
|
hash.update(JSON.stringify([file, bytes.length])).update(bytes);
|
|
3860
3876
|
}
|
|
3861
|
-
headers =
|
|
3877
|
+
headers = import_node_path8.default.join(
|
|
3862
3878
|
swiftCacheDir(),
|
|
3863
3879
|
"swift-sdk-views",
|
|
3864
3880
|
`headers-${hash.digest("hex")}`
|
|
3865
3881
|
);
|
|
3866
3882
|
if (!import_node_fs7.default.existsSync(headers)) {
|
|
3867
|
-
import_node_fs7.default.mkdirSync(
|
|
3883
|
+
import_node_fs7.default.mkdirSync(import_node_path8.default.dirname(headers), { recursive: true });
|
|
3868
3884
|
const staging = import_node_fs7.default.mkdtempSync(`${headers}-`);
|
|
3869
3885
|
import_node_fs7.default.cpSync(root, staging, { recursive: true, preserveTimestamps: true });
|
|
3870
3886
|
try {
|
|
@@ -3884,9 +3900,9 @@ function swiftSharedSdkFlags(moduleRoot, distribution) {
|
|
|
3884
3900
|
const root = swiftSharedSdkRoot(moduleRoot, distribution);
|
|
3885
3901
|
return [
|
|
3886
3902
|
"-isystem",
|
|
3887
|
-
|
|
3903
|
+
import_node_path8.default.join(root, "wasm/storage-include"),
|
|
3888
3904
|
"-idirafter",
|
|
3889
|
-
|
|
3905
|
+
import_node_path8.default.join(root, "usr/include")
|
|
3890
3906
|
];
|
|
3891
3907
|
}
|
|
3892
3908
|
function readULEB(b, o) {
|
|
@@ -4011,8 +4027,8 @@ function weakenBundleInArchive(arBuf) {
|
|
|
4011
4027
|
function mirrorTree(real, mirror, overrides) {
|
|
4012
4028
|
import_node_fs7.default.mkdirSync(mirror);
|
|
4013
4029
|
for (const entry of import_node_fs7.default.readdirSync(real, { withFileTypes: true })) {
|
|
4014
|
-
const from =
|
|
4015
|
-
const to =
|
|
4030
|
+
const from = import_node_path8.default.join(real, entry.name);
|
|
4031
|
+
const to = import_node_path8.default.join(mirror, entry.name);
|
|
4016
4032
|
const override = overrides.get(from);
|
|
4017
4033
|
if (override) import_node_fs7.default.symlinkSync(override, to);
|
|
4018
4034
|
else if (import_node_fs7.default.statSync(from).isDirectory()) mirrorTree(from, to, overrides);
|
|
@@ -4020,20 +4036,20 @@ function mirrorTree(real, mirror, overrides) {
|
|
|
4020
4036
|
}
|
|
4021
4037
|
}
|
|
4022
4038
|
function stageOverlaySlot(realRoot, stagingRoot, relPath) {
|
|
4023
|
-
const segments = relPath.split(
|
|
4039
|
+
const segments = relPath.split(import_node_path8.default.sep);
|
|
4024
4040
|
let real = realRoot;
|
|
4025
4041
|
let mirror = stagingRoot;
|
|
4026
4042
|
for (let i = 0; i < segments.length; i++) {
|
|
4027
4043
|
const segment = segments[i];
|
|
4028
4044
|
for (const entry of (0, import_node_fs7.readdirSync)(real)) {
|
|
4029
4045
|
if (entry === segment) continue;
|
|
4030
|
-
const dest =
|
|
4046
|
+
const dest = import_node_path8.default.join(mirror, entry);
|
|
4031
4047
|
if (!import_node_fs7.default.lstatSync(dest, { throwIfNoEntry: false })) {
|
|
4032
|
-
import_node_fs7.default.symlinkSync(
|
|
4048
|
+
import_node_fs7.default.symlinkSync(import_node_path8.default.join(real, entry), dest);
|
|
4033
4049
|
}
|
|
4034
4050
|
}
|
|
4035
|
-
real =
|
|
4036
|
-
mirror =
|
|
4051
|
+
real = import_node_path8.default.join(real, segment);
|
|
4052
|
+
mirror = import_node_path8.default.join(mirror, segment);
|
|
4037
4053
|
if (i < segments.length - 1) {
|
|
4038
4054
|
if (import_node_fs7.default.lstatSync(mirror, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
4039
4055
|
import_node_fs7.default.unlinkSync(mirror);
|
|
@@ -4048,14 +4064,14 @@ function stageOverlaySlot(realRoot, stagingRoot, relPath) {
|
|
|
4048
4064
|
}
|
|
4049
4065
|
var sdkViews = /* @__PURE__ */ new Map();
|
|
4050
4066
|
function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk) {
|
|
4051
|
-
const frameworks =
|
|
4067
|
+
const frameworks = import_node_path8.default.join(
|
|
4052
4068
|
swiftSharedSdkRoot(moduleRoot, distribution),
|
|
4053
4069
|
"System/Library/Frameworks"
|
|
4054
4070
|
);
|
|
4055
|
-
const overlay =
|
|
4056
|
-
const overlayFiles = (0, import_node_fs7.readdirSync)(overlay, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) =>
|
|
4071
|
+
const overlay = import_node_path8.default.join(swiftSharedSdkRoot(moduleRoot, distribution), "wasm/include");
|
|
4072
|
+
const overlayFiles = (0, import_node_fs7.readdirSync)(overlay, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => import_node_path8.default.join(entry.parentPath, entry.name)).sort();
|
|
4057
4073
|
const key = JSON.stringify([
|
|
4058
|
-
"
|
|
4074
|
+
"v11",
|
|
4059
4075
|
toolchainBin,
|
|
4060
4076
|
sdk,
|
|
4061
4077
|
frameworks,
|
|
@@ -4065,7 +4081,7 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
|
|
|
4065
4081
|
const cached = sdkViews.get(key);
|
|
4066
4082
|
if (cached && import_node_fs7.default.existsSync(cached.manifest)) return touchSdkView(cached.options);
|
|
4067
4083
|
const configuration = (0, import_node_child_process6.execFileSync)(
|
|
4068
|
-
|
|
4084
|
+
import_node_path8.default.join(toolchainBin, "swift"),
|
|
4069
4085
|
[
|
|
4070
4086
|
"sdk",
|
|
4071
4087
|
"configure",
|
|
@@ -4077,57 +4093,57 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
|
|
|
4077
4093
|
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
4078
4094
|
);
|
|
4079
4095
|
const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim();
|
|
4080
|
-
if (!sysroot || !
|
|
4096
|
+
if (!sysroot || !import_node_path8.default.isAbsolute(sysroot))
|
|
4081
4097
|
throw new Error(`swift sdk ${sdk} reports no absolute sdkRootPath`);
|
|
4082
4098
|
let bundle = sysroot;
|
|
4083
4099
|
while (!bundle.endsWith(".artifactbundle")) {
|
|
4084
|
-
if (
|
|
4100
|
+
if (import_node_path8.default.dirname(bundle) === bundle)
|
|
4085
4101
|
throw new Error(`swift sdk ${sdk} is outside an artifact bundle`);
|
|
4086
|
-
bundle =
|
|
4102
|
+
bundle = import_node_path8.default.dirname(bundle);
|
|
4087
4103
|
}
|
|
4088
|
-
const view =
|
|
4104
|
+
const view = import_node_path8.default.join(
|
|
4089
4105
|
swiftCacheDir(),
|
|
4090
4106
|
"swift-sdk-views",
|
|
4091
4107
|
(0, import_node_crypto4.createHash)("sha256").update(key).digest("hex").slice(0, 16)
|
|
4092
4108
|
);
|
|
4093
|
-
const manifest =
|
|
4109
|
+
const manifest = import_node_path8.default.join(view, import_node_path8.default.basename(bundle), "info.json");
|
|
4094
4110
|
if (!import_node_fs7.default.existsSync(manifest)) {
|
|
4095
|
-
import_node_fs7.default.mkdirSync(
|
|
4111
|
+
import_node_fs7.default.mkdirSync(import_node_path8.default.dirname(view), { recursive: true });
|
|
4096
4112
|
const staging = import_node_fs7.default.mkdtempSync(`${view}-`);
|
|
4097
|
-
const realRoot =
|
|
4098
|
-
const overrides =
|
|
4099
|
-
[
|
|
4100
|
-
[
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
]
|
|
4113
|
+
const realRoot = import_node_path8.default.dirname(bundle);
|
|
4114
|
+
const overrides = new Map([
|
|
4115
|
+
[import_node_path8.default.join(sysroot, "darwin/System/Library/Frameworks"), frameworks],
|
|
4116
|
+
...["MacTypes.h", "net/if.h"].map((header) => [
|
|
4117
|
+
import_node_path8.default.join(sysroot, "darwin/usr/include", header),
|
|
4118
|
+
import_node_path8.default.join(swiftSharedSdkRoot(moduleRoot, distribution), "usr/include", header)
|
|
4119
|
+
])
|
|
4104
4120
|
]);
|
|
4105
4121
|
for (const file of overlayFiles) {
|
|
4106
4122
|
overrides.set(
|
|
4107
|
-
|
|
4123
|
+
import_node_path8.default.join(sysroot, "darwin/wasm/include", import_node_path8.default.relative(overlay, file)),
|
|
4108
4124
|
file
|
|
4109
4125
|
);
|
|
4110
4126
|
}
|
|
4111
4127
|
mirrorTree(
|
|
4112
4128
|
sysroot,
|
|
4113
|
-
stageOverlaySlot(realRoot, staging,
|
|
4129
|
+
stageOverlaySlot(realRoot, staging, import_node_path8.default.relative(realRoot, sysroot)),
|
|
4114
4130
|
overrides
|
|
4115
4131
|
);
|
|
4116
4132
|
for (const [file, shared] of overrides) {
|
|
4117
|
-
const destination =
|
|
4133
|
+
const destination = import_node_path8.default.join(staging, import_node_path8.default.relative(realRoot, file));
|
|
4118
4134
|
if (import_node_fs7.default.lstatSync(destination, { throwIfNoEntry: false })) continue;
|
|
4119
|
-
import_node_fs7.default.mkdirSync(
|
|
4135
|
+
import_node_fs7.default.mkdirSync(import_node_path8.default.dirname(destination), { recursive: true });
|
|
4120
4136
|
import_node_fs7.default.symlinkSync(shared, destination);
|
|
4121
4137
|
}
|
|
4122
|
-
const foundationArchive =
|
|
4123
|
-
|
|
4138
|
+
const foundationArchive = import_node_path8.default.join(
|
|
4139
|
+
import_node_path8.default.dirname(sysroot),
|
|
4124
4140
|
"swift.xctoolchain/usr/lib/swift_static/wasi/libFoundation.a"
|
|
4125
4141
|
);
|
|
4126
4142
|
if (import_node_fs7.default.existsSync(foundationArchive)) {
|
|
4127
4143
|
const foundationSlot = stageOverlaySlot(
|
|
4128
4144
|
realRoot,
|
|
4129
4145
|
staging,
|
|
4130
|
-
|
|
4146
|
+
import_node_path8.default.relative(realRoot, foundationArchive)
|
|
4131
4147
|
);
|
|
4132
4148
|
const arBuf = new Uint8Array(import_node_fs7.default.readFileSync(foundationArchive));
|
|
4133
4149
|
weakenBundleInArchive(arBuf);
|
|
@@ -4151,23 +4167,23 @@ function touchSdkView(options) {
|
|
|
4151
4167
|
}
|
|
4152
4168
|
function swiftSharedSdkInputFiles(moduleRoot) {
|
|
4153
4169
|
const root = swiftSharedSdkRoot(moduleRoot, false);
|
|
4154
|
-
return (0, import_node_fs7.readdirSync)(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) =>
|
|
4170
|
+
return (0, import_node_fs7.readdirSync)(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => import_node_path8.default.relative(moduleRoot, import_node_path8.default.join(entry.parentPath, entry.name))).sort();
|
|
4155
4171
|
}
|
|
4156
4172
|
|
|
4157
4173
|
// src/swift-darwin-records.ts
|
|
4158
4174
|
var DARWIN_RECORDS_PREFIX = "DarwinRecords-";
|
|
4159
4175
|
var darwinRecordsMinimum = () => iosDeploymentMinimum(NATIVE_GRAPH_SDK_VERSION) ?? 0;
|
|
4160
4176
|
function compileDarwinRecords(args) {
|
|
4161
|
-
const records =
|
|
4162
|
-
const runtime = (0, import_node_fs8.mkdtempSync)(
|
|
4163
|
-
(0, import_node_fs8.symlinkSync)(
|
|
4177
|
+
const records = import_node_path9.default.join(args.packageRoot, "Sources/DarwinRecords");
|
|
4178
|
+
const runtime = (0, import_node_fs8.mkdtempSync)(import_node_path9.default.join((0, import_node_os4.tmpdir)(), "peach-objc-runtime-"));
|
|
4179
|
+
(0, import_node_fs8.symlinkSync)(import_node_path9.default.join(args.darwin, "usr/include/objc"), import_node_path9.default.join(runtime, "objc"));
|
|
4164
4180
|
const objects = (0, import_node_fs8.readdirSync)(records).filter((file) => file.endsWith(".c") || file.endsWith(".m")).sort((a, b) => a < b ? -1 : a > b ? 1 : 0).map((file) => {
|
|
4165
|
-
const object =
|
|
4181
|
+
const object = import_node_path9.default.join(
|
|
4166
4182
|
args.out,
|
|
4167
4183
|
`${DARWIN_RECORDS_PREFIX}${file.replace(/\.[cm]$/, ".o")}`
|
|
4168
4184
|
);
|
|
4169
4185
|
(0, import_node_child_process7.execFileSync)(
|
|
4170
|
-
|
|
4186
|
+
import_node_path9.default.join(args.bin, "clang"),
|
|
4171
4187
|
[
|
|
4172
4188
|
"--target=wasm32-unknown-wasip1",
|
|
4173
4189
|
`--sysroot=${args.sysroot}`,
|
|
@@ -4177,7 +4193,7 @@ function compileDarwinRecords(args) {
|
|
|
4177
4193
|
// __BLOCKS__, as ios builds libmalloc
|
|
4178
4194
|
...file.endsWith(".m") ? [...swiftObjCRuntimeFlags, "-fwasm-exceptions"] : ["-fblocks"],
|
|
4179
4195
|
// assert() keeps __FILE__, which would carry the builder's checkout
|
|
4180
|
-
`-ffile-prefix-map=${records}${
|
|
4196
|
+
`-ffile-prefix-map=${records}${import_node_path9.default.sep}=DarwinRecords/`,
|
|
4181
4197
|
// apple's headers select on the ios identity original units compile
|
|
4182
4198
|
// with, and TargetConditionals.h refuses a compiler without it
|
|
4183
4199
|
...file.endsWith(".m") ? objcSdkIntakeFlags(args.darwin, args.bin, args.minimum) : [
|
|
@@ -4190,7 +4206,7 @@ function compileDarwinRecords(args) {
|
|
|
4190
4206
|
...swiftSharedSdkFlags(args.packageRoot, false)
|
|
4191
4207
|
],
|
|
4192
4208
|
"-c",
|
|
4193
|
-
|
|
4209
|
+
import_node_path9.default.join(records, file),
|
|
4194
4210
|
"-o",
|
|
4195
4211
|
object
|
|
4196
4212
|
],
|
|
@@ -4426,7 +4442,18 @@ function designTimeSites(source) {
|
|
|
4426
4442
|
while (t < to && tokens[t].kind !== "newline") t++;
|
|
4427
4443
|
continue;
|
|
4428
4444
|
}
|
|
4429
|
-
|
|
4445
|
+
const availability = word === "#available" || word === "#unavailable";
|
|
4446
|
+
t++;
|
|
4447
|
+
if (!availability && text(source, tokens[t]) === "<" && tokens[t].start === token.end) {
|
|
4448
|
+
let depth = 0;
|
|
4449
|
+
do {
|
|
4450
|
+
const p = text(source, tokens[t++]);
|
|
4451
|
+
if (p === "<") depth++;
|
|
4452
|
+
else if (p === ">") depth--;
|
|
4453
|
+
} while (t < to && depth > 0);
|
|
4454
|
+
}
|
|
4455
|
+
if (text(source, tokens[t]) === "(") t = skipGroup(t);
|
|
4456
|
+
if (!availability && text(source, tokens[t]) === "{") t = skipGroup(t);
|
|
4430
4457
|
continue;
|
|
4431
4458
|
}
|
|
4432
4459
|
if (token.kind === "at") {
|
|
@@ -4593,11 +4620,6 @@ function designTimeDiagnostic(output, files) {
|
|
|
4593
4620
|
}).join("\n");
|
|
4594
4621
|
}
|
|
4595
4622
|
|
|
4596
|
-
// src/is-record.ts
|
|
4597
|
-
function isRecord(value) {
|
|
4598
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4599
|
-
}
|
|
4600
|
-
|
|
4601
4623
|
// src/swift-distribution-contract.ts
|
|
4602
4624
|
var SWIFT_DISTRIBUTION_MANIFEST = "distribution.json";
|
|
4603
4625
|
var SWIFT_DISTRIBUTION_HOSTS = [
|
|
@@ -4644,8 +4666,8 @@ var import_node_child_process8 = require("node:child_process");
|
|
|
4644
4666
|
var import_node_crypto5 = require("node:crypto");
|
|
4645
4667
|
var import_node_fs9 = require("node:fs");
|
|
4646
4668
|
var import_promises3 = require("node:fs/promises");
|
|
4647
|
-
var
|
|
4648
|
-
var
|
|
4669
|
+
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
4670
|
+
var import_node_path10 = __toESM(require("node:path"), 1);
|
|
4649
4671
|
var import_node_util = require("node:util");
|
|
4650
4672
|
var import_node_zlib = require("node:zlib");
|
|
4651
4673
|
var run = (0, import_node_util.promisify)(import_node_child_process8.execFile);
|
|
@@ -4662,8 +4684,8 @@ function cachedBrotli(bytes, quality, cacheKey) {
|
|
|
4662
4684
|
const cacheId = `${quality}:${key}`;
|
|
4663
4685
|
const cached = brotliMemoryCache.get(cacheId);
|
|
4664
4686
|
if (cached) return cached;
|
|
4665
|
-
const dir =
|
|
4666
|
-
const file =
|
|
4687
|
+
const dir = import_node_path10.default.join(import_node_os5.default.homedir(), ".peach", "cache", "swift-brotli");
|
|
4688
|
+
const file = import_node_path10.default.join(dir, `${key}${quality === 11 ? "" : "-q4"}.br`);
|
|
4667
4689
|
const pending = (async () => {
|
|
4668
4690
|
try {
|
|
4669
4691
|
return await (0, import_promises3.readFile)(file);
|
|
@@ -4727,7 +4749,7 @@ function swiftIcuAsset(toolchainBin, sdk) {
|
|
|
4727
4749
|
);
|
|
4728
4750
|
}
|
|
4729
4751
|
async function load(toolchainBin, sdk) {
|
|
4730
|
-
const swift =
|
|
4752
|
+
const swift = import_node_path10.default.join(toolchainBin, "swift");
|
|
4731
4753
|
if (!(0, import_node_fs9.existsSync)(swift))
|
|
4732
4754
|
throw new Error(`swift-icu: no swift at ${swift} for the ${sdk} SDK's icu data`);
|
|
4733
4755
|
const { stdout: listed } = await run(swift, ["sdk", "list", ...swiftSdkOptions()], {
|
|
@@ -4750,7 +4772,7 @@ async function load(toolchainBin, sdk) {
|
|
|
4750
4772
|
const resources = /^swiftStaticResourcesPath: (.+)$/m.exec(stdout)?.[1]?.trim();
|
|
4751
4773
|
if (!resources) throw new Error(`swift-icu: ${sdk} names no static resources`);
|
|
4752
4774
|
return Buffer.from(
|
|
4753
|
-
icuSegment(archiveMember((0, import_node_fs9.readFileSync)(
|
|
4775
|
+
icuSegment(archiveMember((0, import_node_fs9.readFileSync)(import_node_path10.default.join(resources, ARCHIVE)), MEMBER))
|
|
4754
4776
|
);
|
|
4755
4777
|
}
|
|
4756
4778
|
function archiveMember(archive, name2) {
|
|
@@ -4807,7 +4829,7 @@ function icuSegment(object) {
|
|
|
4807
4829
|
|
|
4808
4830
|
// src/swift-link-roots.ts
|
|
4809
4831
|
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
4810
|
-
var
|
|
4832
|
+
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
4811
4833
|
var OBJC_SEGMENTS = ["__objc_cats", "__objc_class_aliases"];
|
|
4812
4834
|
var leb = (bytes, at) => {
|
|
4813
4835
|
let value = 0;
|
|
@@ -4824,6 +4846,7 @@ function objcSegmentSizes(bytes) {
|
|
|
4824
4846
|
const names = [];
|
|
4825
4847
|
const sizes = [];
|
|
4826
4848
|
let hasExportedSymbol = false;
|
|
4849
|
+
let definesCategory = false;
|
|
4827
4850
|
while (at.offset < bytes.length) {
|
|
4828
4851
|
const id = bytes[at.offset++];
|
|
4829
4852
|
const size = leb(bytes, at);
|
|
@@ -4863,6 +4886,8 @@ function objcSegmentSizes(bytes) {
|
|
|
4863
4886
|
}
|
|
4864
4887
|
} else if (symKind === 1) {
|
|
4865
4888
|
const sLen = leb(bytes, at);
|
|
4889
|
+
if (!isUndef && Buffer.from(bytes.subarray(at.offset, at.offset + sLen)).toString().startsWith(".objc_category_"))
|
|
4890
|
+
definesCategory = true;
|
|
4866
4891
|
at.offset += sLen;
|
|
4867
4892
|
if (!isUndef) {
|
|
4868
4893
|
leb(bytes, at);
|
|
@@ -4899,6 +4924,7 @@ function objcSegmentSizes(bytes) {
|
|
|
4899
4924
|
result.set(name2, (result.get(name2) ?? 0) + (sizes[index] ?? 0));
|
|
4900
4925
|
});
|
|
4901
4926
|
result.set("__wasm_exported", hasExportedSymbol ? 1 : 0);
|
|
4927
|
+
result.set("__objc_category", definesCategory ? 1 : 0);
|
|
4902
4928
|
return result;
|
|
4903
4929
|
}
|
|
4904
4930
|
var rootsByDistribution = /* @__PURE__ */ new Map();
|
|
@@ -4906,7 +4932,7 @@ function swiftObjcRootObjects(id, root, objects) {
|
|
|
4906
4932
|
const cached = rootsByDistribution.get(id);
|
|
4907
4933
|
if (cached) return cached;
|
|
4908
4934
|
const measured = objects.map(
|
|
4909
|
-
(object) => [object, objcSegmentSizes(import_node_fs10.default.readFileSync(
|
|
4935
|
+
(object) => [object, objcSegmentSizes(import_node_fs10.default.readFileSync(import_node_path11.default.join(root, object)))]
|
|
4910
4936
|
);
|
|
4911
4937
|
const empty = /* @__PURE__ */ new Map();
|
|
4912
4938
|
for (const [, sizes] of measured)
|
|
@@ -4952,14 +4978,14 @@ function swiftObjCModuleMap(module2, headers) {
|
|
|
4952
4978
|
// src/swift-project-user.ts
|
|
4953
4979
|
var import_node_child_process9 = require("node:child_process");
|
|
4954
4980
|
var import_node_fs11 = require("node:fs");
|
|
4955
|
-
var
|
|
4981
|
+
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
4956
4982
|
function prepareSwiftProjectProcess(root, user) {
|
|
4957
4983
|
const home = `${root}.project-home`;
|
|
4958
4984
|
(0, import_node_fs11.rmSync)(home, { recursive: true, force: true });
|
|
4959
|
-
const tmp =
|
|
4960
|
-
const swiftpm =
|
|
4985
|
+
const tmp = import_node_path12.default.join(home, "tmp");
|
|
4986
|
+
const swiftpm = import_node_path12.default.join(home, "swiftpm");
|
|
4961
4987
|
(0, import_node_fs11.mkdirSync)(tmp, { recursive: true });
|
|
4962
|
-
const caches = ["cache", "config", "security"].map((name2) =>
|
|
4988
|
+
const caches = ["cache", "config", "security"].map((name2) => import_node_path12.default.join(swiftpm, name2));
|
|
4963
4989
|
for (const directory of caches) (0, import_node_fs11.mkdirSync)(directory, { recursive: true });
|
|
4964
4990
|
(0, import_node_child_process9.execFileSync)("chown", ["-R", "-P", `${user.uid}:${user.gid}`, root, home]);
|
|
4965
4991
|
(0, import_node_fs11.chmodSync)(root, 448);
|
|
@@ -4970,14 +4996,14 @@ function prepareSwiftProjectProcess(root, user) {
|
|
|
4970
4996
|
env: {
|
|
4971
4997
|
HOME: home,
|
|
4972
4998
|
TMPDIR: tmp,
|
|
4973
|
-
XDG_CONFIG_HOME:
|
|
4974
|
-
XDG_CACHE_HOME:
|
|
4975
|
-
XDG_DATA_HOME:
|
|
4999
|
+
XDG_CONFIG_HOME: import_node_path12.default.join(home, ".config"),
|
|
5000
|
+
XDG_CACHE_HOME: import_node_path12.default.join(home, ".cache"),
|
|
5001
|
+
XDG_DATA_HOME: import_node_path12.default.join(home, ".local", "share")
|
|
4976
5002
|
},
|
|
4977
5003
|
cacheOptions: [
|
|
4978
5004
|
...["cache", "config", "security"].flatMap((name2) => [
|
|
4979
5005
|
`--${name2}-path`,
|
|
4980
|
-
|
|
5006
|
+
import_node_path12.default.join(swiftpm, name2)
|
|
4981
5007
|
]),
|
|
4982
5008
|
"--disable-keychain"
|
|
4983
5009
|
]
|
|
@@ -4993,7 +5019,7 @@ function projectOutputFile(root, file, user) {
|
|
|
4993
5019
|
const real = (0, import_node_fs11.realpathSync)(file);
|
|
4994
5020
|
const base = (0, import_node_fs11.realpathSync)(root);
|
|
4995
5021
|
const stat = (0, import_node_fs11.statSync)(real);
|
|
4996
|
-
if (!real.startsWith(base +
|
|
5022
|
+
if (!real.startsWith(base + import_node_path12.default.sep) || !stat.isFile() || stat.uid !== user.uid) {
|
|
4997
5023
|
throw new Error(`swift-compile: project output ${file} is not a file of its build`);
|
|
4998
5024
|
}
|
|
4999
5025
|
return real;
|
|
@@ -5002,7 +5028,7 @@ function removeProjectLinks(root) {
|
|
|
5002
5028
|
const pending = [root];
|
|
5003
5029
|
for (let directory = pending.pop(); directory; directory = pending.pop()) {
|
|
5004
5030
|
for (const entry of (0, import_node_fs11.readdirSync)(directory, { withFileTypes: true })) {
|
|
5005
|
-
const full =
|
|
5031
|
+
const full = import_node_path12.default.join(directory, entry.name);
|
|
5006
5032
|
if (directory === root && entry.name === ".build") continue;
|
|
5007
5033
|
if (directory === root && entry.name.startsWith(".peach-modules-")) {
|
|
5008
5034
|
(0, import_node_fs11.rmSync)(full, { recursive: true, force: true });
|
|
@@ -5014,9 +5040,9 @@ function removeProjectLinks(root) {
|
|
|
5014
5040
|
|
|
5015
5041
|
// src/swift-reproducible.ts
|
|
5016
5042
|
var import_node_fs12 = require("node:fs");
|
|
5017
|
-
var
|
|
5043
|
+
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
5018
5044
|
function swiftReproducibleBuildFlags(roots) {
|
|
5019
|
-
return [[
|
|
5045
|
+
return [[import_node_os6.default.homedir(), "home"], ...roots].flatMap(
|
|
5020
5046
|
([root, name2]) => [.../* @__PURE__ */ new Set([root, (0, import_node_fs12.realpathSync)(root)])].map((from) => `${from}=/peach/${name2}`)
|
|
5021
5047
|
).flatMap((map) => [
|
|
5022
5048
|
"-Xswiftc",
|
|
@@ -5035,6 +5061,22 @@ var import_node_child_process10 = require("node:child_process");
|
|
|
5035
5061
|
var import_node_crypto6 = require("node:crypto");
|
|
5036
5062
|
var import_node_fs13 = require("node:fs");
|
|
5037
5063
|
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
5064
|
+
|
|
5065
|
+
// src/home-paths.ts
|
|
5066
|
+
var import_node_os7 = require("node:os");
|
|
5067
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
5068
|
+
var PEACH_HOME_ENV = "PEACH_HOME";
|
|
5069
|
+
function ambientHomeDir() {
|
|
5070
|
+
return import_node_path13.default.join((0, import_node_os7.homedir)(), ".peach");
|
|
5071
|
+
}
|
|
5072
|
+
function rnxHomeDir() {
|
|
5073
|
+
const override = process.env[PEACH_HOME_ENV];
|
|
5074
|
+
if (override && override.length > 0) return import_node_path13.default.resolve(override);
|
|
5075
|
+
return ambientHomeDir();
|
|
5076
|
+
}
|
|
5077
|
+
var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
|
|
5078
|
+
|
|
5079
|
+
// src/swift-root-lock.ts
|
|
5038
5080
|
var POLL_MS = 250;
|
|
5039
5081
|
var START_TOLERANCE_MS = 2e3;
|
|
5040
5082
|
function errorCode(error) {
|
|
@@ -5807,11 +5849,9 @@ function parseWasmObjectBytes(file, buf, isDist) {
|
|
|
5807
5849
|
}
|
|
5808
5850
|
}
|
|
5809
5851
|
const typePrefixesInObj = /* @__PURE__ */ new Set();
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
typePrefixesInObj.add(symNames[i].slice(0, -2));
|
|
5814
|
-
}
|
|
5852
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
5853
|
+
if ((symFlags[i] & 16) === 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mn")) {
|
|
5854
|
+
typePrefixesInObj.add(symNames[i].slice(0, -2));
|
|
5815
5855
|
}
|
|
5816
5856
|
}
|
|
5817
5857
|
const objcRegisterFuncToTypePrefix = /* @__PURE__ */ new Map();
|
|
@@ -6093,15 +6133,16 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6093
6133
|
set.add(symIdx);
|
|
6094
6134
|
workQueue.push({ kind: "datasym", obj, symIdx });
|
|
6095
6135
|
};
|
|
6096
|
-
const
|
|
6136
|
+
const knownTypes = /* @__PURE__ */ new Set();
|
|
6097
6137
|
for (const o of distObjs.values())
|
|
6098
|
-
for (const t of o.typePrefixesInObj)
|
|
6138
|
+
for (const t of o.typePrefixesInObj) knownTypes.add(t);
|
|
6099
6139
|
const globalLiveTypes = /* @__PURE__ */ new Set();
|
|
6100
6140
|
const pendingConformances = /* @__PURE__ */ new Map();
|
|
6141
|
+
const eagerConformanceObjects = /* @__PURE__ */ new Set();
|
|
6101
6142
|
const conformingType = (name2) => {
|
|
6102
6143
|
for (let n = name2.length - 1; n > 2; n--) {
|
|
6103
6144
|
const prefix = name2.slice(0, n);
|
|
6104
|
-
if (
|
|
6145
|
+
if (knownTypes.has(prefix)) return prefix;
|
|
6105
6146
|
}
|
|
6106
6147
|
return void 0;
|
|
6107
6148
|
};
|
|
@@ -6113,7 +6154,11 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6113
6154
|
const waiting = pendingConformances.get(pref);
|
|
6114
6155
|
if (waiting) {
|
|
6115
6156
|
pendingConformances.delete(pref);
|
|
6116
|
-
for (const w of waiting)
|
|
6157
|
+
for (const w of waiting) {
|
|
6158
|
+
eagerConformanceObjects.add(w.obj);
|
|
6159
|
+
extractObject(w.obj);
|
|
6160
|
+
activateSymbolInObj(w.obj, w.symIdx);
|
|
6161
|
+
}
|
|
6117
6162
|
}
|
|
6118
6163
|
const mnName = `${pref}Mn`;
|
|
6119
6164
|
for (let i = 0; i < obj.symNames.length; i++) {
|
|
@@ -6140,7 +6185,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6140
6185
|
}
|
|
6141
6186
|
};
|
|
6142
6187
|
const checkTypeTrigger = (obj, rawSymName) => {
|
|
6143
|
-
if (!
|
|
6188
|
+
if (!rawSymName) return;
|
|
6144
6189
|
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
6145
6190
|
const objcPref = obj.objcClassSymToTypePrefix.get(sName);
|
|
6146
6191
|
if (objcPref) {
|
|
@@ -6231,6 +6276,13 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6231
6276
|
}
|
|
6232
6277
|
for (const fIdx of obj.rootFuncs) markFuncLive(obj, fIdx);
|
|
6233
6278
|
for (const sIdx of obj.rootSegs) markSegLive(obj, sIdx);
|
|
6279
|
+
for (const name2 of obj.symNames) {
|
|
6280
|
+
const loaded = name2?.match(/^_c_(\w+)__load$/)?.[1];
|
|
6281
|
+
if (!loaded) continue;
|
|
6282
|
+
const classSym = obj.symNames.indexOf(`._OBJC_CLASS_${loaded}`);
|
|
6283
|
+
if (classSym !== -1 && (obj.symFlags[classSym] & 16) === 0)
|
|
6284
|
+
activateSymbolInObj(obj, classSym);
|
|
6285
|
+
}
|
|
6234
6286
|
if (obj.file.endsWith("libswiftCore__Swift.o")) {
|
|
6235
6287
|
for (const pref of obj.typePrefixesInObj) {
|
|
6236
6288
|
if (!pref.startsWith("$ss")) {
|
|
@@ -6255,11 +6307,6 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6255
6307
|
const type = conformingType(mcName);
|
|
6256
6308
|
if (type === void 0 || globalLiveTypes.has(type))
|
|
6257
6309
|
activateSymbolInObj(obj, r.rs);
|
|
6258
|
-
else {
|
|
6259
|
-
let list = pendingConformances.get(type);
|
|
6260
|
-
if (!list) pendingConformances.set(type, list = []);
|
|
6261
|
-
list.push({ obj, symIdx: r.rs });
|
|
6262
|
-
}
|
|
6263
6310
|
}
|
|
6264
6311
|
}
|
|
6265
6312
|
}
|
|
@@ -6267,6 +6314,17 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6267
6314
|
}
|
|
6268
6315
|
}
|
|
6269
6316
|
};
|
|
6317
|
+
for (const obj of distObjs.values()) {
|
|
6318
|
+
if (!obj.isDist) continue;
|
|
6319
|
+
for (const r of obj.dataRelocList) {
|
|
6320
|
+
if (obj.segNames[r.segIdx] !== "swift5_protocol_conformances") continue;
|
|
6321
|
+
const type = conformingType(obj.symNames[r.rs]);
|
|
6322
|
+
if (type === void 0 || obj.typePrefixesInObj.has(type)) continue;
|
|
6323
|
+
let list = pendingConformances.get(type);
|
|
6324
|
+
if (!list) pendingConformances.set(type, list = []);
|
|
6325
|
+
list.push({ obj, symIdx: r.rs });
|
|
6326
|
+
}
|
|
6327
|
+
}
|
|
6270
6328
|
let hasClangObjCEager = false;
|
|
6271
6329
|
const eagerBuildPrunable = [];
|
|
6272
6330
|
for (const f of eagerFiles) {
|
|
@@ -6685,6 +6743,12 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6685
6743
|
emittedPruned.add(ef);
|
|
6686
6744
|
}
|
|
6687
6745
|
}
|
|
6746
|
+
for (const obj of eagerConformanceObjects) {
|
|
6747
|
+
if (!emittedPruned.has(obj.file) && prunedMap.has(obj.file)) {
|
|
6748
|
+
outTokens.push(prunedMap.get(obj.file));
|
|
6749
|
+
emittedPruned.add(obj.file);
|
|
6750
|
+
}
|
|
6751
|
+
}
|
|
6688
6752
|
outTokens.push("--start-lib");
|
|
6689
6753
|
for (const rf of prunableCandidates) {
|
|
6690
6754
|
if (emittedPruned.has(rf)) continue;
|
|
@@ -6860,6 +6924,7 @@ function isSwiftResourceBundles(value) {
|
|
|
6860
6924
|
}
|
|
6861
6925
|
|
|
6862
6926
|
// src/wasm-optimize.ts
|
|
6927
|
+
var import_node_child_process13 = require("node:child_process");
|
|
6863
6928
|
var import_wasm_opt = require("wasm-opt");
|
|
6864
6929
|
var FEATURES = [
|
|
6865
6930
|
"threads",
|
|
@@ -6874,7 +6939,7 @@ var FEATURES = [
|
|
|
6874
6939
|
"sign-ext"
|
|
6875
6940
|
];
|
|
6876
6941
|
var WASM_OPTIMIZE_IDENTITY = `wasm-opt ${import_wasm_opt.BINARYEN_VERSION} -Oz ${FEATURES.join(",")}`;
|
|
6877
|
-
async function
|
|
6942
|
+
async function runWasmOpt(file, output) {
|
|
6878
6943
|
const result = await (0, import_wasm_opt.wasmOpt)([
|
|
6879
6944
|
"-Oz",
|
|
6880
6945
|
...FEATURES.map((feature) => `--enable-${feature}`),
|
|
@@ -6885,6 +6950,29 @@ async function optimizeWasm(file, output) {
|
|
|
6885
6950
|
if (result.status !== 0)
|
|
6886
6951
|
throw new Error(`wasm-opt exited ${result.status}: ${result.stderr}`);
|
|
6887
6952
|
}
|
|
6953
|
+
function installWasmOpt() {
|
|
6954
|
+
try {
|
|
6955
|
+
(0, import_node_child_process13.execFileSync)("npx", ["-y", "wasm-opt", "--wasm-opt-install"], {
|
|
6956
|
+
timeout: 6e5,
|
|
6957
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
6958
|
+
env: { ...process.env, WASM_OPT_VERSION: import_wasm_opt.BINARYEN_VERSION }
|
|
6959
|
+
});
|
|
6960
|
+
} catch (error) {
|
|
6961
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
6962
|
+
throw new Error(`wasm-opt binary missing and on-demand install failed: ${detail}`, {
|
|
6963
|
+
cause: error
|
|
6964
|
+
});
|
|
6965
|
+
}
|
|
6966
|
+
}
|
|
6967
|
+
async function optimizeWasm(file, output) {
|
|
6968
|
+
try {
|
|
6969
|
+
await runWasmOpt(file, output);
|
|
6970
|
+
} catch (error) {
|
|
6971
|
+
if (!(error instanceof import_wasm_opt.BinaryNotFoundError)) throw error;
|
|
6972
|
+
installWasmOpt();
|
|
6973
|
+
await runWasmOpt(file, output);
|
|
6974
|
+
}
|
|
6975
|
+
}
|
|
6888
6976
|
|
|
6889
6977
|
// src/write-build-file.ts
|
|
6890
6978
|
var import_node_fs15 = require("node:fs");
|
|
@@ -7006,7 +7094,7 @@ async function runCompiler(command, args, options, stream = false, quiet) {
|
|
|
7006
7094
|
detached: true,
|
|
7007
7095
|
stdio: ["ignore", "pipe", "pipe"]
|
|
7008
7096
|
};
|
|
7009
|
-
const child = options.lease ? options.lease.spawn(command, args, launch, options.frameworkLease) : (0,
|
|
7097
|
+
const child = options.lease ? options.lease.spawn(command, args, launch, options.frameworkLease) : (0, import_node_child_process14.spawn)(command, args, launch);
|
|
7010
7098
|
let stopping;
|
|
7011
7099
|
try {
|
|
7012
7100
|
return await new Promise((resolve, reject) => {
|
|
@@ -7111,21 +7199,20 @@ function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
|
|
|
7111
7199
|
return { declared: swiftInterfaceDeclarations(header), header };
|
|
7112
7200
|
}
|
|
7113
7201
|
const sources = import_node_path19.default.join(moduleRoot, "Sources", name2);
|
|
7114
|
-
|
|
7202
|
+
const built = import_node_path19.default.join(moduleRoot, ".build/host", `${name2}-Swift.h`);
|
|
7203
|
+
if (!(0, import_node_fs17.existsSync)(sources) || !(0, import_node_fs17.existsSync)(built)) return null;
|
|
7115
7204
|
const declared = /* @__PURE__ */ new Set();
|
|
7116
7205
|
for (const file of (0, import_node_fs17.readdirSync)(sources, { recursive: true, encoding: "utf8" }))
|
|
7117
7206
|
if (file.endsWith(".swift"))
|
|
7118
|
-
for (const [, objc] of (0, import_node_fs17.readFileSync)(
|
|
7119
|
-
|
|
7207
|
+
for (const [, objc, subclass] of (0, import_node_fs17.readFileSync)(
|
|
7208
|
+
import_node_path19.default.join(sources, file),
|
|
7209
|
+
"utf8"
|
|
7210
|
+
).matchAll(
|
|
7211
|
+
/@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s|^(?:public|open)\s+(?:final\s+)?class\s+(\w+)\s*:\s*NSObject\b/gm
|
|
7120
7212
|
))
|
|
7121
|
-
declared.add(objc);
|
|
7213
|
+
declared.add(objc ?? subclass);
|
|
7122
7214
|
if (declared.size === 0) return null;
|
|
7123
|
-
|
|
7124
|
-
return {
|
|
7125
|
-
declared,
|
|
7126
|
-
header: (0, import_node_fs17.existsSync)(built) ? clangInterfaceHeader((0, import_node_fs17.readFileSync)(built, "utf8")) : `// ${name2}-Swift.h is generated when ${name2} builds
|
|
7127
|
-
`
|
|
7128
|
-
};
|
|
7215
|
+
return { declared, header: clangInterfaceHeader((0, import_node_fs17.readFileSync)(built, "utf8")) };
|
|
7129
7216
|
}
|
|
7130
7217
|
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");
|
|
7131
7218
|
var swiftInterfaceDeclarations = (header) => /* @__PURE__ */ new Set([
|
|
@@ -7341,9 +7428,10 @@ function swiftProjectBuildKey(moduleRoot, release) {
|
|
|
7341
7428
|
var SYSTEM_MODULE_LIBRARIES = {
|
|
7342
7429
|
"sqlite3.h": "sqlite3",
|
|
7343
7430
|
"sqlite3ext.h": "sqlite3",
|
|
7431
|
+
"bzlib.h": "bz2",
|
|
7344
7432
|
SQLite3: "sqlite3"
|
|
7345
7433
|
};
|
|
7346
|
-
var SYSTEM_MODULE_IMPORT = /^\s*(?:#\s*(?:import|include)\s*<(sqlite3(?:ext)?\.h)>|@import\s+(SQLite3)\b)/gm;
|
|
7434
|
+
var SYSTEM_MODULE_IMPORT = /^\s*(?:#\s*(?:import|include)\s*<(sqlite3(?:ext)?\.h|bzlib\.h)>|@import\s+(SQLite3)\b)/gm;
|
|
7347
7435
|
function compileTargets(input) {
|
|
7348
7436
|
const manifest = input.files["Package.swift"];
|
|
7349
7437
|
if (manifest === void 0) return [];
|
|
@@ -7539,7 +7627,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
7539
7627
|
const key = JSON.stringify([toolchainBin, sdk, options]);
|
|
7540
7628
|
const cached = sdkPaths.get(key);
|
|
7541
7629
|
if (cached) return cached;
|
|
7542
|
-
const configuration = (0,
|
|
7630
|
+
const configuration = (0, import_node_child_process14.execFileSync)(
|
|
7543
7631
|
import_node_path19.default.join(toolchainBin, "swift"),
|
|
7544
7632
|
[
|
|
7545
7633
|
"sdk",
|
|
@@ -7709,6 +7797,11 @@ function swiftTargetDependencies(files, targets) {
|
|
|
7709
7797
|
const siblings = /* @__PURE__ */ new Map();
|
|
7710
7798
|
for (const target of targets) {
|
|
7711
7799
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
7800
|
+
const ownsHeader = (header) => [`${prefix}${header}`, `${prefix}include/${header}`].some(
|
|
7801
|
+
(file) => Object.hasOwn(files, file) && !targets.some(
|
|
7802
|
+
(candidate) => candidate.name !== target.name && candidate.path !== "." && file.startsWith(`${candidate.path}/`)
|
|
7803
|
+
)
|
|
7804
|
+
);
|
|
7712
7805
|
const deps = new Set(
|
|
7713
7806
|
(target.dependencies ?? []).flatMap(
|
|
7714
7807
|
(dependency) => dependency.kind === "target" && dependency.name !== target.name && names.has(dependency.name) ? [dependency.name] : []
|
|
@@ -7720,7 +7813,7 @@ function swiftTargetDependencies(files, targets) {
|
|
|
7720
7813
|
(candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
|
|
7721
7814
|
))
|
|
7722
7815
|
continue;
|
|
7723
|
-
const imports = file.endsWith(".swift") ? swiftImportNames(contents) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents) : [];
|
|
7816
|
+
const imports = file.endsWith(".swift") ? swiftImportNames(contents) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents, ownsHeader) : [];
|
|
7724
7817
|
for (const name2 of imports) {
|
|
7725
7818
|
if (names.has(name2) && name2 !== target.name) deps.add(name2);
|
|
7726
7819
|
}
|
|
@@ -7756,9 +7849,9 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
|
7756
7849
|
`;
|
|
7757
7850
|
var darwinRecordsRegion = (quoted) => quoted.length ? ["-Wl,--start-lib", ...quoted, "-Wl,--end-lib"] : [];
|
|
7758
7851
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
7759
|
-
var MULTI_MANIFEST_VERSION =
|
|
7852
|
+
var MULTI_MANIFEST_VERSION = 65;
|
|
7760
7853
|
var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
7761
|
-
var compilerSourceDigest = true ? "
|
|
7854
|
+
var compilerSourceDigest = true ? "c1407efb75c18328e37b50abfe396dce388c41563443b4c3a1485a800114a92c" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
|
|
7762
7855
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
7763
7856
|
const hash = (0, import_node_crypto8.createHash)("sha256");
|
|
7764
7857
|
hash.update(`swift-compile
|
|
@@ -7843,6 +7936,13 @@ ${target}
|
|
|
7843
7936
|
}
|
|
7844
7937
|
return hash.digest("hex");
|
|
7845
7938
|
}
|
|
7939
|
+
var nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
7940
|
+
var cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|
|
7941
|
+
var cxxFlagArray = (flags) => JSON.stringify([
|
|
7942
|
+
...nativeCxxCompilerFlags,
|
|
7943
|
+
...fmtConstantInterpreterFlags(flags),
|
|
7944
|
+
...withoutGlogModuleMap(flags)
|
|
7945
|
+
]);
|
|
7846
7946
|
function swiftCrossImportFlags(moduleRoot, distribution) {
|
|
7847
7947
|
const overlayRoot = import_node_path19.default.join(
|
|
7848
7948
|
moduleRoot,
|
|
@@ -8075,13 +8175,13 @@ function emitSwiftPackageManifest(args) {
|
|
|
8075
8175
|
(source) => /\.(?:cc|cpp|cxx|mm)$/.test(source)
|
|
8076
8176
|
);
|
|
8077
8177
|
const nativeSettings = native?.clang ? [
|
|
8078
|
-
`cSettings: [${cDefines} .unsafeFlags(${flagArray(
|
|
8178
|
+
`cSettings: [${cDefines} .unsafeFlags(${flagArray(cFlagArray([...nativeFlags, ...native.clang.flags]))})]`,
|
|
8079
8179
|
...nativeCxx ? [
|
|
8080
|
-
`cxxSettings: [${cxxDefines} .unsafeFlags(${flagArray(
|
|
8180
|
+
`cxxSettings: [${cxxDefines} .unsafeFlags(${flagArray(cxxFlagArray([...cxxFlagsFor(nativeFlags), ...native.clang.cxxFlags]))})]`
|
|
8081
8181
|
] : []
|
|
8082
8182
|
].join(", ") : [
|
|
8083
|
-
`cSettings: [${cDefines}${declaredClangSettings(target, "c")} .unsafeFlags(${flagArray(
|
|
8084
|
-
`cxxSettings: [${cxxDefines}${declaredClangSettings(target, "cxx")} .unsafeFlags(${flagArray(
|
|
8183
|
+
`cSettings: [${cDefines}${declaredClangSettings(target, "c")} .unsafeFlags(${flagArray(cFlagArray([...nativeFlags, ...native?.flags ?? []]))})]`,
|
|
8184
|
+
`cxxSettings: [${cxxDefines}${declaredClangSettings(target, "cxx")} .unsafeFlags(${flagArray(cxxFlagArray([...cxxFlagsFor(nativeFlags), ...native?.cxxFlags ?? []]))})]`
|
|
8085
8185
|
].join(", ");
|
|
8086
8186
|
const exclusions = native?.clang ? [] : [
|
|
8087
8187
|
...native ? native.exclude ?? native.lateSources : [],
|
|
@@ -8150,9 +8250,9 @@ function emitSwiftPackageManifest(args) {
|
|
|
8150
8250
|
` path: ${JSON.stringify(group.path)},`,
|
|
8151
8251
|
` sources: ${JSON.stringify(group.sources)},`,
|
|
8152
8252
|
' publicHeadersPath: "include",',
|
|
8153
|
-
` cSettings: [${macroSettings(owner?.cDefines)}${declaredClangSettings(owner, "c")} .unsafeFlags(${flagArray(
|
|
8253
|
+
` cSettings: [${macroSettings(owner?.cDefines)}${declaredClangSettings(owner, "c")} .unsafeFlags(${flagArray(cFlagArray([...nativeFlags, "-I", native.includeDirectory, ...args.headerDirectory ? ["-I", args.headerDirectory] : [], ...group.flags]))})],`,
|
|
8154
8254
|
...group.sources.some((source) => /\.(?:cc|cpp|cxx|mm)$/.test(source)) ? [
|
|
8155
|
-
` cxxSettings: [${macroSettings(owner?.cxxDefines)}${declaredClangSettings(owner, "cxx")} .unsafeFlags(${flagArray(
|
|
8255
|
+
` cxxSettings: [${macroSettings(owner?.cxxDefines)}${declaredClangSettings(owner, "cxx")} .unsafeFlags(${flagArray(cxxFlagArray([...cxxFlagsFor(nativeFlags), ...group.cxxFlags]))})]),`
|
|
8156
8256
|
] : [" ),"]
|
|
8157
8257
|
]) : [];
|
|
8158
8258
|
}),
|
|
@@ -9860,20 +9960,34 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
9860
9960
|
moduleInterfaces.set(name2, value);
|
|
9861
9961
|
return value;
|
|
9862
9962
|
};
|
|
9963
|
+
const podHeaders = /* @__PURE__ */ new Map();
|
|
9964
|
+
for (const settings of input.nativeTargets ?? [])
|
|
9965
|
+
for (const file of settings.headers) {
|
|
9966
|
+
const owner = /\/Headers\/(?:Public|Private)\/([\w+-]+)\/(?:\1\/)?[^/]+\.h$/.exec(
|
|
9967
|
+
file
|
|
9968
|
+
)?.[1];
|
|
9969
|
+
if (owner)
|
|
9970
|
+
podHeaders.set(import_node_path19.default.basename(file), [
|
|
9971
|
+
...podHeaders.get(import_node_path19.default.basename(file)) ?? [],
|
|
9972
|
+
{ owner, content: input.files[file] }
|
|
9973
|
+
]);
|
|
9974
|
+
}
|
|
9975
|
+
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(import_node_path19.default.basename(file))?.find((header) => header.content === content)?.owner;
|
|
9863
9976
|
for (const settings of input.nativeTargets ?? []) {
|
|
9864
9977
|
for (const file of settings.headers) {
|
|
9865
9978
|
const destination = import_node_path19.default.join(layout.root, file);
|
|
9866
9979
|
if (files.has(destination)) continue;
|
|
9867
9980
|
const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
|
|
9868
9981
|
const frameworkHeader = !interfaceModule && /(?:^|\/)(\w+)\.framework\/Headers\/[\w+.-]+\.h$/.exec(file)?.[1];
|
|
9869
|
-
const
|
|
9982
|
+
const interfaceOwner = frameworkHeader || (interfaceModule ? void 0 : podHeaderOwner(file, input.files[file]));
|
|
9983
|
+
const frameworkInterface = interfaceOwner ? moduleInterface(interfaceOwner) : null;
|
|
9870
9984
|
const rawContents = interfaceModule && moduleInterface(interfaceModule)?.header || input.files[file];
|
|
9871
9985
|
if (rawContents === void 0)
|
|
9872
9986
|
throw new Error(`missing original Objective-C header ${file}`);
|
|
9873
9987
|
const contents = frameworkInterface && typeof rawContents === "string" ? withoutSwiftDeclarations(
|
|
9874
9988
|
rawContents,
|
|
9875
9989
|
frameworkInterface.declared,
|
|
9876
|
-
`#import <${
|
|
9990
|
+
`#import <${interfaceOwner}/${interfaceOwner}-Swift.h>`
|
|
9877
9991
|
) : rawContents;
|
|
9878
9992
|
writeBuildFile(destination, contents);
|
|
9879
9993
|
files.set(destination, contents);
|