peachsim 0.1.1659 → 0.1.1667
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 +7 -0
- package/cli/bridge-flow-runner.ts +2 -2
- package/cli/commands/box.ts +2 -0
- package/cli/commands/control.ts +56 -17
- package/cli/commands/debug.ts +100 -9
- package/cli/commands/flow.ts +2 -2
- package/cli/commands/inspect/settle.ts +4 -2
- package/cli/commands/inspect/settling.ts +17 -14
- package/cli/commands/platform.ts +3 -0
- package/cli/current-sim.ts +21 -1
- package/cli/dev-build-freshness.ts +36 -2
- package/cli/maestro-compare.ts +44 -14
- package/cli/main.ts +3 -0
- package/cli/material-symbol-fonts.ts +3 -100
- package/cli/output-redaction.ts +21 -6
- package/cli/parent-pid.ts +2 -2
- package/cli/ws-bridge.ts +19 -1
- package/detox/attempt-events.cjs +48 -18
- package/detox/index.ts +0 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +2156 -25785
- 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 +85 -37
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +1747 -25394
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +2195 -25834
- package/dist-lib/host/fetch-proxy-handler.cjs +7 -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 +1 -1
- package/dist-lib/index.cjs +190 -45
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +81 -9
- package/dist-lib/native-app-identity-project.cjs +81 -9
- package/dist-lib/native-app-identity-project.mjs +81 -9
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +26 -24
- package/dist-lib/public-origins-lib.json +79 -53
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +18 -15
- package/dist-lib/sdk.mjs +18 -15
- package/dist-lib/skills.cjs +2995 -26434
- package/dist-lib/swift-compile.cjs +985 -24728
- package/dist-lib/swift-compile.mjs +914 -24657
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +28 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1780 -25372
- package/dist-lib/vite.cjs +73 -21
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-gesture-handler.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/demo/demo-bundle-platform.d.ts +29 -0
- package/dist-types/packages/peach-engine/src/engine/app-font-registry.d.ts +13 -1
- package/dist-types/packages/peach-engine/src/engine/clipboardContract.d.ts +17 -0
- package/dist-types/packages/peach-engine/src/engine/fontDataContract.d.ts +73 -0
- package/dist-types/packages/peach-engine/src/engine/glass-material.d.ts +1 -2
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +19 -3
- package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +0 -4
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +0 -1
- package/dist-types/packages/peach-engine/src/ios/aux-shell-animated-sources.d.ts +6 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +68 -0
- package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +4 -0
- package/dist-types/packages/peach-engine/src/render-worker/nativeSyncReplyContract.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +8 -1
- package/dist-types/packages/peach-engine/src/render-worker/shell-scene-schema.d.ts +10 -2
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +3 -0
- package/dist-types/packages/peach-globals/src/accessibilityBridgeContract.d.ts +11 -0
- package/dist-types/packages/peach-globals/src/androidDateTimePickerBridgeContract.d.ts +41 -0
- package/dist-types/packages/peach-globals/src/appLifecycleBridgeContract.d.ts +22 -0
- package/dist-types/packages/peach-globals/src/audioBridgeContract.d.ts +33 -0
- package/dist-types/packages/peach-globals/src/bridgeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/cameraBridgeContract.d.ts +94 -0
- package/dist-types/packages/peach-globals/src/captureBridgeContract.d.ts +36 -0
- package/dist-types/packages/peach-globals/src/clipboardBridgeContract.d.ts +27 -0
- package/dist-types/packages/peach-globals/src/compositorBridgeContract.d.ts +31 -0
- package/dist-types/packages/peach-globals/src/debugBridgeContract.d.ts +27 -0
- package/dist-types/packages/peach-globals/src/electronBridgeContract.d.ts +29 -0
- package/dist-types/packages/peach-globals/src/eventBridgeContract.d.ts +200 -0
- package/dist-types/packages/peach-globals/src/globalsContract.d.ts +462 -0
- package/dist-types/packages/peach-globals/src/hostStorageBridgeContract.d.ts +3 -0
- package/dist-types/packages/peach-globals/src/imagePickerBridgeContract.d.ts +47 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +47 -3334
- package/dist-types/packages/peach-globals/src/interactionBridgeContract.d.ts +21 -0
- package/dist-types/packages/peach-globals/src/keyboardBridgeContract.d.ts +44 -0
- package/dist-types/packages/peach-globals/src/lockstepCaptureBridgeContract.d.ts +77 -0
- package/dist-types/packages/peach-globals/src/nativeViewContract.d.ts +28 -0
- package/dist-types/packages/peach-globals/src/navigationBridgeContract.d.ts +11 -0
- package/dist-types/packages/peach-globals/src/nodeContract.d.ts +664 -0
- package/dist-types/packages/peach-globals/src/performanceBridgeContract.d.ts +100 -0
- package/dist-types/packages/peach-globals/src/permissionsBridgeContract.d.ts +152 -0
- package/dist-types/packages/peach-globals/src/photoLibraryBridgeContract.d.ts +36 -0
- package/dist-types/packages/peach-globals/src/portalBridgeContract.d.ts +9 -0
- package/dist-types/packages/peach-globals/src/recordingBridgeContract.d.ts +131 -0
- package/dist-types/packages/peach-globals/src/replayBridgeContract.d.ts +125 -0
- package/dist-types/packages/peach-globals/src/sceneStreamBridgeContract.d.ts +37 -0
- package/dist-types/packages/peach-globals/src/settingsBridgeContract.d.ts +7 -0
- package/dist-types/packages/peach-globals/src/shareSheetBridgeContract.d.ts +14 -0
- package/dist-types/packages/peach-globals/src/shellBridgeContract.d.ts +82 -0
- package/dist-types/packages/peach-globals/src/shellHostBridgeContract.d.ts +28 -0
- package/dist-types/packages/peach-globals/src/speechSynthesisBridgeContract.d.ts +25 -0
- package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +278 -0
- package/dist-types/packages/peach-globals/src/timelineBridgeContract.d.ts +58 -0
- package/dist-types/packages/peach-globals/src/videoBridgeContract.d.ts +80 -0
- package/dist-types/packages/peach-globals/src/webViewBridgeContract.d.ts +331 -0
- package/dist-types/packages/peach-globals/src/windowBridgeContract.d.ts +5 -0
- package/dist-types/packages/peach-kit/src/ui/popover-placement.d.ts +3 -5
- package/package.json +2 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVAsset.h +20 -0
- package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVAsynchronousKeyValueLoading.h +15 -0
- package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.h +5 -0
- package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVMetadataFormat.h +13 -0
- package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVMetadataItem.h +16 -0
- package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVTimedMetadataGroup.h +13 -0
- package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Modules/module.modulemap +4 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Conversion.h +19 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Convolution.h +11 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Geometry.h +17 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_Types.h +307 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_Utilities.h +174 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Headers/Accelerate.h +7 -0
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/CoreData.h +5 -0
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSFetchRequest.h +21 -0
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSFetchedResultsController.h +39 -0
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSManagedObject.h +10 -0
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSManagedObjectContext.h +9 -0
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSManagedObjectID.h +7 -0
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSManagedObjectModel.h +5 -0
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSPersistentStoreCoordinator.h +5 -0
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSPersistentStoreRequest.h +5 -0
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +185 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGBase.h +2 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +316 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Modules/module.modulemap +4 -0
- package/sdk/ios/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.h +46 -0
- package/sdk/ios/System/Library/Frameworks/CoreImage.framework/Modules/module.modulemap +4 -0
- package/sdk/ios/System/Library/Frameworks/CoreMedia.framework/Headers/CMTime.h +31 -0
- package/sdk/ios/System/Library/Frameworks/CoreMedia.framework/Headers/CMTimeRange.h +8 -0
- package/sdk/ios/System/Library/Frameworks/CoreMedia.framework/Headers/CoreMedia.h +3 -0
- package/sdk/ios/System/Library/Frameworks/CoreMedia.framework/Modules/module.modulemap +4 -0
- package/sdk/ios/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h +12 -0
- package/sdk/ios/System/Library/Frameworks/CoreServices.framework/Headers/UTCoreTypes.h +1276 -0
- package/sdk/ios/System/Library/Frameworks/CoreServices.framework/Headers/UTType.h +644 -0
- package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTFontManager.h +20 -0
- package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CoreText.h +2 -0
- package/sdk/ios/System/Library/Frameworks/CoreText.framework/Modules/module.modulemap +4 -0
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +1441 -0
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Modules/module.modulemap +4 -0
- package/sdk/ios/System/Library/Frameworks/ImageIO.framework/Headers/CGImageAnimation.h +106 -0
- package/sdk/ios/System/Library/Frameworks/ImageIO.framework/Headers/CGImageDestination.h +429 -0
- package/sdk/ios/System/Library/Frameworks/ImageIO.framework/Headers/CGImageMetadata.h +665 -0
- package/sdk/ios/System/Library/Frameworks/ImageIO.framework/Headers/CGImageProperties.h +2504 -0
- package/sdk/ios/System/Library/Frameworks/ImageIO.framework/Headers/CGImageSource.h +634 -0
- package/sdk/ios/System/Library/Frameworks/ImageIO.framework/Headers/ImageIO.h +22 -0
- package/sdk/ios/System/Library/Frameworks/ImageIO.framework/Headers/ImageIOBase.h +18 -0
- package/sdk/ios/System/Library/Frameworks/ImageIO.framework/Modules/module.modulemap +4 -0
- package/sdk/ios/System/Library/Frameworks/MobileCoreServices.framework/Headers/MobileCoreServices.h +9 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.h +40 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Modules/module.modulemap +4 -0
- package/sdk/ios/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h +14 -0
- package/sdk/ios/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewControllerConfiguration.h +9 -0
- package/sdk/ios/System/Library/Frameworks/SafariServices.framework/Headers/SafariServices.h +2 -0
- package/sdk/ios/System/Library/Frameworks/SafariServices.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecBase.h +3 -0
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecItem.h +30 -0
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/Security.h +3 -0
- package/sdk/ios/System/Library/Frameworks/Security.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAppearance.h +5 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIColor.h +2 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +817 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Modules/module.modulemap +4 -0
- package/sdk/ios/usr/include/Availability.h +630 -0
- package/sdk/ios/usr/include/AvailabilityInternal.h +556 -0
- package/sdk/ios/usr/include/AvailabilityInternalLegacy.h +4346 -0
- package/sdk/ios/usr/include/AvailabilityVersions.h +547 -0
- package/sdk/ios/usr/include/CommonCrypto/CommonDigest.h +130 -0
- package/sdk/ios/usr/include/MacTypes.h +3 -0
- package/sdk/ios/usr/include/TargetConditionals.h +14 -0
- package/sdk/ios/usr/include/__xlocale.h +41 -0
- package/sdk/ios/usr/include/_bounds.h +67 -0
- package/sdk/ios/usr/include/_ctermid.h +42 -0
- package/sdk/ios/usr/include/_mb_cur_max.h +39 -0
- package/sdk/ios/usr/include/_printf.h +38 -0
- package/sdk/ios/usr/include/_stdio.h +510 -0
- package/sdk/ios/usr/include/_types/_intmax_t.h +40 -0
- package/sdk/ios/usr/include/_types/_locale_t.h +38 -0
- package/sdk/ios/usr/include/_types/_uint16_t.h +32 -0
- package/sdk/ios/usr/include/_types/_uint32_t.h +32 -0
- package/sdk/ios/usr/include/_types/_uint64_t.h +32 -0
- package/sdk/ios/usr/include/_types/_uint8_t.h +32 -0
- package/sdk/ios/usr/include/_types/_uintmax_t.h +40 -0
- package/sdk/ios/usr/include/_types.h +72 -0
- package/sdk/ios/usr/include/arm/_endian.h +105 -0
- package/sdk/ios/usr/include/arm/_mcontext.h +95 -0
- package/sdk/ios/usr/include/arm/_param.h +25 -0
- package/sdk/ios/usr/include/arm/_types.h +125 -0
- package/sdk/ios/usr/include/arm/endian.h +65 -0
- package/sdk/ios/usr/include/arm/signal.h +22 -0
- package/sdk/ios/usr/include/arm/types.h +110 -0
- package/sdk/ios/usr/include/asl.h +160 -0
- package/sdk/ios/usr/include/assert.h +14 -0
- package/sdk/ios/usr/include/dirent.h +224 -0
- package/sdk/ios/usr/include/dispatch/dispatch.h +114 -0
- package/sdk/ios/usr/include/dlfcn.h +16 -0
- package/sdk/ios/usr/include/errno.h +24 -0
- package/sdk/ios/usr/include/execinfo.h +11 -0
- package/sdk/ios/usr/include/fcntl.h +23 -0
- package/sdk/ios/usr/include/i386/_endian.h +105 -0
- package/sdk/ios/usr/include/i386/_mcontext.h +216 -0
- package/sdk/ios/usr/include/i386/_param.h +49 -0
- package/sdk/ios/usr/include/i386/_types.h +149 -0
- package/sdk/ios/usr/include/i386/endian.h +89 -0
- package/sdk/ios/usr/include/i386/signal.h +47 -0
- package/sdk/ios/usr/include/libkern/OSAtomic.h +51 -0
- package/sdk/ios/usr/include/libkern/OSAtomicDeprecated.h +1267 -0
- package/sdk/ios/usr/include/libkern/OSAtomicQueue.h +115 -0
- package/sdk/ios/usr/include/libkern/OSSpinLockDeprecated.h +212 -0
- package/sdk/ios/usr/include/libkern/_OSByteOrder.h +125 -0
- package/sdk/ios/usr/include/libkern/arm/_OSByteOrder.h +99 -0
- package/sdk/ios/usr/include/libkern/i386/_OSByteOrder.h +110 -0
- package/sdk/ios/usr/include/limits.h +4 -0
- package/sdk/ios/usr/include/mach/arm/_structs.h +741 -0
- package/sdk/ios/usr/include/mach/boolean.h +4 -0
- package/sdk/ios/usr/include/mach/exception_types.h +40 -0
- package/sdk/ios/usr/include/mach/host_info.h +200 -0
- package/sdk/ios/usr/include/mach/i386/_structs.h +1316 -0
- package/sdk/ios/usr/include/mach/kern_return.h +61 -0
- package/sdk/ios/usr/include/mach/mach.h +16 -0
- package/sdk/ios/usr/include/mach/mach_error.h +10 -0
- package/sdk/ios/usr/include/mach/mach_host.h +18 -0
- package/sdk/ios/usr/include/mach/mach_init.h +15 -0
- package/sdk/ios/usr/include/mach/mach_port.h +11 -0
- package/sdk/ios/usr/include/mach/mach_time.h +14 -0
- package/sdk/ios/usr/include/mach/mach_types.h +20 -0
- package/sdk/ios/usr/include/mach/machine/_structs.h +40 -0
- package/sdk/ios/usr/include/mach/machine.h +144 -0
- package/sdk/ios/usr/include/mach/task.h +14 -0
- package/sdk/ios/usr/include/mach/task_info.h +23 -0
- package/sdk/ios/usr/include/mach/task_policy.h +29 -0
- package/sdk/ios/usr/include/mach/thread_act.h +12 -0
- package/sdk/ios/usr/include/mach/thread_info.h +32 -0
- package/sdk/ios/usr/include/mach/time_value.h +4 -0
- package/sdk/ios/usr/include/mach/vm_prot.h +8 -0
- package/sdk/ios/usr/include/mach/vm_region.h +43 -0
- package/sdk/ios/usr/include/mach/vm_statistics.h +491 -0
- package/sdk/ios/usr/include/mach/vm_types.h +8 -0
- package/sdk/ios/usr/include/mach-o/arch.h +21 -0
- package/sdk/ios/usr/include/mach-o/dyld.h +16 -0
- package/sdk/ios/usr/include/mach-o/dyld_images.h +71 -0
- package/sdk/ios/usr/include/mach-o/getsect.h +17 -0
- package/sdk/ios/usr/include/mach-o/loader.h +158 -0
- package/sdk/ios/usr/include/mach-o/nlist.h +38 -0
- package/sdk/ios/usr/include/mach-o/stab.h +33 -0
- package/sdk/ios/usr/include/mach-o/utils.h +10 -0
- package/sdk/ios/usr/include/machine/_endian.h +42 -0
- package/sdk/ios/usr/include/machine/_mcontext.h +39 -0
- package/sdk/ios/usr/include/machine/_param.h +39 -0
- package/sdk/ios/usr/include/machine/_types.h +39 -0
- package/sdk/ios/usr/include/machine/endian.h +42 -0
- package/sdk/ios/usr/include/machine/signal.h +39 -0
- package/sdk/ios/usr/include/machine/types.h +42 -0
- package/sdk/ios/usr/include/math.h +5 -0
- package/sdk/ios/usr/include/module.modulemap +4 -0
- package/sdk/ios/usr/include/net/if.h +20 -0
- package/sdk/ios/usr/include/net/if_dl.h +10 -0
- package/sdk/ios/usr/include/net/if_var.h +15 -0
- package/sdk/ios/usr/include/net/net_kev.h +100 -0
- package/sdk/ios/usr/include/netdb.h +5 -0
- package/sdk/ios/usr/include/netinet/in.h +670 -0
- package/sdk/ios/usr/include/netinet6/in6.h +676 -0
- package/sdk/ios/usr/include/notify.h +45 -0
- package/sdk/ios/usr/include/notify_keys.h +17 -0
- package/sdk/ios/usr/include/objc/NSObject.h +79 -0
- package/sdk/ios/usr/include/os/availability.h +140 -0
- package/sdk/ios/usr/include/os/lock.h +24 -0
- package/sdk/ios/usr/include/os/log.h +77 -0
- package/sdk/ios/usr/include/os/object.h +13 -0
- package/sdk/ios/usr/include/peach/darwin.h +6 -0
- package/sdk/ios/usr/include/peach/netdb.h +316 -0
- package/sdk/ios/usr/include/peach/pthread.h +19 -0
- package/sdk/ios/usr/include/pthread.h +4 -0
- package/sdk/ios/usr/include/secure/_common.h +45 -0
- package/sdk/ios/usr/include/secure/_stdio.h +130 -0
- package/sdk/ios/usr/include/signal.h +132 -0
- package/sdk/ios/usr/include/stdint.h +205 -0
- package/sdk/ios/usr/include/stdio.h +65 -0
- package/sdk/ios/usr/include/stdlib.h +17 -0
- package/sdk/ios/usr/include/string.h +8 -0
- package/sdk/ios/usr/include/sys/__endian.h +108 -0
- package/sdk/ios/usr/include/sys/_endian.h +152 -0
- package/sdk/ios/usr/include/sys/_posix_availability.h +73 -0
- package/sdk/ios/usr/include/sys/_pthread/_pthread_attr_t.h +32 -0
- package/sdk/ios/usr/include/sys/_pthread/_pthread_t.h +32 -0
- package/sdk/ios/usr/include/sys/_pthread/_pthread_types.h +120 -0
- package/sdk/ios/usr/include/sys/_symbol_aliasing.h +1093 -0
- package/sdk/ios/usr/include/sys/_types/_errno_t.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_filesec_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_gid_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_in_addr_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_in_port_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_ino_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_int16_t.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_int32_t.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_int64_t.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_int8_t.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_intptr_t.h +33 -0
- package/sdk/ios/usr/include/sys/_types/_iovec_t.h +35 -0
- package/sdk/ios/usr/include/sys/_types/_mode_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_null.h +54 -0
- package/sdk/ios/usr/include/sys/_types/_o_dsync.h +30 -0
- package/sdk/ios/usr/include/sys/_types/_o_sync.h +30 -0
- package/sdk/ios/usr/include/sys/_types/_off_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_pid_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_ptrdiff_t.h +56 -0
- package/sdk/ios/usr/include/sys/_types/_s_ifmt.h +74 -0
- package/sdk/ios/usr/include/sys/_types/_sa_family_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_seek_set.h +51 -0
- package/sdk/ios/usr/include/sys/_types/_sigaltstack.h +50 -0
- package/sdk/ios/usr/include/sys/_types/_sigset_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_size_t.h +56 -0
- package/sdk/ios/usr/include/sys/_types/_socklen_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_ssize_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_timespec.h +38 -0
- package/sdk/ios/usr/include/sys/_types/_timeval32.h +3 -0
- package/sdk/ios/usr/include/sys/_types/_u_int16_t.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_u_int32_t.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_u_int64_t.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_u_int8_t.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_ucontext.h +59 -0
- package/sdk/ios/usr/include/sys/_types/_uid_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_uintptr_t.h +37 -0
- package/sdk/ios/usr/include/sys/_types/_va_list.h +49 -0
- package/sdk/ios/usr/include/sys/_types/_wchar_t.h +59 -0
- package/sdk/ios/usr/include/sys/_types.h +103 -0
- package/sdk/ios/usr/include/sys/appleapiopts.h +61 -0
- package/sdk/ios/usr/include/sys/cdefs.h +341 -0
- package/sdk/ios/usr/include/sys/constrained_ctypes.h +622 -0
- package/sdk/ios/usr/include/sys/dirent.h +141 -0
- package/sdk/ios/usr/include/sys/errno.h +271 -0
- package/sdk/ios/usr/include/sys/fcntl.h +649 -0
- package/sdk/ios/usr/include/sys/mman.h +273 -0
- package/sdk/ios/usr/include/sys/proc.h +65 -0
- package/sdk/ios/usr/include/sys/qos.h +61 -0
- package/sdk/ios/usr/include/sys/signal.h +394 -0
- package/sdk/ios/usr/include/sys/socket.h +752 -0
- package/sdk/ios/usr/include/sys/stdio.h +61 -0
- package/sdk/ios/usr/include/sys/sysctl.h +74 -0
- package/sdk/ios/usr/include/sys/syslimits.h +11 -0
- package/sdk/ios/usr/include/sys/time.h +5 -0
- package/sdk/ios/usr/include/sys/types.h +21 -0
- package/sdk/ios/usr/include/sys/ucontext.h +41 -0
- package/sdk/ios/usr/include/sys/xattr.h +50 -0
- package/sdk/ios/usr/include/time.h +2 -0
- package/sdk/ios/usr/include/unistd.h +3 -0
- package/sdk/ios/usr/include/uuid/uuid.h +19 -0
- package/sdk/ios/usr/include/xlocale/_stdio.h +85 -0
- package/sdk/ios/usr/lib/swift/CoreGraphics.swiftmodule/arm64-apple-ios-simulator.swiftinterface +8 -0
- package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +51 -0
- package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +20 -0
- package/sdk/ios/wasm/include/dlfcn.h +3 -0
- package/sdk/ios/wasm/include/netdb.h +4 -0
- package/sdk/ios/wasm/include/pthread.h +3 -0
- package/sdk/ios/wasm/include/stdlib.h +3 -0
- package/sdk/ios/wasm/include/string.h +3 -0
- package/sdk/ios/wasm/include/sys/socket.h +7 -0
- package/sdk/ios/wasm/include/sys/types.h +4 -0
- package/sdk/ios/wasm/include/sys/ucontext.h +38 -0
- package/src/cli-runtime.ts +5 -5
- package/src/conformance-comparison-contract.ts +146 -0
- package/src/conformance-pixel-comparison.ts +327 -0
- package/src/device-catalog.ts +12 -3
- package/src/material-symbol-fonts.ts +107 -0
- package/src/stub-pattern-matcher.ts +4 -0
- package/src/swift-compile.ts +517 -189
- package/src/swift-compiler-digest.ts +6 -2
- package/src/swift-distribution.ts +2 -1
- package/src/swift-host.ts +26 -3
- package/src/swift-objc-compile.ts +72 -97
- package/src/swift-objc-import.ts +47 -11
- package/src/swift-objc-metadata.ts +54 -7
- package/src/swift-objc-sdk-tree.ts +17 -0
- package/src/swift-objc-sdk.ts +27 -24178
- package/src/swift-objc-standin.ts +4 -2
- package/src/swift-standins.ts +2 -2
- package/src/swift-toolchain.ts +36 -0
- package/src/swift-vite-lifetime.ts +42 -0
- package/src/swiftContract.ts +54 -0
- package/src/vite-plugin-one.ts +36 -15
- package/src/vite-plugin-swift.ts +21 -2
- package/src/xcode-header-search.ts +114 -0
- package/src/xcode-project.ts +103 -9
package/src/swift-compile.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
renameSync,
|
|
17
17
|
rmSync,
|
|
18
18
|
statSync,
|
|
19
|
+
utimesSync,
|
|
19
20
|
writeFileSync,
|
|
20
21
|
} from 'node:fs'
|
|
21
22
|
import os from 'node:os'
|
|
@@ -34,7 +35,11 @@ import {
|
|
|
34
35
|
} from './swift-distribution-contract'
|
|
35
36
|
import { swiftIcuAsset, type SwiftIcuAsset } from './swift-icu'
|
|
36
37
|
import { swiftObjCExports } from './swift-objc-export'
|
|
37
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
SwiftObjCImportError,
|
|
40
|
+
swiftObjCImports,
|
|
41
|
+
swiftObjCPrivateImports,
|
|
42
|
+
} from './swift-objc-import'
|
|
38
43
|
import { validateObjcPeerStartupLibraries } from './swift-objc-metadata'
|
|
39
44
|
import { materializeObjcSdk, objcView } from './swift-objc-standin'
|
|
40
45
|
import {
|
|
@@ -50,8 +55,10 @@ import {
|
|
|
50
55
|
} from './swift-package'
|
|
51
56
|
import { withSwiftRootLock, type SwiftRootLease } from './swift-root-lock'
|
|
52
57
|
import {
|
|
58
|
+
sourceSwiftCheckout,
|
|
53
59
|
swiftEnvironment,
|
|
54
60
|
swiftSdkOptions,
|
|
61
|
+
swiftSourceSdk,
|
|
55
62
|
swiftToolchain,
|
|
56
63
|
type SwiftWasmSdk,
|
|
57
64
|
} from './swift-toolchain'
|
|
@@ -65,6 +72,7 @@ import {
|
|
|
65
72
|
type SwiftObjCPeerStartup,
|
|
66
73
|
type SwiftProjectPreparation,
|
|
67
74
|
} from './swiftContract'
|
|
75
|
+
import { writeXcodeHeaderSearch } from './xcode-header-search'
|
|
68
76
|
import type { SwiftImageUpload } from './swift-submit'
|
|
69
77
|
import type { SwiftResourceBundle } from './swiftContract'
|
|
70
78
|
|
|
@@ -178,9 +186,15 @@ const SWIFTPM_PROGRESS = /^\[\d+\/\d+\] /
|
|
|
178
186
|
const SWIFTPM_NOISE =
|
|
179
187
|
/^(?:\[\d+\/\d+\] |Building for production\.\.\.$|warning: '--build-system native' has been deprecated)/
|
|
180
188
|
|
|
181
|
-
// compiler jobs match the fixture builder's cap to fit a 16GiB Linux slot
|
|
189
|
+
// compiler jobs match the fixture builder's cap to fit a 16GiB Linux slot, and
|
|
190
|
+
// never exceed the cores an admitted build scope granted (TM_EXEC_CPU_CORES).
|
|
191
|
+
const admittedCores = Number(process.env.TM_EXEC_CPU_CORES)
|
|
182
192
|
const BUILD_JOBS = String(
|
|
183
|
-
Math.min(
|
|
193
|
+
Math.min(
|
|
194
|
+
4,
|
|
195
|
+
Math.max(1, Math.floor(os.availableParallelism() / 2)),
|
|
196
|
+
Number.isInteger(admittedCores) && admittedCores > 0 ? admittedCores : 4,
|
|
197
|
+
),
|
|
184
198
|
)
|
|
185
199
|
|
|
186
200
|
export interface SwiftCompileInput {
|
|
@@ -259,21 +273,11 @@ export function swiftDistributionAt(root: string): SwiftDistributionManifest | n
|
|
|
259
273
|
/** the wasm SDK a module root compiles with: a distribution's manifest names
|
|
260
274
|
* it, a source checkout's toolchain.json pins it. */
|
|
261
275
|
export function swiftModuleSdk(root: string): SwiftWasmSdk {
|
|
262
|
-
const pin
|
|
263
|
-
swiftDistributionAt(root) ??
|
|
264
|
-
JSON.parse(readFileSync(path.join(root, 'toolchain.json'), 'utf8'))
|
|
265
|
-
if (
|
|
266
|
-
!pin ||
|
|
267
|
-
typeof pin !== 'object' ||
|
|
268
|
-
typeof Reflect.get(pin, 'wasmSdkId') !== 'string' ||
|
|
269
|
-
typeof Reflect.get(pin, 'wasmSdkUrl') !== 'string' ||
|
|
270
|
-
typeof Reflect.get(pin, 'wasmSdkChecksum') !== 'string'
|
|
271
|
-
)
|
|
272
|
-
throw new Error(`${root} pins no wasm SDK id, url and checksum`)
|
|
276
|
+
const pin = swiftDistributionAt(root) ?? swiftSourceSdk(root)
|
|
273
277
|
return {
|
|
274
|
-
wasmSdkId:
|
|
275
|
-
wasmSdkUrl:
|
|
276
|
-
wasmSdkChecksum:
|
|
278
|
+
wasmSdkId: pin.wasmSdkId,
|
|
279
|
+
wasmSdkUrl: pin.wasmSdkUrl,
|
|
280
|
+
wasmSdkChecksum: pin.wasmSdkChecksum,
|
|
277
281
|
}
|
|
278
282
|
}
|
|
279
283
|
|
|
@@ -368,7 +372,7 @@ export function swiftMacroPlugins(moduleRoot: string): {
|
|
|
368
372
|
}
|
|
369
373
|
}
|
|
370
374
|
|
|
371
|
-
async function ensureMacroPlugins(
|
|
375
|
+
export async function ensureMacroPlugins(
|
|
372
376
|
moduleRoot: string,
|
|
373
377
|
toolchainBin: string,
|
|
374
378
|
release: string,
|
|
@@ -820,7 +824,7 @@ const EXECUTABLE_LINK_FLAGS = ` "-Xclang-linker", "-O0",
|
|
|
820
824
|
const REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n'
|
|
821
825
|
|
|
822
826
|
/** bump with any change to the emitted multi-target manifest text. */
|
|
823
|
-
export const MULTI_MANIFEST_VERSION =
|
|
827
|
+
export const MULTI_MANIFEST_VERSION = 40
|
|
824
828
|
|
|
825
829
|
// build-cli replaces this in every bundle; source runs read the files directly.
|
|
826
830
|
declare const __SWIFT_COMPILER_DIGEST__: string | undefined
|
|
@@ -909,6 +913,14 @@ interface SwiftNativeTargetPlan {
|
|
|
909
913
|
// target and compiled by the downstream implementation target.
|
|
910
914
|
lateSources: string[]
|
|
911
915
|
mixed?: boolean
|
|
916
|
+
clang?: {
|
|
917
|
+
modulemap: string
|
|
918
|
+
sources: string[]
|
|
919
|
+
flags: string[]
|
|
920
|
+
cxxFlags: string[]
|
|
921
|
+
importFlags: string[]
|
|
922
|
+
objc: boolean
|
|
923
|
+
}
|
|
912
924
|
exclude?: string[]
|
|
913
925
|
groups?: { name: string; sources: string[]; flags: string[]; cxxFlags: string[] }[]
|
|
914
926
|
late?: { name: string; producers: string[] }
|
|
@@ -919,7 +931,9 @@ export function emitSwiftPackageManifest(args: {
|
|
|
919
931
|
cxxLanguageStandard?: string
|
|
920
932
|
native?: Map<string, SwiftNativeTargetPlan>
|
|
921
933
|
headerDirectory?: string
|
|
922
|
-
objcExports?: { modules: Set<string>; flags: string[] }
|
|
934
|
+
objcExports?: { modules: Set<string>; flags: string[]; rootModule: string }
|
|
935
|
+
/** the objective-c runtime and sdk flags every original native unit compiles with. */
|
|
936
|
+
nativeFlags?: string[]
|
|
923
937
|
siblings: Map<string, string[]>
|
|
924
938
|
moduleRoot: string
|
|
925
939
|
oneModule?: boolean
|
|
@@ -987,6 +1001,9 @@ export function emitSwiftPackageManifest(args: {
|
|
|
987
1001
|
.join('')
|
|
988
1002
|
const executable = targets.find((target) => target.executable)
|
|
989
1003
|
if (!executable) throw new Error('swift-compile: no executable target to emit')
|
|
1004
|
+
const linkedNativeModules = [...(args.native?.entries() ?? [])].flatMap(
|
|
1005
|
+
([name, value]) => (value.clang ? [name] : []),
|
|
1006
|
+
)
|
|
990
1007
|
// each target compiles in the language mode and default isolation its
|
|
991
1008
|
// author declared, the way xcode builds the same package.
|
|
992
1009
|
const stanza = (target: SwiftPackageTarget): string => {
|
|
@@ -998,9 +1015,11 @@ export function emitSwiftPackageManifest(args: {
|
|
|
998
1015
|
? ' .defaultIsolation(MainActor.self),'
|
|
999
1016
|
: ''
|
|
1000
1017
|
const interoperability = target.cxxInterop ? ' .interoperabilityMode(.Cxx),' : ''
|
|
1001
|
-
const exports =
|
|
1002
|
-
|
|
1003
|
-
|
|
1018
|
+
const exports =
|
|
1019
|
+
args.objcExports?.modules.has(target.name) ||
|
|
1020
|
+
args.objcExports?.rootModule === target.name
|
|
1021
|
+
? ' .enableExperimentalFeature("Extern"),'
|
|
1022
|
+
: ''
|
|
1004
1023
|
const defines = (target.defines ?? [])
|
|
1005
1024
|
.map((name) => ` .define(${JSON.stringify(name)}),`)
|
|
1006
1025
|
.join('')
|
|
@@ -1025,6 +1044,21 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1025
1044
|
`, "-Xfrontend", "-import-module", "-Xfrontend", ${JSON.stringify(swiftTargetModuleName(name))}`,
|
|
1026
1045
|
)
|
|
1027
1046
|
.join('')
|
|
1047
|
+
const importContext = new Set<string>()
|
|
1048
|
+
const includeImportContext = (name: string): void => {
|
|
1049
|
+
if (importContext.has(name)) return
|
|
1050
|
+
importContext.add(name)
|
|
1051
|
+
for (const dependency of siblings.get(name) ?? []) includeImportContext(dependency)
|
|
1052
|
+
}
|
|
1053
|
+
for (const dependency of [
|
|
1054
|
+
...(siblings.get(target.name) ?? []),
|
|
1055
|
+
...(target.executable ? linkedNativeModules : []),
|
|
1056
|
+
])
|
|
1057
|
+
includeImportContext(dependency)
|
|
1058
|
+
const nativeImportFlags = [...importContext]
|
|
1059
|
+
.flatMap((name) => args.native?.get(name)?.clang?.importFlags ?? [])
|
|
1060
|
+
.map((flag) => `, "-Xcc", ${JSON.stringify(flag)}`)
|
|
1061
|
+
.join('')
|
|
1028
1062
|
const header =
|
|
1029
1063
|
args.headerDirectory &&
|
|
1030
1064
|
[...(args.native?.values() ?? [])].some((value) =>
|
|
@@ -1032,13 +1066,14 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1032
1066
|
)
|
|
1033
1067
|
? `, "-emit-objc-header-path", ${JSON.stringify(path.join(args.headerDirectory, `${target.name}-${args.objcExports?.modules.has(target.name) ? 'Cxx' : 'Swift'}.h`))}`
|
|
1034
1068
|
: ''
|
|
1035
|
-
const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${exports} .unsafeFlags(["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ''}${imports}${nativeImports}${header}])]`
|
|
1069
|
+
const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${exports} .unsafeFlags(["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ''}${imports}${nativeImports}${nativeImportFlags}${header}])]`
|
|
1036
1070
|
const deps = [
|
|
1037
1071
|
...new Set([
|
|
1038
1072
|
...(target.executable
|
|
1039
1073
|
? [
|
|
1040
1074
|
...new Set([
|
|
1041
1075
|
...(args.objcExports?.modules ?? []),
|
|
1076
|
+
...linkedNativeModules,
|
|
1042
1077
|
...[...(args.native?.values() ?? [])].flatMap(
|
|
1043
1078
|
(value) => value.late?.producers ?? [],
|
|
1044
1079
|
),
|
|
@@ -1098,7 +1133,7 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1098
1133
|
const link = target.executable
|
|
1099
1134
|
? `,
|
|
1100
1135
|
linkerSettings: [
|
|
1101
|
-
${
|
|
1136
|
+
${librarySettings.map((setting) => `${setting},`).join('\n ')}
|
|
1102
1137
|
.unsafeFlags([
|
|
1103
1138
|
${REACTOR_FLAG}${EXECUTABLE_LINK_FLAGS} "-Xlinker", "--export-if-defined=__main_argc_argv"${args.objcExports ? ', "-Xlinker", "--fatal-warnings"' : ''}${library},
|
|
1104
1139
|
]),
|
|
@@ -1108,17 +1143,29 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1108
1143
|
? `,
|
|
1109
1144
|
linkerSettings: [${librarySettings.join(', ')}]`
|
|
1110
1145
|
: ''
|
|
1146
|
+
const nativeSettings = native?.clang
|
|
1147
|
+
? [
|
|
1148
|
+
`cSettings: [.unsafeFlags(${JSON.stringify([...(args.objcExports?.flags ?? args.nativeFlags ?? []), ...native.clang.flags])})]`,
|
|
1149
|
+
`cxxSettings: [${defines} .unsafeFlags(${JSON.stringify(['-fno-cxx-modules', ...(args.objcExports?.flags ?? args.nativeFlags ?? []), ...native.clang.cxxFlags])})]`,
|
|
1150
|
+
].join(', ')
|
|
1151
|
+
: `${args.objcExports ? `cSettings: [.unsafeFlags(${JSON.stringify(args.objcExports.flags)})], ` : ''}cxxSettings: [${defines} .unsafeFlags(["-fno-cxx-modules"])]`
|
|
1111
1152
|
return [
|
|
1112
1153
|
` ${kind}(`,
|
|
1113
1154
|
` name: "${target.name}",`,
|
|
1114
1155
|
` dependencies: [${deps}],`,
|
|
1115
|
-
` path:
|
|
1156
|
+
` path: ${JSON.stringify(native?.clang ? '.' : target.path)},`,
|
|
1116
1157
|
...(native
|
|
1117
1158
|
? [` exclude: ${JSON.stringify(native.exclude ?? native.lateSources)},`]
|
|
1118
1159
|
: []),
|
|
1160
|
+
...(native?.clang
|
|
1161
|
+
? [
|
|
1162
|
+
` sources: ${JSON.stringify(native.clang.sources.map((source) => path.posix.join(native.path, source)))},`,
|
|
1163
|
+
` publicHeadersPath: ${JSON.stringify(path.posix.dirname(native.clang.modulemap))},`,
|
|
1164
|
+
]
|
|
1165
|
+
: []),
|
|
1119
1166
|
// the native backend supplies dependency module maps without their
|
|
1120
1167
|
// compiled modules. textual c++ includes keep those dependencies usable.
|
|
1121
|
-
` ${clang ?
|
|
1168
|
+
` ${clang ? nativeSettings : swiftSettings}${link}`,
|
|
1122
1169
|
` ),`,
|
|
1123
1170
|
].join('\n')
|
|
1124
1171
|
}
|
|
@@ -1159,14 +1206,10 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1159
1206
|
).flatMap((group) => [
|
|
1160
1207
|
` .target(name: ${JSON.stringify(group.name)},`,
|
|
1161
1208
|
` dependencies: ${JSON.stringify(args.native?.get(name)?.mixed ? [] : [name])},`,
|
|
1162
|
-
` path: ${JSON.stringify(native.path)},`,
|
|
1163
|
-
` sources: ${JSON.stringify(group.sources)},`,
|
|
1164
|
-
` publicHeadersPath:
|
|
1165
|
-
...(args.objcExports
|
|
1166
|
-
? [
|
|
1167
|
-
` cSettings: [.unsafeFlags(${JSON.stringify([...args.objcExports.flags, ...group.flags])})],`,
|
|
1168
|
-
]
|
|
1169
|
-
: []),
|
|
1209
|
+
` path: ${JSON.stringify(native.clang ? '.' : native.path)},`,
|
|
1210
|
+
` sources: ${JSON.stringify(native.clang ? group.sources.map((source) => path.posix.join(native.path, source)) : group.sources)},`,
|
|
1211
|
+
` publicHeadersPath: ${JSON.stringify(native.clang ? path.posix.dirname(native.clang.modulemap) : 'include')},`,
|
|
1212
|
+
` cSettings: [.unsafeFlags(${JSON.stringify([...(args.objcExports?.flags ?? args.nativeFlags ?? []), ...group.flags])})],`,
|
|
1170
1213
|
` cxxSettings: [.unsafeFlags(${JSON.stringify(['-fno-cxx-modules', '-I', native.includeDirectory, '-I', args.headerDirectory, ...group.cxxFlags])})]),`,
|
|
1171
1214
|
])
|
|
1172
1215
|
: [],
|
|
@@ -5933,6 +5976,9 @@ export function prepareSwiftDependency(source: string, destination: string): voi
|
|
|
5933
5976
|
copy(source, destination)
|
|
5934
5977
|
}
|
|
5935
5978
|
|
|
5979
|
+
// where a mixed native target compiles units whose paths swiftpm would hide.
|
|
5980
|
+
const HIDDEN_UNITS = 'PeachHiddenUnits'
|
|
5981
|
+
|
|
5936
5982
|
export function writeSwiftProject(
|
|
5937
5983
|
layout: SwiftProjectLayout,
|
|
5938
5984
|
input: SwiftCompileInput,
|
|
@@ -5999,6 +6045,87 @@ export function writeSwiftProject(
|
|
|
5999
6045
|
foreignTypes: Map<string, string>
|
|
6000
6046
|
}
|
|
6001
6047
|
>()
|
|
6048
|
+
const objcProducers = new Set<string>()
|
|
6049
|
+
const targetStagedFiles = new Map<string, Map<string, string | Buffer | undefined>>()
|
|
6050
|
+
const stageTargetFile = (
|
|
6051
|
+
target: string,
|
|
6052
|
+
file: string,
|
|
6053
|
+
contents: string | Buffer,
|
|
6054
|
+
options?: { allowExisting?: boolean },
|
|
6055
|
+
) => {
|
|
6056
|
+
const relative = path.relative(layout.root, file).split(path.sep).join(path.posix.sep)
|
|
6057
|
+
const prior = files.has(file)
|
|
6058
|
+
? files.get(file)
|
|
6059
|
+
: Object.hasOwn(input.files, relative)
|
|
6060
|
+
? input.files[relative]
|
|
6061
|
+
: undefined
|
|
6062
|
+
if (!options?.allowExisting && prior !== undefined)
|
|
6063
|
+
throw new Error(`target ${target} already contains generated output ${relative}`)
|
|
6064
|
+
const staged =
|
|
6065
|
+
targetStagedFiles.get(target) ?? new Map<string, string | Buffer | undefined>()
|
|
6066
|
+
if (!staged.has(file)) staged.set(file, prior)
|
|
6067
|
+
targetStagedFiles.set(target, staged)
|
|
6068
|
+
files.set(file, contents)
|
|
6069
|
+
}
|
|
6070
|
+
const targetEntries = (target: SwiftPackageTarget) => {
|
|
6071
|
+
const prefix = target.path === '.' ? '' : `${target.path}/`
|
|
6072
|
+
return Object.entries(input.files).filter(
|
|
6073
|
+
([file]) =>
|
|
6074
|
+
file.startsWith(prefix) &&
|
|
6075
|
+
!targets.some(
|
|
6076
|
+
(candidate) =>
|
|
6077
|
+
candidate.name !== target.name &&
|
|
6078
|
+
candidate.path !== '.' &&
|
|
6079
|
+
candidate.path.startsWith(prefix) &&
|
|
6080
|
+
file.startsWith(`${candidate.path}/`),
|
|
6081
|
+
),
|
|
6082
|
+
)
|
|
6083
|
+
}
|
|
6084
|
+
const failTargetPreparation = (target: SwiftPackageTarget, message: string) => {
|
|
6085
|
+
const prefix = target.path === '.' ? '' : `${target.path}/`
|
|
6086
|
+
const entries = targetEntries(target)
|
|
6087
|
+
const swift = entries.some(([file]) => file.endsWith('.swift'))
|
|
6088
|
+
targetFailures.push(`${target.name}: ${message}`)
|
|
6089
|
+
imports.delete(target.name)
|
|
6090
|
+
objcProducers.delete(target.name)
|
|
6091
|
+
for (const [file, prior] of targetStagedFiles.get(target.name) ?? []) {
|
|
6092
|
+
if (prior === undefined) files.delete(file)
|
|
6093
|
+
else files.set(file, prior)
|
|
6094
|
+
}
|
|
6095
|
+
targetStagedFiles.delete(target.name)
|
|
6096
|
+
if (
|
|
6097
|
+
entries.some(([file]) => /\.(?:c|cc|cpp|cxx|m|mm)$/.test(file)) &&
|
|
6098
|
+
(swift ||
|
|
6099
|
+
(input.nativeTargets?.some((value) => value.name === target.name) &&
|
|
6100
|
+
entries.some(([file]) => /\.mm?$/.test(file))))
|
|
6101
|
+
) {
|
|
6102
|
+
if (!swift) {
|
|
6103
|
+
const unprepared = path.join(
|
|
6104
|
+
layout.root,
|
|
6105
|
+
target.path,
|
|
6106
|
+
'PeachUnprepared.generated.swift',
|
|
6107
|
+
)
|
|
6108
|
+
if (
|
|
6109
|
+
!files.has(unprepared) &&
|
|
6110
|
+
!Object.hasOwn(input.files, `${prefix}PeachUnprepared.generated.swift`)
|
|
6111
|
+
)
|
|
6112
|
+
files.set(
|
|
6113
|
+
unprepared,
|
|
6114
|
+
`// ${target.name} failed preparation; its dependents import nothing from it.\n`,
|
|
6115
|
+
)
|
|
6116
|
+
}
|
|
6117
|
+
native.set(target.name, {
|
|
6118
|
+
mixed: true,
|
|
6119
|
+
path: target.path,
|
|
6120
|
+
includeDirectory: path.join(layout.root, target.path, 'include'),
|
|
6121
|
+
sources: [],
|
|
6122
|
+
lateSources: [],
|
|
6123
|
+
exclude: entries
|
|
6124
|
+
.filter(([file]) => !file.endsWith('.swift') && !file.endsWith('.metal'))
|
|
6125
|
+
.map(([file]) => file.slice(prefix.length)),
|
|
6126
|
+
})
|
|
6127
|
+
}
|
|
6128
|
+
}
|
|
6002
6129
|
// headers keep their original project paths. product headers additionally
|
|
6003
6130
|
// occupy the same Module/Header.h namespace that xcode publishes.
|
|
6004
6131
|
for (const settings of input.nativeTargets ?? []) {
|
|
@@ -6021,21 +6148,39 @@ export function writeSwiftProject(
|
|
|
6021
6148
|
writeFileSync(destination, contents)
|
|
6022
6149
|
}
|
|
6023
6150
|
}
|
|
6151
|
+
// xcode's header maps and product header overlay, naming the headers
|
|
6152
|
+
// written above, bound into every clang command of their target.
|
|
6153
|
+
const nativeTargets = input.nativeTargets ?? []
|
|
6154
|
+
const fromInputRoot = (file: string) =>
|
|
6155
|
+
file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`)
|
|
6156
|
+
? path.join(layout.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1))
|
|
6157
|
+
: file
|
|
6158
|
+
const headerSearch = writeXcodeHeaderSearch(
|
|
6159
|
+
path.join(layout.root, '.build', 'peach-xcode-headers'),
|
|
6160
|
+
nativeTargets.map((settings) => ({
|
|
6161
|
+
headerMaps: settings.headerMaps.map((map) => ({
|
|
6162
|
+
flag: map.flag,
|
|
6163
|
+
entries: map.entries.map(([key, file]): [string, string] => [
|
|
6164
|
+
key,
|
|
6165
|
+
fromInputRoot(file),
|
|
6166
|
+
]),
|
|
6167
|
+
})),
|
|
6168
|
+
productHeaders: Object.fromEntries(
|
|
6169
|
+
Object.entries(settings.productHeaders).map(([product, file]) => [
|
|
6170
|
+
path.join(layout.root, product),
|
|
6171
|
+
path.join(layout.root, file),
|
|
6172
|
+
]),
|
|
6173
|
+
),
|
|
6174
|
+
userHeaderSearchPaths: settings.userHeaderSearchPaths.map((directory) =>
|
|
6175
|
+
path.join(layout.root, directory),
|
|
6176
|
+
),
|
|
6177
|
+
})),
|
|
6178
|
+
)
|
|
6024
6179
|
// declarations are imported before swift can emit the header that native
|
|
6025
6180
|
// implementations consume. give those implementations a downstream target.
|
|
6026
6181
|
for (const target of targets) {
|
|
6027
6182
|
const prefix = target.path === '.' ? '' : `${target.path}/`
|
|
6028
|
-
const entries =
|
|
6029
|
-
([file]) =>
|
|
6030
|
-
file.startsWith(prefix) &&
|
|
6031
|
-
!targets.some(
|
|
6032
|
-
(candidate) =>
|
|
6033
|
-
candidate.name !== target.name &&
|
|
6034
|
-
candidate.path !== '.' &&
|
|
6035
|
-
candidate.path.startsWith(prefix) &&
|
|
6036
|
-
file.startsWith(`${candidate.path}/`),
|
|
6037
|
-
),
|
|
6038
|
-
)
|
|
6183
|
+
const entries = targetEntries(target)
|
|
6039
6184
|
const units = entries.filter(([file]) => /\.(?:c|cc|cpp|cxx|m|mm)$/.test(file))
|
|
6040
6185
|
if (units.length === 0) continue
|
|
6041
6186
|
const settings = input.nativeTargets?.find((value) => value.name === target.name)
|
|
@@ -6043,7 +6188,6 @@ export function writeSwiftProject(
|
|
|
6043
6188
|
entries.some(([file]) => file.endsWith('.swift')) ||
|
|
6044
6189
|
(settings && units.some(([file]) => /\.mm?$/.test(file)))
|
|
6045
6190
|
) {
|
|
6046
|
-
const swift = entries.some(([file]) => file.endsWith('.swift'))
|
|
6047
6191
|
try {
|
|
6048
6192
|
if (!settings)
|
|
6049
6193
|
throw new Error(
|
|
@@ -6082,7 +6226,8 @@ export function writeSwiftProject(
|
|
|
6082
6226
|
.replaceAll(SWIFT_NATIVE_SDK_INCLUDE, sdkInclude),
|
|
6083
6227
|
)
|
|
6084
6228
|
const originalFlags = [
|
|
6085
|
-
...
|
|
6229
|
+
...settings.flags,
|
|
6230
|
+
...headerSearch.flags[nativeTargets.indexOf(settings)]!,
|
|
6086
6231
|
...search,
|
|
6087
6232
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
6088
6233
|
'-F',
|
|
@@ -6132,11 +6277,17 @@ export function writeSwiftProject(
|
|
|
6132
6277
|
const nativeUnits: [string, string][] = accessor
|
|
6133
6278
|
? [...units, [accessorUnit, accessor.body]]
|
|
6134
6279
|
: units
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6280
|
+
// swiftpm drops a listed source inside a hidden directory, which xcode
|
|
6281
|
+
// compiles (a generated unit under .build), so it compiles from a
|
|
6282
|
+
// visible copy in the target.
|
|
6283
|
+
const unitSource = (file: string) => {
|
|
6284
|
+
const relative = file.slice(prefix.length)
|
|
6285
|
+
return relative.split('/').some((part) => part.startsWith('.'))
|
|
6286
|
+
? path.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, '$1%2E'))
|
|
6287
|
+
: relative
|
|
6139
6288
|
}
|
|
6289
|
+
const accessorFlags = accessor ? ['-include', accessorHeader] : []
|
|
6290
|
+
let nativeC = false
|
|
6140
6291
|
if (roots.length) {
|
|
6141
6292
|
const sourceHeaders = path.join(
|
|
6142
6293
|
layout.root,
|
|
@@ -6166,8 +6317,13 @@ export function writeSwiftProject(
|
|
|
6166
6317
|
},
|
|
6167
6318
|
)
|
|
6168
6319
|
const defined = new Set<string>()
|
|
6320
|
+
let objcDeclarations = false
|
|
6169
6321
|
const declarations = (node: unknown): void => {
|
|
6170
6322
|
if (!node || typeof node !== 'object') return
|
|
6323
|
+
if (Reflect.get(node, 'isImplicit') === true) return
|
|
6324
|
+
const kind: unknown = Reflect.get(node, 'kind')
|
|
6325
|
+
if (typeof kind === 'string' && /^ObjC.*Decl$/.test(kind))
|
|
6326
|
+
objcDeclarations = true
|
|
6171
6327
|
const name: unknown = Reflect.get(node, 'name')
|
|
6172
6328
|
if (
|
|
6173
6329
|
Reflect.get(node, 'kind') === 'ObjCInterfaceDecl' &&
|
|
@@ -6179,6 +6335,20 @@ export function writeSwiftProject(
|
|
|
6179
6335
|
if (Array.isArray(children)) for (const child of children) declarations(child)
|
|
6180
6336
|
}
|
|
6181
6337
|
declarations(view.clangAST)
|
|
6338
|
+
// the complete original surface decides the importer, including
|
|
6339
|
+
// declarations absent from the swift symbol graph, such as globals.
|
|
6340
|
+
nativeC =
|
|
6341
|
+
!entries.some(([file]) => file.endsWith('.swift')) &&
|
|
6342
|
+
!objcDeclarations &&
|
|
6343
|
+
view.graphs.every((graph) =>
|
|
6344
|
+
graph.symbols.every(
|
|
6345
|
+
(symbol) =>
|
|
6346
|
+
!symbol.identifier.precise.includes('c:objc(') &&
|
|
6347
|
+
!(symbol.declarationFragments ?? []).some((fragment) =>
|
|
6348
|
+
fragment.preciseIdentifier?.includes('c:objc('),
|
|
6349
|
+
),
|
|
6350
|
+
),
|
|
6351
|
+
)
|
|
6182
6352
|
const foreignTypes = new Map<string, string>()
|
|
6183
6353
|
for (const graph of view.graphs)
|
|
6184
6354
|
for (const symbol of graph.symbols) {
|
|
@@ -6188,21 +6358,38 @@ export function writeSwiftProject(
|
|
|
6188
6358
|
if (nativeName && defined.has(nativeName))
|
|
6189
6359
|
foreignTypes.set(symbol.pathComponents[0]!, nativeName)
|
|
6190
6360
|
}
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6361
|
+
if (!nativeC)
|
|
6362
|
+
imports.set(target.name, {
|
|
6363
|
+
view,
|
|
6364
|
+
classes: [...foreignTypes.values()],
|
|
6365
|
+
headers: roots.map((file) => path.join(layout.root, file)),
|
|
6366
|
+
foreignTypes,
|
|
6367
|
+
})
|
|
6197
6368
|
}
|
|
6198
|
-
const thunks = roots.length ? ['PeachObjCImports.generated.m'] : []
|
|
6369
|
+
const thunks = roots.length && !nativeC ? ['PeachObjCImports.generated.m'] : []
|
|
6199
6370
|
const groups = new Map<
|
|
6200
6371
|
string,
|
|
6201
6372
|
{ name: string; sources: string[]; flags: string[]; cxxFlags: string[] }
|
|
6202
6373
|
>()
|
|
6203
|
-
for (const [file] of nativeUnits) {
|
|
6374
|
+
for (const [file, contents] of nativeUnits) {
|
|
6204
6375
|
const origin = settings?.sourceDirectories[file]
|
|
6205
|
-
|
|
6376
|
+
// the unit also sits at its original path, as xcode compiles it, so a
|
|
6377
|
+
// search path reaching it (an included .c) finds the same file.
|
|
6378
|
+
if (origin) {
|
|
6379
|
+
const original = path.join(layout.root, origin, path.posix.basename(file))
|
|
6380
|
+
mkdirSync(path.dirname(original), { recursive: true })
|
|
6381
|
+
stageTargetFile(target.name, original, contents, { allowExisting: true })
|
|
6382
|
+
}
|
|
6383
|
+
const source = unitSource(file)
|
|
6384
|
+
if (source !== file.slice(prefix.length))
|
|
6385
|
+
stageTargetFile(
|
|
6386
|
+
target.name,
|
|
6387
|
+
path.join(layout.root, target.path, source),
|
|
6388
|
+
contents,
|
|
6389
|
+
{
|
|
6390
|
+
allowExisting: true,
|
|
6391
|
+
},
|
|
6392
|
+
)
|
|
6206
6393
|
const perFile = [
|
|
6207
6394
|
...(origin ? ['-iquote', path.join(layout.root, origin)] : []),
|
|
6208
6395
|
...stageFlags(
|
|
@@ -6216,7 +6403,7 @@ export function writeSwiftProject(
|
|
|
6216
6403
|
.digest('hex')
|
|
6217
6404
|
.slice(0, 12)
|
|
6218
6405
|
const group = groups.get(identity) ?? {
|
|
6219
|
-
name: `${target.name}
|
|
6406
|
+
name: `${target.name}${nativeC ? 'Native' : 'Swift'}Implementation_${identity}`,
|
|
6220
6407
|
sources: [],
|
|
6221
6408
|
flags: [...flags, ...prefixHeader, ...accessorFlags, ...perFile],
|
|
6222
6409
|
cxxFlags: [
|
|
@@ -6230,7 +6417,7 @@ export function writeSwiftProject(
|
|
|
6230
6417
|
...perFile,
|
|
6231
6418
|
],
|
|
6232
6419
|
}
|
|
6233
|
-
group.sources.push(
|
|
6420
|
+
group.sources.push(source)
|
|
6234
6421
|
groups.set(identity, group)
|
|
6235
6422
|
}
|
|
6236
6423
|
if (thunks.length)
|
|
@@ -6241,7 +6428,52 @@ export function writeSwiftProject(
|
|
|
6241
6428
|
cxxFlags: [...flags, '-fobjc-arc'],
|
|
6242
6429
|
})
|
|
6243
6430
|
const include = path.join(layout.root, target.path, 'include')
|
|
6244
|
-
|
|
6431
|
+
if (accessor) {
|
|
6432
|
+
stageTargetFile(target.name, accessorHeader, accessor.header)
|
|
6433
|
+
stageTargetFile(
|
|
6434
|
+
target.name,
|
|
6435
|
+
path.join(layout.root, accessorUnit),
|
|
6436
|
+
accessor.body,
|
|
6437
|
+
)
|
|
6438
|
+
}
|
|
6439
|
+
if (nativeC) {
|
|
6440
|
+
const modulemaps = Object.entries(settings.productHeaders).filter(([product]) =>
|
|
6441
|
+
product.endsWith('/Modules/module.modulemap'),
|
|
6442
|
+
)
|
|
6443
|
+
if (modulemaps.length !== 1)
|
|
6444
|
+
throw new Error(`target ${target.name} requires one original module map`)
|
|
6445
|
+
const [product, original] = modulemaps[0]!
|
|
6446
|
+
const contents = input.files[original]
|
|
6447
|
+
if (contents === undefined)
|
|
6448
|
+
throw new Error(`missing original module map ${original}`)
|
|
6449
|
+
stageTargetFile(target.name, path.join(layout.root, product), contents)
|
|
6450
|
+
const [owner, ...implementations] = groups.values()
|
|
6451
|
+
if (!owner) throw new Error(`target ${target.name} has no original units`)
|
|
6452
|
+
native.set(target.name, {
|
|
6453
|
+
path: target.path,
|
|
6454
|
+
includeDirectory: path.join(layout.root, path.dirname(product)),
|
|
6455
|
+
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
6456
|
+
lateSources: implementations.flatMap((group) => group.sources),
|
|
6457
|
+
exclude: [],
|
|
6458
|
+
clang: {
|
|
6459
|
+
modulemap: product,
|
|
6460
|
+
sources: owner.sources,
|
|
6461
|
+
flags: owner.flags,
|
|
6462
|
+
cxxFlags: owner.cxxFlags,
|
|
6463
|
+
importFlags: flags,
|
|
6464
|
+
objc: units.some(([file]) => /\.mm?$/.test(file)),
|
|
6465
|
+
},
|
|
6466
|
+
...(implementations.length
|
|
6467
|
+
? {
|
|
6468
|
+
groups: implementations,
|
|
6469
|
+
late: { name: `${target.name}NativeImplementation`, producers: [] },
|
|
6470
|
+
}
|
|
6471
|
+
: {}),
|
|
6472
|
+
})
|
|
6473
|
+
continue
|
|
6474
|
+
}
|
|
6475
|
+
stageTargetFile(
|
|
6476
|
+
target.name,
|
|
6245
6477
|
path.join(include, 'module.modulemap'),
|
|
6246
6478
|
`module ${target.name}ImplementationDeclarations { export * }\n`,
|
|
6247
6479
|
)
|
|
@@ -6249,11 +6481,8 @@ export function writeSwiftProject(
|
|
|
6249
6481
|
mixed: true,
|
|
6250
6482
|
path: target.path,
|
|
6251
6483
|
includeDirectory: include,
|
|
6252
|
-
sources: nativeUnits.map(([file]) => file
|
|
6253
|
-
lateSources: [
|
|
6254
|
-
...nativeUnits.map(([file]) => file.slice(prefix.length)),
|
|
6255
|
-
...thunks,
|
|
6256
|
-
],
|
|
6484
|
+
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
6485
|
+
lateSources: [...nativeUnits.map(([file]) => unitSource(file)), ...thunks],
|
|
6257
6486
|
exclude: [
|
|
6258
6487
|
...entries
|
|
6259
6488
|
.filter(([file]) => !file.endsWith('.swift') && !file.endsWith('.metal'))
|
|
@@ -6262,6 +6491,11 @@ export function writeSwiftProject(
|
|
|
6262
6491
|
? [OBJC_RESOURCE_ACCESSOR_HEADER, OBJC_RESOURCE_ACCESSOR_BODY]
|
|
6263
6492
|
: []),
|
|
6264
6493
|
...thunks,
|
|
6494
|
+
...(nativeUnits.some(
|
|
6495
|
+
([file]) => unitSource(file) !== file.slice(prefix.length),
|
|
6496
|
+
)
|
|
6497
|
+
? [HIDDEN_UNITS]
|
|
6498
|
+
: []),
|
|
6265
6499
|
'include',
|
|
6266
6500
|
],
|
|
6267
6501
|
groups: [...groups.values()],
|
|
@@ -6282,23 +6516,7 @@ export function writeSwiftProject(
|
|
|
6282
6516
|
// target that fails to compile, so a failing stand-in would hide the
|
|
6283
6517
|
// other targets' errors, and a missing one breaks every importer.
|
|
6284
6518
|
if (!(error instanceof Error)) throw error
|
|
6285
|
-
|
|
6286
|
-
imports.delete(target.name)
|
|
6287
|
-
if (!swift)
|
|
6288
|
-
files.set(
|
|
6289
|
-
path.join(layout.root, target.path, 'PeachUnprepared.generated.swift'),
|
|
6290
|
-
`// ${target.name} failed preparation; its dependents import nothing from it.\n`,
|
|
6291
|
-
)
|
|
6292
|
-
native.set(target.name, {
|
|
6293
|
-
mixed: true,
|
|
6294
|
-
path: target.path,
|
|
6295
|
-
includeDirectory: path.join(layout.root, target.path, 'include'),
|
|
6296
|
-
sources: [],
|
|
6297
|
-
lateSources: [],
|
|
6298
|
-
exclude: entries
|
|
6299
|
-
.filter(([file]) => !file.endsWith('.swift') && !file.endsWith('.metal'))
|
|
6300
|
-
.map(([file]) => file.slice(prefix.length)),
|
|
6301
|
-
})
|
|
6519
|
+
failTargetPreparation(target, error.message)
|
|
6302
6520
|
}
|
|
6303
6521
|
continue
|
|
6304
6522
|
}
|
|
@@ -6419,67 +6637,11 @@ export function writeSwiftProject(
|
|
|
6419
6637
|
layout.multi ? targets : targets.map((target) => ({ ...target, path: '.' })),
|
|
6420
6638
|
compiled,
|
|
6421
6639
|
)
|
|
6422
|
-
// an application's swift module must precede its native implementations.
|
|
6423
|
-
// the tiny executable calls the original typed entry after both are linked.
|
|
6424
|
-
for (const target of [...targets]) {
|
|
6425
|
-
if (
|
|
6426
|
-
!target.executable ||
|
|
6427
|
-
![...native.values()].some((value) => value.late?.producers.includes(target.name))
|
|
6428
|
-
)
|
|
6429
|
-
continue
|
|
6430
|
-
const prefix = target.path === '.' ? '' : `${target.path}/`
|
|
6431
|
-
const entries = [...compiled].filter(
|
|
6432
|
-
([file]) =>
|
|
6433
|
-
file.startsWith(prefix) &&
|
|
6434
|
-
!targets.some(
|
|
6435
|
-
(candidate) =>
|
|
6436
|
-
candidate.name !== target.name &&
|
|
6437
|
-
candidate.path !== '.' &&
|
|
6438
|
-
candidate.path.startsWith(prefix) &&
|
|
6439
|
-
file.startsWith(`${candidate.path}/`),
|
|
6440
|
-
),
|
|
6441
|
-
)
|
|
6442
|
-
const mains = entries.flatMap(([file, source]) => {
|
|
6443
|
-
const match = /@main\b[\s\S]*?\b(?:struct|class|enum)\s+([A-Za-z_]\w*)/.exec(
|
|
6444
|
-
swiftCodeMask(source),
|
|
6445
|
-
)
|
|
6446
|
-
return match ? [{ file, source, match }] : []
|
|
6447
|
-
})
|
|
6448
|
-
if (mains.length !== 1)
|
|
6449
|
-
throw new Error(
|
|
6450
|
-
`mixed executable ${target.name} requires one typed Swift application entry`,
|
|
6451
|
-
)
|
|
6452
|
-
const main = mains[0]!
|
|
6453
|
-
compiled.set(
|
|
6454
|
-
main.file,
|
|
6455
|
-
main.source.slice(0, main.match.index) +
|
|
6456
|
-
' ' +
|
|
6457
|
-
main.source.slice(main.match.index + 5) +
|
|
6458
|
-
`\n@MainActor public func __peachRunApplication() { ${main.match[1]}.main() }\n`,
|
|
6459
|
-
)
|
|
6460
|
-
const name = `${target.name}Executable`
|
|
6461
|
-
if (targets.some((candidate) => candidate.name === name))
|
|
6462
|
-
throw new Error(`mixed application executable target conflicts with ${name}`)
|
|
6463
|
-
target.executable = false
|
|
6464
|
-
targets.push({
|
|
6465
|
-
...target,
|
|
6466
|
-
name,
|
|
6467
|
-
path: `PeachApplication/${name}`,
|
|
6468
|
-
executable: true,
|
|
6469
|
-
resources: false,
|
|
6470
|
-
dependencies: [{ kind: 'target', name: target.name }],
|
|
6471
|
-
exclude: [],
|
|
6472
|
-
})
|
|
6473
|
-
files.set(
|
|
6474
|
-
path.join(layout.root, `PeachApplication/${name}/Entry.swift`),
|
|
6475
|
-
`import ${swiftTargetModuleName(target.name)}\n@main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }\n`,
|
|
6476
|
-
)
|
|
6477
|
-
}
|
|
6478
6640
|
// genuine objective-c consumers receive declarations and implementations from
|
|
6479
6641
|
// one typed export plan. the swift compiler emits their C function prototypes.
|
|
6480
|
-
const objcProducers = new Set<string>()
|
|
6481
6642
|
for (const name of imports.keys()) objcProducers.add(name)
|
|
6482
|
-
for (const [name, plan] of native)
|
|
6643
|
+
for (const [name, plan] of native) if (plan.clang?.objc) objcProducers.add(name)
|
|
6644
|
+
for (const [, plan] of native) {
|
|
6483
6645
|
if (!plan.late) continue
|
|
6484
6646
|
if (plan.lateSources.some((file) => /\.mm?$/.test(file)))
|
|
6485
6647
|
for (const producer of plan.late.producers) objcProducers.add(producer)
|
|
@@ -6488,24 +6650,16 @@ export function writeSwiftProject(
|
|
|
6488
6650
|
const registrations: string[] = []
|
|
6489
6651
|
const registeredClasses = new Set<string>(['NSObject'])
|
|
6490
6652
|
let rootOwner: string | undefined
|
|
6491
|
-
for (const name of objcProducers) {
|
|
6653
|
+
for (const name of [...objcProducers]) {
|
|
6492
6654
|
const target = targets.find((value) => value.name === name)!
|
|
6493
6655
|
const prefix = target.path === '.' ? '' : `${target.path}/`
|
|
6494
6656
|
let exported: ReturnType<typeof swiftObjCExports>
|
|
6495
6657
|
try {
|
|
6496
6658
|
exported = swiftObjCExports({
|
|
6497
6659
|
module: swiftTargetModuleName(name),
|
|
6498
|
-
sources:
|
|
6660
|
+
sources: targetEntries(target).filter(
|
|
6499
6661
|
([file]) =>
|
|
6500
|
-
file.startsWith(prefix) &&
|
|
6501
6662
|
file.endsWith('.swift') &&
|
|
6502
|
-
!targets.some(
|
|
6503
|
-
(candidate) =>
|
|
6504
|
-
candidate.name !== name &&
|
|
6505
|
-
candidate.path !== '.' &&
|
|
6506
|
-
candidate.path.startsWith(prefix) &&
|
|
6507
|
-
file.startsWith(`${candidate.path}/`),
|
|
6508
|
-
) &&
|
|
6509
6663
|
!target.exclude?.some(
|
|
6510
6664
|
(excluded) =>
|
|
6511
6665
|
file.slice(prefix.length) === excluded ||
|
|
@@ -6520,11 +6674,29 @@ export function writeSwiftProject(
|
|
|
6520
6674
|
} catch (error) {
|
|
6521
6675
|
// its objective-c units then fail on the missing header in the same build.
|
|
6522
6676
|
if (!(error instanceof Error)) throw error
|
|
6523
|
-
|
|
6677
|
+
failTargetPreparation(target, error.message)
|
|
6524
6678
|
continue
|
|
6525
6679
|
}
|
|
6526
6680
|
const original = imports.get(name)
|
|
6527
6681
|
if (!exported && !original) continue
|
|
6682
|
+
let generated: ReturnType<typeof swiftObjCImports> | undefined
|
|
6683
|
+
try {
|
|
6684
|
+
generated =
|
|
6685
|
+
original &&
|
|
6686
|
+
swiftObjCImports(original.view.graphs, {
|
|
6687
|
+
module: swiftTargetModuleName(name),
|
|
6688
|
+
headers: original.headers,
|
|
6689
|
+
classes: original.classes,
|
|
6690
|
+
clangAST: original.view.clangAST,
|
|
6691
|
+
peerTypes: exported?.types,
|
|
6692
|
+
})
|
|
6693
|
+
} catch (error) {
|
|
6694
|
+
// a refused import registers nothing, and the target's swift then fails
|
|
6695
|
+
// on the missing declarations in the same build.
|
|
6696
|
+
if (!(error instanceof SwiftObjCImportError)) throw error
|
|
6697
|
+
failTargetPreparation(target, error.message)
|
|
6698
|
+
continue
|
|
6699
|
+
}
|
|
6528
6700
|
objcModules.add(name)
|
|
6529
6701
|
rootOwner ??= exported
|
|
6530
6702
|
? [...exported.swift.keys()][0]
|
|
@@ -6557,14 +6729,7 @@ export function writeSwiftProject(
|
|
|
6557
6729
|
for (const type of original?.classes ?? []) registeredClasses.add(type)
|
|
6558
6730
|
for (const [file, text] of exported?.swift ?? [])
|
|
6559
6731
|
compiled.set(file, compiled.get(file)! + text)
|
|
6560
|
-
if (
|
|
6561
|
-
const generated = swiftObjCImports(original.view.graphs, {
|
|
6562
|
-
module: swiftTargetModuleName(name),
|
|
6563
|
-
headers: original.headers,
|
|
6564
|
-
classes: original.classes,
|
|
6565
|
-
clangAST: original.view.clangAST,
|
|
6566
|
-
peerTypes: exported?.types,
|
|
6567
|
-
})
|
|
6732
|
+
if (generated) {
|
|
6568
6733
|
const register = `_peach_objc_imports_${swiftTargetModuleName(name)}`
|
|
6569
6734
|
files.set(
|
|
6570
6735
|
path.join(layout.root, target.path, 'PeachObjCImports.generated.swift'),
|
|
@@ -6579,12 +6744,111 @@ export function writeSwiftProject(
|
|
|
6579
6744
|
registrations.push(`${register}();`)
|
|
6580
6745
|
}
|
|
6581
6746
|
}
|
|
6582
|
-
|
|
6747
|
+
if (!rootOwner && [...native.values()].some((plan) => plan.clang?.objc)) {
|
|
6748
|
+
rootOwner = targets
|
|
6749
|
+
.flatMap((target) =>
|
|
6750
|
+
targetEntries(target).filter(([file]) => {
|
|
6751
|
+
const relative = file.slice(target.path === '.' ? 0 : target.path.length + 1)
|
|
6752
|
+
return (
|
|
6753
|
+
file !== 'Package.swift' &&
|
|
6754
|
+
file.endsWith('.swift') &&
|
|
6755
|
+
!target.exclude?.some(
|
|
6756
|
+
(excluded) => relative === excluded || relative.startsWith(`${excluded}/`),
|
|
6757
|
+
)
|
|
6758
|
+
)
|
|
6759
|
+
}),
|
|
6760
|
+
)
|
|
6761
|
+
.find(([file]) => compiled.has(file))?.[0]
|
|
6762
|
+
if (!rootOwner)
|
|
6763
|
+
throw new Error('original Objective-C implementations require a Swift root owner')
|
|
6764
|
+
}
|
|
6765
|
+
// an application's swift module must precede its native implementations.
|
|
6766
|
+
// the tiny executable calls the original typed entry after both are linked.
|
|
6767
|
+
for (const target of [...targets]) {
|
|
6768
|
+
if (
|
|
6769
|
+
!target.executable ||
|
|
6770
|
+
![...native.values()].some((value) => value.late?.producers.includes(target.name))
|
|
6771
|
+
)
|
|
6772
|
+
continue
|
|
6773
|
+
const prefix = target.path === '.' ? '' : `${target.path}/`
|
|
6774
|
+
const entries = [...compiled].filter(
|
|
6775
|
+
([file]) =>
|
|
6776
|
+
file.startsWith(prefix) &&
|
|
6777
|
+
!targets.some(
|
|
6778
|
+
(candidate) =>
|
|
6779
|
+
candidate.name !== target.name &&
|
|
6780
|
+
candidate.path !== '.' &&
|
|
6781
|
+
candidate.path.startsWith(prefix) &&
|
|
6782
|
+
file.startsWith(`${candidate.path}/`),
|
|
6783
|
+
),
|
|
6784
|
+
)
|
|
6785
|
+
const mains = entries.flatMap(([file, source]) => {
|
|
6786
|
+
const match = /@main\b[\s\S]*?\b(?:struct|class|enum)\s+([A-Za-z_]\w*)/.exec(
|
|
6787
|
+
swiftCodeMask(source),
|
|
6788
|
+
)
|
|
6789
|
+
return match ? [{ file, source, match }] : []
|
|
6790
|
+
})
|
|
6791
|
+
if (mains.length !== 1)
|
|
6792
|
+
throw new Error(
|
|
6793
|
+
`mixed executable ${target.name} requires one typed Swift application entry`,
|
|
6794
|
+
)
|
|
6795
|
+
const main = mains[0]!
|
|
6796
|
+
compiled.set(
|
|
6797
|
+
main.file,
|
|
6798
|
+
main.source.slice(0, main.match.index) +
|
|
6799
|
+
' ' +
|
|
6800
|
+
main.source.slice(main.match.index + 5) +
|
|
6801
|
+
`\n@MainActor public func __peachRunApplication() { ${main.match[1]}.main() }\n`,
|
|
6802
|
+
)
|
|
6803
|
+
const name = `${target.name}Executable`
|
|
6804
|
+
if (targets.some((candidate) => candidate.name === name))
|
|
6805
|
+
throw new Error(`mixed application executable target conflicts with ${name}`)
|
|
6806
|
+
target.executable = false
|
|
6807
|
+
targets.push({
|
|
6808
|
+
...target,
|
|
6809
|
+
name,
|
|
6810
|
+
path: `PeachApplication/${name}`,
|
|
6811
|
+
executable: true,
|
|
6812
|
+
resources: false,
|
|
6813
|
+
dependencies: [{ kind: 'target', name: target.name }],
|
|
6814
|
+
exclude: [],
|
|
6815
|
+
})
|
|
6816
|
+
files.set(
|
|
6817
|
+
path.join(layout.root, `PeachApplication/${name}/Entry.swift`),
|
|
6818
|
+
`import ${swiftTargetModuleName(target.name)}\n@main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }\n`,
|
|
6819
|
+
)
|
|
6820
|
+
}
|
|
6821
|
+
// original units compile on the objective-c runtime whether or not swift
|
|
6822
|
+
// exports anything to them.
|
|
6823
|
+
const nativeFlags = (() => {
|
|
6824
|
+
if (native.size === 0) return undefined
|
|
6825
|
+
const headers = materializeObjcSdk(path.join(layout.root, '.build', 'peach-objc-sdk'))
|
|
6826
|
+
return [
|
|
6827
|
+
'-fobjc-runtime=gnustep-2.2',
|
|
6828
|
+
'-fobjc-exceptions',
|
|
6829
|
+
'-fexceptions',
|
|
6830
|
+
'-fwasm-exceptions',
|
|
6831
|
+
'-fobjc-arc',
|
|
6832
|
+
'-fblocks',
|
|
6833
|
+
'-F',
|
|
6834
|
+
path.join(headers, 'System/Library/Frameworks'),
|
|
6835
|
+
'-idirafter',
|
|
6836
|
+
path.join(headers, 'usr/include'),
|
|
6837
|
+
'-I',
|
|
6838
|
+
headerDirectory,
|
|
6839
|
+
]
|
|
6840
|
+
})()
|
|
6841
|
+
let objcExports: Parameters<typeof emitSwiftPackageManifest>[0]['objcExports']
|
|
6583
6842
|
if (rootOwner && input.objcPeerStartup)
|
|
6584
6843
|
throw new Error(
|
|
6585
6844
|
'Objective-C peer startup: joining framework metadata with source exports requires one qualified root registration',
|
|
6586
6845
|
)
|
|
6587
6846
|
if (rootOwner) {
|
|
6847
|
+
const rootSource = rootOwner
|
|
6848
|
+
const rootModule = bySourcePath.find(
|
|
6849
|
+
(target) => target.path === '.' || rootSource.startsWith(`${target.path}/`),
|
|
6850
|
+
)?.name
|
|
6851
|
+
if (!rootModule) throw new Error('Objective-C root registration has no owning target')
|
|
6588
6852
|
if (
|
|
6589
6853
|
targets.some((target) => target.name === 'PeachSwiftObjCExports') ||
|
|
6590
6854
|
Object.keys(input.files).some((file) => file.startsWith('PeachObjCExports/'))
|
|
@@ -6598,15 +6862,14 @@ export function writeSwiftProject(
|
|
|
6598
6862
|
throw new Error('Objective-C root registration has no owning Swift source')
|
|
6599
6863
|
files.set(
|
|
6600
6864
|
ownerFile,
|
|
6601
|
-
|
|
6602
|
-
`
|
|
6865
|
+
`
|
|
6603
6866
|
@_extern(c, "_peach_objc_register_all_exports") private func __peachRegisterAllExports()
|
|
6604
6867
|
private let __peachExportRegistration: Void = { __peachRegisterAllExports() }()
|
|
6605
6868
|
@_cdecl("_peach_objc_ensure_exports")
|
|
6606
6869
|
public func __peachEnsureExportRegistration() { _ = __peachExportRegistration }
|
|
6607
6870
|
@_cdecl("_peach_objc_export_root")
|
|
6608
6871
|
public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nativeName: "NSObject") }
|
|
6609
|
-
|
|
6872
|
+
` + ownerSource,
|
|
6610
6873
|
)
|
|
6611
6874
|
if (compiled.has(rootOwner)) compiled.set(rootOwner, files.get(ownerFile)!.toString())
|
|
6612
6875
|
files.set(
|
|
@@ -6618,12 +6881,8 @@ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nati
|
|
|
6618
6881
|
[
|
|
6619
6882
|
'#import <Foundation/Foundation.h>',
|
|
6620
6883
|
'extern void _peach_objc_ensure_exports(void);',
|
|
6621
|
-
'extern void *_peach_objc_allocate_foreign(void *);',
|
|
6622
6884
|
'@implementation NSObject',
|
|
6623
6885
|
'+ (void)initialize { _peach_objc_ensure_exports(); }',
|
|
6624
|
-
'+ (instancetype)alloc { return (__bridge id)_peach_objc_allocate_foreign((__bridge void *)self); }',
|
|
6625
|
-
'+ (instancetype)new { return [[self alloc] init]; }',
|
|
6626
|
-
'- (instancetype)init { return self; }',
|
|
6627
6886
|
'@end',
|
|
6628
6887
|
'extern void _peach_objc_export_root(void);',
|
|
6629
6888
|
...registrations.flatMap((text) =>
|
|
@@ -6640,22 +6899,11 @@ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nati
|
|
|
6640
6899
|
'',
|
|
6641
6900
|
].join('\n'),
|
|
6642
6901
|
)
|
|
6643
|
-
const headers = materializeObjcSdk(path.join(layout.root, '.build', 'peach-objc-sdk'))
|
|
6644
6902
|
objcExports = {
|
|
6645
6903
|
modules: objcModules,
|
|
6904
|
+
rootModule,
|
|
6646
6905
|
flags: [
|
|
6647
|
-
|
|
6648
|
-
'-fobjc-exceptions',
|
|
6649
|
-
'-fexceptions',
|
|
6650
|
-
'-fwasm-exceptions',
|
|
6651
|
-
'-fobjc-arc',
|
|
6652
|
-
'-fblocks',
|
|
6653
|
-
'-F',
|
|
6654
|
-
path.join(headers, 'System/Library/Frameworks'),
|
|
6655
|
-
'-idirafter',
|
|
6656
|
-
path.join(headers, 'usr/include'),
|
|
6657
|
-
'-I',
|
|
6658
|
-
headerDirectory,
|
|
6906
|
+
...nativeFlags!,
|
|
6659
6907
|
...[...objcModules].map(
|
|
6660
6908
|
(name) =>
|
|
6661
6909
|
`-fmodule-map-file=${path.join(headerModuleDirectory, name, 'module.modulemap')}`,
|
|
@@ -6735,6 +6983,7 @@ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nati
|
|
|
6735
6983
|
targets,
|
|
6736
6984
|
native,
|
|
6737
6985
|
objcExports,
|
|
6986
|
+
nativeFlags,
|
|
6738
6987
|
headerDirectory: native.size > 0 ? headerDirectory : undefined,
|
|
6739
6988
|
cxxLanguageStandard: swiftManifestCxxLanguageStandard(
|
|
6740
6989
|
input.files['Package.swift'] ?? '',
|
|
@@ -6980,6 +7229,82 @@ function saveCompiledArtifact(root: string, artifact: SwiftCompileArtifact): voi
|
|
|
6980
7229
|
}
|
|
6981
7230
|
}
|
|
6982
7231
|
|
|
7232
|
+
// every source edit addresses a new shared artifact directory of tens of
|
|
7233
|
+
// mebibytes, and nothing else ever removes one. a save retires the least
|
|
7234
|
+
// recently used entries past this soft budget; entries used within the grace
|
|
7235
|
+
// window and the entry just saved always stay, so a burst of recent entries can
|
|
7236
|
+
// exceed it. a reader treats a vanished entry as a miss and rebuilds, so
|
|
7237
|
+
// retirement only needs to be atomic: an entry is renamed out of the address
|
|
7238
|
+
// space before it is deleted, and a lost renewal race costs one rebuild.
|
|
7239
|
+
const SHARED_ARTIFACT_BUDGET_BYTES = 4 * 1024 ** 3
|
|
7240
|
+
const SHARED_ARTIFACT_GRACE_MS = 3_600_000
|
|
7241
|
+
const RETIRED_PREFIX = '.retired-'
|
|
7242
|
+
|
|
7243
|
+
function vanished(error: unknown): boolean {
|
|
7244
|
+
return error instanceof Error && 'code' in error && error.code === 'ENOENT'
|
|
7245
|
+
}
|
|
7246
|
+
|
|
7247
|
+
// a hit marks the entry used; a concurrent pruner may have retired it after the
|
|
7248
|
+
// read, which leaves the verified bytes in hand valid.
|
|
7249
|
+
function renewSharedArtifact(sharedRoot: string): void {
|
|
7250
|
+
try {
|
|
7251
|
+
utimesSync(sharedRoot, new Date(), new Date())
|
|
7252
|
+
} catch (error) {
|
|
7253
|
+
if (!vanished(error)) throw error
|
|
7254
|
+
}
|
|
7255
|
+
}
|
|
7256
|
+
|
|
7257
|
+
function pruneSharedArtifacts(parent: string, keep: string): void {
|
|
7258
|
+
const entries: { directory: string; used: number; bytes: number }[] = []
|
|
7259
|
+
for (const name of readdirSync(parent)) {
|
|
7260
|
+
const directory = path.join(parent, name)
|
|
7261
|
+
if (name.startsWith(RETIRED_PREFIX)) {
|
|
7262
|
+
rmSync(directory, { recursive: true, force: true })
|
|
7263
|
+
continue
|
|
7264
|
+
}
|
|
7265
|
+
try {
|
|
7266
|
+
let bytes = 0
|
|
7267
|
+
for (const file of readdirSync(path.join(directory, 'artifact'))) {
|
|
7268
|
+
try {
|
|
7269
|
+
bytes += statSync(path.join(directory, 'artifact', file)).size
|
|
7270
|
+
} catch (error) {
|
|
7271
|
+
if (!vanished(error)) throw error
|
|
7272
|
+
}
|
|
7273
|
+
}
|
|
7274
|
+
entries.push({ directory, used: statSync(directory).mtimeMs, bytes })
|
|
7275
|
+
} catch (error) {
|
|
7276
|
+
// another process retired this entry, or is still creating it.
|
|
7277
|
+
if (!vanished(error)) throw error
|
|
7278
|
+
}
|
|
7279
|
+
}
|
|
7280
|
+
let total = entries.reduce((sum, entry) => sum + entry.bytes, 0)
|
|
7281
|
+
for (const entry of entries.sort((a, b) => a.used - b.used)) {
|
|
7282
|
+
if (total <= SHARED_ARTIFACT_BUDGET_BYTES) break
|
|
7283
|
+
if (entry.directory === keep || Date.now() - entry.used < SHARED_ARTIFACT_GRACE_MS)
|
|
7284
|
+
continue
|
|
7285
|
+
const retired = path.join(
|
|
7286
|
+
parent,
|
|
7287
|
+
`${RETIRED_PREFIX}${process.pid}-${path.basename(entry.directory)}`,
|
|
7288
|
+
)
|
|
7289
|
+
try {
|
|
7290
|
+
// an entry renewed since the scan is in use again.
|
|
7291
|
+
if (statSync(entry.directory).mtimeMs !== entry.used) continue
|
|
7292
|
+
renameSync(entry.directory, retired)
|
|
7293
|
+
} catch (error) {
|
|
7294
|
+
if (vanished(error)) continue
|
|
7295
|
+
throw error
|
|
7296
|
+
}
|
|
7297
|
+
rmSync(retired, { recursive: true, force: true })
|
|
7298
|
+
total -= entry.bytes
|
|
7299
|
+
}
|
|
7300
|
+
}
|
|
7301
|
+
|
|
7302
|
+
function saveSharedArtifact(sharedRoot: string, artifact: SwiftCompileArtifact): void {
|
|
7303
|
+
saveCompiledArtifact(sharedRoot, artifact)
|
|
7304
|
+
renewSharedArtifact(sharedRoot)
|
|
7305
|
+
pruneSharedArtifacts(path.dirname(sharedRoot), sharedRoot)
|
|
7306
|
+
}
|
|
7307
|
+
|
|
6983
7308
|
// the two newest artifacts of each build root stay in memory, keyed by address.
|
|
6984
7309
|
// the disk cache keeps only the last one, so an edit undone, or a toggle between
|
|
6985
7310
|
// two states, would otherwise rebuild bytes this process already holds.
|
|
@@ -7030,7 +7355,8 @@ export function compileSwiftProjectUnit(
|
|
|
7030
7355
|
const cached = readCompiledArtifact(path.join(sharedRoot, 'artifact'), hash)
|
|
7031
7356
|
const previous = cached ?? readCompiledArtifact(path.join(root, 'artifact'), hash)
|
|
7032
7357
|
if (previous) {
|
|
7033
|
-
if (
|
|
7358
|
+
if (cached) renewSharedArtifact(sharedRoot)
|
|
7359
|
+
else saveSharedArtifact(sharedRoot, previous)
|
|
7034
7360
|
report('reusing verified disk artifact')
|
|
7035
7361
|
return retain(root, previous)
|
|
7036
7362
|
}
|
|
@@ -7041,10 +7367,12 @@ export function compileSwiftProjectUnit(
|
|
|
7041
7367
|
process.env.TM_SESSION &&
|
|
7042
7368
|
!admittedMacBuilderSlot() &&
|
|
7043
7369
|
process.env.CI !== 'true' &&
|
|
7044
|
-
moduleRoot ===
|
|
7370
|
+
moduleRoot === sourceSwiftCheckout() &&
|
|
7045
7371
|
!swiftDistributionAt(moduleRoot)
|
|
7046
7372
|
) {
|
|
7047
|
-
|
|
7373
|
+
// staging another process's sources sweeps the root, so the request
|
|
7374
|
+
// and returning output live beside it until this caller cleans them.
|
|
7375
|
+
const requestRoot = mkdtempSync(`${root}.builder-request-`)
|
|
7048
7376
|
const output = path.join(requestRoot, 'output')
|
|
7049
7377
|
const request = path.join(requestRoot, 'request.json')
|
|
7050
7378
|
writeFileSync(
|
|
@@ -7093,7 +7421,7 @@ export function compileSwiftProjectUnit(
|
|
|
7093
7421
|
)
|
|
7094
7422
|
}
|
|
7095
7423
|
saveCompiledArtifact(root, artifact)
|
|
7096
|
-
|
|
7424
|
+
saveSharedArtifact(sharedRoot, artifact)
|
|
7097
7425
|
report('builder artifact verified')
|
|
7098
7426
|
return retain(root, artifact)
|
|
7099
7427
|
} finally {
|
|
@@ -7318,7 +7646,7 @@ export function compileSwiftProjectUnit(
|
|
|
7318
7646
|
icu: await icu,
|
|
7319
7647
|
}
|
|
7320
7648
|
saveCompiledArtifact(root, artifact)
|
|
7321
|
-
|
|
7649
|
+
saveSharedArtifact(sharedRoot, artifact)
|
|
7322
7650
|
report('compiled artifact verified')
|
|
7323
7651
|
return retain(root, artifact)
|
|
7324
7652
|
},
|