peachsim 0.1.1684 → 0.1.1700
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/bridge-flow-runner.ts +61 -39
- package/cli/commands/agent-wrapper.ts +21 -10
- package/cli/commands/control.ts +27 -7
- package/cli/commands/coverage-swift.ts +72 -5
- package/cli/commands/coverage.ts +1 -1
- package/cli/commands/detect.ts +17 -4
- package/cli/commands/inspect/actions.ts +1 -0
- package/cli/commands/maestro-compare.ts +25 -99
- package/cli/commands/screenshot.ts +12 -0
- package/cli/help-core.ts +3 -4
- package/cli/maestro-compare.ts +172 -4
- package/cli/outbound-endpoints.ts +2 -10
- package/detox/index.ts +15 -0
- package/detox/launch-permissions.ts +169 -0
- package/dist-lib/agent-daemon-client.cjs +2 -2
- package/dist-lib/agent-events.cjs +2 -2
- package/dist-lib/attached-projects.cjs +2 -2
- package/dist-lib/auth/shared-session.cjs +2 -2
- package/dist-lib/backend-origin.cjs +2 -2
- package/dist-lib/beta.cjs +2 -2
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +2 -2
- package/dist-lib/bridge-contract-input.cjs +2 -2
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +2 -2
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +6729 -3591
- package/dist-lib/capture-contract.cjs +2 -2
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +2 -2
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +2 -2
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +2 -2
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +2 -2
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +104 -3
- package/dist-lib/dev-bundle-resolution.cjs +208 -44
- package/dist-lib/expo-swift-bundle.cjs +3475 -2137
- package/dist-lib/expo-swift-metadata.cjs +2 -2
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +2 -2
- package/dist-lib/host/bridge-host.cjs +8970 -3652
- package/dist-lib/host/fetch-proxy-handler.cjs +332 -40
- package/dist-lib/host/fetch-proxy-overrides.cjs +2 -2
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +2 -2
- package/dist-lib/host/websocket-proxy.cjs +2 -2
- package/dist-lib/index.cjs +469 -143
- package/dist-lib/jump-to-source-babel.cjs +2 -2
- package/dist-lib/jump-to-source-native.cjs +2 -2
- package/dist-lib/kotlin-host.cjs +2 -2
- package/dist-lib/menu.cjs +2 -2
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +2 -2
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +2 -2
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +465 -139
- package/dist-lib/native-app-identity-project.cjs +209 -86
- package/dist-lib/native-app-identity-project.mjs +251 -116
- package/dist-lib/native-app-identity.cjs +2 -2
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +2 -2
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +2 -2
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +2 -2
- package/dist-lib/public-brand.cjs +2 -2
- package/dist-lib/public-origins-lib-esm.json +27 -23
- package/dist-lib/public-origins-lib.json +221 -88
- package/dist-lib/react-native-host-modules.cjs +2 -2
- 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 +206 -31
- package/dist-lib/sdk.cjs +3 -3
- package/dist-lib/sdk.mjs +2 -2
- package/dist-lib/skills.cjs +20997 -16596
- package/dist-lib/swift-compile.cjs +3075 -459
- package/dist-lib/swift-compile.mjs +3028 -415
- package/dist-lib/swift-package.cjs +131 -69
- package/dist-lib/swift-package.mjs +126 -68
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +31 -4
- package/dist-lib/swift.cjs +2 -2
- package/dist-lib/vite-swift.cjs +5049 -1704
- package/dist-lib/vite.cjs +261 -58
- package/dist-lib/worklet-executable.cjs +8 -5
- package/dist-lib/worklet-executable.mjs +7 -4
- package/dist-types/packages/peach-engine/src/engine/clipboardContract.d.ts +15 -1
- package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/scroll-pan-contacts.d.ts +3 -1
- package/dist-types/packages/peach-engine/src/engine/scroll.d.ts +7 -0
- package/dist-types/packages/peach-engine/src/engine/types.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +2 -2
- package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/scroll-mirror.d.ts +17 -0
- package/dist-types/packages/peach-engine/src/render-worker/worker-input-runtime.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +3 -0
- package/dist-types/packages/peach-globals/src/cameraBridgeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/clipboardBridgeContract.d.ts +6 -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-globals/src/replayBridgeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/shellHostBridgeContract.d.ts +3 -0
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/dist-types/packages/peach-kit/src/materials/types.d.ts +1 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/scripts/dev-server-scanner.ts +4 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Alpha.h +2282 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/BasicImageTypes.h +55 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Conversion.h +10551 -6
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Convolution.h +4236 -3
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Geometry.h +827 -8
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Histogram.h +1369 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Morphology.h +1243 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Transform.h +1747 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage.h +291 -2
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_CVUtilities.h +1283 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_Types.h +811 -91
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_Utilities.h +1342 -25
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns.h +2738 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_constants.h +1685 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_graph.h +913 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_structures.h +1917 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/LinearAlgebra.h +23 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/arithmetic.h +209 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/base.h +104 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/linear_systems.h +77 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/matrix.h +554 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/norms.h +58 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/object.h +186 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/splat.h +86 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/vector.h +364 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Quadrature/Integration.h +195 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Quadrature/Quadrature.h +44 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/BLAS/BLAS.h +2330 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/BLAS/Types.h +123 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/Solve.h +8339 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/SolveImplementation.h +520 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/SolveImplementationTyped.h +1893 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/Sparse.h +10 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/blas_new.h +1098 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/cblas.h +859 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/cblas_new.h +1134 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/clapack.h +10555 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h +695 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack.h +38526 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack_types.h +60 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack_version.h +20 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/thread_api.h +50 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vBasicOps.h +1218 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vBigNum.h +1458 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vDSP.h +10377 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vDSP_translate.h +167 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vForce.h +1243 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vecLib.h +114 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vecLibTypes.h +146 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vectorOps.h +1106 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vfp.h +294 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Headers/Accelerate.h +25 -1
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFArray.h +673 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFAvailability.h +232 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h +827 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCalendar.h +121 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCharacterSet.h +387 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFData.h +79 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFDate.h +122 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFDictionary.h +674 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFError.h +182 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFLocale.h +213 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFNotificationCenter.h +82 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFNumber.h +129 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFSet.h +491 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h +883 -2
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFTimeZone.h +98 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +11 -220
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +2 -6
- 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 +98 -3
- 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/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/QuartzCore.framework/Headers/QuartzCore.h +1 -0
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecBase.h +906 -3
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecCertificate.h +613 -0
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecItem.h +1284 -29
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecPolicy.h +441 -0
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecTrust.h +845 -0
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/Security.h +4 -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/AvailabilityMacros.h +3985 -0
- package/sdk/ios/usr/include/complex.h +167 -0
- package/sdk/ios/usr/include/copyfile.h +143 -0
- package/sdk/ios/usr/include/dispatch/dispatch.h +5 -0
- package/sdk/ios/usr/include/mach/mach_types.h +1 -0
- package/sdk/ios/usr/include/malloc/_malloc.h +143 -0
- package/sdk/ios/usr/include/malloc/_malloc_type.h +153 -0
- package/sdk/ios/usr/include/malloc/_platform.h +80 -0
- package/sdk/ios/usr/include/malloc/_ptrcheck.h +43 -0
- package/sdk/ios/usr/include/malloc/malloc.h +768 -0
- package/sdk/ios/usr/include/math.h +835 -2
- package/sdk/ios/usr/include/os/availability.h +168 -6
- package/sdk/ios/usr/include/os/base.h +351 -0
- package/sdk/ios/usr/include/os/clock.h +18 -0
- package/sdk/ios/usr/include/os/lock.h +232 -10
- package/sdk/ios/usr/include/os/log.h +521 -38
- package/sdk/ios/usr/include/os/object.h +320 -3
- package/sdk/ios/usr/include/os/trace.h +492 -0
- package/sdk/ios/usr/include/os/trace_base.h +167 -0
- package/sdk/ios/usr/include/os/workgroup.h +37 -0
- package/sdk/ios/usr/include/os/workgroup_base.h +91 -0
- package/sdk/ios/usr/include/os/workgroup_interval.h +156 -0
- package/sdk/ios/usr/include/os/workgroup_object.h +359 -0
- package/sdk/ios/usr/include/os/workgroup_parallel.h +76 -0
- package/sdk/ios/usr/include/sys/cdefs.h +38 -1
- package/sdk/ios/wasm/include/unistd.h +3 -0
- package/skills/contrast/SKILL.md +3 -0
- package/src/codex-client.ts +11 -6
- package/src/dev-bundle-resolution.ts +124 -48
- package/src/expo-native-workspace.ts +176 -0
- package/src/expo-swift-host.ts +161 -26
- package/src/expo-swift-ready.ts +14 -28
- package/src/expoSwiftContract.ts +4 -1
- package/src/generated/swift-c-predefines.json +2044 -0
- package/src/host/bridge-host.ts +5 -0
- package/src/installed-package-versions.ts +14 -1
- package/src/metro-project-root.ts +44 -33
- package/src/native-app-identity-project.ts +1 -0
- package/src/nitro-adapter.lock.json +916 -10
- package/src/nitro-adapter.ts +33 -24
- package/src/nitro-bundle.ts +108 -21
- package/src/nitro-compile.ts +36 -5
- package/src/nitro-source.ts +13 -3
- package/src/nitroAdapterContract.ts +100 -20
- package/src/nitroContract.ts +18 -2
- package/src/node-http-fetch.ts +116 -0
- package/src/packageVersionsContract.ts +46 -0
- package/src/serverDiscoveryContract.ts +1 -0
- package/src/settingsContract.ts +0 -30
- package/src/swift-binary-modules.ts +20 -5
- package/src/swift-compile.ts +598 -81
- package/src/swift-coverage/package.ts +3 -1
- package/src/swift-coverage/xcode-assets.ts +66 -5
- package/src/swift-coverage/xcode-packages.ts +11 -6
- package/src/swift-host.ts +347 -60
- package/src/swift-objc-compile.ts +52 -10
- package/src/swift-objc-metadata.ts +2 -2
- package/src/swift-objc-platform.ts +2 -2
- package/src/swift-objc-standin.ts +53 -13
- package/src/swift-package-manifest.ts +151 -28
- package/src/swift-package.ts +158 -75
- package/src/swift-packages.ts +141 -44
- package/src/swift-source-file.ts +10 -15
- package/src/swift-source-pods.ts +126 -41
- package/src/swift-standin-digest.ts +77 -0
- package/src/swift-standin-emit.ts +40 -4
- package/src/swift-standins.ts +154 -31
- package/src/swift-submit.ts +5 -0
- package/src/swift-toolchain.ts +38 -0
- package/src/swiftContract.ts +168 -75
- package/src/target-matcher.ts +15 -2
- package/src/vite-plugin.ts +0 -10
- package/src/worklet-executable.ts +7 -3
- package/src/xcode-json-project.ts +14 -2
- package/src/xcode-project.ts +215 -100
- package/src/settings-flags.ts +0 -107
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'
|
|
@@ -48,10 +49,13 @@ import {
|
|
|
48
49
|
objcView,
|
|
49
50
|
} from './swift-objc-standin'
|
|
50
51
|
import {
|
|
52
|
+
isSwiftNativeTranslationUnit,
|
|
51
53
|
OBJC_RESOURCE_ACCESSOR_BODY,
|
|
52
54
|
OBJC_RESOURCE_ACCESSOR_HEADER,
|
|
53
55
|
swiftManifestCxxLanguageStandard,
|
|
56
|
+
swiftManifestDeclarations,
|
|
54
57
|
swiftManifestTargets,
|
|
58
|
+
swiftManifestPackages,
|
|
55
59
|
swiftObjCResourceAccessor,
|
|
56
60
|
swiftObjCResourceBundleName,
|
|
57
61
|
swiftPackagePartition,
|
|
@@ -62,18 +66,23 @@ import {
|
|
|
62
66
|
import { withSwiftRootLock, type SwiftRootLease } from './swift-root-lock'
|
|
63
67
|
import {
|
|
64
68
|
sourceSwiftCheckout,
|
|
69
|
+
SWIFT_AUTOLINK_LINKER,
|
|
65
70
|
swiftEnvironment,
|
|
66
71
|
swiftSdkOptions,
|
|
67
72
|
swiftSourceSdk,
|
|
68
73
|
swiftToolchain,
|
|
74
|
+
writeSwiftAutolinkLinker,
|
|
69
75
|
type SwiftWasmSdk,
|
|
70
76
|
} from './swift-toolchain'
|
|
71
77
|
import {
|
|
72
78
|
isSwiftNativeTargets,
|
|
79
|
+
isSwiftPackageFiles,
|
|
73
80
|
isSwiftObjCPeerStartup,
|
|
74
81
|
isSwiftResourceBundles,
|
|
82
|
+
isSwiftResourcePath,
|
|
75
83
|
SWIFT_NATIVE_INPUT_ROOT,
|
|
76
84
|
SWIFT_NATIVE_SDK_INCLUDE,
|
|
85
|
+
type SwiftPackageFiles,
|
|
77
86
|
type SwiftNativeTarget,
|
|
78
87
|
type SwiftObjCPeerStartup,
|
|
79
88
|
type SwiftProjectPreparation,
|
|
@@ -205,6 +214,8 @@ const BUILD_JOBS = String(
|
|
|
205
214
|
|
|
206
215
|
export interface SwiftCompileInput {
|
|
207
216
|
files: Record<string, string>
|
|
217
|
+
packageFiles?: SwiftPackageFiles
|
|
218
|
+
packageGuestImports?: string[]
|
|
208
219
|
objcPeerStartup?: SwiftObjCPeerStartup
|
|
209
220
|
nativeTargets?: SwiftNativeTarget[]
|
|
210
221
|
metalSources?: Record<string, string>
|
|
@@ -330,12 +341,18 @@ export function swiftModuleInputFiles(root: string): string[] {
|
|
|
330
341
|
* checkout's must be rebuilt (scripts/build-preview-plugin.sh) first. */
|
|
331
342
|
export function swiftMacroPlugins(moduleRoot: string): {
|
|
332
343
|
libraries: string[]
|
|
344
|
+
executables: string[]
|
|
333
345
|
stale: boolean
|
|
334
346
|
} {
|
|
335
347
|
const distribution = swiftDistributionAt(moduleRoot)
|
|
336
348
|
if (distribution)
|
|
337
349
|
return {
|
|
338
|
-
libraries: distribution.plugins
|
|
350
|
+
libraries: distribution.plugins
|
|
351
|
+
.filter((plugin) => path.basename(plugin) !== 'ExpoModulesMacros')
|
|
352
|
+
.map((plugin) => path.join(moduleRoot, plugin)),
|
|
353
|
+
executables: distribution.plugins
|
|
354
|
+
.filter((plugin) => path.basename(plugin) === 'ExpoModulesMacros')
|
|
355
|
+
.map((plugin) => path.join(moduleRoot, plugin)),
|
|
339
356
|
stale: false,
|
|
340
357
|
}
|
|
341
358
|
const dir = path.join(moduleRoot, '.build/host/RnxPreviewMacros')
|
|
@@ -343,6 +360,8 @@ export function swiftMacroPlugins(moduleRoot: string): {
|
|
|
343
360
|
readFileSync(path.join(moduleRoot, 'toolchain.json'), 'utf8'),
|
|
344
361
|
).release
|
|
345
362
|
const compilerStamp = path.join(dir, 'compiler-release')
|
|
363
|
+
const pluginScript = path.join(moduleRoot, 'scripts/build-preview-plugin.sh')
|
|
364
|
+
const expoPlugin = path.join(dir, 'ExpoModulesMacros')
|
|
346
365
|
// linux names a plugin's module from lib<Module>.so
|
|
347
366
|
const ext = process.platform === 'darwin' ? 'dylib' : 'so'
|
|
348
367
|
const plugins = [
|
|
@@ -367,8 +386,11 @@ export function swiftMacroPlugins(moduleRoot: string): {
|
|
|
367
386
|
]
|
|
368
387
|
return {
|
|
369
388
|
libraries: plugins.map(({ library }) => library),
|
|
389
|
+
executables: [expoPlugin],
|
|
370
390
|
stale:
|
|
371
391
|
!existsSync(compilerStamp) ||
|
|
392
|
+
!existsSync(expoPlugin) ||
|
|
393
|
+
statSync(pluginScript).mtimeMs > statSync(expoPlugin).mtimeMs ||
|
|
372
394
|
readFileSync(compilerStamp, 'utf8').trim() !== release ||
|
|
373
395
|
plugins.some(
|
|
374
396
|
({ library, sources }) =>
|
|
@@ -383,8 +405,8 @@ export async function ensureMacroPlugins(
|
|
|
383
405
|
toolchainBin: string,
|
|
384
406
|
release: string,
|
|
385
407
|
signal?: AbortSignal,
|
|
386
|
-
): Promise<string[]> {
|
|
387
|
-
const { libraries, stale } = swiftMacroPlugins(moduleRoot)
|
|
408
|
+
): Promise<{ libraries: string[]; executables: string[] }> {
|
|
409
|
+
const { libraries, executables, stale } = swiftMacroPlugins(moduleRoot)
|
|
388
410
|
if (stale) {
|
|
389
411
|
await runCompiler(
|
|
390
412
|
'sh',
|
|
@@ -400,7 +422,7 @@ export async function ensureMacroPlugins(
|
|
|
400
422
|
`${release}\n`,
|
|
401
423
|
)
|
|
402
424
|
}
|
|
403
|
-
return libraries
|
|
425
|
+
return { libraries, executables }
|
|
404
426
|
}
|
|
405
427
|
|
|
406
428
|
const linkedModuleDigests = new Map<string, { stamp: string; digest: Buffer }>()
|
|
@@ -534,6 +556,30 @@ const OPTIONAL_FRAMEWORKS = new Set(Object.keys(OPTIONAL_FRAMEWORK_DEPENDENCIES)
|
|
|
534
556
|
const SWIFT_IMPORT =
|
|
535
557
|
/^\s*(?:@\w+(?:\([^)]*\))?\s+)*import\s+(?:(?:typealias|struct|class|enum|protocol|let|var|func)\s+)?([A-Za-z_][A-Za-z0-9_]*)/
|
|
536
558
|
|
|
559
|
+
// three-valued (kleene) logic shared by the swift and c condition
|
|
560
|
+
// evaluators: an undecided operand only decides when the other forces the
|
|
561
|
+
// outcome, so false && undefined is false and true || undefined is true.
|
|
562
|
+
const kleeneNot = (value: boolean | undefined): boolean | undefined =>
|
|
563
|
+
value === undefined ? undefined : !value
|
|
564
|
+
const kleeneAnd = (
|
|
565
|
+
left: boolean | undefined,
|
|
566
|
+
right: boolean | undefined,
|
|
567
|
+
): boolean | undefined =>
|
|
568
|
+
left === false || right === false
|
|
569
|
+
? false
|
|
570
|
+
: left === true && right === true
|
|
571
|
+
? true
|
|
572
|
+
: undefined
|
|
573
|
+
const kleeneOr = (
|
|
574
|
+
left: boolean | undefined,
|
|
575
|
+
right: boolean | undefined,
|
|
576
|
+
): boolean | undefined =>
|
|
577
|
+
left === true || right === true
|
|
578
|
+
? true
|
|
579
|
+
: left === false && right === false
|
|
580
|
+
? false
|
|
581
|
+
: undefined
|
|
582
|
+
|
|
537
583
|
// a compilation condition as the wasm compile sees it after the source
|
|
538
584
|
// rewrite below: `os(iOS)` and `os(WASI)` hold, other platforms do not,
|
|
539
585
|
// `canImport` holds for an available module. what the scan cannot know
|
|
@@ -541,16 +587,13 @@ const SWIFT_IMPORT =
|
|
|
541
587
|
// through `!`, `&&` and `||`.
|
|
542
588
|
function swiftCondition(
|
|
543
589
|
text: string,
|
|
544
|
-
available
|
|
590
|
+
available?: ReadonlySet<string>,
|
|
545
591
|
): boolean | undefined {
|
|
546
592
|
const tokens = text.match(/\w+\s*\([^()]*\)|&&|\|\||!|\(|\)|\w+/g) ?? []
|
|
547
593
|
let index = 0
|
|
548
594
|
const atom = (): boolean | undefined => {
|
|
549
595
|
const token = tokens[index++]
|
|
550
|
-
if (token === '!')
|
|
551
|
-
const value = atom()
|
|
552
|
-
return value === undefined ? undefined : !value
|
|
553
|
-
}
|
|
596
|
+
if (token === '!') return kleeneNot(atom())
|
|
554
597
|
if (token === '(') {
|
|
555
598
|
const value = either()
|
|
556
599
|
index++
|
|
@@ -562,8 +605,8 @@ function swiftCondition(
|
|
|
562
605
|
if (!call) return undefined
|
|
563
606
|
const [, name, argument] = call
|
|
564
607
|
if (name === 'os') return argument === 'iOS' || argument === 'WASI'
|
|
565
|
-
if (name === 'canImport') return available
|
|
566
|
-
if (name === 'targetEnvironment') return
|
|
608
|
+
if (name === 'canImport') return available?.has(argument!)
|
|
609
|
+
if (name === 'targetEnvironment') return argument === 'simulator'
|
|
567
610
|
if (name === 'arch') return argument === 'wasm32'
|
|
568
611
|
return undefined
|
|
569
612
|
}
|
|
@@ -571,8 +614,7 @@ function swiftCondition(
|
|
|
571
614
|
let value = atom()
|
|
572
615
|
while (tokens[index] === '&&') {
|
|
573
616
|
index++
|
|
574
|
-
|
|
575
|
-
value = value === false || next === false ? false : value && next ? true : undefined
|
|
617
|
+
value = kleeneAnd(value, atom())
|
|
576
618
|
}
|
|
577
619
|
return value
|
|
578
620
|
}
|
|
@@ -580,37 +622,25 @@ function swiftCondition(
|
|
|
580
622
|
let value = both()
|
|
581
623
|
while (tokens[index] === '||') {
|
|
582
624
|
index++
|
|
583
|
-
|
|
584
|
-
value =
|
|
585
|
-
value === true || next === true
|
|
586
|
-
? true
|
|
587
|
-
: value === false && next === false
|
|
588
|
-
? false
|
|
589
|
-
: undefined
|
|
625
|
+
value = kleeneOr(value, both())
|
|
590
626
|
}
|
|
591
627
|
return value
|
|
592
628
|
}
|
|
593
629
|
return either()
|
|
594
630
|
}
|
|
595
631
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
* whose condition holds there, `os(iOS)` included since the compile rewrites
|
|
600
|
-
* it to true. a branch the scan cannot decide may compile out, so its
|
|
601
|
-
* imports stay out of the list.
|
|
602
|
-
*/
|
|
603
|
-
export function swiftImportNames(
|
|
632
|
+
// each line's branch state under the app's wasm compilation conditions.
|
|
633
|
+
// directives themselves are not executable source.
|
|
634
|
+
function* swiftConditionalLines(
|
|
604
635
|
contents: string,
|
|
605
636
|
available?: ReadonlySet<string>,
|
|
606
|
-
): string
|
|
607
|
-
const names: string[] = []
|
|
637
|
+
): Generator<{ line: string; active: boolean | undefined }> {
|
|
608
638
|
// per open `#if`: whether its current branch is active, and whether an
|
|
609
639
|
// earlier branch was taken (or may have been)
|
|
610
640
|
const frames: { active: boolean | undefined; taken: boolean | undefined }[] = []
|
|
611
641
|
for (const line of contents.split('\n')) {
|
|
612
642
|
const directive = /^\s*#(if|elseif|else|endif)\b(.*)$/.exec(line)
|
|
613
|
-
if (directive
|
|
643
|
+
if (directive) {
|
|
614
644
|
const [, kind, rest] = directive
|
|
615
645
|
const condition = (rest ?? '').replace(/\/\/.*$/, '').trim()
|
|
616
646
|
if (kind === 'if') {
|
|
@@ -633,9 +663,34 @@ export function swiftImportNames(
|
|
|
633
663
|
? holds
|
|
634
664
|
: undefined
|
|
635
665
|
}
|
|
666
|
+
yield { line, active: false }
|
|
636
667
|
continue
|
|
637
668
|
}
|
|
638
|
-
|
|
669
|
+
yield {
|
|
670
|
+
line,
|
|
671
|
+
active: frames.some((frame) => frame.active === false)
|
|
672
|
+
? false
|
|
673
|
+
: frames.every((frame) => frame.active === true)
|
|
674
|
+
? true
|
|
675
|
+
: undefined,
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* the modules a source imports, in order. with `available`, only imports the
|
|
682
|
+
* wasm compile certainly reaches: those outside every `#if`, or in a branch
|
|
683
|
+
* whose condition holds there, `os(iOS)` included since the compile rewrites
|
|
684
|
+
* it to true. a branch the scan cannot decide may compile out, so its
|
|
685
|
+
* imports stay out of the list.
|
|
686
|
+
*/
|
|
687
|
+
export function swiftImportNames(
|
|
688
|
+
contents: string,
|
|
689
|
+
available?: ReadonlySet<string>,
|
|
690
|
+
): string[] {
|
|
691
|
+
const names: string[] = []
|
|
692
|
+
for (const { line, active } of swiftConditionalLines(contents, available)) {
|
|
693
|
+
if (available && active !== true) continue
|
|
639
694
|
const name = SWIFT_IMPORT.exec(line)?.[1]
|
|
640
695
|
if (name) names.push(name)
|
|
641
696
|
}
|
|
@@ -650,11 +705,11 @@ export function swiftPeachModules(moduleRoot: string): string[] {
|
|
|
650
705
|
const distribution = swiftDistributionAt(moduleRoot)
|
|
651
706
|
return distribution
|
|
652
707
|
? distribution.modules
|
|
653
|
-
:
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
)
|
|
657
|
-
|
|
708
|
+
: swiftManifestDeclarations(
|
|
709
|
+
readFileSync(path.join(moduleRoot, 'Package.swift'), 'utf8'),
|
|
710
|
+
)
|
|
711
|
+
.filter((target) => !target.executable && !target.path.startsWith('fixtures/'))
|
|
712
|
+
.map((target) => target.name)
|
|
658
713
|
}
|
|
659
714
|
|
|
660
715
|
const sdkPaths = new Map<string, { sysroot: string; resources: string }>()
|
|
@@ -826,17 +881,20 @@ const ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One
|
|
|
826
881
|
// target share (specs/peach-swift/build-plans.md). clang runs `wasm-opt -Os`
|
|
827
882
|
// after a wasm link whenever the machine has one on PATH, which makes every
|
|
828
883
|
// edit pay for an optimizer pass and the artifact depend on the machine, so
|
|
829
|
-
// -O0 on the clang link turns that pass off everywhere. the
|
|
830
|
-
//
|
|
831
|
-
|
|
884
|
+
// -O0 on the clang link turns that pass off everywhere. the build root's
|
|
885
|
+
// linker drops repeated autolink -l flags (writeSwiftAutolinkLinker). the
|
|
886
|
+
// rest is the native main-thread stack budget.
|
|
887
|
+
const executableLinkFlags = (root: string) => ` "-Xclang-linker", "-O0",
|
|
888
|
+
"-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path.join(root, SWIFT_AUTOLINK_LINKER)}`)},
|
|
832
889
|
"-Xlinker", "-z", "-Xlinker", "stack-size=8372224",
|
|
833
890
|
"-Xlinker", "--stack-first",
|
|
834
891
|
"-Xlinker", "--global-base=8372224",
|
|
892
|
+
"-Xlinker", "-lsetjmp",
|
|
835
893
|
`
|
|
836
894
|
const REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n'
|
|
837
895
|
|
|
838
896
|
/** bump with any change to the emitted multi-target manifest text. */
|
|
839
|
-
export const MULTI_MANIFEST_VERSION =
|
|
897
|
+
export const MULTI_MANIFEST_VERSION = 45
|
|
840
898
|
|
|
841
899
|
// build-cli replaces this in every bundle; source runs read the files directly.
|
|
842
900
|
declare const __SWIFT_COMPILER_DIGEST__: string | undefined
|
|
@@ -893,6 +951,11 @@ export function swiftArtifactHash(
|
|
|
893
951
|
),
|
|
894
952
|
)
|
|
895
953
|
hash.update(JSON.stringify(input.nativeTargets ?? []))
|
|
954
|
+
hash.update(JSON.stringify(input.packageGuestImports ?? []))
|
|
955
|
+
for (const file of Object.keys(input.packageFiles ?? {}).sort()) {
|
|
956
|
+
hash.update(`package-file\0${file}\0`)
|
|
957
|
+
hash.update(createHash('sha256').update(input.packageFiles![file]!).digest())
|
|
958
|
+
}
|
|
896
959
|
hash.update(JSON.stringify(input.objcPeerStartup ?? null))
|
|
897
960
|
for (const target of Object.keys(input.libraries ?? {}).sort()) {
|
|
898
961
|
hash.update(`library\n${target}\n`)
|
|
@@ -927,6 +990,7 @@ interface SwiftNativeTargetPlan {
|
|
|
927
990
|
flags?: string[]
|
|
928
991
|
cxxFlags?: string[]
|
|
929
992
|
mixed?: boolean
|
|
993
|
+
underlying?: { modulemap: string; flags: string[] }
|
|
930
994
|
clang?: {
|
|
931
995
|
modulemap: string
|
|
932
996
|
sources: string[]
|
|
@@ -940,8 +1004,29 @@ interface SwiftNativeTargetPlan {
|
|
|
940
1004
|
late?: { name: string; producers: string[] }
|
|
941
1005
|
}
|
|
942
1006
|
|
|
1007
|
+
function swiftCrossImportFlags(moduleRoot: string, distribution: boolean): string[] {
|
|
1008
|
+
const overlayRoot = path.join(
|
|
1009
|
+
moduleRoot,
|
|
1010
|
+
distribution ? 'modules' : 'cross-import-overlays',
|
|
1011
|
+
)
|
|
1012
|
+
return readdirSync(overlayRoot, { encoding: 'utf8', recursive: true })
|
|
1013
|
+
.filter((file) => file.endsWith('.swiftoverlay'))
|
|
1014
|
+
.sort((left, right) => left.localeCompare(right))
|
|
1015
|
+
.flatMap((file) => [
|
|
1016
|
+
'-Xfrontend',
|
|
1017
|
+
'-swift-module-cross-import',
|
|
1018
|
+
'-Xfrontend',
|
|
1019
|
+
path.basename(path.dirname(file), '.swiftcrossimport'),
|
|
1020
|
+
'-Xfrontend',
|
|
1021
|
+
path.join(overlayRoot, file),
|
|
1022
|
+
])
|
|
1023
|
+
}
|
|
1024
|
+
|
|
943
1025
|
export function emitSwiftPackageManifest(args: {
|
|
1026
|
+
/** the build root holding the linker each executable links with. */
|
|
1027
|
+
root: string
|
|
944
1028
|
targets: SwiftPackageTarget[]
|
|
1029
|
+
packages?: ReadonlyMap<string, string>
|
|
945
1030
|
cxxLanguageStandard?: string
|
|
946
1031
|
native?: Map<string, SwiftNativeTargetPlan>
|
|
947
1032
|
headerDirectory?: string
|
|
@@ -996,21 +1081,7 @@ export function emitSwiftPackageManifest(args: {
|
|
|
996
1081
|
.join('\n') + '\n',
|
|
997
1082
|
)
|
|
998
1083
|
}
|
|
999
|
-
const
|
|
1000
|
-
moduleRoot,
|
|
1001
|
-
distribution ? 'modules' : 'cross-import-overlays',
|
|
1002
|
-
)
|
|
1003
|
-
const overlayFlags = readdirSync(overlayRoot, { encoding: 'utf8', recursive: true })
|
|
1004
|
-
.filter((file) => file.endsWith('.swiftoverlay'))
|
|
1005
|
-
.sort((left, right) => left.localeCompare(right))
|
|
1006
|
-
.flatMap((file) => [
|
|
1007
|
-
'-Xfrontend',
|
|
1008
|
-
'-swift-module-cross-import',
|
|
1009
|
-
'-Xfrontend',
|
|
1010
|
-
path.basename(path.dirname(file), '.swiftcrossimport'),
|
|
1011
|
-
'-Xfrontend',
|
|
1012
|
-
path.join(overlayRoot, file),
|
|
1013
|
-
])
|
|
1084
|
+
const overlayFlags = swiftCrossImportFlags(moduleRoot, Boolean(distribution))
|
|
1014
1085
|
.map((flag) => `, ${JSON.stringify(flag)}`)
|
|
1015
1086
|
.join('')
|
|
1016
1087
|
const executable = targets.find((target) => target.executable)
|
|
@@ -1085,9 +1156,20 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1085
1156
|
])
|
|
1086
1157
|
includeImportContext(dependency)
|
|
1087
1158
|
const nativeImportFlags = [...importContext]
|
|
1088
|
-
.flatMap((name) =>
|
|
1159
|
+
.flatMap((name) => {
|
|
1160
|
+
const dependency = args.native?.get(name)
|
|
1161
|
+
return dependency?.underlying
|
|
1162
|
+
? [
|
|
1163
|
+
`-fmodule-map-file=${dependency.underlying.modulemap}`,
|
|
1164
|
+
...dependency.underlying.flags,
|
|
1165
|
+
]
|
|
1166
|
+
: (dependency?.clang?.importFlags ?? [])
|
|
1167
|
+
})
|
|
1089
1168
|
.map((flag) => `, "-Xcc", ${JSON.stringify(flag)}`)
|
|
1090
1169
|
.join('')
|
|
1170
|
+
const underlying = native?.underlying
|
|
1171
|
+
? `, "-import-underlying-module", "-Xcc", ${JSON.stringify(`-fmodule-map-file=${native.underlying.modulemap}`)}${native.underlying.flags.map((flag) => `, "-Xcc", ${JSON.stringify(flag)}`).join('')}`
|
|
1172
|
+
: ''
|
|
1091
1173
|
const header =
|
|
1092
1174
|
args.headerDirectory &&
|
|
1093
1175
|
[...(args.native?.values() ?? [])].some((value) =>
|
|
@@ -1095,9 +1177,16 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1095
1177
|
)
|
|
1096
1178
|
? `, "-emit-objc-header-path", ${JSON.stringify(path.join(args.headerDirectory, `${target.name}-${args.objcExports?.modules.has(target.name) ? 'Cxx' : 'Swift'}.h`))}`
|
|
1097
1179
|
: ''
|
|
1098
|
-
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}])]`
|
|
1180
|
+
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}${underlying}${header}${upstream}])]`
|
|
1099
1181
|
const deps = [
|
|
1100
1182
|
...new Set([
|
|
1183
|
+
...(target.dependencies ?? []).flatMap((dependency) =>
|
|
1184
|
+
dependency.kind === 'product'
|
|
1185
|
+
? [
|
|
1186
|
+
`.product(name: ${JSON.stringify(dependency.name)}, package: ${JSON.stringify(dependency.package)})`,
|
|
1187
|
+
]
|
|
1188
|
+
: [],
|
|
1189
|
+
),
|
|
1101
1190
|
...(target.executable
|
|
1102
1191
|
? [
|
|
1103
1192
|
...new Set([
|
|
@@ -1164,7 +1253,7 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1164
1253
|
linkerSettings: [
|
|
1165
1254
|
${librarySettings.map((setting) => `${setting},`).join('\n ')}
|
|
1166
1255
|
.unsafeFlags([
|
|
1167
|
-
${REACTOR_FLAG}${
|
|
1256
|
+
${REACTOR_FLAG}${executableLinkFlags(args.root)} "-Xlinker", "--export-if-defined=__main_argc_argv"${args.objcExports ? ', "-Xlinker", "--fatal-warnings"' : ''}${library},
|
|
1168
1257
|
]),
|
|
1169
1258
|
.unsafeFlags(["-Xlinker", "--strip-all"], .when(configuration: .release)),
|
|
1170
1259
|
]`
|
|
@@ -1183,14 +1272,18 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1183
1272
|
`cSettings: [${cDefines} .unsafeFlags(${JSON.stringify([...(args.nativeFlags?.get(target.name) ?? []), ...(native?.flags ?? [])])})]`,
|
|
1184
1273
|
`cxxSettings: [${cxxDefines} .unsafeFlags(${JSON.stringify(['-fno-cxx-modules', ...(args.nativeFlags?.get(target.name) ?? []), ...(native?.cxxFlags ?? [])])})]`,
|
|
1185
1274
|
].join(', ')
|
|
1275
|
+
const exclusions = native?.clang
|
|
1276
|
+
? (native.exclude ?? native.lateSources)
|
|
1277
|
+
: [
|
|
1278
|
+
...(native ? (native.exclude ?? native.lateSources) : []),
|
|
1279
|
+
...(target.exclude ?? []),
|
|
1280
|
+
]
|
|
1186
1281
|
return [
|
|
1187
1282
|
` ${kind}(`,
|
|
1188
1283
|
` name: "${target.name}",`,
|
|
1189
1284
|
` dependencies: [${deps}],`,
|
|
1190
1285
|
` path: ${JSON.stringify(native?.clang ? '.' : target.path)},`,
|
|
1191
|
-
...(
|
|
1192
|
-
? [` exclude: ${JSON.stringify(native.exclude ?? native.lateSources)},`]
|
|
1193
|
-
: []),
|
|
1286
|
+
...(exclusions.length ? [` exclude: ${JSON.stringify(exclusions)},`] : []),
|
|
1194
1287
|
...(native?.clang
|
|
1195
1288
|
? [
|
|
1196
1289
|
` sources: ${JSON.stringify(native.clang.sources.map((source) => path.posix.join(native.path, source)))},`,
|
|
@@ -1199,6 +1292,9 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1199
1292
|
: native?.flags
|
|
1200
1293
|
? [` sources: ${JSON.stringify(native.sources)},`]
|
|
1201
1294
|
: []),
|
|
1295
|
+
...(!native?.clang && target.publicHeadersPath !== undefined
|
|
1296
|
+
? [` publicHeadersPath: ${JSON.stringify(target.publicHeadersPath)},`]
|
|
1297
|
+
: []),
|
|
1202
1298
|
// the native backend supplies dependency module maps without their
|
|
1203
1299
|
// compiled modules. textual c++ includes keep those dependencies usable.
|
|
1204
1300
|
` ${clang ? nativeSettings : swiftSettings}${link}`,
|
|
@@ -1215,7 +1311,13 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1215
1311
|
'let package = Package(',
|
|
1216
1312
|
' name: "app",',
|
|
1217
1313
|
` products: [.executable(name: "${executable.name}", targets: ["${executable.name}"])],`,
|
|
1218
|
-
` dependencies: [${
|
|
1314
|
+
` dependencies: [${[
|
|
1315
|
+
...(distribution ? [] : [`.package(path: ${JSON.stringify(moduleRoot)})`]),
|
|
1316
|
+
...[...(args.packages ?? [])].map(
|
|
1317
|
+
([name, directory]) =>
|
|
1318
|
+
`.package(name: ${JSON.stringify(name)}, path: ${JSON.stringify(directory)})`,
|
|
1319
|
+
),
|
|
1320
|
+
].join(', ')}],`,
|
|
1219
1321
|
' targets: [',
|
|
1220
1322
|
...targets.map(stanza),
|
|
1221
1323
|
...(args.objcExports
|
|
@@ -5744,9 +5846,12 @@ export function swiftSourceClosure(
|
|
|
5744
5846
|
return Object.fromEntries(Object.entries(files).filter(([file]) => included.has(file)))
|
|
5745
5847
|
}
|
|
5746
5848
|
|
|
5747
|
-
/**
|
|
5849
|
+
/** application entries, excluding comments, strings and inactive branches. */
|
|
5748
5850
|
export function swiftApplicationEntry(file: string, source: string): boolean {
|
|
5749
|
-
const
|
|
5851
|
+
const code = [...swiftConditionalLines(swiftCodeMask(source))]
|
|
5852
|
+
.map(({ line, active }) => (active === false ? ' '.repeat(line.length) : line))
|
|
5853
|
+
.join('\n')
|
|
5854
|
+
const { tokens } = swiftCodeScan(code)
|
|
5750
5855
|
let depth = 0
|
|
5751
5856
|
for (const at of tokens) {
|
|
5752
5857
|
if (source[at] === '{') depth++
|
|
@@ -5763,6 +5868,304 @@ export function swiftApplicationEntry(file: string, source: string): boolean {
|
|
|
5763
5868
|
return false
|
|
5764
5869
|
}
|
|
5765
5870
|
|
|
5871
|
+
// a c-family entry: a main definition outside comments and strings. headers
|
|
5872
|
+
// never compile, so only sources are scanned.
|
|
5873
|
+
/** the macro environment a c-family entry guard evaluates against. */
|
|
5874
|
+
export interface SwiftCMacroEnvironment {
|
|
5875
|
+
/** the target's -D set, with values where given. */
|
|
5876
|
+
defines: ReadonlyMap<string, string | undefined>
|
|
5877
|
+
/** the compiler's own predefines for the unit's language. */
|
|
5878
|
+
predefines: ReadonlyMap<string, string | undefined>
|
|
5879
|
+
/** names any of the target's own sources or headers defines. */
|
|
5880
|
+
targetDefined: ReadonlySet<string>
|
|
5881
|
+
}
|
|
5882
|
+
|
|
5883
|
+
const emptyMacroEnvironment: SwiftCMacroEnvironment = {
|
|
5884
|
+
defines: new Map(),
|
|
5885
|
+
predefines: new Map(),
|
|
5886
|
+
targetDefined: new Set(),
|
|
5887
|
+
}
|
|
5888
|
+
|
|
5889
|
+
// whether the environment defines the name: -D and predefines decide,
|
|
5890
|
+
// a name only the target's own sources define is undecided (order and
|
|
5891
|
+
// conditions are not evaluated), and a name nowhere visible is absent.
|
|
5892
|
+
function cMacroDefined(name: string, env: SwiftCMacroEnvironment): boolean | undefined {
|
|
5893
|
+
if (env.defines.has(name) || env.predefines.has(name)) return true
|
|
5894
|
+
if (env.targetDefined.has(name)) return undefined
|
|
5895
|
+
return false
|
|
5896
|
+
}
|
|
5897
|
+
|
|
5898
|
+
function cMacroIntOrTrue(value: string | undefined): boolean | undefined {
|
|
5899
|
+
if (value === undefined) return true
|
|
5900
|
+
if (/^0[xX][0-9a-fA-F]+[uUlL]*$/.test(value) || /^\d+[uUlL]*$/.test(value))
|
|
5901
|
+
return Number.parseInt(value) !== 0
|
|
5902
|
+
return undefined
|
|
5903
|
+
}
|
|
5904
|
+
|
|
5905
|
+
function cMacroBareValue(name: string, env: SwiftCMacroEnvironment): boolean | undefined {
|
|
5906
|
+
if (env.defines.has(name)) return cMacroIntOrTrue(env.defines.get(name))
|
|
5907
|
+
if (env.predefines.has(name)) return cMacroIntOrTrue(env.predefines.get(name))
|
|
5908
|
+
if (env.targetDefined.has(name)) return undefined
|
|
5909
|
+
return false
|
|
5910
|
+
}
|
|
5911
|
+
|
|
5912
|
+
function cMacroNegated(name: string, env: SwiftCMacroEnvironment): boolean | undefined {
|
|
5913
|
+
return kleeneNot(cMacroDefined(name, env))
|
|
5914
|
+
}
|
|
5915
|
+
|
|
5916
|
+
// a preprocessor condition the macro environment decides, or undefined when
|
|
5917
|
+
// the text needs the real preprocessor (comparisons, function-like macros,
|
|
5918
|
+
// __has_include and the like). only defined-ness, boolean operators and
|
|
5919
|
+
// integer literals evaluate; the rest is undecided.
|
|
5920
|
+
function cConditionValue(
|
|
5921
|
+
expression: string,
|
|
5922
|
+
env: SwiftCMacroEnvironment,
|
|
5923
|
+
): boolean | undefined {
|
|
5924
|
+
let i = 0
|
|
5925
|
+
const skipSpaces = () => {
|
|
5926
|
+
while (i < expression.length && /\s/.test(expression[i]!)) i++
|
|
5927
|
+
}
|
|
5928
|
+
const parseOr = (): boolean | undefined => {
|
|
5929
|
+
let value = parseAnd()
|
|
5930
|
+
for (;;) {
|
|
5931
|
+
skipSpaces()
|
|
5932
|
+
if (!expression.startsWith('||', i)) return value
|
|
5933
|
+
i += 2
|
|
5934
|
+
value = kleeneOr(value, parseAnd())
|
|
5935
|
+
}
|
|
5936
|
+
}
|
|
5937
|
+
const parseAnd = (): boolean | undefined => {
|
|
5938
|
+
let value = parseUnary()
|
|
5939
|
+
for (;;) {
|
|
5940
|
+
skipSpaces()
|
|
5941
|
+
if (!expression.startsWith('&&', i)) return value
|
|
5942
|
+
i += 2
|
|
5943
|
+
value = kleeneAnd(value, parseUnary())
|
|
5944
|
+
}
|
|
5945
|
+
}
|
|
5946
|
+
const parseUnary = (): boolean | undefined => {
|
|
5947
|
+
skipSpaces()
|
|
5948
|
+
if (expression[i] === '!') {
|
|
5949
|
+
i++
|
|
5950
|
+
return kleeneNot(parseUnary())
|
|
5951
|
+
}
|
|
5952
|
+
if (expression[i] === '(') {
|
|
5953
|
+
i++
|
|
5954
|
+
const value = parseOr()
|
|
5955
|
+
skipSpaces()
|
|
5956
|
+
return expression[i] === ')' ? (i++, value) : undefined
|
|
5957
|
+
}
|
|
5958
|
+
const defined = /^defined\b/.exec(expression.slice(i))
|
|
5959
|
+
if (defined) {
|
|
5960
|
+
i += defined[0].length
|
|
5961
|
+
skipSpaces()
|
|
5962
|
+
const parenthesized = expression[i] === '('
|
|
5963
|
+
if (parenthesized) {
|
|
5964
|
+
i++
|
|
5965
|
+
skipSpaces()
|
|
5966
|
+
}
|
|
5967
|
+
const name = /^\w+/.exec(expression.slice(i))?.[0]
|
|
5968
|
+
if (!name) return undefined
|
|
5969
|
+
i += name.length
|
|
5970
|
+
skipSpaces()
|
|
5971
|
+
if (parenthesized) {
|
|
5972
|
+
if (expression[i] !== ')') return undefined
|
|
5973
|
+
i++
|
|
5974
|
+
}
|
|
5975
|
+
return cMacroDefined(name, env)
|
|
5976
|
+
}
|
|
5977
|
+
const literal = /^(0[xX][0-9a-fA-F]+|\d+)[uUlL]*/.exec(expression.slice(i))
|
|
5978
|
+
if (literal) {
|
|
5979
|
+
i += literal[0].length
|
|
5980
|
+
return Number(literal[1]) !== 0
|
|
5981
|
+
}
|
|
5982
|
+
const name = /^\w+/.exec(expression.slice(i))?.[0]
|
|
5983
|
+
if (!name) return undefined
|
|
5984
|
+
i += name.length
|
|
5985
|
+
return cMacroBareValue(name, env)
|
|
5986
|
+
}
|
|
5987
|
+
const value = parseOr()
|
|
5988
|
+
skipSpaces()
|
|
5989
|
+
return i === expression.length ? value : undefined
|
|
5990
|
+
}
|
|
5991
|
+
|
|
5992
|
+
// the lines xcode's preprocessor keeps: conditional directives evaluated
|
|
5993
|
+
// against the macro environment, with undecided branches kept, so an entry
|
|
5994
|
+
// guard the text cannot decide still counts.
|
|
5995
|
+
function cActiveCode(code: string, env: SwiftCMacroEnvironment): string {
|
|
5996
|
+
const kept: string[] = []
|
|
5997
|
+
const stack: { parent: boolean; taken: boolean }[] = []
|
|
5998
|
+
let active = true
|
|
5999
|
+
for (const line of code.replace(/\\\r?\n/g, '').split('\n')) {
|
|
6000
|
+
const directive =
|
|
6001
|
+
/^\s*#\s*(if|ifdef|ifndef|elif|elifdef|elifndef|else|endif)\b(.*)$/.exec(line)
|
|
6002
|
+
if (!directive) {
|
|
6003
|
+
if (active) kept.push(line)
|
|
6004
|
+
continue
|
|
6005
|
+
}
|
|
6006
|
+
const keyword = directive[1]!
|
|
6007
|
+
const rest = directive[2]!.trim()
|
|
6008
|
+
if (keyword === 'if' || keyword === 'ifdef' || keyword === 'ifndef') {
|
|
6009
|
+
const name = /^\w+$/.exec(rest)?.[0]
|
|
6010
|
+
const value =
|
|
6011
|
+
keyword === 'if'
|
|
6012
|
+
? cConditionValue(rest, env)
|
|
6013
|
+
: name === undefined
|
|
6014
|
+
? undefined
|
|
6015
|
+
: keyword === 'ifdef'
|
|
6016
|
+
? cMacroDefined(name, env)
|
|
6017
|
+
: cMacroNegated(name, env)
|
|
6018
|
+
stack.push({ parent: active, taken: value === true })
|
|
6019
|
+
active = active && value !== false
|
|
6020
|
+
} else if (keyword === 'endif') {
|
|
6021
|
+
active = stack.pop()?.parent ?? true
|
|
6022
|
+
} else if (stack.length === 0) {
|
|
6023
|
+
continue
|
|
6024
|
+
} else {
|
|
6025
|
+
const frame = stack[stack.length - 1]!
|
|
6026
|
+
if (keyword === 'else') {
|
|
6027
|
+
active = frame.parent && !frame.taken
|
|
6028
|
+
frame.taken = true
|
|
6029
|
+
} else {
|
|
6030
|
+
const name = /^\w+$/.exec(rest)?.[0]
|
|
6031
|
+
const value =
|
|
6032
|
+
keyword === 'elif'
|
|
6033
|
+
? cConditionValue(rest, env)
|
|
6034
|
+
: name === undefined
|
|
6035
|
+
? undefined
|
|
6036
|
+
: keyword === 'elifdef'
|
|
6037
|
+
? cMacroDefined(name, env)
|
|
6038
|
+
: cMacroNegated(name, env)
|
|
6039
|
+
const branch = !frame.taken && value !== false
|
|
6040
|
+
if (branch && value === true) frame.taken = true
|
|
6041
|
+
active = frame.parent && branch
|
|
6042
|
+
}
|
|
6043
|
+
}
|
|
6044
|
+
}
|
|
6045
|
+
return kept.join('\n')
|
|
6046
|
+
}
|
|
6047
|
+
|
|
6048
|
+
// the source with comments and string and character literals removed,
|
|
6049
|
+
// newlines kept so directive lines stay intact.
|
|
6050
|
+
function stripCCode(source: string): string {
|
|
6051
|
+
let code = ''
|
|
6052
|
+
let i = 0
|
|
6053
|
+
while (i < source.length) {
|
|
6054
|
+
if (source.startsWith('//', i)) {
|
|
6055
|
+
const end = source.indexOf('\n', i)
|
|
6056
|
+
i = end === -1 ? source.length : end
|
|
6057
|
+
} else if (source.startsWith('/*', i)) {
|
|
6058
|
+
const end = source.indexOf('*/', i + 2)
|
|
6059
|
+
i = end === -1 ? source.length : end + 2
|
|
6060
|
+
} else if (source[i] === '"' || source[i] === "'") {
|
|
6061
|
+
const quote = source[i]!
|
|
6062
|
+
i++
|
|
6063
|
+
while (i < source.length && source[i] !== quote) i += source[i] === '\\' ? 2 : 1
|
|
6064
|
+
i++
|
|
6065
|
+
} else {
|
|
6066
|
+
code += source[i]
|
|
6067
|
+
i++
|
|
6068
|
+
}
|
|
6069
|
+
}
|
|
6070
|
+
return code
|
|
6071
|
+
}
|
|
6072
|
+
|
|
6073
|
+
// every name the given sources define. order and conditions are not
|
|
6074
|
+
// evaluated: a name defined anywhere makes its guards undecided.
|
|
6075
|
+
export function swiftCDefinedNames(sources: Iterable<string>): Set<string> {
|
|
6076
|
+
const names = new Set<string>()
|
|
6077
|
+
for (const source of sources)
|
|
6078
|
+
for (const line of stripCCode(source).split('\n')) {
|
|
6079
|
+
const name = /^\s*#\s*define\s+([A-Za-z_]\w*)/.exec(line)?.[1]
|
|
6080
|
+
if (name) names.add(name)
|
|
6081
|
+
}
|
|
6082
|
+
return names
|
|
6083
|
+
}
|
|
6084
|
+
|
|
6085
|
+
type SwiftCPredefinesTable = {
|
|
6086
|
+
release: string
|
|
6087
|
+
languages: Record<string, Record<string, string | null>>
|
|
6088
|
+
}
|
|
6089
|
+
const cPredefineTable: SwiftCPredefinesTable = cPredefinesJson
|
|
6090
|
+
const cPredefineCache = new Map<string, Map<string, string | undefined>>()
|
|
6091
|
+
|
|
6092
|
+
// the compiler's own macros for the language xcode compiles the unit with:
|
|
6093
|
+
// the pinned toolchain clang's `-dM -E -target arm64-apple-ios-simulator`
|
|
6094
|
+
// predefines, committed in generated/swift-c-predefines.json and held at
|
|
6095
|
+
// the pinned release by scripts/check/swift-c-predefines-generated.ts. a
|
|
6096
|
+
// table, not a spawn, so the scan works hosted, on linux and without xcode.
|
|
6097
|
+
// the triple is the arm64 simulator triple (TARGET_OS_SIMULATOR is 1 there),
|
|
6098
|
+
// matching the emulated target.
|
|
6099
|
+
export function swiftCPredefines(
|
|
6100
|
+
language: 'c' | 'c++' | 'objective-c' | 'objective-c++',
|
|
6101
|
+
): Map<string, string | undefined> {
|
|
6102
|
+
const cached = cPredefineCache.get(language)
|
|
6103
|
+
if (cached) return cached
|
|
6104
|
+
const predefines = new Map<string, string | undefined>()
|
|
6105
|
+
for (const [name, value] of Object.entries(cPredefineTable.languages[language]))
|
|
6106
|
+
predefines.set(name, value ?? undefined)
|
|
6107
|
+
cPredefineCache.set(language, predefines)
|
|
6108
|
+
return predefines
|
|
6109
|
+
}
|
|
6110
|
+
|
|
6111
|
+
export function swiftCMainEntry(
|
|
6112
|
+
file: string,
|
|
6113
|
+
source: string,
|
|
6114
|
+
env: SwiftCMacroEnvironment = emptyMacroEnvironment,
|
|
6115
|
+
): boolean {
|
|
6116
|
+
if (!isSwiftNativeTranslationUnit(file)) return false
|
|
6117
|
+
const code = cActiveCode(stripCCode(source), env)
|
|
6118
|
+
// brace depth ahead of each match, except linkage blocks (`extern "C"`,
|
|
6119
|
+
// strings already stripped): a main inside any other braces is a member,
|
|
6120
|
+
// not the file-scope entry. linkage stays transparent, matching clang,
|
|
6121
|
+
// which accepts the entry with a -Wmain warning.
|
|
6122
|
+
const linkage: boolean[] = []
|
|
6123
|
+
let scanned = 0
|
|
6124
|
+
for (const match of code.matchAll(/^\s*(?:int\s+|void\s+)?main\s*\(/gm)) {
|
|
6125
|
+
while (scanned < match.index) {
|
|
6126
|
+
if (code[scanned] === '{') {
|
|
6127
|
+
let start = scanned
|
|
6128
|
+
while (
|
|
6129
|
+
start > 0 &&
|
|
6130
|
+
code[start - 1] !== ';' &&
|
|
6131
|
+
code[start - 1] !== '{' &&
|
|
6132
|
+
code[start - 1] !== '}'
|
|
6133
|
+
)
|
|
6134
|
+
start--
|
|
6135
|
+
linkage.push(/(?:^|[^\w])extern\s*$/.test(code.slice(start, scanned)))
|
|
6136
|
+
} else if (code[scanned] === '}') linkage.pop()
|
|
6137
|
+
scanned += 1
|
|
6138
|
+
}
|
|
6139
|
+
if (linkage.some((open) => !open)) continue
|
|
6140
|
+
// a definition opens its body after the parameter list and any
|
|
6141
|
+
// trailing declarators (noexcept, attributes); a declaration or a
|
|
6142
|
+
// call ends with a semicolon instead.
|
|
6143
|
+
let depth = 1
|
|
6144
|
+
let index = match.index + match[0].length
|
|
6145
|
+
for (; index < code.length && depth > 0; index++) {
|
|
6146
|
+
if (code[index] === '(') depth++
|
|
6147
|
+
else if (code[index] === ')') depth--
|
|
6148
|
+
}
|
|
6149
|
+
if (depth > 0) continue
|
|
6150
|
+
for (; index < code.length; index++) {
|
|
6151
|
+
const char = code[index]
|
|
6152
|
+
if (char === '{') return true
|
|
6153
|
+
if (char === ';' || char === '}') break
|
|
6154
|
+
// a trailing declarator group (noexcept(...), attributes);
|
|
6155
|
+
// braces inside it belong to the declarator, not a body.
|
|
6156
|
+
if (char === '(' || char === '[') {
|
|
6157
|
+
const closer = char === '(' ? ')' : ']'
|
|
6158
|
+
let nested = 1
|
|
6159
|
+
while (nested > 0 && ++index < code.length) {
|
|
6160
|
+
if (code[index] === char) nested++
|
|
6161
|
+
else if (code[index] === closer) nested--
|
|
6162
|
+
}
|
|
6163
|
+
}
|
|
6164
|
+
}
|
|
6165
|
+
}
|
|
6166
|
+
return false
|
|
6167
|
+
}
|
|
6168
|
+
|
|
5766
6169
|
// swift's executable entry runs after the reactor's _initialize has completed.
|
|
5767
6170
|
// global swift values remain lazy; native application initializers need separate
|
|
5768
6171
|
// object evidence and are refused here rather than running the registry early.
|
|
@@ -5778,7 +6181,7 @@ function installObjcPeerStartup(
|
|
|
5778
6181
|
}
|
|
5779
6182
|
if (
|
|
5780
6183
|
(input.nativeTargets?.length ?? 0) > 0 ||
|
|
5781
|
-
Object.keys(input.files).some(
|
|
6184
|
+
Object.keys(input.files).some(isSwiftNativeTranslationUnit)
|
|
5782
6185
|
)
|
|
5783
6186
|
fail('original native source targets require constructor provenance before admission')
|
|
5784
6187
|
validateObjcPeerStartupLibraries(input.libraries ?? {})
|
|
@@ -6029,6 +6432,19 @@ export function writeSwiftProject(
|
|
|
6029
6432
|
throw new Error('swift compile input has invalid Objective-C peer startup metadata')
|
|
6030
6433
|
if (input.nativeTargets !== undefined && !isSwiftNativeTargets(input.nativeTargets))
|
|
6031
6434
|
throw new Error('swift compile input has invalid original clang target inputs')
|
|
6435
|
+
if (input.packageFiles !== undefined && !isSwiftPackageFiles(input.packageFiles))
|
|
6436
|
+
throw new Error('swift compile input has invalid original package files')
|
|
6437
|
+
const packages = input.packageFiles
|
|
6438
|
+
? swiftManifestPackages(input.files['Package.swift'] ?? '')
|
|
6439
|
+
: new Map<string, string>()
|
|
6440
|
+
for (const directory of packages.values())
|
|
6441
|
+
if (
|
|
6442
|
+
!isSwiftResourcePath(directory) ||
|
|
6443
|
+
!Object.hasOwn(input.packageFiles ?? {}, `${directory}/Package.swift`)
|
|
6444
|
+
)
|
|
6445
|
+
throw new Error(
|
|
6446
|
+
`swift compile input has no transported package manifest for ${directory}`,
|
|
6447
|
+
)
|
|
6032
6448
|
if (
|
|
6033
6449
|
input.resourceBundles !== undefined &&
|
|
6034
6450
|
!isSwiftResourceBundles(input.resourceBundles)
|
|
@@ -6144,7 +6560,7 @@ export function writeSwiftProject(
|
|
|
6144
6560
|
}
|
|
6145
6561
|
targetStagedFiles.delete(target.name)
|
|
6146
6562
|
if (
|
|
6147
|
-
entries.some(([file]) =>
|
|
6563
|
+
entries.some(([file]) => isSwiftNativeTranslationUnit(file)) &&
|
|
6148
6564
|
(swift || input.nativeTargets?.some((value) => value.name === target.name))
|
|
6149
6565
|
) {
|
|
6150
6566
|
if (!swift) {
|
|
@@ -6174,8 +6590,9 @@ export function writeSwiftProject(
|
|
|
6174
6590
|
})
|
|
6175
6591
|
}
|
|
6176
6592
|
}
|
|
6177
|
-
// headers keep their original project paths.
|
|
6178
|
-
// occupy the
|
|
6593
|
+
// headers keep their original project paths. an xcode target's product
|
|
6594
|
+
// headers additionally occupy the flat Module/Header.h namespace it
|
|
6595
|
+
// publishes; a swiftpm target's stay under its public headers directory.
|
|
6179
6596
|
for (const settings of input.nativeTargets ?? []) {
|
|
6180
6597
|
for (const file of settings.headers) {
|
|
6181
6598
|
const contents = input.files[file]
|
|
@@ -6186,6 +6603,7 @@ export function writeSwiftProject(
|
|
|
6186
6603
|
writeFileSync(destination, contents)
|
|
6187
6604
|
files.set(destination, contents)
|
|
6188
6605
|
}
|
|
6606
|
+
if (!settings.flattensPublicHeaders) continue
|
|
6189
6607
|
for (const header of settings.publicHeaders) {
|
|
6190
6608
|
const destination = path.join(headerDirectory, settings.name, path.basename(header))
|
|
6191
6609
|
if (files.has(destination))
|
|
@@ -6229,7 +6647,7 @@ export function writeSwiftProject(
|
|
|
6229
6647
|
for (const target of targets) {
|
|
6230
6648
|
const prefix = target.path === '.' ? '' : `${target.path}/`
|
|
6231
6649
|
const entries = targetEntries(target)
|
|
6232
|
-
const units = entries.filter(([file]) =>
|
|
6650
|
+
const units = entries.filter(([file]) => isSwiftNativeTranslationUnit(file))
|
|
6233
6651
|
if (units.length === 0) continue
|
|
6234
6652
|
const includes = `${prefix}include/`
|
|
6235
6653
|
const consumers = new Map<string, Set<string>>()
|
|
@@ -6285,12 +6703,13 @@ export function writeSwiftProject(
|
|
|
6285
6703
|
mkdirSync(path.dirname(destination), { recursive: true })
|
|
6286
6704
|
writeFileSync(destination, input.files[file]!)
|
|
6287
6705
|
}
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6706
|
+
// xcode searches only the target's search paths and header maps; a
|
|
6707
|
+
// -I per header directory would let an angle include land on a
|
|
6708
|
+
// project header xcode never exposes (damus: <stdint.h> on flatcc's
|
|
6709
|
+
// portable/include/std/stdint.h instead of the sdk).
|
|
6710
|
+
const search = [...new Set([...(settings?.headerSearchPaths ?? [])])].flatMap(
|
|
6711
|
+
(dir) => ['-I', path.join(layout.root, dir)],
|
|
6712
|
+
)
|
|
6294
6713
|
const toolchainBin = nativeToolchain()
|
|
6295
6714
|
const sdkHeaders = materializeObjcSdk(
|
|
6296
6715
|
path.join(layout.root, '.build', 'peach-objc-sdk'),
|
|
@@ -6331,7 +6750,8 @@ export function writeSwiftProject(
|
|
|
6331
6750
|
?.resources ?? false,
|
|
6332
6751
|
usesBundleMacro: entries.some(
|
|
6333
6752
|
([file, contents]) =>
|
|
6334
|
-
|
|
6753
|
+
(isSwiftNativeTranslationUnit(file) ||
|
|
6754
|
+
/\.(?:h|hpp|hh|hxx)$/.test(file)) &&
|
|
6335
6755
|
/\bSWIFTPM_MODULE_BUNDLE\b/.test(contents),
|
|
6336
6756
|
),
|
|
6337
6757
|
bundles: input.resourceBundles,
|
|
@@ -6417,7 +6837,6 @@ export function writeSwiftProject(
|
|
|
6417
6837
|
// the complete original surface decides the importer, including
|
|
6418
6838
|
// declarations absent from the swift symbol graph, such as globals.
|
|
6419
6839
|
nativeC =
|
|
6420
|
-
!entries.some(([file]) => file.endsWith('.swift')) &&
|
|
6421
6840
|
!objcDeclarations &&
|
|
6422
6841
|
view.graphs.every((graph) =>
|
|
6423
6842
|
graph.symbols.every(
|
|
@@ -6552,6 +6971,46 @@ export function writeSwiftProject(
|
|
|
6552
6971
|
})
|
|
6553
6972
|
continue
|
|
6554
6973
|
}
|
|
6974
|
+
if (nativeC && entries.some(([file]) => file.endsWith('.swift'))) {
|
|
6975
|
+
const modulemaps = Object.entries(settings.productHeaders).filter(([product]) =>
|
|
6976
|
+
product.endsWith('.modulemap'),
|
|
6977
|
+
)
|
|
6978
|
+
if (modulemaps.length !== 1)
|
|
6979
|
+
throw new Error(`target ${target.name} requires one original module map`)
|
|
6980
|
+
const [product, original] = modulemaps[0]!
|
|
6981
|
+
const contents = input.files[original]
|
|
6982
|
+
if (contents === undefined)
|
|
6983
|
+
throw new Error(`missing original module map ${original}`)
|
|
6984
|
+
stageTargetFile(target.name, path.join(layout.root, product), contents, {
|
|
6985
|
+
allowExisting: true,
|
|
6986
|
+
})
|
|
6987
|
+
const include = path.join(layout.root, target.path, 'include')
|
|
6988
|
+
stageTargetFile(
|
|
6989
|
+
target.name,
|
|
6990
|
+
path.join(include, 'module.modulemap'),
|
|
6991
|
+
`module ${target.name}ImplementationDeclarations { export * }\n`,
|
|
6992
|
+
)
|
|
6993
|
+
native.set(target.name, {
|
|
6994
|
+
mixed: true,
|
|
6995
|
+
path: target.path,
|
|
6996
|
+
includeDirectory: include,
|
|
6997
|
+
sources: nativeUnits.map(([file]) => unitSource(file)),
|
|
6998
|
+
lateSources: nativeUnits.map(([file]) => unitSource(file)),
|
|
6999
|
+
exclude: entries
|
|
7000
|
+
.filter(([file]) => !file.endsWith('.swift') && !file.endsWith('.metal'))
|
|
7001
|
+
.map(([file]) => file.slice(prefix.length))
|
|
7002
|
+
.concat('include'),
|
|
7003
|
+
underlying: { modulemap: path.join(layout.root, product), flags },
|
|
7004
|
+
groups: [...groups.values()],
|
|
7005
|
+
late: {
|
|
7006
|
+
name: `${target.name}SwiftImplementation`,
|
|
7007
|
+
producers: nativeUnits.some(([file]) => /\.mm?$/.test(file))
|
|
7008
|
+
? [target.name]
|
|
7009
|
+
: [],
|
|
7010
|
+
},
|
|
7011
|
+
})
|
|
7012
|
+
continue
|
|
7013
|
+
}
|
|
6555
7014
|
if (nativeC) {
|
|
6556
7015
|
const modulemaps = Object.entries(settings.productHeaders).filter(([product]) =>
|
|
6557
7016
|
product.endsWith('/Modules/module.modulemap'),
|
|
@@ -6759,7 +7218,11 @@ export function writeSwiftProject(
|
|
|
6759
7218
|
continue
|
|
6760
7219
|
}
|
|
6761
7220
|
const original = imports.get(name)
|
|
6762
|
-
if (!exported && !original)
|
|
7221
|
+
if (!exported && !original) {
|
|
7222
|
+
if (native.get(name)?.lateSources.some((file) => /\.mm?$/.test(file)))
|
|
7223
|
+
rootOwner ??= targetEntries(target).find(([file]) => file.endsWith('.swift'))?.[0]
|
|
7224
|
+
continue
|
|
7225
|
+
}
|
|
6763
7226
|
let generated: ReturnType<typeof swiftObjCImports> | undefined
|
|
6764
7227
|
try {
|
|
6765
7228
|
generated =
|
|
@@ -6925,6 +7388,8 @@ export function writeSwiftProject(
|
|
|
6925
7388
|
'-fobjc-exceptions',
|
|
6926
7389
|
'-fexceptions',
|
|
6927
7390
|
'-fwasm-exceptions',
|
|
7391
|
+
'-mllvm',
|
|
7392
|
+
'-wasm-enable-sjlj',
|
|
6928
7393
|
'-fobjc-arc',
|
|
6929
7394
|
'-fblocks',
|
|
6930
7395
|
...objcSdkIntakeFlags(headers, nativeToolchain(), minimum),
|
|
@@ -7013,7 +7478,7 @@ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nati
|
|
|
7013
7478
|
throw new Error(
|
|
7014
7479
|
'scripts/contrast-app-Package.swift lost the executable linker line',
|
|
7015
7480
|
)
|
|
7016
|
-
manifest = manifest.replace(reactor, `${reactor}${
|
|
7481
|
+
manifest = manifest.replace(reactor, `${reactor}${executableLinkFlags(layout.root)}`)
|
|
7017
7482
|
const optionalProducts =
|
|
7018
7483
|
swiftTargetDependencies(input.files, [{ name: 'App', path: '.' }]).get('App') ?? []
|
|
7019
7484
|
if (optionalProducts.length > 0) {
|
|
@@ -7068,7 +7533,9 @@ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nati
|
|
|
7068
7533
|
files.set(
|
|
7069
7534
|
path.join(layout.root, 'Package.swift'),
|
|
7070
7535
|
emitSwiftPackageManifest({
|
|
7536
|
+
root: layout.root,
|
|
7071
7537
|
targets,
|
|
7538
|
+
packages,
|
|
7072
7539
|
native,
|
|
7073
7540
|
objcExports,
|
|
7074
7541
|
nativeFlags,
|
|
@@ -7092,6 +7559,35 @@ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nati
|
|
|
7092
7559
|
}) + moduleFiles,
|
|
7093
7560
|
)
|
|
7094
7561
|
}
|
|
7562
|
+
for (const [file, bytes] of Object.entries(input.packageFiles ?? {}))
|
|
7563
|
+
files.set(path.join(layout.root, file), Buffer.from(bytes, 'base64'))
|
|
7564
|
+
if (input.packageFiles) {
|
|
7565
|
+
files.set(
|
|
7566
|
+
path.join(layout.root, '.peach-target-toolset.json'),
|
|
7567
|
+
JSON.stringify({
|
|
7568
|
+
schemaVersion: '1.0',
|
|
7569
|
+
swiftCompiler: {
|
|
7570
|
+
extraCLIOptions: [
|
|
7571
|
+
'-I',
|
|
7572
|
+
distribution
|
|
7573
|
+
? path.join(moduleRoot, 'modules')
|
|
7574
|
+
: path.join(layout.root, '.build', WASM_TRIPLE, 'release', 'Modules'),
|
|
7575
|
+
'-Xfrontend',
|
|
7576
|
+
'-enable-cross-import-overlays',
|
|
7577
|
+
...swiftCrossImportFlags(moduleRoot, Boolean(distribution)),
|
|
7578
|
+
...(distribution
|
|
7579
|
+
? FOUNDATION_IMPLICIT_MODULES.flatMap((module) => [
|
|
7580
|
+
'-Xfrontend',
|
|
7581
|
+
'-import-module',
|
|
7582
|
+
'-Xfrontend',
|
|
7583
|
+
module,
|
|
7584
|
+
])
|
|
7585
|
+
: []),
|
|
7586
|
+
],
|
|
7587
|
+
},
|
|
7588
|
+
}),
|
|
7589
|
+
)
|
|
7590
|
+
}
|
|
7095
7591
|
// resource accessors and the /res pack share the original target assignment.
|
|
7096
7592
|
for (const target of resourceTargets) {
|
|
7097
7593
|
if (!target.resources) continue
|
|
@@ -7549,6 +8045,7 @@ export function compileSwiftProjectUnit(
|
|
|
7549
8045
|
// and that one reads and gzips it while swift builds
|
|
7550
8046
|
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId
|
|
7551
8047
|
const icu = swiftIcuAsset(options.toolchainBin, sdk)
|
|
8048
|
+
writeSwiftAutolinkLinker(root, options.toolchainBin)
|
|
7552
8049
|
const buildArgs = [
|
|
7553
8050
|
'build',
|
|
7554
8051
|
...swiftPackageCacheOptions(),
|
|
@@ -7561,6 +8058,9 @@ export function compileSwiftProjectUnit(
|
|
|
7561
8058
|
...swiftSdkOptions(),
|
|
7562
8059
|
'--swift-sdk',
|
|
7563
8060
|
sdk,
|
|
8061
|
+
...(input.packageFiles
|
|
8062
|
+
? ['--toolset', path.join(root, '.peach-target-toolset.json')]
|
|
8063
|
+
: []),
|
|
7564
8064
|
'-c',
|
|
7565
8065
|
'release',
|
|
7566
8066
|
'-Xswiftc',
|
|
@@ -7569,12 +8069,18 @@ export function compileSwiftProjectUnit(
|
|
|
7569
8069
|
'-num-threads',
|
|
7570
8070
|
'-Xswiftc',
|
|
7571
8071
|
BUILD_JOBS,
|
|
7572
|
-
...macroPlugins.flatMap((plugin) => [
|
|
8072
|
+
...macroPlugins.libraries.flatMap((plugin) => [
|
|
7573
8073
|
'-Xswiftc',
|
|
7574
8074
|
'-load-plugin-library',
|
|
7575
8075
|
'-Xswiftc',
|
|
7576
8076
|
plugin,
|
|
7577
8077
|
]),
|
|
8078
|
+
...macroPlugins.executables.flatMap((plugin) => [
|
|
8079
|
+
'-Xswiftc',
|
|
8080
|
+
'-load-plugin-executable',
|
|
8081
|
+
'-Xswiftc',
|
|
8082
|
+
`${plugin}#ExpoModulesMacros`,
|
|
8083
|
+
]),
|
|
7578
8084
|
]
|
|
7579
8085
|
const buildOptions = {
|
|
7580
8086
|
env: {
|
|
@@ -7599,6 +8105,17 @@ export function compileSwiftProjectUnit(
|
|
|
7599
8105
|
}
|
|
7600
8106
|
report('compiling and linking Swift modules')
|
|
7601
8107
|
try {
|
|
8108
|
+
if (input.packageFiles && !swiftDistributionAt(moduleRoot)) {
|
|
8109
|
+
const frameworks = new Set(['SwiftUI'])
|
|
8110
|
+
for (const name of input.packageGuestImports ?? [])
|
|
8111
|
+
if (OPTIONAL_FRAMEWORKS.has(name)) frameworks.add(name)
|
|
8112
|
+
for (const framework of frameworks)
|
|
8113
|
+
await runCompiler(
|
|
8114
|
+
swift,
|
|
8115
|
+
[...buildArgs, '--target', framework],
|
|
8116
|
+
buildOptions,
|
|
8117
|
+
)
|
|
8118
|
+
}
|
|
7602
8119
|
// clang consumes the real emitted headers after swift finishes.
|
|
7603
8120
|
// swiftpm's transitive swift module maps are not C declarations:
|
|
7604
8121
|
// importing them would shadow SDK modules such as ObjectiveC.
|