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,11 +1,11 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.1744 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
|
|
3
3
|
// src/swift-compile.ts
|
|
4
4
|
import {
|
|
5
5
|
spawn as spawn3,
|
|
6
|
-
execFileSync as
|
|
6
|
+
execFileSync as execFileSync5
|
|
7
7
|
} from "node:child_process";
|
|
8
|
-
import { createHash as
|
|
8
|
+
import { createHash as createHash8, randomUUID as randomUUID3 } from "node:crypto";
|
|
9
9
|
import {
|
|
10
10
|
cpSync,
|
|
11
11
|
existsSync as existsSync2,
|
|
@@ -21,8 +21,8 @@ import {
|
|
|
21
21
|
utimesSync,
|
|
22
22
|
writeFileSync as writeFileSync3
|
|
23
23
|
} from "node:fs";
|
|
24
|
-
import
|
|
25
|
-
import
|
|
24
|
+
import os3 from "node:os";
|
|
25
|
+
import path14 from "node:path";
|
|
26
26
|
|
|
27
27
|
// src/admitted-mac-build.ts
|
|
28
28
|
import { spawnSync } from "node:child_process";
|
|
@@ -54,7 +54,7 @@ function admittedMacBuilderSlot(env = process.env) {
|
|
|
54
54
|
|
|
55
55
|
// src/generated/swift-c-predefines.json
|
|
56
56
|
var swift_c_predefines_default = {
|
|
57
|
-
release: "swift-6.4.0-RELEASE-custom-
|
|
57
|
+
release: "swift-6.4.0-RELEASE-custom-81b2c791c27276bf",
|
|
58
58
|
languages: {
|
|
59
59
|
c: {
|
|
60
60
|
TARGET_IPHONE_SIMULATOR: "1",
|
|
@@ -2104,10 +2104,13 @@ import fs from "node:fs";
|
|
|
2104
2104
|
import { homedir } from "node:os";
|
|
2105
2105
|
import path from "node:path";
|
|
2106
2106
|
var PEACH_HOME_ENV = "PEACH_HOME";
|
|
2107
|
+
function ambientHomeDir() {
|
|
2108
|
+
return path.join(homedir(), ".peach");
|
|
2109
|
+
}
|
|
2107
2110
|
function rnxHomeDir() {
|
|
2108
2111
|
const override = process.env[PEACH_HOME_ENV];
|
|
2109
2112
|
if (override && override.length > 0) return path.resolve(override);
|
|
2110
|
-
return
|
|
2113
|
+
return ambientHomeDir();
|
|
2111
2114
|
}
|
|
2112
2115
|
function cacheDir() {
|
|
2113
2116
|
return path.join(rnxHomeDir(), "cache");
|
|
@@ -2822,9 +2825,9 @@ var EXCERPT = /^(\s*)(\d+)( \| )(.*)$/;
|
|
|
2822
2825
|
var MARKER = /^(\s*)( \| )(.*)$/;
|
|
2823
2826
|
function designTimeDiagnostic(output, files) {
|
|
2824
2827
|
const rewritten = /* @__PURE__ */ new Map();
|
|
2825
|
-
const linesOf = (
|
|
2828
|
+
const linesOf = (path15) => {
|
|
2826
2829
|
const file = Object.keys(files).find(
|
|
2827
|
-
(name2) => name2.endsWith(".swift") && (
|
|
2830
|
+
(name2) => name2.endsWith(".swift") && (path15 === name2 || path15.endsWith(`/${name2}`))
|
|
2828
2831
|
);
|
|
2829
2832
|
if (file === void 0) return null;
|
|
2830
2833
|
let lines = rewritten.get(file);
|
|
@@ -2941,23 +2944,40 @@ function swiftSdkOptions() {
|
|
|
2941
2944
|
}
|
|
2942
2945
|
return [];
|
|
2943
2946
|
}
|
|
2944
|
-
var SWIFT_HOST_COMPILER_RELEASE = "swift-6.4.0-RELEASE-custom-
|
|
2945
|
-
var SWIFT_HOST_COMPILER_ID = "
|
|
2947
|
+
var SWIFT_HOST_COMPILER_RELEASE = "swift-6.4.0-RELEASE-custom-81b2c791c27276bf";
|
|
2948
|
+
var SWIFT_HOST_COMPILER_ID = "81b2c791c27276bf";
|
|
2946
2949
|
var compilerArchives = {
|
|
2947
|
-
"swift-6.4.0-RELEASE-custom-
|
|
2948
|
-
identity: "
|
|
2950
|
+
"swift-6.4.0-RELEASE-custom-0b2d0a9011c88e66": {
|
|
2951
|
+
identity: "0b2d0a9011c88e66",
|
|
2952
|
+
hosts: {
|
|
2953
|
+
"darwin-arm64": {
|
|
2954
|
+
checksum: "dc6a494227297ea657e8e5f7c5b4a861cb5e142bdbcfcb028ace2aeb19db90cc",
|
|
2955
|
+
manifest: "d8e9eee0fb9b847f1e9350525d6c68606df46101745f553332309ed026b3c26a"
|
|
2956
|
+
},
|
|
2957
|
+
"linux-x64": {
|
|
2958
|
+
checksum: "85c04b4496aea1657c21a47f448e01d6ccc1c7920d130a566db37fb8350a7be2",
|
|
2959
|
+
manifest: "8451659e74235ad53b700c1afbe293512197900eb98cb1f79e36df2f5c85d511"
|
|
2960
|
+
},
|
|
2961
|
+
"linux-arm64": {
|
|
2962
|
+
checksum: "196606ed62c5c926d18e6ef0769cb1ab21c9943f9084070ddf14a7bc696768b8",
|
|
2963
|
+
manifest: "85fb8d5b6527bd75003a6dbd25b68b22540665cf9df9b13f41f82e5d8acdbf1d"
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2966
|
+
},
|
|
2967
|
+
"swift-6.4.0-RELEASE-custom-f7c03c3f59ec5d83": {
|
|
2968
|
+
identity: "f7c03c3f59ec5d83",
|
|
2949
2969
|
hosts: {
|
|
2950
2970
|
"darwin-arm64": {
|
|
2951
|
-
checksum: "
|
|
2952
|
-
manifest: "
|
|
2971
|
+
checksum: "8946a2d4716d3b0784cef7a85a35f66537bd319c4c5a48c63457d607260df5c5",
|
|
2972
|
+
manifest: "2a7754e6e365bf71ae6b6aefbbd810123795c73d43fb902a8a972d009d72790f"
|
|
2953
2973
|
},
|
|
2954
2974
|
"linux-x64": {
|
|
2955
|
-
checksum: "
|
|
2956
|
-
manifest: "
|
|
2975
|
+
checksum: "5ffa3b54d54583c1d6a38b708693072db4d088ba4bf5966b17014c068b2db641",
|
|
2976
|
+
manifest: "1b23ea52c5570de4697481a54bd0b0a0bcd6b54feccb7b0bb940d3643dec82cb"
|
|
2957
2977
|
},
|
|
2958
2978
|
"linux-arm64": {
|
|
2959
|
-
checksum: "
|
|
2960
|
-
manifest: "
|
|
2979
|
+
checksum: "29b0b97b7b0db4475dbe55f7011e57f493fed9f3482a6705becebd8b68c90bab",
|
|
2980
|
+
manifest: "3fdab1132715f5899de1bb1d7ddcd52cf540295ab86586c72f49502f37a403a1"
|
|
2961
2981
|
}
|
|
2962
2982
|
}
|
|
2963
2983
|
},
|
|
@@ -2965,20 +2985,36 @@ var compilerArchives = {
|
|
|
2965
2985
|
identity: SWIFT_HOST_COMPILER_ID,
|
|
2966
2986
|
hosts: {
|
|
2967
2987
|
"darwin-arm64": {
|
|
2968
|
-
checksum: "
|
|
2969
|
-
manifest: "
|
|
2988
|
+
checksum: "bc51b83d9e2e01c9873875326544734486d3ff3a868d650379c304045e8838d3",
|
|
2989
|
+
manifest: "a26eb9cb4fbd1dbd7faac20cced1ec5e67745bd358aa1180cc4abc1a0d21d6e6"
|
|
2970
2990
|
},
|
|
2971
2991
|
"linux-x64": {
|
|
2972
|
-
checksum: "
|
|
2973
|
-
manifest: "
|
|
2992
|
+
checksum: "ea63bbdecae14ff8e9e3f535b521fedc65d51b31521c5d10cc332cb91882d058",
|
|
2993
|
+
manifest: "b22b321ce3eb3fe044fa2122484a15c061f262c45d88a05b3fbace0a5bf038b6"
|
|
2974
2994
|
},
|
|
2975
2995
|
"linux-arm64": {
|
|
2976
|
-
checksum: "
|
|
2977
|
-
manifest: "
|
|
2996
|
+
checksum: "3eef4ed57830908515d8def2882e312f7cabeea57ccda5b2a7585401ef98cc48",
|
|
2997
|
+
manifest: "cfab342b8090fa83a697a391a7563cba14b771c24f07e1f8e19977f913ac88be"
|
|
2978
2998
|
}
|
|
2979
2999
|
}
|
|
2980
3000
|
}
|
|
2981
3001
|
};
|
|
3002
|
+
var SWIFT_PRIVATE_DISTRIBUTION_ENV = "PEACH_SWIFT_PRIVATE_DISTRIBUTION";
|
|
3003
|
+
function privateSwiftDistributionRoot() {
|
|
3004
|
+
const root = process.env[SWIFT_PRIVATE_DISTRIBUTION_ENV]?.trim();
|
|
3005
|
+
return root ? path4.resolve(root) : null;
|
|
3006
|
+
}
|
|
3007
|
+
function privateSwiftRelease() {
|
|
3008
|
+
const root = privateSwiftDistributionRoot();
|
|
3009
|
+
if (!root) return null;
|
|
3010
|
+
const manifest = JSON.parse(
|
|
3011
|
+
fs2.readFileSync(path4.join(root, "distribution.json"), "utf8")
|
|
3012
|
+
);
|
|
3013
|
+
const release = manifest && typeof manifest === "object" && Reflect.get(manifest, "release");
|
|
3014
|
+
if (typeof release !== "string")
|
|
3015
|
+
throw new Error(`${root} holds no Swift distribution release`);
|
|
3016
|
+
return release;
|
|
3017
|
+
}
|
|
2982
3018
|
function swiftHostCompilerArchive(release, host2 = `${process.platform}-${process.arch}`) {
|
|
2983
3019
|
const compiler = compilerArchives[release];
|
|
2984
3020
|
if (!compiler) throw new Error(`unqualified host compiler ${release}`);
|
|
@@ -3026,6 +3062,14 @@ for arg in "$@"; do
|
|
|
3026
3062
|
rsp=\${arg#@}
|
|
3027
3063
|
awk 'BEGIN { RS = " "; ORS = " " } /^"-l/ { if (seen[$0]++) next } { print }' "$rsp" > "$rsp.dedup"
|
|
3028
3064
|
mv "$rsp.dedup" "$rsp"
|
|
3065
|
+
if [ "\${PEACH_DEFER_WASM_LINK:-}" = "1" ] && grep -q '"--start-lib"' "$rsp"; then
|
|
3066
|
+
cp "$rsp" ${JSON.stringify(path4.join(directory, ".peach-link.rsp"))}
|
|
3067
|
+
out=$(awk 'BEGIN { RS = " " } prev == "\\"'-o'\\"" { gsub(/^"|"[[:space:]]*$/, ""); print; exit } { prev = $0 }' "$rsp")
|
|
3068
|
+
if [ -n "$out" ]; then
|
|
3069
|
+
printf '\\000asm\\001\\000\\000\\000' > "$out"
|
|
3070
|
+
exit 0
|
|
3071
|
+
fi
|
|
3072
|
+
fi
|
|
3029
3073
|
;;
|
|
3030
3074
|
esac
|
|
3031
3075
|
done
|
|
@@ -3043,15 +3087,20 @@ function peachHome() {
|
|
|
3043
3087
|
return override ? path4.resolve(override) : path4.join(os.homedir(), ".peach");
|
|
3044
3088
|
}
|
|
3045
3089
|
var scratch;
|
|
3090
|
+
var linuxLibraryPath;
|
|
3046
3091
|
function swiftEnvironment(base = process.env) {
|
|
3047
|
-
if (!scratch) return base;
|
|
3048
3092
|
return {
|
|
3049
3093
|
...base,
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3094
|
+
...linuxLibraryPath ? {
|
|
3095
|
+
LD_LIBRARY_PATH: [linuxLibraryPath, base.LD_LIBRARY_PATH].filter(Boolean).join(":")
|
|
3096
|
+
} : {},
|
|
3097
|
+
...scratch ? {
|
|
3098
|
+
TMPDIR: scratch.directory,
|
|
3099
|
+
XDG_CONFIG_HOME: path4.join(scratch.home, ".config"),
|
|
3100
|
+
XDG_CACHE_HOME: path4.join(scratch.home, ".cache"),
|
|
3101
|
+
XDG_DATA_HOME: path4.join(scratch.home, ".local", "share"),
|
|
3102
|
+
...process.platform === "linux" ? { HOME: scratch.home } : {}
|
|
3103
|
+
} : {}
|
|
3055
3104
|
};
|
|
3056
3105
|
}
|
|
3057
3106
|
function swiftSourceSdk(root) {
|
|
@@ -3186,8 +3235,11 @@ function swiftFileChecksum(file) {
|
|
|
3186
3235
|
return hash.digest("hex");
|
|
3187
3236
|
}
|
|
3188
3237
|
function verifySwiftHostCompiler(release, root) {
|
|
3189
|
-
const pin = swiftHostCompilerArchive(release);
|
|
3190
3238
|
const file = path4.join(root, "compiler.json");
|
|
3239
|
+
const pin = release === privateSwiftRelease() ? {
|
|
3240
|
+
identity: release.replace(/^.*-custom-/, ""),
|
|
3241
|
+
manifest: swiftFileChecksum(file)
|
|
3242
|
+
} : swiftHostCompilerArchive(release);
|
|
3191
3243
|
if (swiftFileChecksum(file) !== pin.manifest)
|
|
3192
3244
|
throw new Error(`Swift compiler manifest mismatch at ${root}`);
|
|
3193
3245
|
const manifest = JSON.parse(fs2.readFileSync(file, "utf8"));
|
|
@@ -3238,6 +3290,8 @@ function swiftInstallSteps(release, wasmSdk) {
|
|
|
3238
3290
|
].join("\n");
|
|
3239
3291
|
}
|
|
3240
3292
|
function swiftCompilerInstall(release) {
|
|
3293
|
+
if (release === privateSwiftRelease())
|
|
3294
|
+
return { note: " (private: its builder installs it)", commands: [] };
|
|
3241
3295
|
if (release.includes("-custom-")) {
|
|
3242
3296
|
const archive = swiftHostCompilerArchive(release);
|
|
3243
3297
|
const directory = path4.resolve(swiftToolchainBin(release), "../..");
|
|
@@ -3388,12 +3442,7 @@ function icuSegment(object) {
|
|
|
3388
3442
|
// src/swift-link-roots.ts
|
|
3389
3443
|
import fs3 from "node:fs";
|
|
3390
3444
|
import path6 from "node:path";
|
|
3391
|
-
var OBJC_SEGMENTS = [
|
|
3392
|
-
"__objc_classes",
|
|
3393
|
-
"__objc_protocols",
|
|
3394
|
-
"__objc_cats",
|
|
3395
|
-
"__objc_class_aliases"
|
|
3396
|
-
];
|
|
3445
|
+
var OBJC_SEGMENTS = ["__objc_cats", "__objc_class_aliases"];
|
|
3397
3446
|
var leb = (bytes, at) => {
|
|
3398
3447
|
let value = 0;
|
|
3399
3448
|
let scale = 1;
|
|
@@ -3408,6 +3457,7 @@ function objcSegmentSizes(bytes) {
|
|
|
3408
3457
|
const at = { offset: 8 };
|
|
3409
3458
|
const names = [];
|
|
3410
3459
|
const sizes = [];
|
|
3460
|
+
let hasExportedSymbol = false;
|
|
3411
3461
|
while (at.offset < bytes.length) {
|
|
3412
3462
|
const id = bytes[at.offset++];
|
|
3413
3463
|
const size = leb(bytes, at);
|
|
@@ -3432,6 +3482,31 @@ function objcSegmentSizes(bytes) {
|
|
|
3432
3482
|
leb(bytes, at);
|
|
3433
3483
|
leb(bytes, at);
|
|
3434
3484
|
}
|
|
3485
|
+
} else if (kind === 8) {
|
|
3486
|
+
for (let count = leb(bytes, at); count > 0; count--) {
|
|
3487
|
+
const symKind = bytes[at.offset++];
|
|
3488
|
+
const flags = leb(bytes, at);
|
|
3489
|
+
const isUndef = (flags & 16) !== 0;
|
|
3490
|
+
const isExplicitName = (flags & 64) !== 0;
|
|
3491
|
+
if (!isUndef && (flags & 32) !== 0) hasExportedSymbol = true;
|
|
3492
|
+
if (symKind === 0 || symKind === 2 || symKind === 4 || symKind === 5) {
|
|
3493
|
+
leb(bytes, at);
|
|
3494
|
+
if (!isUndef || isExplicitName) {
|
|
3495
|
+
const sLen = leb(bytes, at);
|
|
3496
|
+
at.offset += sLen;
|
|
3497
|
+
}
|
|
3498
|
+
} else if (symKind === 1) {
|
|
3499
|
+
const sLen = leb(bytes, at);
|
|
3500
|
+
at.offset += sLen;
|
|
3501
|
+
if (!isUndef) {
|
|
3502
|
+
leb(bytes, at);
|
|
3503
|
+
leb(bytes, at);
|
|
3504
|
+
leb(bytes, at);
|
|
3505
|
+
}
|
|
3506
|
+
} else if (symKind === 3) {
|
|
3507
|
+
leb(bytes, at);
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3435
3510
|
}
|
|
3436
3511
|
at.offset = next;
|
|
3437
3512
|
}
|
|
@@ -3457,6 +3532,7 @@ function objcSegmentSizes(bytes) {
|
|
|
3457
3532
|
if (OBJC_SEGMENTS.includes(name2))
|
|
3458
3533
|
result.set(name2, (result.get(name2) ?? 0) + (sizes[index] ?? 0));
|
|
3459
3534
|
});
|
|
3535
|
+
result.set("__wasm_exported", hasExportedSymbol ? 1 : 0);
|
|
3460
3536
|
return result;
|
|
3461
3537
|
}
|
|
3462
3538
|
var rootsByDistribution = /* @__PURE__ */ new Map();
|
|
@@ -3472,7 +3548,7 @@ function swiftObjcRootObjects(id, root, objects) {
|
|
|
3472
3548
|
empty.set(name2, Math.min(empty.get(name2) ?? size, size));
|
|
3473
3549
|
const roots = new Set(
|
|
3474
3550
|
measured.filter(
|
|
3475
|
-
([, sizes]) => [...sizes].some(([name2, size]) => size > (empty.get(name2) ?? 0))
|
|
3551
|
+
([object, sizes]) => object !== "lib/Foundation-NSStringFormatting.o" && object !== "lib/FoundationNetworking-Session.o" && [...sizes].some(([name2, size]) => size > (empty.get(name2) ?? 0))
|
|
3476
3552
|
).map(([object]) => object)
|
|
3477
3553
|
);
|
|
3478
3554
|
rootsByDistribution.set(id, roots);
|
|
@@ -4093,6 +4169,9 @@ function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
|
|
|
4093
4169
|
// the installed icu archive exports its swift_-prefixed names, which the
|
|
4094
4170
|
// unicode headers rename to only off darwin.
|
|
4095
4171
|
"-DU_DISABLE_RENAMING=0",
|
|
4172
|
+
// clang enables blocks in every language for darwin targets, and the sdk
|
|
4173
|
+
// headers declare block types unguarded.
|
|
4174
|
+
"-fblocks",
|
|
4096
4175
|
...WASI_EMULATION_FLAGS,
|
|
4097
4176
|
"-iframework",
|
|
4098
4177
|
path9.join(headers, "System/Library/Frameworks"),
|
|
@@ -4312,16 +4391,1448 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
|
|
|
4312
4391
|
}
|
|
4313
4392
|
|
|
4314
4393
|
// src/swift-shared-sdk.ts
|
|
4315
|
-
import {
|
|
4394
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
4395
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
4396
|
+
import fs5, { readdirSync as readdirSync4, readFileSync as readFileSync6 } from "node:fs";
|
|
4316
4397
|
import path11 from "node:path";
|
|
4317
4398
|
function swiftSharedSdkRoot(moduleRoot, distribution) {
|
|
4318
4399
|
return path11.resolve(moduleRoot, distribution ? "sdk/ios" : "../peachsim/sdk/ios");
|
|
4319
4400
|
}
|
|
4401
|
+
var sdkViews = /* @__PURE__ */ new Map();
|
|
4402
|
+
function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk) {
|
|
4403
|
+
const frameworks = path11.join(
|
|
4404
|
+
swiftSharedSdkRoot(moduleRoot, distribution),
|
|
4405
|
+
"System/Library/Frameworks"
|
|
4406
|
+
);
|
|
4407
|
+
const key = JSON.stringify([toolchainBin, sdk, frameworks, swiftSdkOptions()]);
|
|
4408
|
+
const cached = sdkViews.get(key);
|
|
4409
|
+
if (cached) return cached;
|
|
4410
|
+
const configuration = execFileSync3(
|
|
4411
|
+
path11.join(toolchainBin, "swift"),
|
|
4412
|
+
[
|
|
4413
|
+
"sdk",
|
|
4414
|
+
"configure",
|
|
4415
|
+
...swiftSdkOptions(),
|
|
4416
|
+
"--show-configuration",
|
|
4417
|
+
sdk,
|
|
4418
|
+
"wasm32-unknown-wasip1"
|
|
4419
|
+
],
|
|
4420
|
+
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
4421
|
+
);
|
|
4422
|
+
const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim();
|
|
4423
|
+
if (!sysroot || !path11.isAbsolute(sysroot))
|
|
4424
|
+
throw new Error(`swift sdk ${sdk} reports no absolute sdkRootPath`);
|
|
4425
|
+
let bundle = sysroot;
|
|
4426
|
+
while (!bundle.endsWith(".artifactbundle")) {
|
|
4427
|
+
if (path11.dirname(bundle) === bundle)
|
|
4428
|
+
throw new Error(`swift sdk ${sdk} is outside an artifact bundle`);
|
|
4429
|
+
bundle = path11.dirname(bundle);
|
|
4430
|
+
}
|
|
4431
|
+
const view = path11.join(
|
|
4432
|
+
swiftCacheDir(),
|
|
4433
|
+
"swift-sdk-views",
|
|
4434
|
+
createHash6("sha256").update(key).digest("hex").slice(0, 16)
|
|
4435
|
+
);
|
|
4436
|
+
if (!fs5.existsSync(view)) {
|
|
4437
|
+
fs5.mkdirSync(path11.dirname(view), { recursive: true });
|
|
4438
|
+
const staging = fs5.mkdtempSync(`${view}-`);
|
|
4439
|
+
const segments = [
|
|
4440
|
+
path11.basename(bundle),
|
|
4441
|
+
...path11.relative(bundle, path11.join(sysroot, "darwin/System/Library")).split(path11.sep),
|
|
4442
|
+
"Frameworks"
|
|
4443
|
+
];
|
|
4444
|
+
let real = path11.dirname(bundle);
|
|
4445
|
+
let mirror = staging;
|
|
4446
|
+
for (const segment of segments) {
|
|
4447
|
+
for (const entry of readdirSync4(real))
|
|
4448
|
+
if (entry !== segment)
|
|
4449
|
+
fs5.symlinkSync(path11.join(real, entry), path11.join(mirror, entry));
|
|
4450
|
+
real = path11.join(real, segment);
|
|
4451
|
+
mirror = path11.join(mirror, segment);
|
|
4452
|
+
if (segment !== "Frameworks") fs5.mkdirSync(mirror);
|
|
4453
|
+
}
|
|
4454
|
+
fs5.symlinkSync(frameworks, mirror);
|
|
4455
|
+
try {
|
|
4456
|
+
fs5.renameSync(staging, view);
|
|
4457
|
+
} catch (error) {
|
|
4458
|
+
fs5.rmSync(staging, { recursive: true, force: true });
|
|
4459
|
+
if (!fs5.existsSync(view)) throw error;
|
|
4460
|
+
}
|
|
4461
|
+
}
|
|
4462
|
+
const options = ["--swift-sdks-path", view];
|
|
4463
|
+
sdkViews.set(key, options);
|
|
4464
|
+
return options;
|
|
4465
|
+
}
|
|
4320
4466
|
function swiftSharedSdkInputFiles(moduleRoot) {
|
|
4321
4467
|
const root = swiftSharedSdkRoot(moduleRoot, false);
|
|
4322
4468
|
return readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path11.relative(moduleRoot, path11.join(entry.parentPath, entry.name))).sort();
|
|
4323
4469
|
}
|
|
4324
4470
|
|
|
4471
|
+
// src/swift-wasm-prune.ts
|
|
4472
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
4473
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
4474
|
+
import fs6 from "node:fs";
|
|
4475
|
+
import os2 from "node:os";
|
|
4476
|
+
import path12 from "node:path";
|
|
4477
|
+
function readULEB(b, o) {
|
|
4478
|
+
let res = 0;
|
|
4479
|
+
let shift = 0;
|
|
4480
|
+
let p = o;
|
|
4481
|
+
while (true) {
|
|
4482
|
+
const byte = b[p++];
|
|
4483
|
+
res |= (byte & 127) << shift;
|
|
4484
|
+
if ((byte & 128) === 0) break;
|
|
4485
|
+
shift += 7;
|
|
4486
|
+
}
|
|
4487
|
+
return [res, p];
|
|
4488
|
+
}
|
|
4489
|
+
function readSLEB(b, o) {
|
|
4490
|
+
let res = 0;
|
|
4491
|
+
let shift = 0;
|
|
4492
|
+
let p = o;
|
|
4493
|
+
let byte = 0;
|
|
4494
|
+
do {
|
|
4495
|
+
byte = b[p++];
|
|
4496
|
+
res |= (byte & 127) << shift;
|
|
4497
|
+
shift += 7;
|
|
4498
|
+
} while (byte & 128);
|
|
4499
|
+
if (shift < 32 && byte & 64) res |= ~0 << shift;
|
|
4500
|
+
return [res, p];
|
|
4501
|
+
}
|
|
4502
|
+
function encodeULEB(val) {
|
|
4503
|
+
const out = [];
|
|
4504
|
+
do {
|
|
4505
|
+
let byte = val & 127;
|
|
4506
|
+
val >>>= 7;
|
|
4507
|
+
if (val !== 0) byte |= 128;
|
|
4508
|
+
out.push(byte);
|
|
4509
|
+
} while (val !== 0);
|
|
4510
|
+
return out;
|
|
4511
|
+
}
|
|
4512
|
+
var HAS_ADDEND = /* @__PURE__ */ new Set([3, 4, 5, 8, 9, 11, 13, 14, 15, 16, 21, 22, 23, 24, 25]);
|
|
4513
|
+
var ROOT_SEG_PREFIXES = [
|
|
4514
|
+
".init_array",
|
|
4515
|
+
"__objc_init_func",
|
|
4516
|
+
"__objc_classes",
|
|
4517
|
+
"__objc_cats",
|
|
4518
|
+
"__objc_class_aliases",
|
|
4519
|
+
"objc_clsrolist",
|
|
4520
|
+
"swift5_protocols",
|
|
4521
|
+
"swift5_protocol_conformances",
|
|
4522
|
+
"swift5_type_metadata",
|
|
4523
|
+
"swift5_type_metadata_2",
|
|
4524
|
+
"swift5_replace",
|
|
4525
|
+
"swift5_replac2",
|
|
4526
|
+
"swift5_accessible_functions",
|
|
4527
|
+
"swift5_entry"
|
|
4528
|
+
];
|
|
4529
|
+
function isRootSegName(name2) {
|
|
4530
|
+
for (const pref of ROOT_SEG_PREFIXES) {
|
|
4531
|
+
if (name2 === pref || name2.startsWith(`${pref}.`)) return true;
|
|
4532
|
+
}
|
|
4533
|
+
return false;
|
|
4534
|
+
}
|
|
4535
|
+
var PARTITIONED_SEGS = /* @__PURE__ */ new Set([
|
|
4536
|
+
".rodata",
|
|
4537
|
+
".data",
|
|
4538
|
+
".data.rel.ro",
|
|
4539
|
+
"swift5_capture",
|
|
4540
|
+
"swift5_fieldmd",
|
|
4541
|
+
"swift5_assocty",
|
|
4542
|
+
"swift5_typeref",
|
|
4543
|
+
"swift5_builtin",
|
|
4544
|
+
"swift5_mpenum"
|
|
4545
|
+
]);
|
|
4546
|
+
var PRUNED_SDK_ARCHIVES = /* @__PURE__ */ new Set([
|
|
4547
|
+
"libFoundation",
|
|
4548
|
+
"lib_FoundationCollections",
|
|
4549
|
+
"libswift_StringProcessing",
|
|
4550
|
+
"libswift_RegexParser",
|
|
4551
|
+
"libswiftObservation",
|
|
4552
|
+
"libswiftSynchronization",
|
|
4553
|
+
"libswiftCxx",
|
|
4554
|
+
"libswiftCxxStdlib",
|
|
4555
|
+
"libswiftWASILibc",
|
|
4556
|
+
"libswift_Builtin_float",
|
|
4557
|
+
"libObjectiveC"
|
|
4558
|
+
]);
|
|
4559
|
+
var OMIT_SDK_LIB_FLAGS = /* @__PURE__ */ new Set([
|
|
4560
|
+
...[...PRUNED_SDK_ARCHIVES].map((a) => `-l${a.slice(3)}`),
|
|
4561
|
+
"-lswiftCore",
|
|
4562
|
+
"-lswift_Concurrency"
|
|
4563
|
+
]);
|
|
4564
|
+
var NEUTRALIZED_SWIFTRT_SECTIONS = /* @__PURE__ */ new Set([
|
|
4565
|
+
"swift5_tests",
|
|
4566
|
+
"swift5_runtime_attributes",
|
|
4567
|
+
"swift5_mpenum",
|
|
4568
|
+
"swift5_capture",
|
|
4569
|
+
"swift5_builtin",
|
|
4570
|
+
"swift5_assocty",
|
|
4571
|
+
"swift5_fieldmd",
|
|
4572
|
+
"swift5_reflstr",
|
|
4573
|
+
"swift5_typeref"
|
|
4574
|
+
]);
|
|
4575
|
+
var parsedObjectCache = /* @__PURE__ */ new Map();
|
|
4576
|
+
function readArMembers(buf) {
|
|
4577
|
+
if (buf.length < 8) return [];
|
|
4578
|
+
const magic = Buffer.from(buf.subarray(0, 8)).toString("ascii");
|
|
4579
|
+
if (magic !== "!<arch>\n") return [];
|
|
4580
|
+
const out = [];
|
|
4581
|
+
let gnuNames = null;
|
|
4582
|
+
let pos = 8;
|
|
4583
|
+
while (pos + 60 <= buf.length) {
|
|
4584
|
+
const rawName = Buffer.from(buf.subarray(pos, pos + 16)).toString("ascii");
|
|
4585
|
+
const sizeStr = Buffer.from(buf.subarray(pos + 48, pos + 58)).toString("ascii").trim();
|
|
4586
|
+
const size = Number.parseInt(sizeStr, 10);
|
|
4587
|
+
pos += 60;
|
|
4588
|
+
if (Number.isNaN(size) || pos + size > buf.length) break;
|
|
4589
|
+
let bodyStart = pos;
|
|
4590
|
+
const bodyEnd = pos + size;
|
|
4591
|
+
let name2 = rawName.trim();
|
|
4592
|
+
if (rawName.startsWith("#1/")) {
|
|
4593
|
+
const nLen = Number.parseInt(rawName.slice(3).trim(), 10);
|
|
4594
|
+
name2 = Buffer.from(buf.subarray(bodyStart, bodyStart + nLen)).toString("utf8").replace(/\0+$/, "");
|
|
4595
|
+
bodyStart += nLen;
|
|
4596
|
+
} else if (rawName.startsWith("//")) {
|
|
4597
|
+
gnuNames = buf.subarray(bodyStart, bodyEnd);
|
|
4598
|
+
pos = bodyEnd + (size & 1);
|
|
4599
|
+
continue;
|
|
4600
|
+
} else if (rawName.startsWith("/") && gnuNames) {
|
|
4601
|
+
const offStr = rawName.slice(1).trim();
|
|
4602
|
+
if (offStr.length > 0 && /^\d+$/.test(offStr)) {
|
|
4603
|
+
const off = Number.parseInt(offStr, 10);
|
|
4604
|
+
let end = off;
|
|
4605
|
+
while (end < gnuNames.length && gnuNames[end] !== 10 && gnuNames[end] !== 47) {
|
|
4606
|
+
end++;
|
|
4607
|
+
}
|
|
4608
|
+
name2 = Buffer.from(gnuNames.subarray(off, end)).toString("utf8");
|
|
4609
|
+
} else {
|
|
4610
|
+
pos = bodyEnd + (size & 1);
|
|
4611
|
+
continue;
|
|
4612
|
+
}
|
|
4613
|
+
} else if (name2.endsWith("/")) {
|
|
4614
|
+
name2 = name2.slice(0, -1);
|
|
4615
|
+
}
|
|
4616
|
+
const bytes = buf.subarray(bodyStart, bodyEnd);
|
|
4617
|
+
if (bytes.length >= 8 && bytes[0] === 0 && bytes[1] === 97 && bytes[2] === 115 && bytes[3] === 109) {
|
|
4618
|
+
out.push({ name: name2, bytes });
|
|
4619
|
+
}
|
|
4620
|
+
pos = bodyEnd + (size & 1);
|
|
4621
|
+
}
|
|
4622
|
+
return out;
|
|
4623
|
+
}
|
|
4624
|
+
function patchSwiftrtObject(src) {
|
|
4625
|
+
const buf = new Uint8Array(src);
|
|
4626
|
+
const neutralizedSyms = /* @__PURE__ */ new Set();
|
|
4627
|
+
let fallbackSymIdx = 2;
|
|
4628
|
+
let pos = 8;
|
|
4629
|
+
while (pos < buf.length) {
|
|
4630
|
+
const id = buf[pos++];
|
|
4631
|
+
const [sz, p] = readULEB(buf, pos);
|
|
4632
|
+
const end = p + sz;
|
|
4633
|
+
if (id === 0) {
|
|
4634
|
+
const [nLen, np] = readULEB(buf, p);
|
|
4635
|
+
const name2 = Buffer.from(buf.subarray(np, np + nLen)).toString("utf8");
|
|
4636
|
+
const cp = np + nLen;
|
|
4637
|
+
if (name2 === "linking") {
|
|
4638
|
+
let [, lp] = readULEB(buf, cp);
|
|
4639
|
+
while (lp < end) {
|
|
4640
|
+
const subId = buf[lp++];
|
|
4641
|
+
const [subLen, sp] = readULEB(buf, lp);
|
|
4642
|
+
const subEnd = sp + subLen;
|
|
4643
|
+
if (subId === 8) {
|
|
4644
|
+
let [cnt, cur] = readULEB(buf, sp);
|
|
4645
|
+
for (let i = 0; i < cnt; i++) {
|
|
4646
|
+
const kind = buf[cur++];
|
|
4647
|
+
const [fl, c2] = readULEB(buf, cur);
|
|
4648
|
+
cur = c2;
|
|
4649
|
+
const isUndef = (fl & 16) !== 0;
|
|
4650
|
+
const isExplicitName = (fl & 64) !== 0;
|
|
4651
|
+
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
4652
|
+
const [, c3] = readULEB(buf, cur);
|
|
4653
|
+
cur = c3;
|
|
4654
|
+
if (!isUndef || isExplicitName) {
|
|
4655
|
+
const [sLen, c4] = readULEB(buf, cur);
|
|
4656
|
+
cur = c4 + sLen;
|
|
4657
|
+
}
|
|
4658
|
+
} else if (kind === 1) {
|
|
4659
|
+
const [sLen, c3] = readULEB(buf, cur);
|
|
4660
|
+
const sName = Buffer.from(buf.subarray(c3, c3 + sLen)).toString("utf8");
|
|
4661
|
+
if (sName === "_ZN12_GLOBAL__N_18sectionsE") fallbackSymIdx = i;
|
|
4662
|
+
for (const prefix of ["__start_", "__stop_"]) {
|
|
4663
|
+
if (sName.startsWith(prefix) && NEUTRALIZED_SWIFTRT_SECTIONS.has(sName.slice(prefix.length))) {
|
|
4664
|
+
buf[c3] = 120;
|
|
4665
|
+
neutralizedSyms.add(i);
|
|
4666
|
+
}
|
|
4667
|
+
}
|
|
4668
|
+
cur = c3 + sLen;
|
|
4669
|
+
if (!isUndef) {
|
|
4670
|
+
const [, c4] = readULEB(buf, cur);
|
|
4671
|
+
const [, c5] = readULEB(buf, c4);
|
|
4672
|
+
const [, c6] = readULEB(buf, c5);
|
|
4673
|
+
cur = c6;
|
|
4674
|
+
}
|
|
4675
|
+
} else if (kind === 3) {
|
|
4676
|
+
const [, c3] = readULEB(buf, cur);
|
|
4677
|
+
cur = c3;
|
|
4678
|
+
}
|
|
4679
|
+
}
|
|
4680
|
+
}
|
|
4681
|
+
lp = subEnd;
|
|
4682
|
+
}
|
|
4683
|
+
}
|
|
4684
|
+
}
|
|
4685
|
+
pos = end;
|
|
4686
|
+
}
|
|
4687
|
+
pos = 8;
|
|
4688
|
+
while (pos < buf.length) {
|
|
4689
|
+
const id = buf[pos++];
|
|
4690
|
+
const [sz, p] = readULEB(buf, pos);
|
|
4691
|
+
const end = p + sz;
|
|
4692
|
+
if (id === 0) {
|
|
4693
|
+
const [nLen, np] = readULEB(buf, p);
|
|
4694
|
+
const name2 = Buffer.from(buf.subarray(np, np + nLen)).toString("utf8");
|
|
4695
|
+
const cp = np + nLen;
|
|
4696
|
+
if (name2 === "reloc.CODE") {
|
|
4697
|
+
const [, r1] = readULEB(buf, cp);
|
|
4698
|
+
let [cnt, cur] = readULEB(buf, r1);
|
|
4699
|
+
for (let i = 0; i < cnt; i++) {
|
|
4700
|
+
const rType = buf[cur++];
|
|
4701
|
+
const [, c2] = readULEB(buf, cur);
|
|
4702
|
+
const [rs, c3] = readULEB(buf, c2);
|
|
4703
|
+
if (neutralizedSyms.has(rs) && c3 - c2 === 1) {
|
|
4704
|
+
buf[c2] = fallbackSymIdx;
|
|
4705
|
+
}
|
|
4706
|
+
cur = c3;
|
|
4707
|
+
if (HAS_ADDEND.has(rType)) {
|
|
4708
|
+
const [, c4] = readSLEB(buf, cur);
|
|
4709
|
+
cur = c4;
|
|
4710
|
+
}
|
|
4711
|
+
}
|
|
4712
|
+
}
|
|
4713
|
+
}
|
|
4714
|
+
pos = end;
|
|
4715
|
+
}
|
|
4716
|
+
return buf;
|
|
4717
|
+
}
|
|
4718
|
+
function parseWasmObjectBytes(file, buf, isDist) {
|
|
4719
|
+
let pos = 8;
|
|
4720
|
+
let numImportFuncs = 0;
|
|
4721
|
+
const importFuncNames = [];
|
|
4722
|
+
const importGlobalNames = [];
|
|
4723
|
+
const importTableNames = [];
|
|
4724
|
+
const importEventNames = [];
|
|
4725
|
+
let codeStart = 0;
|
|
4726
|
+
const fStarts = [];
|
|
4727
|
+
const fEnds = [];
|
|
4728
|
+
let dataStart = 0;
|
|
4729
|
+
const sStarts = [];
|
|
4730
|
+
const sEnds = [];
|
|
4731
|
+
const sPayloadStarts = [];
|
|
4732
|
+
const segNames = [];
|
|
4733
|
+
const segFlags = [];
|
|
4734
|
+
let symKind = new Uint8Array(0);
|
|
4735
|
+
let symFlags = new Uint32Array(0);
|
|
4736
|
+
let symElemIdx = new Int32Array(0);
|
|
4737
|
+
let symOff = new Int32Array(0);
|
|
4738
|
+
let symSz = new Int32Array(0);
|
|
4739
|
+
const symNames = [];
|
|
4740
|
+
const initFuncs = [];
|
|
4741
|
+
const rawCodeRelocs = [];
|
|
4742
|
+
const rawDataRelocs = [];
|
|
4743
|
+
while (pos < buf.length) {
|
|
4744
|
+
const id = buf[pos++];
|
|
4745
|
+
const [sz, p] = readULEB(buf, pos);
|
|
4746
|
+
const end = p + sz;
|
|
4747
|
+
if (id === 2) {
|
|
4748
|
+
let [cnt, cp] = readULEB(buf, p);
|
|
4749
|
+
for (let i = 0; i < cnt; i++) {
|
|
4750
|
+
const [mLen, m2] = readULEB(buf, cp);
|
|
4751
|
+
cp = m2 + mLen;
|
|
4752
|
+
const [fLen, f2] = readULEB(buf, cp);
|
|
4753
|
+
const fName = Buffer.from(buf.subarray(f2, f2 + fLen)).toString("utf8");
|
|
4754
|
+
cp = f2 + fLen;
|
|
4755
|
+
const kind = buf[cp++];
|
|
4756
|
+
if (kind === 0) {
|
|
4757
|
+
const [, c2] = readULEB(buf, cp);
|
|
4758
|
+
cp = c2;
|
|
4759
|
+
importFuncNames.push(fName);
|
|
4760
|
+
numImportFuncs++;
|
|
4761
|
+
} else if (kind === 1) {
|
|
4762
|
+
cp++;
|
|
4763
|
+
const [fl, c2] = readULEB(buf, cp);
|
|
4764
|
+
cp = c2;
|
|
4765
|
+
const [, c3] = readULEB(buf, cp);
|
|
4766
|
+
cp = c3;
|
|
4767
|
+
if (fl & 1) {
|
|
4768
|
+
const [, c4] = readULEB(buf, cp);
|
|
4769
|
+
cp = c4;
|
|
4770
|
+
}
|
|
4771
|
+
importTableNames.push(fName);
|
|
4772
|
+
} else if (kind === 2) {
|
|
4773
|
+
const [fl, c2] = readULEB(buf, cp);
|
|
4774
|
+
cp = c2;
|
|
4775
|
+
const [, c3] = readULEB(buf, cp);
|
|
4776
|
+
cp = c3;
|
|
4777
|
+
if (fl & 1) {
|
|
4778
|
+
const [, c4] = readULEB(buf, cp);
|
|
4779
|
+
cp = c4;
|
|
4780
|
+
}
|
|
4781
|
+
} else if (kind === 3) {
|
|
4782
|
+
cp += 2;
|
|
4783
|
+
importGlobalNames.push(fName);
|
|
4784
|
+
} else if (kind === 4) {
|
|
4785
|
+
cp++;
|
|
4786
|
+
const [, c2] = readULEB(buf, cp);
|
|
4787
|
+
cp = c2;
|
|
4788
|
+
importEventNames.push(fName);
|
|
4789
|
+
}
|
|
4790
|
+
}
|
|
4791
|
+
} else if (id === 10) {
|
|
4792
|
+
codeStart = p;
|
|
4793
|
+
let [cnt, cp] = readULEB(buf, p);
|
|
4794
|
+
for (let i = 0; i < cnt; i++) {
|
|
4795
|
+
const st = cp - codeStart;
|
|
4796
|
+
const [bLen, b2] = readULEB(buf, cp);
|
|
4797
|
+
cp = b2 + bLen;
|
|
4798
|
+
fStarts.push(st);
|
|
4799
|
+
fEnds.push(cp - codeStart);
|
|
4800
|
+
}
|
|
4801
|
+
} else if (id === 11) {
|
|
4802
|
+
dataStart = p;
|
|
4803
|
+
let [cnt, cp] = readULEB(buf, p);
|
|
4804
|
+
for (let i = 0; i < cnt; i++) {
|
|
4805
|
+
const st = cp - dataStart;
|
|
4806
|
+
const [mode, m2] = readULEB(buf, cp);
|
|
4807
|
+
cp = m2;
|
|
4808
|
+
if (mode === 2) {
|
|
4809
|
+
const [, m3] = readULEB(buf, cp);
|
|
4810
|
+
cp = m3;
|
|
4811
|
+
}
|
|
4812
|
+
if (mode === 0 || mode === 2) {
|
|
4813
|
+
const op = buf[cp++];
|
|
4814
|
+
if (op === 65 || op === 66) {
|
|
4815
|
+
const [, m4] = readSLEB(buf, cp);
|
|
4816
|
+
cp = m4;
|
|
4817
|
+
} else if (op === 35) {
|
|
4818
|
+
const [, m4] = readULEB(buf, cp);
|
|
4819
|
+
cp = m4;
|
|
4820
|
+
}
|
|
4821
|
+
cp++;
|
|
4822
|
+
}
|
|
4823
|
+
const [dLen, d2] = readULEB(buf, cp);
|
|
4824
|
+
sPayloadStarts.push(d2 - dataStart);
|
|
4825
|
+
cp = d2 + dLen;
|
|
4826
|
+
sStarts.push(st);
|
|
4827
|
+
sEnds.push(cp - dataStart);
|
|
4828
|
+
}
|
|
4829
|
+
} else if (id === 0) {
|
|
4830
|
+
const [nLen, np] = readULEB(buf, p);
|
|
4831
|
+
const name2 = Buffer.from(buf.subarray(np, np + nLen)).toString("utf8");
|
|
4832
|
+
const cp = np + nLen;
|
|
4833
|
+
if (name2 === "linking") {
|
|
4834
|
+
let [, lp] = readULEB(buf, cp);
|
|
4835
|
+
while (lp < end) {
|
|
4836
|
+
const subId = buf[lp++];
|
|
4837
|
+
const [subLen, sp] = readULEB(buf, lp);
|
|
4838
|
+
const subEnd = sp + subLen;
|
|
4839
|
+
if (subId === 5) {
|
|
4840
|
+
const [cnt, p2] = readULEB(buf, sp);
|
|
4841
|
+
let cur = p2;
|
|
4842
|
+
for (let i = 0; i < cnt; i++) {
|
|
4843
|
+
const [sLen, s2] = readULEB(buf, cur);
|
|
4844
|
+
segNames.push(Buffer.from(buf.subarray(s2, s2 + sLen)).toString("utf8"));
|
|
4845
|
+
cur = s2 + sLen;
|
|
4846
|
+
const [, s3] = readULEB(buf, cur);
|
|
4847
|
+
const [fl, s4] = readULEB(buf, s3);
|
|
4848
|
+
segFlags.push(fl);
|
|
4849
|
+
cur = s4;
|
|
4850
|
+
}
|
|
4851
|
+
} else if (subId === 6) {
|
|
4852
|
+
const [cnt, p2] = readULEB(buf, sp);
|
|
4853
|
+
let cur = p2;
|
|
4854
|
+
for (let i = 0; i < cnt; i++) {
|
|
4855
|
+
const [, s2] = readULEB(buf, cur);
|
|
4856
|
+
const [symIdx, s3] = readULEB(buf, s2);
|
|
4857
|
+
initFuncs.push(symIdx);
|
|
4858
|
+
cur = s3;
|
|
4859
|
+
}
|
|
4860
|
+
} else if (subId === 8) {
|
|
4861
|
+
const [cnt, p2] = readULEB(buf, sp);
|
|
4862
|
+
symKind = new Uint8Array(cnt);
|
|
4863
|
+
symFlags = new Uint32Array(cnt);
|
|
4864
|
+
symElemIdx = new Int32Array(cnt).fill(-1);
|
|
4865
|
+
symOff = new Int32Array(cnt).fill(0);
|
|
4866
|
+
symSz = new Int32Array(cnt).fill(0);
|
|
4867
|
+
let cur = p2;
|
|
4868
|
+
for (let i = 0; i < cnt; i++) {
|
|
4869
|
+
const kind = buf[cur++];
|
|
4870
|
+
const [fl, c2] = readULEB(buf, cur);
|
|
4871
|
+
cur = c2;
|
|
4872
|
+
symKind[i] = kind;
|
|
4873
|
+
symFlags[i] = fl;
|
|
4874
|
+
const isUndef = (fl & 16) !== 0;
|
|
4875
|
+
const isExplicitName = (fl & 64) !== 0;
|
|
4876
|
+
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
4877
|
+
const [el, c3] = readULEB(buf, cur);
|
|
4878
|
+
cur = c3;
|
|
4879
|
+
if (!isUndef && kind === 0) symElemIdx[i] = el;
|
|
4880
|
+
let sName = "";
|
|
4881
|
+
if (!isUndef || isExplicitName) {
|
|
4882
|
+
const [sLen, c4] = readULEB(buf, cur);
|
|
4883
|
+
sName = Buffer.from(buf.subarray(c4, c4 + sLen)).toString("utf8");
|
|
4884
|
+
cur = c4 + sLen;
|
|
4885
|
+
} else if (kind === 0) {
|
|
4886
|
+
sName = importFuncNames[el] ?? "";
|
|
4887
|
+
} else if (kind === 2) {
|
|
4888
|
+
sName = importGlobalNames[el] ?? "";
|
|
4889
|
+
} else if (kind === 4) {
|
|
4890
|
+
sName = importEventNames[el] ?? "";
|
|
4891
|
+
} else if (kind === 5) {
|
|
4892
|
+
sName = importTableNames[el] ?? "";
|
|
4893
|
+
}
|
|
4894
|
+
symNames.push(sName);
|
|
4895
|
+
} else if (kind === 1) {
|
|
4896
|
+
const [sLen, c3] = readULEB(buf, cur);
|
|
4897
|
+
const sName = Buffer.from(buf.subarray(c3, c3 + sLen)).toString("utf8");
|
|
4898
|
+
cur = c3 + sLen;
|
|
4899
|
+
if (!isUndef) {
|
|
4900
|
+
const [segIdx, c4] = readULEB(buf, cur);
|
|
4901
|
+
const [sOff, c5] = readULEB(buf, c4);
|
|
4902
|
+
const [sSz, c6] = readULEB(buf, c5);
|
|
4903
|
+
cur = c6;
|
|
4904
|
+
symElemIdx[i] = segIdx;
|
|
4905
|
+
symOff[i] = sOff;
|
|
4906
|
+
symSz[i] = sSz;
|
|
4907
|
+
}
|
|
4908
|
+
symNames.push(sName);
|
|
4909
|
+
} else if (kind === 3) {
|
|
4910
|
+
const [, c3] = readULEB(buf, cur);
|
|
4911
|
+
cur = c3;
|
|
4912
|
+
symNames.push("");
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4915
|
+
}
|
|
4916
|
+
lp = subEnd;
|
|
4917
|
+
}
|
|
4918
|
+
} else if (name2 === "reloc.CODE" || name2 === "reloc.DATA") {
|
|
4919
|
+
const [, r1] = readULEB(buf, cp);
|
|
4920
|
+
const [cnt, r2] = readULEB(buf, r1);
|
|
4921
|
+
let cur = r2;
|
|
4922
|
+
const target = name2 === "reloc.CODE" ? rawCodeRelocs : rawDataRelocs;
|
|
4923
|
+
for (let i = 0; i < cnt; i++) {
|
|
4924
|
+
const rStart = cur;
|
|
4925
|
+
const rType = buf[cur++];
|
|
4926
|
+
const [ro, c2] = readULEB(buf, cur);
|
|
4927
|
+
const [rs, c3] = readULEB(buf, c2);
|
|
4928
|
+
cur = c3;
|
|
4929
|
+
if (HAS_ADDEND.has(rType)) {
|
|
4930
|
+
const [, c4] = readSLEB(buf, cur);
|
|
4931
|
+
cur = c4;
|
|
4932
|
+
}
|
|
4933
|
+
target.push({ rawBytes: new Uint8Array(buf.subarray(rStart, cur)), ro, rs });
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
}
|
|
4937
|
+
pos = end;
|
|
4938
|
+
}
|
|
4939
|
+
const symParentIdx = new Int32Array(symKind.length).fill(-1);
|
|
4940
|
+
const segTopSyms = /* @__PURE__ */ new Map();
|
|
4941
|
+
if (isDist) {
|
|
4942
|
+
const bySeg = /* @__PURE__ */ new Map();
|
|
4943
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
4944
|
+
if (symKind[i] === 1 && symElemIdx[i] >= 0) {
|
|
4945
|
+
const segIdx = symElemIdx[i];
|
|
4946
|
+
if (PARTITIONED_SEGS.has(segNames[segIdx])) {
|
|
4947
|
+
let list = bySeg.get(segIdx);
|
|
4948
|
+
if (!list) {
|
|
4949
|
+
list = [];
|
|
4950
|
+
bySeg.set(segIdx, list);
|
|
4951
|
+
}
|
|
4952
|
+
list.push(i);
|
|
4953
|
+
}
|
|
4954
|
+
}
|
|
4955
|
+
}
|
|
4956
|
+
for (const [segIdx, syms] of bySeg) {
|
|
4957
|
+
const segByteLen = (sEnds[segIdx] ?? 0) - (sPayloadStarts[segIdx] ?? 0);
|
|
4958
|
+
const sorted = [...syms].sort(
|
|
4959
|
+
(a, b) => symOff[a] - symOff[b] || symSz[b] - symSz[a]
|
|
4960
|
+
);
|
|
4961
|
+
const dedupTop = [];
|
|
4962
|
+
for (let k = 0; k < sorted.length; k++) {
|
|
4963
|
+
const i = sorted[k];
|
|
4964
|
+
const off = symOff[i];
|
|
4965
|
+
const sz = symSz[i];
|
|
4966
|
+
const lastTop = dedupTop[dedupTop.length - 1];
|
|
4967
|
+
if (lastTop && off < lastTop.end) {
|
|
4968
|
+
symParentIdx[i] = lastTop.symIdx;
|
|
4969
|
+
continue;
|
|
4970
|
+
}
|
|
4971
|
+
let nextOff = segByteLen;
|
|
4972
|
+
for (let m = k + 1; m < sorted.length; m++) {
|
|
4973
|
+
if (symOff[sorted[m]] > off) {
|
|
4974
|
+
nextOff = symOff[sorted[m]];
|
|
4975
|
+
break;
|
|
4976
|
+
}
|
|
4977
|
+
}
|
|
4978
|
+
const end = sz > 0 ? off + sz : nextOff;
|
|
4979
|
+
symParentIdx[i] = i;
|
|
4980
|
+
dedupTop.push({ symIdx: i, off, end });
|
|
4981
|
+
}
|
|
4982
|
+
segTopSyms.set(segIdx, dedupTop);
|
|
4983
|
+
}
|
|
4984
|
+
}
|
|
4985
|
+
const funcRelocs = Array.from({ length: fEnds.length }, () => []);
|
|
4986
|
+
const codeRelocList = [];
|
|
4987
|
+
for (const r of rawCodeRelocs) {
|
|
4988
|
+
let lo = 0;
|
|
4989
|
+
let hi = fEnds.length - 1;
|
|
4990
|
+
while (lo < hi) {
|
|
4991
|
+
const mid = lo + hi >> 1;
|
|
4992
|
+
if (fEnds[mid] <= r.ro) lo = mid + 1;
|
|
4993
|
+
else hi = mid;
|
|
4994
|
+
}
|
|
4995
|
+
if (fEnds.length > 0) {
|
|
4996
|
+
funcRelocs[lo].push(r.rs);
|
|
4997
|
+
codeRelocList.push({ ...r, funcIdx: lo });
|
|
4998
|
+
}
|
|
4999
|
+
}
|
|
5000
|
+
const segRelocs = Array.from({ length: segNames.length }, () => []);
|
|
5001
|
+
const symDataRelocs = /* @__PURE__ */ new Map();
|
|
5002
|
+
const dataRelocList = [];
|
|
5003
|
+
for (const r of rawDataRelocs) {
|
|
5004
|
+
let lo = 0;
|
|
5005
|
+
let hi = sEnds.length - 1;
|
|
5006
|
+
while (lo < hi) {
|
|
5007
|
+
const mid = lo + hi >> 1;
|
|
5008
|
+
if (sEnds[mid] <= r.ro) lo = mid + 1;
|
|
5009
|
+
else hi = mid;
|
|
5010
|
+
}
|
|
5011
|
+
if (sEnds.length > 0 && lo < segRelocs.length) {
|
|
5012
|
+
const offInSeg = r.ro - (sPayloadStarts[lo] ?? 0);
|
|
5013
|
+
let ownerSymIdx = -1;
|
|
5014
|
+
const topList = segTopSyms.get(lo);
|
|
5015
|
+
if (topList) {
|
|
5016
|
+
const owner = topList.find((t) => offInSeg >= t.off && offInSeg < t.end);
|
|
5017
|
+
if (owner) ownerSymIdx = owner.symIdx;
|
|
5018
|
+
}
|
|
5019
|
+
if (ownerSymIdx !== -1) {
|
|
5020
|
+
let list = symDataRelocs.get(ownerSymIdx);
|
|
5021
|
+
if (!list) {
|
|
5022
|
+
list = [];
|
|
5023
|
+
symDataRelocs.set(ownerSymIdx, list);
|
|
5024
|
+
}
|
|
5025
|
+
list.push(r.rs);
|
|
5026
|
+
} else {
|
|
5027
|
+
segRelocs[lo].push(r.rs);
|
|
5028
|
+
}
|
|
5029
|
+
dataRelocList.push({ ...r, segIdx: lo, offInSeg, ownerSymIdx });
|
|
5030
|
+
}
|
|
5031
|
+
}
|
|
5032
|
+
const typePrefixesInObj = /* @__PURE__ */ new Set();
|
|
5033
|
+
if (isDist) {
|
|
5034
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
5035
|
+
if ((symFlags[i] & 16) === 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mn")) {
|
|
5036
|
+
typePrefixesInObj.add(symNames[i].slice(0, -2));
|
|
5037
|
+
}
|
|
5038
|
+
}
|
|
5039
|
+
}
|
|
5040
|
+
const objcRegisterFuncToTypePrefix = /* @__PURE__ */ new Map();
|
|
5041
|
+
const objcClassSymToTypePrefix = /* @__PURE__ */ new Map();
|
|
5042
|
+
if (isDist) {
|
|
5043
|
+
for (const symIdx of initFuncs) {
|
|
5044
|
+
if (symKind[symIdx] === 0 && symElemIdx[symIdx] >= numImportFuncs) {
|
|
5045
|
+
const lf = symElemIdx[symIdx] - numImportFuncs;
|
|
5046
|
+
const fName = symNames[symIdx];
|
|
5047
|
+
if (fName.startsWith(".L.swift.objc.register")) {
|
|
5048
|
+
const relSyms = funcRelocs[lf].map((si) => symNames[si]);
|
|
5049
|
+
const mnSym = relSyms.find((s) => s.startsWith("$s") && s.endsWith("Mn"));
|
|
5050
|
+
const objcSym = relSyms.find((s) => s.startsWith("._OBJC_CLASS_"));
|
|
5051
|
+
if (mnSym) {
|
|
5052
|
+
const pref = mnSym.slice(0, -2);
|
|
5053
|
+
objcRegisterFuncToTypePrefix.set(lf, pref);
|
|
5054
|
+
if (objcSym) objcClassSymToTypePrefix.set(objcSym, pref);
|
|
5055
|
+
}
|
|
5056
|
+
}
|
|
5057
|
+
}
|
|
5058
|
+
}
|
|
5059
|
+
}
|
|
5060
|
+
const rootFuncs = [];
|
|
5061
|
+
const rootSegs = [];
|
|
5062
|
+
for (const symIdx of initFuncs) {
|
|
5063
|
+
if (symKind[symIdx] === 0 && symElemIdx[symIdx] >= numImportFuncs) {
|
|
5064
|
+
const lf = symElemIdx[symIdx] - numImportFuncs;
|
|
5065
|
+
if (!objcRegisterFuncToTypePrefix.has(lf)) {
|
|
5066
|
+
rootFuncs.push(lf);
|
|
5067
|
+
}
|
|
5068
|
+
}
|
|
5069
|
+
}
|
|
5070
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
5071
|
+
const isRootSym = isDist ? (symFlags[i] & 32) !== 0 : (symFlags[i] & 128) !== 0 || (symFlags[i] & 32) !== 0;
|
|
5072
|
+
if (isRootSym && (symFlags[i] & 16) === 0) {
|
|
5073
|
+
if (symKind[i] === 0 && symElemIdx[i] >= numImportFuncs) {
|
|
5074
|
+
rootFuncs.push(symElemIdx[i] - numImportFuncs);
|
|
5075
|
+
} else if (symKind[i] === 1 && symElemIdx[i] >= 0) {
|
|
5076
|
+
rootSegs.push(symElemIdx[i]);
|
|
5077
|
+
}
|
|
5078
|
+
}
|
|
5079
|
+
}
|
|
5080
|
+
for (let i = 0; i < segNames.length; i++) {
|
|
5081
|
+
const sName = segNames[i];
|
|
5082
|
+
if (isDist && (sName === "swift5_type_metadata" || sName === "swift5_protocol_conformances" || sName === "__objc_classes" || sName.startsWith(".init_array"))) {
|
|
5083
|
+
continue;
|
|
5084
|
+
}
|
|
5085
|
+
if (isRootSegName(sName) || !isDist && ((segFlags[i] ?? 0) & 4) !== 0) {
|
|
5086
|
+
rootSegs.push(i);
|
|
5087
|
+
}
|
|
5088
|
+
}
|
|
5089
|
+
return {
|
|
5090
|
+
file,
|
|
5091
|
+
isDist,
|
|
5092
|
+
numImportFuncs,
|
|
5093
|
+
numFuncs: fEnds.length,
|
|
5094
|
+
numSegments: segNames.length,
|
|
5095
|
+
segNames,
|
|
5096
|
+
symKind,
|
|
5097
|
+
symFlags,
|
|
5098
|
+
symElemIdx,
|
|
5099
|
+
symOff,
|
|
5100
|
+
symSz,
|
|
5101
|
+
symParentIdx,
|
|
5102
|
+
symNames,
|
|
5103
|
+
funcRelocs,
|
|
5104
|
+
segRelocs,
|
|
5105
|
+
symDataRelocs,
|
|
5106
|
+
codeRelocList,
|
|
5107
|
+
dataRelocList,
|
|
5108
|
+
initFuncSyms: initFuncs,
|
|
5109
|
+
objcRegisterFuncToTypePrefix,
|
|
5110
|
+
objcClassSymToTypePrefix,
|
|
5111
|
+
typePrefixesInObj,
|
|
5112
|
+
rootFuncs,
|
|
5113
|
+
rootSegs
|
|
5114
|
+
};
|
|
5115
|
+
}
|
|
5116
|
+
function parseWasmObjectCached(file, isDist, useCache) {
|
|
5117
|
+
const key = `${isDist ? "1" : "0"}:${file}`;
|
|
5118
|
+
if (useCache) {
|
|
5119
|
+
const hit = parsedObjectCache.get(key);
|
|
5120
|
+
if (hit) return hit;
|
|
5121
|
+
}
|
|
5122
|
+
const parsed = parseWasmObjectBytes(file, new Uint8Array(fs6.readFileSync(file)), isDist);
|
|
5123
|
+
if (useCache) parsedObjectCache.set(key, parsed);
|
|
5124
|
+
return parsed;
|
|
5125
|
+
}
|
|
5126
|
+
function peachHome2() {
|
|
5127
|
+
const override = process.env.PEACH_HOME;
|
|
5128
|
+
return override ? path12.resolve(override) : path12.join(os2.homedir(), ".peach");
|
|
5129
|
+
}
|
|
5130
|
+
function ensureUnpackedSdkObjects(sdkWasiDir) {
|
|
5131
|
+
const sdkKey = createHash7("sha256").update(sdkWasiDir).digest("hex").slice(0, 16);
|
|
5132
|
+
const outDir = path12.join(peachHome2(), "cache", "swift-builds", `sdk-objs-${sdkKey}`);
|
|
5133
|
+
const stamp = path12.join(outDir, ".complete");
|
|
5134
|
+
if (fs6.existsSync(stamp)) return outDir;
|
|
5135
|
+
const tmpDir = `${outDir}.${process.pid}.${Date.now()}.tmp`;
|
|
5136
|
+
fs6.mkdirSync(tmpDir, { recursive: true });
|
|
5137
|
+
const archives = fs6.readdirSync(sdkWasiDir).filter((f) => f.endsWith(".a")).sort();
|
|
5138
|
+
for (const archive of archives) {
|
|
5139
|
+
const aBase = archive.replace(/\.a$/, "");
|
|
5140
|
+
const members = readArMembers(
|
|
5141
|
+
new Uint8Array(fs6.readFileSync(path12.join(sdkWasiDir, archive)))
|
|
5142
|
+
);
|
|
5143
|
+
const seen = /* @__PURE__ */ new Map();
|
|
5144
|
+
for (const m of members) {
|
|
5145
|
+
const count = (seen.get(m.name) ?? 0) + 1;
|
|
5146
|
+
seen.set(m.name, count);
|
|
5147
|
+
const suffix = count > 1 ? `_${count}` : "";
|
|
5148
|
+
const safeName = m.name.replaceAll("/", "__");
|
|
5149
|
+
const outName = `${aBase}__${safeName}${suffix}`;
|
|
5150
|
+
fs6.writeFileSync(path12.join(tmpDir, outName), m.bytes);
|
|
5151
|
+
}
|
|
5152
|
+
}
|
|
5153
|
+
fs6.writeFileSync(path12.join(tmpDir, ".complete"), "1\n");
|
|
5154
|
+
fs6.mkdirSync(path12.dirname(outDir), { recursive: true });
|
|
5155
|
+
if (fs6.existsSync(stamp)) {
|
|
5156
|
+
fs6.rmSync(tmpDir, { recursive: true, force: true });
|
|
5157
|
+
return outDir;
|
|
5158
|
+
}
|
|
5159
|
+
fs6.rmSync(outDir, { recursive: true, force: true });
|
|
5160
|
+
fs6.renameSync(tmpDir, outDir);
|
|
5161
|
+
return outDir;
|
|
5162
|
+
}
|
|
5163
|
+
function isPrunableSdkFile(file) {
|
|
5164
|
+
const base = path12.basename(file);
|
|
5165
|
+
const aBase = base.split("__")[0];
|
|
5166
|
+
if (PRUNED_SDK_ARCHIVES.has(aBase)) return true;
|
|
5167
|
+
if (base === "libswiftCore__Swift.o" || base === "libswift_Concurrency___Concurrency.o") {
|
|
5168
|
+
return true;
|
|
5169
|
+
}
|
|
5170
|
+
return false;
|
|
5171
|
+
}
|
|
5172
|
+
function getModulePrefix(file) {
|
|
5173
|
+
const base = path12.basename(file);
|
|
5174
|
+
const dbl = base.indexOf("__");
|
|
5175
|
+
if (dbl > 0) return base.slice(0, dbl);
|
|
5176
|
+
const dash = base.indexOf("-");
|
|
5177
|
+
return dash > 0 ? base.slice(0, dash) : base;
|
|
5178
|
+
}
|
|
5179
|
+
function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot) {
|
|
5180
|
+
const rspPath = path12.join(directory, ".peach-link.rsp");
|
|
5181
|
+
if (!fs6.existsSync(rspPath)) return;
|
|
5182
|
+
const origRsp = fs6.readFileSync(rspPath, "utf8");
|
|
5183
|
+
const tokens = Array.from(origRsp.matchAll(/"([^"]+)"|(\S+)/g), (m) => m[1] ?? m[2]);
|
|
5184
|
+
if (!tokens.includes("--start-lib")) return;
|
|
5185
|
+
const sdkFlag = tokens.find(
|
|
5186
|
+
(t) => t.startsWith("-L") && t.endsWith("/swift_static/wasi")
|
|
5187
|
+
);
|
|
5188
|
+
if (!sdkFlag) return;
|
|
5189
|
+
const sdkWasiDir = sdkFlag.slice(2);
|
|
5190
|
+
const sdkObjsDir = ensureUnpackedSdkObjects(sdkWasiDir);
|
|
5191
|
+
const distDir = path12.join(moduleRoot, "lib");
|
|
5192
|
+
const prunedObjsDir = path12.join(directory, ".peach-pruned-objs");
|
|
5193
|
+
fs6.rmSync(prunedObjsDir, { recursive: true, force: true });
|
|
5194
|
+
fs6.mkdirSync(prunedObjsDir, { recursive: true });
|
|
5195
|
+
const distFiles = [];
|
|
5196
|
+
const eagerFiles = [];
|
|
5197
|
+
const extraArchiveObjs = [];
|
|
5198
|
+
let inStartLib = false;
|
|
5199
|
+
let swiftrtOrigPath = "";
|
|
5200
|
+
for (const t of tokens) {
|
|
5201
|
+
if (t === "--start-lib") {
|
|
5202
|
+
inStartLib = true;
|
|
5203
|
+
continue;
|
|
5204
|
+
}
|
|
5205
|
+
if (t === "--end-lib") {
|
|
5206
|
+
inStartLib = false;
|
|
5207
|
+
continue;
|
|
5208
|
+
}
|
|
5209
|
+
if (t.endsWith(".o")) {
|
|
5210
|
+
if (t.startsWith(distDir)) {
|
|
5211
|
+
if (path12.basename(t) !== "Foundation-NSStringFormatting.o") {
|
|
5212
|
+
distFiles.push(t);
|
|
5213
|
+
}
|
|
5214
|
+
if (!inStartLib) eagerFiles.push(t);
|
|
5215
|
+
} else if (!inStartLib) {
|
|
5216
|
+
if (t.endsWith("/swiftrt.o")) {
|
|
5217
|
+
swiftrtOrigPath = t;
|
|
5218
|
+
} else {
|
|
5219
|
+
eagerFiles.push(t);
|
|
5220
|
+
}
|
|
5221
|
+
}
|
|
5222
|
+
} else if (!inStartLib && t.endsWith(".a") && !t.endsWith("libclang_rt.builtins-wasm32.a") && fs6.existsSync(t)) {
|
|
5223
|
+
const members = readArMembers(new Uint8Array(fs6.readFileSync(t)));
|
|
5224
|
+
for (const m of members) {
|
|
5225
|
+
extraArchiveObjs.push(parseWasmObjectBytes(`${t}(${m.name})`, m.bytes, false));
|
|
5226
|
+
}
|
|
5227
|
+
}
|
|
5228
|
+
}
|
|
5229
|
+
let patchedSwiftrtPath = "";
|
|
5230
|
+
if (swiftrtOrigPath && fs6.existsSync(swiftrtOrigPath)) {
|
|
5231
|
+
patchedSwiftrtPath = path12.join(prunedObjsDir, "swiftrt-patched.o");
|
|
5232
|
+
fs6.writeFileSync(
|
|
5233
|
+
patchedSwiftrtPath,
|
|
5234
|
+
patchSwiftrtObject(new Uint8Array(fs6.readFileSync(swiftrtOrigPath)))
|
|
5235
|
+
);
|
|
5236
|
+
eagerFiles.push(patchedSwiftrtPath);
|
|
5237
|
+
}
|
|
5238
|
+
const allSdkObjFiles = fs6.readdirSync(sdkObjsDir).filter((f) => f.endsWith(".o") || f.endsWith(".obj")).sort();
|
|
5239
|
+
const sdkFiles = allSdkObjFiles.map((f) => path12.join(sdkObjsDir, f));
|
|
5240
|
+
const distObjs = /* @__PURE__ */ new Map();
|
|
5241
|
+
const lazyProviders = /* @__PURE__ */ new Map();
|
|
5242
|
+
const registerLazyProvider = (obj) => {
|
|
5243
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
5244
|
+
const fl = obj.symFlags[i];
|
|
5245
|
+
const isUndef = (fl & 16) !== 0;
|
|
5246
|
+
const isLocal = (fl & 3) === 2;
|
|
5247
|
+
if (!isUndef && !isLocal) {
|
|
5248
|
+
const name2 = obj.symNames[i];
|
|
5249
|
+
if (name2) {
|
|
5250
|
+
let list = lazyProviders.get(name2);
|
|
5251
|
+
if (!list) {
|
|
5252
|
+
list = [];
|
|
5253
|
+
lazyProviders.set(name2, list);
|
|
5254
|
+
}
|
|
5255
|
+
list.push(obj);
|
|
5256
|
+
}
|
|
5257
|
+
}
|
|
5258
|
+
}
|
|
5259
|
+
};
|
|
5260
|
+
for (const f of [...distFiles, ...sdkFiles]) {
|
|
5261
|
+
const isSdk = f.startsWith(sdkObjsDir);
|
|
5262
|
+
const isPrunableSwift = !isSdk || isPrunableSdkFile(f);
|
|
5263
|
+
const obj = parseWasmObjectCached(f, isPrunableSwift, true);
|
|
5264
|
+
distObjs.set(f, obj);
|
|
5265
|
+
registerLazyProvider(obj);
|
|
5266
|
+
}
|
|
5267
|
+
for (const obj of extraArchiveObjs) {
|
|
5268
|
+
registerLazyProvider(obj);
|
|
5269
|
+
}
|
|
5270
|
+
const extractedObjs = /* @__PURE__ */ new Set();
|
|
5271
|
+
const definedGlobalSyms = /* @__PURE__ */ new Map();
|
|
5272
|
+
const extractedSymbolDefs = /* @__PURE__ */ new Map();
|
|
5273
|
+
const liveGlobalNames = /* @__PURE__ */ new Set();
|
|
5274
|
+
const liveFuncs = /* @__PURE__ */ new Map();
|
|
5275
|
+
const liveSegs = /* @__PURE__ */ new Map();
|
|
5276
|
+
const liveDataSyms = /* @__PURE__ */ new Map();
|
|
5277
|
+
const liveTypes = /* @__PURE__ */ new Map();
|
|
5278
|
+
const workQueue = [];
|
|
5279
|
+
const pendingUndef = /* @__PURE__ */ new Set();
|
|
5280
|
+
const markFuncLive = (obj, localFuncIdx) => {
|
|
5281
|
+
const arr = liveFuncs.get(obj);
|
|
5282
|
+
if (arr[localFuncIdx]) return;
|
|
5283
|
+
arr[localFuncIdx] = 1;
|
|
5284
|
+
workQueue.push({ kind: "func", obj, idx: localFuncIdx });
|
|
5285
|
+
};
|
|
5286
|
+
const markSegLive = (obj, segIdx) => {
|
|
5287
|
+
const arr = liveSegs.get(obj);
|
|
5288
|
+
if (arr[segIdx]) return;
|
|
5289
|
+
arr[segIdx] = 1;
|
|
5290
|
+
workQueue.push({ kind: "seg", obj, idx: segIdx });
|
|
5291
|
+
};
|
|
5292
|
+
const markDataSymLive = (obj, symIdx) => {
|
|
5293
|
+
const set = liveDataSyms.get(obj);
|
|
5294
|
+
if (set.has(symIdx)) return;
|
|
5295
|
+
set.add(symIdx);
|
|
5296
|
+
workQueue.push({ kind: "datasym", obj, symIdx });
|
|
5297
|
+
};
|
|
5298
|
+
const markTypeLive = (obj, pref) => {
|
|
5299
|
+
const set = liveTypes.get(obj);
|
|
5300
|
+
if (set.has(pref)) return;
|
|
5301
|
+
set.add(pref);
|
|
5302
|
+
const mnName = `${pref}Mn`;
|
|
5303
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
5304
|
+
if (obj.symNames[i] === mnName && (obj.symFlags[i] & 16) === 0) {
|
|
5305
|
+
activateSymbolInObj(obj, i);
|
|
5306
|
+
}
|
|
5307
|
+
}
|
|
5308
|
+
for (const [lf, p] of obj.objcRegisterFuncToTypePrefix) {
|
|
5309
|
+
if (p === pref) {
|
|
5310
|
+
markFuncLive(obj, lf);
|
|
5311
|
+
}
|
|
5312
|
+
}
|
|
5313
|
+
for (let sIdx = 0; sIdx < obj.segNames.length; sIdx++) {
|
|
5314
|
+
if (obj.segNames[sIdx] === "swift5_protocol_conformances") {
|
|
5315
|
+
for (const r of obj.dataRelocList) {
|
|
5316
|
+
if (r.segIdx === sIdx) {
|
|
5317
|
+
const mcName = obj.symNames[r.rs];
|
|
5318
|
+
if (mcName.startsWith(pref)) {
|
|
5319
|
+
activateSymbolInObj(obj, r.rs);
|
|
5320
|
+
}
|
|
5321
|
+
}
|
|
5322
|
+
}
|
|
5323
|
+
}
|
|
5324
|
+
}
|
|
5325
|
+
};
|
|
5326
|
+
const checkTypeTrigger = (obj, rawSymName) => {
|
|
5327
|
+
if (!obj.isDist || !rawSymName) return;
|
|
5328
|
+
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
5329
|
+
const objcPref = obj.objcClassSymToTypePrefix.get(sName);
|
|
5330
|
+
if (objcPref) {
|
|
5331
|
+
markTypeLive(obj, objcPref);
|
|
5332
|
+
return;
|
|
5333
|
+
}
|
|
5334
|
+
if (!sName.startsWith("$s") || sName.endsWith("Tm")) return;
|
|
5335
|
+
for (const suffix of ["Ma", "Mf", "N", "Mn", "ML"]) {
|
|
5336
|
+
if (sName.endsWith(suffix)) {
|
|
5337
|
+
const cand = sName.slice(0, -suffix.length);
|
|
5338
|
+
if (obj.typePrefixesInObj.has(cand)) {
|
|
5339
|
+
markTypeLive(obj, cand);
|
|
5340
|
+
return;
|
|
5341
|
+
}
|
|
5342
|
+
}
|
|
5343
|
+
}
|
|
5344
|
+
if (obj.file.endsWith("libswiftCore__Swift.o") || obj.file.endsWith("libswift_Concurrency___Concurrency.o")) {
|
|
5345
|
+
for (const pref of obj.typePrefixesInObj) {
|
|
5346
|
+
if (sName.startsWith(pref)) {
|
|
5347
|
+
markTypeLive(obj, pref);
|
|
5348
|
+
}
|
|
5349
|
+
}
|
|
5350
|
+
}
|
|
5351
|
+
};
|
|
5352
|
+
const activateGlobalName = (name2) => {
|
|
5353
|
+
if (!name2) return;
|
|
5354
|
+
if (!liveGlobalNames.has(name2)) liveGlobalNames.add(name2);
|
|
5355
|
+
const defs = extractedSymbolDefs.get(name2);
|
|
5356
|
+
if (defs) {
|
|
5357
|
+
for (const d of defs) {
|
|
5358
|
+
activateSymbolInObj(d.obj, d.symIdx);
|
|
5359
|
+
}
|
|
5360
|
+
}
|
|
5361
|
+
};
|
|
5362
|
+
function activateSymbolInObj(obj, symIdx) {
|
|
5363
|
+
const kind = obj.symKind[symIdx];
|
|
5364
|
+
const el = obj.symElemIdx[symIdx];
|
|
5365
|
+
const sName = obj.symNames[symIdx];
|
|
5366
|
+
const fl = obj.symFlags[symIdx];
|
|
5367
|
+
const isUndef = (fl & 16) !== 0;
|
|
5368
|
+
const isLocal = (fl & 3) === 2;
|
|
5369
|
+
checkTypeTrigger(obj, sName);
|
|
5370
|
+
if (!isUndef && !isLocal && sName && !liveGlobalNames.has(sName)) {
|
|
5371
|
+
activateGlobalName(sName);
|
|
5372
|
+
}
|
|
5373
|
+
if (kind === 0 && el >= obj.numImportFuncs) {
|
|
5374
|
+
markFuncLive(obj, el - obj.numImportFuncs);
|
|
5375
|
+
} else if (kind === 1 && el >= 0) {
|
|
5376
|
+
const pIdx = obj.symParentIdx[symIdx];
|
|
5377
|
+
if (pIdx !== -1) {
|
|
5378
|
+
markDataSymLive(obj, pIdx);
|
|
5379
|
+
const parentName = obj.symNames[pIdx];
|
|
5380
|
+
checkTypeTrigger(obj, parentName);
|
|
5381
|
+
}
|
|
5382
|
+
markSegLive(obj, el);
|
|
5383
|
+
}
|
|
5384
|
+
}
|
|
5385
|
+
const extractObject = (obj) => {
|
|
5386
|
+
if (extractedObjs.has(obj)) return;
|
|
5387
|
+
extractedObjs.add(obj);
|
|
5388
|
+
liveFuncs.set(obj, new Uint8Array(obj.numFuncs));
|
|
5389
|
+
liveSegs.set(obj, new Uint8Array(obj.numSegments));
|
|
5390
|
+
liveDataSyms.set(obj, /* @__PURE__ */ new Set());
|
|
5391
|
+
liveTypes.set(obj, /* @__PURE__ */ new Set());
|
|
5392
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
5393
|
+
const fl = obj.symFlags[i];
|
|
5394
|
+
const isUndef = (fl & 16) !== 0;
|
|
5395
|
+
const isLocal = (fl & 3) === 2;
|
|
5396
|
+
const isWeak = (fl & 3) === 1;
|
|
5397
|
+
if (!isUndef && !isLocal) {
|
|
5398
|
+
const name2 = obj.symNames[i];
|
|
5399
|
+
if (name2) {
|
|
5400
|
+
if (!definedGlobalSyms.has(name2) || !isWeak) {
|
|
5401
|
+
definedGlobalSyms.set(name2, { obj, symIdx: i });
|
|
5402
|
+
}
|
|
5403
|
+
let dList = extractedSymbolDefs.get(name2);
|
|
5404
|
+
if (!dList) {
|
|
5405
|
+
dList = [];
|
|
5406
|
+
extractedSymbolDefs.set(name2, dList);
|
|
5407
|
+
}
|
|
5408
|
+
dList.push({ obj, symIdx: i });
|
|
5409
|
+
if (pendingUndef.has(name2) || liveGlobalNames.has(name2)) {
|
|
5410
|
+
pendingUndef.delete(name2);
|
|
5411
|
+
activateSymbolInObj(obj, i);
|
|
5412
|
+
}
|
|
5413
|
+
}
|
|
5414
|
+
}
|
|
5415
|
+
}
|
|
5416
|
+
for (const fIdx of obj.rootFuncs) markFuncLive(obj, fIdx);
|
|
5417
|
+
for (const sIdx of obj.rootSegs) markSegLive(obj, sIdx);
|
|
5418
|
+
if (obj.file.endsWith("libswiftCore__Swift.o")) {
|
|
5419
|
+
for (const pref of obj.typePrefixesInObj) {
|
|
5420
|
+
if (!pref.startsWith("$ss")) {
|
|
5421
|
+
markTypeLive(obj, pref);
|
|
5422
|
+
}
|
|
5423
|
+
}
|
|
5424
|
+
}
|
|
5425
|
+
if (obj.isDist) {
|
|
5426
|
+
for (let sIdx = 0; sIdx < obj.segNames.length; sIdx++) {
|
|
5427
|
+
if (obj.segNames[sIdx] === "swift5_protocol_conformances") {
|
|
5428
|
+
for (const r of obj.dataRelocList) {
|
|
5429
|
+
if (r.segIdx === sIdx) {
|
|
5430
|
+
const mcName = obj.symNames[r.rs];
|
|
5431
|
+
let matchesLocalType = false;
|
|
5432
|
+
for (const pref of obj.typePrefixesInObj) {
|
|
5433
|
+
if (mcName.startsWith(pref)) {
|
|
5434
|
+
matchesLocalType = true;
|
|
5435
|
+
break;
|
|
5436
|
+
}
|
|
5437
|
+
}
|
|
5438
|
+
if (!matchesLocalType) {
|
|
5439
|
+
activateSymbolInObj(obj, r.rs);
|
|
5440
|
+
}
|
|
5441
|
+
}
|
|
5442
|
+
}
|
|
5443
|
+
}
|
|
5444
|
+
}
|
|
5445
|
+
}
|
|
5446
|
+
};
|
|
5447
|
+
for (const f of eagerFiles) {
|
|
5448
|
+
const isDist = f.startsWith(distDir);
|
|
5449
|
+
const obj = distObjs.get(f) ?? parseWasmObjectCached(f, isDist, false);
|
|
5450
|
+
extractObject(obj);
|
|
5451
|
+
if (isDist) {
|
|
5452
|
+
const base = path12.basename(f);
|
|
5453
|
+
if (base.startsWith("PeachFoundation-") || base.startsWith("PeachObjC-") || base.startsWith("PeachICU-") || base.startsWith("Darwin-")) {
|
|
5454
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
5455
|
+
const sName = obj.symNames[i];
|
|
5456
|
+
if ((obj.symFlags[i] & 16) === 0 && sName && !sName.startsWith("$s") && !sName.startsWith(".")) {
|
|
5457
|
+
activateSymbolInObj(obj, i);
|
|
5458
|
+
}
|
|
5459
|
+
}
|
|
5460
|
+
}
|
|
5461
|
+
}
|
|
5462
|
+
}
|
|
5463
|
+
for (const symName of ["_initialize", "__main_argc_argv", "main"]) {
|
|
5464
|
+
const def = definedGlobalSyms.get(symName);
|
|
5465
|
+
if (def) activateSymbolInObj(def.obj, def.symIdx);
|
|
5466
|
+
}
|
|
5467
|
+
while (workQueue.length > 0) {
|
|
5468
|
+
const item = workQueue.pop();
|
|
5469
|
+
const obj = item.obj;
|
|
5470
|
+
let relocs;
|
|
5471
|
+
if (item.kind === "func") {
|
|
5472
|
+
relocs = obj.funcRelocs[item.idx];
|
|
5473
|
+
} else if (item.kind === "seg") {
|
|
5474
|
+
relocs = obj.segRelocs[item.idx];
|
|
5475
|
+
} else {
|
|
5476
|
+
relocs = obj.symDataRelocs.get(item.symIdx) ?? [];
|
|
5477
|
+
}
|
|
5478
|
+
for (const symIdx of relocs) {
|
|
5479
|
+
const fl = obj.symFlags[symIdx];
|
|
5480
|
+
const isUndef = (fl & 16) !== 0;
|
|
5481
|
+
const isLocal = (fl & 3) === 2;
|
|
5482
|
+
const isWeak = (fl & 3) === 1;
|
|
5483
|
+
if (!isUndef) {
|
|
5484
|
+
activateSymbolInObj(obj, symIdx);
|
|
5485
|
+
if (!isLocal) {
|
|
5486
|
+
const name2 = obj.symNames[symIdx];
|
|
5487
|
+
activateGlobalName(name2);
|
|
5488
|
+
}
|
|
5489
|
+
} else {
|
|
5490
|
+
const name2 = obj.symNames[symIdx];
|
|
5491
|
+
if (!name2) continue;
|
|
5492
|
+
let def = definedGlobalSyms.get(name2);
|
|
5493
|
+
if (!def) {
|
|
5494
|
+
const cands = lazyProviders.get(name2);
|
|
5495
|
+
if (cands && cands.length > 0) {
|
|
5496
|
+
const reqMod = getModulePrefix(obj.file);
|
|
5497
|
+
let chosen = cands.find((c) => extractedObjs.has(c));
|
|
5498
|
+
if (!chosen) {
|
|
5499
|
+
const sameMod = cands.filter((c) => getModulePrefix(c.file) === reqMod);
|
|
5500
|
+
const sdkPool = cands.filter((c) => c.file.startsWith(sdkObjsDir));
|
|
5501
|
+
const pool = sameMod.length > 0 ? sameMod : sdkPool.length > 0 ? sdkPool : cands;
|
|
5502
|
+
chosen = pool.reduce(
|
|
5503
|
+
(a, b) => a.rootSegs.length + a.rootFuncs.length <= b.rootSegs.length + b.rootFuncs.length ? a : b
|
|
5504
|
+
);
|
|
5505
|
+
}
|
|
5506
|
+
extractObject(chosen);
|
|
5507
|
+
def = definedGlobalSyms.get(name2);
|
|
5508
|
+
} else if (!isWeak) {
|
|
5509
|
+
pendingUndef.add(name2);
|
|
5510
|
+
}
|
|
5511
|
+
}
|
|
5512
|
+
if (def) {
|
|
5513
|
+
activateGlobalName(name2);
|
|
5514
|
+
}
|
|
5515
|
+
}
|
|
5516
|
+
}
|
|
5517
|
+
}
|
|
5518
|
+
const isSpecialSegRelocLive = (obj, segName, r) => {
|
|
5519
|
+
const sLive = liveSegs.get(obj);
|
|
5520
|
+
const dLive = liveDataSyms.get(obj);
|
|
5521
|
+
const tLive = liveTypes.get(obj);
|
|
5522
|
+
const targetName = obj.symNames[r.rs] ?? "";
|
|
5523
|
+
if (segName === "swift5_type_metadata") {
|
|
5524
|
+
const raw2 = targetName.startsWith(".Lgot.") ? targetName.slice(6) : targetName;
|
|
5525
|
+
if (raw2.endsWith("Mn")) {
|
|
5526
|
+
const pref = raw2.slice(0, -2);
|
|
5527
|
+
if (obj.typePrefixesInObj.has(pref)) return tLive.has(pref);
|
|
5528
|
+
}
|
|
5529
|
+
return true;
|
|
5530
|
+
}
|
|
5531
|
+
if (segName === "swift5_protocol_conformances" || segName === "__objc_classes") {
|
|
5532
|
+
const pIdx = obj.symParentIdx[r.rs];
|
|
5533
|
+
if (pIdx !== -1) return dLive.has(pIdx);
|
|
5534
|
+
const segIdx = obj.symElemIdx[r.rs];
|
|
5535
|
+
return segIdx >= 0 ? sLive[segIdx] === 1 : true;
|
|
5536
|
+
}
|
|
5537
|
+
return true;
|
|
5538
|
+
};
|
|
5539
|
+
const writePrunedObject = (obj, outFile) => {
|
|
5540
|
+
const buf = new Uint8Array(fs6.readFileSync(obj.file));
|
|
5541
|
+
const fLive = liveFuncs.get(obj);
|
|
5542
|
+
const sLive = liveSegs.get(obj);
|
|
5543
|
+
const dLive = liveDataSyms.get(obj);
|
|
5544
|
+
const keptCodeRelocs = obj.codeRelocList.filter((r) => fLive[r.funcIdx] === 1);
|
|
5545
|
+
const firstLiveInSpecialSeg = /* @__PURE__ */ new Map();
|
|
5546
|
+
const deadSpecialSegs = /* @__PURE__ */ new Set();
|
|
5547
|
+
for (let sIdx = 0; sIdx < obj.segNames.length; sIdx++) {
|
|
5548
|
+
const sName = obj.segNames[sIdx];
|
|
5549
|
+
if (sName === "swift5_type_metadata" || sName === "swift5_protocol_conformances" || sName === "__objc_classes") {
|
|
5550
|
+
const segRels = obj.dataRelocList.filter((r) => r.segIdx === sIdx);
|
|
5551
|
+
const liveRels = segRels.filter((r) => isSpecialSegRelocLive(obj, sName, r));
|
|
5552
|
+
if (liveRels.length === 0) {
|
|
5553
|
+
deadSpecialSegs.add(sIdx);
|
|
5554
|
+
} else {
|
|
5555
|
+
const first = liveRels[0];
|
|
5556
|
+
const rType = first.rawBytes[0];
|
|
5557
|
+
const [, afterRoOff] = readULEB(first.rawBytes, 1);
|
|
5558
|
+
firstLiveInSpecialSeg.set(sIdx, {
|
|
5559
|
+
rType,
|
|
5560
|
+
afterRo: first.rawBytes.subarray(afterRoOff)
|
|
5561
|
+
});
|
|
5562
|
+
}
|
|
5563
|
+
}
|
|
5564
|
+
}
|
|
5565
|
+
const keptDataRelocBytes = [];
|
|
5566
|
+
const zeroDataRelocOffsets = [];
|
|
5567
|
+
const usedSyms = /* @__PURE__ */ new Set();
|
|
5568
|
+
for (const r of keptCodeRelocs) usedSyms.add(r.rs);
|
|
5569
|
+
for (const r of obj.dataRelocList) {
|
|
5570
|
+
const sName = obj.segNames[r.segIdx];
|
|
5571
|
+
if (sName === "swift5_type_metadata" || sName === "swift5_protocol_conformances" || sName === "__objc_classes") {
|
|
5572
|
+
if (deadSpecialSegs.has(r.segIdx)) continue;
|
|
5573
|
+
if (isSpecialSegRelocLive(obj, sName, r)) {
|
|
5574
|
+
keptDataRelocBytes.push(r.rawBytes);
|
|
5575
|
+
usedSyms.add(r.rs);
|
|
5576
|
+
} else if (sName === "__objc_classes") {
|
|
5577
|
+
zeroDataRelocOffsets.push(r.ro);
|
|
5578
|
+
} else {
|
|
5579
|
+
const repl = firstLiveInSpecialSeg.get(r.segIdx);
|
|
5580
|
+
const roBytes = encodeULEB(r.ro);
|
|
5581
|
+
const out = new Uint8Array(1 + roBytes.length + repl.afterRo.length);
|
|
5582
|
+
out[0] = repl.rType;
|
|
5583
|
+
out.set(roBytes, 1);
|
|
5584
|
+
out.set(repl.afterRo, 1 + roBytes.length);
|
|
5585
|
+
keptDataRelocBytes.push(out);
|
|
5586
|
+
}
|
|
5587
|
+
} else if (r.ownerSymIdx !== -1) {
|
|
5588
|
+
if (dLive.has(r.ownerSymIdx)) {
|
|
5589
|
+
keptDataRelocBytes.push(r.rawBytes);
|
|
5590
|
+
usedSyms.add(r.rs);
|
|
5591
|
+
}
|
|
5592
|
+
} else if (sLive[r.segIdx] === 1) {
|
|
5593
|
+
keptDataRelocBytes.push(r.rawBytes);
|
|
5594
|
+
usedSyms.add(r.rs);
|
|
5595
|
+
}
|
|
5596
|
+
}
|
|
5597
|
+
const keptInitSyms = obj.initFuncSyms.filter((symIdx) => {
|
|
5598
|
+
if (obj.symKind[symIdx] === 0 && obj.symElemIdx[symIdx] >= obj.numImportFuncs) {
|
|
5599
|
+
return fLive[obj.symElemIdx[symIdx] - obj.numImportFuncs] === 1;
|
|
5600
|
+
}
|
|
5601
|
+
return true;
|
|
5602
|
+
});
|
|
5603
|
+
for (const symIdx of keptInitSyms) usedSyms.add(symIdx);
|
|
5604
|
+
const outChunks = [buf.subarray(0, 8)];
|
|
5605
|
+
let pos = 8;
|
|
5606
|
+
while (pos < buf.length) {
|
|
5607
|
+
const secStart = pos;
|
|
5608
|
+
const id = buf[pos++];
|
|
5609
|
+
const [sz, p] = readULEB(buf, pos);
|
|
5610
|
+
const end = p + sz;
|
|
5611
|
+
if (id === 0) {
|
|
5612
|
+
const [nLen, np] = readULEB(buf, p);
|
|
5613
|
+
const name2 = Buffer.from(buf.subarray(np, np + nLen)).toString("utf8");
|
|
5614
|
+
const cp = np + nLen;
|
|
5615
|
+
if (name2 === "linking") {
|
|
5616
|
+
const [, lpStart] = readULEB(buf, cp);
|
|
5617
|
+
const subChunks = [buf.subarray(p, lpStart)];
|
|
5618
|
+
let lp = lpStart;
|
|
5619
|
+
while (lp < end) {
|
|
5620
|
+
const subStart = lp;
|
|
5621
|
+
const subId = buf[lp++];
|
|
5622
|
+
const [subLen, sp] = readULEB(buf, lp);
|
|
5623
|
+
const subEnd = sp + subLen;
|
|
5624
|
+
if (subId === 5) {
|
|
5625
|
+
const subCopy = new Uint8Array(buf.subarray(subStart, subEnd));
|
|
5626
|
+
let [cnt, cur] = readULEB(buf, sp);
|
|
5627
|
+
for (let i = 0; i < cnt; i++) {
|
|
5628
|
+
const [sLen, s2] = readULEB(buf, cur);
|
|
5629
|
+
const segName = obj.segNames[i];
|
|
5630
|
+
const isSpecial = segName === "swift5_type_metadata" || segName === "swift5_protocol_conformances" || segName === "__objc_classes";
|
|
5631
|
+
if (deadSpecialSegs.has(i)) {
|
|
5632
|
+
let repl = "";
|
|
5633
|
+
if (segName === "swift5_type_metadata") repl = ".dead_swift5_type_md";
|
|
5634
|
+
else if (segName === "swift5_protocol_conformances")
|
|
5635
|
+
repl = ".dead_swift5_protocol_confor";
|
|
5636
|
+
else if (segName === "__objc_classes") repl = ".dead_objc_cls";
|
|
5637
|
+
if (repl.length === sLen) {
|
|
5638
|
+
subCopy.set(Buffer.from(repl, "utf8"), s2 - subStart);
|
|
5639
|
+
}
|
|
5640
|
+
}
|
|
5641
|
+
cur = s2 + sLen;
|
|
5642
|
+
const [, s3] = readULEB(buf, cur);
|
|
5643
|
+
const [segFl, s4] = readULEB(buf, s3);
|
|
5644
|
+
const sFlLen = s4 - s3;
|
|
5645
|
+
const keepRetain = isSpecial ? !deadSpecialSegs.has(i) : isRootSegName(segName) && !segName.startsWith(".init_array") && sLive[i] === 1;
|
|
5646
|
+
const newSegFl = keepRetain ? segFl | 4 : segFl & ~4;
|
|
5647
|
+
if (sFlLen === 1) {
|
|
5648
|
+
subCopy[s3 - subStart] = newSegFl;
|
|
5649
|
+
} else if (sFlLen === 2) {
|
|
5650
|
+
subCopy[s3 - subStart] = newSegFl & 127 | 128;
|
|
5651
|
+
subCopy[s3 - subStart + 1] = newSegFl >> 7;
|
|
5652
|
+
}
|
|
5653
|
+
cur = s4;
|
|
5654
|
+
}
|
|
5655
|
+
subChunks.push(subCopy);
|
|
5656
|
+
} else if (subId === 6) {
|
|
5657
|
+
let [cnt, cur] = readULEB(buf, sp);
|
|
5658
|
+
const entrySlices = [];
|
|
5659
|
+
for (let i = 0; i < cnt; i++) {
|
|
5660
|
+
const eStart = cur;
|
|
5661
|
+
const [, s2] = readULEB(buf, cur);
|
|
5662
|
+
const [symIdx, s3] = readULEB(buf, s2);
|
|
5663
|
+
cur = s3;
|
|
5664
|
+
if (obj.symKind[symIdx] === 0 && obj.symElemIdx[symIdx] >= obj.numImportFuncs) {
|
|
5665
|
+
if (fLive[obj.symElemIdx[symIdx] - obj.numImportFuncs] === 1) {
|
|
5666
|
+
entrySlices.push(buf.subarray(eStart, cur));
|
|
5667
|
+
}
|
|
5668
|
+
} else {
|
|
5669
|
+
entrySlices.push(buf.subarray(eStart, cur));
|
|
5670
|
+
}
|
|
5671
|
+
}
|
|
5672
|
+
if (entrySlices.length > 0) {
|
|
5673
|
+
const cntBytes = Uint8Array.from(encodeULEB(entrySlices.length));
|
|
5674
|
+
const bodyLen = cntBytes.length + entrySlices.reduce((a, b) => a + b.length, 0);
|
|
5675
|
+
const lenBytes = Uint8Array.from(encodeULEB(bodyLen));
|
|
5676
|
+
subChunks.push(Uint8Array.of(6), lenBytes, cntBytes, ...entrySlices);
|
|
5677
|
+
}
|
|
5678
|
+
} else if (subId === 8) {
|
|
5679
|
+
const subCopy = new Uint8Array(buf.subarray(subStart, subEnd));
|
|
5680
|
+
let [cnt, cur] = readULEB(buf, sp);
|
|
5681
|
+
for (let i = 0; i < cnt; i++) {
|
|
5682
|
+
const kind = buf[cur++];
|
|
5683
|
+
const flOffset = cur - subStart;
|
|
5684
|
+
const [fl, c2] = readULEB(buf, cur);
|
|
5685
|
+
cur = c2;
|
|
5686
|
+
const isUndef = (fl & 16) !== 0;
|
|
5687
|
+
const isExplicitName = (fl & 64) !== 0;
|
|
5688
|
+
const flLen = c2 - (flOffset + subStart);
|
|
5689
|
+
let newFl = fl & 127;
|
|
5690
|
+
if (isUndef && (kind === 0 || kind === 1) && !usedSyms.has(i)) {
|
|
5691
|
+
newFl = (fl & ~3 | 1) & 127;
|
|
5692
|
+
} else if (!isUndef && kind === 0 && obj.symElemIdx[i] >= obj.numImportFuncs && fLive[obj.symElemIdx[i] - obj.numImportFuncs] === 0) {
|
|
5693
|
+
newFl = fl & 64 | 2;
|
|
5694
|
+
}
|
|
5695
|
+
if (flLen === 1) {
|
|
5696
|
+
subCopy[flOffset] = newFl;
|
|
5697
|
+
} else if (flLen === 2) {
|
|
5698
|
+
subCopy[flOffset] = newFl | 128;
|
|
5699
|
+
subCopy[flOffset + 1] = 0;
|
|
5700
|
+
}
|
|
5701
|
+
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
5702
|
+
const [, c3] = readULEB(buf, cur);
|
|
5703
|
+
cur = c3;
|
|
5704
|
+
if (!isUndef || isExplicitName) {
|
|
5705
|
+
const [sLen, c4] = readULEB(buf, cur);
|
|
5706
|
+
cur = c4 + sLen;
|
|
5707
|
+
}
|
|
5708
|
+
} else if (kind === 1) {
|
|
5709
|
+
const [sLen, c3] = readULEB(buf, cur);
|
|
5710
|
+
cur = c3 + sLen;
|
|
5711
|
+
if (!isUndef) {
|
|
5712
|
+
const [, c4] = readULEB(buf, cur);
|
|
5713
|
+
const [, c5] = readULEB(buf, c4);
|
|
5714
|
+
const [, c6] = readULEB(buf, c5);
|
|
5715
|
+
cur = c6;
|
|
5716
|
+
}
|
|
5717
|
+
} else if (kind === 3) {
|
|
5718
|
+
const [, c3] = readULEB(buf, cur);
|
|
5719
|
+
cur = c3;
|
|
5720
|
+
}
|
|
5721
|
+
}
|
|
5722
|
+
subChunks.push(subCopy);
|
|
5723
|
+
} else {
|
|
5724
|
+
subChunks.push(buf.subarray(subStart, subEnd));
|
|
5725
|
+
}
|
|
5726
|
+
lp = subEnd;
|
|
5727
|
+
}
|
|
5728
|
+
const totalSubLen = subChunks.reduce((a, b) => a + b.length, 0);
|
|
5729
|
+
outChunks.push(
|
|
5730
|
+
Uint8Array.of(0),
|
|
5731
|
+
Uint8Array.from(encodeULEB(totalSubLen)),
|
|
5732
|
+
...subChunks
|
|
5733
|
+
);
|
|
5734
|
+
} else if (name2 === "reloc.CODE") {
|
|
5735
|
+
const [, r1] = readULEB(buf, cp);
|
|
5736
|
+
const headerSlice = buf.subarray(p, r1);
|
|
5737
|
+
const cntBytes = Uint8Array.from(encodeULEB(keptCodeRelocs.length));
|
|
5738
|
+
const relSlices = keptCodeRelocs.map((r) => r.rawBytes);
|
|
5739
|
+
const totalLen = headerSlice.length + cntBytes.length + relSlices.reduce((a, b) => a + b.length, 0);
|
|
5740
|
+
outChunks.push(
|
|
5741
|
+
Uint8Array.of(0),
|
|
5742
|
+
Uint8Array.from(encodeULEB(totalLen)),
|
|
5743
|
+
headerSlice,
|
|
5744
|
+
cntBytes,
|
|
5745
|
+
...relSlices
|
|
5746
|
+
);
|
|
5747
|
+
} else if (name2 === "reloc.DATA") {
|
|
5748
|
+
const [, r1] = readULEB(buf, cp);
|
|
5749
|
+
const headerSlice = buf.subarray(p, r1);
|
|
5750
|
+
const cntBytes = Uint8Array.from(encodeULEB(keptDataRelocBytes.length));
|
|
5751
|
+
const totalLen = headerSlice.length + cntBytes.length + keptDataRelocBytes.reduce((a, b) => a + b.length, 0);
|
|
5752
|
+
outChunks.push(
|
|
5753
|
+
Uint8Array.of(0),
|
|
5754
|
+
Uint8Array.from(encodeULEB(totalLen)),
|
|
5755
|
+
headerSlice,
|
|
5756
|
+
cntBytes,
|
|
5757
|
+
...keptDataRelocBytes
|
|
5758
|
+
);
|
|
5759
|
+
} else if (name2 === ".swift1_autolink_entries") {
|
|
5760
|
+
} else {
|
|
5761
|
+
outChunks.push(buf.subarray(secStart, end));
|
|
5762
|
+
}
|
|
5763
|
+
} else {
|
|
5764
|
+
if (id === 11 && zeroDataRelocOffsets.length > 0) {
|
|
5765
|
+
for (const ro of zeroDataRelocOffsets) {
|
|
5766
|
+
buf.fill(0, p + ro, p + ro + 4);
|
|
5767
|
+
}
|
|
5768
|
+
}
|
|
5769
|
+
outChunks.push(buf.subarray(secStart, end));
|
|
5770
|
+
}
|
|
5771
|
+
pos = end;
|
|
5772
|
+
}
|
|
5773
|
+
fs6.writeFileSync(outFile, Buffer.concat(outChunks));
|
|
5774
|
+
};
|
|
5775
|
+
const prunableCandidates = [
|
|
5776
|
+
...distFiles,
|
|
5777
|
+
...sdkFiles.filter((f) => isPrunableSdkFile(f))
|
|
5778
|
+
];
|
|
5779
|
+
const reachedPrunableObjs = prunableCandidates.map((f) => distObjs.get(f)).filter((o) => extractedObjs.has(o));
|
|
5780
|
+
const prunedMap = /* @__PURE__ */ new Map();
|
|
5781
|
+
for (const o of reachedPrunableObjs) {
|
|
5782
|
+
const outPath = path12.join(prunedObjsDir, path12.basename(o.file));
|
|
5783
|
+
writePrunedObject(o, outPath);
|
|
5784
|
+
prunedMap.set(o.file, outPath);
|
|
5785
|
+
}
|
|
5786
|
+
const extraCoreConcurrencyObjs = allSdkObjFiles.filter(
|
|
5787
|
+
(f) => f.startsWith("libswiftCore__") && f !== "libswiftCore__Swift.o" || f.startsWith("libswift_Concurrency__") && f !== "libswift_Concurrency___Concurrency.o"
|
|
5788
|
+
).map((f) => path12.join(sdkObjsDir, f));
|
|
5789
|
+
const outTokens = [];
|
|
5790
|
+
const emittedPruned = /* @__PURE__ */ new Set();
|
|
5791
|
+
inStartLib = false;
|
|
5792
|
+
for (const t of tokens) {
|
|
5793
|
+
if (t === "--start-lib") {
|
|
5794
|
+
inStartLib = true;
|
|
5795
|
+
outTokens.push("--start-lib");
|
|
5796
|
+
for (const rf of prunableCandidates) {
|
|
5797
|
+
if (emittedPruned.has(rf)) continue;
|
|
5798
|
+
if (prunedMap.has(rf)) {
|
|
5799
|
+
outTokens.push(prunedMap.get(rf));
|
|
5800
|
+
emittedPruned.add(rf);
|
|
5801
|
+
} else if (rf.startsWith(distDir)) {
|
|
5802
|
+
const m = getModulePrefix(rf);
|
|
5803
|
+
if (m === "PeachICU" || m === "Darwin") {
|
|
5804
|
+
outTokens.push(rf);
|
|
5805
|
+
}
|
|
5806
|
+
}
|
|
5807
|
+
}
|
|
5808
|
+
outTokens.push(...extraCoreConcurrencyObjs);
|
|
5809
|
+
continue;
|
|
5810
|
+
}
|
|
5811
|
+
if (t === "--end-lib") {
|
|
5812
|
+
inStartLib = false;
|
|
5813
|
+
outTokens.push("--end-lib");
|
|
5814
|
+
continue;
|
|
5815
|
+
}
|
|
5816
|
+
if (inStartLib) continue;
|
|
5817
|
+
if (t === swiftrtOrigPath && patchedSwiftrtPath) {
|
|
5818
|
+
outTokens.push(patchedSwiftrtPath);
|
|
5819
|
+
} else if (prunedMap.has(t)) {
|
|
5820
|
+
outTokens.push(prunedMap.get(t));
|
|
5821
|
+
emittedPruned.add(t);
|
|
5822
|
+
} else if (OMIT_SDK_LIB_FLAGS.has(t)) {
|
|
5823
|
+
continue;
|
|
5824
|
+
} else {
|
|
5825
|
+
outTokens.push(t);
|
|
5826
|
+
}
|
|
5827
|
+
}
|
|
5828
|
+
const prunedRspPath = path12.join(directory, ".peach-link.pruned.rsp");
|
|
5829
|
+
fs6.writeFileSync(prunedRspPath, outTokens.map((t) => JSON.stringify(t)).join(" "));
|
|
5830
|
+
execFileSync4(path12.join(toolchainBin, "wasm-ld"), [`@${prunedRspPath}`], {
|
|
5831
|
+
stdio: "pipe"
|
|
5832
|
+
});
|
|
5833
|
+
fs6.rmSync(rspPath, { force: true });
|
|
5834
|
+
}
|
|
5835
|
+
|
|
4325
5836
|
// src/swiftContract.ts
|
|
4326
5837
|
var SWIFT_REMOTE_PACKAGES_DIR = "__packages__";
|
|
4327
5838
|
var SWIFT_LOCAL_PACKAGES_DIR = "__local_packages__";
|
|
@@ -4424,9 +5935,36 @@ function isSwiftResourceBundles(value) {
|
|
|
4424
5935
|
) && new Set(value.map((bundle) => bundle.target)).size === value.length && new Set(value.map((bundle) => bundle.path)).size === value.length;
|
|
4425
5936
|
}
|
|
4426
5937
|
|
|
5938
|
+
// src/wasm-optimize.ts
|
|
5939
|
+
import { BINARYEN_VERSION, wasmOpt } from "wasm-opt";
|
|
5940
|
+
var FEATURES = [
|
|
5941
|
+
"threads",
|
|
5942
|
+
"bulk-memory",
|
|
5943
|
+
"bulk-memory-opt",
|
|
5944
|
+
"call-indirect-overlong",
|
|
5945
|
+
"exception-handling",
|
|
5946
|
+
"multivalue",
|
|
5947
|
+
"mutable-globals",
|
|
5948
|
+
"nontrapping-float-to-int",
|
|
5949
|
+
"reference-types",
|
|
5950
|
+
"sign-ext"
|
|
5951
|
+
];
|
|
5952
|
+
var WASM_OPTIMIZE_IDENTITY = `wasm-opt ${BINARYEN_VERSION} -Oz ${FEATURES.join(",")}`;
|
|
5953
|
+
async function optimizeWasm(file, output) {
|
|
5954
|
+
const result = await wasmOpt([
|
|
5955
|
+
"-Oz",
|
|
5956
|
+
...FEATURES.map((feature) => `--enable-${feature}`),
|
|
5957
|
+
file,
|
|
5958
|
+
"-o",
|
|
5959
|
+
output
|
|
5960
|
+
]);
|
|
5961
|
+
if (result.status !== 0)
|
|
5962
|
+
throw new Error(`wasm-opt exited ${result.status}: ${result.stderr}`);
|
|
5963
|
+
}
|
|
5964
|
+
|
|
4427
5965
|
// src/xcode-header-search.ts
|
|
4428
|
-
import
|
|
4429
|
-
import
|
|
5966
|
+
import fs7 from "node:fs";
|
|
5967
|
+
import path13 from "node:path";
|
|
4430
5968
|
function headerMap(entries) {
|
|
4431
5969
|
const unique = /* @__PURE__ */ new Map();
|
|
4432
5970
|
for (const entry of entries)
|
|
@@ -4469,16 +6007,16 @@ function headerMap(entries) {
|
|
|
4469
6007
|
return Buffer.concat([table, ...strings]);
|
|
4470
6008
|
}
|
|
4471
6009
|
function writeXcodeHeaderSearch(directory, targets) {
|
|
4472
|
-
|
|
6010
|
+
fs7.mkdirSync(directory, { recursive: true });
|
|
4473
6011
|
const productDirectories = /* @__PURE__ */ new Map();
|
|
4474
6012
|
for (const target of targets)
|
|
4475
6013
|
for (const [product, file] of Object.entries(target.productHeaders)) {
|
|
4476
|
-
const listed = productDirectories.get(
|
|
4477
|
-
productDirectories.set(
|
|
4478
|
-
listed.push({ name:
|
|
6014
|
+
const listed = productDirectories.get(path13.dirname(product)) ?? [];
|
|
6015
|
+
productDirectories.set(path13.dirname(product), listed);
|
|
6016
|
+
listed.push({ name: path13.basename(product), file });
|
|
4479
6017
|
}
|
|
4480
|
-
const overlay =
|
|
4481
|
-
|
|
6018
|
+
const overlay = path13.join(directory, "all-product-headers.yaml");
|
|
6019
|
+
fs7.writeFileSync(
|
|
4482
6020
|
overlay,
|
|
4483
6021
|
JSON.stringify({
|
|
4484
6022
|
"case-sensitive": "false",
|
|
@@ -4497,8 +6035,8 @@ function writeXcodeHeaderSearch(directory, targets) {
|
|
|
4497
6035
|
const files = [overlay];
|
|
4498
6036
|
const flags = targets.map((target, index) => {
|
|
4499
6037
|
const maps = target.headerMaps.map((map, order) => {
|
|
4500
|
-
const file =
|
|
4501
|
-
|
|
6038
|
+
const file = path13.join(directory, `${index}-${order}.hmap`);
|
|
6039
|
+
fs7.writeFileSync(file, headerMap(map.entries));
|
|
4502
6040
|
files.push(file);
|
|
4503
6041
|
return { flag: map.flag, file };
|
|
4504
6042
|
});
|
|
@@ -4604,7 +6142,7 @@ var admittedCores = Number(process.env.TM_EXEC_CPU_CORES);
|
|
|
4604
6142
|
var BUILD_JOBS = String(
|
|
4605
6143
|
Math.min(
|
|
4606
6144
|
4,
|
|
4607
|
-
Math.max(1, Math.floor(
|
|
6145
|
+
Math.max(1, Math.floor(os3.availableParallelism() / 2)),
|
|
4608
6146
|
Number.isInteger(admittedCores) && admittedCores > 0 ? admittedCores : 4
|
|
4609
6147
|
)
|
|
4610
6148
|
);
|
|
@@ -4614,10 +6152,39 @@ function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
|
|
|
4614
6152
|
return (compileTimeoutMs ?? SWIFT_BUILDER_DEFAULT_COMPILE_MS) + SWIFT_BUILDER_TRANSPORT_MARGIN_MS;
|
|
4615
6153
|
}
|
|
4616
6154
|
function swiftDistributionAt(root) {
|
|
4617
|
-
const file =
|
|
6155
|
+
const file = path14.join(root, SWIFT_DISTRIBUTION_MANIFEST);
|
|
4618
6156
|
if (!existsSync2(file)) return null;
|
|
4619
6157
|
return parseSwiftDistributionManifest(JSON.parse(readFileSync7(file, "utf8")));
|
|
4620
6158
|
}
|
|
6159
|
+
function swiftModuleInterface(moduleRoot, name2) {
|
|
6160
|
+
if (swiftDistributionAt(moduleRoot)) {
|
|
6161
|
+
const file = path14.join(moduleRoot, "modules", `${name2}-Swift.h`);
|
|
6162
|
+
if (!existsSync2(file)) return null;
|
|
6163
|
+
const header = clangInterfaceHeader(readFileSync7(file, "utf8"));
|
|
6164
|
+
return { declared: swiftInterfaceDeclarations(header), header };
|
|
6165
|
+
}
|
|
6166
|
+
const sources = path14.join(moduleRoot, "Sources", name2);
|
|
6167
|
+
if (!existsSync2(sources)) return null;
|
|
6168
|
+
const declared = /* @__PURE__ */ new Set();
|
|
6169
|
+
for (const file of readdirSync5(sources, { recursive: true, encoding: "utf8" }))
|
|
6170
|
+
if (file.endsWith(".swift"))
|
|
6171
|
+
for (const [, objc] of readFileSync7(path14.join(sources, file), "utf8").matchAll(
|
|
6172
|
+
/@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s/g
|
|
6173
|
+
))
|
|
6174
|
+
declared.add(objc);
|
|
6175
|
+
if (declared.size === 0) return null;
|
|
6176
|
+
const built = path14.join(moduleRoot, ".build/host", `${name2}-Swift.h`);
|
|
6177
|
+
return {
|
|
6178
|
+
declared,
|
|
6179
|
+
header: existsSync2(built) ? clangInterfaceHeader(readFileSync7(built, "utf8")) : `// ${name2}-Swift.h is generated when ${name2} builds
|
|
6180
|
+
`
|
|
6181
|
+
};
|
|
6182
|
+
}
|
|
6183
|
+
var clangInterfaceHeader = (header) => header.replace(/^@import UIKitCore;$/m, "@import UIKit;");
|
|
6184
|
+
var swiftInterfaceDeclarations = (header) => /* @__PURE__ */ new Set([
|
|
6185
|
+
...[...header.matchAll(/^@protocol\s+(\w+)\b(?![^\n]*;\s*$)/gm)].map((m) => m[1]),
|
|
6186
|
+
...[...header.matchAll(/^@interface\s+(\w+)\s*(?=[:<{]|$)/gm)].map((m) => m[1])
|
|
6187
|
+
]);
|
|
4621
6188
|
function swiftModuleSdk(root) {
|
|
4622
6189
|
const pin = swiftDistributionAt(root) ?? swiftSourceSdk(root);
|
|
4623
6190
|
return {
|
|
@@ -4626,12 +6193,21 @@ function swiftModuleSdk(root) {
|
|
|
4626
6193
|
wasmSdkChecksum: pin.wasmSdkChecksum
|
|
4627
6194
|
};
|
|
4628
6195
|
}
|
|
6196
|
+
function swiftCompileSdkOptions(moduleRoot, toolchainBin) {
|
|
6197
|
+
return swiftSharedSdkViewOptions(
|
|
6198
|
+
moduleRoot,
|
|
6199
|
+
swiftDistributionAt(moduleRoot) !== null,
|
|
6200
|
+
toolchainBin,
|
|
6201
|
+
swiftModuleSdk(moduleRoot).wasmSdkId
|
|
6202
|
+
);
|
|
6203
|
+
}
|
|
4629
6204
|
function swiftModuleInputFiles(root) {
|
|
4630
6205
|
if (swiftDistributionAt(root)) return [SWIFT_DISTRIBUTION_MANIFEST];
|
|
4631
6206
|
const files = [
|
|
4632
6207
|
...swiftSharedSdkInputFiles(root),
|
|
4633
6208
|
"../peachsim/src/swift-shared-sdk.ts",
|
|
4634
6209
|
"../../scripts/generate/swift-sdk-module/darwin-mach.json",
|
|
6210
|
+
"../../scripts/generate/swift-sdk-module/darwin-socketvar.json",
|
|
4635
6211
|
"../../scripts/ops/swift-distribution-publish.ts",
|
|
4636
6212
|
"Package.swift",
|
|
4637
6213
|
"scripts/contrast-app-Package.swift",
|
|
@@ -4647,7 +6223,7 @@ function swiftModuleInputFiles(root) {
|
|
|
4647
6223
|
"toolchain.json"
|
|
4648
6224
|
];
|
|
4649
6225
|
const walk = (dir) => {
|
|
4650
|
-
for (const entry of readdirSync5(
|
|
6226
|
+
for (const entry of readdirSync5(path14.join(root, dir), {
|
|
4651
6227
|
withFileTypes: true
|
|
4652
6228
|
})) {
|
|
4653
6229
|
const relative = `${dir}/${entry.name}`;
|
|
@@ -4665,35 +6241,35 @@ function swiftMacroPlugins(moduleRoot) {
|
|
|
4665
6241
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
4666
6242
|
if (distribution)
|
|
4667
6243
|
return {
|
|
4668
|
-
libraries: distribution.plugins.filter((plugin) =>
|
|
4669
|
-
executables: distribution.plugins.filter((plugin) =>
|
|
6244
|
+
libraries: distribution.plugins.filter((plugin) => path14.basename(plugin) !== "ExpoModulesMacros").map((plugin) => path14.join(moduleRoot, plugin)),
|
|
6245
|
+
executables: distribution.plugins.filter((plugin) => path14.basename(plugin) === "ExpoModulesMacros").map((plugin) => path14.join(moduleRoot, plugin)),
|
|
4670
6246
|
stale: false
|
|
4671
6247
|
};
|
|
4672
|
-
const dir =
|
|
6248
|
+
const dir = path14.join(moduleRoot, ".build/host/RnxPreviewMacros");
|
|
4673
6249
|
const release = JSON.parse(
|
|
4674
|
-
readFileSync7(
|
|
6250
|
+
readFileSync7(path14.join(moduleRoot, "toolchain.json"), "utf8")
|
|
4675
6251
|
).release;
|
|
4676
|
-
const compilerStamp =
|
|
4677
|
-
const pluginScript =
|
|
4678
|
-
const expoPlugin =
|
|
6252
|
+
const compilerStamp = path14.join(dir, "compiler-release");
|
|
6253
|
+
const pluginScript = path14.join(moduleRoot, "scripts/build-preview-plugin.sh");
|
|
6254
|
+
const expoPlugin = path14.join(dir, "ExpoModulesMacros");
|
|
4679
6255
|
const ext = process.platform === "darwin" ? "dylib" : "so";
|
|
4680
6256
|
const plugins = [
|
|
4681
6257
|
{
|
|
4682
|
-
library:
|
|
4683
|
-
sources: [
|
|
6258
|
+
library: path14.join(dir, `libRnxPreviewMacros.${ext}`),
|
|
6259
|
+
sources: [path14.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
|
|
4684
6260
|
},
|
|
4685
6261
|
{
|
|
4686
|
-
library:
|
|
6262
|
+
library: path14.join(dir, `libFoundationMacros.${ext}`),
|
|
4687
6263
|
sources: [
|
|
4688
|
-
|
|
4689
|
-
|
|
6264
|
+
path14.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
|
|
6265
|
+
path14.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
|
|
4690
6266
|
]
|
|
4691
6267
|
},
|
|
4692
6268
|
{
|
|
4693
|
-
library:
|
|
6269
|
+
library: path14.join(dir, `libTipKitMacros.${ext}`),
|
|
4694
6270
|
sources: [
|
|
4695
|
-
|
|
4696
|
-
|
|
6271
|
+
path14.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
|
|
6272
|
+
path14.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
|
|
4697
6273
|
]
|
|
4698
6274
|
}
|
|
4699
6275
|
];
|
|
@@ -4711,14 +6287,14 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal) {
|
|
|
4711
6287
|
await runCompiler(
|
|
4712
6288
|
"sh",
|
|
4713
6289
|
[
|
|
4714
|
-
|
|
6290
|
+
path14.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
4715
6291
|
toolchainBin,
|
|
4716
6292
|
libraries[0]
|
|
4717
6293
|
],
|
|
4718
6294
|
{ signal }
|
|
4719
6295
|
);
|
|
4720
6296
|
writeFileSync3(
|
|
4721
|
-
|
|
6297
|
+
path14.join(path14.dirname(libraries[0]), "compiler-release"),
|
|
4722
6298
|
`${release}
|
|
4723
6299
|
`
|
|
4724
6300
|
);
|
|
@@ -4732,9 +6308,9 @@ function clearLinkedModuleDigests(root) {
|
|
|
4732
6308
|
}
|
|
4733
6309
|
function swiftModuleDigest(root) {
|
|
4734
6310
|
const files = swiftModuleInputFiles(root);
|
|
4735
|
-
const stampHash =
|
|
6311
|
+
const stampHash = createHash8("sha256");
|
|
4736
6312
|
for (const file of files) {
|
|
4737
|
-
const stat = statSync(
|
|
6313
|
+
const stat = statSync(path14.join(root, file), { bigint: true });
|
|
4738
6314
|
stampHash.update(file);
|
|
4739
6315
|
stampHash.update(
|
|
4740
6316
|
`${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
|
|
@@ -4744,11 +6320,11 @@ function swiftModuleDigest(root) {
|
|
|
4744
6320
|
const stamp = stampHash.digest("hex");
|
|
4745
6321
|
const cached = linkedModuleDigests.get(root);
|
|
4746
6322
|
if (cached?.stamp === stamp) return cached.digest;
|
|
4747
|
-
const hash =
|
|
6323
|
+
const hash = createHash8("sha256");
|
|
4748
6324
|
for (const file of files) {
|
|
4749
|
-
hash.update(
|
|
6325
|
+
hash.update(createHash8("sha256").update(file).digest());
|
|
4750
6326
|
hash.update(
|
|
4751
|
-
|
|
6327
|
+
createHash8("sha256").update(readFileSync7(path14.join(root, file))).digest()
|
|
4752
6328
|
);
|
|
4753
6329
|
}
|
|
4754
6330
|
const digest = hash.digest();
|
|
@@ -4756,7 +6332,7 @@ function swiftModuleDigest(root) {
|
|
|
4756
6332
|
return digest;
|
|
4757
6333
|
}
|
|
4758
6334
|
function swiftProjectBuildKey(moduleRoot, release) {
|
|
4759
|
-
return
|
|
6335
|
+
return createHash8("sha256").update(`${release}\0${swiftModuleSdk(moduleRoot).wasmSdkId}`).update(swiftModuleDigest(moduleRoot)).digest("hex").slice(0, 32);
|
|
4760
6336
|
}
|
|
4761
6337
|
function compileTargets(input) {
|
|
4762
6338
|
const manifest = input.files["Package.swift"];
|
|
@@ -4772,7 +6348,7 @@ function withNativeSourceGlue(input, glue) {
|
|
|
4772
6348
|
...input,
|
|
4773
6349
|
files: {
|
|
4774
6350
|
...input.files,
|
|
4775
|
-
[
|
|
6351
|
+
[path14.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
|
|
4776
6352
|
},
|
|
4777
6353
|
oneModule: true
|
|
4778
6354
|
};
|
|
@@ -4788,9 +6364,8 @@ var OPTIONAL_FRAMEWORK_DEPENDENCIES = {
|
|
|
4788
6364
|
ImagePlayground: [],
|
|
4789
6365
|
QuickLookThumbnailing: [],
|
|
4790
6366
|
libxml2: [],
|
|
4791
|
-
Compression: [
|
|
4792
|
-
zlib: [
|
|
4793
|
-
PeachCodec: [],
|
|
6367
|
+
Compression: [],
|
|
6368
|
+
zlib: [],
|
|
4794
6369
|
TikTokBusinessSDK: [],
|
|
4795
6370
|
nSure: [],
|
|
4796
6371
|
Statsig: [],
|
|
@@ -4913,21 +6488,22 @@ function swiftImportNames(contents, available) {
|
|
|
4913
6488
|
function swiftPeachModules(moduleRoot) {
|
|
4914
6489
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
4915
6490
|
return distribution ? distribution.modules : swiftManifestDeclarations(
|
|
4916
|
-
readFileSync7(
|
|
6491
|
+
readFileSync7(path14.join(moduleRoot, "Package.swift"), "utf8")
|
|
4917
6492
|
).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
|
|
4918
6493
|
}
|
|
4919
6494
|
var sdkPaths = /* @__PURE__ */ new Map();
|
|
4920
6495
|
function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
4921
6496
|
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
|
|
4922
|
-
const
|
|
6497
|
+
const options = swiftCompileSdkOptions(moduleRoot, toolchainBin);
|
|
6498
|
+
const key = JSON.stringify([toolchainBin, sdk, options]);
|
|
4923
6499
|
const cached = sdkPaths.get(key);
|
|
4924
6500
|
if (cached) return cached;
|
|
4925
|
-
const configuration =
|
|
4926
|
-
|
|
6501
|
+
const configuration = execFileSync5(
|
|
6502
|
+
path14.join(toolchainBin, "swift"),
|
|
4927
6503
|
[
|
|
4928
6504
|
"sdk",
|
|
4929
6505
|
"configure",
|
|
4930
|
-
...
|
|
6506
|
+
...options,
|
|
4931
6507
|
"--show-configuration",
|
|
4932
6508
|
sdk,
|
|
4933
6509
|
"wasm32-unknown-wasip1"
|
|
@@ -4953,25 +6529,25 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
4953
6529
|
const compiler = config.swiftCompiler;
|
|
4954
6530
|
if (!compiler || typeof compiler !== "object" || !("extraCLIOptions" in compiler))
|
|
4955
6531
|
continue;
|
|
4956
|
-
const
|
|
4957
|
-
if (!Array.isArray(
|
|
6532
|
+
const options2 = compiler.extraCLIOptions;
|
|
6533
|
+
if (!Array.isArray(options2) || !options2.every((value) => typeof value === "string"))
|
|
4958
6534
|
throw new Error(
|
|
4959
6535
|
`swift sdk ${sdk} has invalid swift compiler options in ${toolset}`
|
|
4960
6536
|
);
|
|
4961
|
-
for (let index = 0; index <
|
|
4962
|
-
if (
|
|
4963
|
-
const flag =
|
|
6537
|
+
for (let index = 0; index < options2.length; index++) {
|
|
6538
|
+
if (options2[index] === "-Xcc" && typeof options2[index + 1] === "string") {
|
|
6539
|
+
const flag = options2[index + 1];
|
|
4964
6540
|
if (flag !== "-fwasm-exceptions") cFlags.push(flag);
|
|
4965
|
-
if (flag === "-iframeworkwithsysroot" &&
|
|
4966
|
-
cFlags.push(
|
|
4967
|
-
frameworks.push(
|
|
6541
|
+
if (flag === "-iframeworkwithsysroot" && options2[index + 2] === "-Xcc" && typeof options2[index + 3] === "string") {
|
|
6542
|
+
cFlags.push(options2[index + 3]);
|
|
6543
|
+
frameworks.push(path14.join(sysroot, options2[index + 3]));
|
|
4968
6544
|
index += 3;
|
|
4969
6545
|
continue;
|
|
4970
6546
|
}
|
|
4971
6547
|
index += 1;
|
|
4972
6548
|
continue;
|
|
4973
6549
|
}
|
|
4974
|
-
const option =
|
|
6550
|
+
const option = options2[index];
|
|
4975
6551
|
if (option.startsWith("-iframework") || option.startsWith("-F"))
|
|
4976
6552
|
throw new Error(
|
|
4977
6553
|
`swift sdk ${sdk} has an unsupported framework search option ${option}`
|
|
@@ -4981,7 +6557,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
4981
6557
|
}
|
|
4982
6558
|
const paths = {
|
|
4983
6559
|
sysroot,
|
|
4984
|
-
darwin:
|
|
6560
|
+
darwin: path14.join(sysroot, "darwin"),
|
|
4985
6561
|
resources: field("swiftResourcesPath"),
|
|
4986
6562
|
frameworks,
|
|
4987
6563
|
cFlags
|
|
@@ -4997,19 +6573,19 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
4997
6573
|
if (cached) return cached;
|
|
4998
6574
|
const modules = new Set(swiftPeachModules(moduleRoot));
|
|
4999
6575
|
const { resources, frameworks } = swiftSdkPaths(moduleRoot, toolchainBin);
|
|
5000
|
-
for (const entry of readdirSync5(
|
|
6576
|
+
for (const entry of readdirSync5(path14.join(resources, "wasi"))) {
|
|
5001
6577
|
if (entry.endsWith(".swiftmodule"))
|
|
5002
6578
|
modules.add(entry.slice(0, -".swiftmodule".length));
|
|
5003
6579
|
}
|
|
5004
6580
|
for (const entry of readdirSync5(resources)) {
|
|
5005
|
-
const map =
|
|
6581
|
+
const map = path14.join(resources, entry, "module.modulemap");
|
|
5006
6582
|
if (!existsSync2(map)) continue;
|
|
5007
6583
|
for (const match of readFileSync7(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
|
|
5008
6584
|
modules.add(match[1]);
|
|
5009
6585
|
}
|
|
5010
6586
|
for (const directory of frameworks) {
|
|
5011
6587
|
for (const entry of readdirSync5(directory)) {
|
|
5012
|
-
const map =
|
|
6588
|
+
const map = path14.join(directory, entry, "Modules/module.modulemap");
|
|
5013
6589
|
if (!existsSync2(map)) continue;
|
|
5014
6590
|
for (const match of readFileSync7(map, "utf8").matchAll(
|
|
5015
6591
|
/^framework\s+module\s+([A-Za-z_]\w*)/gm
|
|
@@ -5062,18 +6638,18 @@ function swiftSystemLibraryExclusions(files, targets, distributionModules) {
|
|
|
5062
6638
|
);
|
|
5063
6639
|
}
|
|
5064
6640
|
function distributionModulesPath(root, moduleRoot, excluded) {
|
|
5065
|
-
const modules =
|
|
6641
|
+
const modules = path14.join(moduleRoot, "modules");
|
|
5066
6642
|
if (!excluded || excluded.size === 0) return modules;
|
|
5067
|
-
const key =
|
|
5068
|
-
const directory =
|
|
5069
|
-
const complete =
|
|
6643
|
+
const key = createHash8("sha256").update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
|
|
6644
|
+
const directory = path14.join(root, `.peach-modules-${key}`);
|
|
6645
|
+
const complete = path14.join(directory, ".complete");
|
|
5070
6646
|
if (!existsSync2(complete)) {
|
|
5071
6647
|
mkdirSync2(directory, { recursive: true });
|
|
5072
6648
|
for (const entry of readdirSync5(directory))
|
|
5073
|
-
rmSync3(
|
|
6649
|
+
rmSync3(path14.join(directory, entry), { recursive: true, force: true });
|
|
5074
6650
|
for (const entry of readdirSync5(modules)) {
|
|
5075
6651
|
if (excluded.has(entry.replace(/\.swiftmodule$/, ""))) continue;
|
|
5076
|
-
symlinkSync(
|
|
6652
|
+
symlinkSync(path14.join(modules, entry), path14.join(directory, entry));
|
|
5077
6653
|
}
|
|
5078
6654
|
writeFileSync3(complete, "");
|
|
5079
6655
|
}
|
|
@@ -5120,7 +6696,7 @@ var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
|
|
|
5120
6696
|
).join("");
|
|
5121
6697
|
var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
5122
6698
|
var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
5123
|
-
"-Xclang-linker", ${JSON.stringify(`-fuse-ld=${
|
|
6699
|
+
"-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path14.join(root, SWIFT_AUTOLINK_LINKER)}`)},
|
|
5124
6700
|
"-Xlinker", "-z", "-Xlinker", "stack-size=8372224",
|
|
5125
6701
|
"-Xlinker", "--stack-first",
|
|
5126
6702
|
"-Xlinker", "--global-base=8372224",
|
|
@@ -5129,44 +6705,47 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
|
5129
6705
|
"-Xlinker", "--growable-table",
|
|
5130
6706
|
`;
|
|
5131
6707
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
5132
|
-
var MULTI_MANIFEST_VERSION =
|
|
5133
|
-
var compilerSourceDigest = true ? "
|
|
6708
|
+
var MULTI_MANIFEST_VERSION = 51;
|
|
6709
|
+
var compilerSourceDigest = true ? "b895d808e6b9911d7c80744af3eb884b635b96b82b69c6903f1e66ebd7485d6c" : swiftCompilerSourceDigest(import.meta.dirname);
|
|
5134
6710
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
5135
|
-
const hash =
|
|
6711
|
+
const hash = createHash8("sha256");
|
|
5136
6712
|
hash.update(`swift-compile
|
|
5137
6713
|
${release}
|
|
5138
6714
|
`);
|
|
5139
6715
|
hash.update(compilerSourceDigest);
|
|
5140
6716
|
if (input.oneModule) hash.update("one-module\n");
|
|
5141
6717
|
hash.update(swiftModuleDigest(moduleRoot));
|
|
5142
|
-
if (input.lazyDistribution)
|
|
6718
|
+
if (input.lazyDistribution)
|
|
6719
|
+
hash.update(`lazy-distribution
|
|
6720
|
+
${WASM_OPTIMIZE_IDENTITY}
|
|
6721
|
+
`);
|
|
5143
6722
|
for (const file of Object.keys(input.files).sort()) {
|
|
5144
|
-
hash.update(
|
|
5145
|
-
hash.update(
|
|
6723
|
+
hash.update(createHash8("sha256").update(file).digest());
|
|
6724
|
+
hash.update(createHash8("sha256").update(input.files[file]).digest());
|
|
5146
6725
|
}
|
|
5147
6726
|
for (const file of Object.keys(input.metalSources ?? {}).sort()) {
|
|
5148
6727
|
hash.update("metal-source\n");
|
|
5149
|
-
hash.update(
|
|
6728
|
+
hash.update(createHash8("sha256").update(file).digest());
|
|
5150
6729
|
hash.update(
|
|
5151
|
-
|
|
6730
|
+
createHash8("sha256").update(input.metalSources?.[file] ?? "").digest()
|
|
5152
6731
|
);
|
|
5153
6732
|
}
|
|
5154
6733
|
for (const base of Object.keys(input.resources ?? {}).sort()) {
|
|
5155
|
-
hash.update(
|
|
6734
|
+
hash.update(createHash8("sha256").update(base).digest());
|
|
5156
6735
|
hash.update(
|
|
5157
|
-
|
|
6736
|
+
createHash8("sha256").update(input.resources?.[base] ?? "").digest()
|
|
5158
6737
|
);
|
|
5159
6738
|
}
|
|
5160
6739
|
for (const name2 of Object.keys(input.images ?? {}).sort()) {
|
|
5161
6740
|
const image = input.images?.[name2];
|
|
5162
6741
|
if (!image) continue;
|
|
5163
|
-
hash.update(
|
|
5164
|
-
hash.update(
|
|
5165
|
-
hash.update(
|
|
6742
|
+
hash.update(createHash8("sha256").update(name2).digest());
|
|
6743
|
+
hash.update(createHash8("sha256").update(image.file).digest());
|
|
6744
|
+
hash.update(createHash8("sha256").update(image.data).digest());
|
|
5166
6745
|
}
|
|
5167
6746
|
for (const file of [...new Set(input.resourcePaths ?? [])].sort()) {
|
|
5168
6747
|
hash.update("resource-path\n");
|
|
5169
|
-
hash.update(
|
|
6748
|
+
hash.update(createHash8("sha256").update(file).digest());
|
|
5170
6749
|
}
|
|
5171
6750
|
hash.update(
|
|
5172
6751
|
JSON.stringify(
|
|
@@ -5181,18 +6760,18 @@ ${input.defaultLocalization}
|
|
|
5181
6760
|
`);
|
|
5182
6761
|
for (const file of Object.keys(input.packageFiles ?? {}).sort()) {
|
|
5183
6762
|
hash.update(`package-file\0${file}\0`);
|
|
5184
|
-
hash.update(
|
|
6763
|
+
hash.update(createHash8("sha256").update(input.packageFiles[file]).digest());
|
|
5185
6764
|
}
|
|
5186
6765
|
for (const file of Object.keys(input.projectFiles ?? {}).sort()) {
|
|
5187
6766
|
hash.update(`project-file\0${file}\0`);
|
|
5188
|
-
hash.update(
|
|
6767
|
+
hash.update(createHash8("sha256").update(input.projectFiles[file]).digest());
|
|
5189
6768
|
}
|
|
5190
6769
|
for (const target of Object.keys(input.libraries ?? {}).sort()) {
|
|
5191
6770
|
hash.update(`library
|
|
5192
6771
|
${target}
|
|
5193
6772
|
`);
|
|
5194
6773
|
hash.update(
|
|
5195
|
-
|
|
6774
|
+
createHash8("sha256").update(input.libraries?.[target] ?? "").digest()
|
|
5196
6775
|
);
|
|
5197
6776
|
}
|
|
5198
6777
|
const targets = compileTargets(input);
|
|
@@ -5211,7 +6790,7 @@ ${target}
|
|
|
5211
6790
|
return hash.digest("hex");
|
|
5212
6791
|
}
|
|
5213
6792
|
function swiftCrossImportFlags(moduleRoot, distribution) {
|
|
5214
|
-
const overlayRoot =
|
|
6793
|
+
const overlayRoot = path14.join(
|
|
5215
6794
|
moduleRoot,
|
|
5216
6795
|
distribution ? "modules" : "cross-import-overlays"
|
|
5217
6796
|
);
|
|
@@ -5219,9 +6798,9 @@ function swiftCrossImportFlags(moduleRoot, distribution) {
|
|
|
5219
6798
|
"-Xfrontend",
|
|
5220
6799
|
"-swift-module-cross-import",
|
|
5221
6800
|
"-Xfrontend",
|
|
5222
|
-
|
|
6801
|
+
path14.basename(path14.dirname(file), ".swiftcrossimport"),
|
|
5223
6802
|
"-Xfrontend",
|
|
5224
|
-
|
|
6803
|
+
path14.join(overlayRoot, file)
|
|
5225
6804
|
]);
|
|
5226
6805
|
}
|
|
5227
6806
|
function withoutWasmOverlayIsystem(flags) {
|
|
@@ -5267,17 +6846,19 @@ function emitSwiftPackageManifest(args) {
|
|
|
5267
6846
|
(name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
|
|
5268
6847
|
)
|
|
5269
6848
|
);
|
|
5270
|
-
const quoted = (object) => `"${
|
|
6849
|
+
const quoted = (object) => `"${path14.join(moduleRoot, object).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
5271
6850
|
const roots = args.lazyDistribution ? swiftObjcRootObjects(distribution.id, moduleRoot, distribution.objects) : null;
|
|
5272
6851
|
const list = (roots ? [
|
|
5273
6852
|
...objects.filter((object) => roots.has(object)).map(quoted),
|
|
5274
6853
|
"-Wl,--start-lib",
|
|
5275
|
-
...objects.filter(
|
|
6854
|
+
...objects.filter(
|
|
6855
|
+
(object) => !roots.has(object) && object !== "lib/Foundation-NSStringFormatting.o"
|
|
6856
|
+
).map(quoted),
|
|
5276
6857
|
"-Wl,--end-lib"
|
|
5277
6858
|
] : objects.map(quoted)).join("\n") + "\n";
|
|
5278
6859
|
distributionLinkPath = distributionLink.path.replace(
|
|
5279
6860
|
/\.rsp$/,
|
|
5280
|
-
`-${
|
|
6861
|
+
`-${createHash8("sha256").update(list).digest("hex").slice(0, 12)}.rsp`
|
|
5281
6862
|
);
|
|
5282
6863
|
distributionLink.files.set(distributionLinkPath, list);
|
|
5283
6864
|
}
|
|
@@ -5291,7 +6872,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
5291
6872
|
const stanza = (target) => {
|
|
5292
6873
|
const native = args.native?.get(target.name);
|
|
5293
6874
|
if (target.systemLibrary || native?.clang?.sources.length === 0)
|
|
5294
|
-
return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ?
|
|
6875
|
+
return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? path14.posix.dirname(native.clang.modulemap) : target.path)}),`;
|
|
5295
6876
|
const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
|
|
5296
6877
|
const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
|
|
5297
6878
|
const defines = (target.defines ?? []).map((name2) => ` .define(${JSON.stringify(name2)}),`).join("");
|
|
@@ -5332,12 +6913,12 @@ function emitSwiftPackageManifest(args) {
|
|
|
5332
6913
|
].map((flag) => `, ${JSON.stringify(flag)}`).join("");
|
|
5333
6914
|
const header = args.headerDirectory && [...args.native?.values() ?? []].some(
|
|
5334
6915
|
(value) => value.late?.producers.includes(target.name)
|
|
5335
|
-
) ? `, "-emit-objc-header-path", ${JSON.stringify(
|
|
6916
|
+
) ? `, "-emit-objc-header-path", ${JSON.stringify(path14.join(args.headerDirectory, `${target.name}-Swift.h`))}` : "";
|
|
5336
6917
|
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}])]`;
|
|
5337
6918
|
const deps = [
|
|
5338
6919
|
.../* @__PURE__ */ new Set([
|
|
5339
6920
|
...(target.dependencies ?? []).flatMap(
|
|
5340
|
-
(dependency) => dependency.kind === "product" && !(linkedObjects && dependency.package ===
|
|
6921
|
+
(dependency) => dependency.kind === "product" && !(linkedObjects && dependency.package === path14.basename(moduleRoot).toLowerCase()) ? [
|
|
5341
6922
|
`.product(name: ${JSON.stringify(dependency.name)}, package: ${JSON.stringify(dependency.package)})`
|
|
5342
6923
|
] : []
|
|
5343
6924
|
),
|
|
@@ -5408,8 +6989,8 @@ function emitSwiftPackageManifest(args) {
|
|
|
5408
6989
|
` path: ${JSON.stringify(native?.clang ? "." : target.path)},`,
|
|
5409
6990
|
...exclusions.length ? [` exclude: ${JSON.stringify(exclusions)},`] : [],
|
|
5410
6991
|
...native?.clang ? [
|
|
5411
|
-
` sources: ${JSON.stringify(native.clang.sources.map((source) =>
|
|
5412
|
-
` publicHeadersPath: ${JSON.stringify(
|
|
6992
|
+
` sources: ${JSON.stringify(native.clang.sources.map((source) => path14.posix.join(native.path, source)))},`,
|
|
6993
|
+
` publicHeadersPath: ${JSON.stringify(path14.posix.dirname(native.clang.modulemap))},`
|
|
5413
6994
|
] : native?.flags ? [` sources: ${JSON.stringify(native.sources)},`] : [],
|
|
5414
6995
|
...!native?.clang && target.publicHeadersPath !== void 0 ? [` publicHeadersPath: ${JSON.stringify(target.publicHeadersPath)},`] : [],
|
|
5415
6996
|
// the native backend supplies dependency module maps without their
|
|
@@ -5453,8 +7034,8 @@ function emitSwiftPackageManifest(args) {
|
|
|
5453
7034
|
` .target(name: ${JSON.stringify(group.name)},`,
|
|
5454
7035
|
` dependencies: ${JSON.stringify(native.mixed ? [] : [name2])},`,
|
|
5455
7036
|
` path: ${JSON.stringify(native.clang || native.mixed ? "." : native.path)},`,
|
|
5456
|
-
` sources: ${JSON.stringify(native.clang || native.mixed ? group.sources.map((source) =>
|
|
5457
|
-
` publicHeadersPath: ${JSON.stringify(native.clang ?
|
|
7037
|
+
` sources: ${JSON.stringify(native.clang || native.mixed ? group.sources.map((source) => path14.posix.join(native.path, source)) : group.sources)},`,
|
|
7038
|
+
` publicHeadersPath: ${JSON.stringify(native.clang ? path14.posix.dirname(native.clang.modulemap) : native.implementationHeaders ?? "include")},`,
|
|
5458
7039
|
` cSettings: [${macroSettings(owner?.cDefines)} .unsafeFlags(${JSON.stringify([...nativeFlags, ...group.flags])})],`,
|
|
5459
7040
|
` cxxSettings: [${macroSettings(owner?.cxxDefines)} .unsafeFlags(${JSON.stringify(["-fno-cxx-modules", ...cxxFlagsFor(nativeFlags), "-I", native.includeDirectory, "-I", args.headerDirectory, ...group.cxxFlags])})]),`
|
|
5460
7041
|
]) : [];
|
|
@@ -5469,8 +7050,8 @@ function syncSwiftTree(base, files) {
|
|
|
5469
7050
|
mkdirSync2(base, { recursive: true });
|
|
5470
7051
|
const walk = (dir) => {
|
|
5471
7052
|
for (const entry of readdirSync5(dir, { withFileTypes: true })) {
|
|
5472
|
-
const full =
|
|
5473
|
-
if (dir === base && (entry.name === ".build" || entry.name.startsWith(".peach-modules-") || entry.name === SWIFT_LINK_STAMP
|
|
7053
|
+
const full = path14.join(dir, entry.name);
|
|
7054
|
+
if (dir === base && (entry.name === ".build" || entry.name.startsWith(".peach-modules-") || entry.name === SWIFT_LINK_STAMP))
|
|
5474
7055
|
continue;
|
|
5475
7056
|
if (entry.isDirectory()) walk(full);
|
|
5476
7057
|
else if (!files.has(full)) rmSync3(full, { force: true });
|
|
@@ -5480,14 +7061,14 @@ function syncSwiftTree(base, files) {
|
|
|
5480
7061
|
for (const [full, contents] of files) {
|
|
5481
7062
|
if (existsSync2(full) && (typeof contents === "string" ? readFileSync7(full, "utf8") === contents : readFileSync7(full).equals(contents)))
|
|
5482
7063
|
continue;
|
|
5483
|
-
mkdirSync2(
|
|
7064
|
+
mkdirSync2(path14.dirname(full), { recursive: true });
|
|
5484
7065
|
writeFileSync3(full, contents);
|
|
5485
7066
|
}
|
|
5486
7067
|
}
|
|
5487
7068
|
var DIRECTIVE = /^[ \t]*#(?:if|elseif)\b/;
|
|
5488
7069
|
var OS_IOS = /\b(?:os\(\s*iOS\s*\)|targetEnvironment\(\s*simulator\s*\))/g;
|
|
5489
7070
|
var DELEGATE_CLASS = /^class\s+[A-Za-z_]\w*\s*(?:<[^>{]*>)?\s*:[^{]*\b(?:UIApplicationDelegate|UISceneDelegate|UIWindowSceneDelegate)\b[^{]*\{/;
|
|
5490
|
-
var REUSABLE_INIT = /^override(?=\s+init\s*\(\s*(?:style\s*:[^,)]*,\s*reuseIdentifier|reuseIdentifier)\s*:)/;
|
|
7071
|
+
var REUSABLE_INIT = /^override(?=\s+(?:(?:public|open|internal)\s+)?init\s*\(\s*(?:style\s*:[^,)]*,\s*reuseIdentifier|reuseIdentifier)\s*:)/;
|
|
5491
7072
|
var REUSABLE_VIEW_BASES = [
|
|
5492
7073
|
"UICollectionReusableView",
|
|
5493
7074
|
"UICollectionViewCell",
|
|
@@ -5643,34 +7224,12 @@ function swiftCodeMask(source) {
|
|
|
5643
7224
|
return chars.join("");
|
|
5644
7225
|
}
|
|
5645
7226
|
var FOUNDATION_NETWORKING_TYPES = /* @__PURE__ */ new Set([
|
|
5646
|
-
"CachedURLResponse",
|
|
5647
|
-
"HTTPCookieStorage",
|
|
5648
|
-
"NSMutableURLRequest",
|
|
5649
7227
|
"NSURLConnection",
|
|
5650
7228
|
"NSURLConnectionDataDelegate",
|
|
5651
7229
|
"NSURLConnectionDelegate",
|
|
5652
7230
|
"NSURLConnectionDownloadDelegate",
|
|
5653
|
-
"URLCache",
|
|
5654
|
-
"URLCredentialStorage",
|
|
5655
7231
|
"URLProtocol",
|
|
5656
|
-
"URLProtocolClient"
|
|
5657
|
-
"URLRequest",
|
|
5658
|
-
"URLSession",
|
|
5659
|
-
"URLSessionConfiguration",
|
|
5660
|
-
"URLSessionDataDelegate",
|
|
5661
|
-
"URLSessionDataTask",
|
|
5662
|
-
"URLSessionDelegate",
|
|
5663
|
-
"URLSessionDownloadDelegate",
|
|
5664
|
-
"URLSessionDownloadTask",
|
|
5665
|
-
"URLSessionStreamDelegate",
|
|
5666
|
-
"URLSessionStreamTask",
|
|
5667
|
-
"URLSessionTask",
|
|
5668
|
-
"URLSessionTaskDelegate",
|
|
5669
|
-
"URLSessionTaskMetrics",
|
|
5670
|
-
"URLSessionTaskTransactionMetrics",
|
|
5671
|
-
"URLSessionUploadTask",
|
|
5672
|
-
"URLSessionWebSocketDelegate",
|
|
5673
|
-
"URLSessionWebSocketTask"
|
|
7232
|
+
"URLProtocolClient"
|
|
5674
7233
|
]);
|
|
5675
7234
|
var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
|
|
5676
7235
|
"AsyncCharacterSequence",
|
|
@@ -5696,6 +7255,7 @@ var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
|
|
|
5696
7255
|
"NSCollectionChangeType",
|
|
5697
7256
|
"NSConditionLock",
|
|
5698
7257
|
"NSDataDetector",
|
|
7258
|
+
"NSErrorPointer",
|
|
5699
7259
|
"NSException",
|
|
5700
7260
|
"NSExtensionContext",
|
|
5701
7261
|
"NSExtensionItem",
|
|
@@ -5787,9 +7347,7 @@ var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
|
|
|
5787
7347
|
"URLUbiquitousSharedItemPermissions",
|
|
5788
7348
|
"URLUbiquitousSharedItemRole",
|
|
5789
7349
|
"UndoManager",
|
|
5790
|
-
"ValueTransformer"
|
|
5791
|
-
"XMLParser",
|
|
5792
|
-
"XMLParserDelegate"
|
|
7350
|
+
"ValueTransformer"
|
|
5793
7351
|
]);
|
|
5794
7352
|
var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
5795
7353
|
"CFBridgingRetain",
|
|
@@ -6158,7 +7716,6 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
6158
7716
|
"NSUnicodeStringEncoding",
|
|
6159
7717
|
"NSUserActivityErrorMaximum",
|
|
6160
7718
|
"NSUserActivityErrorMinimum",
|
|
6161
|
-
"NSUserActivityTypeBrowsingWeb",
|
|
6162
7719
|
"NSValidationErrorMaximum",
|
|
6163
7720
|
"NSValidationErrorMinimum",
|
|
6164
7721
|
"NSWindows95OperatingSystem",
|
|
@@ -6324,6 +7881,15 @@ var CORE_FOUNDATION_HANDLE_IMPORTS = [
|
|
|
6324
7881
|
"import typealias CoreFoundation.CFTypeRef",
|
|
6325
7882
|
"import CoreGraphics"
|
|
6326
7883
|
]).join("; ");
|
|
7884
|
+
function foundationOwnerOf(name2) {
|
|
7885
|
+
if (name2 === "NSClassFromString" || name2 === "NSKeyValueChange" || name2 === "NSKeyValueObservedChange" || name2 === "NSKeyValueObservation")
|
|
7886
|
+
return "PeachObjC";
|
|
7887
|
+
if (name2 === "DispatchData") return "Dispatch";
|
|
7888
|
+
if (FOUNDATION_NETWORKING_TYPES.has(name2)) return "FoundationNetworking";
|
|
7889
|
+
if (FOUNDATION_OVERLAY_TYPES.has(name2) || FOUNDATION_OVERLAY_GLOBALS.has(name2) || CORE_FOUNDATION_OVERLAY_GLOBALS.has(name2))
|
|
7890
|
+
return "PeachFoundation";
|
|
7891
|
+
return void 0;
|
|
7892
|
+
}
|
|
6327
7893
|
function swiftSourceAsIOS(source) {
|
|
6328
7894
|
const { lineStarts, tokens } = swiftCodeScan(source);
|
|
6329
7895
|
let offset = 0;
|
|
@@ -6379,16 +7945,7 @@ function swiftSourceAsIOS(source) {
|
|
|
6379
7945
|
}
|
|
6380
7946
|
const foundationMember = /^Foundation\s*\.\s*(?:`([A-Za-z_]\w*)`|([A-Za-z_]\w*)\b)/.exec(rest);
|
|
6381
7947
|
const foundationName = foundationMember?.[1] ?? foundationMember?.[2];
|
|
6382
|
-
|
|
6383
|
-
if (foundationName !== void 0) {
|
|
6384
|
-
if (foundationName === "NSClassFromString" || foundationName === "NSKeyValueChange" || foundationName === "NSKeyValueObservedChange" || foundationName === "NSKeyValueObservation")
|
|
6385
|
-
foundationOwner = "PeachObjC";
|
|
6386
|
-
else if (foundationName === "DispatchData") foundationOwner = "Dispatch";
|
|
6387
|
-
else if (FOUNDATION_NETWORKING_TYPES.has(foundationName))
|
|
6388
|
-
foundationOwner = "FoundationNetworking";
|
|
6389
|
-
else if (FOUNDATION_OVERLAY_TYPES.has(foundationName) || FOUNDATION_OVERLAY_GLOBALS.has(foundationName) || CORE_FOUNDATION_OVERLAY_GLOBALS.has(foundationName))
|
|
6390
|
-
foundationOwner = "PeachFoundation";
|
|
6391
|
-
}
|
|
7948
|
+
const foundationOwner = foundationName === void 0 ? void 0 : foundationOwnerOf(foundationName);
|
|
6392
7949
|
if (foundationOwner !== void 0) {
|
|
6393
7950
|
out += conditioned.slice(copied, at) + foundationOwner;
|
|
6394
7951
|
copied = at + "Foundation".length;
|
|
@@ -6500,7 +8057,7 @@ function swiftApplicationEntry(file, source) {
|
|
|
6500
8057
|
else if (source[at] === "}") depth--;
|
|
6501
8058
|
else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
|
|
6502
8059
|
return true;
|
|
6503
|
-
else if (depth === 0 &&
|
|
8060
|
+
else if (depth === 0 && path14.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
|
|
6504
8061
|
return true;
|
|
6505
8062
|
}
|
|
6506
8063
|
return false;
|
|
@@ -6861,14 +8418,14 @@ function prepareSwiftDependency(source, destination) {
|
|
|
6861
8418
|
for (const entry of readdirSync5(from, { withFileTypes: true })) {
|
|
6862
8419
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
6863
8420
|
continue;
|
|
6864
|
-
const file =
|
|
8421
|
+
const file = path14.join(from, entry.name);
|
|
6865
8422
|
if (entry.isDirectory()) gather(file);
|
|
6866
8423
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
6867
|
-
origins[
|
|
8424
|
+
origins[path14.relative(source, file)] = readFileSync7(file, "utf8");
|
|
6868
8425
|
}
|
|
6869
8426
|
};
|
|
6870
8427
|
gather(source);
|
|
6871
|
-
const manifest =
|
|
8428
|
+
const manifest = path14.join(source, "Package.swift");
|
|
6872
8429
|
const targets = existsSync2(manifest) ? swiftManifestTargets(readFileSync7(manifest, "utf8")) : [];
|
|
6873
8430
|
const compiled = compiledSwiftSources(origins, targets);
|
|
6874
8431
|
const copy = (from, to) => {
|
|
@@ -6876,31 +8433,31 @@ function prepareSwiftDependency(source, destination) {
|
|
|
6876
8433
|
for (const entry of readdirSync5(from, { withFileTypes: true })) {
|
|
6877
8434
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
6878
8435
|
continue;
|
|
6879
|
-
const file =
|
|
6880
|
-
const target =
|
|
8436
|
+
const file = path14.join(from, entry.name);
|
|
8437
|
+
const target = path14.join(to, entry.name);
|
|
6881
8438
|
if (entry.isDirectory()) copy(file, target);
|
|
6882
8439
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
6883
|
-
writeFileSync3(target, compiled.get(
|
|
8440
|
+
writeFileSync3(target, compiled.get(path14.relative(source, file)));
|
|
6884
8441
|
else cpSync(file, target, { verbatimSymlinks: true });
|
|
6885
8442
|
}
|
|
6886
8443
|
};
|
|
6887
8444
|
copy(source, destination);
|
|
6888
8445
|
}
|
|
6889
8446
|
var HIDDEN_UNITS = "PeachHiddenUnits";
|
|
6890
|
-
function clangImportModuleMapFlags(settings, layoutRoot, written) {
|
|
8447
|
+
function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
|
|
6891
8448
|
const searched = new Set(settings.headerSearchPaths);
|
|
6892
|
-
const directory =
|
|
8449
|
+
const directory = path14.join(layoutRoot, ".build", "peach-clang-modulemaps");
|
|
6893
8450
|
return (settings.moduleMaps ?? []).flatMap((map) => {
|
|
6894
|
-
const headers =
|
|
8451
|
+
const headers = path14.join(layoutRoot, map.headers);
|
|
6895
8452
|
if (!existsSync2(headers)) return [];
|
|
6896
|
-
const published =
|
|
8453
|
+
const published = path14.join(headers, "module.modulemap");
|
|
6897
8454
|
if (searched.has(map.headers) && existsSync2(published)) return [];
|
|
6898
8455
|
if (!searched.has(map.headers) && existsSync2(published))
|
|
6899
8456
|
return [`-fmodule-map-file=${published}`];
|
|
6900
8457
|
const cached = written.get(headers);
|
|
6901
8458
|
if (cached) return [cached];
|
|
6902
8459
|
mkdirSync2(directory, { recursive: true });
|
|
6903
|
-
const output =
|
|
8460
|
+
const output = path14.join(directory, `module-${written.size}.modulemap`);
|
|
6904
8461
|
writeFileSync3(
|
|
6905
8462
|
output,
|
|
6906
8463
|
swiftPackageClangModuleMap(swiftTargetModuleName(map.module), {
|
|
@@ -6908,6 +8465,7 @@ function clangImportModuleMapFlags(settings, layoutRoot, written) {
|
|
|
6908
8465
|
path: headers
|
|
6909
8466
|
})
|
|
6910
8467
|
);
|
|
8468
|
+
generated.push({ output, module: swiftTargetModuleName(map.module), published });
|
|
6911
8469
|
const flag = `-fmodule-map-file=${output}`;
|
|
6912
8470
|
written.set(headers, flag);
|
|
6913
8471
|
return [flag];
|
|
@@ -6936,14 +8494,19 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
6936
8494
|
const targets = distribution && compileTargets(input).length === 0 ? [
|
|
6937
8495
|
{
|
|
6938
8496
|
name: "App",
|
|
6939
|
-
path:
|
|
8497
|
+
path: path14.relative(layout.root, layout.sources),
|
|
6940
8498
|
executable: true,
|
|
6941
8499
|
languageMode: 5,
|
|
6942
8500
|
mainActorIsolation: false,
|
|
6943
8501
|
resources: false
|
|
6944
8502
|
}
|
|
6945
8503
|
] : compileTargets(input);
|
|
6946
|
-
const distributionExcludes = distribution ?
|
|
8504
|
+
const distributionExcludes = distribution ? /* @__PURE__ */ new Set([
|
|
8505
|
+
...swiftSystemLibraryExclusions(input.files, targets, distribution.modules),
|
|
8506
|
+
...distribution.modules.filter(
|
|
8507
|
+
(name2) => OPTIONAL_FRAMEWORKS.has(name2) && targets.some((target) => target.name === name2)
|
|
8508
|
+
)
|
|
8509
|
+
]) : void 0;
|
|
6947
8510
|
const files = /* @__PURE__ */ new Map();
|
|
6948
8511
|
const native = /* @__PURE__ */ new Map();
|
|
6949
8512
|
const targetFailures = [];
|
|
@@ -6959,26 +8522,34 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
6959
8522
|
if (target) swiftTargets.add(target.name);
|
|
6960
8523
|
}
|
|
6961
8524
|
const importedModules = /* @__PURE__ */ new Set();
|
|
8525
|
+
const swiftImportedModules = /* @__PURE__ */ new Set();
|
|
8526
|
+
const clangImportedModules = /* @__PURE__ */ new Set();
|
|
6962
8527
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
6963
8528
|
if (file.endsWith(".swift"))
|
|
6964
|
-
for (const name2 of swiftImportNames(contents))
|
|
8529
|
+
for (const name2 of swiftImportNames(contents)) {
|
|
8530
|
+
importedModules.add(name2);
|
|
8531
|
+
swiftImportedModules.add(name2);
|
|
8532
|
+
}
|
|
6965
8533
|
else if (SWIFT_NATIVE_SOURCE_EXTENSIONS.some(
|
|
6966
8534
|
(extension) => extension !== ".modulemap" && file.endsWith(extension)
|
|
6967
8535
|
))
|
|
6968
|
-
for (const name2 of clangImportNames(contents))
|
|
8536
|
+
for (const name2 of clangImportNames(contents)) {
|
|
8537
|
+
importedModules.add(name2);
|
|
8538
|
+
clangImportedModules.add(name2);
|
|
8539
|
+
}
|
|
6969
8540
|
}
|
|
6970
|
-
const headerDirectory =
|
|
8541
|
+
const headerDirectory = path14.join(layout.root, ".build", "peach-cxx-headers");
|
|
6971
8542
|
let checkedToolchain;
|
|
6972
8543
|
const nativeToolchain = () => {
|
|
6973
8544
|
if (checkedToolchain) return checkedToolchain;
|
|
6974
|
-
const pin = distribution ?? JSON.parse(readFileSync7(
|
|
8545
|
+
const pin = distribution ?? JSON.parse(readFileSync7(path14.join(moduleRoot, "toolchain.json"), "utf8"));
|
|
6975
8546
|
checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
|
|
6976
8547
|
return checkedToolchain;
|
|
6977
8548
|
};
|
|
6978
8549
|
const deploymentTarget = (name2) => input.nativeTargets?.find((value) => value.name === name2)?.deploymentTarget ?? targets.find((value) => value.name === name2)?.iosDeploymentTarget ?? null;
|
|
6979
8550
|
const targetStagedFiles = /* @__PURE__ */ new Map();
|
|
6980
8551
|
const stageTargetFile = (target, file, contents, options) => {
|
|
6981
|
-
const relative =
|
|
8552
|
+
const relative = path14.relative(layout.root, file).split(path14.sep).join(path14.posix.sep);
|
|
6982
8553
|
const prior = files.has(file) ? files.get(file) : Object.hasOwn(input.files, relative) ? input.files[relative] : void 0;
|
|
6983
8554
|
if (!options?.allowExisting && prior !== void 0)
|
|
6984
8555
|
throw new Error(`target ${target} already contains generated output ${relative}`);
|
|
@@ -7007,7 +8578,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7007
8578
|
targetStagedFiles.delete(target.name);
|
|
7008
8579
|
if (entries.some(([file]) => isSwiftNativeTranslationUnit(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name))) {
|
|
7009
8580
|
if (!swift) {
|
|
7010
|
-
const unprepared =
|
|
8581
|
+
const unprepared = path14.join(
|
|
7011
8582
|
layout.root,
|
|
7012
8583
|
target.path,
|
|
7013
8584
|
"PeachUnprepared.generated.swift"
|
|
@@ -7022,7 +8593,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7022
8593
|
native.set(target.name, {
|
|
7023
8594
|
mixed: true,
|
|
7024
8595
|
path: target.path,
|
|
7025
|
-
includeDirectory:
|
|
8596
|
+
includeDirectory: path14.join(layout.root, target.path, "include"),
|
|
7026
8597
|
sources: [],
|
|
7027
8598
|
lateSources: [],
|
|
7028
8599
|
exclude: entries.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length))
|
|
@@ -7031,30 +8602,33 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7031
8602
|
};
|
|
7032
8603
|
for (const settings of input.nativeTargets ?? []) {
|
|
7033
8604
|
for (const file of settings.headers) {
|
|
7034
|
-
const
|
|
8605
|
+
const interfaceModule = /(?:^|\/)(\w+)\.framework\/Headers\/\1-Swift\.h$/.exec(
|
|
8606
|
+
file
|
|
8607
|
+
)?.[1];
|
|
8608
|
+
const contents = interfaceModule && swiftModuleInterface(moduleRoot, interfaceModule)?.header || input.files[file];
|
|
7035
8609
|
if (contents === void 0)
|
|
7036
8610
|
throw new Error(`missing original Objective-C header ${file}`);
|
|
7037
|
-
const destination =
|
|
7038
|
-
mkdirSync2(
|
|
8611
|
+
const destination = path14.join(layout.root, file);
|
|
8612
|
+
mkdirSync2(path14.dirname(destination), { recursive: true });
|
|
7039
8613
|
writeFileSync3(destination, contents);
|
|
7040
8614
|
files.set(destination, contents);
|
|
7041
8615
|
}
|
|
7042
8616
|
if (!settings.flattensPublicHeaders) continue;
|
|
7043
8617
|
for (const header of settings.publicHeaders) {
|
|
7044
|
-
const destination =
|
|
8618
|
+
const destination = path14.join(headerDirectory, settings.name, path14.basename(header));
|
|
7045
8619
|
if (files.has(destination))
|
|
7046
8620
|
throw new Error(`duplicate product header ${destination}`);
|
|
7047
|
-
const contents = `#import ${JSON.stringify(
|
|
8621
|
+
const contents = `#import ${JSON.stringify(path14.join(layout.root, header))}
|
|
7048
8622
|
`;
|
|
7049
8623
|
files.set(destination, contents);
|
|
7050
|
-
mkdirSync2(
|
|
8624
|
+
mkdirSync2(path14.dirname(destination), { recursive: true });
|
|
7051
8625
|
writeFileSync3(destination, contents);
|
|
7052
8626
|
}
|
|
7053
8627
|
}
|
|
7054
8628
|
const nativeTargets = input.nativeTargets ?? [];
|
|
7055
|
-
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ?
|
|
8629
|
+
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path14.join(layout.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
|
|
7056
8630
|
const headerSearch = writeXcodeHeaderSearch(
|
|
7057
|
-
|
|
8631
|
+
path14.join(layout.root, ".build", "peach-xcode-headers"),
|
|
7058
8632
|
nativeTargets.map((settings) => ({
|
|
7059
8633
|
headerMaps: settings.headerMaps.map((map) => ({
|
|
7060
8634
|
flag: map.flag,
|
|
@@ -7065,16 +8639,17 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7065
8639
|
})),
|
|
7066
8640
|
productHeaders: Object.fromEntries(
|
|
7067
8641
|
Object.entries(settings.productHeaders).map(([product, file]) => [
|
|
7068
|
-
|
|
7069
|
-
|
|
8642
|
+
path14.join(layout.root, product),
|
|
8643
|
+
path14.join(layout.root, file)
|
|
7070
8644
|
])
|
|
7071
8645
|
),
|
|
7072
8646
|
userHeaderSearchPaths: settings.userHeaderSearchPaths.map(
|
|
7073
|
-
(directory) =>
|
|
8647
|
+
(directory) => path14.join(layout.root, directory)
|
|
7074
8648
|
)
|
|
7075
8649
|
}))
|
|
7076
8650
|
);
|
|
7077
8651
|
const importModuleMaps = /* @__PURE__ */ new Map();
|
|
8652
|
+
const generatedModuleMaps = [];
|
|
7078
8653
|
for (const target of targets) {
|
|
7079
8654
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
7080
8655
|
const entries = targetEntries(target);
|
|
@@ -7094,7 +8669,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7094
8669
|
if (producer && targets.some((value) => value.name === producer))
|
|
7095
8670
|
producers2.add(producer);
|
|
7096
8671
|
const local = [
|
|
7097
|
-
|
|
8672
|
+
path14.posix.join(path14.posix.dirname(file), include2),
|
|
7098
8673
|
`${includes}${include2}`
|
|
7099
8674
|
].find((candidate) => input.files[candidate] !== void 0);
|
|
7100
8675
|
if (local) {
|
|
@@ -7128,12 +8703,12 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7128
8703
|
const headers = settings.headers;
|
|
7129
8704
|
const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : entries.some(([file]) => file.endsWith(".swift")) || importedModules.has(swiftTargetModuleName(target.name)) ? settings.publicHeaders : [];
|
|
7130
8705
|
for (const file of headers) {
|
|
7131
|
-
const destination =
|
|
7132
|
-
mkdirSync2(
|
|
8706
|
+
const destination = path14.join(layout.root, file);
|
|
8707
|
+
mkdirSync2(path14.dirname(destination), { recursive: true });
|
|
7133
8708
|
writeFileSync3(destination, input.files[file]);
|
|
7134
8709
|
}
|
|
7135
8710
|
const search = [.../* @__PURE__ */ new Set([...settings?.headerSearchPaths ?? []])].flatMap(
|
|
7136
|
-
(dir) => ["-I",
|
|
8711
|
+
(dir) => ["-I", path14.join(layout.root, dir)]
|
|
7137
8712
|
);
|
|
7138
8713
|
const toolchainBin = nativeToolchain();
|
|
7139
8714
|
const stageFlags = (flags2, sdkInclude2) => flags2.map(
|
|
@@ -7145,7 +8720,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7145
8720
|
...search,
|
|
7146
8721
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
7147
8722
|
"-F",
|
|
7148
|
-
|
|
8723
|
+
path14.join(layout.root, dir)
|
|
7149
8724
|
]),
|
|
7150
8725
|
"-I",
|
|
7151
8726
|
headerDirectory
|
|
@@ -7156,13 +8731,13 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7156
8731
|
const flag = settings.flags[index];
|
|
7157
8732
|
if (flag === "-I" || flag === "-iquote") {
|
|
7158
8733
|
const directory = settings.flags[index + 1];
|
|
7159
|
-
if (directory === void 0 || !
|
|
8734
|
+
if (directory === void 0 || !path14.isAbsolute(directory)) {
|
|
7160
8735
|
index++;
|
|
7161
8736
|
continue;
|
|
7162
8737
|
}
|
|
7163
8738
|
}
|
|
7164
8739
|
const joined = /^-(?:I|iquote)(.+)$/.exec(flag);
|
|
7165
|
-
if (joined && !
|
|
8740
|
+
if (joined && !path14.isAbsolute(joined[1])) continue;
|
|
7166
8741
|
kept.push(flag);
|
|
7167
8742
|
}
|
|
7168
8743
|
return [
|
|
@@ -7171,18 +8746,18 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7171
8746
|
...search,
|
|
7172
8747
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
7173
8748
|
"-F",
|
|
7174
|
-
|
|
8749
|
+
path14.join(layout.root, dir)
|
|
7175
8750
|
]),
|
|
7176
8751
|
"-I",
|
|
7177
8752
|
headerDirectory
|
|
7178
8753
|
];
|
|
7179
8754
|
})();
|
|
7180
|
-
const sdkInclude =
|
|
8755
|
+
const sdkInclude = path14.join(
|
|
7181
8756
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
7182
8757
|
"darwin/usr/include"
|
|
7183
8758
|
);
|
|
7184
8759
|
const flags = stageFlags(originalFlags, sdkInclude);
|
|
7185
|
-
const prefixHeader = settings?.prefixHeader ? ["-include",
|
|
8760
|
+
const prefixHeader = settings?.prefixHeader ? ["-include", path14.join(layout.root, settings.prefixHeader)] : [];
|
|
7186
8761
|
const bundleName = entries.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
|
|
7187
8762
|
target: target.name,
|
|
7188
8763
|
path: target.path,
|
|
@@ -7193,7 +8768,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7193
8768
|
bundles: input.resourceBundles
|
|
7194
8769
|
});
|
|
7195
8770
|
const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
|
|
7196
|
-
const accessorHeader =
|
|
8771
|
+
const accessorHeader = path14.join(
|
|
7197
8772
|
layout.root,
|
|
7198
8773
|
target.path,
|
|
7199
8774
|
OBJC_RESOURCE_ACCESSOR_HEADER
|
|
@@ -7204,7 +8779,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7204
8779
|
const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
|
|
7205
8780
|
const unitSource = (file) => {
|
|
7206
8781
|
const relative = file.slice(prefix.length);
|
|
7207
|
-
return relative.split("/").some((part) => part.startsWith(".")) ?
|
|
8782
|
+
return relative.split("/").some((part) => part.startsWith(".")) ? path14.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
|
|
7208
8783
|
};
|
|
7209
8784
|
const accessorFlags = accessor ? ["-include", accessorHeader] : [];
|
|
7210
8785
|
const nativeC = !entries.some(([file]) => file.endsWith(".swift"));
|
|
@@ -7234,20 +8809,20 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7234
8809
|
)
|
|
7235
8810
|
].sort();
|
|
7236
8811
|
const topHeaders = settings.publicHeaders.filter(
|
|
7237
|
-
(file) =>
|
|
8812
|
+
(file) => path14.posix.dirname(file) === headerDir
|
|
7238
8813
|
);
|
|
7239
8814
|
if (input.files[custom] !== void 0) {
|
|
7240
8815
|
swiftpmModuleMap = { path: custom, contents: input.files[custom] };
|
|
7241
8816
|
} else if (input.files[umbrella] !== void 0) {
|
|
7242
8817
|
if (siblingDirs.length > 0)
|
|
7243
8818
|
throw new Error(
|
|
7244
|
-
`target ${target.name} has invalid header layout: umbrella header found at '${
|
|
8819
|
+
`target ${target.name} has invalid header layout: umbrella header found at '${path14.join(layout.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name2) => path14.join(layout.root, headerDir, name2)).join(", ")}; consider removing them`
|
|
7245
8820
|
);
|
|
7246
8821
|
swiftpmModuleMap = {
|
|
7247
8822
|
path: custom,
|
|
7248
8823
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
7249
8824
|
kind: "header",
|
|
7250
|
-
path:
|
|
8825
|
+
path: path14.join(layout.root, umbrella)
|
|
7251
8826
|
})
|
|
7252
8827
|
};
|
|
7253
8828
|
} else if (input.files[nestedUmbrella] !== void 0 && siblingDirs.length === 1 && siblingDirs[0] === moduleName && topHeaders.length === 0) {
|
|
@@ -7255,7 +8830,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7255
8830
|
path: custom,
|
|
7256
8831
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
7257
8832
|
kind: "header",
|
|
7258
|
-
path:
|
|
8833
|
+
path: path14.join(layout.root, nestedUmbrella)
|
|
7259
8834
|
})
|
|
7260
8835
|
};
|
|
7261
8836
|
} else {
|
|
@@ -7263,12 +8838,12 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7263
8838
|
path: custom,
|
|
7264
8839
|
contents: swiftPackageClangModuleMap(moduleName, {
|
|
7265
8840
|
kind: "directory",
|
|
7266
|
-
path:
|
|
8841
|
+
path: path14.join(layout.root, headerDir)
|
|
7267
8842
|
})
|
|
7268
8843
|
};
|
|
7269
8844
|
}
|
|
7270
8845
|
}
|
|
7271
|
-
const modulemap = originalModuleMap?.[0] ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ??
|
|
8846
|
+
const modulemap = originalModuleMap?.[0] ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? path14.posix.join(
|
|
7272
8847
|
".build",
|
|
7273
8848
|
"peach-objc-originals",
|
|
7274
8849
|
target.name,
|
|
@@ -7276,48 +8851,53 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7276
8851
|
);
|
|
7277
8852
|
const moduleContents = originalModuleMap ? input.files[originalModuleMap[1]] : swiftpmModuleMap?.contents ?? packageModuleMap?.[1] ?? swiftObjCModuleMap(
|
|
7278
8853
|
swiftTargetModuleName(target.name),
|
|
7279
|
-
roots2.map((file) =>
|
|
8854
|
+
roots2.map((file) => path14.join(layout.root, file))
|
|
7280
8855
|
);
|
|
7281
8856
|
if (moduleContents === void 0)
|
|
7282
8857
|
throw new Error("missing original module map " + modulemap);
|
|
7283
|
-
stageTargetFile(target.name,
|
|
8858
|
+
stageTargetFile(target.name, path14.join(layout.root, modulemap), moduleContents, {
|
|
7284
8859
|
allowExisting: true
|
|
7285
8860
|
});
|
|
7286
8861
|
const importFlags = [
|
|
7287
8862
|
...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
|
|
7288
|
-
"-fmodule-map-file=" +
|
|
7289
|
-
...clangImportModuleMapFlags(
|
|
8863
|
+
"-fmodule-map-file=" + path14.join(layout.root, modulemap),
|
|
8864
|
+
...clangImportModuleMapFlags(
|
|
8865
|
+
settings,
|
|
8866
|
+
layout.root,
|
|
8867
|
+
importModuleMaps,
|
|
8868
|
+
generatedModuleMaps
|
|
8869
|
+
)
|
|
7290
8870
|
];
|
|
7291
8871
|
const groups = /* @__PURE__ */ new Map();
|
|
7292
8872
|
for (const [file, contents] of nativeUnits) {
|
|
7293
8873
|
const origin = settings?.sourceDirectories[file];
|
|
7294
8874
|
if (origin) {
|
|
7295
|
-
const original =
|
|
7296
|
-
mkdirSync2(
|
|
8875
|
+
const original = path14.join(layout.root, origin, path14.posix.basename(file));
|
|
8876
|
+
mkdirSync2(path14.dirname(original), { recursive: true });
|
|
7297
8877
|
stageTargetFile(target.name, original, contents, { allowExisting: true });
|
|
7298
8878
|
}
|
|
7299
8879
|
const source = unitSource(file);
|
|
7300
8880
|
if (source !== file.slice(prefix.length))
|
|
7301
8881
|
stageTargetFile(
|
|
7302
8882
|
target.name,
|
|
7303
|
-
|
|
8883
|
+
path14.join(layout.root, target.path, source),
|
|
7304
8884
|
contents,
|
|
7305
8885
|
{
|
|
7306
8886
|
allowExisting: true
|
|
7307
8887
|
}
|
|
7308
8888
|
);
|
|
7309
8889
|
const perFile = [
|
|
7310
|
-
...origin ? ["-iquote",
|
|
8890
|
+
...origin ? ["-iquote", path14.join(layout.root, origin)] : [],
|
|
7311
8891
|
...stageFlags(
|
|
7312
8892
|
settings?.fileFlags[file] ?? [],
|
|
7313
|
-
|
|
8893
|
+
path14.join(
|
|
7314
8894
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
7315
8895
|
"darwin/usr/include"
|
|
7316
8896
|
)
|
|
7317
8897
|
)
|
|
7318
8898
|
];
|
|
7319
8899
|
const cxx = /\.(?:cc|cpp|cxx|mm)$/.test(file);
|
|
7320
|
-
const identity =
|
|
8900
|
+
const identity = createHash8("sha256").update(JSON.stringify([cxx, perFile, (consumers.get(file)?.size ?? 0) > 0])).digest("hex").slice(0, 12);
|
|
7321
8901
|
const group = groups.get(identity) ?? {
|
|
7322
8902
|
name: `${target.name}${nativeC ? "Native" : "Swift"}Implementation_${identity}`,
|
|
7323
8903
|
sources: [],
|
|
@@ -7328,7 +8908,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7328
8908
|
...accessorFlags,
|
|
7329
8909
|
...stageFlags(
|
|
7330
8910
|
cxx ? settings.cxxFlags : [],
|
|
7331
|
-
|
|
8911
|
+
path14.join(
|
|
7332
8912
|
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
7333
8913
|
"darwin/usr/include"
|
|
7334
8914
|
)
|
|
@@ -7343,7 +8923,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7343
8923
|
stageTargetFile(target.name, accessorHeader, accessor.header);
|
|
7344
8924
|
stageTargetFile(
|
|
7345
8925
|
target.name,
|
|
7346
|
-
|
|
8926
|
+
path14.join(layout.root, accessorUnit),
|
|
7347
8927
|
accessor.body
|
|
7348
8928
|
);
|
|
7349
8929
|
}
|
|
@@ -7358,7 +8938,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7358
8938
|
].sort();
|
|
7359
8939
|
native.set(target.name, {
|
|
7360
8940
|
path: target.path,
|
|
7361
|
-
includeDirectory:
|
|
8941
|
+
includeDirectory: path14.dirname(path14.join(layout.root, modulemap)),
|
|
7362
8942
|
importFlags,
|
|
7363
8943
|
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
7364
8944
|
lateSources: implementations.flatMap((group) => group.sources),
|
|
@@ -7376,15 +8956,15 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7376
8956
|
});
|
|
7377
8957
|
continue;
|
|
7378
8958
|
}
|
|
7379
|
-
const implementationHeaders =
|
|
8959
|
+
const implementationHeaders = path14.posix.join(
|
|
7380
8960
|
".build",
|
|
7381
8961
|
"peach-objc-implementations",
|
|
7382
8962
|
target.name
|
|
7383
8963
|
);
|
|
7384
|
-
const include2 =
|
|
8964
|
+
const include2 = path14.join(layout.root, implementationHeaders);
|
|
7385
8965
|
stageTargetFile(
|
|
7386
8966
|
target.name,
|
|
7387
|
-
|
|
8967
|
+
path14.join(include2, "module.modulemap"),
|
|
7388
8968
|
`module ${target.name}ImplementationDeclarations { export * }
|
|
7389
8969
|
`
|
|
7390
8970
|
);
|
|
@@ -7395,7 +8975,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7395
8975
|
implementationHeaders,
|
|
7396
8976
|
importFlags,
|
|
7397
8977
|
swiftFlags: [
|
|
7398
|
-
...settings.bridgingHeader ? ["-import-objc-header",
|
|
8978
|
+
...settings.bridgingHeader ? ["-import-objc-header", path14.join(layout.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
|
|
7399
8979
|
...importFlags.flatMap((flag) => ["-Xcc", flag])
|
|
7400
8980
|
],
|
|
7401
8981
|
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
@@ -7425,7 +9005,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7425
9005
|
}
|
|
7426
9006
|
native.set(target.name, {
|
|
7427
9007
|
path: target.path,
|
|
7428
|
-
includeDirectory:
|
|
9008
|
+
includeDirectory: path14.join(layout.root, includes),
|
|
7429
9009
|
sources: units.map(([file]) => file.slice(prefix.length)),
|
|
7430
9010
|
lateSources: late.map(([file]) => file.slice(prefix.length)),
|
|
7431
9011
|
...late.length > 0 ? {
|
|
@@ -7443,7 +9023,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7443
9023
|
([file]) => file.startsWith(includes) && /\.(?:h|hpp|hh|hxx)$/.test(file) && consumers.get(file).size === 0
|
|
7444
9024
|
);
|
|
7445
9025
|
files.set(
|
|
7446
|
-
|
|
9026
|
+
path14.join(layout.root, includes, "module.modulemap"),
|
|
7447
9027
|
[
|
|
7448
9028
|
`module ${target.name} {`,
|
|
7449
9029
|
...roots.map(
|
|
@@ -7455,16 +9035,26 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7455
9035
|
].join("\n")
|
|
7456
9036
|
);
|
|
7457
9037
|
}
|
|
9038
|
+
for (const map of generatedModuleMaps)
|
|
9039
|
+
if (files.has(map.published) || Object.hasOwn(
|
|
9040
|
+
input.files,
|
|
9041
|
+
path14.relative(layout.root, map.published).split(path14.sep).join(path14.posix.sep)
|
|
9042
|
+
))
|
|
9043
|
+
writeFileSync3(
|
|
9044
|
+
map.output,
|
|
9045
|
+
`extern module ${map.module} ${JSON.stringify(map.published)}
|
|
9046
|
+
`
|
|
9047
|
+
);
|
|
7458
9048
|
if (native.size > 0) mkdirSync2(headerDirectory, { recursive: true });
|
|
7459
9049
|
const nativeHeaderFlags = [];
|
|
7460
9050
|
for (const name2 of new Set(
|
|
7461
9051
|
[...native.values()].flatMap((value) => value.late?.producers ?? [])
|
|
7462
9052
|
)) {
|
|
7463
9053
|
files.set(
|
|
7464
|
-
|
|
9054
|
+
path14.join(headerDirectory, name2, name2 + "-Swift.h"),
|
|
7465
9055
|
'#include "../' + name2 + '-Swift.h"\n'
|
|
7466
9056
|
);
|
|
7467
|
-
const modulemap =
|
|
9057
|
+
const modulemap = path14.join(
|
|
7468
9058
|
layout.root,
|
|
7469
9059
|
".build",
|
|
7470
9060
|
"peach-objc-swift-headers",
|
|
@@ -7474,19 +9064,19 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7474
9064
|
files.set(
|
|
7475
9065
|
modulemap,
|
|
7476
9066
|
swiftObjCModuleMap(swiftTargetModuleName(name2), [
|
|
7477
|
-
...(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) =>
|
|
7478
|
-
|
|
9067
|
+
...(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) => path14.join(layout.root, header)),
|
|
9068
|
+
path14.join(headerDirectory, name2 + "-Swift.h")
|
|
7479
9069
|
])
|
|
7480
9070
|
);
|
|
7481
9071
|
nativeHeaderFlags.push("-fmodule-map-file=" + modulemap);
|
|
7482
9072
|
}
|
|
7483
|
-
const modulePlan =
|
|
9073
|
+
const modulePlan = createHash8("sha256").update(
|
|
7484
9074
|
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
7485
9075
|
);
|
|
7486
9076
|
if (!distribution) {
|
|
7487
|
-
modulePlan.update(readFileSync7(
|
|
9077
|
+
modulePlan.update(readFileSync7(path14.join(moduleRoot, "Package.swift")));
|
|
7488
9078
|
}
|
|
7489
|
-
const resourcePlan =
|
|
9079
|
+
const resourcePlan = createHash8("sha256").update(
|
|
7490
9080
|
JSON.stringify(
|
|
7491
9081
|
resourceTargets.filter((target) => target.resources).map((target) => [
|
|
7492
9082
|
target.name,
|
|
@@ -7531,7 +9121,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7531
9121
|
`;
|
|
7532
9122
|
} else if (mains.length === 0) {
|
|
7533
9123
|
const procedural = entries.filter(
|
|
7534
|
-
([file, source]) =>
|
|
9124
|
+
([file, source]) => path14.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
|
|
7535
9125
|
);
|
|
7536
9126
|
const wrapped = procedural.length === 1 ? wrapUIApplicationMainEntry(procedural[0][1]) : null;
|
|
7537
9127
|
if (!wrapped)
|
|
@@ -7560,7 +9150,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7560
9150
|
exclude: []
|
|
7561
9151
|
});
|
|
7562
9152
|
files.set(
|
|
7563
|
-
|
|
9153
|
+
path14.join(layout.root, `PeachApplication/${name2}/Entry.swift`),
|
|
7564
9154
|
`import ${swiftTargetModuleName(target.name)}
|
|
7565
9155
|
@main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }
|
|
7566
9156
|
`
|
|
@@ -7570,7 +9160,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7570
9160
|
const nativeFlags = native.size > 0 ? /* @__PURE__ */ new Map() : void 0;
|
|
7571
9161
|
if (nativeFlags) {
|
|
7572
9162
|
const toolchainBin = nativeToolchain();
|
|
7573
|
-
const headers =
|
|
9163
|
+
const headers = path14.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
|
|
7574
9164
|
for (const target of targets) {
|
|
7575
9165
|
const version = deploymentTarget(target.name);
|
|
7576
9166
|
const minimum = iosDeploymentMinimum(version);
|
|
@@ -7601,10 +9191,10 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7601
9191
|
if (targets.length === 0 && !prebuilt) {
|
|
7602
9192
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
7603
9193
|
if (file === "Package.swift") continue;
|
|
7604
|
-
files.set(
|
|
9194
|
+
files.set(path14.join(layout.sources, file), compiled.get(file) ?? contents);
|
|
7605
9195
|
}
|
|
7606
9196
|
let manifest = readFileSync7(
|
|
7607
|
-
|
|
9197
|
+
path14.join(moduleRoot, "scripts/contrast-app-Package.swift"),
|
|
7608
9198
|
"utf8"
|
|
7609
9199
|
).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
|
|
7610
9200
|
const reactor = ` ${REACTOR_FLAG}`;
|
|
@@ -7648,25 +9238,25 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7648
9238
|
manifest = manifest.replace(anchor, `${anchor}
|
|
7649
9239
|
${SPRITEKIT_PRODUCT},`);
|
|
7650
9240
|
}
|
|
7651
|
-
files.set(
|
|
9241
|
+
files.set(path14.join(layout.root, "Package.swift"), manifest + moduleFiles);
|
|
7652
9242
|
} else {
|
|
7653
9243
|
const base = layout.multi ? layout.root : layout.sources;
|
|
7654
9244
|
const libraries = /* @__PURE__ */ new Map();
|
|
7655
9245
|
for (const [target, data] of Object.entries(input.libraries ?? {})) {
|
|
7656
9246
|
const bytes = Buffer.from(data, "base64");
|
|
7657
|
-
const digest =
|
|
7658
|
-
const file =
|
|
9247
|
+
const digest = createHash8("sha256").update(bytes).digest("hex");
|
|
9248
|
+
const file = path14.join(layout.root, ".peach-libraries", `lib${target}-${digest}.a`);
|
|
7659
9249
|
files.set(file, bytes);
|
|
7660
9250
|
libraries.set(target, file);
|
|
7661
9251
|
}
|
|
7662
9252
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
7663
9253
|
if (file === "Package.swift") continue;
|
|
7664
|
-
files.set(
|
|
9254
|
+
files.set(path14.join(base, file), compiled.get(file) ?? contents);
|
|
7665
9255
|
}
|
|
7666
9256
|
const manifestTargets = targets.length > 0 ? targets : [
|
|
7667
9257
|
{
|
|
7668
9258
|
name: "App",
|
|
7669
|
-
path:
|
|
9259
|
+
path: path14.relative(layout.root, layout.sources).split(path14.sep).join("/"),
|
|
7670
9260
|
executable: true,
|
|
7671
9261
|
languageMode: 5,
|
|
7672
9262
|
mainActorIsolation: false,
|
|
@@ -7676,9 +9266,11 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7676
9266
|
const reachesFrameworks = !distribution || Object.entries(input.files).some(
|
|
7677
9267
|
([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
|
|
7678
9268
|
) || [...importedModules].some(
|
|
7679
|
-
(name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2)
|
|
9269
|
+
(name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2) && !(clangImportedModules.has(name2) && !swiftImportedModules.has(name2) && existsSync2(
|
|
9270
|
+
path14.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name2)
|
|
9271
|
+
))
|
|
7680
9272
|
);
|
|
7681
|
-
const frameworkLink = prebuilt ?
|
|
9273
|
+
const frameworkLink = prebuilt ? path14.join(layout.root, ".peach-framework-objects.rsp") : void 0;
|
|
7682
9274
|
if (prebuilt && frameworkLink) {
|
|
7683
9275
|
files.set(
|
|
7684
9276
|
frameworkLink,
|
|
@@ -7686,7 +9278,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7686
9278
|
);
|
|
7687
9279
|
}
|
|
7688
9280
|
files.set(
|
|
7689
|
-
|
|
9281
|
+
path14.join(layout.root, "Package.swift"),
|
|
7690
9282
|
emitSwiftPackageManifest({
|
|
7691
9283
|
root: layout.root,
|
|
7692
9284
|
targets: manifestTargets,
|
|
@@ -7720,7 +9312,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7720
9312
|
),
|
|
7721
9313
|
...reachesFrameworks ? {
|
|
7722
9314
|
distributionLink: {
|
|
7723
|
-
path:
|
|
9315
|
+
path: path14.join(layout.root, ".peach-distribution-objects.rsp"),
|
|
7724
9316
|
files
|
|
7725
9317
|
},
|
|
7726
9318
|
lazyDistribution: input.lazyDistribution
|
|
@@ -7739,21 +9331,21 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7739
9331
|
);
|
|
7740
9332
|
}
|
|
7741
9333
|
for (const [file, bytes] of Object.entries(input.packageFiles ?? {}))
|
|
7742
|
-
files.set(
|
|
9334
|
+
files.set(path14.join(layout.root, file), Buffer.from(bytes, "base64"));
|
|
7743
9335
|
for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
|
|
7744
|
-
const destination =
|
|
9336
|
+
const destination = path14.join(layout.root, file);
|
|
7745
9337
|
if (files.has(destination)) continue;
|
|
7746
9338
|
files.set(destination, Buffer.from(bytes, "base64"));
|
|
7747
9339
|
}
|
|
7748
9340
|
if (input.packageFiles || prebuilt) {
|
|
7749
9341
|
files.set(
|
|
7750
|
-
|
|
9342
|
+
path14.join(layout.root, ".peach-target-toolset.json"),
|
|
7751
9343
|
JSON.stringify({
|
|
7752
9344
|
schemaVersion: "1.0",
|
|
7753
9345
|
swiftCompiler: {
|
|
7754
9346
|
extraCLIOptions: [
|
|
7755
9347
|
"-I",
|
|
7756
|
-
distribution ? distributionModulesPath(layout.root, moduleRoot, distributionExcludes) : prebuilt ? prebuilt.modules :
|
|
9348
|
+
distribution ? distributionModulesPath(layout.root, moduleRoot, distributionExcludes) : prebuilt ? prebuilt.modules : path14.join(layout.root, ".build", WASM_TRIPLE, "release", "Modules"),
|
|
7757
9349
|
...prebuilt?.moduleMaps.flatMap((map) => [
|
|
7758
9350
|
"-Xcc",
|
|
7759
9351
|
`-fmodule-map-file=${map}`
|
|
@@ -7782,9 +9374,9 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7782
9374
|
throw new Error(
|
|
7783
9375
|
`swift resource target ${target.name} has no matching bundle assignment`
|
|
7784
9376
|
);
|
|
7785
|
-
const directory = layout.multi ?
|
|
9377
|
+
const directory = layout.multi ? path14.join(layout.root, target.path) : layout.sources;
|
|
7786
9378
|
files.set(
|
|
7787
|
-
|
|
9379
|
+
path14.join(directory, "ResourceBundleAccessor.generated.swift"),
|
|
7788
9380
|
[
|
|
7789
9381
|
"import Foundation",
|
|
7790
9382
|
"",
|
|
@@ -7801,7 +9393,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
|
|
|
7801
9393
|
}
|
|
7802
9394
|
for (const [file, source] of compiled)
|
|
7803
9395
|
if (!Object.hasOwn(input.files, file))
|
|
7804
|
-
files.set(
|
|
9396
|
+
files.set(path14.join(layout.multi ? layout.root : layout.sources, file), source);
|
|
7805
9397
|
syncSwiftTree(layout.root, files);
|
|
7806
9398
|
const producers = [
|
|
7807
9399
|
.../* @__PURE__ */ new Set([...[...native.values()].flatMap((value) => value.late?.producers ?? [])])
|
|
@@ -7836,24 +9428,17 @@ function outputOf(error) {
|
|
|
7836
9428
|
return error instanceof Error ? error.message : String(error);
|
|
7837
9429
|
}
|
|
7838
9430
|
function builtArtifact(layout) {
|
|
7839
|
-
const binDir =
|
|
7840
|
-
const manifest = readFileSync7(
|
|
9431
|
+
const binDir = path14.join(layout.root, ".build", WASM_TRIPLE, "release");
|
|
9432
|
+
const manifest = readFileSync7(path14.join(layout.root, "Package.swift"), "utf8");
|
|
7841
9433
|
const executable = swiftManifestTargets(manifest).find((target) => target.executable);
|
|
7842
9434
|
if (executable === void 0) {
|
|
7843
9435
|
throw new Error("swift-compile: the written manifest names no executable target");
|
|
7844
9436
|
}
|
|
7845
|
-
|
|
7846
|
-
if (!existsSync2(file)) {
|
|
7847
|
-
const found = existsSync2(binDir) ? readdirSync5(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
|
|
7848
|
-
throw new Error(
|
|
7849
|
-
`swift-compile: the build produced no ${executable.name}.wasm (found: ${found.join(", ") || "none"})`
|
|
7850
|
-
);
|
|
7851
|
-
}
|
|
7852
|
-
return file;
|
|
9437
|
+
return path14.join(binDir, `${executable.name}.wasm`);
|
|
7853
9438
|
}
|
|
7854
9439
|
function projectDiagnostic(output, layout, files) {
|
|
7855
9440
|
const base = layout.multi ? layout.root : layout.sources;
|
|
7856
|
-
const prefix = `${base}${
|
|
9441
|
+
const prefix = `${base}${path14.sep}`;
|
|
7857
9442
|
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();
|
|
7858
9443
|
}
|
|
7859
9444
|
var ROOT_LOCKS = Symbol.for("peachsim.swiftCompile.rootLocks");
|
|
@@ -7889,13 +9474,13 @@ function serialize(root, work, signal) {
|
|
|
7889
9474
|
function readCompiledArtifact(directory, hash) {
|
|
7890
9475
|
try {
|
|
7891
9476
|
const receipt = JSON.parse(
|
|
7892
|
-
readFileSync7(
|
|
9477
|
+
readFileSync7(path14.join(directory, "artifact.json"), "utf8")
|
|
7893
9478
|
);
|
|
7894
9479
|
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")
|
|
7895
9480
|
return null;
|
|
7896
|
-
const bytes = readFileSync7(
|
|
7897
|
-
const gzip2 = readFileSync7(
|
|
7898
|
-
if (
|
|
9481
|
+
const bytes = readFileSync7(path14.join(directory, "app.wasm"));
|
|
9482
|
+
const gzip2 = readFileSync7(path14.join(directory, "icu.gz"));
|
|
9483
|
+
if (createHash8("sha256").update(bytes).digest("hex") !== receipt.wasm || createHash8("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length < 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
|
|
7899
9484
|
return null;
|
|
7900
9485
|
return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 } };
|
|
7901
9486
|
} catch (error) {
|
|
@@ -7905,22 +9490,22 @@ function readCompiledArtifact(directory, hash) {
|
|
|
7905
9490
|
}
|
|
7906
9491
|
}
|
|
7907
9492
|
function saveCompiledArtifact(root, artifact) {
|
|
7908
|
-
const directory =
|
|
9493
|
+
const directory = path14.join(root, "artifact");
|
|
7909
9494
|
mkdirSync2(directory, { recursive: true });
|
|
7910
|
-
const pending = mkdtempSync2(
|
|
9495
|
+
const pending = mkdtempSync2(path14.join(root, ".artifact-"));
|
|
7911
9496
|
try {
|
|
7912
|
-
writeFileSync3(
|
|
7913
|
-
writeFileSync3(
|
|
9497
|
+
writeFileSync3(path14.join(pending, "app.wasm"), artifact.bytes);
|
|
9498
|
+
writeFileSync3(path14.join(pending, "icu.gz"), artifact.icu.gzip);
|
|
7914
9499
|
writeFileSync3(
|
|
7915
|
-
|
|
9500
|
+
path14.join(pending, "artifact.json"),
|
|
7916
9501
|
JSON.stringify({
|
|
7917
9502
|
hash: artifact.hash,
|
|
7918
|
-
wasm:
|
|
9503
|
+
wasm: createHash8("sha256").update(artifact.bytes).digest("hex"),
|
|
7919
9504
|
icu: artifact.icu.sha256
|
|
7920
9505
|
})
|
|
7921
9506
|
);
|
|
7922
9507
|
for (const file of ["app.wasm", "icu.gz", "artifact.json"]) {
|
|
7923
|
-
renameSync(
|
|
9508
|
+
renameSync(path14.join(pending, file), path14.join(directory, file));
|
|
7924
9509
|
}
|
|
7925
9510
|
} finally {
|
|
7926
9511
|
rmSync3(pending, { recursive: true, force: true });
|
|
@@ -7942,16 +9527,16 @@ function renewSharedArtifact(sharedRoot) {
|
|
|
7942
9527
|
function pruneSharedArtifacts(parent, keep) {
|
|
7943
9528
|
const entries = [];
|
|
7944
9529
|
for (const name2 of readdirSync5(parent)) {
|
|
7945
|
-
const directory =
|
|
9530
|
+
const directory = path14.join(parent, name2);
|
|
7946
9531
|
if (name2.startsWith(RETIRED_PREFIX)) {
|
|
7947
9532
|
rmSync3(directory, { recursive: true, force: true });
|
|
7948
9533
|
continue;
|
|
7949
9534
|
}
|
|
7950
9535
|
try {
|
|
7951
9536
|
let bytes = 0;
|
|
7952
|
-
for (const file of readdirSync5(
|
|
9537
|
+
for (const file of readdirSync5(path14.join(directory, "artifact"))) {
|
|
7953
9538
|
try {
|
|
7954
|
-
bytes += statSync(
|
|
9539
|
+
bytes += statSync(path14.join(directory, "artifact", file)).size;
|
|
7955
9540
|
} catch (error) {
|
|
7956
9541
|
if (!vanished(error)) throw error;
|
|
7957
9542
|
}
|
|
@@ -7966,9 +9551,9 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
7966
9551
|
if (total <= SHARED_ARTIFACT_BUDGET_BYTES) break;
|
|
7967
9552
|
if (entry.directory === keep || Date.now() - entry.used < SHARED_ARTIFACT_GRACE_MS)
|
|
7968
9553
|
continue;
|
|
7969
|
-
const retired =
|
|
9554
|
+
const retired = path14.join(
|
|
7970
9555
|
parent,
|
|
7971
|
-
`${RETIRED_PREFIX}${process.pid}-${
|
|
9556
|
+
`${RETIRED_PREFIX}${process.pid}-${path14.basename(entry.directory)}`
|
|
7972
9557
|
);
|
|
7973
9558
|
try {
|
|
7974
9559
|
if (statSync(entry.directory).mtimeMs !== entry.used) continue;
|
|
@@ -7984,7 +9569,7 @@ function pruneSharedArtifacts(parent, keep) {
|
|
|
7984
9569
|
function saveSharedArtifact(sharedRoot, artifact) {
|
|
7985
9570
|
saveCompiledArtifact(sharedRoot, artifact);
|
|
7986
9571
|
renewSharedArtifact(sharedRoot);
|
|
7987
|
-
pruneSharedArtifacts(
|
|
9572
|
+
pruneSharedArtifacts(path14.dirname(sharedRoot), sharedRoot);
|
|
7988
9573
|
}
|
|
7989
9574
|
var retainedArtifacts = /* @__PURE__ */ new Map();
|
|
7990
9575
|
function retain(root, artifact) {
|
|
@@ -8012,7 +9597,7 @@ function frameworkLibraryTargets(manifest) {
|
|
|
8012
9597
|
}
|
|
8013
9598
|
function linkedFrameworkTargets(moduleRoot, input) {
|
|
8014
9599
|
const libraries = frameworkLibraryTargets(
|
|
8015
|
-
readFileSync7(
|
|
9600
|
+
readFileSync7(path14.join(moduleRoot, "Package.swift"), "utf8")
|
|
8016
9601
|
);
|
|
8017
9602
|
const targets = compileTargets(input);
|
|
8018
9603
|
const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
|
|
@@ -8053,7 +9638,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
|
|
|
8053
9638
|
return { products: linked, targets: linkedMembers };
|
|
8054
9639
|
}
|
|
8055
9640
|
function writeFrameworkLinkPackage(linkRoot, moduleRoot, products) {
|
|
8056
|
-
const identity =
|
|
9641
|
+
const identity = path14.basename(moduleRoot).toLowerCase();
|
|
8057
9642
|
const swiftString = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
8058
9643
|
const dependencies = products.map(
|
|
8059
9644
|
(name2) => ` .product(name: ${swiftString(name2)}, package: ${swiftString(identity)}),`
|
|
@@ -8075,12 +9660,12 @@ ${dependencies}
|
|
|
8075
9660
|
]
|
|
8076
9661
|
)
|
|
8077
9662
|
`;
|
|
8078
|
-
const sourceDir =
|
|
9663
|
+
const sourceDir = path14.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
|
|
8079
9664
|
mkdirSync2(sourceDir, { recursive: true });
|
|
8080
|
-
const manifestPath =
|
|
9665
|
+
const manifestPath = path14.join(linkRoot, "Package.swift");
|
|
8081
9666
|
if (!existsSync2(manifestPath) || readFileSync7(manifestPath, "utf8") !== manifest)
|
|
8082
9667
|
writeFileSync3(manifestPath, manifest);
|
|
8083
|
-
const source =
|
|
9668
|
+
const source = path14.join(sourceDir, "Link.swift");
|
|
8084
9669
|
if (!existsSync2(source)) writeFileSync3(source, "");
|
|
8085
9670
|
}
|
|
8086
9671
|
function frameworkLinkClosure(scratch2, roots) {
|
|
@@ -8092,7 +9677,7 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
8092
9677
|
const moduleMaps = /* @__PURE__ */ new Map();
|
|
8093
9678
|
let pending = null;
|
|
8094
9679
|
let compiling = null;
|
|
8095
|
-
for (const line of readFileSync7(
|
|
9680
|
+
for (const line of readFileSync7(path14.join(scratch2, "release.yaml"), "utf8").split(
|
|
8096
9681
|
"\n"
|
|
8097
9682
|
)) {
|
|
8098
9683
|
const phony = phonyHeader.exec(line);
|
|
@@ -8160,20 +9745,34 @@ function frameworkLinkClosure(scratch2, roots) {
|
|
|
8160
9745
|
files.sort();
|
|
8161
9746
|
return { objects: files, modules, moduleMaps: [...maps].sort() };
|
|
8162
9747
|
}
|
|
8163
|
-
function
|
|
9748
|
+
function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
|
|
8164
9749
|
if (!existsSync2(modulesDir)) return;
|
|
9750
|
+
const folded = new Set([...keep].map((name2) => name2.toLowerCase()));
|
|
8165
9751
|
for (const name2 of readdirSync5(modulesDir)) {
|
|
8166
9752
|
const dot = name2.indexOf(".");
|
|
8167
9753
|
if (dot <= 0) continue;
|
|
8168
|
-
|
|
8169
|
-
|
|
9754
|
+
const module = name2.slice(0, dot);
|
|
9755
|
+
if (keep.has(module) || !folded.has(module.toLowerCase())) continue;
|
|
9756
|
+
rmSync3(path14.join(modulesDir, name2), { recursive: true, force: true });
|
|
8170
9757
|
}
|
|
8171
9758
|
}
|
|
8172
9759
|
async function compileFrameworkProducts(args) {
|
|
8173
|
-
const scratch2 = swiftFrameworkScratch(args.
|
|
9760
|
+
const scratch2 = swiftFrameworkScratch(args.frameworkKey);
|
|
8174
9761
|
mkdirSync2(scratch2, { recursive: true });
|
|
9762
|
+
const now = /* @__PURE__ */ new Date();
|
|
9763
|
+
utimesSync(scratch2, now, now);
|
|
9764
|
+
return withSwiftRootLock(
|
|
9765
|
+
scratch2,
|
|
9766
|
+
(lease) => buildFrameworkProducts(scratch2, {
|
|
9767
|
+
...args,
|
|
9768
|
+
buildOptions: { ...args.buildOptions, lease }
|
|
9769
|
+
}),
|
|
9770
|
+
args.buildOptions.signal
|
|
9771
|
+
);
|
|
9772
|
+
}
|
|
9773
|
+
async function buildFrameworkProducts(scratch2, args) {
|
|
8175
9774
|
const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input);
|
|
8176
|
-
const linkRoot =
|
|
9775
|
+
const linkRoot = path14.join(scratch2, "link");
|
|
8177
9776
|
writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products);
|
|
8178
9777
|
await runCompiler(
|
|
8179
9778
|
args.swift,
|
|
@@ -8190,7 +9789,7 @@ async function compileFrameworkProducts(args) {
|
|
|
8190
9789
|
scratch2,
|
|
8191
9790
|
"--target",
|
|
8192
9791
|
FRAMEWORK_LINK_TARGET,
|
|
8193
|
-
...
|
|
9792
|
+
...swiftCompileSdkOptions(args.moduleRoot, args.toolchainBin),
|
|
8194
9793
|
"--swift-sdk",
|
|
8195
9794
|
args.sdk,
|
|
8196
9795
|
"-c",
|
|
@@ -8217,15 +9816,17 @@ async function compileFrameworkProducts(args) {
|
|
|
8217
9816
|
args.buildOptions,
|
|
8218
9817
|
SWIFTPM_PROGRESS,
|
|
8219
9818
|
SWIFTPM_NOISE
|
|
8220
|
-
)
|
|
8221
|
-
|
|
9819
|
+
).catch((error) => {
|
|
9820
|
+
throw new Error(outputOf(error), { cause: error });
|
|
9821
|
+
});
|
|
9822
|
+
const release = path14.join(scratch2, WASM_TRIPLE, "release");
|
|
8222
9823
|
const linked = frameworkLinkClosure(scratch2, linkedTargets.targets);
|
|
8223
9824
|
const objects = linked.objects;
|
|
8224
|
-
|
|
8225
|
-
const response =
|
|
9825
|
+
removeCaseCollidingModuleArtifacts(path14.join(release, "Modules"), linked.modules);
|
|
9826
|
+
const response = path14.join(scratch2, "autolink-objects.rsp");
|
|
8226
9827
|
writeFileSync3(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
|
|
8227
9828
|
const extracted = await runCompiler(
|
|
8228
|
-
|
|
9829
|
+
path14.join(args.toolchainBin, "swift-autolink-extract"),
|
|
8229
9830
|
[`@${response}`, "-o", "-"],
|
|
8230
9831
|
args.buildOptions
|
|
8231
9832
|
);
|
|
@@ -8233,25 +9834,54 @@ async function compileFrameworkProducts(args) {
|
|
|
8233
9834
|
const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
|
|
8234
9835
|
if (link.includes("-lFoundation"))
|
|
8235
9836
|
objects.push(
|
|
8236
|
-
|
|
9837
|
+
path14.join(
|
|
8237
9838
|
swiftSdkPaths(args.moduleRoot, args.toolchainBin).resources,
|
|
8238
9839
|
"wasi/NSStringFormatting.objc.o"
|
|
8239
9840
|
)
|
|
8240
9841
|
);
|
|
8241
9842
|
return {
|
|
8242
|
-
modules:
|
|
9843
|
+
modules: path14.join(release, "Modules"),
|
|
8243
9844
|
objects,
|
|
8244
9845
|
link,
|
|
8245
9846
|
moduleMaps: linked.moduleMaps
|
|
8246
9847
|
};
|
|
8247
9848
|
}
|
|
8248
9849
|
var SWIFT_LINK_STAMP = ".peach-link-stamp";
|
|
8249
|
-
var
|
|
8250
|
-
function
|
|
8251
|
-
return
|
|
9850
|
+
var SWIFT_FRAMEWORK_SCRATCHES_KEPT = 3;
|
|
9851
|
+
function swiftFrameworksDir() {
|
|
9852
|
+
return path14.join(swiftCacheDir(), "swift-frameworks");
|
|
9853
|
+
}
|
|
9854
|
+
function swiftFrameworkScratch(frameworkKey) {
|
|
9855
|
+
return path14.join(swiftFrameworksDir(), frameworkKey);
|
|
9856
|
+
}
|
|
9857
|
+
function stageFrameworkSource(moduleRoot, frameworkKey) {
|
|
9858
|
+
if (swiftDistributionAt(moduleRoot)) return moduleRoot;
|
|
9859
|
+
const staged = path14.join(swiftFrameworkScratch(frameworkKey), "source");
|
|
9860
|
+
const stagedModule = path14.join(staged, "packages", path14.basename(moduleRoot));
|
|
9861
|
+
if (existsSync2(path14.join(staged, ".complete"))) return stagedModule;
|
|
9862
|
+
const partial = `${staged}.${randomUUID3()}`;
|
|
9863
|
+
mkdirSync2(partial, { recursive: true });
|
|
9864
|
+
cpSync(moduleRoot, path14.join(partial, "packages", path14.basename(moduleRoot)), {
|
|
9865
|
+
recursive: true,
|
|
9866
|
+
preserveTimestamps: true,
|
|
9867
|
+
filter: (source) => path14.relative(moduleRoot, source) !== ".build"
|
|
9868
|
+
});
|
|
9869
|
+
cpSync(
|
|
9870
|
+
swiftSharedSdkRoot(moduleRoot, false),
|
|
9871
|
+
path14.join(partial, "packages/peachsim/sdk/ios"),
|
|
9872
|
+
{ recursive: true, preserveTimestamps: true }
|
|
9873
|
+
);
|
|
9874
|
+
symlinkSync(
|
|
9875
|
+
realpathSync(path14.join(moduleRoot, "../../node_modules")),
|
|
9876
|
+
path14.join(partial, "node_modules")
|
|
9877
|
+
);
|
|
9878
|
+
writeFileSync3(path14.join(partial, ".complete"), "");
|
|
9879
|
+
rmSync3(staged, { recursive: true, force: true });
|
|
9880
|
+
renameSync(partial, staged);
|
|
9881
|
+
return stagedModule;
|
|
8252
9882
|
}
|
|
8253
9883
|
function swiftLinkStamp(args) {
|
|
8254
|
-
const hash =
|
|
9884
|
+
const hash = createHash8("sha256");
|
|
8255
9885
|
hash.update(`swift-link/v1
|
|
8256
9886
|
${args.frameworkKey}
|
|
8257
9887
|
`);
|
|
@@ -8276,26 +9906,22 @@ ${args.prebuilt.modules}
|
|
|
8276
9906
|
`);
|
|
8277
9907
|
for (const entry of readdirSync5(args.prebuilt.modules).sort())
|
|
8278
9908
|
hash.update(`${entry}
|
|
8279
|
-
${statOf(
|
|
9909
|
+
${statOf(path14.join(args.prebuilt.modules, entry))}`);
|
|
8280
9910
|
return hash.digest("hex");
|
|
8281
9911
|
}
|
|
8282
|
-
function
|
|
8283
|
-
const
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
const scratch2 = swiftFrameworkScratch(root);
|
|
8293
|
-
if (previous === key || !existsSync2(scratch2)) return false;
|
|
8294
|
-
rmSync3(scratch2, { recursive: true, force: true });
|
|
8295
|
-
return true;
|
|
9912
|
+
async function pruneFrameworkScratches(keep) {
|
|
9913
|
+
const dir = swiftFrameworksDir();
|
|
9914
|
+
const idle = readdirSync5(dir).filter((name2) => name2 !== keep).map((name2) => ({ name: name2, modified: statSync(path14.join(dir, name2)).mtimeMs })).sort((left, right) => right.modified - left.modified).slice(SWIFT_FRAMEWORK_SCRATCHES_KEPT - 1);
|
|
9915
|
+
for (const { name: name2 } of idle)
|
|
9916
|
+
await withSwiftRootLock(
|
|
9917
|
+
path14.join(dir, name2),
|
|
9918
|
+
async () => rmSync3(path14.join(dir, name2), { recursive: true, force: true }),
|
|
9919
|
+
void 0,
|
|
9920
|
+
false
|
|
9921
|
+
);
|
|
8296
9922
|
}
|
|
8297
9923
|
function retireStaleSwiftLink(root, stamp) {
|
|
8298
|
-
const receipt =
|
|
9924
|
+
const receipt = path14.join(root, SWIFT_LINK_STAMP);
|
|
8299
9925
|
let previous = null;
|
|
8300
9926
|
try {
|
|
8301
9927
|
previous = readFileSync7(receipt, "utf8").trim();
|
|
@@ -8304,7 +9930,7 @@ function retireStaleSwiftLink(root, stamp) {
|
|
|
8304
9930
|
}
|
|
8305
9931
|
writeFileSync3(receipt, `${stamp}
|
|
8306
9932
|
`);
|
|
8307
|
-
const retired =
|
|
9933
|
+
const retired = path14.join(root, ".build");
|
|
8308
9934
|
if (previous === stamp || !existsSync2(retired)) return false;
|
|
8309
9935
|
rmSync3(retired, { recursive: true, force: true });
|
|
8310
9936
|
return true;
|
|
@@ -8313,15 +9939,15 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8313
9939
|
options.signal?.throwIfAborted();
|
|
8314
9940
|
mkdirSync2(options.buildRoot, { recursive: true });
|
|
8315
9941
|
const root = realpathSync(options.buildRoot);
|
|
8316
|
-
const moduleRoot =
|
|
9942
|
+
const moduleRoot = path14.resolve(options.moduleRoot);
|
|
8317
9943
|
const layout = {
|
|
8318
9944
|
root,
|
|
8319
|
-
sources:
|
|
9945
|
+
sources: path14.join(root, "Sources", "App"),
|
|
8320
9946
|
multi: compileTargets(input).length > 0
|
|
8321
9947
|
};
|
|
8322
9948
|
const hash = swiftArtifactHash(input, options.release, moduleRoot);
|
|
8323
9949
|
const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
|
|
8324
|
-
const sharedRoot =
|
|
9950
|
+
const sharedRoot = path14.join(swiftCacheDir(), "swift-projects", hash);
|
|
8325
9951
|
const report = (message) => {
|
|
8326
9952
|
console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
|
|
8327
9953
|
options.onStage?.(message);
|
|
@@ -8335,8 +9961,8 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8335
9961
|
report("reusing memory artifact");
|
|
8336
9962
|
return retain(root, retained);
|
|
8337
9963
|
}
|
|
8338
|
-
const cached = readCompiledArtifact(
|
|
8339
|
-
const previous = cached ?? readCompiledArtifact(
|
|
9964
|
+
const cached = readCompiledArtifact(path14.join(sharedRoot, "artifact"), hash);
|
|
9965
|
+
const previous = cached ?? readCompiledArtifact(path14.join(root, "artifact"), hash);
|
|
8340
9966
|
if (previous) {
|
|
8341
9967
|
if (cached) renewSharedArtifact(sharedRoot);
|
|
8342
9968
|
else saveSharedArtifact(sharedRoot, previous);
|
|
@@ -8345,8 +9971,8 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8345
9971
|
}
|
|
8346
9972
|
if (process.platform === "darwin" && process.env.TM_SESSION && !admittedMacBuilderSlot() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
|
|
8347
9973
|
const requestRoot = mkdtempSync2(`${root}.builder-request-`);
|
|
8348
|
-
const output =
|
|
8349
|
-
const request =
|
|
9974
|
+
const output = path14.join(requestRoot, "output");
|
|
9975
|
+
const request = path14.join(requestRoot, "request.json");
|
|
8350
9976
|
writeFileSync3(
|
|
8351
9977
|
request,
|
|
8352
9978
|
JSON.stringify({
|
|
@@ -8360,12 +9986,12 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8360
9986
|
})
|
|
8361
9987
|
);
|
|
8362
9988
|
try {
|
|
8363
|
-
const repo =
|
|
9989
|
+
const repo = path14.resolve(moduleRoot, "../..");
|
|
8364
9990
|
report("requesting builder admission or cached result");
|
|
8365
9991
|
await runCompiler(
|
|
8366
9992
|
"bun",
|
|
8367
9993
|
[
|
|
8368
|
-
|
|
9994
|
+
path14.join(repo, "scripts/build/swift-project.ts"),
|
|
8369
9995
|
"--request",
|
|
8370
9996
|
request,
|
|
8371
9997
|
"--output",
|
|
@@ -8399,27 +10025,34 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8399
10025
|
return withSwiftRootLock(
|
|
8400
10026
|
root,
|
|
8401
10027
|
async (lease) => {
|
|
8402
|
-
const built = readCompiledArtifact(
|
|
10028
|
+
const built = readCompiledArtifact(path14.join(sharedRoot, "artifact"), hash);
|
|
8403
10029
|
if (built) {
|
|
8404
10030
|
report("reusing verified disk artifact");
|
|
8405
10031
|
return retain(root, built);
|
|
8406
10032
|
}
|
|
8407
|
-
const swift =
|
|
10033
|
+
const swift = path14.join(options.toolchainBin, "swift");
|
|
8408
10034
|
if (!existsSync2(swift)) {
|
|
8409
10035
|
throw new Error(
|
|
8410
10036
|
`swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
|
|
8411
10037
|
);
|
|
8412
10038
|
}
|
|
8413
|
-
|
|
8414
|
-
|
|
10039
|
+
const frameworkRoot = await withSwiftRootLock(
|
|
10040
|
+
swiftFrameworkScratch(frameworkKey),
|
|
10041
|
+
async () => stageFrameworkSource(moduleRoot, frameworkKey),
|
|
10042
|
+
options.signal
|
|
10043
|
+
);
|
|
8415
10044
|
report("preparing compiler plugins");
|
|
8416
|
-
const macroPlugins = await
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
|
|
10045
|
+
const macroPlugins = await withSwiftRootLock(
|
|
10046
|
+
swiftFrameworkScratch(frameworkKey),
|
|
10047
|
+
async () => ensureMacroPlugins(
|
|
10048
|
+
frameworkRoot,
|
|
10049
|
+
options.toolchainBin,
|
|
10050
|
+
options.release,
|
|
10051
|
+
options.signal
|
|
10052
|
+
),
|
|
8420
10053
|
options.signal
|
|
8421
10054
|
);
|
|
8422
|
-
const sdk = swiftModuleSdk(
|
|
10055
|
+
const sdk = swiftModuleSdk(frameworkRoot).wasmSdkId;
|
|
8423
10056
|
const icu = swiftIcuAsset(options.toolchainBin, sdk);
|
|
8424
10057
|
const buildOptions = {
|
|
8425
10058
|
env: {
|
|
@@ -8427,11 +10060,12 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8427
10060
|
// shipped host plugins resolve against the selected compiler's runtime.
|
|
8428
10061
|
...process.platform === "linux" ? {
|
|
8429
10062
|
LD_LIBRARY_PATH: [
|
|
8430
|
-
|
|
8431
|
-
|
|
10063
|
+
path14.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
10064
|
+
path14.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
8432
10065
|
process.env.LD_LIBRARY_PATH
|
|
8433
10066
|
].filter(Boolean).join(":")
|
|
8434
|
-
} : {}
|
|
10067
|
+
} : {},
|
|
10068
|
+
...input.lazyDistribution ? { PEACH_DEFER_WASM_LINK: "1" } : {}
|
|
8435
10069
|
},
|
|
8436
10070
|
maxBuffer: 64 * 1024 * 1024,
|
|
8437
10071
|
timeout: options.timeoutMs,
|
|
@@ -8442,8 +10076,8 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8442
10076
|
if (!swiftDistributionAt(moduleRoot)) {
|
|
8443
10077
|
report("compiling framework products");
|
|
8444
10078
|
prebuilt = await compileFrameworkProducts({
|
|
8445
|
-
moduleRoot,
|
|
8446
|
-
|
|
10079
|
+
moduleRoot: frameworkRoot,
|
|
10080
|
+
frameworkKey,
|
|
8447
10081
|
input,
|
|
8448
10082
|
swift,
|
|
8449
10083
|
sdk,
|
|
@@ -8451,6 +10085,7 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8451
10085
|
plugins: macroPlugins,
|
|
8452
10086
|
buildOptions
|
|
8453
10087
|
});
|
|
10088
|
+
await pruneFrameworkScratches(frameworkKey);
|
|
8454
10089
|
}
|
|
8455
10090
|
if (retireStaleSwiftLink(
|
|
8456
10091
|
root,
|
|
@@ -8460,7 +10095,7 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8460
10095
|
})
|
|
8461
10096
|
))
|
|
8462
10097
|
report("framework revision changed; rebuilding the app link");
|
|
8463
|
-
const preparation = writeSwiftProject(layout, input,
|
|
10098
|
+
const preparation = writeSwiftProject(layout, input, frameworkRoot, prebuilt);
|
|
8464
10099
|
writeSwiftAutolinkLinker(root, options.toolchainBin);
|
|
8465
10100
|
const unprepared = preparation.targetFailures.map(
|
|
8466
10101
|
(failure) => `error: target ${failure}`
|
|
@@ -8474,10 +10109,10 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8474
10109
|
BUILD_JOBS,
|
|
8475
10110
|
"--package-path",
|
|
8476
10111
|
root,
|
|
8477
|
-
...
|
|
10112
|
+
...swiftCompileSdkOptions(frameworkRoot, options.toolchainBin),
|
|
8478
10113
|
"--swift-sdk",
|
|
8479
10114
|
sdk,
|
|
8480
|
-
...input.packageFiles || prebuilt ? ["--toolset",
|
|
10115
|
+
...input.packageFiles || prebuilt ? ["--toolset", path14.join(root, ".peach-target-toolset.json")] : [],
|
|
8481
10116
|
"-c",
|
|
8482
10117
|
"release",
|
|
8483
10118
|
"-Xswiftc",
|
|
@@ -8499,6 +10134,12 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8499
10134
|
`${plugin}#ExpoModulesMacros`
|
|
8500
10135
|
])
|
|
8501
10136
|
];
|
|
10137
|
+
const linked = builtArtifact(layout);
|
|
10138
|
+
if (input.lazyDistribution) {
|
|
10139
|
+
rmSync3(path14.join(root, ".peach-link.rsp"), { force: true });
|
|
10140
|
+
if (existsSync2(linked) && statSync(linked).size <= 8)
|
|
10141
|
+
rmSync3(linked, { force: true });
|
|
10142
|
+
}
|
|
8502
10143
|
report("compiling and linking Swift modules");
|
|
8503
10144
|
try {
|
|
8504
10145
|
for (const producer of preparation.headerProducers) {
|
|
@@ -8519,7 +10160,7 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8519
10160
|
);
|
|
8520
10161
|
} catch (error) {
|
|
8521
10162
|
const output = outputOf(error);
|
|
8522
|
-
const moduleCache =
|
|
10163
|
+
const moduleCache = path14.join(
|
|
8523
10164
|
root,
|
|
8524
10165
|
".build",
|
|
8525
10166
|
WASM_TRIPLE,
|
|
@@ -8555,9 +10196,21 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
8555
10196
|
}
|
|
8556
10197
|
}
|
|
8557
10198
|
if (unprepared.length) throw new Error(unprepared.join("\n"));
|
|
10199
|
+
if (!existsSync2(linked)) {
|
|
10200
|
+
const binDir = path14.dirname(linked);
|
|
10201
|
+
const found = existsSync2(binDir) ? readdirSync5(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
|
|
10202
|
+
throw new Error(
|
|
10203
|
+
`swift-compile: the build produced no ${path14.basename(linked)} (found: ${found.join(", ") || "none"})`
|
|
10204
|
+
);
|
|
10205
|
+
}
|
|
10206
|
+
const optimized = `${linked}.optimized`;
|
|
10207
|
+
if (input.lazyDistribution) {
|
|
10208
|
+
pruneSwiftWasmLink(root, options.toolchainBin, frameworkRoot);
|
|
10209
|
+
await optimizeWasm(linked, optimized);
|
|
10210
|
+
}
|
|
8558
10211
|
const artifact = {
|
|
8559
10212
|
hash,
|
|
8560
|
-
bytes: readFileSync7(
|
|
10213
|
+
bytes: readFileSync7(input.lazyDistribution ? optimized : linked),
|
|
8561
10214
|
icu: await icu
|
|
8562
10215
|
};
|
|
8563
10216
|
saveCompiledArtifact(root, artifact);
|
|
@@ -8580,6 +10233,7 @@ export {
|
|
|
8580
10233
|
compileTargets,
|
|
8581
10234
|
emitSwiftPackageManifest,
|
|
8582
10235
|
ensureMacroPlugins,
|
|
10236
|
+
foundationOwnerOf,
|
|
8583
10237
|
lowerAVAssetURLCluster,
|
|
8584
10238
|
lowerNSValueTimeBox,
|
|
8585
10239
|
missingSwiftModules,
|
|
@@ -8592,12 +10246,14 @@ export {
|
|
|
8592
10246
|
swiftCMainEntry,
|
|
8593
10247
|
swiftCPredefines,
|
|
8594
10248
|
swiftCodeMask,
|
|
10249
|
+
swiftCompileSdkOptions,
|
|
8595
10250
|
swiftDistributionAt,
|
|
8596
10251
|
swiftIcuAsset,
|
|
8597
10252
|
swiftImportNames,
|
|
8598
10253
|
swiftMacroPlugins,
|
|
8599
10254
|
swiftModuleDigest,
|
|
8600
10255
|
swiftModuleInputFiles,
|
|
10256
|
+
swiftModuleInterface,
|
|
8601
10257
|
swiftModuleSdk,
|
|
8602
10258
|
swiftPeachModules,
|
|
8603
10259
|
swiftProjectBuildKey,
|