peachsim 0.1.1674 → 0.1.1692
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/cli/commands/control.ts +13 -1
- package/cli/commands/coverage-swift.ts +150 -27
- package/cli/commands/coverage.ts +219 -20
- package/cli/commands/detect.ts +10 -6
- package/cli/commands/inspect/actions.ts +1 -0
- package/cli/commands/inspect/core.ts +2 -0
- package/cli/commands/inspect/wait-ready.ts +7 -0
- package/cli/commands/screenshot.ts +12 -0
- package/cli/outbound-endpoints.ts +12 -0
- package/detox/index.ts +11 -1
- package/detox/jest-environment.cjs +14 -0
- 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 +4833 -2432
- 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 +6 -4
- package/dist-lib/detox/jest-environment.cjs +14 -0
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +3785 -1737
- 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 +4253 -2205
- package/dist-lib/host/fetch-proxy-handler.cjs +20 -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 +2065 -796
- 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 +6325 -4287
- package/dist-lib/native-app-identity-project.cjs +192 -55
- package/dist-lib/native-app-identity-project.mjs +235 -86
- 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 +27 -23
- package/dist-lib/public-origins-lib-static.json +1 -1
- package/dist-lib/public-origins-lib.json +156 -87
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +2 -2
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +3 -2
- package/dist-lib/sdk.mjs +3 -2
- package/dist-lib/skills.cjs +5036 -2833
- package/dist-lib/swift-compile.cjs +2937 -437
- package/dist-lib/swift-compile.mjs +2932 -435
- package/dist-lib/swift-package.cjs +137 -49
- package/dist-lib/swift-package.mjs +132 -49
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +26 -11
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +6005 -1725
- package/dist-lib/vite.cjs +1911 -776
- package/dist-lib/worklet-executable.cjs +7 -4
- package/dist-lib/worklet-executable.mjs +7 -4
- package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/clipboardContract.d.ts +24 -2
- package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +11 -3
- package/dist-types/packages/peach-engine/src/webview-automation-host.d.ts +6 -0
- package/dist-types/packages/peach-globals/src/clipboardBridgeContract.d.ts +8 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
- package/dist-types/packages/peach-globals/src/nodeContract.d.ts +3 -2
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +60 -2
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLAvailability.h +22 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBackgroundActivitySession.h +145 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBeaconIdentityCondition.h +113 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBeaconIdentityConstraint.h +34 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBeaconRegion.h +225 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBody.h +26 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLCircularGeographicCondition.h +59 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLCircularRegion.h +64 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLCondition.h +48 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLError.h +52 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLErrorDomain.h +24 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLGeocoder.h +55 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLHeading.h +117 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocation.h +9 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager+CLVisitExtensions.h +45 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager.h +877 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManagerDelegate.h +225 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationPushServiceError.h +33 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationPushServiceExtension.h +28 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationUpdater.h +250 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLMonitor.h +140 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLMonitorConfiguration.h +77 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLMonitoringEvent.h +184 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLMonitoringRecord.h +57 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLPlacemark.h +98 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLRegion.h +123 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLServiceSession.h +211 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLVisit.h +66 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CoreLocation.h +46 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Modules/module.modulemap +7 -0
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +117 -2
- package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceBase.h +52 -0
- package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceObjC.h +240 -0
- package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceRef.h +474 -0
- package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceTypes.h +66 -0
- package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Modules/module.modulemap +10 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFComposeAssistantViewController.h +29 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeControllerDeferredAction.h +14 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeViewController.h +162 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailDraft.h +24 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController+UPI.h +31 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController.h +169 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MessageUI.h +13 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Modules/module.modulemap +11 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4AccelerationStructure.h +9 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4Archive.h +16 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4ArgumentTable.h +17 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4BinaryFunction.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4BinaryFunctionDescriptor.h +14 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4BufferRange.h +79 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommandAllocator.h +15 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommandBuffer.h +17 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommandEncoder.h +16 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommandQueue.h +19 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommitFeedback.h +15 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4Compiler.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CompilerTask.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4ComputeCommandEncoder.h +19 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4ComputePipeline.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4Counters.h +19 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4FunctionDescriptor.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4LibraryDescriptor.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4LibraryFunctionDescriptor.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4LinkingDescriptor.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4MachineLearningCommandEncoder.h +17 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4MachineLearningPipeline.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4MeshRenderPipeline.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4PipelineDataSetSerializer.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4PipelineState.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4RenderCommandEncoder.h +17 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4RenderPass.h +17 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4RenderPipeline.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4SpecializedFunctionDescriptor.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4StitchedFunctionDescriptor.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4TileRenderPipeline.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLAccelerationStructure.h +1212 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLAccelerationStructureCommandEncoder.h +322 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLAccelerationStructureTypes.h +224 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLAllocation.h +22 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLArgument.h +279 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLArgumentEncoder.h +199 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLBinaryArchive.h +142 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLBlitCommandEncoder.h +266 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLBlitPass.h +82 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLBuffer.h +94 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCaptureManager.h +113 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCaptureScope.h +43 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCommandBuffer.h +449 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCommandEncoder.h +148 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCommandQueue.h +102 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLComputeCommandEncoder.h +350 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLComputePass.h +90 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLComputePipeline.h +274 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCounters.h +225 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDataType.h +232 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDefines.h +39 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDepthStencil.h +93 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h +1122 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDeviceCertification.h +29 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDrawable.h +36 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDynamicLibrary.h +81 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLEvent.h +79 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFence.h +22 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionConstantValues.h +30 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionDescriptor.h +95 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionHandle.h +29 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionLog.h +37 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionStitching.h +131 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLGPUAddress.h +19 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLHeap.h +284 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIOCommandBuffer.h +10 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIOCommandQueue.h +11 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIOCompressor.h +10 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIndirectCommandBuffer.h +157 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIndirectCommandEncoder.h +110 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIntersectionFunctionTable.h +186 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLLibrary.h +549 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLLinkedFunctions.h +57 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLLogState.h +65 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLParallelRenderCommandEncoder.h +77 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLPipeline.h +57 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLPixelFormat.h +342 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLRasterizationRate.h +323 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLRenderCommandEncoder.h +1068 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLRenderPass.h +411 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLRenderPipeline.h +788 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResidencySet.h +141 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResource.h +307 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResourceStateCommandEncoder.h +125 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResourceStatePass.h +85 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResourceViewPool.h +22 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLSampler.h +252 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLStageInputOutputDescriptor.h +158 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLTensor.h +17 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLTexture.h +460 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLTextureViewPool.h +18 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLTypes.h +125 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLVertexDescriptor.h +153 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLVisibleFunctionTable.h +45 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/Metal.h +94 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Modules/module.modulemap +6 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +10 -0
- package/sdk/ios/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UTDefines.h +35 -0
- package/sdk/ios/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UTTagClass.h +33 -0
- package/sdk/ios/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UTType.h +504 -0
- package/sdk/ios/System/Library/Frameworks/_LocationEssentials.framework/Headers/CLEssentialsAvailability.h +14 -0
- package/sdk/ios/System/Library/Frameworks/_LocationEssentials.framework/Headers/CLLocationEssentials.h +444 -0
- package/sdk/ios/System/Library/Frameworks/_LocationEssentials.framework/Headers/LocationEssentials.h +14 -0
- package/sdk/ios/System/Library/Frameworks/_LocationEssentials.framework/Modules/module.modulemap +14 -0
- package/sdk/ios/usr/include/arm/param.h +151 -0
- package/sdk/ios/usr/include/complex.h +167 -0
- package/sdk/ios/usr/include/dispatch/dispatch.h +8 -0
- package/sdk/ios/usr/include/dlfcn.h +1 -2
- package/sdk/ios/usr/include/mach/mach_types.h +1 -0
- package/sdk/ios/usr/include/machine/param.h +42 -0
- package/sdk/ios/usr/include/math.h +835 -2
- package/sdk/ios/usr/include/net/if.h +1 -2
- package/sdk/ios/usr/include/peach/pthread.h +4 -4
- package/sdk/ios/usr/include/pthread/qos.h +304 -0
- package/sdk/ios/usr/include/sys/_types/_fd_clr.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_copy.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_def.h +121 -0
- package/sdk/ios/usr/include/sys/_types/_fd_isset.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_set.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_setsize.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_zero.h +31 -0
- package/sdk/ios/usr/include/sys/cdefs.h +3 -1
- package/sdk/ios/usr/include/sys/param.h +235 -0
- package/sdk/ios/usr/include/sys/proc.h +1 -0
- package/sdk/ios/usr/include/sys/qos.h +151 -12
- package/sdk/ios/wasm/include/__typedef_sigset_t.h +7 -0
- package/sdk/ios/wasm/include/fcntl.h +11 -0
- package/sdk/ios/wasm/include/mach/machine/boolean.h +2 -0
- package/sdk/ios/wasm/include/mach/machine/exception.h +5 -0
- package/sdk/ios/wasm/include/mach/machine/kern_return.h +2 -0
- package/sdk/ios/wasm/include/mach/machine/processor_info.h +2 -0
- package/sdk/ios/wasm/include/mach/machine/rpc.h +2 -0
- package/sdk/ios/wasm/include/mach/machine/thread_state.h +3 -0
- package/sdk/ios/wasm/include/mach/machine/thread_status.h +3 -0
- package/sdk/ios/wasm/include/mach/machine/vm_param.h +3 -0
- package/sdk/ios/wasm/include/mach/machine/vm_types.h +18 -0
- package/sdk/ios/wasm/include/machine/_types.h +153 -0
- package/sdk/ios/wasm/include/machine/endian.h +2 -0
- package/sdk/ios/wasm/include/machine/limits.h +2 -0
- package/sdk/ios/wasm/include/machine/types.h +30 -0
- package/sdk/ios/wasm/include/poll.h +8 -0
- package/sdk/ios/wasm/include/pthread.h +50 -0
- package/sdk/ios/wasm/include/signal.h +72 -0
- package/sdk/ios/wasm/include/stdlib.h +3 -0
- package/sdk/ios/wasm/include/string.h +10 -0
- package/sdk/ios/wasm/include/sys/_pthread/_pthread_attr_t.h +7 -0
- package/sdk/ios/wasm/include/sys/_pthread/_pthread_t.h +7 -0
- package/sdk/ios/wasm/include/sys/mman.h +122 -0
- package/sdk/ios/wasm/include/sys/select.h +37 -0
- package/sdk/ios/wasm/include/sys/signal.h +259 -0
- package/sdk/ios/wasm/include/sys/socket.h +8 -0
- package/sdk/ios/wasm/include/sys/types.h +14 -0
- package/sdk/ios/wasm/include/sys/ucontext.h +1 -0
- package/sdk/ios/wasm/include/sys/uio.h +11 -0
- package/sdk/ios/wasm/include/sys/wait.h +89 -0
- package/sdk/ios/wasm/include/time.h +8 -0
- package/sdk/ios/wasm/include/unistd.h +17 -0
- package/src/bridge-contract.ts +2 -0
- package/src/chromium-admission.ts +10 -5
- package/src/device-catalog.ts +4 -4
- package/src/generated/swift-c-predefines.json +1988 -0
- package/src/host/fetch-proxy-handler.ts +20 -0
- package/src/metro-plugin.ts +5 -2
- package/src/nitro-adapter.lock.json +6 -6
- package/src/nitro-bundle.ts +1 -0
- package/src/nitro-compile.ts +67 -2
- package/src/nitroContract.ts +18 -2
- package/src/numbered-lock.ts +72 -0
- package/src/react-native-coverage/capability-reference-resolution.ts +62 -5
- package/src/react-native-coverage/capability-source-references.ts +50 -13
- package/src/react-native-coverage/native-source-credit.ts +126 -0
- package/src/react-native-coverage/native-source-ranges-file.ts +38 -0
- package/src/react-native-coverage/native-surface.ts +49 -0
- package/src/react-native-coverage/verified-reach.ts +22 -2
- package/src/runtime-assets.ts +17 -0
- package/src/swift-compile.ts +530 -97
- package/src/swift-coverage/indexing.ts +17 -1
- package/src/swift-coverage/package.ts +3 -1
- package/src/swift-coverage/sdk.ts +71 -0
- package/src/swift-coverage/source.ts +74 -2
- package/src/swift-coverage/types.ts +6 -0
- package/src/swift-coverage/xcode-assets.ts +62 -2
- package/src/swift-coverage/xcode-packages.ts +11 -6
- package/src/swift-distribution.lock.json +12 -12
- package/src/swift-host.ts +457 -62
- package/src/swift-objc-compile.ts +26 -26
- package/src/swift-objc-metadata.ts +2 -8
- package/src/swift-objc-platform.ts +53 -0
- package/src/swift-objc-standin.ts +66 -12
- package/src/swift-package-manifest.ts +196 -28
- package/src/swift-package.ts +186 -60
- package/src/swift-packages.ts +298 -88
- package/src/swift-source-file.ts +10 -15
- package/src/swift-source-pods.ts +288 -0
- package/src/swift-standins.ts +87 -13
- package/src/swift-submit.ts +5 -0
- package/src/swift-toolchain.ts +32 -10
- package/src/swiftContract.ts +160 -75
- package/src/target-matcher.ts +15 -2
- package/src/vite-plugin-one.ts +5 -4
- package/src/worker-system-chunks.ts +7 -1
- package/src/worklet-executable.ts +7 -3
- package/src/xcode-json-project.ts +14 -2
- package/src/xcode-project.ts +193 -69
package/src/swift-compile.ts
CHANGED
|
@@ -23,6 +23,7 @@ import os from 'node:os'
|
|
|
23
23
|
import path from 'node:path'
|
|
24
24
|
import yaml from 'yaml'
|
|
25
25
|
import { admittedMacBuilderSlot } from './admitted-mac-build'
|
|
26
|
+
import cPredefinesJson from './generated/swift-c-predefines.json' with { type: 'json' }
|
|
26
27
|
import { rnxHomeDir, swiftPackageCacheOptions } from './home-paths'
|
|
27
28
|
import { isRecord } from './is-record'
|
|
28
29
|
import { terminateProcessGroup } from './process-group'
|
|
@@ -41,12 +42,20 @@ import {
|
|
|
41
42
|
swiftObjCPrivateImports,
|
|
42
43
|
} from './swift-objc-import'
|
|
43
44
|
import { validateObjcPeerStartupLibraries } from './swift-objc-metadata'
|
|
44
|
-
import { materializeObjcSdk, objcView, WASI_EMULATION_FLAGS } from './swift-objc-standin'
|
|
45
45
|
import {
|
|
46
|
+
iosDeploymentMinimum,
|
|
47
|
+
materializeObjcSdk,
|
|
48
|
+
objcSdkIntakeFlags,
|
|
49
|
+
objcView,
|
|
50
|
+
} from './swift-objc-standin'
|
|
51
|
+
import {
|
|
52
|
+
isSwiftNativeTranslationUnit,
|
|
46
53
|
OBJC_RESOURCE_ACCESSOR_BODY,
|
|
47
54
|
OBJC_RESOURCE_ACCESSOR_HEADER,
|
|
48
55
|
swiftManifestCxxLanguageStandard,
|
|
56
|
+
swiftManifestDeclarations,
|
|
49
57
|
swiftManifestTargets,
|
|
58
|
+
swiftManifestPackages,
|
|
50
59
|
swiftObjCResourceAccessor,
|
|
51
60
|
swiftObjCResourceBundleName,
|
|
52
61
|
swiftPackagePartition,
|
|
@@ -65,10 +74,13 @@ import {
|
|
|
65
74
|
} from './swift-toolchain'
|
|
66
75
|
import {
|
|
67
76
|
isSwiftNativeTargets,
|
|
77
|
+
isSwiftPackageFiles,
|
|
68
78
|
isSwiftObjCPeerStartup,
|
|
69
79
|
isSwiftResourceBundles,
|
|
80
|
+
isSwiftResourcePath,
|
|
70
81
|
SWIFT_NATIVE_INPUT_ROOT,
|
|
71
82
|
SWIFT_NATIVE_SDK_INCLUDE,
|
|
83
|
+
type SwiftPackageFiles,
|
|
72
84
|
type SwiftNativeTarget,
|
|
73
85
|
type SwiftObjCPeerStartup,
|
|
74
86
|
type SwiftProjectPreparation,
|
|
@@ -200,6 +212,8 @@ const BUILD_JOBS = String(
|
|
|
200
212
|
|
|
201
213
|
export interface SwiftCompileInput {
|
|
202
214
|
files: Record<string, string>
|
|
215
|
+
packageFiles?: SwiftPackageFiles
|
|
216
|
+
packageGuestImports?: string[]
|
|
203
217
|
objcPeerStartup?: SwiftObjCPeerStartup
|
|
204
218
|
nativeTargets?: SwiftNativeTarget[]
|
|
205
219
|
metalSources?: Record<string, string>
|
|
@@ -536,7 +550,7 @@ const SWIFT_IMPORT =
|
|
|
536
550
|
// through `!`, `&&` and `||`.
|
|
537
551
|
function swiftCondition(
|
|
538
552
|
text: string,
|
|
539
|
-
available
|
|
553
|
+
available?: ReadonlySet<string>,
|
|
540
554
|
): boolean | undefined {
|
|
541
555
|
const tokens = text.match(/\w+\s*\([^()]*\)|&&|\|\||!|\(|\)|\w+/g) ?? []
|
|
542
556
|
let index = 0
|
|
@@ -557,8 +571,8 @@ function swiftCondition(
|
|
|
557
571
|
if (!call) return undefined
|
|
558
572
|
const [, name, argument] = call
|
|
559
573
|
if (name === 'os') return argument === 'iOS' || argument === 'WASI'
|
|
560
|
-
if (name === 'canImport') return available
|
|
561
|
-
if (name === 'targetEnvironment') return
|
|
574
|
+
if (name === 'canImport') return available?.has(argument!)
|
|
575
|
+
if (name === 'targetEnvironment') return argument === 'simulator'
|
|
562
576
|
if (name === 'arch') return argument === 'wasm32'
|
|
563
577
|
return undefined
|
|
564
578
|
}
|
|
@@ -588,24 +602,18 @@ function swiftCondition(
|
|
|
588
602
|
return either()
|
|
589
603
|
}
|
|
590
604
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
* whose condition holds there, `os(iOS)` included since the compile rewrites
|
|
595
|
-
* it to true. a branch the scan cannot decide may compile out, so its
|
|
596
|
-
* imports stay out of the list.
|
|
597
|
-
*/
|
|
598
|
-
export function swiftImportNames(
|
|
605
|
+
// each line's branch state under the app's wasm compilation conditions.
|
|
606
|
+
// directives themselves are not executable source.
|
|
607
|
+
function* swiftConditionalLines(
|
|
599
608
|
contents: string,
|
|
600
609
|
available?: ReadonlySet<string>,
|
|
601
|
-
): string
|
|
602
|
-
const names: string[] = []
|
|
610
|
+
): Generator<{ line: string; active: boolean | undefined }> {
|
|
603
611
|
// per open `#if`: whether its current branch is active, and whether an
|
|
604
612
|
// earlier branch was taken (or may have been)
|
|
605
613
|
const frames: { active: boolean | undefined; taken: boolean | undefined }[] = []
|
|
606
614
|
for (const line of contents.split('\n')) {
|
|
607
615
|
const directive = /^\s*#(if|elseif|else|endif)\b(.*)$/.exec(line)
|
|
608
|
-
if (directive
|
|
616
|
+
if (directive) {
|
|
609
617
|
const [, kind, rest] = directive
|
|
610
618
|
const condition = (rest ?? '').replace(/\/\/.*$/, '').trim()
|
|
611
619
|
if (kind === 'if') {
|
|
@@ -628,9 +636,34 @@ export function swiftImportNames(
|
|
|
628
636
|
? holds
|
|
629
637
|
: undefined
|
|
630
638
|
}
|
|
639
|
+
yield { line, active: false }
|
|
631
640
|
continue
|
|
632
641
|
}
|
|
633
|
-
|
|
642
|
+
yield {
|
|
643
|
+
line,
|
|
644
|
+
active: frames.some((frame) => frame.active === false)
|
|
645
|
+
? false
|
|
646
|
+
: frames.every((frame) => frame.active === true)
|
|
647
|
+
? true
|
|
648
|
+
: undefined,
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* the modules a source imports, in order. with `available`, only imports the
|
|
655
|
+
* wasm compile certainly reaches: those outside every `#if`, or in a branch
|
|
656
|
+
* whose condition holds there, `os(iOS)` included since the compile rewrites
|
|
657
|
+
* it to true. a branch the scan cannot decide may compile out, so its
|
|
658
|
+
* imports stay out of the list.
|
|
659
|
+
*/
|
|
660
|
+
export function swiftImportNames(
|
|
661
|
+
contents: string,
|
|
662
|
+
available?: ReadonlySet<string>,
|
|
663
|
+
): string[] {
|
|
664
|
+
const names: string[] = []
|
|
665
|
+
for (const { line, active } of swiftConditionalLines(contents, available)) {
|
|
666
|
+
if (available && active !== true) continue
|
|
634
667
|
const name = SWIFT_IMPORT.exec(line)?.[1]
|
|
635
668
|
if (name) names.push(name)
|
|
636
669
|
}
|
|
@@ -645,11 +678,11 @@ export function swiftPeachModules(moduleRoot: string): string[] {
|
|
|
645
678
|
const distribution = swiftDistributionAt(moduleRoot)
|
|
646
679
|
return distribution
|
|
647
680
|
? distribution.modules
|
|
648
|
-
:
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
)
|
|
652
|
-
|
|
681
|
+
: swiftManifestDeclarations(
|
|
682
|
+
readFileSync(path.join(moduleRoot, 'Package.swift'), 'utf8'),
|
|
683
|
+
)
|
|
684
|
+
.filter((target) => !target.executable)
|
|
685
|
+
.map((target) => target.name)
|
|
653
686
|
}
|
|
654
687
|
|
|
655
688
|
const sdkPaths = new Map<string, { sysroot: string; resources: string }>()
|
|
@@ -723,16 +756,22 @@ export function swiftAvailableModules(
|
|
|
723
756
|
* `available`) that nothing available provides, each with the files
|
|
724
757
|
* importing it. the compiler stops at the first
|
|
725
758
|
* missing module; this names all of them at once.
|
|
759
|
+
* `providedByFile` names the compiler modules each file's own target
|
|
760
|
+
* settings provide, which no sdk ships: Builtin, which the compiler
|
|
761
|
+
* synthesizes when the target enables the BuiltinModule feature.
|
|
726
762
|
*/
|
|
727
763
|
export function missingSwiftModules(
|
|
728
764
|
files: Record<string, string>,
|
|
729
765
|
available: ReadonlySet<string>,
|
|
766
|
+
providedByFile: (file: string) => readonly string[] = () => [],
|
|
730
767
|
): Map<string, string[]> {
|
|
731
768
|
const missing = new Map<string, string[]>()
|
|
732
769
|
for (const [file, contents] of Object.entries(files)) {
|
|
733
770
|
if (!file.endsWith('.swift') || file === 'Package.swift') continue
|
|
734
|
-
|
|
735
|
-
|
|
771
|
+
const extra = providedByFile(file)
|
|
772
|
+
const scoped = extra.length === 0 ? available : new Set([...available, ...extra])
|
|
773
|
+
for (const name of new Set(swiftImportNames(contents, scoped))) {
|
|
774
|
+
if (scoped.has(name)) continue
|
|
736
775
|
missing.set(name, [...(missing.get(name) ?? []), file])
|
|
737
776
|
}
|
|
738
777
|
}
|
|
@@ -825,7 +864,7 @@ const EXECUTABLE_LINK_FLAGS = ` "-Xclang-linker", "-O0",
|
|
|
825
864
|
const REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n'
|
|
826
865
|
|
|
827
866
|
/** bump with any change to the emitted multi-target manifest text. */
|
|
828
|
-
export const MULTI_MANIFEST_VERSION =
|
|
867
|
+
export const MULTI_MANIFEST_VERSION = 43
|
|
829
868
|
|
|
830
869
|
// build-cli replaces this in every bundle; source runs read the files directly.
|
|
831
870
|
declare const __SWIFT_COMPILER_DIGEST__: string | undefined
|
|
@@ -882,6 +921,11 @@ export function swiftArtifactHash(
|
|
|
882
921
|
),
|
|
883
922
|
)
|
|
884
923
|
hash.update(JSON.stringify(input.nativeTargets ?? []))
|
|
924
|
+
hash.update(JSON.stringify(input.packageGuestImports ?? []))
|
|
925
|
+
for (const file of Object.keys(input.packageFiles ?? {}).sort()) {
|
|
926
|
+
hash.update(`package-file\0${file}\0`)
|
|
927
|
+
hash.update(createHash('sha256').update(input.packageFiles![file]!).digest())
|
|
928
|
+
}
|
|
885
929
|
hash.update(JSON.stringify(input.objcPeerStartup ?? null))
|
|
886
930
|
for (const target of Object.keys(input.libraries ?? {}).sort()) {
|
|
887
931
|
hash.update(`library\n${target}\n`)
|
|
@@ -929,14 +973,33 @@ interface SwiftNativeTargetPlan {
|
|
|
929
973
|
late?: { name: string; producers: string[] }
|
|
930
974
|
}
|
|
931
975
|
|
|
976
|
+
function swiftCrossImportFlags(moduleRoot: string, distribution: boolean): string[] {
|
|
977
|
+
const overlayRoot = path.join(
|
|
978
|
+
moduleRoot,
|
|
979
|
+
distribution ? 'modules' : 'cross-import-overlays',
|
|
980
|
+
)
|
|
981
|
+
return readdirSync(overlayRoot, { encoding: 'utf8', recursive: true })
|
|
982
|
+
.filter((file) => file.endsWith('.swiftoverlay'))
|
|
983
|
+
.sort((left, right) => left.localeCompare(right))
|
|
984
|
+
.flatMap((file) => [
|
|
985
|
+
'-Xfrontend',
|
|
986
|
+
'-swift-module-cross-import',
|
|
987
|
+
'-Xfrontend',
|
|
988
|
+
path.basename(path.dirname(file), '.swiftcrossimport'),
|
|
989
|
+
'-Xfrontend',
|
|
990
|
+
path.join(overlayRoot, file),
|
|
991
|
+
])
|
|
992
|
+
}
|
|
993
|
+
|
|
932
994
|
export function emitSwiftPackageManifest(args: {
|
|
933
995
|
targets: SwiftPackageTarget[]
|
|
996
|
+
packages?: ReadonlyMap<string, string>
|
|
934
997
|
cxxLanguageStandard?: string
|
|
935
998
|
native?: Map<string, SwiftNativeTargetPlan>
|
|
936
999
|
headerDirectory?: string
|
|
937
|
-
objcExports?: { modules: Set<string>;
|
|
938
|
-
/** the objective-c runtime and
|
|
939
|
-
nativeFlags?: string[]
|
|
1000
|
+
objcExports?: { modules: Set<string>; rootModule: string }
|
|
1001
|
+
/** the objective-c runtime, sdk and platform flags each target's original native units compile with. */
|
|
1002
|
+
nativeFlags?: Map<string, string[]>
|
|
940
1003
|
siblings: Map<string, string[]>
|
|
941
1004
|
moduleRoot: string
|
|
942
1005
|
oneModule?: boolean
|
|
@@ -985,21 +1048,7 @@ export function emitSwiftPackageManifest(args: {
|
|
|
985
1048
|
.join('\n') + '\n',
|
|
986
1049
|
)
|
|
987
1050
|
}
|
|
988
|
-
const
|
|
989
|
-
moduleRoot,
|
|
990
|
-
distribution ? 'modules' : 'cross-import-overlays',
|
|
991
|
-
)
|
|
992
|
-
const overlayFlags = readdirSync(overlayRoot, { encoding: 'utf8', recursive: true })
|
|
993
|
-
.filter((file) => file.endsWith('.swiftoverlay'))
|
|
994
|
-
.sort((left, right) => left.localeCompare(right))
|
|
995
|
-
.flatMap((file) => [
|
|
996
|
-
'-Xfrontend',
|
|
997
|
-
'-swift-module-cross-import',
|
|
998
|
-
'-Xfrontend',
|
|
999
|
-
path.basename(path.dirname(file), '.swiftcrossimport'),
|
|
1000
|
-
'-Xfrontend',
|
|
1001
|
-
path.join(overlayRoot, file),
|
|
1002
|
-
])
|
|
1051
|
+
const overlayFlags = swiftCrossImportFlags(moduleRoot, Boolean(distribution))
|
|
1003
1052
|
.map((flag) => `, ${JSON.stringify(flag)}`)
|
|
1004
1053
|
.join('')
|
|
1005
1054
|
const executable = targets.find((target) => target.executable)
|
|
@@ -1030,6 +1079,17 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1030
1079
|
const defines = (target.defines ?? [])
|
|
1031
1080
|
.map((name) => ` .define(${JSON.stringify(name)}),`)
|
|
1032
1081
|
.join('')
|
|
1082
|
+
const features = (target.experimentalFeatures ?? [])
|
|
1083
|
+
.map((name) => ` .enableExperimentalFeature(${JSON.stringify(name)}),`)
|
|
1084
|
+
.join('')
|
|
1085
|
+
const upcoming = (target.upcomingFeatures ?? [])
|
|
1086
|
+
.map((name) => ` .enableUpcomingFeature(${JSON.stringify(name)}),`)
|
|
1087
|
+
.join('')
|
|
1088
|
+
// the manifest's own raw flags last, where swiftpm puts a target's
|
|
1089
|
+
// settings: after the build's defaults, so they win as they do in xcode.
|
|
1090
|
+
const upstream = (target.swiftFlags ?? [])
|
|
1091
|
+
.map((flag) => `, ${JSON.stringify(flag)}`)
|
|
1092
|
+
.join('')
|
|
1033
1093
|
// a distribution's modules import from its modules/ directory, and its
|
|
1034
1094
|
// objects link as inputs, exactly as a source build links every object it
|
|
1035
1095
|
// compiled: whole, and ahead of the sdk libraries, so PeachICU's
|
|
@@ -1073,9 +1133,16 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1073
1133
|
)
|
|
1074
1134
|
? `, "-emit-objc-header-path", ${JSON.stringify(path.join(args.headerDirectory, `${target.name}-${args.objcExports?.modules.has(target.name) ? 'Cxx' : 'Swift'}.h`))}`
|
|
1075
1135
|
: ''
|
|
1076
|
-
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}])]`
|
|
1136
|
+
const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming}${exports} .unsafeFlags(["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ''}${imports}${nativeImports}${nativeImportFlags}${header}${upstream}])]`
|
|
1077
1137
|
const deps = [
|
|
1078
1138
|
...new Set([
|
|
1139
|
+
...(target.dependencies ?? []).flatMap((dependency) =>
|
|
1140
|
+
dependency.kind === 'product'
|
|
1141
|
+
? [
|
|
1142
|
+
`.product(name: ${JSON.stringify(dependency.name)}, package: ${JSON.stringify(dependency.package)})`,
|
|
1143
|
+
]
|
|
1144
|
+
: [],
|
|
1145
|
+
),
|
|
1079
1146
|
...(target.executable
|
|
1080
1147
|
? [
|
|
1081
1148
|
...new Set([
|
|
@@ -1154,12 +1221,12 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1154
1221
|
const cxxDefines = macroSettings(target.cxxDefines)
|
|
1155
1222
|
const nativeSettings = native?.clang
|
|
1156
1223
|
? [
|
|
1157
|
-
`cSettings: [${cDefines} .unsafeFlags(${JSON.stringify([...(args.
|
|
1158
|
-
`cxxSettings: [${cxxDefines} .unsafeFlags(${JSON.stringify(['-fno-cxx-modules', ...(args.
|
|
1224
|
+
`cSettings: [${cDefines} .unsafeFlags(${JSON.stringify([...(args.nativeFlags?.get(target.name) ?? []), ...native.clang.flags])})]`,
|
|
1225
|
+
`cxxSettings: [${cxxDefines} .unsafeFlags(${JSON.stringify(['-fno-cxx-modules', ...(args.nativeFlags?.get(target.name) ?? []), ...native.clang.cxxFlags])})]`,
|
|
1159
1226
|
].join(', ')
|
|
1160
1227
|
: [
|
|
1161
|
-
`cSettings: [${cDefines} .unsafeFlags(${JSON.stringify([...(args.
|
|
1162
|
-
`cxxSettings: [${cxxDefines} .unsafeFlags(${JSON.stringify(['-fno-cxx-modules', ...(args.
|
|
1228
|
+
`cSettings: [${cDefines} .unsafeFlags(${JSON.stringify([...(args.nativeFlags?.get(target.name) ?? []), ...(native?.flags ?? [])])})]`,
|
|
1229
|
+
`cxxSettings: [${cxxDefines} .unsafeFlags(${JSON.stringify(['-fno-cxx-modules', ...(args.nativeFlags?.get(target.name) ?? []), ...(native?.cxxFlags ?? [])])})]`,
|
|
1163
1230
|
].join(', ')
|
|
1164
1231
|
return [
|
|
1165
1232
|
` ${kind}(`,
|
|
@@ -1177,6 +1244,9 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1177
1244
|
: native?.flags
|
|
1178
1245
|
? [` sources: ${JSON.stringify(native.sources)},`]
|
|
1179
1246
|
: []),
|
|
1247
|
+
...(!native?.clang && target.publicHeadersPath !== undefined
|
|
1248
|
+
? [` publicHeadersPath: ${JSON.stringify(target.publicHeadersPath)},`]
|
|
1249
|
+
: []),
|
|
1180
1250
|
// the native backend supplies dependency module maps without their
|
|
1181
1251
|
// compiled modules. textual c++ includes keep those dependencies usable.
|
|
1182
1252
|
` ${clang ? nativeSettings : swiftSettings}${link}`,
|
|
@@ -1193,7 +1263,13 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1193
1263
|
'let package = Package(',
|
|
1194
1264
|
' name: "app",',
|
|
1195
1265
|
` products: [.executable(name: "${executable.name}", targets: ["${executable.name}"])],`,
|
|
1196
|
-
` dependencies: [${
|
|
1266
|
+
` dependencies: [${[
|
|
1267
|
+
...(distribution ? [] : [`.package(path: ${JSON.stringify(moduleRoot)})`]),
|
|
1268
|
+
...[...(args.packages ?? [])].map(
|
|
1269
|
+
([name, directory]) =>
|
|
1270
|
+
`.package(name: ${JSON.stringify(name)}, path: ${JSON.stringify(directory)})`,
|
|
1271
|
+
),
|
|
1272
|
+
].join(', ')}],`,
|
|
1197
1273
|
' targets: [',
|
|
1198
1274
|
...targets.map(stanza),
|
|
1199
1275
|
...(args.objcExports
|
|
@@ -1203,7 +1279,7 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1203
1279
|
' path: "PeachObjCExports",',
|
|
1204
1280
|
` sources: ${JSON.stringify(['root.m', ...[...args.objcExports.modules].map((name) => `${name}.m`)])},`,
|
|
1205
1281
|
' publicHeadersPath: "include",',
|
|
1206
|
-
` cSettings: [.unsafeFlags(${JSON.stringify([...args.objcExports.
|
|
1282
|
+
` cSettings: [.unsafeFlags(${JSON.stringify([...args.nativeFlags!.get(args.objcExports.rootModule)!.filter((flag) => flag !== '-fobjc-arc'), '-fno-objc-arc', '-Xclang', '-disable-objc-default-synthesize-properties'])})]),`,
|
|
1207
1283
|
]
|
|
1208
1284
|
: []),
|
|
1209
1285
|
...[...(args.native?.entries() ?? [])].flatMap(([name, native]) => {
|
|
@@ -1225,8 +1301,8 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1225
1301
|
` path: ${JSON.stringify(native.clang ? '.' : native.path)},`,
|
|
1226
1302
|
` sources: ${JSON.stringify(native.clang ? group.sources.map((source) => path.posix.join(native.path, source)) : group.sources)},`,
|
|
1227
1303
|
` publicHeadersPath: ${JSON.stringify(native.clang ? path.posix.dirname(native.clang.modulemap) : 'include')},`,
|
|
1228
|
-
` cSettings: [${macroSettings(owner?.cDefines)} .unsafeFlags(${JSON.stringify([...(args.
|
|
1229
|
-
` cxxSettings: [${macroSettings(owner?.cxxDefines)} .unsafeFlags(${JSON.stringify(['-fno-cxx-modules', ...(args.
|
|
1304
|
+
` cSettings: [${macroSettings(owner?.cDefines)} .unsafeFlags(${JSON.stringify([...(args.nativeFlags?.get(name) ?? []), ...group.flags])})],`,
|
|
1305
|
+
` cxxSettings: [${macroSettings(owner?.cxxDefines)} .unsafeFlags(${JSON.stringify(['-fno-cxx-modules', ...(args.nativeFlags?.get(name) ?? []), '-I', native.includeDirectory, '-I', args.headerDirectory, ...group.cxxFlags])})]),`,
|
|
1230
1306
|
])
|
|
1231
1307
|
: []
|
|
1232
1308
|
}),
|
|
@@ -5722,9 +5798,12 @@ export function swiftSourceClosure(
|
|
|
5722
5798
|
return Object.fromEntries(Object.entries(files).filter(([file]) => included.has(file)))
|
|
5723
5799
|
}
|
|
5724
5800
|
|
|
5725
|
-
/**
|
|
5801
|
+
/** application entries, excluding comments, strings and inactive branches. */
|
|
5726
5802
|
export function swiftApplicationEntry(file: string, source: string): boolean {
|
|
5727
|
-
const
|
|
5803
|
+
const code = [...swiftConditionalLines(swiftCodeMask(source))]
|
|
5804
|
+
.map(({ line, active }) => (active === false ? ' '.repeat(line.length) : line))
|
|
5805
|
+
.join('\n')
|
|
5806
|
+
const { tokens } = swiftCodeScan(code)
|
|
5728
5807
|
let depth = 0
|
|
5729
5808
|
for (const at of tokens) {
|
|
5730
5809
|
if (source[at] === '{') depth++
|
|
@@ -5741,6 +5820,287 @@ export function swiftApplicationEntry(file: string, source: string): boolean {
|
|
|
5741
5820
|
return false
|
|
5742
5821
|
}
|
|
5743
5822
|
|
|
5823
|
+
// a c-family entry: a main definition outside comments and strings. headers
|
|
5824
|
+
// never compile, so only sources are scanned.
|
|
5825
|
+
/** the macro environment a c-family entry guard evaluates against. */
|
|
5826
|
+
export interface SwiftCMacroEnvironment {
|
|
5827
|
+
/** the target's -D set, with values where given. */
|
|
5828
|
+
defines: ReadonlyMap<string, string | undefined>
|
|
5829
|
+
/** the compiler's own predefines for the unit's language. */
|
|
5830
|
+
predefines: ReadonlyMap<string, string | undefined>
|
|
5831
|
+
/** names any of the target's own sources or headers defines. */
|
|
5832
|
+
targetDefined: ReadonlySet<string>
|
|
5833
|
+
}
|
|
5834
|
+
|
|
5835
|
+
const emptyMacroEnvironment: SwiftCMacroEnvironment = {
|
|
5836
|
+
defines: new Map(),
|
|
5837
|
+
predefines: new Map(),
|
|
5838
|
+
targetDefined: new Set(),
|
|
5839
|
+
}
|
|
5840
|
+
|
|
5841
|
+
// whether the environment defines the name: -D and predefines decide,
|
|
5842
|
+
// a name only the target's own sources define is undecided (order and
|
|
5843
|
+
// conditions are not evaluated), and a name nowhere visible is absent.
|
|
5844
|
+
function cMacroDefined(name: string, env: SwiftCMacroEnvironment): boolean | undefined {
|
|
5845
|
+
if (env.defines.has(name) || env.predefines.has(name)) return true
|
|
5846
|
+
if (env.targetDefined.has(name)) return undefined
|
|
5847
|
+
return false
|
|
5848
|
+
}
|
|
5849
|
+
|
|
5850
|
+
function cMacroIntOrTrue(value: string | undefined): boolean | undefined {
|
|
5851
|
+
if (value === undefined) return true
|
|
5852
|
+
if (/^0[xX][0-9a-fA-F]+[uUlL]*$/.test(value) || /^\d+[uUlL]*$/.test(value))
|
|
5853
|
+
return Number.parseInt(value) !== 0
|
|
5854
|
+
return undefined
|
|
5855
|
+
}
|
|
5856
|
+
|
|
5857
|
+
function cMacroBareValue(name: string, env: SwiftCMacroEnvironment): boolean | undefined {
|
|
5858
|
+
if (env.defines.has(name)) return cMacroIntOrTrue(env.defines.get(name))
|
|
5859
|
+
if (env.predefines.has(name)) return cMacroIntOrTrue(env.predefines.get(name))
|
|
5860
|
+
if (env.targetDefined.has(name)) return undefined
|
|
5861
|
+
return false
|
|
5862
|
+
}
|
|
5863
|
+
|
|
5864
|
+
function cMacroNegated(name: string, env: SwiftCMacroEnvironment): boolean | undefined {
|
|
5865
|
+
const value = cMacroDefined(name, env)
|
|
5866
|
+
return value === undefined ? undefined : !value
|
|
5867
|
+
}
|
|
5868
|
+
|
|
5869
|
+
// a preprocessor condition the macro environment decides, or undefined when
|
|
5870
|
+
// the text needs the real preprocessor (comparisons, function-like macros,
|
|
5871
|
+
// __has_include and the like). only defined-ness, boolean operators and
|
|
5872
|
+
// integer literals evaluate; the rest is undecided.
|
|
5873
|
+
function cConditionValue(
|
|
5874
|
+
expression: string,
|
|
5875
|
+
env: SwiftCMacroEnvironment,
|
|
5876
|
+
): boolean | undefined {
|
|
5877
|
+
let i = 0
|
|
5878
|
+
const skipSpaces = () => {
|
|
5879
|
+
while (i < expression.length && /\s/.test(expression[i]!)) i++
|
|
5880
|
+
}
|
|
5881
|
+
const parseOr = (): boolean | undefined => {
|
|
5882
|
+
let value = parseAnd()
|
|
5883
|
+
for (;;) {
|
|
5884
|
+
skipSpaces()
|
|
5885
|
+
if (!expression.startsWith('||', i)) return value
|
|
5886
|
+
i += 2
|
|
5887
|
+
const right = parseAnd()
|
|
5888
|
+
value = value === undefined || right === undefined ? undefined : value || right
|
|
5889
|
+
}
|
|
5890
|
+
}
|
|
5891
|
+
const parseAnd = (): boolean | undefined => {
|
|
5892
|
+
let value = parseUnary()
|
|
5893
|
+
for (;;) {
|
|
5894
|
+
skipSpaces()
|
|
5895
|
+
if (!expression.startsWith('&&', i)) return value
|
|
5896
|
+
i += 2
|
|
5897
|
+
const right = parseUnary()
|
|
5898
|
+
value = value === undefined || right === undefined ? undefined : value && right
|
|
5899
|
+
}
|
|
5900
|
+
}
|
|
5901
|
+
const parseUnary = (): boolean | undefined => {
|
|
5902
|
+
skipSpaces()
|
|
5903
|
+
if (expression[i] === '!') {
|
|
5904
|
+
i++
|
|
5905
|
+
const value = parseUnary()
|
|
5906
|
+
return value === undefined ? undefined : !value
|
|
5907
|
+
}
|
|
5908
|
+
if (expression[i] === '(') {
|
|
5909
|
+
i++
|
|
5910
|
+
const value = parseOr()
|
|
5911
|
+
skipSpaces()
|
|
5912
|
+
return expression[i] === ')' ? (i++, value) : undefined
|
|
5913
|
+
}
|
|
5914
|
+
const defined = /^defined\b/.exec(expression.slice(i))
|
|
5915
|
+
if (defined) {
|
|
5916
|
+
i += defined[0].length
|
|
5917
|
+
skipSpaces()
|
|
5918
|
+
const parenthesized = expression[i] === '('
|
|
5919
|
+
if (parenthesized) {
|
|
5920
|
+
i++
|
|
5921
|
+
skipSpaces()
|
|
5922
|
+
}
|
|
5923
|
+
const name = /^\w+/.exec(expression.slice(i))?.[0]
|
|
5924
|
+
if (!name) return undefined
|
|
5925
|
+
i += name.length
|
|
5926
|
+
skipSpaces()
|
|
5927
|
+
if (parenthesized) {
|
|
5928
|
+
if (expression[i] !== ')') return undefined
|
|
5929
|
+
i++
|
|
5930
|
+
}
|
|
5931
|
+
return cMacroDefined(name, env)
|
|
5932
|
+
}
|
|
5933
|
+
const literal = /^(0[xX][0-9a-fA-F]+|\d+)[uUlL]*/.exec(expression.slice(i))
|
|
5934
|
+
if (literal) {
|
|
5935
|
+
i += literal[0].length
|
|
5936
|
+
return Number(literal[1]) !== 0
|
|
5937
|
+
}
|
|
5938
|
+
const name = /^\w+/.exec(expression.slice(i))?.[0]
|
|
5939
|
+
if (!name) return undefined
|
|
5940
|
+
i += name.length
|
|
5941
|
+
return cMacroBareValue(name, env)
|
|
5942
|
+
}
|
|
5943
|
+
const value = parseOr()
|
|
5944
|
+
skipSpaces()
|
|
5945
|
+
return i === expression.length ? value : undefined
|
|
5946
|
+
}
|
|
5947
|
+
|
|
5948
|
+
// the lines xcode's preprocessor keeps: conditional directives evaluated
|
|
5949
|
+
// against the macro environment, with undecided branches kept, so an entry
|
|
5950
|
+
// guard the text cannot decide still counts.
|
|
5951
|
+
function cActiveCode(code: string, env: SwiftCMacroEnvironment): string {
|
|
5952
|
+
const kept: string[] = []
|
|
5953
|
+
const stack: { parent: boolean; taken: boolean }[] = []
|
|
5954
|
+
let active = true
|
|
5955
|
+
for (const line of code.replace(/\\\r?\n/g, '').split('\n')) {
|
|
5956
|
+
const directive =
|
|
5957
|
+
/^\s*#\s*(if|ifdef|ifndef|elif|elifdef|elifndef|else|endif)\b(.*)$/.exec(line)
|
|
5958
|
+
if (!directive) {
|
|
5959
|
+
if (active) kept.push(line)
|
|
5960
|
+
continue
|
|
5961
|
+
}
|
|
5962
|
+
const keyword = directive[1]!
|
|
5963
|
+
const rest = directive[2]!.trim()
|
|
5964
|
+
if (keyword === 'if' || keyword === 'ifdef' || keyword === 'ifndef') {
|
|
5965
|
+
const name = /^\w+$/.exec(rest)?.[0]
|
|
5966
|
+
const value =
|
|
5967
|
+
keyword === 'if'
|
|
5968
|
+
? cConditionValue(rest, env)
|
|
5969
|
+
: name === undefined
|
|
5970
|
+
? undefined
|
|
5971
|
+
: keyword === 'ifdef'
|
|
5972
|
+
? cMacroDefined(name, env)
|
|
5973
|
+
: cMacroNegated(name, env)
|
|
5974
|
+
stack.push({ parent: active, taken: value === true })
|
|
5975
|
+
active = active && value !== false
|
|
5976
|
+
} else if (keyword === 'endif') {
|
|
5977
|
+
active = stack.pop()?.parent ?? true
|
|
5978
|
+
} else if (stack.length === 0) {
|
|
5979
|
+
continue
|
|
5980
|
+
} else {
|
|
5981
|
+
const frame = stack[stack.length - 1]!
|
|
5982
|
+
if (keyword === 'else') {
|
|
5983
|
+
active = frame.parent && !frame.taken
|
|
5984
|
+
frame.taken = true
|
|
5985
|
+
} else {
|
|
5986
|
+
const name = /^\w+$/.exec(rest)?.[0]
|
|
5987
|
+
const value =
|
|
5988
|
+
keyword === 'elif'
|
|
5989
|
+
? cConditionValue(rest, env)
|
|
5990
|
+
: name === undefined
|
|
5991
|
+
? undefined
|
|
5992
|
+
: keyword === 'elifdef'
|
|
5993
|
+
? cMacroDefined(name, env)
|
|
5994
|
+
: cMacroNegated(name, env)
|
|
5995
|
+
const branch = !frame.taken && value !== false
|
|
5996
|
+
if (branch && value === true) frame.taken = true
|
|
5997
|
+
active = frame.parent && branch
|
|
5998
|
+
}
|
|
5999
|
+
}
|
|
6000
|
+
}
|
|
6001
|
+
return kept.join('\n')
|
|
6002
|
+
}
|
|
6003
|
+
|
|
6004
|
+
// the source with comments and string and character literals removed,
|
|
6005
|
+
// newlines kept so directive lines stay intact.
|
|
6006
|
+
function stripCCode(source: string): string {
|
|
6007
|
+
let code = ''
|
|
6008
|
+
let i = 0
|
|
6009
|
+
while (i < source.length) {
|
|
6010
|
+
if (source.startsWith('//', i)) {
|
|
6011
|
+
const end = source.indexOf('\n', i)
|
|
6012
|
+
i = end === -1 ? source.length : end
|
|
6013
|
+
} else if (source.startsWith('/*', i)) {
|
|
6014
|
+
const end = source.indexOf('*/', i + 2)
|
|
6015
|
+
i = end === -1 ? source.length : end + 2
|
|
6016
|
+
} else if (source[i] === '"' || source[i] === "'") {
|
|
6017
|
+
const quote = source[i]!
|
|
6018
|
+
i++
|
|
6019
|
+
while (i < source.length && source[i] !== quote) i += source[i] === '\\' ? 2 : 1
|
|
6020
|
+
i++
|
|
6021
|
+
} else {
|
|
6022
|
+
code += source[i]
|
|
6023
|
+
i++
|
|
6024
|
+
}
|
|
6025
|
+
}
|
|
6026
|
+
return code
|
|
6027
|
+
}
|
|
6028
|
+
|
|
6029
|
+
// every name the given sources define. order and conditions are not
|
|
6030
|
+
// evaluated: a name defined anywhere makes its guards undecided.
|
|
6031
|
+
export function swiftCDefinedNames(sources: Iterable<string>): Set<string> {
|
|
6032
|
+
const names = new Set<string>()
|
|
6033
|
+
for (const source of sources)
|
|
6034
|
+
for (const line of stripCCode(source).split('\n')) {
|
|
6035
|
+
const name = /^\s*#\s*define\s+([A-Za-z_]\w*)/.exec(line)?.[1]
|
|
6036
|
+
if (name) names.add(name)
|
|
6037
|
+
}
|
|
6038
|
+
return names
|
|
6039
|
+
}
|
|
6040
|
+
|
|
6041
|
+
type SwiftCPredefinesTable = {
|
|
6042
|
+
release: string
|
|
6043
|
+
languages: Record<string, Record<string, string | null>>
|
|
6044
|
+
}
|
|
6045
|
+
const cPredefineTable: SwiftCPredefinesTable = cPredefinesJson
|
|
6046
|
+
const cPredefineCache = new Map<string, Map<string, string | undefined>>()
|
|
6047
|
+
|
|
6048
|
+
// the compiler's own macros for the language xcode compiles the unit with:
|
|
6049
|
+
// the pinned toolchain clang's `-dM -E -target arm64-apple-ios` predefines,
|
|
6050
|
+
// committed in generated/swift-c-predefines.json and held at the pinned
|
|
6051
|
+
// release by scripts/check/swift-c-predefines-generated.ts. a table, not a
|
|
6052
|
+
// spawn, so the scan works hosted, on linux and without xcode. the triple
|
|
6053
|
+
// is the arm64-apple-ios device triple (TARGET_OS_SIMULATOR is 0 there; it
|
|
6054
|
+
// is 1 for the simulator SDK), matching the shipping configuration.
|
|
6055
|
+
export function swiftCPredefines(
|
|
6056
|
+
language: 'c' | 'c++' | 'objective-c' | 'objective-c++',
|
|
6057
|
+
): Map<string, string | undefined> {
|
|
6058
|
+
const cached = cPredefineCache.get(language)
|
|
6059
|
+
if (cached) return cached
|
|
6060
|
+
const predefines = new Map<string, string | undefined>()
|
|
6061
|
+
for (const [name, value] of Object.entries(cPredefineTable.languages[language]))
|
|
6062
|
+
predefines.set(name, value ?? undefined)
|
|
6063
|
+
cPredefineCache.set(language, predefines)
|
|
6064
|
+
return predefines
|
|
6065
|
+
}
|
|
6066
|
+
|
|
6067
|
+
export function swiftCMainEntry(
|
|
6068
|
+
file: string,
|
|
6069
|
+
source: string,
|
|
6070
|
+
env: SwiftCMacroEnvironment = emptyMacroEnvironment,
|
|
6071
|
+
): boolean {
|
|
6072
|
+
if (!isSwiftNativeTranslationUnit(file)) return false
|
|
6073
|
+
const code = cActiveCode(stripCCode(source), env)
|
|
6074
|
+
for (const match of code.matchAll(/^\s*(?:int\s+|void\s+)?main\s*\(/gm)) {
|
|
6075
|
+
// a definition opens its body after the parameter list and any
|
|
6076
|
+
// trailing declarators (noexcept, attributes); a declaration or a
|
|
6077
|
+
// call ends with a semicolon instead.
|
|
6078
|
+
let depth = 1
|
|
6079
|
+
let index = match.index + match[0].length
|
|
6080
|
+
for (; index < code.length && depth > 0; index++) {
|
|
6081
|
+
if (code[index] === '(') depth++
|
|
6082
|
+
else if (code[index] === ')') depth--
|
|
6083
|
+
}
|
|
6084
|
+
if (depth > 0) continue
|
|
6085
|
+
for (; index < code.length; index++) {
|
|
6086
|
+
const char = code[index]
|
|
6087
|
+
if (char === '{') return true
|
|
6088
|
+
if (char === ';' || char === '}') break
|
|
6089
|
+
// a trailing declarator group (noexcept(...), attributes);
|
|
6090
|
+
// braces inside it belong to the declarator, not a body.
|
|
6091
|
+
if (char === '(' || char === '[') {
|
|
6092
|
+
const closer = char === '(' ? ')' : ']'
|
|
6093
|
+
let nested = 1
|
|
6094
|
+
while (nested > 0 && ++index < code.length) {
|
|
6095
|
+
if (code[index] === char) nested++
|
|
6096
|
+
else if (code[index] === closer) nested--
|
|
6097
|
+
}
|
|
6098
|
+
}
|
|
6099
|
+
}
|
|
6100
|
+
}
|
|
6101
|
+
return false
|
|
6102
|
+
}
|
|
6103
|
+
|
|
5744
6104
|
// swift's executable entry runs after the reactor's _initialize has completed.
|
|
5745
6105
|
// global swift values remain lazy; native application initializers need separate
|
|
5746
6106
|
// object evidence and are refused here rather than running the registry early.
|
|
@@ -5756,7 +6116,7 @@ function installObjcPeerStartup(
|
|
|
5756
6116
|
}
|
|
5757
6117
|
if (
|
|
5758
6118
|
(input.nativeTargets?.length ?? 0) > 0 ||
|
|
5759
|
-
Object.keys(input.files).some(
|
|
6119
|
+
Object.keys(input.files).some(isSwiftNativeTranslationUnit)
|
|
5760
6120
|
)
|
|
5761
6121
|
fail('original native source targets require constructor provenance before admission')
|
|
5762
6122
|
validateObjcPeerStartupLibraries(input.libraries ?? {})
|
|
@@ -6007,6 +6367,19 @@ export function writeSwiftProject(
|
|
|
6007
6367
|
throw new Error('swift compile input has invalid Objective-C peer startup metadata')
|
|
6008
6368
|
if (input.nativeTargets !== undefined && !isSwiftNativeTargets(input.nativeTargets))
|
|
6009
6369
|
throw new Error('swift compile input has invalid original clang target inputs')
|
|
6370
|
+
if (input.packageFiles !== undefined && !isSwiftPackageFiles(input.packageFiles))
|
|
6371
|
+
throw new Error('swift compile input has invalid original package files')
|
|
6372
|
+
const packages = input.packageFiles
|
|
6373
|
+
? swiftManifestPackages(input.files['Package.swift'] ?? '')
|
|
6374
|
+
: new Map<string, string>()
|
|
6375
|
+
for (const directory of packages.values())
|
|
6376
|
+
if (
|
|
6377
|
+
!isSwiftResourcePath(directory) ||
|
|
6378
|
+
!Object.hasOwn(input.packageFiles ?? {}, `${directory}/Package.swift`)
|
|
6379
|
+
)
|
|
6380
|
+
throw new Error(
|
|
6381
|
+
`swift compile input has no transported package manifest for ${directory}`,
|
|
6382
|
+
)
|
|
6010
6383
|
if (
|
|
6011
6384
|
input.resourceBundles !== undefined &&
|
|
6012
6385
|
!isSwiftResourceBundles(input.resourceBundles)
|
|
@@ -6062,6 +6435,18 @@ export function writeSwiftProject(
|
|
|
6062
6435
|
}
|
|
6063
6436
|
>()
|
|
6064
6437
|
const objcProducers = new Set<string>()
|
|
6438
|
+
// the pinned toolchain, checked once for every original target.
|
|
6439
|
+
let checkedToolchain: string | undefined
|
|
6440
|
+
const nativeToolchain = () => {
|
|
6441
|
+
if (checkedToolchain) return checkedToolchain
|
|
6442
|
+
const pin: { release: string } =
|
|
6443
|
+
distribution ??
|
|
6444
|
+
JSON.parse(readFileSync(path.join(moduleRoot, 'toolchain.json'), 'utf8'))
|
|
6445
|
+
checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot))
|
|
6446
|
+
return checkedToolchain
|
|
6447
|
+
}
|
|
6448
|
+
const deploymentTarget = (name: string) =>
|
|
6449
|
+
input.nativeTargets?.find((value) => value.name === name)?.deploymentTarget ?? '16.0'
|
|
6065
6450
|
const targetStagedFiles = new Map<string, Map<string, string | Buffer | undefined>>()
|
|
6066
6451
|
const stageTargetFile = (
|
|
6067
6452
|
target: string,
|
|
@@ -6110,7 +6495,7 @@ export function writeSwiftProject(
|
|
|
6110
6495
|
}
|
|
6111
6496
|
targetStagedFiles.delete(target.name)
|
|
6112
6497
|
if (
|
|
6113
|
-
entries.some(([file]) =>
|
|
6498
|
+
entries.some(([file]) => isSwiftNativeTranslationUnit(file)) &&
|
|
6114
6499
|
(swift || input.nativeTargets?.some((value) => value.name === target.name))
|
|
6115
6500
|
) {
|
|
6116
6501
|
if (!swift) {
|
|
@@ -6195,7 +6580,7 @@ export function writeSwiftProject(
|
|
|
6195
6580
|
for (const target of targets) {
|
|
6196
6581
|
const prefix = target.path === '.' ? '' : `${target.path}/`
|
|
6197
6582
|
const entries = targetEntries(target)
|
|
6198
|
-
const units = entries.filter(([file]) =>
|
|
6583
|
+
const units = entries.filter(([file]) => isSwiftNativeTranslationUnit(file))
|
|
6199
6584
|
if (units.length === 0) continue
|
|
6200
6585
|
const includes = `${prefix}include/`
|
|
6201
6586
|
const consumers = new Map<string, Set<string>>()
|
|
@@ -6251,17 +6636,14 @@ export function writeSwiftProject(
|
|
|
6251
6636
|
mkdirSync(path.dirname(destination), { recursive: true })
|
|
6252
6637
|
writeFileSync(destination, input.files[file]!)
|
|
6253
6638
|
}
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
JSON.parse(readFileSync(path.join(moduleRoot, 'toolchain.json'), 'utf8'))
|
|
6263
|
-
const release = pin.release
|
|
6264
|
-
const toolchainBin = swiftToolchain(release, swiftModuleSdk(moduleRoot))
|
|
6639
|
+
// xcode searches only the target's search paths and header maps; a
|
|
6640
|
+
// -I per header directory would let an angle include land on a
|
|
6641
|
+
// project header xcode never exposes (damus: <stdint.h> on flatcc's
|
|
6642
|
+
// portable/include/std/stdint.h instead of the sdk).
|
|
6643
|
+
const search = [...new Set([...(settings?.headerSearchPaths ?? [])])].flatMap(
|
|
6644
|
+
(dir) => ['-I', path.join(layout.root, dir)],
|
|
6645
|
+
)
|
|
6646
|
+
const toolchainBin = nativeToolchain()
|
|
6265
6647
|
const sdkHeaders = materializeObjcSdk(
|
|
6266
6648
|
path.join(layout.root, '.build', 'peach-objc-sdk'),
|
|
6267
6649
|
)
|
|
@@ -6301,7 +6683,8 @@ export function writeSwiftProject(
|
|
|
6301
6683
|
?.resources ?? false,
|
|
6302
6684
|
usesBundleMacro: entries.some(
|
|
6303
6685
|
([file, contents]) =>
|
|
6304
|
-
|
|
6686
|
+
(isSwiftNativeTranslationUnit(file) ||
|
|
6687
|
+
/\.(?:h|hpp|hh|hxx)$/.test(file)) &&
|
|
6305
6688
|
/\bSWIFTPM_MODULE_BUNDLE\b/.test(contents),
|
|
6306
6689
|
),
|
|
6307
6690
|
bundles: input.resourceBundles,
|
|
@@ -6362,7 +6745,7 @@ export function writeSwiftProject(
|
|
|
6362
6745
|
path.join(layout.root, '.build', 'peach-objc-imports', target.name),
|
|
6363
6746
|
{
|
|
6364
6747
|
flags: stageFlags(originalFlags, path.join(sdkHeaders, 'usr/include')),
|
|
6365
|
-
target: `arm64-apple-ios${
|
|
6748
|
+
target: `arm64-apple-ios${deploymentTarget(target.name)}-simulator`,
|
|
6366
6749
|
},
|
|
6367
6750
|
)
|
|
6368
6751
|
const defined = new Set<string>()
|
|
@@ -6869,26 +7252,42 @@ export function writeSwiftProject(
|
|
|
6869
7252
|
`import ${swiftTargetModuleName(target.name)}\n@main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }\n`,
|
|
6870
7253
|
)
|
|
6871
7254
|
}
|
|
6872
|
-
// original units compile on the objective-c runtime
|
|
6873
|
-
// exports anything to them.
|
|
7255
|
+
// original units compile on the objective-c runtime, at their target's
|
|
7256
|
+
// deployment minimum, whether or not swift exports anything to them.
|
|
6874
7257
|
const nativeFlags = (() => {
|
|
6875
7258
|
if (native.size === 0) return undefined
|
|
6876
7259
|
const headers = materializeObjcSdk(path.join(layout.root, '.build', 'peach-objc-sdk'))
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
7260
|
+
const moduleMaps = rootOwner
|
|
7261
|
+
? [...objcModules].map(
|
|
7262
|
+
(name) =>
|
|
7263
|
+
`-fmodule-map-file=${path.join(headerModuleDirectory, name, 'module.modulemap')}`,
|
|
7264
|
+
)
|
|
7265
|
+
: []
|
|
7266
|
+
return new Map(
|
|
7267
|
+
targets.map((target) => {
|
|
7268
|
+
const version = deploymentTarget(target.name)
|
|
7269
|
+
const minimum = iosDeploymentMinimum(version)
|
|
7270
|
+
if (minimum === undefined)
|
|
7271
|
+
throw new Error(
|
|
7272
|
+
`${target.name}: unsupported IPHONEOS_DEPLOYMENT_TARGET ${JSON.stringify(version)}`,
|
|
7273
|
+
)
|
|
7274
|
+
return [
|
|
7275
|
+
target.name,
|
|
7276
|
+
[
|
|
7277
|
+
'-fobjc-runtime=gnustep-2.2',
|
|
7278
|
+
'-fobjc-exceptions',
|
|
7279
|
+
'-fexceptions',
|
|
7280
|
+
'-fwasm-exceptions',
|
|
7281
|
+
'-fobjc-arc',
|
|
7282
|
+
'-fblocks',
|
|
7283
|
+
...objcSdkIntakeFlags(headers, nativeToolchain(), minimum),
|
|
7284
|
+
'-I',
|
|
7285
|
+
headerDirectory,
|
|
7286
|
+
...moduleMaps,
|
|
7287
|
+
],
|
|
7288
|
+
]
|
|
7289
|
+
}),
|
|
7290
|
+
)
|
|
6892
7291
|
})()
|
|
6893
7292
|
let objcExports: Parameters<typeof emitSwiftPackageManifest>[0]['objcExports']
|
|
6894
7293
|
if (rootOwner && input.objcPeerStartup)
|
|
@@ -6951,17 +7350,7 @@ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nati
|
|
|
6951
7350
|
'',
|
|
6952
7351
|
].join('\n'),
|
|
6953
7352
|
)
|
|
6954
|
-
objcExports = {
|
|
6955
|
-
modules: objcModules,
|
|
6956
|
-
rootModule,
|
|
6957
|
-
flags: [
|
|
6958
|
-
...nativeFlags!,
|
|
6959
|
-
...[...objcModules].map(
|
|
6960
|
-
(name) =>
|
|
6961
|
-
`-fmodule-map-file=${path.join(headerModuleDirectory, name, 'module.modulemap')}`,
|
|
6962
|
-
),
|
|
6963
|
-
],
|
|
6964
|
-
}
|
|
7353
|
+
objcExports = { modules: objcModules, rootModule }
|
|
6965
7354
|
}
|
|
6966
7355
|
if (targets.length === 0) {
|
|
6967
7356
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
@@ -7033,6 +7422,7 @@ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nati
|
|
|
7033
7422
|
path.join(layout.root, 'Package.swift'),
|
|
7034
7423
|
emitSwiftPackageManifest({
|
|
7035
7424
|
targets,
|
|
7425
|
+
packages,
|
|
7036
7426
|
native,
|
|
7037
7427
|
objcExports,
|
|
7038
7428
|
nativeFlags,
|
|
@@ -7056,6 +7446,35 @@ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nati
|
|
|
7056
7446
|
}) + moduleFiles,
|
|
7057
7447
|
)
|
|
7058
7448
|
}
|
|
7449
|
+
for (const [file, bytes] of Object.entries(input.packageFiles ?? {}))
|
|
7450
|
+
files.set(path.join(layout.root, file), Buffer.from(bytes, 'base64'))
|
|
7451
|
+
if (input.packageFiles) {
|
|
7452
|
+
files.set(
|
|
7453
|
+
path.join(layout.root, '.peach-target-toolset.json'),
|
|
7454
|
+
JSON.stringify({
|
|
7455
|
+
schemaVersion: '1.0',
|
|
7456
|
+
swiftCompiler: {
|
|
7457
|
+
extraCLIOptions: [
|
|
7458
|
+
'-I',
|
|
7459
|
+
distribution
|
|
7460
|
+
? path.join(moduleRoot, 'modules')
|
|
7461
|
+
: path.join(layout.root, '.build', WASM_TRIPLE, 'release', 'Modules'),
|
|
7462
|
+
'-Xfrontend',
|
|
7463
|
+
'-enable-cross-import-overlays',
|
|
7464
|
+
...swiftCrossImportFlags(moduleRoot, Boolean(distribution)),
|
|
7465
|
+
...(distribution
|
|
7466
|
+
? FOUNDATION_IMPLICIT_MODULES.flatMap((module) => [
|
|
7467
|
+
'-Xfrontend',
|
|
7468
|
+
'-import-module',
|
|
7469
|
+
'-Xfrontend',
|
|
7470
|
+
module,
|
|
7471
|
+
])
|
|
7472
|
+
: []),
|
|
7473
|
+
],
|
|
7474
|
+
},
|
|
7475
|
+
}),
|
|
7476
|
+
)
|
|
7477
|
+
}
|
|
7059
7478
|
// resource accessors and the /res pack share the original target assignment.
|
|
7060
7479
|
for (const target of resourceTargets) {
|
|
7061
7480
|
if (!target.resources) continue
|
|
@@ -7525,6 +7944,9 @@ export function compileSwiftProjectUnit(
|
|
|
7525
7944
|
...swiftSdkOptions(),
|
|
7526
7945
|
'--swift-sdk',
|
|
7527
7946
|
sdk,
|
|
7947
|
+
...(input.packageFiles
|
|
7948
|
+
? ['--toolset', path.join(root, '.peach-target-toolset.json')]
|
|
7949
|
+
: []),
|
|
7528
7950
|
'-c',
|
|
7529
7951
|
'release',
|
|
7530
7952
|
'-Xswiftc',
|
|
@@ -7563,6 +7985,17 @@ export function compileSwiftProjectUnit(
|
|
|
7563
7985
|
}
|
|
7564
7986
|
report('compiling and linking Swift modules')
|
|
7565
7987
|
try {
|
|
7988
|
+
if (input.packageFiles && !swiftDistributionAt(moduleRoot)) {
|
|
7989
|
+
const frameworks = new Set(['SwiftUI'])
|
|
7990
|
+
for (const name of input.packageGuestImports ?? [])
|
|
7991
|
+
if (OPTIONAL_FRAMEWORKS.has(name)) frameworks.add(name)
|
|
7992
|
+
for (const framework of frameworks)
|
|
7993
|
+
await runCompiler(
|
|
7994
|
+
swift,
|
|
7995
|
+
[...buildArgs, '--target', framework],
|
|
7996
|
+
buildOptions,
|
|
7997
|
+
)
|
|
7998
|
+
}
|
|
7566
7999
|
// clang consumes the real emitted headers after swift finishes.
|
|
7567
8000
|
// swiftpm's transitive swift module maps are not C declarations:
|
|
7568
8001
|
// importing them would shadow SDK modules such as ObjectiveC.
|