peachsim 0.1.1728 → 0.1.1744
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 -0
- package/cli/app-catalog.ts +47 -23
- package/cli/app-fonts.ts +19 -1
- package/cli/command-registry.ts +3 -0
- package/cli/commands/control.ts +68 -16
- package/cli/commands/coverage-swift.ts +112 -4
- package/cli/commands/device.ts +3 -1
- package/cli/commands/doctor.ts +1 -4
- package/cli/commands/inspect/settling.ts +6 -1
- package/cli/commands/inspect/wait-ready.ts +22 -2
- package/cli/commands/package.ts +33 -21
- package/cli/commands/push.ts +56 -0
- package/cli/commands/serve.ts +9 -0
- package/cli/commands/shell-url.ts +41 -9
- package/cli/commands/swift.ts +1 -1
- package/cli/current-sim.ts +27 -0
- package/cli/drivers/linux-browser-libs.lock.json +323 -1
- package/cli/drivers/linux-browser-libs.ts +8 -6
- package/cli/drivers/playwright.ts +5 -1
- package/cli/internal-child.ts +11 -1
- package/cli/main.ts +6 -0
- package/cli/native-input.ts +1 -7
- package/cli/outbound-endpoints.ts +9 -1
- package/cli/packaged-app-launcher.ts +3 -1
- package/cli/scene-video.ts +28 -7
- package/cli/ws-bridge.ts +3 -1
- package/detox/index.ts +18 -5
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +5 -2
- package/dist-lib/auth/shared-session.cjs +5 -2
- 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 +9932 -4561
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- 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 +30 -8
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +6886 -3303
- package/dist-lib/expo-swift-metadata.cjs +14 -2
- package/dist-lib/expo-swift-metadata.mjs +14 -2
- package/dist-lib/home-paths.cjs +7 -2
- package/dist-lib/host/bridge-host.cjs +8513 -3085
- package/dist-lib/host/fetch-proxy-handler.cjs +19 -7
- 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 +6 -3
- package/dist-lib/index.cjs +175 -80
- 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 +209 -32
- package/dist-lib/menu.cjs +7 -1
- package/dist-lib/menu.mjs +7 -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 +146 -76
- package/dist-lib/native-app-identity-project.cjs +76 -39
- package/dist-lib/native-app-identity-project.mjs +76 -39
- package/dist-lib/native-app-identity.cjs +10 -3
- package/dist-lib/native-app-identity.mjs +10 -3
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +5 -2
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +25 -23
- package/dist-lib/public-origins-lib.json +138 -80
- package/dist-lib/react-native-host-modules.cjs +5 -2
- package/dist-lib/react-native-host-modules.mjs +5 -2
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +4 -1
- package/dist-lib/sdk.mjs +4 -1
- package/dist-lib/skills.cjs +41126 -36493
- package/dist-lib/swift-compile.cjs +2103 -444
- package/dist-lib/swift-compile.mjs +2025 -369
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +84 -24
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +6094 -2687
- package/dist-lib/vite.cjs +32 -10
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-compat/src/stubs/screen-transition-math.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/cli-companion.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/canvaskit-renderer.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +7 -4
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +1 -3
- package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +0 -5
- package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +8 -0
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +10 -1
- package/dist-types/packages/peach-engine/src/engine/paint-boundary.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/render-damage.d.ts +2 -2
- package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +25 -3
- package/dist-types/packages/peach-engine/src/engine/scroll-platform.d.ts +1 -15
- package/dist-types/packages/peach-engine/src/engine/scroll.d.ts +1 -3
- package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +6 -0
- package/dist-types/packages/peach-engine/src/engine/text-paragraph.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/types.d.ts +23 -0
- package/dist-types/packages/peach-engine/src/ios/chrome-metrics.d.ts +6 -0
- package/dist-types/packages/peach-engine/src/metro-identity-contract.d.ts +33 -0
- package/dist-types/packages/peach-engine/src/native-preview-bundle.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/preview/bundle-layout.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/remote-stream/scene-recording.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-gpu.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/render-worker/metro-bundle-metadata.d.ts +28 -0
- package/dist-types/packages/peach-engine/src/render-worker/native-ui-protocol.d.ts +21 -1
- package/dist-types/packages/peach-engine/src/render-worker/prepared-boot-bundle.d.ts +7 -0
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +15 -2
- package/dist-types/packages/peach-engine/src/render-worker/scroll-mirror.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +6 -0
- package/dist-types/packages/peach-engine/src/render-worker/test-bridge-protocol.d.ts +3 -3
- package/dist-types/packages/peach-engine/src/render-worker/webgpu-frame-transaction.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/webgpu-readback-scheduler.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +14 -1
- package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +8 -1
- package/dist-types/packages/peach-engine/src/rolldown-production-fingerprint.d.ts +1 -4
- package/dist-types/packages/peach-engine/src/rolldown-production-module.d.ts +12 -0
- package/dist-types/packages/peach-engine/src/rolldown-production-roles.d.ts +6 -0
- package/dist-types/packages/peach-engine/src/settings/devices.d.ts +6 -1
- package/dist-types/packages/peach-engine/src/settings/duo-fold-bus.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/shell-events.d.ts +4 -0
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +8 -0
- package/kotlin/README.md +3 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +2 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccount.h +55 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountCredential.h +35 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountStore.h +94 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountType.h +53 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACError.h +37 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/Accounts.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/AccountsDefines.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +1 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetworkErrors.h +257 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFByteOrder.h +305 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +2 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGAffineTransform.h +204 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGBitmapContext.h +260 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGColor.h +164 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGColorConversionInfo.h +101 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGColorSpace.h +510 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGContext.h +1132 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGConvertColorDataWithFormat.h +34 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDataConsumer.h +83 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDataProvider.h +197 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGEXRToneMappingGamma.h +36 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGError.h +38 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGFont.h +312 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGFunction.h +106 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGGradient.h +123 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGITUToneMapping.h +31 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGImage.h +409 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGLayer.h +78 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFArray.h +120 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFContentStream.h +55 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFContext.h +535 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFDictionary.h +133 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFDocument.h +252 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFMarkedContentItem.h +37 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFObject.h +67 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFOperatorTable.h +51 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFPage.h +101 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFScanner.h +123 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFStream.h +44 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFString.h +52 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFStructureElement.h +87 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPath.h +441 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPattern.h +89 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGRenderingBufferProvider.h +49 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGShading.h +124 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGToneMapping.h +85 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +44 -252
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Modules/module.modulemap +1 -0
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/CFNetworkErrors.h +257 -0
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +58 -9
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +992 -98
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/NSURLSession+Network.h +32 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/Network.h +51 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/advertise_descriptor.h +193 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/browse_descriptor.h +163 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/browse_result.h +207 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/browser.h +285 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/connection.h +714 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/connection_group.h +629 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/connection_report.h +932 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/content_context.h +229 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/endpoint.h +390 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/error.h +135 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/ethernet_channel.h +349 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/framer_options.h +1187 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/group_descriptor.h +184 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/interface.h +150 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/ip_options.h +351 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/listener.h +438 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/nw_object.h +200 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/parameters.h +1205 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/path.h +392 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/path_monitor.h +216 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/privacy_context.h +188 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/protocol_options.h +126 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/proxy_config.h +357 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/quic_options.h +889 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/resolver_config.h +94 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/tcp_options.h +459 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/tls_options.h +115 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/txt_record.h +432 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/udp_options.h +112 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/ws_options.h +743 -0
- package/sdk/ios/System/Library/Frameworks/Network.framework/Modules/module.modulemap +9 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAAnimation.h +395 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CABase.h +132 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CADisplayLink.h +107 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAEmitterCell.h +153 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAEmitterLayer.h +151 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAFrameRateRange.h +40 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAGradientLayer.h +78 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CALayer.h +1078 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAMediaTiming.h +97 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAMediaTimingFunction.h +67 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAReplicatorLayer.h +65 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAScrollLayer.h +64 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAShapeLayer.h +135 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATextLayer.h +99 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATiledLayer.h +67 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATransaction.h +124 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATransform3D.h +138 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATransformLayer.h +40 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAValueFunction.h +78 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.h +19 -38
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecureTransport.h +1757 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/NSAttributedString.h +19 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/NSParagraphStyle.h +28 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityConstants.h +114 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h +16 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBarAppearance.h +47 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDataDetectors.h +20 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDatePicker.h +13 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDevice.h +16 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIEvent.h +84 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIGestureRecognizer.h +119 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIGestureRecognizerSubclass.h +66 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIHoverGestureRecognizer.h +45 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +161 -37
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIPickerView.h +76 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITabBar.h +8 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITabBarAppearance.h +78 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITextInputTraits.h +29 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITouch.h +104 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITraitCollection.h +19 -0
- package/sdk/ios/usr/include/dns_sd.h +3616 -0
- package/sdk/ios/usr/include/dnssd.modulemap +4 -0
- package/sdk/ios/usr/include/module.modulemap +1 -0
- package/sdk/ios/usr/include/os/signpost.h +414 -0
- package/sdk/ios/usr/include/os.modulemap +5 -0
- package/sdk/ios/usr/include/sys/socketvar.h +191 -0
- package/sdk/ios/usr/include/sys/vsock.h +84 -0
- package/sdk/ios/wasm/include/errno.h +4 -20
- package/sdk/ios/wasm/include/pthread.h +3 -0
- package/sdk/ios/wasm/include/setjmp.h +57 -0
- package/sdk/ios/wasm/include/sys/resource.h +2 -2
- package/sdk/native-hashes.json +3 -3
- package/skills/contrast/SKILL.md +6 -5
- package/skills/peach-debug/SKILL.md +68 -265
- package/skills/peach-debug/references/accessibility.md +37 -73
- package/skills/peach-debug/references/commands.md +2 -2
- package/skills/peach-debug/references/events.md +74 -0
- package/skills/peach-perf/SKILL.md +64 -402
- package/skills/peach-perf/references/presentation.md +46 -0
- package/skills/peach-perf/references/profiling.md +93 -0
- package/skills/peach-perf/references/render-counters.md +57 -0
- package/skills/peach-setup/SKILL.md +66 -217
- package/skills/peach-setup/references/native-config.md +35 -0
- package/skills/peach-setup/references/reporting.md +28 -0
- package/skills/peach-test/SKILL.md +68 -285
- package/skills/peach-test/references/detox.md +69 -0
- package/skills/peach-test/references/maestro.md +95 -0
- package/skills/peach-visual/SKILL.md +53 -106
- package/src/android-autolinking.ts +1 -0
- package/src/android-bridge-packages.ts +279 -0
- package/src/appPackageContract.ts +14 -1
- package/src/assetCatalogContract.ts +8 -1
- package/src/bridge-contract.ts +6 -0
- package/src/bundle-channel.mjs +152 -60
- package/src/cli-runtime.ts +3 -0
- package/src/configured-bundle-producer.ts +10 -0
- package/src/device-catalog.ts +68 -4
- package/src/expo-discovery-cache.ts +10 -3
- package/src/expo-kotlin-host.ts +97 -26
- package/src/expo-native-workspace.ts +211 -52
- package/src/expo-swift-host.ts +149 -123
- package/src/expo-swift-ready.ts +5 -1
- package/src/expo-widget-assets.ts +76 -0
- package/src/expoKotlinContract.ts +12 -2
- package/src/expoSwiftContract.ts +21 -2
- package/src/generated/swift-c-predefines.json +1 -1
- package/src/home-paths.ts +6 -1
- package/src/host/bridge-host.ts +5 -0
- package/src/host/fetch-proxy-handler.ts +10 -0
- package/src/host/websocket-proxy.ts +7 -2
- package/src/kotlin-host.ts +204 -30
- package/src/kotlinSdkContract.ts +2 -1
- package/src/menu.ts +7 -0
- package/src/native-prebuilt.ts +154 -0
- package/src/nitro-adapter.lock.json +261 -261
- package/src/nitro-adapter.ts +118 -50
- package/src/nitro-bundle.ts +134 -96
- package/src/nitro-compile.ts +16 -6
- package/src/nitro-dependencies.ts +43 -28
- package/src/nitro-source.ts +142 -30
- package/src/nitro-superset.lock.json +103 -0
- package/src/nitro-superset.ts +137 -0
- package/src/nitroAdapterContract.ts +146 -98
- package/src/nitroContract.ts +68 -21
- package/src/react-bridge-importers.ts +1 -0
- package/src/react-native-bridge-modules.ts +2 -0
- package/src/react-native-host-modules.ts +4 -1
- package/src/settingsContract.ts +37 -1
- package/src/storageSnapshotContract.ts +29 -81
- package/src/swift-compile.ts +315 -117
- package/src/swift-compiler-digest.ts +2 -0
- package/src/swift-coverage/indexdump.ts +22 -6
- package/src/swift-coverage/indexing.ts +4 -4
- package/src/swift-coverage/sdk.ts +104 -20
- package/src/swift-coverage/types.ts +34 -0
- package/src/swift-coverage/xcode-packages.ts +61 -1
- package/src/swift-coverage/xcode.ts +19 -13
- package/src/swift-cxx-reachable.ts +1 -1
- package/src/swift-distribution.lock.json +18 -13
- package/src/swift-distribution.ts +57 -26
- package/src/swift-host.ts +51 -35
- package/src/swift-link-roots.ts +45 -18
- package/src/swift-objc-compile.ts +78 -2
- package/src/swift-objc-standin.ts +3 -0
- package/src/swift-shared-sdk.ts +85 -1
- package/src/swift-standin-emit.ts +6 -1
- package/src/swift-standins.ts +403 -19
- package/src/swift-submit.ts +17 -1
- package/src/swift-toolchain.ts +98 -23
- package/src/swift-wasm-prune.ts +1629 -0
- package/src/turbo-bundle.ts +82 -0
- package/src/turbo-compile.ts +120 -0
- package/src/turbo-runtime.lock.json +69 -0
- package/src/turbo-source.ts +754 -0
- package/src/vite-plugin-one.ts +15 -3
- package/src/vite-plugin.ts +82 -23
- package/src/wasm-optimize.ts +34 -0
- package/src/worker-system-chunks.ts +3 -3
- package/src/xcode-project.ts +52 -0
- package/src/xcode-target-members.ts +12 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.1744 | (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;
|
|
@@ -40,6 +40,7 @@ __export(swift_compile_exports, {
|
|
|
40
40
|
compileTargets: () => compileTargets,
|
|
41
41
|
emitSwiftPackageManifest: () => emitSwiftPackageManifest,
|
|
42
42
|
ensureMacroPlugins: () => ensureMacroPlugins,
|
|
43
|
+
foundationOwnerOf: () => foundationOwnerOf,
|
|
43
44
|
lowerAVAssetURLCluster: () => lowerAVAssetURLCluster,
|
|
44
45
|
lowerNSValueTimeBox: () => lowerNSValueTimeBox,
|
|
45
46
|
missingSwiftModules: () => missingSwiftModules,
|
|
@@ -52,12 +53,14 @@ __export(swift_compile_exports, {
|
|
|
52
53
|
swiftCMainEntry: () => swiftCMainEntry,
|
|
53
54
|
swiftCPredefines: () => swiftCPredefines,
|
|
54
55
|
swiftCodeMask: () => swiftCodeMask,
|
|
56
|
+
swiftCompileSdkOptions: () => swiftCompileSdkOptions,
|
|
55
57
|
swiftDistributionAt: () => swiftDistributionAt,
|
|
56
58
|
swiftIcuAsset: () => swiftIcuAsset,
|
|
57
59
|
swiftImportNames: () => swiftImportNames,
|
|
58
60
|
swiftMacroPlugins: () => swiftMacroPlugins,
|
|
59
61
|
swiftModuleDigest: () => swiftModuleDigest,
|
|
60
62
|
swiftModuleInputFiles: () => swiftModuleInputFiles,
|
|
63
|
+
swiftModuleInterface: () => swiftModuleInterface,
|
|
61
64
|
swiftModuleSdk: () => swiftModuleSdk,
|
|
62
65
|
swiftPeachModules: () => swiftPeachModules,
|
|
63
66
|
swiftProjectBuildKey: () => swiftProjectBuildKey,
|
|
@@ -74,11 +77,11 @@ __export(swift_compile_exports, {
|
|
|
74
77
|
writeSwiftProject: () => writeSwiftProject
|
|
75
78
|
});
|
|
76
79
|
module.exports = __toCommonJS(swift_compile_exports);
|
|
77
|
-
var
|
|
78
|
-
var
|
|
79
|
-
var
|
|
80
|
-
var
|
|
81
|
-
var
|
|
80
|
+
var import_node_child_process9 = require("node:child_process");
|
|
81
|
+
var import_node_crypto7 = require("node:crypto");
|
|
82
|
+
var import_node_fs10 = require("node:fs");
|
|
83
|
+
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
84
|
+
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
82
85
|
|
|
83
86
|
// src/admitted-mac-build.ts
|
|
84
87
|
var import_node_child_process = require("node:child_process");
|
|
@@ -110,7 +113,7 @@ function admittedMacBuilderSlot(env = process.env) {
|
|
|
110
113
|
|
|
111
114
|
// src/generated/swift-c-predefines.json
|
|
112
115
|
var swift_c_predefines_default = {
|
|
113
|
-
release: "swift-6.4.0-RELEASE-custom-
|
|
116
|
+
release: "swift-6.4.0-RELEASE-custom-81b2c791c27276bf",
|
|
114
117
|
languages: {
|
|
115
118
|
c: {
|
|
116
119
|
TARGET_IPHONE_SIMULATOR: "1",
|
|
@@ -2158,10 +2161,13 @@ var swift_c_predefines_default = {
|
|
|
2158
2161
|
var import_node_os = require("node:os");
|
|
2159
2162
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
2160
2163
|
var PEACH_HOME_ENV = "PEACH_HOME";
|
|
2164
|
+
function ambientHomeDir() {
|
|
2165
|
+
return import_node_path.default.join((0, import_node_os.homedir)(), ".peach");
|
|
2166
|
+
}
|
|
2161
2167
|
function rnxHomeDir() {
|
|
2162
2168
|
const override = process.env[PEACH_HOME_ENV];
|
|
2163
2169
|
if (override && override.length > 0) return import_node_path.default.resolve(override);
|
|
2164
|
-
return
|
|
2170
|
+
return ambientHomeDir();
|
|
2165
2171
|
}
|
|
2166
2172
|
function cacheDir() {
|
|
2167
2173
|
return import_node_path.default.join(rnxHomeDir(), "cache");
|
|
@@ -2864,9 +2870,9 @@ var EXCERPT = /^(\s*)(\d+)( \| )(.*)$/;
|
|
|
2864
2870
|
var MARKER = /^(\s*)( \| )(.*)$/;
|
|
2865
2871
|
function designTimeDiagnostic(output, files) {
|
|
2866
2872
|
const rewritten = /* @__PURE__ */ new Map();
|
|
2867
|
-
const linesOf = (
|
|
2873
|
+
const linesOf = (path14) => {
|
|
2868
2874
|
const file = Object.keys(files).find(
|
|
2869
|
-
(name2) => name2.endsWith(".swift") && (
|
|
2875
|
+
(name2) => name2.endsWith(".swift") && (path14 === name2 || path14.endsWith(`/${name2}`))
|
|
2870
2876
|
);
|
|
2871
2877
|
if (file === void 0) return null;
|
|
2872
2878
|
let lines = rewritten.get(file);
|
|
@@ -2982,23 +2988,40 @@ function swiftSdkOptions() {
|
|
|
2982
2988
|
}
|
|
2983
2989
|
return [];
|
|
2984
2990
|
}
|
|
2985
|
-
var SWIFT_HOST_COMPILER_RELEASE = "swift-6.4.0-RELEASE-custom-
|
|
2986
|
-
var SWIFT_HOST_COMPILER_ID = "
|
|
2991
|
+
var SWIFT_HOST_COMPILER_RELEASE = "swift-6.4.0-RELEASE-custom-81b2c791c27276bf";
|
|
2992
|
+
var SWIFT_HOST_COMPILER_ID = "81b2c791c27276bf";
|
|
2987
2993
|
var compilerArchives = {
|
|
2988
|
-
"swift-6.4.0-RELEASE-custom-
|
|
2989
|
-
identity: "
|
|
2994
|
+
"swift-6.4.0-RELEASE-custom-0b2d0a9011c88e66": {
|
|
2995
|
+
identity: "0b2d0a9011c88e66",
|
|
2996
|
+
hosts: {
|
|
2997
|
+
"darwin-arm64": {
|
|
2998
|
+
checksum: "dc6a494227297ea657e8e5f7c5b4a861cb5e142bdbcfcb028ace2aeb19db90cc",
|
|
2999
|
+
manifest: "d8e9eee0fb9b847f1e9350525d6c68606df46101745f553332309ed026b3c26a"
|
|
3000
|
+
},
|
|
3001
|
+
"linux-x64": {
|
|
3002
|
+
checksum: "85c04b4496aea1657c21a47f448e01d6ccc1c7920d130a566db37fb8350a7be2",
|
|
3003
|
+
manifest: "8451659e74235ad53b700c1afbe293512197900eb98cb1f79e36df2f5c85d511"
|
|
3004
|
+
},
|
|
3005
|
+
"linux-arm64": {
|
|
3006
|
+
checksum: "196606ed62c5c926d18e6ef0769cb1ab21c9943f9084070ddf14a7bc696768b8",
|
|
3007
|
+
manifest: "85fb8d5b6527bd75003a6dbd25b68b22540665cf9df9b13f41f82e5d8acdbf1d"
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
},
|
|
3011
|
+
"swift-6.4.0-RELEASE-custom-f7c03c3f59ec5d83": {
|
|
3012
|
+
identity: "f7c03c3f59ec5d83",
|
|
2990
3013
|
hosts: {
|
|
2991
3014
|
"darwin-arm64": {
|
|
2992
|
-
checksum: "
|
|
2993
|
-
manifest: "
|
|
3015
|
+
checksum: "8946a2d4716d3b0784cef7a85a35f66537bd319c4c5a48c63457d607260df5c5",
|
|
3016
|
+
manifest: "2a7754e6e365bf71ae6b6aefbbd810123795c73d43fb902a8a972d009d72790f"
|
|
2994
3017
|
},
|
|
2995
3018
|
"linux-x64": {
|
|
2996
|
-
checksum: "
|
|
2997
|
-
manifest: "
|
|
3019
|
+
checksum: "5ffa3b54d54583c1d6a38b708693072db4d088ba4bf5966b17014c068b2db641",
|
|
3020
|
+
manifest: "1b23ea52c5570de4697481a54bd0b0a0bcd6b54feccb7b0bb940d3643dec82cb"
|
|
2998
3021
|
},
|
|
2999
3022
|
"linux-arm64": {
|
|
3000
|
-
checksum: "
|
|
3001
|
-
manifest: "
|
|
3023
|
+
checksum: "29b0b97b7b0db4475dbe55f7011e57f493fed9f3482a6705becebd8b68c90bab",
|
|
3024
|
+
manifest: "3fdab1132715f5899de1bb1d7ddcd52cf540295ab86586c72f49502f37a403a1"
|
|
3002
3025
|
}
|
|
3003
3026
|
}
|
|
3004
3027
|
},
|
|
@@ -3006,20 +3029,36 @@ var compilerArchives = {
|
|
|
3006
3029
|
identity: SWIFT_HOST_COMPILER_ID,
|
|
3007
3030
|
hosts: {
|
|
3008
3031
|
"darwin-arm64": {
|
|
3009
|
-
checksum: "
|
|
3010
|
-
manifest: "
|
|
3032
|
+
checksum: "bc51b83d9e2e01c9873875326544734486d3ff3a868d650379c304045e8838d3",
|
|
3033
|
+
manifest: "a26eb9cb4fbd1dbd7faac20cced1ec5e67745bd358aa1180cc4abc1a0d21d6e6"
|
|
3011
3034
|
},
|
|
3012
3035
|
"linux-x64": {
|
|
3013
|
-
checksum: "
|
|
3014
|
-
manifest: "
|
|
3036
|
+
checksum: "ea63bbdecae14ff8e9e3f535b521fedc65d51b31521c5d10cc332cb91882d058",
|
|
3037
|
+
manifest: "b22b321ce3eb3fe044fa2122484a15c061f262c45d88a05b3fbace0a5bf038b6"
|
|
3015
3038
|
},
|
|
3016
3039
|
"linux-arm64": {
|
|
3017
|
-
checksum: "
|
|
3018
|
-
manifest: "
|
|
3040
|
+
checksum: "3eef4ed57830908515d8def2882e312f7cabeea57ccda5b2a7585401ef98cc48",
|
|
3041
|
+
manifest: "cfab342b8090fa83a697a391a7563cba14b771c24f07e1f8e19977f913ac88be"
|
|
3019
3042
|
}
|
|
3020
3043
|
}
|
|
3021
3044
|
}
|
|
3022
3045
|
};
|
|
3046
|
+
var SWIFT_PRIVATE_DISTRIBUTION_ENV = "PEACH_SWIFT_PRIVATE_DISTRIBUTION";
|
|
3047
|
+
function privateSwiftDistributionRoot() {
|
|
3048
|
+
const root = process.env[SWIFT_PRIVATE_DISTRIBUTION_ENV]?.trim();
|
|
3049
|
+
return root ? import_node_path4.default.resolve(root) : null;
|
|
3050
|
+
}
|
|
3051
|
+
function privateSwiftRelease() {
|
|
3052
|
+
const root = privateSwiftDistributionRoot();
|
|
3053
|
+
if (!root) return null;
|
|
3054
|
+
const manifest = JSON.parse(
|
|
3055
|
+
import_node_fs3.default.readFileSync(import_node_path4.default.join(root, "distribution.json"), "utf8")
|
|
3056
|
+
);
|
|
3057
|
+
const release = manifest && typeof manifest === "object" && Reflect.get(manifest, "release");
|
|
3058
|
+
if (typeof release !== "string")
|
|
3059
|
+
throw new Error(`${root} holds no Swift distribution release`);
|
|
3060
|
+
return release;
|
|
3061
|
+
}
|
|
3023
3062
|
function swiftHostCompilerArchive(release, host2 = `${process.platform}-${process.arch}`) {
|
|
3024
3063
|
const compiler = compilerArchives[release];
|
|
3025
3064
|
if (!compiler) throw new Error(`unqualified host compiler ${release}`);
|
|
@@ -3067,6 +3106,14 @@ for arg in "$@"; do
|
|
|
3067
3106
|
rsp=\${arg#@}
|
|
3068
3107
|
awk 'BEGIN { RS = " "; ORS = " " } /^"-l/ { if (seen[$0]++) next } { print }' "$rsp" > "$rsp.dedup"
|
|
3069
3108
|
mv "$rsp.dedup" "$rsp"
|
|
3109
|
+
if [ "\${PEACH_DEFER_WASM_LINK:-}" = "1" ] && grep -q '"--start-lib"' "$rsp"; then
|
|
3110
|
+
cp "$rsp" ${JSON.stringify(import_node_path4.default.join(directory, ".peach-link.rsp"))}
|
|
3111
|
+
out=$(awk 'BEGIN { RS = " " } prev == "\\"'-o'\\"" { gsub(/^"|"[[:space:]]*$/, ""); print; exit } { prev = $0 }' "$rsp")
|
|
3112
|
+
if [ -n "$out" ]; then
|
|
3113
|
+
printf '\\000asm\\001\\000\\000\\000' > "$out"
|
|
3114
|
+
exit 0
|
|
3115
|
+
fi
|
|
3116
|
+
fi
|
|
3070
3117
|
;;
|
|
3071
3118
|
esac
|
|
3072
3119
|
done
|
|
@@ -3084,15 +3131,20 @@ function peachHome() {
|
|
|
3084
3131
|
return override ? import_node_path4.default.resolve(override) : import_node_path4.default.join(import_node_os3.default.homedir(), ".peach");
|
|
3085
3132
|
}
|
|
3086
3133
|
var scratch;
|
|
3134
|
+
var linuxLibraryPath;
|
|
3087
3135
|
function swiftEnvironment(base = process.env) {
|
|
3088
|
-
if (!scratch) return base;
|
|
3089
3136
|
return {
|
|
3090
3137
|
...base,
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3138
|
+
...linuxLibraryPath ? {
|
|
3139
|
+
LD_LIBRARY_PATH: [linuxLibraryPath, base.LD_LIBRARY_PATH].filter(Boolean).join(":")
|
|
3140
|
+
} : {},
|
|
3141
|
+
...scratch ? {
|
|
3142
|
+
TMPDIR: scratch.directory,
|
|
3143
|
+
XDG_CONFIG_HOME: import_node_path4.default.join(scratch.home, ".config"),
|
|
3144
|
+
XDG_CACHE_HOME: import_node_path4.default.join(scratch.home, ".cache"),
|
|
3145
|
+
XDG_DATA_HOME: import_node_path4.default.join(scratch.home, ".local", "share"),
|
|
3146
|
+
...process.platform === "linux" ? { HOME: scratch.home } : {}
|
|
3147
|
+
} : {}
|
|
3096
3148
|
};
|
|
3097
3149
|
}
|
|
3098
3150
|
function swiftSourceSdk(root) {
|
|
@@ -3227,8 +3279,11 @@ function swiftFileChecksum(file) {
|
|
|
3227
3279
|
return hash.digest("hex");
|
|
3228
3280
|
}
|
|
3229
3281
|
function verifySwiftHostCompiler(release, root) {
|
|
3230
|
-
const pin = swiftHostCompilerArchive(release);
|
|
3231
3282
|
const file = import_node_path4.default.join(root, "compiler.json");
|
|
3283
|
+
const pin = release === privateSwiftRelease() ? {
|
|
3284
|
+
identity: release.replace(/^.*-custom-/, ""),
|
|
3285
|
+
manifest: swiftFileChecksum(file)
|
|
3286
|
+
} : swiftHostCompilerArchive(release);
|
|
3232
3287
|
if (swiftFileChecksum(file) !== pin.manifest)
|
|
3233
3288
|
throw new Error(`Swift compiler manifest mismatch at ${root}`);
|
|
3234
3289
|
const manifest = JSON.parse(import_node_fs3.default.readFileSync(file, "utf8"));
|
|
@@ -3279,6 +3334,8 @@ function swiftInstallSteps(release, wasmSdk) {
|
|
|
3279
3334
|
].join("\n");
|
|
3280
3335
|
}
|
|
3281
3336
|
function swiftCompilerInstall(release) {
|
|
3337
|
+
if (release === privateSwiftRelease())
|
|
3338
|
+
return { note: " (private: its builder installs it)", commands: [] };
|
|
3282
3339
|
if (release.includes("-custom-")) {
|
|
3283
3340
|
const archive = swiftHostCompilerArchive(release);
|
|
3284
3341
|
const directory = import_node_path4.default.resolve(swiftToolchainBin(release), "../..");
|
|
@@ -3429,12 +3486,7 @@ function icuSegment(object) {
|
|
|
3429
3486
|
// src/swift-link-roots.ts
|
|
3430
3487
|
var import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
3431
3488
|
var import_node_path6 = __toESM(require("node:path"), 1);
|
|
3432
|
-
var OBJC_SEGMENTS = [
|
|
3433
|
-
"__objc_classes",
|
|
3434
|
-
"__objc_protocols",
|
|
3435
|
-
"__objc_cats",
|
|
3436
|
-
"__objc_class_aliases"
|
|
3437
|
-
];
|
|
3489
|
+
var OBJC_SEGMENTS = ["__objc_cats", "__objc_class_aliases"];
|
|
3438
3490
|
var leb = (bytes, at) => {
|
|
3439
3491
|
let value = 0;
|
|
3440
3492
|
let scale = 1;
|
|
@@ -3449,6 +3501,7 @@ function objcSegmentSizes(bytes) {
|
|
|
3449
3501
|
const at = { offset: 8 };
|
|
3450
3502
|
const names = [];
|
|
3451
3503
|
const sizes = [];
|
|
3504
|
+
let hasExportedSymbol = false;
|
|
3452
3505
|
while (at.offset < bytes.length) {
|
|
3453
3506
|
const id = bytes[at.offset++];
|
|
3454
3507
|
const size = leb(bytes, at);
|
|
@@ -3473,6 +3526,31 @@ function objcSegmentSizes(bytes) {
|
|
|
3473
3526
|
leb(bytes, at);
|
|
3474
3527
|
leb(bytes, at);
|
|
3475
3528
|
}
|
|
3529
|
+
} else if (kind === 8) {
|
|
3530
|
+
for (let count = leb(bytes, at); count > 0; count--) {
|
|
3531
|
+
const symKind = bytes[at.offset++];
|
|
3532
|
+
const flags = leb(bytes, at);
|
|
3533
|
+
const isUndef = (flags & 16) !== 0;
|
|
3534
|
+
const isExplicitName = (flags & 64) !== 0;
|
|
3535
|
+
if (!isUndef && (flags & 32) !== 0) hasExportedSymbol = true;
|
|
3536
|
+
if (symKind === 0 || symKind === 2 || symKind === 4 || symKind === 5) {
|
|
3537
|
+
leb(bytes, at);
|
|
3538
|
+
if (!isUndef || isExplicitName) {
|
|
3539
|
+
const sLen = leb(bytes, at);
|
|
3540
|
+
at.offset += sLen;
|
|
3541
|
+
}
|
|
3542
|
+
} else if (symKind === 1) {
|
|
3543
|
+
const sLen = leb(bytes, at);
|
|
3544
|
+
at.offset += sLen;
|
|
3545
|
+
if (!isUndef) {
|
|
3546
|
+
leb(bytes, at);
|
|
3547
|
+
leb(bytes, at);
|
|
3548
|
+
leb(bytes, at);
|
|
3549
|
+
}
|
|
3550
|
+
} else if (symKind === 3) {
|
|
3551
|
+
leb(bytes, at);
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3476
3554
|
}
|
|
3477
3555
|
at.offset = next;
|
|
3478
3556
|
}
|
|
@@ -3498,6 +3576,7 @@ function objcSegmentSizes(bytes) {
|
|
|
3498
3576
|
if (OBJC_SEGMENTS.includes(name2))
|
|
3499
3577
|
result.set(name2, (result.get(name2) ?? 0) + (sizes[index] ?? 0));
|
|
3500
3578
|
});
|
|
3579
|
+
result.set("__wasm_exported", hasExportedSymbol ? 1 : 0);
|
|
3501
3580
|
return result;
|
|
3502
3581
|
}
|
|
3503
3582
|
var rootsByDistribution = /* @__PURE__ */ new Map();
|
|
@@ -3513,7 +3592,7 @@ function swiftObjcRootObjects(id, root, objects) {
|
|
|
3513
3592
|
empty.set(name2, Math.min(empty.get(name2) ?? size, size));
|
|
3514
3593
|
const roots = new Set(
|
|
3515
3594
|
measured.filter(
|
|
3516
|
-
([, sizes]) => [...sizes].some(([name2, size]) => size > (empty.get(name2) ?? 0))
|
|
3595
|
+
([object, sizes]) => object !== "lib/Foundation-NSStringFormatting.o" && object !== "lib/FoundationNetworking-Session.o" && [...sizes].some(([name2, size]) => size > (empty.get(name2) ?? 0))
|
|
3517
3596
|
).map(([object]) => object)
|
|
3518
3597
|
);
|
|
3519
3598
|
rootsByDistribution.set(id, roots);
|
|
@@ -4132,6 +4211,9 @@ function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
|
|
|
4132
4211
|
// the installed icu archive exports its swift_-prefixed names, which the
|
|
4133
4212
|
// unicode headers rename to only off darwin.
|
|
4134
4213
|
"-DU_DISABLE_RENAMING=0",
|
|
4214
|
+
// clang enables blocks in every language for darwin targets, and the sdk
|
|
4215
|
+
// headers declare block types unguarded.
|
|
4216
|
+
"-fblocks",
|
|
4135
4217
|
...WASI_EMULATION_FLAGS,
|
|
4136
4218
|
"-iframework",
|
|
4137
4219
|
import_node_path9.default.join(headers, "System/Library/Frameworks"),
|
|
@@ -4341,16 +4423,1448 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
4341
4423
|
}
|
|
4342
4424
|
|
|
4343
4425
|
// src/swift-shared-sdk.ts
|
|
4344
|
-
var
|
|
4426
|
+
var import_node_child_process7 = require("node:child_process");
|
|
4427
|
+
var import_node_crypto5 = require("node:crypto");
|
|
4428
|
+
var import_node_fs7 = __toESM(require("node:fs"), 1);
|
|
4345
4429
|
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
4346
4430
|
function swiftSharedSdkRoot(moduleRoot, distribution) {
|
|
4347
4431
|
return import_node_path11.default.resolve(moduleRoot, distribution ? "sdk/ios" : "../peachsim/sdk/ios");
|
|
4348
4432
|
}
|
|
4433
|
+
var sdkViews = /* @__PURE__ */ new Map();
|
|
4434
|
+
function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk) {
|
|
4435
|
+
const frameworks = import_node_path11.default.join(
|
|
4436
|
+
swiftSharedSdkRoot(moduleRoot, distribution),
|
|
4437
|
+
"System/Library/Frameworks"
|
|
4438
|
+
);
|
|
4439
|
+
const key = JSON.stringify([toolchainBin, sdk, frameworks, swiftSdkOptions()]);
|
|
4440
|
+
const cached = sdkViews.get(key);
|
|
4441
|
+
if (cached) return cached;
|
|
4442
|
+
const configuration = (0, import_node_child_process7.execFileSync)(
|
|
4443
|
+
import_node_path11.default.join(toolchainBin, "swift"),
|
|
4444
|
+
[
|
|
4445
|
+
"sdk",
|
|
4446
|
+
"configure",
|
|
4447
|
+
...swiftSdkOptions(),
|
|
4448
|
+
"--show-configuration",
|
|
4449
|
+
sdk,
|
|
4450
|
+
"wasm32-unknown-wasip1"
|
|
4451
|
+
],
|
|
4452
|
+
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
4453
|
+
);
|
|
4454
|
+
const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim();
|
|
4455
|
+
if (!sysroot || !import_node_path11.default.isAbsolute(sysroot))
|
|
4456
|
+
throw new Error(`swift sdk ${sdk} reports no absolute sdkRootPath`);
|
|
4457
|
+
let bundle = sysroot;
|
|
4458
|
+
while (!bundle.endsWith(".artifactbundle")) {
|
|
4459
|
+
if (import_node_path11.default.dirname(bundle) === bundle)
|
|
4460
|
+
throw new Error(`swift sdk ${sdk} is outside an artifact bundle`);
|
|
4461
|
+
bundle = import_node_path11.default.dirname(bundle);
|
|
4462
|
+
}
|
|
4463
|
+
const view = import_node_path11.default.join(
|
|
4464
|
+
swiftCacheDir(),
|
|
4465
|
+
"swift-sdk-views",
|
|
4466
|
+
(0, import_node_crypto5.createHash)("sha256").update(key).digest("hex").slice(0, 16)
|
|
4467
|
+
);
|
|
4468
|
+
if (!import_node_fs7.default.existsSync(view)) {
|
|
4469
|
+
import_node_fs7.default.mkdirSync(import_node_path11.default.dirname(view), { recursive: true });
|
|
4470
|
+
const staging = import_node_fs7.default.mkdtempSync(`${view}-`);
|
|
4471
|
+
const segments = [
|
|
4472
|
+
import_node_path11.default.basename(bundle),
|
|
4473
|
+
...import_node_path11.default.relative(bundle, import_node_path11.default.join(sysroot, "darwin/System/Library")).split(import_node_path11.default.sep),
|
|
4474
|
+
"Frameworks"
|
|
4475
|
+
];
|
|
4476
|
+
let real = import_node_path11.default.dirname(bundle);
|
|
4477
|
+
let mirror = staging;
|
|
4478
|
+
for (const segment of segments) {
|
|
4479
|
+
for (const entry of (0, import_node_fs7.readdirSync)(real))
|
|
4480
|
+
if (entry !== segment)
|
|
4481
|
+
import_node_fs7.default.symlinkSync(import_node_path11.default.join(real, entry), import_node_path11.default.join(mirror, entry));
|
|
4482
|
+
real = import_node_path11.default.join(real, segment);
|
|
4483
|
+
mirror = import_node_path11.default.join(mirror, segment);
|
|
4484
|
+
if (segment !== "Frameworks") import_node_fs7.default.mkdirSync(mirror);
|
|
4485
|
+
}
|
|
4486
|
+
import_node_fs7.default.symlinkSync(frameworks, mirror);
|
|
4487
|
+
try {
|
|
4488
|
+
import_node_fs7.default.renameSync(staging, view);
|
|
4489
|
+
} catch (error) {
|
|
4490
|
+
import_node_fs7.default.rmSync(staging, { recursive: true, force: true });
|
|
4491
|
+
if (!import_node_fs7.default.existsSync(view)) throw error;
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4494
|
+
const options = ["--swift-sdks-path", view];
|
|
4495
|
+
sdkViews.set(key, options);
|
|
4496
|
+
return options;
|
|
4497
|
+
}
|
|
4349
4498
|
function swiftSharedSdkInputFiles(moduleRoot) {
|
|
4350
4499
|
const root = swiftSharedSdkRoot(moduleRoot, false);
|
|
4351
4500
|
return (0, import_node_fs7.readdirSync)(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => import_node_path11.default.relative(moduleRoot, import_node_path11.default.join(entry.parentPath, entry.name))).sort();
|
|
4352
4501
|
}
|
|
4353
4502
|
|
|
4503
|
+
// src/swift-wasm-prune.ts
|
|
4504
|
+
var import_node_child_process8 = require("node:child_process");
|
|
4505
|
+
var import_node_crypto6 = require("node:crypto");
|
|
4506
|
+
var import_node_fs8 = __toESM(require("node:fs"), 1);
|
|
4507
|
+
var import_node_os4 = __toESM(require("node:os"), 1);
|
|
4508
|
+
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
4509
|
+
function readULEB(b, o) {
|
|
4510
|
+
let res = 0;
|
|
4511
|
+
let shift = 0;
|
|
4512
|
+
let p = o;
|
|
4513
|
+
while (true) {
|
|
4514
|
+
const byte = b[p++];
|
|
4515
|
+
res |= (byte & 127) << shift;
|
|
4516
|
+
if ((byte & 128) === 0) break;
|
|
4517
|
+
shift += 7;
|
|
4518
|
+
}
|
|
4519
|
+
return [res, p];
|
|
4520
|
+
}
|
|
4521
|
+
function readSLEB(b, o) {
|
|
4522
|
+
let res = 0;
|
|
4523
|
+
let shift = 0;
|
|
4524
|
+
let p = o;
|
|
4525
|
+
let byte = 0;
|
|
4526
|
+
do {
|
|
4527
|
+
byte = b[p++];
|
|
4528
|
+
res |= (byte & 127) << shift;
|
|
4529
|
+
shift += 7;
|
|
4530
|
+
} while (byte & 128);
|
|
4531
|
+
if (shift < 32 && byte & 64) res |= ~0 << shift;
|
|
4532
|
+
return [res, p];
|
|
4533
|
+
}
|
|
4534
|
+
function encodeULEB(val) {
|
|
4535
|
+
const out = [];
|
|
4536
|
+
do {
|
|
4537
|
+
let byte = val & 127;
|
|
4538
|
+
val >>>= 7;
|
|
4539
|
+
if (val !== 0) byte |= 128;
|
|
4540
|
+
out.push(byte);
|
|
4541
|
+
} while (val !== 0);
|
|
4542
|
+
return out;
|
|
4543
|
+
}
|
|
4544
|
+
var HAS_ADDEND = /* @__PURE__ */ new Set([3, 4, 5, 8, 9, 11, 13, 14, 15, 16, 21, 22, 23, 24, 25]);
|
|
4545
|
+
var ROOT_SEG_PREFIXES = [
|
|
4546
|
+
".init_array",
|
|
4547
|
+
"__objc_init_func",
|
|
4548
|
+
"__objc_classes",
|
|
4549
|
+
"__objc_cats",
|
|
4550
|
+
"__objc_class_aliases",
|
|
4551
|
+
"objc_clsrolist",
|
|
4552
|
+
"swift5_protocols",
|
|
4553
|
+
"swift5_protocol_conformances",
|
|
4554
|
+
"swift5_type_metadata",
|
|
4555
|
+
"swift5_type_metadata_2",
|
|
4556
|
+
"swift5_replace",
|
|
4557
|
+
"swift5_replac2",
|
|
4558
|
+
"swift5_accessible_functions",
|
|
4559
|
+
"swift5_entry"
|
|
4560
|
+
];
|
|
4561
|
+
function isRootSegName(name2) {
|
|
4562
|
+
for (const pref of ROOT_SEG_PREFIXES) {
|
|
4563
|
+
if (name2 === pref || name2.startsWith(`${pref}.`)) return true;
|
|
4564
|
+
}
|
|
4565
|
+
return false;
|
|
4566
|
+
}
|
|
4567
|
+
var PARTITIONED_SEGS = /* @__PURE__ */ new Set([
|
|
4568
|
+
".rodata",
|
|
4569
|
+
".data",
|
|
4570
|
+
".data.rel.ro",
|
|
4571
|
+
"swift5_capture",
|
|
4572
|
+
"swift5_fieldmd",
|
|
4573
|
+
"swift5_assocty",
|
|
4574
|
+
"swift5_typeref",
|
|
4575
|
+
"swift5_builtin",
|
|
4576
|
+
"swift5_mpenum"
|
|
4577
|
+
]);
|
|
4578
|
+
var PRUNED_SDK_ARCHIVES = /* @__PURE__ */ new Set([
|
|
4579
|
+
"libFoundation",
|
|
4580
|
+
"lib_FoundationCollections",
|
|
4581
|
+
"libswift_StringProcessing",
|
|
4582
|
+
"libswift_RegexParser",
|
|
4583
|
+
"libswiftObservation",
|
|
4584
|
+
"libswiftSynchronization",
|
|
4585
|
+
"libswiftCxx",
|
|
4586
|
+
"libswiftCxxStdlib",
|
|
4587
|
+
"libswiftWASILibc",
|
|
4588
|
+
"libswift_Builtin_float",
|
|
4589
|
+
"libObjectiveC"
|
|
4590
|
+
]);
|
|
4591
|
+
var OMIT_SDK_LIB_FLAGS = /* @__PURE__ */ new Set([
|
|
4592
|
+
...[...PRUNED_SDK_ARCHIVES].map((a) => `-l${a.slice(3)}`),
|
|
4593
|
+
"-lswiftCore",
|
|
4594
|
+
"-lswift_Concurrency"
|
|
4595
|
+
]);
|
|
4596
|
+
var NEUTRALIZED_SWIFTRT_SECTIONS = /* @__PURE__ */ new Set([
|
|
4597
|
+
"swift5_tests",
|
|
4598
|
+
"swift5_runtime_attributes",
|
|
4599
|
+
"swift5_mpenum",
|
|
4600
|
+
"swift5_capture",
|
|
4601
|
+
"swift5_builtin",
|
|
4602
|
+
"swift5_assocty",
|
|
4603
|
+
"swift5_fieldmd",
|
|
4604
|
+
"swift5_reflstr",
|
|
4605
|
+
"swift5_typeref"
|
|
4606
|
+
]);
|
|
4607
|
+
var parsedObjectCache = /* @__PURE__ */ new Map();
|
|
4608
|
+
function readArMembers(buf) {
|
|
4609
|
+
if (buf.length < 8) return [];
|
|
4610
|
+
const magic = Buffer.from(buf.subarray(0, 8)).toString("ascii");
|
|
4611
|
+
if (magic !== "!<arch>\n") return [];
|
|
4612
|
+
const out = [];
|
|
4613
|
+
let gnuNames = null;
|
|
4614
|
+
let pos = 8;
|
|
4615
|
+
while (pos + 60 <= buf.length) {
|
|
4616
|
+
const rawName = Buffer.from(buf.subarray(pos, pos + 16)).toString("ascii");
|
|
4617
|
+
const sizeStr = Buffer.from(buf.subarray(pos + 48, pos + 58)).toString("ascii").trim();
|
|
4618
|
+
const size = Number.parseInt(sizeStr, 10);
|
|
4619
|
+
pos += 60;
|
|
4620
|
+
if (Number.isNaN(size) || pos + size > buf.length) break;
|
|
4621
|
+
let bodyStart = pos;
|
|
4622
|
+
const bodyEnd = pos + size;
|
|
4623
|
+
let name2 = rawName.trim();
|
|
4624
|
+
if (rawName.startsWith("#1/")) {
|
|
4625
|
+
const nLen = Number.parseInt(rawName.slice(3).trim(), 10);
|
|
4626
|
+
name2 = Buffer.from(buf.subarray(bodyStart, bodyStart + nLen)).toString("utf8").replace(/\0+$/, "");
|
|
4627
|
+
bodyStart += nLen;
|
|
4628
|
+
} else if (rawName.startsWith("//")) {
|
|
4629
|
+
gnuNames = buf.subarray(bodyStart, bodyEnd);
|
|
4630
|
+
pos = bodyEnd + (size & 1);
|
|
4631
|
+
continue;
|
|
4632
|
+
} else if (rawName.startsWith("/") && gnuNames) {
|
|
4633
|
+
const offStr = rawName.slice(1).trim();
|
|
4634
|
+
if (offStr.length > 0 && /^\d+$/.test(offStr)) {
|
|
4635
|
+
const off = Number.parseInt(offStr, 10);
|
|
4636
|
+
let end = off;
|
|
4637
|
+
while (end < gnuNames.length && gnuNames[end] !== 10 && gnuNames[end] !== 47) {
|
|
4638
|
+
end++;
|
|
4639
|
+
}
|
|
4640
|
+
name2 = Buffer.from(gnuNames.subarray(off, end)).toString("utf8");
|
|
4641
|
+
} else {
|
|
4642
|
+
pos = bodyEnd + (size & 1);
|
|
4643
|
+
continue;
|
|
4644
|
+
}
|
|
4645
|
+
} else if (name2.endsWith("/")) {
|
|
4646
|
+
name2 = name2.slice(0, -1);
|
|
4647
|
+
}
|
|
4648
|
+
const bytes = buf.subarray(bodyStart, bodyEnd);
|
|
4649
|
+
if (bytes.length >= 8 && bytes[0] === 0 && bytes[1] === 97 && bytes[2] === 115 && bytes[3] === 109) {
|
|
4650
|
+
out.push({ name: name2, bytes });
|
|
4651
|
+
}
|
|
4652
|
+
pos = bodyEnd + (size & 1);
|
|
4653
|
+
}
|
|
4654
|
+
return out;
|
|
4655
|
+
}
|
|
4656
|
+
function patchSwiftrtObject(src) {
|
|
4657
|
+
const buf = new Uint8Array(src);
|
|
4658
|
+
const neutralizedSyms = /* @__PURE__ */ new Set();
|
|
4659
|
+
let fallbackSymIdx = 2;
|
|
4660
|
+
let pos = 8;
|
|
4661
|
+
while (pos < buf.length) {
|
|
4662
|
+
const id = buf[pos++];
|
|
4663
|
+
const [sz, p] = readULEB(buf, pos);
|
|
4664
|
+
const end = p + sz;
|
|
4665
|
+
if (id === 0) {
|
|
4666
|
+
const [nLen, np] = readULEB(buf, p);
|
|
4667
|
+
const name2 = Buffer.from(buf.subarray(np, np + nLen)).toString("utf8");
|
|
4668
|
+
const cp = np + nLen;
|
|
4669
|
+
if (name2 === "linking") {
|
|
4670
|
+
let [, lp] = readULEB(buf, cp);
|
|
4671
|
+
while (lp < end) {
|
|
4672
|
+
const subId = buf[lp++];
|
|
4673
|
+
const [subLen, sp] = readULEB(buf, lp);
|
|
4674
|
+
const subEnd = sp + subLen;
|
|
4675
|
+
if (subId === 8) {
|
|
4676
|
+
let [cnt, cur] = readULEB(buf, sp);
|
|
4677
|
+
for (let i = 0; i < cnt; i++) {
|
|
4678
|
+
const kind = buf[cur++];
|
|
4679
|
+
const [fl, c2] = readULEB(buf, cur);
|
|
4680
|
+
cur = c2;
|
|
4681
|
+
const isUndef = (fl & 16) !== 0;
|
|
4682
|
+
const isExplicitName = (fl & 64) !== 0;
|
|
4683
|
+
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
4684
|
+
const [, c3] = readULEB(buf, cur);
|
|
4685
|
+
cur = c3;
|
|
4686
|
+
if (!isUndef || isExplicitName) {
|
|
4687
|
+
const [sLen, c4] = readULEB(buf, cur);
|
|
4688
|
+
cur = c4 + sLen;
|
|
4689
|
+
}
|
|
4690
|
+
} else if (kind === 1) {
|
|
4691
|
+
const [sLen, c3] = readULEB(buf, cur);
|
|
4692
|
+
const sName = Buffer.from(buf.subarray(c3, c3 + sLen)).toString("utf8");
|
|
4693
|
+
if (sName === "_ZN12_GLOBAL__N_18sectionsE") fallbackSymIdx = i;
|
|
4694
|
+
for (const prefix of ["__start_", "__stop_"]) {
|
|
4695
|
+
if (sName.startsWith(prefix) && NEUTRALIZED_SWIFTRT_SECTIONS.has(sName.slice(prefix.length))) {
|
|
4696
|
+
buf[c3] = 120;
|
|
4697
|
+
neutralizedSyms.add(i);
|
|
4698
|
+
}
|
|
4699
|
+
}
|
|
4700
|
+
cur = c3 + sLen;
|
|
4701
|
+
if (!isUndef) {
|
|
4702
|
+
const [, c4] = readULEB(buf, cur);
|
|
4703
|
+
const [, c5] = readULEB(buf, c4);
|
|
4704
|
+
const [, c6] = readULEB(buf, c5);
|
|
4705
|
+
cur = c6;
|
|
4706
|
+
}
|
|
4707
|
+
} else if (kind === 3) {
|
|
4708
|
+
const [, c3] = readULEB(buf, cur);
|
|
4709
|
+
cur = c3;
|
|
4710
|
+
}
|
|
4711
|
+
}
|
|
4712
|
+
}
|
|
4713
|
+
lp = subEnd;
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4716
|
+
}
|
|
4717
|
+
pos = end;
|
|
4718
|
+
}
|
|
4719
|
+
pos = 8;
|
|
4720
|
+
while (pos < buf.length) {
|
|
4721
|
+
const id = buf[pos++];
|
|
4722
|
+
const [sz, p] = readULEB(buf, pos);
|
|
4723
|
+
const end = p + sz;
|
|
4724
|
+
if (id === 0) {
|
|
4725
|
+
const [nLen, np] = readULEB(buf, p);
|
|
4726
|
+
const name2 = Buffer.from(buf.subarray(np, np + nLen)).toString("utf8");
|
|
4727
|
+
const cp = np + nLen;
|
|
4728
|
+
if (name2 === "reloc.CODE") {
|
|
4729
|
+
const [, r1] = readULEB(buf, cp);
|
|
4730
|
+
let [cnt, cur] = readULEB(buf, r1);
|
|
4731
|
+
for (let i = 0; i < cnt; i++) {
|
|
4732
|
+
const rType = buf[cur++];
|
|
4733
|
+
const [, c2] = readULEB(buf, cur);
|
|
4734
|
+
const [rs, c3] = readULEB(buf, c2);
|
|
4735
|
+
if (neutralizedSyms.has(rs) && c3 - c2 === 1) {
|
|
4736
|
+
buf[c2] = fallbackSymIdx;
|
|
4737
|
+
}
|
|
4738
|
+
cur = c3;
|
|
4739
|
+
if (HAS_ADDEND.has(rType)) {
|
|
4740
|
+
const [, c4] = readSLEB(buf, cur);
|
|
4741
|
+
cur = c4;
|
|
4742
|
+
}
|
|
4743
|
+
}
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
pos = end;
|
|
4747
|
+
}
|
|
4748
|
+
return buf;
|
|
4749
|
+
}
|
|
4750
|
+
function parseWasmObjectBytes(file, buf, isDist) {
|
|
4751
|
+
let pos = 8;
|
|
4752
|
+
let numImportFuncs = 0;
|
|
4753
|
+
const importFuncNames = [];
|
|
4754
|
+
const importGlobalNames = [];
|
|
4755
|
+
const importTableNames = [];
|
|
4756
|
+
const importEventNames = [];
|
|
4757
|
+
let codeStart = 0;
|
|
4758
|
+
const fStarts = [];
|
|
4759
|
+
const fEnds = [];
|
|
4760
|
+
let dataStart = 0;
|
|
4761
|
+
const sStarts = [];
|
|
4762
|
+
const sEnds = [];
|
|
4763
|
+
const sPayloadStarts = [];
|
|
4764
|
+
const segNames = [];
|
|
4765
|
+
const segFlags = [];
|
|
4766
|
+
let symKind = new Uint8Array(0);
|
|
4767
|
+
let symFlags = new Uint32Array(0);
|
|
4768
|
+
let symElemIdx = new Int32Array(0);
|
|
4769
|
+
let symOff = new Int32Array(0);
|
|
4770
|
+
let symSz = new Int32Array(0);
|
|
4771
|
+
const symNames = [];
|
|
4772
|
+
const initFuncs = [];
|
|
4773
|
+
const rawCodeRelocs = [];
|
|
4774
|
+
const rawDataRelocs = [];
|
|
4775
|
+
while (pos < buf.length) {
|
|
4776
|
+
const id = buf[pos++];
|
|
4777
|
+
const [sz, p] = readULEB(buf, pos);
|
|
4778
|
+
const end = p + sz;
|
|
4779
|
+
if (id === 2) {
|
|
4780
|
+
let [cnt, cp] = readULEB(buf, p);
|
|
4781
|
+
for (let i = 0; i < cnt; i++) {
|
|
4782
|
+
const [mLen, m2] = readULEB(buf, cp);
|
|
4783
|
+
cp = m2 + mLen;
|
|
4784
|
+
const [fLen, f2] = readULEB(buf, cp);
|
|
4785
|
+
const fName = Buffer.from(buf.subarray(f2, f2 + fLen)).toString("utf8");
|
|
4786
|
+
cp = f2 + fLen;
|
|
4787
|
+
const kind = buf[cp++];
|
|
4788
|
+
if (kind === 0) {
|
|
4789
|
+
const [, c2] = readULEB(buf, cp);
|
|
4790
|
+
cp = c2;
|
|
4791
|
+
importFuncNames.push(fName);
|
|
4792
|
+
numImportFuncs++;
|
|
4793
|
+
} else if (kind === 1) {
|
|
4794
|
+
cp++;
|
|
4795
|
+
const [fl, c2] = readULEB(buf, cp);
|
|
4796
|
+
cp = c2;
|
|
4797
|
+
const [, c3] = readULEB(buf, cp);
|
|
4798
|
+
cp = c3;
|
|
4799
|
+
if (fl & 1) {
|
|
4800
|
+
const [, c4] = readULEB(buf, cp);
|
|
4801
|
+
cp = c4;
|
|
4802
|
+
}
|
|
4803
|
+
importTableNames.push(fName);
|
|
4804
|
+
} else if (kind === 2) {
|
|
4805
|
+
const [fl, c2] = readULEB(buf, cp);
|
|
4806
|
+
cp = c2;
|
|
4807
|
+
const [, c3] = readULEB(buf, cp);
|
|
4808
|
+
cp = c3;
|
|
4809
|
+
if (fl & 1) {
|
|
4810
|
+
const [, c4] = readULEB(buf, cp);
|
|
4811
|
+
cp = c4;
|
|
4812
|
+
}
|
|
4813
|
+
} else if (kind === 3) {
|
|
4814
|
+
cp += 2;
|
|
4815
|
+
importGlobalNames.push(fName);
|
|
4816
|
+
} else if (kind === 4) {
|
|
4817
|
+
cp++;
|
|
4818
|
+
const [, c2] = readULEB(buf, cp);
|
|
4819
|
+
cp = c2;
|
|
4820
|
+
importEventNames.push(fName);
|
|
4821
|
+
}
|
|
4822
|
+
}
|
|
4823
|
+
} else if (id === 10) {
|
|
4824
|
+
codeStart = p;
|
|
4825
|
+
let [cnt, cp] = readULEB(buf, p);
|
|
4826
|
+
for (let i = 0; i < cnt; i++) {
|
|
4827
|
+
const st = cp - codeStart;
|
|
4828
|
+
const [bLen, b2] = readULEB(buf, cp);
|
|
4829
|
+
cp = b2 + bLen;
|
|
4830
|
+
fStarts.push(st);
|
|
4831
|
+
fEnds.push(cp - codeStart);
|
|
4832
|
+
}
|
|
4833
|
+
} else if (id === 11) {
|
|
4834
|
+
dataStart = p;
|
|
4835
|
+
let [cnt, cp] = readULEB(buf, p);
|
|
4836
|
+
for (let i = 0; i < cnt; i++) {
|
|
4837
|
+
const st = cp - dataStart;
|
|
4838
|
+
const [mode, m2] = readULEB(buf, cp);
|
|
4839
|
+
cp = m2;
|
|
4840
|
+
if (mode === 2) {
|
|
4841
|
+
const [, m3] = readULEB(buf, cp);
|
|
4842
|
+
cp = m3;
|
|
4843
|
+
}
|
|
4844
|
+
if (mode === 0 || mode === 2) {
|
|
4845
|
+
const op = buf[cp++];
|
|
4846
|
+
if (op === 65 || op === 66) {
|
|
4847
|
+
const [, m4] = readSLEB(buf, cp);
|
|
4848
|
+
cp = m4;
|
|
4849
|
+
} else if (op === 35) {
|
|
4850
|
+
const [, m4] = readULEB(buf, cp);
|
|
4851
|
+
cp = m4;
|
|
4852
|
+
}
|
|
4853
|
+
cp++;
|
|
4854
|
+
}
|
|
4855
|
+
const [dLen, d2] = readULEB(buf, cp);
|
|
4856
|
+
sPayloadStarts.push(d2 - dataStart);
|
|
4857
|
+
cp = d2 + dLen;
|
|
4858
|
+
sStarts.push(st);
|
|
4859
|
+
sEnds.push(cp - dataStart);
|
|
4860
|
+
}
|
|
4861
|
+
} else if (id === 0) {
|
|
4862
|
+
const [nLen, np] = readULEB(buf, p);
|
|
4863
|
+
const name2 = Buffer.from(buf.subarray(np, np + nLen)).toString("utf8");
|
|
4864
|
+
const cp = np + nLen;
|
|
4865
|
+
if (name2 === "linking") {
|
|
4866
|
+
let [, lp] = readULEB(buf, cp);
|
|
4867
|
+
while (lp < end) {
|
|
4868
|
+
const subId = buf[lp++];
|
|
4869
|
+
const [subLen, sp] = readULEB(buf, lp);
|
|
4870
|
+
const subEnd = sp + subLen;
|
|
4871
|
+
if (subId === 5) {
|
|
4872
|
+
const [cnt, p2] = readULEB(buf, sp);
|
|
4873
|
+
let cur = p2;
|
|
4874
|
+
for (let i = 0; i < cnt; i++) {
|
|
4875
|
+
const [sLen, s2] = readULEB(buf, cur);
|
|
4876
|
+
segNames.push(Buffer.from(buf.subarray(s2, s2 + sLen)).toString("utf8"));
|
|
4877
|
+
cur = s2 + sLen;
|
|
4878
|
+
const [, s3] = readULEB(buf, cur);
|
|
4879
|
+
const [fl, s4] = readULEB(buf, s3);
|
|
4880
|
+
segFlags.push(fl);
|
|
4881
|
+
cur = s4;
|
|
4882
|
+
}
|
|
4883
|
+
} else if (subId === 6) {
|
|
4884
|
+
const [cnt, p2] = readULEB(buf, sp);
|
|
4885
|
+
let cur = p2;
|
|
4886
|
+
for (let i = 0; i < cnt; i++) {
|
|
4887
|
+
const [, s2] = readULEB(buf, cur);
|
|
4888
|
+
const [symIdx, s3] = readULEB(buf, s2);
|
|
4889
|
+
initFuncs.push(symIdx);
|
|
4890
|
+
cur = s3;
|
|
4891
|
+
}
|
|
4892
|
+
} else if (subId === 8) {
|
|
4893
|
+
const [cnt, p2] = readULEB(buf, sp);
|
|
4894
|
+
symKind = new Uint8Array(cnt);
|
|
4895
|
+
symFlags = new Uint32Array(cnt);
|
|
4896
|
+
symElemIdx = new Int32Array(cnt).fill(-1);
|
|
4897
|
+
symOff = new Int32Array(cnt).fill(0);
|
|
4898
|
+
symSz = new Int32Array(cnt).fill(0);
|
|
4899
|
+
let cur = p2;
|
|
4900
|
+
for (let i = 0; i < cnt; i++) {
|
|
4901
|
+
const kind = buf[cur++];
|
|
4902
|
+
const [fl, c2] = readULEB(buf, cur);
|
|
4903
|
+
cur = c2;
|
|
4904
|
+
symKind[i] = kind;
|
|
4905
|
+
symFlags[i] = fl;
|
|
4906
|
+
const isUndef = (fl & 16) !== 0;
|
|
4907
|
+
const isExplicitName = (fl & 64) !== 0;
|
|
4908
|
+
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
4909
|
+
const [el, c3] = readULEB(buf, cur);
|
|
4910
|
+
cur = c3;
|
|
4911
|
+
if (!isUndef && kind === 0) symElemIdx[i] = el;
|
|
4912
|
+
let sName = "";
|
|
4913
|
+
if (!isUndef || isExplicitName) {
|
|
4914
|
+
const [sLen, c4] = readULEB(buf, cur);
|
|
4915
|
+
sName = Buffer.from(buf.subarray(c4, c4 + sLen)).toString("utf8");
|
|
4916
|
+
cur = c4 + sLen;
|
|
4917
|
+
} else if (kind === 0) {
|
|
4918
|
+
sName = importFuncNames[el] ?? "";
|
|
4919
|
+
} else if (kind === 2) {
|
|
4920
|
+
sName = importGlobalNames[el] ?? "";
|
|
4921
|
+
} else if (kind === 4) {
|
|
4922
|
+
sName = importEventNames[el] ?? "";
|
|
4923
|
+
} else if (kind === 5) {
|
|
4924
|
+
sName = importTableNames[el] ?? "";
|
|
4925
|
+
}
|
|
4926
|
+
symNames.push(sName);
|
|
4927
|
+
} else if (kind === 1) {
|
|
4928
|
+
const [sLen, c3] = readULEB(buf, cur);
|
|
4929
|
+
const sName = Buffer.from(buf.subarray(c3, c3 + sLen)).toString("utf8");
|
|
4930
|
+
cur = c3 + sLen;
|
|
4931
|
+
if (!isUndef) {
|
|
4932
|
+
const [segIdx, c4] = readULEB(buf, cur);
|
|
4933
|
+
const [sOff, c5] = readULEB(buf, c4);
|
|
4934
|
+
const [sSz, c6] = readULEB(buf, c5);
|
|
4935
|
+
cur = c6;
|
|
4936
|
+
symElemIdx[i] = segIdx;
|
|
4937
|
+
symOff[i] = sOff;
|
|
4938
|
+
symSz[i] = sSz;
|
|
4939
|
+
}
|
|
4940
|
+
symNames.push(sName);
|
|
4941
|
+
} else if (kind === 3) {
|
|
4942
|
+
const [, c3] = readULEB(buf, cur);
|
|
4943
|
+
cur = c3;
|
|
4944
|
+
symNames.push("");
|
|
4945
|
+
}
|
|
4946
|
+
}
|
|
4947
|
+
}
|
|
4948
|
+
lp = subEnd;
|
|
4949
|
+
}
|
|
4950
|
+
} else if (name2 === "reloc.CODE" || name2 === "reloc.DATA") {
|
|
4951
|
+
const [, r1] = readULEB(buf, cp);
|
|
4952
|
+
const [cnt, r2] = readULEB(buf, r1);
|
|
4953
|
+
let cur = r2;
|
|
4954
|
+
const target = name2 === "reloc.CODE" ? rawCodeRelocs : rawDataRelocs;
|
|
4955
|
+
for (let i = 0; i < cnt; i++) {
|
|
4956
|
+
const rStart = cur;
|
|
4957
|
+
const rType = buf[cur++];
|
|
4958
|
+
const [ro, c2] = readULEB(buf, cur);
|
|
4959
|
+
const [rs, c3] = readULEB(buf, c2);
|
|
4960
|
+
cur = c3;
|
|
4961
|
+
if (HAS_ADDEND.has(rType)) {
|
|
4962
|
+
const [, c4] = readSLEB(buf, cur);
|
|
4963
|
+
cur = c4;
|
|
4964
|
+
}
|
|
4965
|
+
target.push({ rawBytes: new Uint8Array(buf.subarray(rStart, cur)), ro, rs });
|
|
4966
|
+
}
|
|
4967
|
+
}
|
|
4968
|
+
}
|
|
4969
|
+
pos = end;
|
|
4970
|
+
}
|
|
4971
|
+
const symParentIdx = new Int32Array(symKind.length).fill(-1);
|
|
4972
|
+
const segTopSyms = /* @__PURE__ */ new Map();
|
|
4973
|
+
if (isDist) {
|
|
4974
|
+
const bySeg = /* @__PURE__ */ new Map();
|
|
4975
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
4976
|
+
if (symKind[i] === 1 && symElemIdx[i] >= 0) {
|
|
4977
|
+
const segIdx = symElemIdx[i];
|
|
4978
|
+
if (PARTITIONED_SEGS.has(segNames[segIdx])) {
|
|
4979
|
+
let list = bySeg.get(segIdx);
|
|
4980
|
+
if (!list) {
|
|
4981
|
+
list = [];
|
|
4982
|
+
bySeg.set(segIdx, list);
|
|
4983
|
+
}
|
|
4984
|
+
list.push(i);
|
|
4985
|
+
}
|
|
4986
|
+
}
|
|
4987
|
+
}
|
|
4988
|
+
for (const [segIdx, syms] of bySeg) {
|
|
4989
|
+
const segByteLen = (sEnds[segIdx] ?? 0) - (sPayloadStarts[segIdx] ?? 0);
|
|
4990
|
+
const sorted = [...syms].sort(
|
|
4991
|
+
(a, b) => symOff[a] - symOff[b] || symSz[b] - symSz[a]
|
|
4992
|
+
);
|
|
4993
|
+
const dedupTop = [];
|
|
4994
|
+
for (let k = 0; k < sorted.length; k++) {
|
|
4995
|
+
const i = sorted[k];
|
|
4996
|
+
const off = symOff[i];
|
|
4997
|
+
const sz = symSz[i];
|
|
4998
|
+
const lastTop = dedupTop[dedupTop.length - 1];
|
|
4999
|
+
if (lastTop && off < lastTop.end) {
|
|
5000
|
+
symParentIdx[i] = lastTop.symIdx;
|
|
5001
|
+
continue;
|
|
5002
|
+
}
|
|
5003
|
+
let nextOff = segByteLen;
|
|
5004
|
+
for (let m = k + 1; m < sorted.length; m++) {
|
|
5005
|
+
if (symOff[sorted[m]] > off) {
|
|
5006
|
+
nextOff = symOff[sorted[m]];
|
|
5007
|
+
break;
|
|
5008
|
+
}
|
|
5009
|
+
}
|
|
5010
|
+
const end = sz > 0 ? off + sz : nextOff;
|
|
5011
|
+
symParentIdx[i] = i;
|
|
5012
|
+
dedupTop.push({ symIdx: i, off, end });
|
|
5013
|
+
}
|
|
5014
|
+
segTopSyms.set(segIdx, dedupTop);
|
|
5015
|
+
}
|
|
5016
|
+
}
|
|
5017
|
+
const funcRelocs = Array.from({ length: fEnds.length }, () => []);
|
|
5018
|
+
const codeRelocList = [];
|
|
5019
|
+
for (const r of rawCodeRelocs) {
|
|
5020
|
+
let lo = 0;
|
|
5021
|
+
let hi = fEnds.length - 1;
|
|
5022
|
+
while (lo < hi) {
|
|
5023
|
+
const mid = lo + hi >> 1;
|
|
5024
|
+
if (fEnds[mid] <= r.ro) lo = mid + 1;
|
|
5025
|
+
else hi = mid;
|
|
5026
|
+
}
|
|
5027
|
+
if (fEnds.length > 0) {
|
|
5028
|
+
funcRelocs[lo].push(r.rs);
|
|
5029
|
+
codeRelocList.push({ ...r, funcIdx: lo });
|
|
5030
|
+
}
|
|
5031
|
+
}
|
|
5032
|
+
const segRelocs = Array.from({ length: segNames.length }, () => []);
|
|
5033
|
+
const symDataRelocs = /* @__PURE__ */ new Map();
|
|
5034
|
+
const dataRelocList = [];
|
|
5035
|
+
for (const r of rawDataRelocs) {
|
|
5036
|
+
let lo = 0;
|
|
5037
|
+
let hi = sEnds.length - 1;
|
|
5038
|
+
while (lo < hi) {
|
|
5039
|
+
const mid = lo + hi >> 1;
|
|
5040
|
+
if (sEnds[mid] <= r.ro) lo = mid + 1;
|
|
5041
|
+
else hi = mid;
|
|
5042
|
+
}
|
|
5043
|
+
if (sEnds.length > 0 && lo < segRelocs.length) {
|
|
5044
|
+
const offInSeg = r.ro - (sPayloadStarts[lo] ?? 0);
|
|
5045
|
+
let ownerSymIdx = -1;
|
|
5046
|
+
const topList = segTopSyms.get(lo);
|
|
5047
|
+
if (topList) {
|
|
5048
|
+
const owner = topList.find((t) => offInSeg >= t.off && offInSeg < t.end);
|
|
5049
|
+
if (owner) ownerSymIdx = owner.symIdx;
|
|
5050
|
+
}
|
|
5051
|
+
if (ownerSymIdx !== -1) {
|
|
5052
|
+
let list = symDataRelocs.get(ownerSymIdx);
|
|
5053
|
+
if (!list) {
|
|
5054
|
+
list = [];
|
|
5055
|
+
symDataRelocs.set(ownerSymIdx, list);
|
|
5056
|
+
}
|
|
5057
|
+
list.push(r.rs);
|
|
5058
|
+
} else {
|
|
5059
|
+
segRelocs[lo].push(r.rs);
|
|
5060
|
+
}
|
|
5061
|
+
dataRelocList.push({ ...r, segIdx: lo, offInSeg, ownerSymIdx });
|
|
5062
|
+
}
|
|
5063
|
+
}
|
|
5064
|
+
const typePrefixesInObj = /* @__PURE__ */ new Set();
|
|
5065
|
+
if (isDist) {
|
|
5066
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
5067
|
+
if ((symFlags[i] & 16) === 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mn")) {
|
|
5068
|
+
typePrefixesInObj.add(symNames[i].slice(0, -2));
|
|
5069
|
+
}
|
|
5070
|
+
}
|
|
5071
|
+
}
|
|
5072
|
+
const objcRegisterFuncToTypePrefix = /* @__PURE__ */ new Map();
|
|
5073
|
+
const objcClassSymToTypePrefix = /* @__PURE__ */ new Map();
|
|
5074
|
+
if (isDist) {
|
|
5075
|
+
for (const symIdx of initFuncs) {
|
|
5076
|
+
if (symKind[symIdx] === 0 && symElemIdx[symIdx] >= numImportFuncs) {
|
|
5077
|
+
const lf = symElemIdx[symIdx] - numImportFuncs;
|
|
5078
|
+
const fName = symNames[symIdx];
|
|
5079
|
+
if (fName.startsWith(".L.swift.objc.register")) {
|
|
5080
|
+
const relSyms = funcRelocs[lf].map((si) => symNames[si]);
|
|
5081
|
+
const mnSym = relSyms.find((s) => s.startsWith("$s") && s.endsWith("Mn"));
|
|
5082
|
+
const objcSym = relSyms.find((s) => s.startsWith("._OBJC_CLASS_"));
|
|
5083
|
+
if (mnSym) {
|
|
5084
|
+
const pref = mnSym.slice(0, -2);
|
|
5085
|
+
objcRegisterFuncToTypePrefix.set(lf, pref);
|
|
5086
|
+
if (objcSym) objcClassSymToTypePrefix.set(objcSym, pref);
|
|
5087
|
+
}
|
|
5088
|
+
}
|
|
5089
|
+
}
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5092
|
+
const rootFuncs = [];
|
|
5093
|
+
const rootSegs = [];
|
|
5094
|
+
for (const symIdx of initFuncs) {
|
|
5095
|
+
if (symKind[symIdx] === 0 && symElemIdx[symIdx] >= numImportFuncs) {
|
|
5096
|
+
const lf = symElemIdx[symIdx] - numImportFuncs;
|
|
5097
|
+
if (!objcRegisterFuncToTypePrefix.has(lf)) {
|
|
5098
|
+
rootFuncs.push(lf);
|
|
5099
|
+
}
|
|
5100
|
+
}
|
|
5101
|
+
}
|
|
5102
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
5103
|
+
const isRootSym = isDist ? (symFlags[i] & 32) !== 0 : (symFlags[i] & 128) !== 0 || (symFlags[i] & 32) !== 0;
|
|
5104
|
+
if (isRootSym && (symFlags[i] & 16) === 0) {
|
|
5105
|
+
if (symKind[i] === 0 && symElemIdx[i] >= numImportFuncs) {
|
|
5106
|
+
rootFuncs.push(symElemIdx[i] - numImportFuncs);
|
|
5107
|
+
} else if (symKind[i] === 1 && symElemIdx[i] >= 0) {
|
|
5108
|
+
rootSegs.push(symElemIdx[i]);
|
|
5109
|
+
}
|
|
5110
|
+
}
|
|
5111
|
+
}
|
|
5112
|
+
for (let i = 0; i < segNames.length; i++) {
|
|
5113
|
+
const sName = segNames[i];
|
|
5114
|
+
if (isDist && (sName === "swift5_type_metadata" || sName === "swift5_protocol_conformances" || sName === "__objc_classes" || sName.startsWith(".init_array"))) {
|
|
5115
|
+
continue;
|
|
5116
|
+
}
|
|
5117
|
+
if (isRootSegName(sName) || !isDist && ((segFlags[i] ?? 0) & 4) !== 0) {
|
|
5118
|
+
rootSegs.push(i);
|
|
5119
|
+
}
|
|
5120
|
+
}
|
|
5121
|
+
return {
|
|
5122
|
+
file,
|
|
5123
|
+
isDist,
|
|
5124
|
+
numImportFuncs,
|
|
5125
|
+
numFuncs: fEnds.length,
|
|
5126
|
+
numSegments: segNames.length,
|
|
5127
|
+
segNames,
|
|
5128
|
+
symKind,
|
|
5129
|
+
symFlags,
|
|
5130
|
+
symElemIdx,
|
|
5131
|
+
symOff,
|
|
5132
|
+
symSz,
|
|
5133
|
+
symParentIdx,
|
|
5134
|
+
symNames,
|
|
5135
|
+
funcRelocs,
|
|
5136
|
+
segRelocs,
|
|
5137
|
+
symDataRelocs,
|
|
5138
|
+
codeRelocList,
|
|
5139
|
+
dataRelocList,
|
|
5140
|
+
initFuncSyms: initFuncs,
|
|
5141
|
+
objcRegisterFuncToTypePrefix,
|
|
5142
|
+
objcClassSymToTypePrefix,
|
|
5143
|
+
typePrefixesInObj,
|
|
5144
|
+
rootFuncs,
|
|
5145
|
+
rootSegs
|
|
5146
|
+
};
|
|
5147
|
+
}
|
|
5148
|
+
function parseWasmObjectCached(file, isDist, useCache) {
|
|
5149
|
+
const key = `${isDist ? "1" : "0"}:${file}`;
|
|
5150
|
+
if (useCache) {
|
|
5151
|
+
const hit = parsedObjectCache.get(key);
|
|
5152
|
+
if (hit) return hit;
|
|
5153
|
+
}
|
|
5154
|
+
const parsed = parseWasmObjectBytes(file, new Uint8Array(import_node_fs8.default.readFileSync(file)), isDist);
|
|
5155
|
+
if (useCache) parsedObjectCache.set(key, parsed);
|
|
5156
|
+
return parsed;
|
|
5157
|
+
}
|
|
5158
|
+
function peachHome2() {
|
|
5159
|
+
const override = process.env.PEACH_HOME;
|
|
5160
|
+
return override ? import_node_path12.default.resolve(override) : import_node_path12.default.join(import_node_os4.default.homedir(), ".peach");
|
|
5161
|
+
}
|
|
5162
|
+
function ensureUnpackedSdkObjects(sdkWasiDir) {
|
|
5163
|
+
const sdkKey = (0, import_node_crypto6.createHash)("sha256").update(sdkWasiDir).digest("hex").slice(0, 16);
|
|
5164
|
+
const outDir = import_node_path12.default.join(peachHome2(), "cache", "swift-builds", `sdk-objs-${sdkKey}`);
|
|
5165
|
+
const stamp = import_node_path12.default.join(outDir, ".complete");
|
|
5166
|
+
if (import_node_fs8.default.existsSync(stamp)) return outDir;
|
|
5167
|
+
const tmpDir = `${outDir}.${process.pid}.${Date.now()}.tmp`;
|
|
5168
|
+
import_node_fs8.default.mkdirSync(tmpDir, { recursive: true });
|
|
5169
|
+
const archives = import_node_fs8.default.readdirSync(sdkWasiDir).filter((f) => f.endsWith(".a")).sort();
|
|
5170
|
+
for (const archive of archives) {
|
|
5171
|
+
const aBase = archive.replace(/\.a$/, "");
|
|
5172
|
+
const members = readArMembers(
|
|
5173
|
+
new Uint8Array(import_node_fs8.default.readFileSync(import_node_path12.default.join(sdkWasiDir, archive)))
|
|
5174
|
+
);
|
|
5175
|
+
const seen = /* @__PURE__ */ new Map();
|
|
5176
|
+
for (const m of members) {
|
|
5177
|
+
const count = (seen.get(m.name) ?? 0) + 1;
|
|
5178
|
+
seen.set(m.name, count);
|
|
5179
|
+
const suffix = count > 1 ? `_${count}` : "";
|
|
5180
|
+
const safeName = m.name.replaceAll("/", "__");
|
|
5181
|
+
const outName = `${aBase}__${safeName}${suffix}`;
|
|
5182
|
+
import_node_fs8.default.writeFileSync(import_node_path12.default.join(tmpDir, outName), m.bytes);
|
|
5183
|
+
}
|
|
5184
|
+
}
|
|
5185
|
+
import_node_fs8.default.writeFileSync(import_node_path12.default.join(tmpDir, ".complete"), "1\n");
|
|
5186
|
+
import_node_fs8.default.mkdirSync(import_node_path12.default.dirname(outDir), { recursive: true });
|
|
5187
|
+
if (import_node_fs8.default.existsSync(stamp)) {
|
|
5188
|
+
import_node_fs8.default.rmSync(tmpDir, { recursive: true, force: true });
|
|
5189
|
+
return outDir;
|
|
5190
|
+
}
|
|
5191
|
+
import_node_fs8.default.rmSync(outDir, { recursive: true, force: true });
|
|
5192
|
+
import_node_fs8.default.renameSync(tmpDir, outDir);
|
|
5193
|
+
return outDir;
|
|
5194
|
+
}
|
|
5195
|
+
function isPrunableSdkFile(file) {
|
|
5196
|
+
const base = import_node_path12.default.basename(file);
|
|
5197
|
+
const aBase = base.split("__")[0];
|
|
5198
|
+
if (PRUNED_SDK_ARCHIVES.has(aBase)) return true;
|
|
5199
|
+
if (base === "libswiftCore__Swift.o" || base === "libswift_Concurrency___Concurrency.o") {
|
|
5200
|
+
return true;
|
|
5201
|
+
}
|
|
5202
|
+
return false;
|
|
5203
|
+
}
|
|
5204
|
+
function getModulePrefix(file) {
|
|
5205
|
+
const base = import_node_path12.default.basename(file);
|
|
5206
|
+
const dbl = base.indexOf("__");
|
|
5207
|
+
if (dbl > 0) return base.slice(0, dbl);
|
|
5208
|
+
const dash = base.indexOf("-");
|
|
5209
|
+
return dash > 0 ? base.slice(0, dash) : base;
|
|
5210
|
+
}
|
|
5211
|
+
function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot) {
|
|
5212
|
+
const rspPath = import_node_path12.default.join(directory, ".peach-link.rsp");
|
|
5213
|
+
if (!import_node_fs8.default.existsSync(rspPath)) return;
|
|
5214
|
+
const origRsp = import_node_fs8.default.readFileSync(rspPath, "utf8");
|
|
5215
|
+
const tokens = Array.from(origRsp.matchAll(/"([^"]+)"|(\S+)/g), (m) => m[1] ?? m[2]);
|
|
5216
|
+
if (!tokens.includes("--start-lib")) return;
|
|
5217
|
+
const sdkFlag = tokens.find(
|
|
5218
|
+
(t) => t.startsWith("-L") && t.endsWith("/swift_static/wasi")
|
|
5219
|
+
);
|
|
5220
|
+
if (!sdkFlag) return;
|
|
5221
|
+
const sdkWasiDir = sdkFlag.slice(2);
|
|
5222
|
+
const sdkObjsDir = ensureUnpackedSdkObjects(sdkWasiDir);
|
|
5223
|
+
const distDir = import_node_path12.default.join(moduleRoot, "lib");
|
|
5224
|
+
const prunedObjsDir = import_node_path12.default.join(directory, ".peach-pruned-objs");
|
|
5225
|
+
import_node_fs8.default.rmSync(prunedObjsDir, { recursive: true, force: true });
|
|
5226
|
+
import_node_fs8.default.mkdirSync(prunedObjsDir, { recursive: true });
|
|
5227
|
+
const distFiles = [];
|
|
5228
|
+
const eagerFiles = [];
|
|
5229
|
+
const extraArchiveObjs = [];
|
|
5230
|
+
let inStartLib = false;
|
|
5231
|
+
let swiftrtOrigPath = "";
|
|
5232
|
+
for (const t of tokens) {
|
|
5233
|
+
if (t === "--start-lib") {
|
|
5234
|
+
inStartLib = true;
|
|
5235
|
+
continue;
|
|
5236
|
+
}
|
|
5237
|
+
if (t === "--end-lib") {
|
|
5238
|
+
inStartLib = false;
|
|
5239
|
+
continue;
|
|
5240
|
+
}
|
|
5241
|
+
if (t.endsWith(".o")) {
|
|
5242
|
+
if (t.startsWith(distDir)) {
|
|
5243
|
+
if (import_node_path12.default.basename(t) !== "Foundation-NSStringFormatting.o") {
|
|
5244
|
+
distFiles.push(t);
|
|
5245
|
+
}
|
|
5246
|
+
if (!inStartLib) eagerFiles.push(t);
|
|
5247
|
+
} else if (!inStartLib) {
|
|
5248
|
+
if (t.endsWith("/swiftrt.o")) {
|
|
5249
|
+
swiftrtOrigPath = t;
|
|
5250
|
+
} else {
|
|
5251
|
+
eagerFiles.push(t);
|
|
5252
|
+
}
|
|
5253
|
+
}
|
|
5254
|
+
} else if (!inStartLib && t.endsWith(".a") && !t.endsWith("libclang_rt.builtins-wasm32.a") && import_node_fs8.default.existsSync(t)) {
|
|
5255
|
+
const members = readArMembers(new Uint8Array(import_node_fs8.default.readFileSync(t)));
|
|
5256
|
+
for (const m of members) {
|
|
5257
|
+
extraArchiveObjs.push(parseWasmObjectBytes(`${t}(${m.name})`, m.bytes, false));
|
|
5258
|
+
}
|
|
5259
|
+
}
|
|
5260
|
+
}
|
|
5261
|
+
let patchedSwiftrtPath = "";
|
|
5262
|
+
if (swiftrtOrigPath && import_node_fs8.default.existsSync(swiftrtOrigPath)) {
|
|
5263
|
+
patchedSwiftrtPath = import_node_path12.default.join(prunedObjsDir, "swiftrt-patched.o");
|
|
5264
|
+
import_node_fs8.default.writeFileSync(
|
|
5265
|
+
patchedSwiftrtPath,
|
|
5266
|
+
patchSwiftrtObject(new Uint8Array(import_node_fs8.default.readFileSync(swiftrtOrigPath)))
|
|
5267
|
+
);
|
|
5268
|
+
eagerFiles.push(patchedSwiftrtPath);
|
|
5269
|
+
}
|
|
5270
|
+
const allSdkObjFiles = import_node_fs8.default.readdirSync(sdkObjsDir).filter((f) => f.endsWith(".o") || f.endsWith(".obj")).sort();
|
|
5271
|
+
const sdkFiles = allSdkObjFiles.map((f) => import_node_path12.default.join(sdkObjsDir, f));
|
|
5272
|
+
const distObjs = /* @__PURE__ */ new Map();
|
|
5273
|
+
const lazyProviders = /* @__PURE__ */ new Map();
|
|
5274
|
+
const registerLazyProvider = (obj) => {
|
|
5275
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
5276
|
+
const fl = obj.symFlags[i];
|
|
5277
|
+
const isUndef = (fl & 16) !== 0;
|
|
5278
|
+
const isLocal = (fl & 3) === 2;
|
|
5279
|
+
if (!isUndef && !isLocal) {
|
|
5280
|
+
const name2 = obj.symNames[i];
|
|
5281
|
+
if (name2) {
|
|
5282
|
+
let list = lazyProviders.get(name2);
|
|
5283
|
+
if (!list) {
|
|
5284
|
+
list = [];
|
|
5285
|
+
lazyProviders.set(name2, list);
|
|
5286
|
+
}
|
|
5287
|
+
list.push(obj);
|
|
5288
|
+
}
|
|
5289
|
+
}
|
|
5290
|
+
}
|
|
5291
|
+
};
|
|
5292
|
+
for (const f of [...distFiles, ...sdkFiles]) {
|
|
5293
|
+
const isSdk = f.startsWith(sdkObjsDir);
|
|
5294
|
+
const isPrunableSwift = !isSdk || isPrunableSdkFile(f);
|
|
5295
|
+
const obj = parseWasmObjectCached(f, isPrunableSwift, true);
|
|
5296
|
+
distObjs.set(f, obj);
|
|
5297
|
+
registerLazyProvider(obj);
|
|
5298
|
+
}
|
|
5299
|
+
for (const obj of extraArchiveObjs) {
|
|
5300
|
+
registerLazyProvider(obj);
|
|
5301
|
+
}
|
|
5302
|
+
const extractedObjs = /* @__PURE__ */ new Set();
|
|
5303
|
+
const definedGlobalSyms = /* @__PURE__ */ new Map();
|
|
5304
|
+
const extractedSymbolDefs = /* @__PURE__ */ new Map();
|
|
5305
|
+
const liveGlobalNames = /* @__PURE__ */ new Set();
|
|
5306
|
+
const liveFuncs = /* @__PURE__ */ new Map();
|
|
5307
|
+
const liveSegs = /* @__PURE__ */ new Map();
|
|
5308
|
+
const liveDataSyms = /* @__PURE__ */ new Map();
|
|
5309
|
+
const liveTypes = /* @__PURE__ */ new Map();
|
|
5310
|
+
const workQueue = [];
|
|
5311
|
+
const pendingUndef = /* @__PURE__ */ new Set();
|
|
5312
|
+
const markFuncLive = (obj, localFuncIdx) => {
|
|
5313
|
+
const arr = liveFuncs.get(obj);
|
|
5314
|
+
if (arr[localFuncIdx]) return;
|
|
5315
|
+
arr[localFuncIdx] = 1;
|
|
5316
|
+
workQueue.push({ kind: "func", obj, idx: localFuncIdx });
|
|
5317
|
+
};
|
|
5318
|
+
const markSegLive = (obj, segIdx) => {
|
|
5319
|
+
const arr = liveSegs.get(obj);
|
|
5320
|
+
if (arr[segIdx]) return;
|
|
5321
|
+
arr[segIdx] = 1;
|
|
5322
|
+
workQueue.push({ kind: "seg", obj, idx: segIdx });
|
|
5323
|
+
};
|
|
5324
|
+
const markDataSymLive = (obj, symIdx) => {
|
|
5325
|
+
const set = liveDataSyms.get(obj);
|
|
5326
|
+
if (set.has(symIdx)) return;
|
|
5327
|
+
set.add(symIdx);
|
|
5328
|
+
workQueue.push({ kind: "datasym", obj, symIdx });
|
|
5329
|
+
};
|
|
5330
|
+
const markTypeLive = (obj, pref) => {
|
|
5331
|
+
const set = liveTypes.get(obj);
|
|
5332
|
+
if (set.has(pref)) return;
|
|
5333
|
+
set.add(pref);
|
|
5334
|
+
const mnName = `${pref}Mn`;
|
|
5335
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
5336
|
+
if (obj.symNames[i] === mnName && (obj.symFlags[i] & 16) === 0) {
|
|
5337
|
+
activateSymbolInObj(obj, i);
|
|
5338
|
+
}
|
|
5339
|
+
}
|
|
5340
|
+
for (const [lf, p] of obj.objcRegisterFuncToTypePrefix) {
|
|
5341
|
+
if (p === pref) {
|
|
5342
|
+
markFuncLive(obj, lf);
|
|
5343
|
+
}
|
|
5344
|
+
}
|
|
5345
|
+
for (let sIdx = 0; sIdx < obj.segNames.length; sIdx++) {
|
|
5346
|
+
if (obj.segNames[sIdx] === "swift5_protocol_conformances") {
|
|
5347
|
+
for (const r of obj.dataRelocList) {
|
|
5348
|
+
if (r.segIdx === sIdx) {
|
|
5349
|
+
const mcName = obj.symNames[r.rs];
|
|
5350
|
+
if (mcName.startsWith(pref)) {
|
|
5351
|
+
activateSymbolInObj(obj, r.rs);
|
|
5352
|
+
}
|
|
5353
|
+
}
|
|
5354
|
+
}
|
|
5355
|
+
}
|
|
5356
|
+
}
|
|
5357
|
+
};
|
|
5358
|
+
const checkTypeTrigger = (obj, rawSymName) => {
|
|
5359
|
+
if (!obj.isDist || !rawSymName) return;
|
|
5360
|
+
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
5361
|
+
const objcPref = obj.objcClassSymToTypePrefix.get(sName);
|
|
5362
|
+
if (objcPref) {
|
|
5363
|
+
markTypeLive(obj, objcPref);
|
|
5364
|
+
return;
|
|
5365
|
+
}
|
|
5366
|
+
if (!sName.startsWith("$s") || sName.endsWith("Tm")) return;
|
|
5367
|
+
for (const suffix of ["Ma", "Mf", "N", "Mn", "ML"]) {
|
|
5368
|
+
if (sName.endsWith(suffix)) {
|
|
5369
|
+
const cand = sName.slice(0, -suffix.length);
|
|
5370
|
+
if (obj.typePrefixesInObj.has(cand)) {
|
|
5371
|
+
markTypeLive(obj, cand);
|
|
5372
|
+
return;
|
|
5373
|
+
}
|
|
5374
|
+
}
|
|
5375
|
+
}
|
|
5376
|
+
if (obj.file.endsWith("libswiftCore__Swift.o") || obj.file.endsWith("libswift_Concurrency___Concurrency.o")) {
|
|
5377
|
+
for (const pref of obj.typePrefixesInObj) {
|
|
5378
|
+
if (sName.startsWith(pref)) {
|
|
5379
|
+
markTypeLive(obj, pref);
|
|
5380
|
+
}
|
|
5381
|
+
}
|
|
5382
|
+
}
|
|
5383
|
+
};
|
|
5384
|
+
const activateGlobalName = (name2) => {
|
|
5385
|
+
if (!name2) return;
|
|
5386
|
+
if (!liveGlobalNames.has(name2)) liveGlobalNames.add(name2);
|
|
5387
|
+
const defs = extractedSymbolDefs.get(name2);
|
|
5388
|
+
if (defs) {
|
|
5389
|
+
for (const d of defs) {
|
|
5390
|
+
activateSymbolInObj(d.obj, d.symIdx);
|
|
5391
|
+
}
|
|
5392
|
+
}
|
|
5393
|
+
};
|
|
5394
|
+
function activateSymbolInObj(obj, symIdx) {
|
|
5395
|
+
const kind = obj.symKind[symIdx];
|
|
5396
|
+
const el = obj.symElemIdx[symIdx];
|
|
5397
|
+
const sName = obj.symNames[symIdx];
|
|
5398
|
+
const fl = obj.symFlags[symIdx];
|
|
5399
|
+
const isUndef = (fl & 16) !== 0;
|
|
5400
|
+
const isLocal = (fl & 3) === 2;
|
|
5401
|
+
checkTypeTrigger(obj, sName);
|
|
5402
|
+
if (!isUndef && !isLocal && sName && !liveGlobalNames.has(sName)) {
|
|
5403
|
+
activateGlobalName(sName);
|
|
5404
|
+
}
|
|
5405
|
+
if (kind === 0 && el >= obj.numImportFuncs) {
|
|
5406
|
+
markFuncLive(obj, el - obj.numImportFuncs);
|
|
5407
|
+
} else if (kind === 1 && el >= 0) {
|
|
5408
|
+
const pIdx = obj.symParentIdx[symIdx];
|
|
5409
|
+
if (pIdx !== -1) {
|
|
5410
|
+
markDataSymLive(obj, pIdx);
|
|
5411
|
+
const parentName = obj.symNames[pIdx];
|
|
5412
|
+
checkTypeTrigger(obj, parentName);
|
|
5413
|
+
}
|
|
5414
|
+
markSegLive(obj, el);
|
|
5415
|
+
}
|
|
5416
|
+
}
|
|
5417
|
+
const extractObject = (obj) => {
|
|
5418
|
+
if (extractedObjs.has(obj)) return;
|
|
5419
|
+
extractedObjs.add(obj);
|
|
5420
|
+
liveFuncs.set(obj, new Uint8Array(obj.numFuncs));
|
|
5421
|
+
liveSegs.set(obj, new Uint8Array(obj.numSegments));
|
|
5422
|
+
liveDataSyms.set(obj, /* @__PURE__ */ new Set());
|
|
5423
|
+
liveTypes.set(obj, /* @__PURE__ */ new Set());
|
|
5424
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
5425
|
+
const fl = obj.symFlags[i];
|
|
5426
|
+
const isUndef = (fl & 16) !== 0;
|
|
5427
|
+
const isLocal = (fl & 3) === 2;
|
|
5428
|
+
const isWeak = (fl & 3) === 1;
|
|
5429
|
+
if (!isUndef && !isLocal) {
|
|
5430
|
+
const name2 = obj.symNames[i];
|
|
5431
|
+
if (name2) {
|
|
5432
|
+
if (!definedGlobalSyms.has(name2) || !isWeak) {
|
|
5433
|
+
definedGlobalSyms.set(name2, { obj, symIdx: i });
|
|
5434
|
+
}
|
|
5435
|
+
let dList = extractedSymbolDefs.get(name2);
|
|
5436
|
+
if (!dList) {
|
|
5437
|
+
dList = [];
|
|
5438
|
+
extractedSymbolDefs.set(name2, dList);
|
|
5439
|
+
}
|
|
5440
|
+
dList.push({ obj, symIdx: i });
|
|
5441
|
+
if (pendingUndef.has(name2) || liveGlobalNames.has(name2)) {
|
|
5442
|
+
pendingUndef.delete(name2);
|
|
5443
|
+
activateSymbolInObj(obj, i);
|
|
5444
|
+
}
|
|
5445
|
+
}
|
|
5446
|
+
}
|
|
5447
|
+
}
|
|
5448
|
+
for (const fIdx of obj.rootFuncs) markFuncLive(obj, fIdx);
|
|
5449
|
+
for (const sIdx of obj.rootSegs) markSegLive(obj, sIdx);
|
|
5450
|
+
if (obj.file.endsWith("libswiftCore__Swift.o")) {
|
|
5451
|
+
for (const pref of obj.typePrefixesInObj) {
|
|
5452
|
+
if (!pref.startsWith("$ss")) {
|
|
5453
|
+
markTypeLive(obj, pref);
|
|
5454
|
+
}
|
|
5455
|
+
}
|
|
5456
|
+
}
|
|
5457
|
+
if (obj.isDist) {
|
|
5458
|
+
for (let sIdx = 0; sIdx < obj.segNames.length; sIdx++) {
|
|
5459
|
+
if (obj.segNames[sIdx] === "swift5_protocol_conformances") {
|
|
5460
|
+
for (const r of obj.dataRelocList) {
|
|
5461
|
+
if (r.segIdx === sIdx) {
|
|
5462
|
+
const mcName = obj.symNames[r.rs];
|
|
5463
|
+
let matchesLocalType = false;
|
|
5464
|
+
for (const pref of obj.typePrefixesInObj) {
|
|
5465
|
+
if (mcName.startsWith(pref)) {
|
|
5466
|
+
matchesLocalType = true;
|
|
5467
|
+
break;
|
|
5468
|
+
}
|
|
5469
|
+
}
|
|
5470
|
+
if (!matchesLocalType) {
|
|
5471
|
+
activateSymbolInObj(obj, r.rs);
|
|
5472
|
+
}
|
|
5473
|
+
}
|
|
5474
|
+
}
|
|
5475
|
+
}
|
|
5476
|
+
}
|
|
5477
|
+
}
|
|
5478
|
+
};
|
|
5479
|
+
for (const f of eagerFiles) {
|
|
5480
|
+
const isDist = f.startsWith(distDir);
|
|
5481
|
+
const obj = distObjs.get(f) ?? parseWasmObjectCached(f, isDist, false);
|
|
5482
|
+
extractObject(obj);
|
|
5483
|
+
if (isDist) {
|
|
5484
|
+
const base = import_node_path12.default.basename(f);
|
|
5485
|
+
if (base.startsWith("PeachFoundation-") || base.startsWith("PeachObjC-") || base.startsWith("PeachICU-") || base.startsWith("Darwin-")) {
|
|
5486
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
5487
|
+
const sName = obj.symNames[i];
|
|
5488
|
+
if ((obj.symFlags[i] & 16) === 0 && sName && !sName.startsWith("$s") && !sName.startsWith(".")) {
|
|
5489
|
+
activateSymbolInObj(obj, i);
|
|
5490
|
+
}
|
|
5491
|
+
}
|
|
5492
|
+
}
|
|
5493
|
+
}
|
|
5494
|
+
}
|
|
5495
|
+
for (const symName of ["_initialize", "__main_argc_argv", "main"]) {
|
|
5496
|
+
const def = definedGlobalSyms.get(symName);
|
|
5497
|
+
if (def) activateSymbolInObj(def.obj, def.symIdx);
|
|
5498
|
+
}
|
|
5499
|
+
while (workQueue.length > 0) {
|
|
5500
|
+
const item = workQueue.pop();
|
|
5501
|
+
const obj = item.obj;
|
|
5502
|
+
let relocs;
|
|
5503
|
+
if (item.kind === "func") {
|
|
5504
|
+
relocs = obj.funcRelocs[item.idx];
|
|
5505
|
+
} else if (item.kind === "seg") {
|
|
5506
|
+
relocs = obj.segRelocs[item.idx];
|
|
5507
|
+
} else {
|
|
5508
|
+
relocs = obj.symDataRelocs.get(item.symIdx) ?? [];
|
|
5509
|
+
}
|
|
5510
|
+
for (const symIdx of relocs) {
|
|
5511
|
+
const fl = obj.symFlags[symIdx];
|
|
5512
|
+
const isUndef = (fl & 16) !== 0;
|
|
5513
|
+
const isLocal = (fl & 3) === 2;
|
|
5514
|
+
const isWeak = (fl & 3) === 1;
|
|
5515
|
+
if (!isUndef) {
|
|
5516
|
+
activateSymbolInObj(obj, symIdx);
|
|
5517
|
+
if (!isLocal) {
|
|
5518
|
+
const name2 = obj.symNames[symIdx];
|
|
5519
|
+
activateGlobalName(name2);
|
|
5520
|
+
}
|
|
5521
|
+
} else {
|
|
5522
|
+
const name2 = obj.symNames[symIdx];
|
|
5523
|
+
if (!name2) continue;
|
|
5524
|
+
let def = definedGlobalSyms.get(name2);
|
|
5525
|
+
if (!def) {
|
|
5526
|
+
const cands = lazyProviders.get(name2);
|
|
5527
|
+
if (cands && cands.length > 0) {
|
|
5528
|
+
const reqMod = getModulePrefix(obj.file);
|
|
5529
|
+
let chosen = cands.find((c) => extractedObjs.has(c));
|
|
5530
|
+
if (!chosen) {
|
|
5531
|
+
const sameMod = cands.filter((c) => getModulePrefix(c.file) === reqMod);
|
|
5532
|
+
const sdkPool = cands.filter((c) => c.file.startsWith(sdkObjsDir));
|
|
5533
|
+
const pool = sameMod.length > 0 ? sameMod : sdkPool.length > 0 ? sdkPool : cands;
|
|
5534
|
+
chosen = pool.reduce(
|
|
5535
|
+
(a, b) => a.rootSegs.length + a.rootFuncs.length <= b.rootSegs.length + b.rootFuncs.length ? a : b
|
|
5536
|
+
);
|
|
5537
|
+
}
|
|
5538
|
+
extractObject(chosen);
|
|
5539
|
+
def = definedGlobalSyms.get(name2);
|
|
5540
|
+
} else if (!isWeak) {
|
|
5541
|
+
pendingUndef.add(name2);
|
|
5542
|
+
}
|
|
5543
|
+
}
|
|
5544
|
+
if (def) {
|
|
5545
|
+
activateGlobalName(name2);
|
|
5546
|
+
}
|
|
5547
|
+
}
|
|
5548
|
+
}
|
|
5549
|
+
}
|
|
5550
|
+
const isSpecialSegRelocLive = (obj, segName, r) => {
|
|
5551
|
+
const sLive = liveSegs.get(obj);
|
|
5552
|
+
const dLive = liveDataSyms.get(obj);
|
|
5553
|
+
const tLive = liveTypes.get(obj);
|
|
5554
|
+
const targetName = obj.symNames[r.rs] ?? "";
|
|
5555
|
+
if (segName === "swift5_type_metadata") {
|
|
5556
|
+
const raw2 = targetName.startsWith(".Lgot.") ? targetName.slice(6) : targetName;
|
|
5557
|
+
if (raw2.endsWith("Mn")) {
|
|
5558
|
+
const pref = raw2.slice(0, -2);
|
|
5559
|
+
if (obj.typePrefixesInObj.has(pref)) return tLive.has(pref);
|
|
5560
|
+
}
|
|
5561
|
+
return true;
|
|
5562
|
+
}
|
|
5563
|
+
if (segName === "swift5_protocol_conformances" || segName === "__objc_classes") {
|
|
5564
|
+
const pIdx = obj.symParentIdx[r.rs];
|
|
5565
|
+
if (pIdx !== -1) return dLive.has(pIdx);
|
|
5566
|
+
const segIdx = obj.symElemIdx[r.rs];
|
|
5567
|
+
return segIdx >= 0 ? sLive[segIdx] === 1 : true;
|
|
5568
|
+
}
|
|
5569
|
+
return true;
|
|
5570
|
+
};
|
|
5571
|
+
const writePrunedObject = (obj, outFile) => {
|
|
5572
|
+
const buf = new Uint8Array(import_node_fs8.default.readFileSync(obj.file));
|
|
5573
|
+
const fLive = liveFuncs.get(obj);
|
|
5574
|
+
const sLive = liveSegs.get(obj);
|
|
5575
|
+
const dLive = liveDataSyms.get(obj);
|
|
5576
|
+
const keptCodeRelocs = obj.codeRelocList.filter((r) => fLive[r.funcIdx] === 1);
|
|
5577
|
+
const firstLiveInSpecialSeg = /* @__PURE__ */ new Map();
|
|
5578
|
+
const deadSpecialSegs = /* @__PURE__ */ new Set();
|
|
5579
|
+
for (let sIdx = 0; sIdx < obj.segNames.length; sIdx++) {
|
|
5580
|
+
const sName = obj.segNames[sIdx];
|
|
5581
|
+
if (sName === "swift5_type_metadata" || sName === "swift5_protocol_conformances" || sName === "__objc_classes") {
|
|
5582
|
+
const segRels = obj.dataRelocList.filter((r) => r.segIdx === sIdx);
|
|
5583
|
+
const liveRels = segRels.filter((r) => isSpecialSegRelocLive(obj, sName, r));
|
|
5584
|
+
if (liveRels.length === 0) {
|
|
5585
|
+
deadSpecialSegs.add(sIdx);
|
|
5586
|
+
} else {
|
|
5587
|
+
const first = liveRels[0];
|
|
5588
|
+
const rType = first.rawBytes[0];
|
|
5589
|
+
const [, afterRoOff] = readULEB(first.rawBytes, 1);
|
|
5590
|
+
firstLiveInSpecialSeg.set(sIdx, {
|
|
5591
|
+
rType,
|
|
5592
|
+
afterRo: first.rawBytes.subarray(afterRoOff)
|
|
5593
|
+
});
|
|
5594
|
+
}
|
|
5595
|
+
}
|
|
5596
|
+
}
|
|
5597
|
+
const keptDataRelocBytes = [];
|
|
5598
|
+
const zeroDataRelocOffsets = [];
|
|
5599
|
+
const usedSyms = /* @__PURE__ */ new Set();
|
|
5600
|
+
for (const r of keptCodeRelocs) usedSyms.add(r.rs);
|
|
5601
|
+
for (const r of obj.dataRelocList) {
|
|
5602
|
+
const sName = obj.segNames[r.segIdx];
|
|
5603
|
+
if (sName === "swift5_type_metadata" || sName === "swift5_protocol_conformances" || sName === "__objc_classes") {
|
|
5604
|
+
if (deadSpecialSegs.has(r.segIdx)) continue;
|
|
5605
|
+
if (isSpecialSegRelocLive(obj, sName, r)) {
|
|
5606
|
+
keptDataRelocBytes.push(r.rawBytes);
|
|
5607
|
+
usedSyms.add(r.rs);
|
|
5608
|
+
} else if (sName === "__objc_classes") {
|
|
5609
|
+
zeroDataRelocOffsets.push(r.ro);
|
|
5610
|
+
} else {
|
|
5611
|
+
const repl = firstLiveInSpecialSeg.get(r.segIdx);
|
|
5612
|
+
const roBytes = encodeULEB(r.ro);
|
|
5613
|
+
const out = new Uint8Array(1 + roBytes.length + repl.afterRo.length);
|
|
5614
|
+
out[0] = repl.rType;
|
|
5615
|
+
out.set(roBytes, 1);
|
|
5616
|
+
out.set(repl.afterRo, 1 + roBytes.length);
|
|
5617
|
+
keptDataRelocBytes.push(out);
|
|
5618
|
+
}
|
|
5619
|
+
} else if (r.ownerSymIdx !== -1) {
|
|
5620
|
+
if (dLive.has(r.ownerSymIdx)) {
|
|
5621
|
+
keptDataRelocBytes.push(r.rawBytes);
|
|
5622
|
+
usedSyms.add(r.rs);
|
|
5623
|
+
}
|
|
5624
|
+
} else if (sLive[r.segIdx] === 1) {
|
|
5625
|
+
keptDataRelocBytes.push(r.rawBytes);
|
|
5626
|
+
usedSyms.add(r.rs);
|
|
5627
|
+
}
|
|
5628
|
+
}
|
|
5629
|
+
const keptInitSyms = obj.initFuncSyms.filter((symIdx) => {
|
|
5630
|
+
if (obj.symKind[symIdx] === 0 && obj.symElemIdx[symIdx] >= obj.numImportFuncs) {
|
|
5631
|
+
return fLive[obj.symElemIdx[symIdx] - obj.numImportFuncs] === 1;
|
|
5632
|
+
}
|
|
5633
|
+
return true;
|
|
5634
|
+
});
|
|
5635
|
+
for (const symIdx of keptInitSyms) usedSyms.add(symIdx);
|
|
5636
|
+
const outChunks = [buf.subarray(0, 8)];
|
|
5637
|
+
let pos = 8;
|
|
5638
|
+
while (pos < buf.length) {
|
|
5639
|
+
const secStart = pos;
|
|
5640
|
+
const id = buf[pos++];
|
|
5641
|
+
const [sz, p] = readULEB(buf, pos);
|
|
5642
|
+
const end = p + sz;
|
|
5643
|
+
if (id === 0) {
|
|
5644
|
+
const [nLen, np] = readULEB(buf, p);
|
|
5645
|
+
const name2 = Buffer.from(buf.subarray(np, np + nLen)).toString("utf8");
|
|
5646
|
+
const cp = np + nLen;
|
|
5647
|
+
if (name2 === "linking") {
|
|
5648
|
+
const [, lpStart] = readULEB(buf, cp);
|
|
5649
|
+
const subChunks = [buf.subarray(p, lpStart)];
|
|
5650
|
+
let lp = lpStart;
|
|
5651
|
+
while (lp < end) {
|
|
5652
|
+
const subStart = lp;
|
|
5653
|
+
const subId = buf[lp++];
|
|
5654
|
+
const [subLen, sp] = readULEB(buf, lp);
|
|
5655
|
+
const subEnd = sp + subLen;
|
|
5656
|
+
if (subId === 5) {
|
|
5657
|
+
const subCopy = new Uint8Array(buf.subarray(subStart, subEnd));
|
|
5658
|
+
let [cnt, cur] = readULEB(buf, sp);
|
|
5659
|
+
for (let i = 0; i < cnt; i++) {
|
|
5660
|
+
const [sLen, s2] = readULEB(buf, cur);
|
|
5661
|
+
const segName = obj.segNames[i];
|
|
5662
|
+
const isSpecial = segName === "swift5_type_metadata" || segName === "swift5_protocol_conformances" || segName === "__objc_classes";
|
|
5663
|
+
if (deadSpecialSegs.has(i)) {
|
|
5664
|
+
let repl = "";
|
|
5665
|
+
if (segName === "swift5_type_metadata") repl = ".dead_swift5_type_md";
|
|
5666
|
+
else if (segName === "swift5_protocol_conformances")
|
|
5667
|
+
repl = ".dead_swift5_protocol_confor";
|
|
5668
|
+
else if (segName === "__objc_classes") repl = ".dead_objc_cls";
|
|
5669
|
+
if (repl.length === sLen) {
|
|
5670
|
+
subCopy.set(Buffer.from(repl, "utf8"), s2 - subStart);
|
|
5671
|
+
}
|
|
5672
|
+
}
|
|
5673
|
+
cur = s2 + sLen;
|
|
5674
|
+
const [, s3] = readULEB(buf, cur);
|
|
5675
|
+
const [segFl, s4] = readULEB(buf, s3);
|
|
5676
|
+
const sFlLen = s4 - s3;
|
|
5677
|
+
const keepRetain = isSpecial ? !deadSpecialSegs.has(i) : isRootSegName(segName) && !segName.startsWith(".init_array") && sLive[i] === 1;
|
|
5678
|
+
const newSegFl = keepRetain ? segFl | 4 : segFl & ~4;
|
|
5679
|
+
if (sFlLen === 1) {
|
|
5680
|
+
subCopy[s3 - subStart] = newSegFl;
|
|
5681
|
+
} else if (sFlLen === 2) {
|
|
5682
|
+
subCopy[s3 - subStart] = newSegFl & 127 | 128;
|
|
5683
|
+
subCopy[s3 - subStart + 1] = newSegFl >> 7;
|
|
5684
|
+
}
|
|
5685
|
+
cur = s4;
|
|
5686
|
+
}
|
|
5687
|
+
subChunks.push(subCopy);
|
|
5688
|
+
} else if (subId === 6) {
|
|
5689
|
+
let [cnt, cur] = readULEB(buf, sp);
|
|
5690
|
+
const entrySlices = [];
|
|
5691
|
+
for (let i = 0; i < cnt; i++) {
|
|
5692
|
+
const eStart = cur;
|
|
5693
|
+
const [, s2] = readULEB(buf, cur);
|
|
5694
|
+
const [symIdx, s3] = readULEB(buf, s2);
|
|
5695
|
+
cur = s3;
|
|
5696
|
+
if (obj.symKind[symIdx] === 0 && obj.symElemIdx[symIdx] >= obj.numImportFuncs) {
|
|
5697
|
+
if (fLive[obj.symElemIdx[symIdx] - obj.numImportFuncs] === 1) {
|
|
5698
|
+
entrySlices.push(buf.subarray(eStart, cur));
|
|
5699
|
+
}
|
|
5700
|
+
} else {
|
|
5701
|
+
entrySlices.push(buf.subarray(eStart, cur));
|
|
5702
|
+
}
|
|
5703
|
+
}
|
|
5704
|
+
if (entrySlices.length > 0) {
|
|
5705
|
+
const cntBytes = Uint8Array.from(encodeULEB(entrySlices.length));
|
|
5706
|
+
const bodyLen = cntBytes.length + entrySlices.reduce((a, b) => a + b.length, 0);
|
|
5707
|
+
const lenBytes = Uint8Array.from(encodeULEB(bodyLen));
|
|
5708
|
+
subChunks.push(Uint8Array.of(6), lenBytes, cntBytes, ...entrySlices);
|
|
5709
|
+
}
|
|
5710
|
+
} else if (subId === 8) {
|
|
5711
|
+
const subCopy = new Uint8Array(buf.subarray(subStart, subEnd));
|
|
5712
|
+
let [cnt, cur] = readULEB(buf, sp);
|
|
5713
|
+
for (let i = 0; i < cnt; i++) {
|
|
5714
|
+
const kind = buf[cur++];
|
|
5715
|
+
const flOffset = cur - subStart;
|
|
5716
|
+
const [fl, c2] = readULEB(buf, cur);
|
|
5717
|
+
cur = c2;
|
|
5718
|
+
const isUndef = (fl & 16) !== 0;
|
|
5719
|
+
const isExplicitName = (fl & 64) !== 0;
|
|
5720
|
+
const flLen = c2 - (flOffset + subStart);
|
|
5721
|
+
let newFl = fl & 127;
|
|
5722
|
+
if (isUndef && (kind === 0 || kind === 1) && !usedSyms.has(i)) {
|
|
5723
|
+
newFl = (fl & ~3 | 1) & 127;
|
|
5724
|
+
} else if (!isUndef && kind === 0 && obj.symElemIdx[i] >= obj.numImportFuncs && fLive[obj.symElemIdx[i] - obj.numImportFuncs] === 0) {
|
|
5725
|
+
newFl = fl & 64 | 2;
|
|
5726
|
+
}
|
|
5727
|
+
if (flLen === 1) {
|
|
5728
|
+
subCopy[flOffset] = newFl;
|
|
5729
|
+
} else if (flLen === 2) {
|
|
5730
|
+
subCopy[flOffset] = newFl | 128;
|
|
5731
|
+
subCopy[flOffset + 1] = 0;
|
|
5732
|
+
}
|
|
5733
|
+
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
5734
|
+
const [, c3] = readULEB(buf, cur);
|
|
5735
|
+
cur = c3;
|
|
5736
|
+
if (!isUndef || isExplicitName) {
|
|
5737
|
+
const [sLen, c4] = readULEB(buf, cur);
|
|
5738
|
+
cur = c4 + sLen;
|
|
5739
|
+
}
|
|
5740
|
+
} else if (kind === 1) {
|
|
5741
|
+
const [sLen, c3] = readULEB(buf, cur);
|
|
5742
|
+
cur = c3 + sLen;
|
|
5743
|
+
if (!isUndef) {
|
|
5744
|
+
const [, c4] = readULEB(buf, cur);
|
|
5745
|
+
const [, c5] = readULEB(buf, c4);
|
|
5746
|
+
const [, c6] = readULEB(buf, c5);
|
|
5747
|
+
cur = c6;
|
|
5748
|
+
}
|
|
5749
|
+
} else if (kind === 3) {
|
|
5750
|
+
const [, c3] = readULEB(buf, cur);
|
|
5751
|
+
cur = c3;
|
|
5752
|
+
}
|
|
5753
|
+
}
|
|
5754
|
+
subChunks.push(subCopy);
|
|
5755
|
+
} else {
|
|
5756
|
+
subChunks.push(buf.subarray(subStart, subEnd));
|
|
5757
|
+
}
|
|
5758
|
+
lp = subEnd;
|
|
5759
|
+
}
|
|
5760
|
+
const totalSubLen = subChunks.reduce((a, b) => a + b.length, 0);
|
|
5761
|
+
outChunks.push(
|
|
5762
|
+
Uint8Array.of(0),
|
|
5763
|
+
Uint8Array.from(encodeULEB(totalSubLen)),
|
|
5764
|
+
...subChunks
|
|
5765
|
+
);
|
|
5766
|
+
} else if (name2 === "reloc.CODE") {
|
|
5767
|
+
const [, r1] = readULEB(buf, cp);
|
|
5768
|
+
const headerSlice = buf.subarray(p, r1);
|
|
5769
|
+
const cntBytes = Uint8Array.from(encodeULEB(keptCodeRelocs.length));
|
|
5770
|
+
const relSlices = keptCodeRelocs.map((r) => r.rawBytes);
|
|
5771
|
+
const totalLen = headerSlice.length + cntBytes.length + relSlices.reduce((a, b) => a + b.length, 0);
|
|
5772
|
+
outChunks.push(
|
|
5773
|
+
Uint8Array.of(0),
|
|
5774
|
+
Uint8Array.from(encodeULEB(totalLen)),
|
|
5775
|
+
headerSlice,
|
|
5776
|
+
cntBytes,
|
|
5777
|
+
...relSlices
|
|
5778
|
+
);
|
|
5779
|
+
} else if (name2 === "reloc.DATA") {
|
|
5780
|
+
const [, r1] = readULEB(buf, cp);
|
|
5781
|
+
const headerSlice = buf.subarray(p, r1);
|
|
5782
|
+
const cntBytes = Uint8Array.from(encodeULEB(keptDataRelocBytes.length));
|
|
5783
|
+
const totalLen = headerSlice.length + cntBytes.length + keptDataRelocBytes.reduce((a, b) => a + b.length, 0);
|
|
5784
|
+
outChunks.push(
|
|
5785
|
+
Uint8Array.of(0),
|
|
5786
|
+
Uint8Array.from(encodeULEB(totalLen)),
|
|
5787
|
+
headerSlice,
|
|
5788
|
+
cntBytes,
|
|
5789
|
+
...keptDataRelocBytes
|
|
5790
|
+
);
|
|
5791
|
+
} else if (name2 === ".swift1_autolink_entries") {
|
|
5792
|
+
} else {
|
|
5793
|
+
outChunks.push(buf.subarray(secStart, end));
|
|
5794
|
+
}
|
|
5795
|
+
} else {
|
|
5796
|
+
if (id === 11 && zeroDataRelocOffsets.length > 0) {
|
|
5797
|
+
for (const ro of zeroDataRelocOffsets) {
|
|
5798
|
+
buf.fill(0, p + ro, p + ro + 4);
|
|
5799
|
+
}
|
|
5800
|
+
}
|
|
5801
|
+
outChunks.push(buf.subarray(secStart, end));
|
|
5802
|
+
}
|
|
5803
|
+
pos = end;
|
|
5804
|
+
}
|
|
5805
|
+
import_node_fs8.default.writeFileSync(outFile, Buffer.concat(outChunks));
|
|
5806
|
+
};
|
|
5807
|
+
const prunableCandidates = [
|
|
5808
|
+
...distFiles,
|
|
5809
|
+
...sdkFiles.filter((f) => isPrunableSdkFile(f))
|
|
5810
|
+
];
|
|
5811
|
+
const reachedPrunableObjs = prunableCandidates.map((f) => distObjs.get(f)).filter((o) => extractedObjs.has(o));
|
|
5812
|
+
const prunedMap = /* @__PURE__ */ new Map();
|
|
5813
|
+
for (const o of reachedPrunableObjs) {
|
|
5814
|
+
const outPath = import_node_path12.default.join(prunedObjsDir, import_node_path12.default.basename(o.file));
|
|
5815
|
+
writePrunedObject(o, outPath);
|
|
5816
|
+
prunedMap.set(o.file, outPath);
|
|
5817
|
+
}
|
|
5818
|
+
const extraCoreConcurrencyObjs = allSdkObjFiles.filter(
|
|
5819
|
+
(f) => f.startsWith("libswiftCore__") && f !== "libswiftCore__Swift.o" || f.startsWith("libswift_Concurrency__") && f !== "libswift_Concurrency___Concurrency.o"
|
|
5820
|
+
).map((f) => import_node_path12.default.join(sdkObjsDir, f));
|
|
5821
|
+
const outTokens = [];
|
|
5822
|
+
const emittedPruned = /* @__PURE__ */ new Set();
|
|
5823
|
+
inStartLib = false;
|
|
5824
|
+
for (const t of tokens) {
|
|
5825
|
+
if (t === "--start-lib") {
|
|
5826
|
+
inStartLib = true;
|
|
5827
|
+
outTokens.push("--start-lib");
|
|
5828
|
+
for (const rf of prunableCandidates) {
|
|
5829
|
+
if (emittedPruned.has(rf)) continue;
|
|
5830
|
+
if (prunedMap.has(rf)) {
|
|
5831
|
+
outTokens.push(prunedMap.get(rf));
|
|
5832
|
+
emittedPruned.add(rf);
|
|
5833
|
+
} else if (rf.startsWith(distDir)) {
|
|
5834
|
+
const m = getModulePrefix(rf);
|
|
5835
|
+
if (m === "PeachICU" || m === "Darwin") {
|
|
5836
|
+
outTokens.push(rf);
|
|
5837
|
+
}
|
|
5838
|
+
}
|
|
5839
|
+
}
|
|
5840
|
+
outTokens.push(...extraCoreConcurrencyObjs);
|
|
5841
|
+
continue;
|
|
5842
|
+
}
|
|
5843
|
+
if (t === "--end-lib") {
|
|
5844
|
+
inStartLib = false;
|
|
5845
|
+
outTokens.push("--end-lib");
|
|
5846
|
+
continue;
|
|
5847
|
+
}
|
|
5848
|
+
if (inStartLib) continue;
|
|
5849
|
+
if (t === swiftrtOrigPath && patchedSwiftrtPath) {
|
|
5850
|
+
outTokens.push(patchedSwiftrtPath);
|
|
5851
|
+
} else if (prunedMap.has(t)) {
|
|
5852
|
+
outTokens.push(prunedMap.get(t));
|
|
5853
|
+
emittedPruned.add(t);
|
|
5854
|
+
} else if (OMIT_SDK_LIB_FLAGS.has(t)) {
|
|
5855
|
+
continue;
|
|
5856
|
+
} else {
|
|
5857
|
+
outTokens.push(t);
|
|
5858
|
+
}
|
|
5859
|
+
}
|
|
5860
|
+
const prunedRspPath = import_node_path12.default.join(directory, ".peach-link.pruned.rsp");
|
|
5861
|
+
import_node_fs8.default.writeFileSync(prunedRspPath, outTokens.map((t) => JSON.stringify(t)).join(" "));
|
|
5862
|
+
(0, import_node_child_process8.execFileSync)(import_node_path12.default.join(toolchainBin, "wasm-ld"), [`@${prunedRspPath}`], {
|
|
5863
|
+
stdio: "pipe"
|
|
5864
|
+
});
|
|
5865
|
+
import_node_fs8.default.rmSync(rspPath, { force: true });
|
|
5866
|
+
}
|
|
5867
|
+
|
|
4354
5868
|
// src/swiftContract.ts
|
|
4355
5869
|
var SWIFT_REMOTE_PACKAGES_DIR = "__packages__";
|
|
4356
5870
|
var SWIFT_LOCAL_PACKAGES_DIR = "__local_packages__";
|
|
@@ -4453,9 +5967,36 @@ function isSwiftResourceBundles(value) {
|
|
|
4453
5967
|
) && new Set(value.map((bundle) => bundle.target)).size === value.length && new Set(value.map((bundle) => bundle.path)).size === value.length;
|
|
4454
5968
|
}
|
|
4455
5969
|
|
|
5970
|
+
// src/wasm-optimize.ts
|
|
5971
|
+
var import_wasm_opt = require("wasm-opt");
|
|
5972
|
+
var FEATURES = [
|
|
5973
|
+
"threads",
|
|
5974
|
+
"bulk-memory",
|
|
5975
|
+
"bulk-memory-opt",
|
|
5976
|
+
"call-indirect-overlong",
|
|
5977
|
+
"exception-handling",
|
|
5978
|
+
"multivalue",
|
|
5979
|
+
"mutable-globals",
|
|
5980
|
+
"nontrapping-float-to-int",
|
|
5981
|
+
"reference-types",
|
|
5982
|
+
"sign-ext"
|
|
5983
|
+
];
|
|
5984
|
+
var WASM_OPTIMIZE_IDENTITY = `wasm-opt ${import_wasm_opt.BINARYEN_VERSION} -Oz ${FEATURES.join(",")}`;
|
|
5985
|
+
async function optimizeWasm(file, output) {
|
|
5986
|
+
const result = await (0, import_wasm_opt.wasmOpt)([
|
|
5987
|
+
"-Oz",
|
|
5988
|
+
...FEATURES.map((feature) => `--enable-${feature}`),
|
|
5989
|
+
file,
|
|
5990
|
+
"-o",
|
|
5991
|
+
output
|
|
5992
|
+
]);
|
|
5993
|
+
if (result.status !== 0)
|
|
5994
|
+
throw new Error(`wasm-opt exited ${result.status}: ${result.stderr}`);
|
|
5995
|
+
}
|
|
5996
|
+
|
|
4456
5997
|
// src/xcode-header-search.ts
|
|
4457
|
-
var
|
|
4458
|
-
var
|
|
5998
|
+
var import_node_fs9 = __toESM(require("node:fs"), 1);
|
|
5999
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
4459
6000
|
function headerMap(entries) {
|
|
4460
6001
|
const unique = /* @__PURE__ */ new Map();
|
|
4461
6002
|
for (const entry of entries)
|
|
@@ -4498,16 +6039,16 @@ function headerMap(entries) {
|
|
|
4498
6039
|
return Buffer.concat([table, ...strings]);
|
|
4499
6040
|
}
|
|
4500
6041
|
function writeXcodeHeaderSearch(directory, targets) {
|
|
4501
|
-
|
|
6042
|
+
import_node_fs9.default.mkdirSync(directory, { recursive: true });
|
|
4502
6043
|
const productDirectories = /* @__PURE__ */ new Map();
|
|
4503
6044
|
for (const target of targets)
|
|
4504
6045
|
for (const [product, file] of Object.entries(target.productHeaders)) {
|
|
4505
|
-
const listed = productDirectories.get(
|
|
4506
|
-
productDirectories.set(
|
|
4507
|
-
listed.push({ name:
|
|
6046
|
+
const listed = productDirectories.get(import_node_path13.default.dirname(product)) ?? [];
|
|
6047
|
+
productDirectories.set(import_node_path13.default.dirname(product), listed);
|
|
6048
|
+
listed.push({ name: import_node_path13.default.basename(product), file });
|
|
4508
6049
|
}
|
|
4509
|
-
const overlay =
|
|
4510
|
-
|
|
6050
|
+
const overlay = import_node_path13.default.join(directory, "all-product-headers.yaml");
|
|
6051
|
+
import_node_fs9.default.writeFileSync(
|
|
4511
6052
|
overlay,
|
|
4512
6053
|
JSON.stringify({
|
|
4513
6054
|
"case-sensitive": "false",
|
|
@@ -4526,8 +6067,8 @@ function writeXcodeHeaderSearch(directory, targets) {
|
|
|
4526
6067
|
const files = [overlay];
|
|
4527
6068
|
const flags = targets.map((target, index) => {
|
|
4528
6069
|
const maps = target.headerMaps.map((map, order) => {
|
|
4529
|
-
const file =
|
|
4530
|
-
|
|
6070
|
+
const file = import_node_path13.default.join(directory, `${index}-${order}.hmap`);
|
|
6071
|
+
import_node_fs9.default.writeFileSync(file, headerMap(map.entries));
|
|
4531
6072
|
files.push(file);
|
|
4532
6073
|
return { flag: map.flag, file };
|
|
4533
6074
|
});
|
|
@@ -4552,7 +6093,7 @@ async function runCompiler(command, args, options, stream = false, quiet) {
|
|
|
4552
6093
|
detached: true,
|
|
4553
6094
|
stdio: ["ignore", "pipe", "pipe"]
|
|
4554
6095
|
};
|
|
4555
|
-
const child = options.lease ? options.lease.spawn(command, args, launch) : (0,
|
|
6096
|
+
const child = options.lease ? options.lease.spawn(command, args, launch) : (0, import_node_child_process9.spawn)(command, args, launch);
|
|
4556
6097
|
let stopping;
|
|
4557
6098
|
try {
|
|
4558
6099
|
return await new Promise((resolve, reject) => {
|
|
@@ -4633,7 +6174,7 @@ var admittedCores = Number(process.env.TM_EXEC_CPU_CORES);
|
|
|
4633
6174
|
var BUILD_JOBS = String(
|
|
4634
6175
|
Math.min(
|
|
4635
6176
|
4,
|
|
4636
|
-
Math.max(1, Math.floor(
|
|
6177
|
+
Math.max(1, Math.floor(import_node_os5.default.availableParallelism() / 2)),
|
|
4637
6178
|
Number.isInteger(admittedCores) && admittedCores > 0 ? admittedCores : 4
|
|
4638
6179
|
)
|
|
4639
6180
|
);
|
|
@@ -4643,10 +6184,39 @@ function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
|
|
|
4643
6184
|
return (compileTimeoutMs ?? SWIFT_BUILDER_DEFAULT_COMPILE_MS) + SWIFT_BUILDER_TRANSPORT_MARGIN_MS;
|
|
4644
6185
|
}
|
|
4645
6186
|
function swiftDistributionAt(root) {
|
|
4646
|
-
const file =
|
|
4647
|
-
if (!(0,
|
|
4648
|
-
return parseSwiftDistributionManifest(JSON.parse((0,
|
|
6187
|
+
const file = import_node_path14.default.join(root, SWIFT_DISTRIBUTION_MANIFEST);
|
|
6188
|
+
if (!(0, import_node_fs10.existsSync)(file)) return null;
|
|
6189
|
+
return parseSwiftDistributionManifest(JSON.parse((0, import_node_fs10.readFileSync)(file, "utf8")));
|
|
6190
|
+
}
|
|
6191
|
+
function swiftModuleInterface(moduleRoot, name2) {
|
|
6192
|
+
if (swiftDistributionAt(moduleRoot)) {
|
|
6193
|
+
const file = import_node_path14.default.join(moduleRoot, "modules", `${name2}-Swift.h`);
|
|
6194
|
+
if (!(0, import_node_fs10.existsSync)(file)) return null;
|
|
6195
|
+
const header = clangInterfaceHeader((0, import_node_fs10.readFileSync)(file, "utf8"));
|
|
6196
|
+
return { declared: swiftInterfaceDeclarations(header), header };
|
|
6197
|
+
}
|
|
6198
|
+
const sources = import_node_path14.default.join(moduleRoot, "Sources", name2);
|
|
6199
|
+
if (!(0, import_node_fs10.existsSync)(sources)) return null;
|
|
6200
|
+
const declared = /* @__PURE__ */ new Set();
|
|
6201
|
+
for (const file of (0, import_node_fs10.readdirSync)(sources, { recursive: true, encoding: "utf8" }))
|
|
6202
|
+
if (file.endsWith(".swift"))
|
|
6203
|
+
for (const [, objc] of (0, import_node_fs10.readFileSync)(import_node_path14.default.join(sources, file), "utf8").matchAll(
|
|
6204
|
+
/@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s/g
|
|
6205
|
+
))
|
|
6206
|
+
declared.add(objc);
|
|
6207
|
+
if (declared.size === 0) return null;
|
|
6208
|
+
const built = import_node_path14.default.join(moduleRoot, ".build/host", `${name2}-Swift.h`);
|
|
6209
|
+
return {
|
|
6210
|
+
declared,
|
|
6211
|
+
header: (0, import_node_fs10.existsSync)(built) ? clangInterfaceHeader((0, import_node_fs10.readFileSync)(built, "utf8")) : `// ${name2}-Swift.h is generated when ${name2} builds
|
|
6212
|
+
`
|
|
6213
|
+
};
|
|
4649
6214
|
}
|
|
6215
|
+
var clangInterfaceHeader = (header) => header.replace(/^@import UIKitCore;$/m, "@import UIKit;");
|
|
6216
|
+
var swiftInterfaceDeclarations = (header) => /* @__PURE__ */ new Set([
|
|
6217
|
+
...[...header.matchAll(/^@protocol\s+(\w+)\b(?![^\n]*;\s*$)/gm)].map((m) => m[1]),
|
|
6218
|
+
...[...header.matchAll(/^@interface\s+(\w+)\s*(?=[:<{]|$)/gm)].map((m) => m[1])
|
|
6219
|
+
]);
|
|
4650
6220
|
function swiftModuleSdk(root) {
|
|
4651
6221
|
const pin = swiftDistributionAt(root) ?? swiftSourceSdk(root);
|
|
4652
6222
|
return {
|
|
@@ -4655,12 +6225,21 @@ function swiftModuleSdk(root) {
|
|
|
4655
6225
|
wasmSdkChecksum: pin.wasmSdkChecksum
|
|
4656
6226
|
};
|
|
4657
6227
|
}
|
|
6228
|
+
function swiftCompileSdkOptions(moduleRoot, toolchainBin) {
|
|
6229
|
+
return swiftSharedSdkViewOptions(
|
|
6230
|
+
moduleRoot,
|
|
6231
|
+
swiftDistributionAt(moduleRoot) !== null,
|
|
6232
|
+
toolchainBin,
|
|
6233
|
+
swiftModuleSdk(moduleRoot).wasmSdkId
|
|
6234
|
+
);
|
|
6235
|
+
}
|
|
4658
6236
|
function swiftModuleInputFiles(root) {
|
|
4659
6237
|
if (swiftDistributionAt(root)) return [SWIFT_DISTRIBUTION_MANIFEST];
|
|
4660
6238
|
const files = [
|
|
4661
6239
|
...swiftSharedSdkInputFiles(root),
|
|
4662
6240
|
"../peachsim/src/swift-shared-sdk.ts",
|
|
4663
6241
|
"../../scripts/generate/swift-sdk-module/darwin-mach.json",
|
|
6242
|
+
"../../scripts/generate/swift-sdk-module/darwin-socketvar.json",
|
|
4664
6243
|
"../../scripts/ops/swift-distribution-publish.ts",
|
|
4665
6244
|
"Package.swift",
|
|
4666
6245
|
"scripts/contrast-app-Package.swift",
|
|
@@ -4676,7 +6255,7 @@ function swiftModuleInputFiles(root) {
|
|
|
4676
6255
|
"toolchain.json"
|
|
4677
6256
|
];
|
|
4678
6257
|
const walk = (dir) => {
|
|
4679
|
-
for (const entry of (0,
|
|
6258
|
+
for (const entry of (0, import_node_fs10.readdirSync)(import_node_path14.default.join(root, dir), {
|
|
4680
6259
|
withFileTypes: true
|
|
4681
6260
|
})) {
|
|
4682
6261
|
const relative = `${dir}/${entry.name}`;
|
|
@@ -4694,43 +6273,43 @@ function swiftMacroPlugins(moduleRoot) {
|
|
|
4694
6273
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
4695
6274
|
if (distribution)
|
|
4696
6275
|
return {
|
|
4697
|
-
libraries: distribution.plugins.filter((plugin) =>
|
|
4698
|
-
executables: distribution.plugins.filter((plugin) =>
|
|
6276
|
+
libraries: distribution.plugins.filter((plugin) => import_node_path14.default.basename(plugin) !== "ExpoModulesMacros").map((plugin) => import_node_path14.default.join(moduleRoot, plugin)),
|
|
6277
|
+
executables: distribution.plugins.filter((plugin) => import_node_path14.default.basename(plugin) === "ExpoModulesMacros").map((plugin) => import_node_path14.default.join(moduleRoot, plugin)),
|
|
4699
6278
|
stale: false
|
|
4700
6279
|
};
|
|
4701
|
-
const dir =
|
|
6280
|
+
const dir = import_node_path14.default.join(moduleRoot, ".build/host/RnxPreviewMacros");
|
|
4702
6281
|
const release = JSON.parse(
|
|
4703
|
-
(0,
|
|
6282
|
+
(0, import_node_fs10.readFileSync)(import_node_path14.default.join(moduleRoot, "toolchain.json"), "utf8")
|
|
4704
6283
|
).release;
|
|
4705
|
-
const compilerStamp =
|
|
4706
|
-
const pluginScript =
|
|
4707
|
-
const expoPlugin =
|
|
6284
|
+
const compilerStamp = import_node_path14.default.join(dir, "compiler-release");
|
|
6285
|
+
const pluginScript = import_node_path14.default.join(moduleRoot, "scripts/build-preview-plugin.sh");
|
|
6286
|
+
const expoPlugin = import_node_path14.default.join(dir, "ExpoModulesMacros");
|
|
4708
6287
|
const ext = process.platform === "darwin" ? "dylib" : "so";
|
|
4709
6288
|
const plugins = [
|
|
4710
6289
|
{
|
|
4711
|
-
library:
|
|
4712
|
-
sources: [
|
|
6290
|
+
library: import_node_path14.default.join(dir, `libRnxPreviewMacros.${ext}`),
|
|
6291
|
+
sources: [import_node_path14.default.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
|
|
4713
6292
|
},
|
|
4714
6293
|
{
|
|
4715
|
-
library:
|
|
6294
|
+
library: import_node_path14.default.join(dir, `libFoundationMacros.${ext}`),
|
|
4716
6295
|
sources: [
|
|
4717
|
-
|
|
4718
|
-
|
|
6296
|
+
import_node_path14.default.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
|
|
6297
|
+
import_node_path14.default.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
|
|
4719
6298
|
]
|
|
4720
6299
|
},
|
|
4721
6300
|
{
|
|
4722
|
-
library:
|
|
6301
|
+
library: import_node_path14.default.join(dir, `libTipKitMacros.${ext}`),
|
|
4723
6302
|
sources: [
|
|
4724
|
-
|
|
4725
|
-
|
|
6303
|
+
import_node_path14.default.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
|
|
6304
|
+
import_node_path14.default.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
|
|
4726
6305
|
]
|
|
4727
6306
|
}
|
|
4728
6307
|
];
|
|
4729
6308
|
return {
|
|
4730
6309
|
libraries: plugins.map(({ library }) => library),
|
|
4731
6310
|
executables: [expoPlugin],
|
|
4732
|
-
stale: !(0,
|
|
4733
|
-
({ library, sources }) => !(0,
|
|
6311
|
+
stale: !(0, import_node_fs10.existsSync)(compilerStamp) || !(0, import_node_fs10.existsSync)(expoPlugin) || (0, import_node_fs10.statSync)(pluginScript).mtimeMs > (0, import_node_fs10.statSync)(expoPlugin).mtimeMs || (0, import_node_fs10.readFileSync)(compilerStamp, "utf8").trim() !== release || plugins.some(
|
|
6312
|
+
({ library, sources }) => !(0, import_node_fs10.existsSync)(library) || sources.some((source) => (0, import_node_fs10.statSync)(source).mtimeMs > (0, import_node_fs10.statSync)(library).mtimeMs)
|
|
4734
6313
|
)
|
|
4735
6314
|
};
|
|
4736
6315
|
}
|
|
@@ -4740,14 +6319,14 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal) {
|
|
|
4740
6319
|
await runCompiler(
|
|
4741
6320
|
"sh",
|
|
4742
6321
|
[
|
|
4743
|
-
|
|
6322
|
+
import_node_path14.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
4744
6323
|
toolchainBin,
|
|
4745
6324
|
libraries[0]
|
|
4746
6325
|
],
|
|
4747
6326
|
{ signal }
|
|
4748
6327
|
);
|
|
4749
|
-
(0,
|
|
4750
|
-
|
|
6328
|
+
(0, import_node_fs10.writeFileSync)(
|
|
6329
|
+
import_node_path14.default.join(import_node_path14.default.dirname(libraries[0]), "compiler-release"),
|
|
4751
6330
|
`${release}
|
|
4752
6331
|
`
|
|
4753
6332
|
);
|
|
@@ -4761,9 +6340,9 @@ function clearLinkedModuleDigests(root) {
|
|
|
4761
6340
|
}
|
|
4762
6341
|
function swiftModuleDigest(root) {
|
|
4763
6342
|
const files = swiftModuleInputFiles(root);
|
|
4764
|
-
const stampHash = (0,
|
|
6343
|
+
const stampHash = (0, import_node_crypto7.createHash)("sha256");
|
|
4765
6344
|
for (const file of files) {
|
|
4766
|
-
const stat = (0,
|
|
6345
|
+
const stat = (0, import_node_fs10.statSync)(import_node_path14.default.join(root, file), { bigint: true });
|
|
4767
6346
|
stampHash.update(file);
|
|
4768
6347
|
stampHash.update(
|
|
4769
6348
|
`${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
|
|
@@ -4773,11 +6352,11 @@ function swiftModuleDigest(root) {
|
|
|
4773
6352
|
const stamp = stampHash.digest("hex");
|
|
4774
6353
|
const cached = linkedModuleDigests.get(root);
|
|
4775
6354
|
if (cached?.stamp === stamp) return cached.digest;
|
|
4776
|
-
const hash = (0,
|
|
6355
|
+
const hash = (0, import_node_crypto7.createHash)("sha256");
|
|
4777
6356
|
for (const file of files) {
|
|
4778
|
-
hash.update((0,
|
|
6357
|
+
hash.update((0, import_node_crypto7.createHash)("sha256").update(file).digest());
|
|
4779
6358
|
hash.update(
|
|
4780
|
-
(0,
|
|
6359
|
+
(0, import_node_crypto7.createHash)("sha256").update((0, import_node_fs10.readFileSync)(import_node_path14.default.join(root, file))).digest()
|
|
4781
6360
|
);
|
|
4782
6361
|
}
|
|
4783
6362
|
const digest = hash.digest();
|
|
@@ -4785,7 +6364,7 @@ function swiftModuleDigest(root) {
|
|
|
4785
6364
|
return digest;
|
|
4786
6365
|
}
|
|
4787
6366
|
function swiftProjectBuildKey(moduleRoot, release) {
|
|
4788
|
-
return (0,
|
|
6367
|
+
return (0, import_node_crypto7.createHash)("sha256").update(`${release}\0${swiftModuleSdk(moduleRoot).wasmSdkId}`).update(swiftModuleDigest(moduleRoot)).digest("hex").slice(0, 32);
|
|
4789
6368
|
}
|
|
4790
6369
|
function compileTargets(input) {
|
|
4791
6370
|
const manifest = input.files["Package.swift"];
|
|
@@ -4801,7 +6380,7 @@ function withNativeSourceGlue(input, glue) {
|
|
|
4801
6380
|
...input,
|
|
4802
6381
|
files: {
|
|
4803
6382
|
...input.files,
|
|
4804
|
-
[
|
|
6383
|
+
[import_node_path14.default.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
|
|
4805
6384
|
},
|
|
4806
6385
|
oneModule: true
|
|
4807
6386
|
};
|
|
@@ -4817,9 +6396,8 @@ var OPTIONAL_FRAMEWORK_DEPENDENCIES = {
|
|
|
4817
6396
|
ImagePlayground: [],
|
|
4818
6397
|
QuickLookThumbnailing: [],
|
|
4819
6398
|
libxml2: [],
|
|
4820
|
-
Compression: [
|
|
4821
|
-
zlib: [
|
|
4822
|
-
PeachCodec: [],
|
|
6399
|
+
Compression: [],
|
|
6400
|
+
zlib: [],
|
|
4823
6401
|
TikTokBusinessSDK: [],
|
|
4824
6402
|
nSure: [],
|
|
4825
6403
|
Statsig: [],
|
|
@@ -4942,21 +6520,22 @@ function swiftImportNames(contents, available) {
|
|
|
4942
6520
|
function swiftPeachModules(moduleRoot) {
|
|
4943
6521
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
4944
6522
|
return distribution ? distribution.modules : swiftManifestDeclarations(
|
|
4945
|
-
(0,
|
|
6523
|
+
(0, import_node_fs10.readFileSync)(import_node_path14.default.join(moduleRoot, "Package.swift"), "utf8")
|
|
4946
6524
|
).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
|
|
4947
6525
|
}
|
|
4948
6526
|
var sdkPaths = /* @__PURE__ */ new Map();
|
|
4949
6527
|
function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
4950
6528
|
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
|
|
4951
|
-
const
|
|
6529
|
+
const options = swiftCompileSdkOptions(moduleRoot, toolchainBin);
|
|
6530
|
+
const key = JSON.stringify([toolchainBin, sdk, options]);
|
|
4952
6531
|
const cached = sdkPaths.get(key);
|
|
4953
6532
|
if (cached) return cached;
|
|
4954
|
-
const configuration = (0,
|
|
4955
|
-
|
|
6533
|
+
const configuration = (0, import_node_child_process9.execFileSync)(
|
|
6534
|
+
import_node_path14.default.join(toolchainBin, "swift"),
|
|
4956
6535
|
[
|
|
4957
6536
|
"sdk",
|
|
4958
6537
|
"configure",
|
|
4959
|
-
...
|
|
6538
|
+
...options,
|
|
4960
6539
|
"--show-configuration",
|
|
4961
6540
|
sdk,
|
|
4962
6541
|
"wasm32-unknown-wasip1"
|
|
@@ -4977,30 +6556,30 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
4977
6556
|
if (!Array.isArray(toolsets) || !toolsets.every((value) => typeof value === "string"))
|
|
4978
6557
|
throw new Error(`swift sdk ${sdk} reports invalid toolset paths`);
|
|
4979
6558
|
for (const toolset of toolsets) {
|
|
4980
|
-
const config = JSON.parse((0,
|
|
6559
|
+
const config = JSON.parse((0, import_node_fs10.readFileSync)(toolset, "utf8"));
|
|
4981
6560
|
if (!config || typeof config !== "object" || !("swiftCompiler" in config)) continue;
|
|
4982
6561
|
const compiler = config.swiftCompiler;
|
|
4983
6562
|
if (!compiler || typeof compiler !== "object" || !("extraCLIOptions" in compiler))
|
|
4984
6563
|
continue;
|
|
4985
|
-
const
|
|
4986
|
-
if (!Array.isArray(
|
|
6564
|
+
const options2 = compiler.extraCLIOptions;
|
|
6565
|
+
if (!Array.isArray(options2) || !options2.every((value) => typeof value === "string"))
|
|
4987
6566
|
throw new Error(
|
|
4988
6567
|
`swift sdk ${sdk} has invalid swift compiler options in ${toolset}`
|
|
4989
6568
|
);
|
|
4990
|
-
for (let index = 0; index <
|
|
4991
|
-
if (
|
|
4992
|
-
const flag =
|
|
6569
|
+
for (let index = 0; index < options2.length; index++) {
|
|
6570
|
+
if (options2[index] === "-Xcc" && typeof options2[index + 1] === "string") {
|
|
6571
|
+
const flag = options2[index + 1];
|
|
4993
6572
|
if (flag !== "-fwasm-exceptions") cFlags.push(flag);
|
|
4994
|
-
if (flag === "-iframeworkwithsysroot" &&
|
|
4995
|
-
cFlags.push(
|
|
4996
|
-
frameworks.push(
|
|
6573
|
+
if (flag === "-iframeworkwithsysroot" && options2[index + 2] === "-Xcc" && typeof options2[index + 3] === "string") {
|
|
6574
|
+
cFlags.push(options2[index + 3]);
|
|
6575
|
+
frameworks.push(import_node_path14.default.join(sysroot, options2[index + 3]));
|
|
4997
6576
|
index += 3;
|
|
4998
6577
|
continue;
|
|
4999
6578
|
}
|
|
5000
6579
|
index += 1;
|
|
5001
6580
|
continue;
|
|
5002
6581
|
}
|
|
5003
|
-
const option =
|
|
6582
|
+
const option = options2[index];
|
|
5004
6583
|
if (option.startsWith("-iframework") || option.startsWith("-F"))
|
|
5005
6584
|
throw new Error(
|
|
5006
6585
|
`swift sdk ${sdk} has an unsupported framework search option ${option}`
|
|
@@ -5010,7 +6589,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
5010
6589
|
}
|
|
5011
6590
|
const paths = {
|
|
5012
6591
|
sysroot,
|
|
5013
|
-
darwin:
|
|
6592
|
+
darwin: import_node_path14.default.join(sysroot, "darwin"),
|
|
5014
6593
|
resources: field("swiftResourcesPath"),
|
|
5015
6594
|
frameworks,
|
|
5016
6595
|
cFlags
|
|
@@ -5026,21 +6605,21 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
5026
6605
|
if (cached) return cached;
|
|
5027
6606
|
const modules = new Set(swiftPeachModules(moduleRoot));
|
|
5028
6607
|
const { resources, frameworks } = swiftSdkPaths(moduleRoot, toolchainBin);
|
|
5029
|
-
for (const entry of (0,
|
|
6608
|
+
for (const entry of (0, import_node_fs10.readdirSync)(import_node_path14.default.join(resources, "wasi"))) {
|
|
5030
6609
|
if (entry.endsWith(".swiftmodule"))
|
|
5031
6610
|
modules.add(entry.slice(0, -".swiftmodule".length));
|
|
5032
6611
|
}
|
|
5033
|
-
for (const entry of (0,
|
|
5034
|
-
const map =
|
|
5035
|
-
if (!(0,
|
|
5036
|
-
for (const match of (0,
|
|
6612
|
+
for (const entry of (0, import_node_fs10.readdirSync)(resources)) {
|
|
6613
|
+
const map = import_node_path14.default.join(resources, entry, "module.modulemap");
|
|
6614
|
+
if (!(0, import_node_fs10.existsSync)(map)) continue;
|
|
6615
|
+
for (const match of (0, import_node_fs10.readFileSync)(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
|
|
5037
6616
|
modules.add(match[1]);
|
|
5038
6617
|
}
|
|
5039
6618
|
for (const directory of frameworks) {
|
|
5040
|
-
for (const entry of (0,
|
|
5041
|
-
const map =
|
|
5042
|
-
if (!(0,
|
|
5043
|
-
for (const match of (0,
|
|
6619
|
+
for (const entry of (0, import_node_fs10.readdirSync)(directory)) {
|
|
6620
|
+
const map = import_node_path14.default.join(directory, entry, "Modules/module.modulemap");
|
|
6621
|
+
if (!(0, import_node_fs10.existsSync)(map)) continue;
|
|
6622
|
+
for (const match of (0, import_node_fs10.readFileSync)(map, "utf8").matchAll(
|
|
5044
6623
|
/^framework\s+module\s+([A-Za-z_]\w*)/gm
|
|
5045
6624
|
))
|
|
5046
6625
|
modules.add(match[1]);
|
|
@@ -5091,20 +6670,20 @@ function swiftSystemLibraryExclusions(files, targets, distributionModules) {
|
|
|
5091
6670
|
);
|
|
5092
6671
|
}
|
|
5093
6672
|
function distributionModulesPath(root, moduleRoot, excluded) {
|
|
5094
|
-
const modules =
|
|
6673
|
+
const modules = import_node_path14.default.join(moduleRoot, "modules");
|
|
5095
6674
|
if (!excluded || excluded.size === 0) return modules;
|
|
5096
|
-
const key = (0,
|
|
5097
|
-
const directory =
|
|
5098
|
-
const complete =
|
|
5099
|
-
if (!(0,
|
|
5100
|
-
(0,
|
|
5101
|
-
for (const entry of (0,
|
|
5102
|
-
(0,
|
|
5103
|
-
for (const entry of (0,
|
|
6675
|
+
const key = (0, import_node_crypto7.createHash)("sha256").update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
|
|
6676
|
+
const directory = import_node_path14.default.join(root, `.peach-modules-${key}`);
|
|
6677
|
+
const complete = import_node_path14.default.join(directory, ".complete");
|
|
6678
|
+
if (!(0, import_node_fs10.existsSync)(complete)) {
|
|
6679
|
+
(0, import_node_fs10.mkdirSync)(directory, { recursive: true });
|
|
6680
|
+
for (const entry of (0, import_node_fs10.readdirSync)(directory))
|
|
6681
|
+
(0, import_node_fs10.rmSync)(import_node_path14.default.join(directory, entry), { recursive: true, force: true });
|
|
6682
|
+
for (const entry of (0, import_node_fs10.readdirSync)(modules)) {
|
|
5104
6683
|
if (excluded.has(entry.replace(/\.swiftmodule$/, ""))) continue;
|
|
5105
|
-
(0,
|
|
6684
|
+
(0, import_node_fs10.symlinkSync)(import_node_path14.default.join(modules, entry), import_node_path14.default.join(directory, entry));
|
|
5106
6685
|
}
|
|
5107
|
-
(0,
|
|
6686
|
+
(0, import_node_fs10.writeFileSync)(complete, "");
|
|
5108
6687
|
}
|
|
5109
6688
|
return directory;
|
|
5110
6689
|
}
|
|
@@ -5149,7 +6728,7 @@ var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
|
|
|
5149
6728
|
).join("");
|
|
5150
6729
|
var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
5151
6730
|
var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
5152
|
-
"-Xclang-linker", ${JSON.stringify(`-fuse-ld=${
|
|
6731
|
+
"-Xclang-linker", ${JSON.stringify(`-fuse-ld=${import_node_path14.default.join(root, SWIFT_AUTOLINK_LINKER)}`)},
|
|
5153
6732
|
"-Xlinker", "-z", "-Xlinker", "stack-size=8372224",
|
|
5154
6733
|
"-Xlinker", "--stack-first",
|
|
5155
6734
|
"-Xlinker", "--global-base=8372224",
|
|
@@ -5158,44 +6737,47 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
|
5158
6737
|
"-Xlinker", "--growable-table",
|
|
5159
6738
|
`;
|
|
5160
6739
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
5161
|
-
var MULTI_MANIFEST_VERSION =
|
|
5162
|
-
var compilerSourceDigest = true ? "
|
|
6740
|
+
var MULTI_MANIFEST_VERSION = 51;
|
|
6741
|
+
var compilerSourceDigest = true ? "b895d808e6b9911d7c80744af3eb884b635b96b82b69c6903f1e66ebd7485d6c" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
|
|
5163
6742
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
5164
|
-
const hash = (0,
|
|
6743
|
+
const hash = (0, import_node_crypto7.createHash)("sha256");
|
|
5165
6744
|
hash.update(`swift-compile
|
|
5166
6745
|
${release}
|
|
5167
6746
|
`);
|
|
5168
6747
|
hash.update(compilerSourceDigest);
|
|
5169
6748
|
if (input.oneModule) hash.update("one-module\n");
|
|
5170
6749
|
hash.update(swiftModuleDigest(moduleRoot));
|
|
5171
|
-
if (input.lazyDistribution)
|
|
6750
|
+
if (input.lazyDistribution)
|
|
6751
|
+
hash.update(`lazy-distribution
|
|
6752
|
+
${WASM_OPTIMIZE_IDENTITY}
|
|
6753
|
+
`);
|
|
5172
6754
|
for (const file of Object.keys(input.files).sort()) {
|
|
5173
|
-
hash.update((0,
|
|
5174
|
-
hash.update((0,
|
|
6755
|
+
hash.update((0, import_node_crypto7.createHash)("sha256").update(file).digest());
|
|
6756
|
+
hash.update((0, import_node_crypto7.createHash)("sha256").update(input.files[file]).digest());
|
|
5175
6757
|
}
|
|
5176
6758
|
for (const file of Object.keys(input.metalSources ?? {}).sort()) {
|
|
5177
6759
|
hash.update("metal-source\n");
|
|
5178
|
-
hash.update((0,
|
|
6760
|
+
hash.update((0, import_node_crypto7.createHash)("sha256").update(file).digest());
|
|
5179
6761
|
hash.update(
|
|
5180
|
-
(0,
|
|
6762
|
+
(0, import_node_crypto7.createHash)("sha256").update(input.metalSources?.[file] ?? "").digest()
|
|
5181
6763
|
);
|
|
5182
6764
|
}
|
|
5183
6765
|
for (const base of Object.keys(input.resources ?? {}).sort()) {
|
|
5184
|
-
hash.update((0,
|
|
6766
|
+
hash.update((0, import_node_crypto7.createHash)("sha256").update(base).digest());
|
|
5185
6767
|
hash.update(
|
|
5186
|
-
(0,
|
|
6768
|
+
(0, import_node_crypto7.createHash)("sha256").update(input.resources?.[base] ?? "").digest()
|
|
5187
6769
|
);
|
|
5188
6770
|
}
|
|
5189
6771
|
for (const name2 of Object.keys(input.images ?? {}).sort()) {
|
|
5190
6772
|
const image = input.images?.[name2];
|
|
5191
6773
|
if (!image) continue;
|
|
5192
|
-
hash.update((0,
|
|
5193
|
-
hash.update((0,
|
|
5194
|
-
hash.update((0,
|
|
6774
|
+
hash.update((0, import_node_crypto7.createHash)("sha256").update(name2).digest());
|
|
6775
|
+
hash.update((0, import_node_crypto7.createHash)("sha256").update(image.file).digest());
|
|
6776
|
+
hash.update((0, import_node_crypto7.createHash)("sha256").update(image.data).digest());
|
|
5195
6777
|
}
|
|
5196
6778
|
for (const file of [...new Set(input.resourcePaths ?? [])].sort()) {
|
|
5197
6779
|
hash.update("resource-path\n");
|
|
5198
|
-
hash.update((0,
|
|
6780
|
+
hash.update((0, import_node_crypto7.createHash)("sha256").update(file).digest());
|
|
5199
6781
|
}
|
|
5200
6782
|
hash.update(
|
|
5201
6783
|
JSON.stringify(
|
|
@@ -5210,18 +6792,18 @@ ${input.defaultLocalization}
|
|
|
5210
6792
|
`);
|
|
5211
6793
|
for (const file of Object.keys(input.packageFiles ?? {}).sort()) {
|
|
5212
6794
|
hash.update(`package-file\0${file}\0`);
|
|
5213
|
-
hash.update((0,
|
|
6795
|
+
hash.update((0, import_node_crypto7.createHash)("sha256").update(input.packageFiles[file]).digest());
|
|
5214
6796
|
}
|
|
5215
6797
|
for (const file of Object.keys(input.projectFiles ?? {}).sort()) {
|
|
5216
6798
|
hash.update(`project-file\0${file}\0`);
|
|
5217
|
-
hash.update((0,
|
|
6799
|
+
hash.update((0, import_node_crypto7.createHash)("sha256").update(input.projectFiles[file]).digest());
|
|
5218
6800
|
}
|
|
5219
6801
|
for (const target of Object.keys(input.libraries ?? {}).sort()) {
|
|
5220
6802
|
hash.update(`library
|
|
5221
6803
|
${target}
|
|
5222
6804
|
`);
|
|
5223
6805
|
hash.update(
|
|
5224
|
-
(0,
|
|
6806
|
+
(0, import_node_crypto7.createHash)("sha256").update(input.libraries?.[target] ?? "").digest()
|
|
5225
6807
|
);
|
|
5226
6808
|
}
|
|
5227
6809
|
const targets = compileTargets(input);
|
|
@@ -5240,17 +6822,17 @@ ${target}
|
|
|
5240
6822
|
return hash.digest("hex");
|
|
5241
6823
|
}
|
|
5242
6824
|
function swiftCrossImportFlags(moduleRoot, distribution) {
|
|
5243
|
-
const overlayRoot =
|
|
6825
|
+
const overlayRoot = import_node_path14.default.join(
|
|
5244
6826
|
moduleRoot,
|
|
5245
6827
|
distribution ? "modules" : "cross-import-overlays"
|
|
5246
6828
|
);
|
|
5247
|
-
return (0,
|
|
6829
|
+
return (0, import_node_fs10.readdirSync)(overlayRoot, { encoding: "utf8", recursive: true }).filter((file) => file.endsWith(".swiftoverlay")).sort((left, right) => left.localeCompare(right)).flatMap((file) => [
|
|
5248
6830
|
"-Xfrontend",
|
|
5249
6831
|
"-swift-module-cross-import",
|
|
5250
6832
|
"-Xfrontend",
|
|
5251
|
-
|
|
6833
|
+
import_node_path14.default.basename(import_node_path14.default.dirname(file), ".swiftcrossimport"),
|
|
5252
6834
|
"-Xfrontend",
|
|
5253
|
-
|
|
6835
|
+
import_node_path14.default.join(overlayRoot, file)
|
|
5254
6836
|
]);
|
|
5255
6837
|
}
|
|
5256
6838
|
function withoutWasmOverlayIsystem(flags) {
|
|
@@ -5296,17 +6878,19 @@ function emitSwiftPackageManifest(args) {
|
|
|
5296
6878
|
(name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
|
|
5297
6879
|
)
|
|
5298
6880
|
);
|
|
5299
|
-
const quoted = (object) => `"${
|
|
6881
|
+
const quoted = (object) => `"${import_node_path14.default.join(moduleRoot, object).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
5300
6882
|
const roots = args.lazyDistribution ? swiftObjcRootObjects(distribution.id, moduleRoot, distribution.objects) : null;
|
|
5301
6883
|
const list = (roots ? [
|
|
5302
6884
|
...objects.filter((object) => roots.has(object)).map(quoted),
|
|
5303
6885
|
"-Wl,--start-lib",
|
|
5304
|
-
...objects.filter(
|
|
6886
|
+
...objects.filter(
|
|
6887
|
+
(object) => !roots.has(object) && object !== "lib/Foundation-NSStringFormatting.o"
|
|
6888
|
+
).map(quoted),
|
|
5305
6889
|
"-Wl,--end-lib"
|
|
5306
6890
|
] : objects.map(quoted)).join("\n") + "\n";
|
|
5307
6891
|
distributionLinkPath = distributionLink.path.replace(
|
|
5308
6892
|
/\.rsp$/,
|
|
5309
|
-
`-${(0,
|
|
6893
|
+
`-${(0, import_node_crypto7.createHash)("sha256").update(list).digest("hex").slice(0, 12)}.rsp`
|
|
5310
6894
|
);
|
|
5311
6895
|
distributionLink.files.set(distributionLinkPath, list);
|
|
5312
6896
|
}
|
|
@@ -5320,7 +6904,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
5320
6904
|
const stanza = (target) => {
|
|
5321
6905
|
const native = args.native?.get(target.name);
|
|
5322
6906
|
if (target.systemLibrary || native?.clang?.sources.length === 0)
|
|
5323
|
-
return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ?
|
|
6907
|
+
return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? import_node_path14.default.posix.dirname(native.clang.modulemap) : target.path)}),`;
|
|
5324
6908
|
const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
|
|
5325
6909
|
const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
|
|
5326
6910
|
const defines = (target.defines ?? []).map((name2) => ` .define(${JSON.stringify(name2)}),`).join("");
|
|
@@ -5361,12 +6945,12 @@ function emitSwiftPackageManifest(args) {
|
|
|
5361
6945
|
].map((flag) => `, ${JSON.stringify(flag)}`).join("");
|
|
5362
6946
|
const header = args.headerDirectory && [...args.native?.values() ?? []].some(
|
|
5363
6947
|
(value) => value.late?.producers.includes(target.name)
|
|
5364
|
-
) ? `, "-emit-objc-header-path", ${JSON.stringify(
|
|
6948
|
+
) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path14.default.join(args.headerDirectory, `${target.name}-Swift.h`))}` : "";
|
|
5365
6949
|
const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImports}${nativeImportFlags}${objcFlags}${header}${upstream}])]`;
|
|
5366
6950
|
const deps = [
|
|
5367
6951
|
.../* @__PURE__ */ new Set([
|
|
5368
6952
|
...(target.dependencies ?? []).flatMap(
|
|
5369
|
-
(dependency) => dependency.kind === "product" && !(linkedObjects && dependency.package ===
|
|
6953
|
+
(dependency) => dependency.kind === "product" && !(linkedObjects && dependency.package === import_node_path14.default.basename(moduleRoot).toLowerCase()) ? [
|
|
5370
6954
|
`.product(name: ${JSON.stringify(dependency.name)}, package: ${JSON.stringify(dependency.package)})`
|
|
5371
6955
|
] : []
|
|
5372
6956
|
),
|
|
@@ -5437,8 +7021,8 @@ function emitSwiftPackageManifest(args) {
|
|
|
5437
7021
|
` path: ${JSON.stringify(native?.clang ? "." : target.path)},`,
|
|
5438
7022
|
...exclusions.length ? [` exclude: ${JSON.stringify(exclusions)},`] : [],
|
|
5439
7023
|
...native?.clang ? [
|
|
5440
|
-
` sources: ${JSON.stringify(native.clang.sources.map((source) =>
|
|
5441
|
-
` publicHeadersPath: ${JSON.stringify(
|
|
7024
|
+
` sources: ${JSON.stringify(native.clang.sources.map((source) => import_node_path14.default.posix.join(native.path, source)))},`,
|
|
7025
|
+
` publicHeadersPath: ${JSON.stringify(import_node_path14.default.posix.dirname(native.clang.modulemap))},`
|
|
5442
7026
|
] : native?.flags ? [` sources: ${JSON.stringify(native.sources)},`] : [],
|
|
5443
7027
|
...!native?.clang && target.publicHeadersPath !== void 0 ? [` publicHeadersPath: ${JSON.stringify(target.publicHeadersPath)},`] : [],
|
|
5444
7028
|
// the native backend supplies dependency module maps without their
|
|
@@ -5482,8 +7066,8 @@ function emitSwiftPackageManifest(args) {
|
|
|
5482
7066
|
` .target(name: ${JSON.stringify(group.name)},`,
|
|
5483
7067
|
` dependencies: ${JSON.stringify(native.mixed ? [] : [name2])},`,
|
|
5484
7068
|
` path: ${JSON.stringify(native.clang || native.mixed ? "." : native.path)},`,
|
|
5485
|
-
` sources: ${JSON.stringify(native.clang || native.mixed ? group.sources.map((source) =>
|
|
5486
|
-
` publicHeadersPath: ${JSON.stringify(native.clang ?
|
|
7069
|
+
` sources: ${JSON.stringify(native.clang || native.mixed ? group.sources.map((source) => import_node_path14.default.posix.join(native.path, source)) : group.sources)},`,
|
|
7070
|
+
` publicHeadersPath: ${JSON.stringify(native.clang ? import_node_path14.default.posix.dirname(native.clang.modulemap) : native.implementationHeaders ?? "include")},`,
|
|
5487
7071
|
` cSettings: [${macroSettings(owner?.cDefines)} .unsafeFlags(${JSON.stringify([...nativeFlags, ...group.flags])})],`,
|
|
5488
7072
|
` cxxSettings: [${macroSettings(owner?.cxxDefines)} .unsafeFlags(${JSON.stringify(["-fno-cxx-modules", ...cxxFlagsFor(nativeFlags), "-I", native.includeDirectory, "-I", args.headerDirectory, ...group.cxxFlags])})]),`
|
|
5489
7073
|
]) : [];
|
|
@@ -5495,28 +7079,28 @@ function emitSwiftPackageManifest(args) {
|
|
|
5495
7079
|
].join("\n");
|
|
5496
7080
|
}
|
|
5497
7081
|
function syncSwiftTree(base, files) {
|
|
5498
|
-
(0,
|
|
7082
|
+
(0, import_node_fs10.mkdirSync)(base, { recursive: true });
|
|
5499
7083
|
const walk = (dir) => {
|
|
5500
|
-
for (const entry of (0,
|
|
5501
|
-
const full =
|
|
5502
|
-
if (dir === base && (entry.name === ".build" || entry.name.startsWith(".peach-modules-") || entry.name === SWIFT_LINK_STAMP
|
|
7084
|
+
for (const entry of (0, import_node_fs10.readdirSync)(dir, { withFileTypes: true })) {
|
|
7085
|
+
const full = import_node_path14.default.join(dir, entry.name);
|
|
7086
|
+
if (dir === base && (entry.name === ".build" || entry.name.startsWith(".peach-modules-") || entry.name === SWIFT_LINK_STAMP))
|
|
5503
7087
|
continue;
|
|
5504
7088
|
if (entry.isDirectory()) walk(full);
|
|
5505
|
-
else if (!files.has(full)) (0,
|
|
7089
|
+
else if (!files.has(full)) (0, import_node_fs10.rmSync)(full, { force: true });
|
|
5506
7090
|
}
|
|
5507
7091
|
};
|
|
5508
7092
|
walk(base);
|
|
5509
7093
|
for (const [full, contents] of files) {
|
|
5510
|
-
if ((0,
|
|
7094
|
+
if ((0, import_node_fs10.existsSync)(full) && (typeof contents === "string" ? (0, import_node_fs10.readFileSync)(full, "utf8") === contents : (0, import_node_fs10.readFileSync)(full).equals(contents)))
|
|
5511
7095
|
continue;
|
|
5512
|
-
(0,
|
|
5513
|
-
(0,
|
|
7096
|
+
(0, import_node_fs10.mkdirSync)(import_node_path14.default.dirname(full), { recursive: true });
|
|
7097
|
+
(0, import_node_fs10.writeFileSync)(full, contents);
|
|
5514
7098
|
}
|
|
5515
7099
|
}
|
|
5516
7100
|
var DIRECTIVE = /^[ \t]*#(?:if|elseif)\b/;
|
|
5517
7101
|
var OS_IOS = /\b(?:os\(\s*iOS\s*\)|targetEnvironment\(\s*simulator\s*\))/g;
|
|
5518
7102
|
var DELEGATE_CLASS = /^class\s+[A-Za-z_]\w*\s*(?:<[^>{]*>)?\s*:[^{]*\b(?:UIApplicationDelegate|UISceneDelegate|UIWindowSceneDelegate)\b[^{]*\{/;
|
|
5519
|
-
var REUSABLE_INIT = /^override(?=\s+init\s*\(\s*(?:style\s*:[^,)]*,\s*reuseIdentifier|reuseIdentifier)\s*:)/;
|
|
7103
|
+
var REUSABLE_INIT = /^override(?=\s+(?:(?:public|open|internal)\s+)?init\s*\(\s*(?:style\s*:[^,)]*,\s*reuseIdentifier|reuseIdentifier)\s*:)/;
|
|
5520
7104
|
var REUSABLE_VIEW_BASES = [
|
|
5521
7105
|
"UICollectionReusableView",
|
|
5522
7106
|
"UICollectionViewCell",
|
|
@@ -5672,34 +7256,12 @@ function swiftCodeMask(source) {
|
|
|
5672
7256
|
return chars.join("");
|
|
5673
7257
|
}
|
|
5674
7258
|
var FOUNDATION_NETWORKING_TYPES = /* @__PURE__ */ new Set([
|
|
5675
|
-
"CachedURLResponse",
|
|
5676
|
-
"HTTPCookieStorage",
|
|
5677
|
-
"NSMutableURLRequest",
|
|
5678
7259
|
"NSURLConnection",
|
|
5679
7260
|
"NSURLConnectionDataDelegate",
|
|
5680
7261
|
"NSURLConnectionDelegate",
|
|
5681
7262
|
"NSURLConnectionDownloadDelegate",
|
|
5682
|
-
"URLCache",
|
|
5683
|
-
"URLCredentialStorage",
|
|
5684
7263
|
"URLProtocol",
|
|
5685
|
-
"URLProtocolClient"
|
|
5686
|
-
"URLRequest",
|
|
5687
|
-
"URLSession",
|
|
5688
|
-
"URLSessionConfiguration",
|
|
5689
|
-
"URLSessionDataDelegate",
|
|
5690
|
-
"URLSessionDataTask",
|
|
5691
|
-
"URLSessionDelegate",
|
|
5692
|
-
"URLSessionDownloadDelegate",
|
|
5693
|
-
"URLSessionDownloadTask",
|
|
5694
|
-
"URLSessionStreamDelegate",
|
|
5695
|
-
"URLSessionStreamTask",
|
|
5696
|
-
"URLSessionTask",
|
|
5697
|
-
"URLSessionTaskDelegate",
|
|
5698
|
-
"URLSessionTaskMetrics",
|
|
5699
|
-
"URLSessionTaskTransactionMetrics",
|
|
5700
|
-
"URLSessionUploadTask",
|
|
5701
|
-
"URLSessionWebSocketDelegate",
|
|
5702
|
-
"URLSessionWebSocketTask"
|
|
7264
|
+
"URLProtocolClient"
|
|
5703
7265
|
]);
|
|
5704
7266
|
var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
|
|
5705
7267
|
"AsyncCharacterSequence",
|
|
@@ -5725,6 +7287,7 @@ var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
|
|
|
5725
7287
|
"NSCollectionChangeType",
|
|
5726
7288
|
"NSConditionLock",
|
|
5727
7289
|
"NSDataDetector",
|
|
7290
|
+
"NSErrorPointer",
|
|
5728
7291
|
"NSException",
|
|
5729
7292
|
"NSExtensionContext",
|
|
5730
7293
|
"NSExtensionItem",
|
|
@@ -5816,9 +7379,7 @@ var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
|
|
|
5816
7379
|
"URLUbiquitousSharedItemPermissions",
|
|
5817
7380
|
"URLUbiquitousSharedItemRole",
|
|
5818
7381
|
"UndoManager",
|
|
5819
|
-
"ValueTransformer"
|
|
5820
|
-
"XMLParser",
|
|
5821
|
-
"XMLParserDelegate"
|
|
7382
|
+
"ValueTransformer"
|
|
5822
7383
|
]);
|
|
5823
7384
|
var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
5824
7385
|
"CFBridgingRetain",
|
|
@@ -6187,7 +7748,6 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
6187
7748
|
"NSUnicodeStringEncoding",
|
|
6188
7749
|
"NSUserActivityErrorMaximum",
|
|
6189
7750
|
"NSUserActivityErrorMinimum",
|
|
6190
|
-
"NSUserActivityTypeBrowsingWeb",
|
|
6191
7751
|
"NSValidationErrorMaximum",
|
|
6192
7752
|
"NSValidationErrorMinimum",
|
|
6193
7753
|
"NSWindows95OperatingSystem",
|
|
@@ -6353,6 +7913,15 @@ var CORE_FOUNDATION_HANDLE_IMPORTS = [
|
|
|
6353
7913
|
"import typealias CoreFoundation.CFTypeRef",
|
|
6354
7914
|
"import CoreGraphics"
|
|
6355
7915
|
]).join("; ");
|
|
7916
|
+
function foundationOwnerOf(name2) {
|
|
7917
|
+
if (name2 === "NSClassFromString" || name2 === "NSKeyValueChange" || name2 === "NSKeyValueObservedChange" || name2 === "NSKeyValueObservation")
|
|
7918
|
+
return "PeachObjC";
|
|
7919
|
+
if (name2 === "DispatchData") return "Dispatch";
|
|
7920
|
+
if (FOUNDATION_NETWORKING_TYPES.has(name2)) return "FoundationNetworking";
|
|
7921
|
+
if (FOUNDATION_OVERLAY_TYPES.has(name2) || FOUNDATION_OVERLAY_GLOBALS.has(name2) || CORE_FOUNDATION_OVERLAY_GLOBALS.has(name2))
|
|
7922
|
+
return "PeachFoundation";
|
|
7923
|
+
return void 0;
|
|
7924
|
+
}
|
|
6356
7925
|
function swiftSourceAsIOS(source) {
|
|
6357
7926
|
const { lineStarts, tokens } = swiftCodeScan(source);
|
|
6358
7927
|
let offset = 0;
|
|
@@ -6408,16 +7977,7 @@ function swiftSourceAsIOS(source) {
|
|
|
6408
7977
|
}
|
|
6409
7978
|
const foundationMember = /^Foundation\s*\.\s*(?:`([A-Za-z_]\w*)`|([A-Za-z_]\w*)\b)/.exec(rest);
|
|
6410
7979
|
const foundationName = foundationMember?.[1] ?? foundationMember?.[2];
|
|
6411
|
-
|
|
6412
|
-
if (foundationName !== void 0) {
|
|
6413
|
-
if (foundationName === "NSClassFromString" || foundationName === "NSKeyValueChange" || foundationName === "NSKeyValueObservedChange" || foundationName === "NSKeyValueObservation")
|
|
6414
|
-
foundationOwner = "PeachObjC";
|
|
6415
|
-
else if (foundationName === "DispatchData") foundationOwner = "Dispatch";
|
|
6416
|
-
else if (FOUNDATION_NETWORKING_TYPES.has(foundationName))
|
|
6417
|
-
foundationOwner = "FoundationNetworking";
|
|
6418
|
-
else if (FOUNDATION_OVERLAY_TYPES.has(foundationName) || FOUNDATION_OVERLAY_GLOBALS.has(foundationName) || CORE_FOUNDATION_OVERLAY_GLOBALS.has(foundationName))
|
|
6419
|
-
foundationOwner = "PeachFoundation";
|
|
6420
|
-
}
|
|
7980
|
+
const foundationOwner = foundationName === void 0 ? void 0 : foundationOwnerOf(foundationName);
|
|
6421
7981
|
if (foundationOwner !== void 0) {
|
|
6422
7982
|
out += conditioned.slice(copied, at) + foundationOwner;
|
|
6423
7983
|
copied = at + "Foundation".length;
|
|
@@ -6529,7 +8089,7 @@ function swiftApplicationEntry(file, source) {
|
|
|
6529
8089
|
else if (source[at] === "}") depth--;
|
|
6530
8090
|
else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
|
|
6531
8091
|
return true;
|
|
6532
|
-
else if (depth === 0 &&
|
|
8092
|
+
else if (depth === 0 && import_node_path14.default.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
|
|
6533
8093
|
return true;
|
|
6534
8094
|
}
|
|
6535
8095
|
return false;
|
|
@@ -6884,59 +8444,60 @@ function swiftCodeScan(source) {
|
|
|
6884
8444
|
return { lineStarts: starts, tokens };
|
|
6885
8445
|
}
|
|
6886
8446
|
function prepareSwiftDependency(source, destination) {
|
|
6887
|
-
(0,
|
|
8447
|
+
(0, import_node_fs10.rmSync)(destination, { recursive: true, force: true });
|
|
6888
8448
|
const origins = {};
|
|
6889
8449
|
const gather = (from) => {
|
|
6890
|
-
for (const entry of (0,
|
|
8450
|
+
for (const entry of (0, import_node_fs10.readdirSync)(from, { withFileTypes: true })) {
|
|
6891
8451
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
6892
8452
|
continue;
|
|
6893
|
-
const file =
|
|
8453
|
+
const file = import_node_path14.default.join(from, entry.name);
|
|
6894
8454
|
if (entry.isDirectory()) gather(file);
|
|
6895
8455
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
6896
|
-
origins[
|
|
8456
|
+
origins[import_node_path14.default.relative(source, file)] = (0, import_node_fs10.readFileSync)(file, "utf8");
|
|
6897
8457
|
}
|
|
6898
8458
|
};
|
|
6899
8459
|
gather(source);
|
|
6900
|
-
const manifest =
|
|
6901
|
-
const targets = (0,
|
|
8460
|
+
const manifest = import_node_path14.default.join(source, "Package.swift");
|
|
8461
|
+
const targets = (0, import_node_fs10.existsSync)(manifest) ? swiftManifestTargets((0, import_node_fs10.readFileSync)(manifest, "utf8")) : [];
|
|
6902
8462
|
const compiled = compiledSwiftSources(origins, targets);
|
|
6903
8463
|
const copy = (from, to) => {
|
|
6904
|
-
(0,
|
|
6905
|
-
for (const entry of (0,
|
|
8464
|
+
(0, import_node_fs10.mkdirSync)(to, { recursive: true });
|
|
8465
|
+
for (const entry of (0, import_node_fs10.readdirSync)(from, { withFileTypes: true })) {
|
|
6906
8466
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
6907
8467
|
continue;
|
|
6908
|
-
const file =
|
|
6909
|
-
const target =
|
|
8468
|
+
const file = import_node_path14.default.join(from, entry.name);
|
|
8469
|
+
const target = import_node_path14.default.join(to, entry.name);
|
|
6910
8470
|
if (entry.isDirectory()) copy(file, target);
|
|
6911
8471
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
6912
|
-
(0,
|
|
6913
|
-
else (0,
|
|
8472
|
+
(0, import_node_fs10.writeFileSync)(target, compiled.get(import_node_path14.default.relative(source, file)));
|
|
8473
|
+
else (0, import_node_fs10.cpSync)(file, target, { verbatimSymlinks: true });
|
|
6914
8474
|
}
|
|
6915
8475
|
};
|
|
6916
8476
|
copy(source, destination);
|
|
6917
8477
|
}
|
|
6918
8478
|
var HIDDEN_UNITS = "PeachHiddenUnits";
|
|
6919
|
-
function clangImportModuleMapFlags(settings, layoutRoot, written) {
|
|
8479
|
+
function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
|
|
6920
8480
|
const searched = new Set(settings.headerSearchPaths);
|
|
6921
|
-
const directory =
|
|
8481
|
+
const directory = import_node_path14.default.join(layoutRoot, ".build", "peach-clang-modulemaps");
|
|
6922
8482
|
return (settings.moduleMaps ?? []).flatMap((map) => {
|
|
6923
|
-
const headers =
|
|
6924
|
-
if (!(0,
|
|
6925
|
-
const published =
|
|
6926
|
-
if (searched.has(map.headers) && (0,
|
|
6927
|
-
if (!searched.has(map.headers) && (0,
|
|
8483
|
+
const headers = import_node_path14.default.join(layoutRoot, map.headers);
|
|
8484
|
+
if (!(0, import_node_fs10.existsSync)(headers)) return [];
|
|
8485
|
+
const published = import_node_path14.default.join(headers, "module.modulemap");
|
|
8486
|
+
if (searched.has(map.headers) && (0, import_node_fs10.existsSync)(published)) return [];
|
|
8487
|
+
if (!searched.has(map.headers) && (0, import_node_fs10.existsSync)(published))
|
|
6928
8488
|
return [`-fmodule-map-file=${published}`];
|
|
6929
8489
|
const cached = written.get(headers);
|
|
6930
8490
|
if (cached) return [cached];
|
|
6931
|
-
(0,
|
|
6932
|
-
const output =
|
|
6933
|
-
(0,
|
|
8491
|
+
(0, import_node_fs10.mkdirSync)(directory, { recursive: true });
|
|
8492
|
+
const output = import_node_path14.default.join(directory, `module-${written.size}.modulemap`);
|
|
8493
|
+
(0, import_node_fs10.writeFileSync)(
|
|
6934
8494
|
output,
|
|
6935
8495
|
swiftPackageClangModuleMap(swiftTargetModuleName(map.module), {
|
|
6936
8496
|
kind: "directory",
|
|
6937
8497
|
path: headers
|
|
6938
8498
|
})
|
|
6939
8499
|
);
|
|
8500
|
+
generated.push({ output, module: swiftTargetModuleName(map.module), published });
|
|
6940
8501
|
const flag = `-fmodule-map-file=${output}`;
|
|
6941
8502
|
written.set(headers, flag);
|
|
6942
8503
|
return [flag];
|
|
@@ -6965,14 +8526,19 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
6965
8526
|
const targets = distribution && compileTargets(input).length === 0 ? [
|
|
6966
8527
|
{
|
|
6967
8528
|
name: "App",
|
|
6968
|
-
path:
|
|
8529
|
+
path: import_node_path14.default.relative(layout.root, layout.sources),
|
|
6969
8530
|
executable: true,
|
|
6970
8531
|
languageMode: 5,
|
|
6971
8532
|
mainActorIsolation: false,
|
|
6972
8533
|
resources: false
|
|
6973
8534
|
}
|
|
6974
8535
|
] : compileTargets(input);
|
|
6975
|
-
const distributionExcludes = distribution ?
|
|
8536
|
+
const distributionExcludes = distribution ? /* @__PURE__ */ new Set([
|
|
8537
|
+
...swiftSystemLibraryExclusions(input.files, targets, distribution.modules),
|
|
8538
|
+
...distribution.modules.filter(
|
|
8539
|
+
(name2) => OPTIONAL_FRAMEWORKS.has(name2) && targets.some((target) => target.name === name2)
|
|
8540
|
+
)
|
|
8541
|
+
]) : void 0;
|
|
6976
8542
|
const files = /* @__PURE__ */ new Map();
|
|
6977
8543
|
const native = /* @__PURE__ */ new Map();
|
|
6978
8544
|
const targetFailures = [];
|
|
@@ -6988,26 +8554,34 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
6988
8554
|
if (target) swiftTargets.add(target.name);
|
|
6989
8555
|
}
|
|
6990
8556
|
const importedModules = /* @__PURE__ */ new Set();
|
|
8557
|
+
const swiftImportedModules = /* @__PURE__ */ new Set();
|
|
8558
|
+
const clangImportedModules = /* @__PURE__ */ new Set();
|
|
6991
8559
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
6992
8560
|
if (file.endsWith(".swift"))
|
|
6993
|
-
for (const name2 of swiftImportNames(contents))
|
|
8561
|
+
for (const name2 of swiftImportNames(contents)) {
|
|
8562
|
+
importedModules.add(name2);
|
|
8563
|
+
swiftImportedModules.add(name2);
|
|
8564
|
+
}
|
|
6994
8565
|
else if (SWIFT_NATIVE_SOURCE_EXTENSIONS.some(
|
|
6995
8566
|
(extension) => extension !== ".modulemap" && file.endsWith(extension)
|
|
6996
8567
|
))
|
|
6997
|
-
for (const name2 of clangImportNames(contents))
|
|
8568
|
+
for (const name2 of clangImportNames(contents)) {
|
|
8569
|
+
importedModules.add(name2);
|
|
8570
|
+
clangImportedModules.add(name2);
|
|
8571
|
+
}
|
|
6998
8572
|
}
|
|
6999
|
-
const headerDirectory =
|
|
8573
|
+
const headerDirectory = import_node_path14.default.join(layout.root, ".build", "peach-cxx-headers");
|
|
7000
8574
|
let checkedToolchain;
|
|
7001
8575
|
const nativeToolchain = () => {
|
|
7002
8576
|
if (checkedToolchain) return checkedToolchain;
|
|
7003
|
-
const pin = distribution ?? JSON.parse((0,
|
|
8577
|
+
const pin = distribution ?? JSON.parse((0, import_node_fs10.readFileSync)(import_node_path14.default.join(moduleRoot, "toolchain.json"), "utf8"));
|
|
7004
8578
|
checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
|
|
7005
8579
|
return checkedToolchain;
|
|
7006
8580
|
};
|
|
7007
8581
|
const deploymentTarget = (name2) => input.nativeTargets?.find((value) => value.name === name2)?.deploymentTarget ?? targets.find((value) => value.name === name2)?.iosDeploymentTarget ?? null;
|
|
7008
8582
|
const targetStagedFiles = /* @__PURE__ */ new Map();
|
|
7009
8583
|
const stageTargetFile = (target, file, contents, options) => {
|
|
7010
|
-
const relative =
|
|
8584
|
+
const relative = import_node_path14.default.relative(layout.root, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep);
|
|
7011
8585
|
const prior = files.has(file) ? files.get(file) : Object.hasOwn(input.files, relative) ? input.files[relative] : void 0;
|
|
7012
8586
|
if (!options?.allowExisting && prior !== void 0)
|
|
7013
8587
|
throw new Error(`target ${target} already contains generated output ${relative}`);
|
|
@@ -7036,7 +8610,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7036
8610
|
targetStagedFiles.delete(target.name);
|
|
7037
8611
|
if (entries.some(([file]) => isSwiftNativeTranslationUnit(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name))) {
|
|
7038
8612
|
if (!swift) {
|
|
7039
|
-
const unprepared =
|
|
8613
|
+
const unprepared = import_node_path14.default.join(
|
|
7040
8614
|
layout.root,
|
|
7041
8615
|
target.path,
|
|
7042
8616
|
"PeachUnprepared.generated.swift"
|
|
@@ -7051,7 +8625,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7051
8625
|
native.set(target.name, {
|
|
7052
8626
|
mixed: true,
|
|
7053
8627
|
path: target.path,
|
|
7054
|
-
includeDirectory:
|
|
8628
|
+
includeDirectory: import_node_path14.default.join(layout.root, target.path, "include"),
|
|
7055
8629
|
sources: [],
|
|
7056
8630
|
lateSources: [],
|
|
7057
8631
|
exclude: entries.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length))
|
|
@@ -7060,30 +8634,33 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7060
8634
|
};
|
|
7061
8635
|
for (const settings of input.nativeTargets ?? []) {
|
|
7062
8636
|
for (const file of settings.headers) {
|
|
7063
|
-
const
|
|
8637
|
+
const interfaceModule = /(?:^|\/)(\w+)\.framework\/Headers\/\1-Swift\.h$/.exec(
|
|
8638
|
+
file
|
|
8639
|
+
)?.[1];
|
|
8640
|
+
const contents = interfaceModule && swiftModuleInterface(moduleRoot, interfaceModule)?.header || input.files[file];
|
|
7064
8641
|
if (contents === void 0)
|
|
7065
8642
|
throw new Error(`missing original Objective-C header ${file}`);
|
|
7066
|
-
const destination =
|
|
7067
|
-
(0,
|
|
7068
|
-
(0,
|
|
8643
|
+
const destination = import_node_path14.default.join(layout.root, file);
|
|
8644
|
+
(0, import_node_fs10.mkdirSync)(import_node_path14.default.dirname(destination), { recursive: true });
|
|
8645
|
+
(0, import_node_fs10.writeFileSync)(destination, contents);
|
|
7069
8646
|
files.set(destination, contents);
|
|
7070
8647
|
}
|
|
7071
8648
|
if (!settings.flattensPublicHeaders) continue;
|
|
7072
8649
|
for (const header of settings.publicHeaders) {
|
|
7073
|
-
const destination =
|
|
8650
|
+
const destination = import_node_path14.default.join(headerDirectory, settings.name, import_node_path14.default.basename(header));
|
|
7074
8651
|
if (files.has(destination))
|
|
7075
8652
|
throw new Error(`duplicate product header ${destination}`);
|
|
7076
|
-
const contents = `#import ${JSON.stringify(
|
|
8653
|
+
const contents = `#import ${JSON.stringify(import_node_path14.default.join(layout.root, header))}
|
|
7077
8654
|
`;
|
|
7078
8655
|
files.set(destination, contents);
|
|
7079
|
-
(0,
|
|
7080
|
-
(0,
|
|
8656
|
+
(0, import_node_fs10.mkdirSync)(import_node_path14.default.dirname(destination), { recursive: true });
|
|
8657
|
+
(0, import_node_fs10.writeFileSync)(destination, contents);
|
|
7081
8658
|
}
|
|
7082
8659
|
}
|
|
7083
8660
|
const nativeTargets = input.nativeTargets ?? [];
|
|
7084
|
-
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ?
|
|
8661
|
+
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? import_node_path14.default.join(layout.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
|
|
7085
8662
|
const headerSearch = writeXcodeHeaderSearch(
|
|
7086
|
-
|
|
8663
|
+
import_node_path14.default.join(layout.root, ".build", "peach-xcode-headers"),
|
|
7087
8664
|
nativeTargets.map((settings) => ({
|
|
7088
8665
|
headerMaps: settings.headerMaps.map((map) => ({
|
|
7089
8666
|
flag: map.flag,
|
|
@@ -7094,16 +8671,17 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7094
8671
|
})),
|
|
7095
8672
|
productHeaders: Object.fromEntries(
|
|
7096
8673
|
Object.entries(settings.productHeaders).map(([product, file]) => [
|
|
7097
|
-
|
|
7098
|
-
|
|
8674
|
+
import_node_path14.default.join(layout.root, product),
|
|
8675
|
+
import_node_path14.default.join(layout.root, file)
|
|
7099
8676
|
])
|
|
7100
8677
|
),
|
|
7101
8678
|
userHeaderSearchPaths: settings.userHeaderSearchPaths.map(
|
|
7102
|
-
(directory) =>
|
|
8679
|
+
(directory) => import_node_path14.default.join(layout.root, directory)
|
|
7103
8680
|
)
|
|
7104
8681
|
}))
|
|
7105
8682
|
);
|
|
7106
8683
|
const importModuleMaps = /* @__PURE__ */ new Map();
|
|
8684
|
+
const generatedModuleMaps = [];
|
|
7107
8685
|
for (const target of targets) {
|
|
7108
8686
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
7109
8687
|
const entries = targetEntries(target);
|
|
@@ -7123,7 +8701,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7123
8701
|
if (producer && targets.some((value) => value.name === producer))
|
|
7124
8702
|
producers2.add(producer);
|
|
7125
8703
|
const local = [
|
|
7126
|
-
|
|
8704
|
+
import_node_path14.default.posix.join(import_node_path14.default.posix.dirname(file), include2),
|
|
7127
8705
|
`${includes}${include2}`
|
|
7128
8706
|
].find((candidate) => input.files[candidate] !== void 0);
|
|
7129
8707
|
if (local) {
|
|
@@ -7157,12 +8735,12 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7157
8735
|
const headers = settings.headers;
|
|
7158
8736
|
const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : entries.some(([file]) => file.endsWith(".swift")) || importedModules.has(swiftTargetModuleName(target.name)) ? settings.publicHeaders : [];
|
|
7159
8737
|
for (const file of headers) {
|
|
7160
|
-
const destination =
|
|
7161
|
-
(0,
|
|
7162
|
-
(0,
|
|
8738
|
+
const destination = import_node_path14.default.join(layout.root, file);
|
|
8739
|
+
(0, import_node_fs10.mkdirSync)(import_node_path14.default.dirname(destination), { recursive: true });
|
|
8740
|
+
(0, import_node_fs10.writeFileSync)(destination, input.files[file]);
|
|
7163
8741
|
}
|
|
7164
8742
|
const search = [.../* @__PURE__ */ new Set([...settings?.headerSearchPaths ?? []])].flatMap(
|
|
7165
|
-
(dir) => ["-I",
|
|
8743
|
+
(dir) => ["-I", import_node_path14.default.join(layout.root, dir)]
|
|
7166
8744
|
);
|
|
7167
8745
|
const toolchainBin = nativeToolchain();
|
|
7168
8746
|
const stageFlags = (flags2, sdkInclude2) => flags2.map(
|
|
@@ -7174,7 +8752,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7174
8752
|
...search,
|
|
7175
8753
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
7176
8754
|
"-F",
|
|
7177
|
-
|
|
8755
|
+
import_node_path14.default.join(layout.root, dir)
|
|
7178
8756
|
]),
|
|
7179
8757
|
"-I",
|
|
7180
8758
|
headerDirectory
|
|
@@ -7185,13 +8763,13 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7185
8763
|
const flag = settings.flags[index];
|
|
7186
8764
|
if (flag === "-I" || flag === "-iquote") {
|
|
7187
8765
|
const directory = settings.flags[index + 1];
|
|
7188
|
-
if (directory === void 0 || !
|
|
8766
|
+
if (directory === void 0 || !import_node_path14.default.isAbsolute(directory)) {
|
|
7189
8767
|
index++;
|
|
7190
8768
|
continue;
|
|
7191
8769
|
}
|
|
7192
8770
|
}
|
|
7193
8771
|
const joined = /^-(?:I|iquote)(.+)$/.exec(flag);
|
|
7194
|
-
if (joined && !
|
|
8772
|
+
if (joined && !import_node_path14.default.isAbsolute(joined[1])) continue;
|
|
7195
8773
|
kept.push(flag);
|
|
7196
8774
|
}
|
|
7197
8775
|
return [
|
|
@@ -7200,18 +8778,18 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7200
8778
|
...search,
|
|
7201
8779
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
7202
8780
|
"-F",
|
|
7203
|
-
|
|
8781
|
+
import_node_path14.default.join(layout.root, dir)
|
|
7204
8782
|
]),
|
|
7205
8783
|
"-I",
|
|
7206
8784
|
headerDirectory
|
|
7207
8785
|
];
|
|
7208
8786
|
})();
|
|
7209
|
-
const sdkInclude =
|
|
8787
|
+
const sdkInclude = import_node_path14.default.join(
|
|
7210
8788
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
7211
8789
|
"darwin/usr/include"
|
|
7212
8790
|
);
|
|
7213
8791
|
const flags = stageFlags(originalFlags, sdkInclude);
|
|
7214
|
-
const prefixHeader = settings?.prefixHeader ? ["-include",
|
|
8792
|
+
const prefixHeader = settings?.prefixHeader ? ["-include", import_node_path14.default.join(layout.root, settings.prefixHeader)] : [];
|
|
7215
8793
|
const bundleName = entries.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
|
|
7216
8794
|
target: target.name,
|
|
7217
8795
|
path: target.path,
|
|
@@ -7222,7 +8800,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7222
8800
|
bundles: input.resourceBundles
|
|
7223
8801
|
});
|
|
7224
8802
|
const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
|
|
7225
|
-
const accessorHeader =
|
|
8803
|
+
const accessorHeader = import_node_path14.default.join(
|
|
7226
8804
|
layout.root,
|
|
7227
8805
|
target.path,
|
|
7228
8806
|
OBJC_RESOURCE_ACCESSOR_HEADER
|
|
@@ -7233,7 +8811,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7233
8811
|
const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
|
|
7234
8812
|
const unitSource = (file) => {
|
|
7235
8813
|
const relative = file.slice(prefix.length);
|
|
7236
|
-
return relative.split("/").some((part) => part.startsWith(".")) ?
|
|
8814
|
+
return relative.split("/").some((part) => part.startsWith(".")) ? import_node_path14.default.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
|
|
7237
8815
|
};
|
|
7238
8816
|
const accessorFlags = accessor ? ["-include", accessorHeader] : [];
|
|
7239
8817
|
const nativeC = !entries.some(([file]) => file.endsWith(".swift"));
|
|
@@ -7263,20 +8841,20 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7263
8841
|
)
|
|
7264
8842
|
].sort();
|
|
7265
8843
|
const topHeaders = settings.publicHeaders.filter(
|
|
7266
|
-
(file) =>
|
|
8844
|
+
(file) => import_node_path14.default.posix.dirname(file) === headerDir
|
|
7267
8845
|
);
|
|
7268
8846
|
if (input.files[custom] !== void 0) {
|
|
7269
8847
|
swiftpmModuleMap = { path: custom, contents: input.files[custom] };
|
|
7270
8848
|
} else if (input.files[umbrella] !== void 0) {
|
|
7271
8849
|
if (siblingDirs.length > 0)
|
|
7272
8850
|
throw new Error(
|
|
7273
|
-
`target ${target.name} has invalid header layout: umbrella header found at '${
|
|
8851
|
+
`target ${target.name} has invalid header layout: umbrella header found at '${import_node_path14.default.join(layout.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name2) => import_node_path14.default.join(layout.root, headerDir, name2)).join(", ")}; consider removing them`
|
|
7274
8852
|
);
|
|
7275
8853
|
swiftpmModuleMap = {
|
|
7276
8854
|
path: custom,
|
|
7277
8855
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
7278
8856
|
kind: "header",
|
|
7279
|
-
path:
|
|
8857
|
+
path: import_node_path14.default.join(layout.root, umbrella)
|
|
7280
8858
|
})
|
|
7281
8859
|
};
|
|
7282
8860
|
} else if (input.files[nestedUmbrella] !== void 0 && siblingDirs.length === 1 && siblingDirs[0] === moduleName && topHeaders.length === 0) {
|
|
@@ -7284,7 +8862,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7284
8862
|
path: custom,
|
|
7285
8863
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
7286
8864
|
kind: "header",
|
|
7287
|
-
path:
|
|
8865
|
+
path: import_node_path14.default.join(layout.root, nestedUmbrella)
|
|
7288
8866
|
})
|
|
7289
8867
|
};
|
|
7290
8868
|
} else {
|
|
@@ -7292,12 +8870,12 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7292
8870
|
path: custom,
|
|
7293
8871
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
7294
8872
|
kind: "directory",
|
|
7295
|
-
path:
|
|
8873
|
+
path: import_node_path14.default.join(layout.root, headerDir)
|
|
7296
8874
|
})
|
|
7297
8875
|
};
|
|
7298
8876
|
}
|
|
7299
8877
|
}
|
|
7300
|
-
const modulemap = originalModuleMap?.[0] ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ??
|
|
8878
|
+
const modulemap = originalModuleMap?.[0] ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? import_node_path14.default.posix.join(
|
|
7301
8879
|
".build",
|
|
7302
8880
|
"peach-objc-originals",
|
|
7303
8881
|
target.name,
|
|
@@ -7305,48 +8883,53 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7305
8883
|
);
|
|
7306
8884
|
const moduleContents = originalModuleMap ? input.files[originalModuleMap[1]] : swiftpmModuleMap?.contents ?? packageModuleMap?.[1] ?? swiftObjCModuleMap(
|
|
7307
8885
|
swiftTargetModuleName(target.name),
|
|
7308
|
-
roots2.map((file) =>
|
|
8886
|
+
roots2.map((file) => import_node_path14.default.join(layout.root, file))
|
|
7309
8887
|
);
|
|
7310
8888
|
if (moduleContents === void 0)
|
|
7311
8889
|
throw new Error("missing original module map " + modulemap);
|
|
7312
|
-
stageTargetFile(target.name,
|
|
8890
|
+
stageTargetFile(target.name, import_node_path14.default.join(layout.root, modulemap), moduleContents, {
|
|
7313
8891
|
allowExisting: true
|
|
7314
8892
|
});
|
|
7315
8893
|
const importFlags = [
|
|
7316
8894
|
...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
|
|
7317
|
-
"-fmodule-map-file=" +
|
|
7318
|
-
...clangImportModuleMapFlags(
|
|
8895
|
+
"-fmodule-map-file=" + import_node_path14.default.join(layout.root, modulemap),
|
|
8896
|
+
...clangImportModuleMapFlags(
|
|
8897
|
+
settings,
|
|
8898
|
+
layout.root,
|
|
8899
|
+
importModuleMaps,
|
|
8900
|
+
generatedModuleMaps
|
|
8901
|
+
)
|
|
7319
8902
|
];
|
|
7320
8903
|
const groups = /* @__PURE__ */ new Map();
|
|
7321
8904
|
for (const [file, contents] of nativeUnits) {
|
|
7322
8905
|
const origin = settings?.sourceDirectories[file];
|
|
7323
8906
|
if (origin) {
|
|
7324
|
-
const original =
|
|
7325
|
-
(0,
|
|
8907
|
+
const original = import_node_path14.default.join(layout.root, origin, import_node_path14.default.posix.basename(file));
|
|
8908
|
+
(0, import_node_fs10.mkdirSync)(import_node_path14.default.dirname(original), { recursive: true });
|
|
7326
8909
|
stageTargetFile(target.name, original, contents, { allowExisting: true });
|
|
7327
8910
|
}
|
|
7328
8911
|
const source = unitSource(file);
|
|
7329
8912
|
if (source !== file.slice(prefix.length))
|
|
7330
8913
|
stageTargetFile(
|
|
7331
8914
|
target.name,
|
|
7332
|
-
|
|
8915
|
+
import_node_path14.default.join(layout.root, target.path, source),
|
|
7333
8916
|
contents,
|
|
7334
8917
|
{
|
|
7335
8918
|
allowExisting: true
|
|
7336
8919
|
}
|
|
7337
8920
|
);
|
|
7338
8921
|
const perFile = [
|
|
7339
|
-
...origin ? ["-iquote",
|
|
8922
|
+
...origin ? ["-iquote", import_node_path14.default.join(layout.root, origin)] : [],
|
|
7340
8923
|
...stageFlags(
|
|
7341
8924
|
settings?.fileFlags[file] ?? [],
|
|
7342
|
-
|
|
8925
|
+
import_node_path14.default.join(
|
|
7343
8926
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
7344
8927
|
"darwin/usr/include"
|
|
7345
8928
|
)
|
|
7346
8929
|
)
|
|
7347
8930
|
];
|
|
7348
8931
|
const cxx = /\.(?:cc|cpp|cxx|mm)$/.test(file);
|
|
7349
|
-
const identity = (0,
|
|
8932
|
+
const identity = (0, import_node_crypto7.createHash)("sha256").update(JSON.stringify([cxx, perFile, (consumers.get(file)?.size ?? 0) > 0])).digest("hex").slice(0, 12);
|
|
7350
8933
|
const group = groups.get(identity) ?? {
|
|
7351
8934
|
name: `${target.name}${nativeC ? "Native" : "Swift"}Implementation_${identity}`,
|
|
7352
8935
|
sources: [],
|
|
@@ -7357,7 +8940,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7357
8940
|
...accessorFlags,
|
|
7358
8941
|
...stageFlags(
|
|
7359
8942
|
cxx ? settings.cxxFlags : [],
|
|
7360
|
-
|
|
8943
|
+
import_node_path14.default.join(
|
|
7361
8944
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
7362
8945
|
"darwin/usr/include"
|
|
7363
8946
|
)
|
|
@@ -7372,7 +8955,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7372
8955
|
stageTargetFile(target.name, accessorHeader, accessor.header);
|
|
7373
8956
|
stageTargetFile(
|
|
7374
8957
|
target.name,
|
|
7375
|
-
|
|
8958
|
+
import_node_path14.default.join(layout.root, accessorUnit),
|
|
7376
8959
|
accessor.body
|
|
7377
8960
|
);
|
|
7378
8961
|
}
|
|
@@ -7387,7 +8970,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7387
8970
|
].sort();
|
|
7388
8971
|
native.set(target.name, {
|
|
7389
8972
|
path: target.path,
|
|
7390
|
-
includeDirectory:
|
|
8973
|
+
includeDirectory: import_node_path14.default.dirname(import_node_path14.default.join(layout.root, modulemap)),
|
|
7391
8974
|
importFlags,
|
|
7392
8975
|
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
7393
8976
|
lateSources: implementations.flatMap((group) => group.sources),
|
|
@@ -7405,15 +8988,15 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7405
8988
|
});
|
|
7406
8989
|
continue;
|
|
7407
8990
|
}
|
|
7408
|
-
const implementationHeaders =
|
|
8991
|
+
const implementationHeaders = import_node_path14.default.posix.join(
|
|
7409
8992
|
".build",
|
|
7410
8993
|
"peach-objc-implementations",
|
|
7411
8994
|
target.name
|
|
7412
8995
|
);
|
|
7413
|
-
const include2 =
|
|
8996
|
+
const include2 = import_node_path14.default.join(layout.root, implementationHeaders);
|
|
7414
8997
|
stageTargetFile(
|
|
7415
8998
|
target.name,
|
|
7416
|
-
|
|
8999
|
+
import_node_path14.default.join(include2, "module.modulemap"),
|
|
7417
9000
|
`module ${target.name}ImplementationDeclarations { export * }
|
|
7418
9001
|
`
|
|
7419
9002
|
);
|
|
@@ -7424,7 +9007,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7424
9007
|
implementationHeaders,
|
|
7425
9008
|
importFlags,
|
|
7426
9009
|
swiftFlags: [
|
|
7427
|
-
...settings.bridgingHeader ? ["-import-objc-header",
|
|
9010
|
+
...settings.bridgingHeader ? ["-import-objc-header", import_node_path14.default.join(layout.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
|
|
7428
9011
|
...importFlags.flatMap((flag) => ["-Xcc", flag])
|
|
7429
9012
|
],
|
|
7430
9013
|
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
@@ -7454,7 +9037,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7454
9037
|
}
|
|
7455
9038
|
native.set(target.name, {
|
|
7456
9039
|
path: target.path,
|
|
7457
|
-
includeDirectory:
|
|
9040
|
+
includeDirectory: import_node_path14.default.join(layout.root, includes),
|
|
7458
9041
|
sources: units.map(([file]) => file.slice(prefix.length)),
|
|
7459
9042
|
lateSources: late.map(([file]) => file.slice(prefix.length)),
|
|
7460
9043
|
...late.length > 0 ? {
|
|
@@ -7472,7 +9055,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7472
9055
|
([file]) => file.startsWith(includes) && /\.(?:h|hpp|hh|hxx)$/.test(file) && consumers.get(file).size === 0
|
|
7473
9056
|
);
|
|
7474
9057
|
files.set(
|
|
7475
|
-
|
|
9058
|
+
import_node_path14.default.join(layout.root, includes, "module.modulemap"),
|
|
7476
9059
|
[
|
|
7477
9060
|
`module ${target.name} {`,
|
|
7478
9061
|
...roots.map(
|
|
@@ -7484,16 +9067,26 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7484
9067
|
].join("\n")
|
|
7485
9068
|
);
|
|
7486
9069
|
}
|
|
7487
|
-
|
|
9070
|
+
for (const map of generatedModuleMaps)
|
|
9071
|
+
if (files.has(map.published) || Object.hasOwn(
|
|
9072
|
+
input.files,
|
|
9073
|
+
import_node_path14.default.relative(layout.root, map.published).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)
|
|
9074
|
+
))
|
|
9075
|
+
(0, import_node_fs10.writeFileSync)(
|
|
9076
|
+
map.output,
|
|
9077
|
+
`extern module ${map.module} ${JSON.stringify(map.published)}
|
|
9078
|
+
`
|
|
9079
|
+
);
|
|
9080
|
+
if (native.size > 0) (0, import_node_fs10.mkdirSync)(headerDirectory, { recursive: true });
|
|
7488
9081
|
const nativeHeaderFlags = [];
|
|
7489
9082
|
for (const name2 of new Set(
|
|
7490
9083
|
[...native.values()].flatMap((value) => value.late?.producers ?? [])
|
|
7491
9084
|
)) {
|
|
7492
9085
|
files.set(
|
|
7493
|
-
|
|
9086
|
+
import_node_path14.default.join(headerDirectory, name2, name2 + "-Swift.h"),
|
|
7494
9087
|
'#include "../' + name2 + '-Swift.h"\n'
|
|
7495
9088
|
);
|
|
7496
|
-
const modulemap =
|
|
9089
|
+
const modulemap = import_node_path14.default.join(
|
|
7497
9090
|
layout.root,
|
|
7498
9091
|
".build",
|
|
7499
9092
|
"peach-objc-swift-headers",
|
|
@@ -7503,19 +9096,19 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7503
9096
|
files.set(
|
|
7504
9097
|
modulemap,
|
|
7505
9098
|
swiftObjCModuleMap(swiftTargetModuleName(name2), [
|
|
7506
|
-
...(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) =>
|
|
7507
|
-
|
|
9099
|
+
...(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) => import_node_path14.default.join(layout.root, header)),
|
|
9100
|
+
import_node_path14.default.join(headerDirectory, name2 + "-Swift.h")
|
|
7508
9101
|
])
|
|
7509
9102
|
);
|
|
7510
9103
|
nativeHeaderFlags.push("-fmodule-map-file=" + modulemap);
|
|
7511
9104
|
}
|
|
7512
|
-
const modulePlan = (0,
|
|
9105
|
+
const modulePlan = (0, import_node_crypto7.createHash)("sha256").update(
|
|
7513
9106
|
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
7514
9107
|
);
|
|
7515
9108
|
if (!distribution) {
|
|
7516
|
-
modulePlan.update((0,
|
|
9109
|
+
modulePlan.update((0, import_node_fs10.readFileSync)(import_node_path14.default.join(moduleRoot, "Package.swift")));
|
|
7517
9110
|
}
|
|
7518
|
-
const resourcePlan = (0,
|
|
9111
|
+
const resourcePlan = (0, import_node_crypto7.createHash)("sha256").update(
|
|
7519
9112
|
JSON.stringify(
|
|
7520
9113
|
resourceTargets.filter((target) => target.resources).map((target) => [
|
|
7521
9114
|
target.name,
|
|
@@ -7560,7 +9153,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7560
9153
|
`;
|
|
7561
9154
|
} else if (mains.length === 0) {
|
|
7562
9155
|
const procedural = entries.filter(
|
|
7563
|
-
([file, source]) =>
|
|
9156
|
+
([file, source]) => import_node_path14.default.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
|
|
7564
9157
|
);
|
|
7565
9158
|
const wrapped = procedural.length === 1 ? wrapUIApplicationMainEntry(procedural[0][1]) : null;
|
|
7566
9159
|
if (!wrapped)
|
|
@@ -7589,7 +9182,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7589
9182
|
exclude: []
|
|
7590
9183
|
});
|
|
7591
9184
|
files.set(
|
|
7592
|
-
|
|
9185
|
+
import_node_path14.default.join(layout.root, `PeachApplication/${name2}/Entry.swift`),
|
|
7593
9186
|
`import ${swiftTargetModuleName(target.name)}
|
|
7594
9187
|
@main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }
|
|
7595
9188
|
`
|
|
@@ -7599,7 +9192,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7599
9192
|
const nativeFlags = native.size > 0 ? /* @__PURE__ */ new Map() : void 0;
|
|
7600
9193
|
if (nativeFlags) {
|
|
7601
9194
|
const toolchainBin = nativeToolchain();
|
|
7602
|
-
const headers =
|
|
9195
|
+
const headers = import_node_path14.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
|
|
7603
9196
|
for (const target of targets) {
|
|
7604
9197
|
const version = deploymentTarget(target.name);
|
|
7605
9198
|
const minimum = iosDeploymentMinimum(version);
|
|
@@ -7630,10 +9223,10 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7630
9223
|
if (targets.length === 0 && !prebuilt) {
|
|
7631
9224
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
7632
9225
|
if (file === "Package.swift") continue;
|
|
7633
|
-
files.set(
|
|
9226
|
+
files.set(import_node_path14.default.join(layout.sources, file), compiled.get(file) ?? contents);
|
|
7634
9227
|
}
|
|
7635
|
-
let manifest = (0,
|
|
7636
|
-
|
|
9228
|
+
let manifest = (0, import_node_fs10.readFileSync)(
|
|
9229
|
+
import_node_path14.default.join(moduleRoot, "scripts/contrast-app-Package.swift"),
|
|
7637
9230
|
"utf8"
|
|
7638
9231
|
).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
|
|
7639
9232
|
const reactor = ` ${REACTOR_FLAG}`;
|
|
@@ -7677,25 +9270,25 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7677
9270
|
manifest = manifest.replace(anchor, `${anchor}
|
|
7678
9271
|
${SPRITEKIT_PRODUCT},`);
|
|
7679
9272
|
}
|
|
7680
|
-
files.set(
|
|
9273
|
+
files.set(import_node_path14.default.join(layout.root, "Package.swift"), manifest + moduleFiles);
|
|
7681
9274
|
} else {
|
|
7682
9275
|
const base = layout.multi ? layout.root : layout.sources;
|
|
7683
9276
|
const libraries = /* @__PURE__ */ new Map();
|
|
7684
9277
|
for (const [target, data] of Object.entries(input.libraries ?? {})) {
|
|
7685
9278
|
const bytes = Buffer.from(data, "base64");
|
|
7686
|
-
const digest = (0,
|
|
7687
|
-
const file =
|
|
9279
|
+
const digest = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex");
|
|
9280
|
+
const file = import_node_path14.default.join(layout.root, ".peach-libraries", `lib${target}-${digest}.a`);
|
|
7688
9281
|
files.set(file, bytes);
|
|
7689
9282
|
libraries.set(target, file);
|
|
7690
9283
|
}
|
|
7691
9284
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
7692
9285
|
if (file === "Package.swift") continue;
|
|
7693
|
-
files.set(
|
|
9286
|
+
files.set(import_node_path14.default.join(base, file), compiled.get(file) ?? contents);
|
|
7694
9287
|
}
|
|
7695
9288
|
const manifestTargets = targets.length > 0 ? targets : [
|
|
7696
9289
|
{
|
|
7697
9290
|
name: "App",
|
|
7698
|
-
path:
|
|
9291
|
+
path: import_node_path14.default.relative(layout.root, layout.sources).split(import_node_path14.default.sep).join("/"),
|
|
7699
9292
|
executable: true,
|
|
7700
9293
|
languageMode: 5,
|
|
7701
9294
|
mainActorIsolation: false,
|
|
@@ -7705,9 +9298,11 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7705
9298
|
const reachesFrameworks = !distribution || Object.entries(input.files).some(
|
|
7706
9299
|
([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
|
|
7707
9300
|
) || [...importedModules].some(
|
|
7708
|
-
(name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2)
|
|
9301
|
+
(name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2) && !(clangImportedModules.has(name2) && !swiftImportedModules.has(name2) && (0, import_node_fs10.existsSync)(
|
|
9302
|
+
import_node_path14.default.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name2)
|
|
9303
|
+
))
|
|
7709
9304
|
);
|
|
7710
|
-
const frameworkLink = prebuilt ?
|
|
9305
|
+
const frameworkLink = prebuilt ? import_node_path14.default.join(layout.root, ".peach-framework-objects.rsp") : void 0;
|
|
7711
9306
|
if (prebuilt && frameworkLink) {
|
|
7712
9307
|
files.set(
|
|
7713
9308
|
frameworkLink,
|
|
@@ -7715,7 +9310,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7715
9310
|
);
|
|
7716
9311
|
}
|
|
7717
9312
|
files.set(
|
|
7718
|
-
|
|
9313
|
+
import_node_path14.default.join(layout.root, "Package.swift"),
|
|
7719
9314
|
emitSwiftPackageManifest({
|
|
7720
9315
|
root: layout.root,
|
|
7721
9316
|
targets: manifestTargets,
|
|
@@ -7749,7 +9344,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7749
9344
|
),
|
|
7750
9345
|
...reachesFrameworks ? {
|
|
7751
9346
|
distributionLink: {
|
|
7752
|
-
path:
|
|
9347
|
+
path: import_node_path14.default.join(layout.root, ".peach-distribution-objects.rsp"),
|
|
7753
9348
|
files
|
|
7754
9349
|
},
|
|
7755
9350
|
lazyDistribution: input.lazyDistribution
|
|
@@ -7768,21 +9363,21 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7768
9363
|
);
|
|
7769
9364
|
}
|
|
7770
9365
|
for (const [file, bytes] of Object.entries(input.packageFiles ?? {}))
|
|
7771
|
-
files.set(
|
|
9366
|
+
files.set(import_node_path14.default.join(layout.root, file), Buffer.from(bytes, "base64"));
|
|
7772
9367
|
for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
|
|
7773
|
-
const destination =
|
|
9368
|
+
const destination = import_node_path14.default.join(layout.root, file);
|
|
7774
9369
|
if (files.has(destination)) continue;
|
|
7775
9370
|
files.set(destination, Buffer.from(bytes, "base64"));
|
|
7776
9371
|
}
|
|
7777
9372
|
if (input.packageFiles || prebuilt) {
|
|
7778
9373
|
files.set(
|
|
7779
|
-
|
|
9374
|
+
import_node_path14.default.join(layout.root, ".peach-target-toolset.json"),
|
|
7780
9375
|
JSON.stringify({
|
|
7781
9376
|
schemaVersion: "1.0",
|
|
7782
9377
|
swiftCompiler: {
|
|
7783
9378
|
extraCLIOptions: [
|
|
7784
9379
|
"-I",
|
|
7785
|
-
distribution ? distributionModulesPath(layout.root, moduleRoot, distributionExcludes) : prebuilt ? prebuilt.modules :
|
|
9380
|
+
distribution ? distributionModulesPath(layout.root, moduleRoot, distributionExcludes) : prebuilt ? prebuilt.modules : import_node_path14.default.join(layout.root, ".build", WASM_TRIPLE, "release", "Modules"),
|
|
7786
9381
|
...prebuilt?.moduleMaps.flatMap((map) => [
|
|
7787
9382
|
"-Xcc",
|
|
7788
9383
|
`-fmodule-map-file=${map}`
|
|
@@ -7811,9 +9406,9 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7811
9406
|
throw new Error(
|
|
7812
9407
|
`swift resource target ${target.name} has no matching bundle assignment`
|
|
7813
9408
|
);
|
|
7814
|
-
const directory = layout.multi ?
|
|
9409
|
+
const directory = layout.multi ? import_node_path14.default.join(layout.root, target.path) : layout.sources;
|
|
7815
9410
|
files.set(
|
|
7816
|
-
|
|
9411
|
+
import_node_path14.default.join(directory, "ResourceBundleAccessor.generated.swift"),
|
|
7817
9412
|
[
|
|
7818
9413
|
"import Foundation",
|
|
7819
9414
|
"",
|
|
@@ -7830,7 +9425,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7830
9425
|
}
|
|
7831
9426
|
for (const [file, source] of compiled)
|
|
7832
9427
|
if (!Object.hasOwn(input.files, file))
|
|
7833
|
-
files.set(
|
|
9428
|
+
files.set(import_node_path14.default.join(layout.multi ? layout.root : layout.sources, file), source);
|
|
7834
9429
|
syncSwiftTree(layout.root, files);
|
|
7835
9430
|
const producers = [
|
|
7836
9431
|
.../* @__PURE__ */ new Set([...[...native.values()].flatMap((value) => value.late?.producers ?? [])])
|
|
@@ -7865,24 +9460,17 @@ function outputOf(error) {
|
|
|
7865
9460
|
return error instanceof Error ? error.message : String(error);
|
|
7866
9461
|
}
|
|
7867
9462
|
function builtArtifact(layout) {
|
|
7868
|
-
const binDir =
|
|
7869
|
-
const manifest = (0,
|
|
9463
|
+
const binDir = import_node_path14.default.join(layout.root, ".build", WASM_TRIPLE, "release");
|
|
9464
|
+
const manifest = (0, import_node_fs10.readFileSync)(import_node_path14.default.join(layout.root, "Package.swift"), "utf8");
|
|
7870
9465
|
const executable = swiftManifestTargets(manifest).find((target) => target.executable);
|
|
7871
9466
|
if (executable === void 0) {
|
|
7872
9467
|
throw new Error("swift-compile: the written manifest names no executable target");
|
|
7873
9468
|
}
|
|
7874
|
-
|
|
7875
|
-
if (!(0, import_node_fs9.existsSync)(file)) {
|
|
7876
|
-
const found = (0, import_node_fs9.existsSync)(binDir) ? (0, import_node_fs9.readdirSync)(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
|
|
7877
|
-
throw new Error(
|
|
7878
|
-
`swift-compile: the build produced no ${executable.name}.wasm (found: ${found.join(", ") || "none"})`
|
|
7879
|
-
);
|
|
7880
|
-
}
|
|
7881
|
-
return file;
|
|
9469
|
+
return import_node_path14.default.join(binDir, `${executable.name}.wasm`);
|
|
7882
9470
|
}
|
|
7883
9471
|
function projectDiagnostic(output, layout, files) {
|
|
7884
9472
|
const base = layout.multi ? layout.root : layout.sources;
|
|
7885
|
-
const prefix = `${base}${
|
|
9473
|
+
const prefix = `${base}${import_node_path14.default.sep}`;
|
|
7886
9474
|
return designTimeDiagnostic(output, files).split("\n").filter((line) => !SWIFTPM_NOISE.test(line)).map((line) => line.startsWith(prefix) ? line.slice(prefix.length) : line).join("\n").trim();
|
|
7887
9475
|
}
|
|
7888
9476
|
var ROOT_LOCKS = Symbol.for("peachsim.swiftCompile.rootLocks");
|
|
@@ -7918,13 +9506,13 @@ function serialize(root, work, signal) {
|
|
|
7918
9506
|
function readCompiledArtifact(directory, hash) {
|
|
7919
9507
|
try {
|
|
7920
9508
|
const receipt = JSON.parse(
|
|
7921
|
-
(0,
|
|
9509
|
+
(0, import_node_fs10.readFileSync)(import_node_path14.default.join(directory, "artifact.json"), "utf8")
|
|
7922
9510
|
);
|
|
7923
9511
|
if (!receipt || typeof receipt !== "object" || !("hash" in receipt) || receipt.hash !== hash || !("icu" in receipt) || typeof receipt.icu !== "string" || !("wasm" in receipt) || typeof receipt.wasm !== "string")
|
|
7924
9512
|
return null;
|
|
7925
|
-
const bytes = (0,
|
|
7926
|
-
const gzip2 = (0,
|
|
7927
|
-
if ((0,
|
|
9513
|
+
const bytes = (0, import_node_fs10.readFileSync)(import_node_path14.default.join(directory, "app.wasm"));
|
|
9514
|
+
const gzip2 = (0, import_node_fs10.readFileSync)(import_node_path14.default.join(directory, "icu.gz"));
|
|
9515
|
+
if ((0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex") !== receipt.wasm || (0, import_node_crypto7.createHash)("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length < 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
|
|
7928
9516
|
return null;
|
|
7929
9517
|
return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 } };
|
|
7930
9518
|
} catch (error) {
|
|
@@ -7934,25 +9522,25 @@ function readCompiledArtifact(directory, hash) {
|
|
|
7934
9522
|
}
|
|
7935
9523
|
}
|
|
7936
9524
|
function saveCompiledArtifact(root, artifact) {
|
|
7937
|
-
const directory =
|
|
7938
|
-
(0,
|
|
7939
|
-
const pending = (0,
|
|
9525
|
+
const directory = import_node_path14.default.join(root, "artifact");
|
|
9526
|
+
(0, import_node_fs10.mkdirSync)(directory, { recursive: true });
|
|
9527
|
+
const pending = (0, import_node_fs10.mkdtempSync)(import_node_path14.default.join(root, ".artifact-"));
|
|
7940
9528
|
try {
|
|
7941
|
-
(0,
|
|
7942
|
-
(0,
|
|
7943
|
-
(0,
|
|
7944
|
-
|
|
9529
|
+
(0, import_node_fs10.writeFileSync)(import_node_path14.default.join(pending, "app.wasm"), artifact.bytes);
|
|
9530
|
+
(0, import_node_fs10.writeFileSync)(import_node_path14.default.join(pending, "icu.gz"), artifact.icu.gzip);
|
|
9531
|
+
(0, import_node_fs10.writeFileSync)(
|
|
9532
|
+
import_node_path14.default.join(pending, "artifact.json"),
|
|
7945
9533
|
JSON.stringify({
|
|
7946
9534
|
hash: artifact.hash,
|
|
7947
|
-
wasm: (0,
|
|
9535
|
+
wasm: (0, import_node_crypto7.createHash)("sha256").update(artifact.bytes).digest("hex"),
|
|
7948
9536
|
icu: artifact.icu.sha256
|
|
7949
9537
|
})
|
|
7950
9538
|
);
|
|
7951
9539
|
for (const file of ["app.wasm", "icu.gz", "artifact.json"]) {
|
|
7952
|
-
(0,
|
|
9540
|
+
(0, import_node_fs10.renameSync)(import_node_path14.default.join(pending, file), import_node_path14.default.join(directory, file));
|
|
7953
9541
|
}
|
|
7954
9542
|
} finally {
|
|
7955
|
-
(0,
|
|
9543
|
+
(0, import_node_fs10.rmSync)(pending, { recursive: true, force: true });
|
|
7956
9544
|
}
|
|
7957
9545
|
}
|
|
7958
9546
|
var SHARED_ARTIFACT_BUDGET_BYTES = 4 * 1024 ** 3;
|
|
@@ -7963,29 +9551,29 @@ function vanished(error) {
|
|
|
7963
9551
|
}
|
|
7964
9552
|
function renewSharedArtifact(sharedRoot) {
|
|
7965
9553
|
try {
|
|
7966
|
-
(0,
|
|
9554
|
+
(0, import_node_fs10.utimesSync)(sharedRoot, /* @__PURE__ */ new Date(), /* @__PURE__ */ new Date());
|
|
7967
9555
|
} catch (error) {
|
|
7968
9556
|
if (!vanished(error)) throw error;
|
|
7969
9557
|
}
|
|
7970
9558
|
}
|
|
7971
9559
|
function pruneSharedArtifacts(parent, keep) {
|
|
7972
9560
|
const entries = [];
|
|
7973
|
-
for (const name2 of (0,
|
|
7974
|
-
const directory =
|
|
9561
|
+
for (const name2 of (0, import_node_fs10.readdirSync)(parent)) {
|
|
9562
|
+
const directory = import_node_path14.default.join(parent, name2);
|
|
7975
9563
|
if (name2.startsWith(RETIRED_PREFIX)) {
|
|
7976
|
-
(0,
|
|
9564
|
+
(0, import_node_fs10.rmSync)(directory, { recursive: true, force: true });
|
|
7977
9565
|
continue;
|
|
7978
9566
|
}
|
|
7979
9567
|
try {
|
|
7980
9568
|
let bytes = 0;
|
|
7981
|
-
for (const file of (0,
|
|
9569
|
+
for (const file of (0, import_node_fs10.readdirSync)(import_node_path14.default.join(directory, "artifact"))) {
|
|
7982
9570
|
try {
|
|
7983
|
-
bytes += (0,
|
|
9571
|
+
bytes += (0, import_node_fs10.statSync)(import_node_path14.default.join(directory, "artifact", file)).size;
|
|
7984
9572
|
} catch (error) {
|
|
7985
9573
|
if (!vanished(error)) throw error;
|
|
7986
9574
|
}
|
|
7987
9575
|
}
|
|
7988
|
-
entries.push({ directory, used: (0,
|
|
9576
|
+
entries.push({ directory, used: (0, import_node_fs10.statSync)(directory).mtimeMs, bytes });
|
|
7989
9577
|
} catch (error) {
|
|
7990
9578
|
if (!vanished(error)) throw error;
|
|
7991
9579
|
}
|
|
@@ -7995,25 +9583,25 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
7995
9583
|
if (total <= SHARED_ARTIFACT_BUDGET_BYTES) break;
|
|
7996
9584
|
if (entry.directory === keep || Date.now() - entry.used < SHARED_ARTIFACT_GRACE_MS)
|
|
7997
9585
|
continue;
|
|
7998
|
-
const retired =
|
|
9586
|
+
const retired = import_node_path14.default.join(
|
|
7999
9587
|
parent,
|
|
8000
|
-
`${RETIRED_PREFIX}${process.pid}-${
|
|
9588
|
+
`${RETIRED_PREFIX}${process.pid}-${import_node_path14.default.basename(entry.directory)}`
|
|
8001
9589
|
);
|
|
8002
9590
|
try {
|
|
8003
|
-
if ((0,
|
|
8004
|
-
(0,
|
|
9591
|
+
if ((0, import_node_fs10.statSync)(entry.directory).mtimeMs !== entry.used) continue;
|
|
9592
|
+
(0, import_node_fs10.renameSync)(entry.directory, retired);
|
|
8005
9593
|
} catch (error) {
|
|
8006
9594
|
if (vanished(error)) continue;
|
|
8007
9595
|
throw error;
|
|
8008
9596
|
}
|
|
8009
|
-
(0,
|
|
9597
|
+
(0, import_node_fs10.rmSync)(retired, { recursive: true, force: true });
|
|
8010
9598
|
total -= entry.bytes;
|
|
8011
9599
|
}
|
|
8012
9600
|
}
|
|
8013
9601
|
function saveSharedArtifact(sharedRoot, artifact) {
|
|
8014
9602
|
saveCompiledArtifact(sharedRoot, artifact);
|
|
8015
9603
|
renewSharedArtifact(sharedRoot);
|
|
8016
|
-
pruneSharedArtifacts(
|
|
9604
|
+
pruneSharedArtifacts(import_node_path14.default.dirname(sharedRoot), sharedRoot);
|
|
8017
9605
|
}
|
|
8018
9606
|
var retainedArtifacts = /* @__PURE__ */ new Map();
|
|
8019
9607
|
function retain(root, artifact) {
|
|
@@ -8041,7 +9629,7 @@ function frameworkLibraryTargets(manifest) {
|
|
|
8041
9629
|
}
|
|
8042
9630
|
function linkedFrameworkTargets(moduleRoot, input) {
|
|
8043
9631
|
const libraries = frameworkLibraryTargets(
|
|
8044
|
-
(0,
|
|
9632
|
+
(0, import_node_fs10.readFileSync)(import_node_path14.default.join(moduleRoot, "Package.swift"), "utf8")
|
|
8045
9633
|
);
|
|
8046
9634
|
const targets = compileTargets(input);
|
|
8047
9635
|
const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
|
|
@@ -8082,7 +9670,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
8082
9670
|
return { products: linked, targets: linkedMembers };
|
|
8083
9671
|
}
|
|
8084
9672
|
function writeFrameworkLinkPackage(linkRoot, moduleRoot, products) {
|
|
8085
|
-
const identity =
|
|
9673
|
+
const identity = import_node_path14.default.basename(moduleRoot).toLowerCase();
|
|
8086
9674
|
const swiftString = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
8087
9675
|
const dependencies = products.map(
|
|
8088
9676
|
(name2) => ` .product(name: ${swiftString(name2)}, package: ${swiftString(identity)}),`
|
|
@@ -8104,13 +9692,13 @@ ${dependencies}
|
|
|
8104
9692
|
]
|
|
8105
9693
|
)
|
|
8106
9694
|
`;
|
|
8107
|
-
const sourceDir =
|
|
8108
|
-
(0,
|
|
8109
|
-
const manifestPath =
|
|
8110
|
-
if (!(0,
|
|
8111
|
-
(0,
|
|
8112
|
-
const source =
|
|
8113
|
-
if (!(0,
|
|
9695
|
+
const sourceDir = import_node_path14.default.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
|
|
9696
|
+
(0, import_node_fs10.mkdirSync)(sourceDir, { recursive: true });
|
|
9697
|
+
const manifestPath = import_node_path14.default.join(linkRoot, "Package.swift");
|
|
9698
|
+
if (!(0, import_node_fs10.existsSync)(manifestPath) || (0, import_node_fs10.readFileSync)(manifestPath, "utf8") !== manifest)
|
|
9699
|
+
(0, import_node_fs10.writeFileSync)(manifestPath, manifest);
|
|
9700
|
+
const source = import_node_path14.default.join(sourceDir, "Link.swift");
|
|
9701
|
+
if (!(0, import_node_fs10.existsSync)(source)) (0, import_node_fs10.writeFileSync)(source, "");
|
|
8114
9702
|
}
|
|
8115
9703
|
function frameworkLinkClosure(scratch2, roots) {
|
|
8116
9704
|
const suffix = `${WASM_TRIPLE}-release`;
|
|
@@ -8121,7 +9709,7 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
8121
9709
|
const moduleMaps = /* @__PURE__ */ new Map();
|
|
8122
9710
|
let pending = null;
|
|
8123
9711
|
let compiling = null;
|
|
8124
|
-
for (const line of (0,
|
|
9712
|
+
for (const line of (0, import_node_fs10.readFileSync)(import_node_path14.default.join(scratch2, "release.yaml"), "utf8").split(
|
|
8125
9713
|
"\n"
|
|
8126
9714
|
)) {
|
|
8127
9715
|
const phony = phonyHeader.exec(line);
|
|
@@ -8180,7 +9768,7 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
8180
9768
|
for (const file of own) {
|
|
8181
9769
|
if (seen.has(file)) continue;
|
|
8182
9770
|
seen.add(file);
|
|
8183
|
-
if (!(0,
|
|
9771
|
+
if (!(0, import_node_fs10.existsSync)(file))
|
|
8184
9772
|
throw new Error(`swift-compile: framework object ${file} was not built`);
|
|
8185
9773
|
files.push(file);
|
|
8186
9774
|
}
|
|
@@ -8189,20 +9777,34 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
8189
9777
|
files.sort();
|
|
8190
9778
|
return { objects: files, modules, moduleMaps: [...maps].sort() };
|
|
8191
9779
|
}
|
|
8192
|
-
function
|
|
8193
|
-
if (!(0,
|
|
8194
|
-
|
|
9780
|
+
function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
|
|
9781
|
+
if (!(0, import_node_fs10.existsSync)(modulesDir)) return;
|
|
9782
|
+
const folded = new Set([...keep].map((name2) => name2.toLowerCase()));
|
|
9783
|
+
for (const name2 of (0, import_node_fs10.readdirSync)(modulesDir)) {
|
|
8195
9784
|
const dot = name2.indexOf(".");
|
|
8196
9785
|
if (dot <= 0) continue;
|
|
8197
|
-
|
|
8198
|
-
(
|
|
9786
|
+
const module2 = name2.slice(0, dot);
|
|
9787
|
+
if (keep.has(module2) || !folded.has(module2.toLowerCase())) continue;
|
|
9788
|
+
(0, import_node_fs10.rmSync)(import_node_path14.default.join(modulesDir, name2), { recursive: true, force: true });
|
|
8199
9789
|
}
|
|
8200
9790
|
}
|
|
8201
9791
|
async function compileFrameworkProducts(args) {
|
|
8202
|
-
const scratch2 = swiftFrameworkScratch(args.
|
|
8203
|
-
(0,
|
|
9792
|
+
const scratch2 = swiftFrameworkScratch(args.frameworkKey);
|
|
9793
|
+
(0, import_node_fs10.mkdirSync)(scratch2, { recursive: true });
|
|
9794
|
+
const now = /* @__PURE__ */ new Date();
|
|
9795
|
+
(0, import_node_fs10.utimesSync)(scratch2, now, now);
|
|
9796
|
+
return withSwiftRootLock(
|
|
9797
|
+
scratch2,
|
|
9798
|
+
(lease) => buildFrameworkProducts(scratch2, {
|
|
9799
|
+
...args,
|
|
9800
|
+
buildOptions: { ...args.buildOptions, lease }
|
|
9801
|
+
}),
|
|
9802
|
+
args.buildOptions.signal
|
|
9803
|
+
);
|
|
9804
|
+
}
|
|
9805
|
+
async function buildFrameworkProducts(scratch2, args) {
|
|
8204
9806
|
const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input);
|
|
8205
|
-
const linkRoot =
|
|
9807
|
+
const linkRoot = import_node_path14.default.join(scratch2, "link");
|
|
8206
9808
|
writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products);
|
|
8207
9809
|
await runCompiler(
|
|
8208
9810
|
args.swift,
|
|
@@ -8219,7 +9821,7 @@ async function compileFrameworkProducts(args) {
|
|
|
8219
9821
|
scratch2,
|
|
8220
9822
|
"--target",
|
|
8221
9823
|
FRAMEWORK_LINK_TARGET,
|
|
8222
|
-
...
|
|
9824
|
+
...swiftCompileSdkOptions(args.moduleRoot, args.toolchainBin),
|
|
8223
9825
|
"--swift-sdk",
|
|
8224
9826
|
args.sdk,
|
|
8225
9827
|
"-c",
|
|
@@ -8246,47 +9848,78 @@ async function compileFrameworkProducts(args) {
|
|
|
8246
9848
|
args.buildOptions,
|
|
8247
9849
|
SWIFTPM_PROGRESS,
|
|
8248
9850
|
SWIFTPM_NOISE
|
|
8249
|
-
)
|
|
8250
|
-
|
|
9851
|
+
).catch((error) => {
|
|
9852
|
+
throw new Error(outputOf(error), { cause: error });
|
|
9853
|
+
});
|
|
9854
|
+
const release = import_node_path14.default.join(scratch2, WASM_TRIPLE, "release");
|
|
8251
9855
|
const linked = frameworkLinkClosure(scratch2, linkedTargets.targets);
|
|
8252
9856
|
const objects = linked.objects;
|
|
8253
|
-
|
|
8254
|
-
const response =
|
|
8255
|
-
(0,
|
|
9857
|
+
removeCaseCollidingModuleArtifacts(import_node_path14.default.join(release, "Modules"), linked.modules);
|
|
9858
|
+
const response = import_node_path14.default.join(scratch2, "autolink-objects.rsp");
|
|
9859
|
+
(0, import_node_fs10.writeFileSync)(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
|
|
8256
9860
|
const extracted = await runCompiler(
|
|
8257
|
-
|
|
9861
|
+
import_node_path14.default.join(args.toolchainBin, "swift-autolink-extract"),
|
|
8258
9862
|
[`@${response}`, "-o", "-"],
|
|
8259
9863
|
args.buildOptions
|
|
8260
9864
|
);
|
|
8261
|
-
(0,
|
|
9865
|
+
(0, import_node_fs10.rmSync)(response, { force: true });
|
|
8262
9866
|
const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
|
|
8263
9867
|
if (link.includes("-lFoundation"))
|
|
8264
9868
|
objects.push(
|
|
8265
|
-
|
|
9869
|
+
import_node_path14.default.join(
|
|
8266
9870
|
swiftSdkPaths(args.moduleRoot, args.toolchainBin).resources,
|
|
8267
9871
|
"wasi/NSStringFormatting.objc.o"
|
|
8268
9872
|
)
|
|
8269
9873
|
);
|
|
8270
9874
|
return {
|
|
8271
|
-
modules:
|
|
9875
|
+
modules: import_node_path14.default.join(release, "Modules"),
|
|
8272
9876
|
objects,
|
|
8273
9877
|
link,
|
|
8274
9878
|
moduleMaps: linked.moduleMaps
|
|
8275
9879
|
};
|
|
8276
9880
|
}
|
|
8277
9881
|
var SWIFT_LINK_STAMP = ".peach-link-stamp";
|
|
8278
|
-
var
|
|
8279
|
-
function
|
|
8280
|
-
return
|
|
9882
|
+
var SWIFT_FRAMEWORK_SCRATCHES_KEPT = 3;
|
|
9883
|
+
function swiftFrameworksDir() {
|
|
9884
|
+
return import_node_path14.default.join(swiftCacheDir(), "swift-frameworks");
|
|
9885
|
+
}
|
|
9886
|
+
function swiftFrameworkScratch(frameworkKey) {
|
|
9887
|
+
return import_node_path14.default.join(swiftFrameworksDir(), frameworkKey);
|
|
9888
|
+
}
|
|
9889
|
+
function stageFrameworkSource(moduleRoot, frameworkKey) {
|
|
9890
|
+
if (swiftDistributionAt(moduleRoot)) return moduleRoot;
|
|
9891
|
+
const staged = import_node_path14.default.join(swiftFrameworkScratch(frameworkKey), "source");
|
|
9892
|
+
const stagedModule = import_node_path14.default.join(staged, "packages", import_node_path14.default.basename(moduleRoot));
|
|
9893
|
+
if ((0, import_node_fs10.existsSync)(import_node_path14.default.join(staged, ".complete"))) return stagedModule;
|
|
9894
|
+
const partial = `${staged}.${(0, import_node_crypto7.randomUUID)()}`;
|
|
9895
|
+
(0, import_node_fs10.mkdirSync)(partial, { recursive: true });
|
|
9896
|
+
(0, import_node_fs10.cpSync)(moduleRoot, import_node_path14.default.join(partial, "packages", import_node_path14.default.basename(moduleRoot)), {
|
|
9897
|
+
recursive: true,
|
|
9898
|
+
preserveTimestamps: true,
|
|
9899
|
+
filter: (source) => import_node_path14.default.relative(moduleRoot, source) !== ".build"
|
|
9900
|
+
});
|
|
9901
|
+
(0, import_node_fs10.cpSync)(
|
|
9902
|
+
swiftSharedSdkRoot(moduleRoot, false),
|
|
9903
|
+
import_node_path14.default.join(partial, "packages/peachsim/sdk/ios"),
|
|
9904
|
+
{ recursive: true, preserveTimestamps: true }
|
|
9905
|
+
);
|
|
9906
|
+
(0, import_node_fs10.symlinkSync)(
|
|
9907
|
+
(0, import_node_fs10.realpathSync)(import_node_path14.default.join(moduleRoot, "../../node_modules")),
|
|
9908
|
+
import_node_path14.default.join(partial, "node_modules")
|
|
9909
|
+
);
|
|
9910
|
+
(0, import_node_fs10.writeFileSync)(import_node_path14.default.join(partial, ".complete"), "");
|
|
9911
|
+
(0, import_node_fs10.rmSync)(staged, { recursive: true, force: true });
|
|
9912
|
+
(0, import_node_fs10.renameSync)(partial, staged);
|
|
9913
|
+
return stagedModule;
|
|
8281
9914
|
}
|
|
8282
9915
|
function swiftLinkStamp(args) {
|
|
8283
|
-
const hash = (0,
|
|
9916
|
+
const hash = (0, import_node_crypto7.createHash)("sha256");
|
|
8284
9917
|
hash.update(`swift-link/v1
|
|
8285
9918
|
${args.frameworkKey}
|
|
8286
9919
|
`);
|
|
8287
9920
|
if (!args.prebuilt) return hash.digest("hex");
|
|
8288
9921
|
const statOf = (file) => {
|
|
8289
|
-
const stat = (0,
|
|
9922
|
+
const stat = (0, import_node_fs10.statSync)(file, { bigint: true });
|
|
8290
9923
|
return `${stat.size}:${stat.mtimeNs}`;
|
|
8291
9924
|
};
|
|
8292
9925
|
for (const object of args.prebuilt.objects)
|
|
@@ -8303,54 +9936,50 @@ ${args.prebuilt.link.join("\n")}
|
|
|
8303
9936
|
hash.update(`modules
|
|
8304
9937
|
${args.prebuilt.modules}
|
|
8305
9938
|
`);
|
|
8306
|
-
for (const entry of (0,
|
|
9939
|
+
for (const entry of (0, import_node_fs10.readdirSync)(args.prebuilt.modules).sort())
|
|
8307
9940
|
hash.update(`${entry}
|
|
8308
|
-
${statOf(
|
|
9941
|
+
${statOf(import_node_path14.default.join(args.prebuilt.modules, entry))}`);
|
|
8309
9942
|
return hash.digest("hex");
|
|
8310
9943
|
}
|
|
8311
|
-
function
|
|
8312
|
-
const
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
const scratch2 = swiftFrameworkScratch(root);
|
|
8322
|
-
if (previous === key || !(0, import_node_fs9.existsSync)(scratch2)) return false;
|
|
8323
|
-
(0, import_node_fs9.rmSync)(scratch2, { recursive: true, force: true });
|
|
8324
|
-
return true;
|
|
9944
|
+
async function pruneFrameworkScratches(keep) {
|
|
9945
|
+
const dir = swiftFrameworksDir();
|
|
9946
|
+
const idle = (0, import_node_fs10.readdirSync)(dir).filter((name2) => name2 !== keep).map((name2) => ({ name: name2, modified: (0, import_node_fs10.statSync)(import_node_path14.default.join(dir, name2)).mtimeMs })).sort((left, right) => right.modified - left.modified).slice(SWIFT_FRAMEWORK_SCRATCHES_KEPT - 1);
|
|
9947
|
+
for (const { name: name2 } of idle)
|
|
9948
|
+
await withSwiftRootLock(
|
|
9949
|
+
import_node_path14.default.join(dir, name2),
|
|
9950
|
+
async () => (0, import_node_fs10.rmSync)(import_node_path14.default.join(dir, name2), { recursive: true, force: true }),
|
|
9951
|
+
void 0,
|
|
9952
|
+
false
|
|
9953
|
+
);
|
|
8325
9954
|
}
|
|
8326
9955
|
function retireStaleSwiftLink(root, stamp) {
|
|
8327
|
-
const receipt =
|
|
9956
|
+
const receipt = import_node_path14.default.join(root, SWIFT_LINK_STAMP);
|
|
8328
9957
|
let previous = null;
|
|
8329
9958
|
try {
|
|
8330
|
-
previous = (0,
|
|
9959
|
+
previous = (0, import_node_fs10.readFileSync)(receipt, "utf8").trim();
|
|
8331
9960
|
} catch (error) {
|
|
8332
9961
|
if (!vanished(error)) throw error;
|
|
8333
9962
|
}
|
|
8334
|
-
(0,
|
|
9963
|
+
(0, import_node_fs10.writeFileSync)(receipt, `${stamp}
|
|
8335
9964
|
`);
|
|
8336
|
-
const retired =
|
|
8337
|
-
if (previous === stamp || !(0,
|
|
8338
|
-
(0,
|
|
9965
|
+
const retired = import_node_path14.default.join(root, ".build");
|
|
9966
|
+
if (previous === stamp || !(0, import_node_fs10.existsSync)(retired)) return false;
|
|
9967
|
+
(0, import_node_fs10.rmSync)(retired, { recursive: true, force: true });
|
|
8339
9968
|
return true;
|
|
8340
9969
|
}
|
|
8341
9970
|
function compileSwiftProjectUnit(input, options) {
|
|
8342
9971
|
options.signal?.throwIfAborted();
|
|
8343
|
-
(0,
|
|
8344
|
-
const root = (0,
|
|
8345
|
-
const moduleRoot =
|
|
9972
|
+
(0, import_node_fs10.mkdirSync)(options.buildRoot, { recursive: true });
|
|
9973
|
+
const root = (0, import_node_fs10.realpathSync)(options.buildRoot);
|
|
9974
|
+
const moduleRoot = import_node_path14.default.resolve(options.moduleRoot);
|
|
8346
9975
|
const layout = {
|
|
8347
9976
|
root,
|
|
8348
|
-
sources:
|
|
9977
|
+
sources: import_node_path14.default.join(root, "Sources", "App"),
|
|
8349
9978
|
multi: compileTargets(input).length > 0
|
|
8350
9979
|
};
|
|
8351
9980
|
const hash = swiftArtifactHash(input, options.release, moduleRoot);
|
|
8352
9981
|
const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
|
|
8353
|
-
const sharedRoot =
|
|
9982
|
+
const sharedRoot = import_node_path14.default.join(swiftCacheDir(), "swift-projects", hash);
|
|
8354
9983
|
const report = (message) => {
|
|
8355
9984
|
console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
|
|
8356
9985
|
options.onStage?.(message);
|
|
@@ -8364,8 +9993,8 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8364
9993
|
report("reusing memory artifact");
|
|
8365
9994
|
return retain(root, retained);
|
|
8366
9995
|
}
|
|
8367
|
-
const cached = readCompiledArtifact(
|
|
8368
|
-
const previous = cached ?? readCompiledArtifact(
|
|
9996
|
+
const cached = readCompiledArtifact(import_node_path14.default.join(sharedRoot, "artifact"), hash);
|
|
9997
|
+
const previous = cached ?? readCompiledArtifact(import_node_path14.default.join(root, "artifact"), hash);
|
|
8369
9998
|
if (previous) {
|
|
8370
9999
|
if (cached) renewSharedArtifact(sharedRoot);
|
|
8371
10000
|
else saveSharedArtifact(sharedRoot, previous);
|
|
@@ -8373,10 +10002,10 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8373
10002
|
return retain(root, previous);
|
|
8374
10003
|
}
|
|
8375
10004
|
if (process.platform === "darwin" && process.env.TM_SESSION && !admittedMacBuilderSlot() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
|
|
8376
|
-
const requestRoot = (0,
|
|
8377
|
-
const output =
|
|
8378
|
-
const request =
|
|
8379
|
-
(0,
|
|
10005
|
+
const requestRoot = (0, import_node_fs10.mkdtempSync)(`${root}.builder-request-`);
|
|
10006
|
+
const output = import_node_path14.default.join(requestRoot, "output");
|
|
10007
|
+
const request = import_node_path14.default.join(requestRoot, "request.json");
|
|
10008
|
+
(0, import_node_fs10.writeFileSync)(
|
|
8380
10009
|
request,
|
|
8381
10010
|
JSON.stringify({
|
|
8382
10011
|
input,
|
|
@@ -8389,12 +10018,12 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8389
10018
|
})
|
|
8390
10019
|
);
|
|
8391
10020
|
try {
|
|
8392
|
-
const repo =
|
|
10021
|
+
const repo = import_node_path14.default.resolve(moduleRoot, "../..");
|
|
8393
10022
|
report("requesting builder admission or cached result");
|
|
8394
10023
|
await runCompiler(
|
|
8395
10024
|
"bun",
|
|
8396
10025
|
[
|
|
8397
|
-
|
|
10026
|
+
import_node_path14.default.join(repo, "scripts/build/swift-project.ts"),
|
|
8398
10027
|
"--request",
|
|
8399
10028
|
request,
|
|
8400
10029
|
"--output",
|
|
@@ -8422,33 +10051,40 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8422
10051
|
report("builder artifact verified");
|
|
8423
10052
|
return retain(root, artifact);
|
|
8424
10053
|
} finally {
|
|
8425
|
-
(0,
|
|
10054
|
+
(0, import_node_fs10.rmSync)(requestRoot, { recursive: true, force: true });
|
|
8426
10055
|
}
|
|
8427
10056
|
}
|
|
8428
10057
|
return withSwiftRootLock(
|
|
8429
10058
|
root,
|
|
8430
10059
|
async (lease) => {
|
|
8431
|
-
const built = readCompiledArtifact(
|
|
10060
|
+
const built = readCompiledArtifact(import_node_path14.default.join(sharedRoot, "artifact"), hash);
|
|
8432
10061
|
if (built) {
|
|
8433
10062
|
report("reusing verified disk artifact");
|
|
8434
10063
|
return retain(root, built);
|
|
8435
10064
|
}
|
|
8436
|
-
const swift =
|
|
8437
|
-
if (!(0,
|
|
10065
|
+
const swift = import_node_path14.default.join(options.toolchainBin, "swift");
|
|
10066
|
+
if (!(0, import_node_fs10.existsSync)(swift)) {
|
|
8438
10067
|
throw new Error(
|
|
8439
10068
|
`swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
|
|
8440
10069
|
);
|
|
8441
10070
|
}
|
|
8442
|
-
|
|
8443
|
-
|
|
10071
|
+
const frameworkRoot = await withSwiftRootLock(
|
|
10072
|
+
swiftFrameworkScratch(frameworkKey),
|
|
10073
|
+
async () => stageFrameworkSource(moduleRoot, frameworkKey),
|
|
10074
|
+
options.signal
|
|
10075
|
+
);
|
|
8444
10076
|
report("preparing compiler plugins");
|
|
8445
|
-
const macroPlugins = await
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
10077
|
+
const macroPlugins = await withSwiftRootLock(
|
|
10078
|
+
swiftFrameworkScratch(frameworkKey),
|
|
10079
|
+
async () => ensureMacroPlugins(
|
|
10080
|
+
frameworkRoot,
|
|
10081
|
+
options.toolchainBin,
|
|
10082
|
+
options.release,
|
|
10083
|
+
options.signal
|
|
10084
|
+
),
|
|
8449
10085
|
options.signal
|
|
8450
10086
|
);
|
|
8451
|
-
const sdk = swiftModuleSdk(
|
|
10087
|
+
const sdk = swiftModuleSdk(frameworkRoot).wasmSdkId;
|
|
8452
10088
|
const icu = swiftIcuAsset(options.toolchainBin, sdk);
|
|
8453
10089
|
const buildOptions = {
|
|
8454
10090
|
env: {
|
|
@@ -8456,11 +10092,12 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8456
10092
|
// shipped host plugins resolve against the selected compiler's runtime.
|
|
8457
10093
|
...process.platform === "linux" ? {
|
|
8458
10094
|
LD_LIBRARY_PATH: [
|
|
8459
|
-
|
|
8460
|
-
|
|
10095
|
+
import_node_path14.default.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
10096
|
+
import_node_path14.default.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
8461
10097
|
process.env.LD_LIBRARY_PATH
|
|
8462
10098
|
].filter(Boolean).join(":")
|
|
8463
|
-
} : {}
|
|
10099
|
+
} : {},
|
|
10100
|
+
...input.lazyDistribution ? { PEACH_DEFER_WASM_LINK: "1" } : {}
|
|
8464
10101
|
},
|
|
8465
10102
|
maxBuffer: 64 * 1024 * 1024,
|
|
8466
10103
|
timeout: options.timeoutMs,
|
|
@@ -8471,8 +10108,8 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8471
10108
|
if (!swiftDistributionAt(moduleRoot)) {
|
|
8472
10109
|
report("compiling framework products");
|
|
8473
10110
|
prebuilt = await compileFrameworkProducts({
|
|
8474
|
-
moduleRoot,
|
|
8475
|
-
|
|
10111
|
+
moduleRoot: frameworkRoot,
|
|
10112
|
+
frameworkKey,
|
|
8476
10113
|
input,
|
|
8477
10114
|
swift,
|
|
8478
10115
|
sdk,
|
|
@@ -8480,6 +10117,7 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8480
10117
|
plugins: macroPlugins,
|
|
8481
10118
|
buildOptions
|
|
8482
10119
|
});
|
|
10120
|
+
await pruneFrameworkScratches(frameworkKey);
|
|
8483
10121
|
}
|
|
8484
10122
|
if (retireStaleSwiftLink(
|
|
8485
10123
|
root,
|
|
@@ -8489,7 +10127,7 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8489
10127
|
})
|
|
8490
10128
|
))
|
|
8491
10129
|
report("framework revision changed; rebuilding the app link");
|
|
8492
|
-
const preparation = writeSwiftProject(layout, input,
|
|
10130
|
+
const preparation = writeSwiftProject(layout, input, frameworkRoot, prebuilt);
|
|
8493
10131
|
writeSwiftAutolinkLinker(root, options.toolchainBin);
|
|
8494
10132
|
const unprepared = preparation.targetFailures.map(
|
|
8495
10133
|
(failure) => `error: target ${failure}`
|
|
@@ -8503,10 +10141,10 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8503
10141
|
BUILD_JOBS,
|
|
8504
10142
|
"--package-path",
|
|
8505
10143
|
root,
|
|
8506
|
-
...
|
|
10144
|
+
...swiftCompileSdkOptions(frameworkRoot, options.toolchainBin),
|
|
8507
10145
|
"--swift-sdk",
|
|
8508
10146
|
sdk,
|
|
8509
|
-
...input.packageFiles || prebuilt ? ["--toolset",
|
|
10147
|
+
...input.packageFiles || prebuilt ? ["--toolset", import_node_path14.default.join(root, ".peach-target-toolset.json")] : [],
|
|
8510
10148
|
"-c",
|
|
8511
10149
|
"release",
|
|
8512
10150
|
"-Xswiftc",
|
|
@@ -8528,6 +10166,12 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8528
10166
|
`${plugin}#ExpoModulesMacros`
|
|
8529
10167
|
])
|
|
8530
10168
|
];
|
|
10169
|
+
const linked = builtArtifact(layout);
|
|
10170
|
+
if (input.lazyDistribution) {
|
|
10171
|
+
(0, import_node_fs10.rmSync)(import_node_path14.default.join(root, ".peach-link.rsp"), { force: true });
|
|
10172
|
+
if ((0, import_node_fs10.existsSync)(linked) && (0, import_node_fs10.statSync)(linked).size <= 8)
|
|
10173
|
+
(0, import_node_fs10.rmSync)(linked, { force: true });
|
|
10174
|
+
}
|
|
8531
10175
|
report("compiling and linking Swift modules");
|
|
8532
10176
|
try {
|
|
8533
10177
|
for (const producer of preparation.headerProducers) {
|
|
@@ -8548,15 +10192,15 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8548
10192
|
);
|
|
8549
10193
|
} catch (error) {
|
|
8550
10194
|
const output = outputOf(error);
|
|
8551
|
-
const moduleCache =
|
|
10195
|
+
const moduleCache = import_node_path14.default.join(
|
|
8552
10196
|
root,
|
|
8553
10197
|
".build",
|
|
8554
10198
|
WASM_TRIPLE,
|
|
8555
10199
|
"release",
|
|
8556
10200
|
"ModuleCache"
|
|
8557
10201
|
);
|
|
8558
|
-
if (output.includes("was compiled with module cache path") && (0,
|
|
8559
|
-
(0,
|
|
10202
|
+
if (output.includes("was compiled with module cache path") && (0, import_node_fs10.existsSync)(moduleCache)) {
|
|
10203
|
+
(0, import_node_fs10.rmSync)(moduleCache, { recursive: true, force: true });
|
|
8560
10204
|
try {
|
|
8561
10205
|
await runCompiler(
|
|
8562
10206
|
swift,
|
|
@@ -8584,9 +10228,21 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8584
10228
|
}
|
|
8585
10229
|
}
|
|
8586
10230
|
if (unprepared.length) throw new Error(unprepared.join("\n"));
|
|
10231
|
+
if (!(0, import_node_fs10.existsSync)(linked)) {
|
|
10232
|
+
const binDir = import_node_path14.default.dirname(linked);
|
|
10233
|
+
const found = (0, import_node_fs10.existsSync)(binDir) ? (0, import_node_fs10.readdirSync)(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
|
|
10234
|
+
throw new Error(
|
|
10235
|
+
`swift-compile: the build produced no ${import_node_path14.default.basename(linked)} (found: ${found.join(", ") || "none"})`
|
|
10236
|
+
);
|
|
10237
|
+
}
|
|
10238
|
+
const optimized = `${linked}.optimized`;
|
|
10239
|
+
if (input.lazyDistribution) {
|
|
10240
|
+
pruneSwiftWasmLink(root, options.toolchainBin, frameworkRoot);
|
|
10241
|
+
await optimizeWasm(linked, optimized);
|
|
10242
|
+
}
|
|
8587
10243
|
const artifact = {
|
|
8588
10244
|
hash,
|
|
8589
|
-
bytes: (0,
|
|
10245
|
+
bytes: (0, import_node_fs10.readFileSync)(input.lazyDistribution ? optimized : linked),
|
|
8590
10246
|
icu: await icu
|
|
8591
10247
|
};
|
|
8592
10248
|
saveCompiledArtifact(root, artifact);
|
|
@@ -8610,6 +10266,7 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8610
10266
|
compileTargets,
|
|
8611
10267
|
emitSwiftPackageManifest,
|
|
8612
10268
|
ensureMacroPlugins,
|
|
10269
|
+
foundationOwnerOf,
|
|
8613
10270
|
lowerAVAssetURLCluster,
|
|
8614
10271
|
lowerNSValueTimeBox,
|
|
8615
10272
|
missingSwiftModules,
|
|
@@ -8622,12 +10279,14 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8622
10279
|
swiftCMainEntry,
|
|
8623
10280
|
swiftCPredefines,
|
|
8624
10281
|
swiftCodeMask,
|
|
10282
|
+
swiftCompileSdkOptions,
|
|
8625
10283
|
swiftDistributionAt,
|
|
8626
10284
|
swiftIcuAsset,
|
|
8627
10285
|
swiftImportNames,
|
|
8628
10286
|
swiftMacroPlugins,
|
|
8629
10287
|
swiftModuleDigest,
|
|
8630
10288
|
swiftModuleInputFiles,
|
|
10289
|
+
swiftModuleInterface,
|
|
8631
10290
|
swiftModuleSdk,
|
|
8632
10291
|
swiftPeachModules,
|
|
8633
10292
|
swiftProjectBuildKey,
|