peachsim 0.1.1716 → 0.1.1738
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -3
- package/cli/app-bundle-resources.ts +2 -1
- package/cli/app-fonts.ts +4 -4
- package/cli/app-splash.ts +4 -4
- package/cli/app-stubs.ts +17 -0
- package/cli/command-registry.ts +1 -0
- package/cli/commands/control.ts +83 -822
- package/cli/commands/coverage-swift.ts +112 -4
- package/cli/commands/daemon.ts +8 -0
- package/cli/commands/detox.ts +3 -0
- package/cli/commands/doctor.ts +19 -2
- package/cli/commands/inspect/actions.ts +74 -14
- package/cli/commands/inspect/core.ts +5 -1
- package/cli/commands/inspect/settling.ts +5 -2
- package/cli/commands/inspect/wait-ready.ts +6 -0
- package/cli/commands/inspect.ts +48 -45
- package/cli/commands/kotlin.ts +12 -2
- package/cli/commands/package.ts +760 -0
- package/cli/commands/serve.ts +6 -0
- package/cli/commands/shell-url.ts +838 -0
- package/cli/commands/swift.ts +42 -102
- package/cli/commands/test.ts +20 -0
- package/cli/commands/upload.ts +1 -1
- package/cli/device-option.ts +1 -1
- package/cli/main.ts +13 -1
- package/cli/native-input.ts +199 -0
- package/cli/outbound-endpoints.ts +26 -1
- package/cli/packaged-app-launcher.ts +95 -0
- package/cli/scene-video.ts +36 -12
- package/detox/index.ts +196 -24
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +5 -2
- package/dist-lib/auth/shared-session.cjs +5 -2
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +39889 -31873
- 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 +195 -63
- package/dist-lib/dev-bundle-resolution.cjs +14 -13
- package/dist-lib/expo-swift-bundle.cjs +18507 -11835
- package/dist-lib/expo-swift-metadata.cjs +4 -1
- package/dist-lib/expo-swift-metadata.mjs +3 -1
- package/dist-lib/home-paths.cjs +27 -3
- package/dist-lib/host/bridge-host.cjs +28373 -24090
- package/dist-lib/host/fetch-proxy-handler.cjs +235 -225
- 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 +915 -399
- 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 +335 -47
- package/dist-lib/menu.cjs +13 -1
- package/dist-lib/menu.mjs +13 -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 +918 -411
- package/dist-lib/native-app-identity-project.cjs +703 -283
- package/dist-lib/native-app-identity-project.mjs +500 -87
- package/dist-lib/native-app-identity.cjs +13 -2
- package/dist-lib/native-app-identity.mjs +13 -2
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +5 -2
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +28 -23
- package/dist-lib/public-origins-lib.json +418 -224
- package/dist-lib/react-native-host-modules.cjs +35 -2
- package/dist-lib/react-native-host-modules.mjs +35 -2
- package/dist-lib/reap-browser.cjs +12 -4
- package/dist-lib/scripts/dev-server-scanner.cjs +15 -8
- package/dist-lib/sdk.cjs +17 -7
- package/dist-lib/sdk.mjs +16 -7
- package/dist-lib/skills.cjs +44825 -29141
- package/dist-lib/swift-compile.cjs +616 -400
- package/dist-lib/swift-compile.mjs +528 -315
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +105 -17
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +4660 -2252
- package/dist-lib/vite.cjs +248 -234
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-cookies.d.ts +17 -8
- package/dist-types/packages/peach-engine/src/engine/canvaskit-renderer.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +7 -4
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +9 -6
- package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +0 -5
- package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +11 -1
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +5 -12
- package/dist-types/packages/peach-engine/src/engine/render-damage.d.ts +2 -2
- package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +5 -0
- package/dist-types/packages/peach-engine/src/engine/text-paragraph.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/types.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/native-preview-bundle.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +9 -0
- 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/native-ui-commandContract.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +7 -2
- package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +5 -0
- package/dist-types/packages/peach-engine/src/render-worker/tree-sync-port.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +36 -2
- package/dist-types/packages/peach-engine/src/shell-events.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/audioBridgeContract.d.ts +5 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
- package/dist-types/packages/peach-globals/src/keyboardBridgeContract.d.ts +11 -0
- package/dist-types/packages/peach-globals/src/shellBridgeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +9 -2
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/kotlin/README.md +3 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/scripts/dev-server-scanner.ts +12 -25
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccount.h +55 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountCredential.h +35 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountStore.h +94 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountType.h +53 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACError.h +37 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/Accounts.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/AccountsDefines.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASFoundation.h +52 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSession.h +128 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSessionCallback.h +35 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/AuthenticationServices.h +3 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFHTTPMessage.h +724 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +4 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetworkDefs.h +27 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h +1301 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +3 -1
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager.h +21 -50
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLRegion.h +6 -6
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +58 -3
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +711 -46
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h +12 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIInterface.h +23 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +7 -9
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIOrientation.h +14 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIStringDrawing.h +12 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIView.h +14 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewAnimating.h +12 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewController.h +16 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIWindow.h +2 -0
- package/sdk/ios/usr/include/ConditionalMacros.h +619 -0
- package/sdk/ios/usr/include/module.modulemap +1 -0
- package/sdk/ios/usr/include/objc/objc-sync.h +59 -0
- package/sdk/ios/usr/include/os/signpost.h +414 -0
- package/sdk/ios/usr/include/os.modulemap +10 -0
- package/sdk/ios/usr/include/sys/cdefs.h +5 -0
- package/sdk/ios/usr/include/sys/ioccom.h +99 -0
- package/sdk/ios/usr/include/sys/syslog.h +236 -0
- package/sdk/ios/usr/include/syslog.h +24 -0
- package/sdk/ios/wasm/include/errno.h +4 -20
- package/sdk/ios/wasm/include/fcntl.h +4 -2
- package/sdk/ios/wasm/include/pthread.h +3 -0
- package/sdk/ios/wasm/include/setjmp.h +57 -0
- package/sdk/ios/wasm/include/stdio.h +24 -0
- package/sdk/ios/wasm/include/stdlib.h +32 -7
- package/sdk/ios/wasm/include/sys/file.h +7 -0
- package/sdk/ios/wasm/include/sys/ioctl.h +6 -0
- package/sdk/ios/wasm/include/sys/resource.h +2 -2
- package/sdk/ios/wasm/include/sys/syscall.h +9 -0
- package/sdk/ios/wasm/include/sys/time.h +10 -0
- package/sdk/ios/wasm/include/unistd.h +12 -3
- package/sdk/native-hashes.json +4 -3
- package/skills/contrast/SKILL.md +2 -1
- package/skills/peach-debug/SKILL.md +0 -1
- package/skills/peach-perf/SKILL.md +0 -1
- package/skills/peach-setup/SKILL.md +0 -1
- package/skills/peach-test/SKILL.md +7 -4
- package/skills/peach-visual/SKILL.md +0 -1
- package/src/admitted-mac-build.ts +3 -0
- package/src/android-app-identity.ts +18 -0
- package/src/android-autolinking.ts +1 -0
- package/src/android-bridge-packages.ts +279 -0
- package/src/android-root-module.ts +9 -9
- package/src/appPackageContract.ts +83 -0
- package/src/bridge-contract.ts +50 -0
- package/src/bundle-channel.mjs +41 -6
- package/src/cli-runtime.ts +9 -5
- package/src/dev-bundle-resolution.ts +7 -27
- package/src/dom-source-reference.ts +15 -0
- package/src/expo-discovery-cache.ts +134 -26
- package/src/expo-kotlin-host.ts +97 -26
- package/src/expo-manifest-body.ts +33 -0
- package/src/expo-native-workspace.ts +158 -38
- package/src/expo-swift-host.ts +350 -75
- package/src/expo-swift-ready.ts +5 -1
- package/src/expoKotlinContract.ts +12 -2
- package/src/expoSwiftContract.ts +10 -0
- package/src/generated/swift-c-predefines.json +1 -1
- package/src/home-paths.ts +41 -2
- package/src/host/app-package-handler.ts +47 -0
- package/src/host/bridge-host.ts +8 -0
- package/src/host/fetch-proxy-handler.ts +10 -0
- package/src/host/staged-host-files.ts +18 -0
- package/src/index.ts +3 -0
- package/src/kotlin-host.ts +225 -48
- package/src/kotlin-instance-source.ts +126 -0
- package/src/kotlinSdkContract.ts +2 -1
- package/src/menu.ts +14 -0
- package/src/native-app-identity-project.ts +7 -2
- package/src/native-app-identity.ts +11 -0
- package/src/native-firebase-config.ts +24 -1
- package/src/native-prebuilt.ts +154 -0
- package/src/nitro-adapter.lock.json +270 -270
- package/src/nitro-adapter.ts +56 -50
- package/src/nitro-bundle.ts +92 -74
- package/src/nitro-compile.ts +45 -14
- package/src/nitro-dependencies.ts +63 -46
- package/src/nitro-source.ts +64 -26
- package/src/nitroAdapterContract.ts +146 -98
- package/src/nitroContract.ts +71 -21
- package/src/react-native-bridge-modules.ts +70 -42
- package/src/react-native-host-modules.ts +34 -1
- package/src/reactNativeConfigurationContract.ts +14 -0
- package/src/reap-browser.ts +15 -3
- package/src/sdk.ts +5 -0
- package/src/settingsContract.ts +38 -1
- package/src/sim-client.ts +4 -1
- package/src/storageSnapshotContract.ts +32 -81
- package/src/swift-compile.ts +268 -89
- package/src/swift-coverage/indexdump.ts +22 -6
- package/src/swift-coverage/indexing.ts +4 -4
- package/src/swift-coverage/provenance.ts +1 -0
- package/src/swift-coverage/sdk.ts +104 -20
- package/src/swift-coverage/types.ts +34 -0
- package/src/swift-coverage/xcode-asset-symbols.ts +922 -0
- package/src/swift-coverage/xcode-assets.ts +89 -131
- package/src/swift-coverage/xcode.ts +10 -2
- package/src/swift-cxx-reachable.ts +2 -1
- package/src/swift-distribution.lock.json +20 -16
- package/src/swift-host.ts +98 -22
- package/src/swift-icu.ts +1 -1
- package/src/swift-link-roots.ts +118 -0
- package/src/swift-objc-compile.ts +144 -22
- package/src/swift-objc-import.ts +6 -0
- package/src/swift-objc-standin.ts +2 -14
- package/src/swift-package-manifest.ts +14 -6
- package/src/swift-packages.ts +75 -11
- package/src/swift-pdf-raster.ts +1 -0
- package/src/swift-root-lock.ts +17 -1
- package/src/swift-source-pods.ts +2 -10
- package/src/swift-standin-emit.ts +597 -57
- package/src/swift-standins.ts +599 -56
- package/src/swift-submit.ts +7 -1
- package/src/swift-toolchain.ts +140 -17
- package/src/turbo-bundle.ts +81 -0
- package/src/turbo-codegen-intake.ts +91 -0
- package/src/turbo-compile.ts +120 -0
- package/src/turbo-runtime.lock.json +69 -0
- package/src/turbo-source.ts +754 -0
- package/src/vite-plugin-one.ts +17 -12
- package/src/vite-plugin.ts +28 -15
- package/src/xcode-project.ts +223 -22
package/src/swift-compile.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
renameSync,
|
|
17
17
|
rmSync,
|
|
18
18
|
statSync,
|
|
19
|
+
symlinkSync,
|
|
19
20
|
utimesSync,
|
|
20
21
|
writeFileSync,
|
|
21
22
|
} from 'node:fs'
|
|
@@ -23,7 +24,7 @@ import os from 'node:os'
|
|
|
23
24
|
import path from 'node:path'
|
|
24
25
|
import { admittedMacBuilderSlot } from './admitted-mac-build'
|
|
25
26
|
import cPredefinesJson from './generated/swift-c-predefines.json' with { type: 'json' }
|
|
26
|
-
import {
|
|
27
|
+
import { swiftCacheDir, swiftPackageCacheOptions } from './home-paths'
|
|
27
28
|
import { terminateProcessGroup } from './process-group'
|
|
28
29
|
import { swiftCompilerSourceDigest } from './swift-compiler-digest'
|
|
29
30
|
import { designTimeDiagnostic, designTimeSource } from './swift-design-time'
|
|
@@ -33,7 +34,12 @@ import {
|
|
|
33
34
|
type SwiftDistributionManifest,
|
|
34
35
|
} from './swift-distribution-contract'
|
|
35
36
|
import { swiftIcuAsset, type SwiftIcuAsset } from './swift-icu'
|
|
36
|
-
import {
|
|
37
|
+
import { swiftObjcRootObjects } from './swift-link-roots'
|
|
38
|
+
import {
|
|
39
|
+
SWIFT_OBJC_INTEROP_FLAGS,
|
|
40
|
+
swiftClangImporterFlags,
|
|
41
|
+
swiftObjCModuleMap,
|
|
42
|
+
} from './swift-objc-import'
|
|
37
43
|
import { swiftObjCRuntimeFlags } from './swift-objc-runtime'
|
|
38
44
|
import { iosDeploymentMinimum, objcSdkIntakeFlags } from './swift-objc-standin'
|
|
39
45
|
import {
|
|
@@ -56,7 +62,7 @@ import {
|
|
|
56
62
|
type SwiftPackageTarget,
|
|
57
63
|
} from './swift-package'
|
|
58
64
|
import { withSwiftRootLock, type SwiftRootLease } from './swift-root-lock'
|
|
59
|
-
import { swiftSharedSdkInputFiles } from './swift-shared-sdk'
|
|
65
|
+
import { swiftSharedSdkInputFiles, swiftSharedSdkRoot } from './swift-shared-sdk'
|
|
60
66
|
import {
|
|
61
67
|
sourceSwiftCheckout,
|
|
62
68
|
SWIFT_AUTOLINK_LINKER,
|
|
@@ -215,6 +221,8 @@ export interface SwiftCompileInput {
|
|
|
215
221
|
projectFiles?: Record<string, string>
|
|
216
222
|
packageGuestImports?: string[]
|
|
217
223
|
nativeTargets?: SwiftNativeTarget[]
|
|
224
|
+
/** the Xcode app project's development region, for the emitted manifest's default localization. */
|
|
225
|
+
defaultLocalization?: string
|
|
218
226
|
metalSources?: Record<string, string>
|
|
219
227
|
resources?: Record<string, string>
|
|
220
228
|
/** project-relative resource paths retained before the bundle namespace flattens. */
|
|
@@ -234,6 +242,11 @@ export interface SwiftCompileInput {
|
|
|
234
242
|
* replace the stand-in's traps.
|
|
235
243
|
*/
|
|
236
244
|
libraries?: Record<string, string>
|
|
245
|
+
/**
|
|
246
|
+
* link the distribution as an archive: only the objects the program
|
|
247
|
+
* references by symbol, plus those that register ObjC classes at load.
|
|
248
|
+
*/
|
|
249
|
+
lazyDistribution?: boolean
|
|
237
250
|
}
|
|
238
251
|
|
|
239
252
|
// the builder hop wraps the compiler's own timeout with admission, transfer and
|
|
@@ -305,6 +318,7 @@ export function swiftModuleInputFiles(root: string): string[] {
|
|
|
305
318
|
...swiftSharedSdkInputFiles(root),
|
|
306
319
|
'../peachsim/src/swift-shared-sdk.ts',
|
|
307
320
|
'../../scripts/generate/swift-sdk-module/darwin-mach.json',
|
|
321
|
+
'../../scripts/ops/swift-distribution-publish.ts',
|
|
308
322
|
'Package.swift',
|
|
309
323
|
'scripts/contrast-app-Package.swift',
|
|
310
324
|
'scripts/build-distribution.ts',
|
|
@@ -505,6 +519,8 @@ export function withNativeSourceGlue(
|
|
|
505
519
|
|
|
506
520
|
// optional families link only into an app whose sources import them, each
|
|
507
521
|
// with the optional families it depends on (packages/sootsim-swift/Package.swift).
|
|
522
|
+
// a family a base framework depends on is base too: CoreGraphics decodes
|
|
523
|
+
// through PeachCodec, so PeachCodec links into every app.
|
|
508
524
|
const OPTIONAL_FRAMEWORK_DEPENDENCIES: Record<string, string[]> = {
|
|
509
525
|
GameplayKit: [],
|
|
510
526
|
simd: [],
|
|
@@ -516,9 +532,8 @@ const OPTIONAL_FRAMEWORK_DEPENDENCIES: Record<string, string[]> = {
|
|
|
516
532
|
ImagePlayground: [],
|
|
517
533
|
QuickLookThumbnailing: [],
|
|
518
534
|
libxml2: [],
|
|
519
|
-
Compression: [
|
|
520
|
-
zlib: [
|
|
521
|
-
PeachCodec: [],
|
|
535
|
+
Compression: [],
|
|
536
|
+
zlib: [],
|
|
522
537
|
TikTokBusinessSDK: [],
|
|
523
538
|
nSure: [],
|
|
524
539
|
Statsig: [],
|
|
@@ -893,6 +908,80 @@ export function missingSwiftModules(
|
|
|
893
908
|
return new Map([...missing].sort(([left], [right]) => left.localeCompare(right)))
|
|
894
909
|
}
|
|
895
910
|
|
|
911
|
+
/**
|
|
912
|
+
* the clang module names and plain C headers a package's `.systemLibrary`
|
|
913
|
+
* targets own. a system target's clang module name need not match its SwiftPM
|
|
914
|
+
* target name, and its headers need not be provided by the distribution.
|
|
915
|
+
*/
|
|
916
|
+
export function swiftSystemLibrarySurface(
|
|
917
|
+
files: Record<string, string>,
|
|
918
|
+
targets: readonly Pick<SwiftPackageTarget, 'path' | 'systemLibrary'>[],
|
|
919
|
+
): { modules: Set<string>; headers: Set<string> } {
|
|
920
|
+
const modules = new Set<string>()
|
|
921
|
+
const headers = new Set<string>()
|
|
922
|
+
for (const target of targets) {
|
|
923
|
+
if (!target.systemLibrary) continue
|
|
924
|
+
const prefix = target.path === '.' ? '' : `${target.path.replace(/\/+$/, '')}/`
|
|
925
|
+
for (const [file, contents] of Object.entries(files)) {
|
|
926
|
+
if (!file.startsWith(prefix) || !file.endsWith('.modulemap')) continue
|
|
927
|
+
for (const match of contents.matchAll(/^\s*module\s+([A-Za-z_]\w*)/gm))
|
|
928
|
+
modules.add(match[1]!)
|
|
929
|
+
for (const match of contents.matchAll(/^\s*(?:umbrella\s+)?header\s+"([^"]+)"/gm)) {
|
|
930
|
+
const header = files[`${prefix}${match[1]}`]
|
|
931
|
+
if (header === undefined) continue
|
|
932
|
+
for (const include of header.matchAll(/#\s*(?:include|import)\s*<([^>/]+)>/g))
|
|
933
|
+
headers.add(include[1]!.replace(/\.h$/, ''))
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
return { modules, headers }
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
/**
|
|
941
|
+
* distribution modules a local system library must win over. a distribution
|
|
942
|
+
* module or a header it owns would otherwise satisfy the system target's
|
|
943
|
+
* `#include`, replacing the target SDK's declarations with the distribution's.
|
|
944
|
+
*/
|
|
945
|
+
export function swiftSystemLibraryExclusions(
|
|
946
|
+
files: Record<string, string>,
|
|
947
|
+
targets: readonly Pick<SwiftPackageTarget, 'path' | 'systemLibrary'>[],
|
|
948
|
+
distributionModules: readonly string[],
|
|
949
|
+
): Set<string> {
|
|
950
|
+
const surface = swiftSystemLibrarySurface(files, targets)
|
|
951
|
+
return new Set(
|
|
952
|
+
distributionModules.filter(
|
|
953
|
+
(name) => surface.modules.has(name) || surface.headers.has(name),
|
|
954
|
+
),
|
|
955
|
+
)
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/** a distribution modules path without the modules a local system library owns. */
|
|
959
|
+
function distributionModulesPath(
|
|
960
|
+
root: string,
|
|
961
|
+
moduleRoot: string,
|
|
962
|
+
excluded: ReadonlySet<string> | undefined,
|
|
963
|
+
): string {
|
|
964
|
+
const modules = path.join(moduleRoot, 'modules')
|
|
965
|
+
if (!excluded || excluded.size === 0) return modules
|
|
966
|
+
const key = createHash('sha256')
|
|
967
|
+
.update([...excluded].sort().join('\0'))
|
|
968
|
+
.digest('hex')
|
|
969
|
+
.slice(0, 16)
|
|
970
|
+
const directory = path.join(root, `.peach-modules-${key}`)
|
|
971
|
+
const complete = path.join(directory, '.complete')
|
|
972
|
+
if (!existsSync(complete)) {
|
|
973
|
+
mkdirSync(directory, { recursive: true })
|
|
974
|
+
for (const entry of readdirSync(directory))
|
|
975
|
+
rmSync(path.join(directory, entry), { recursive: true, force: true })
|
|
976
|
+
for (const entry of readdirSync(modules)) {
|
|
977
|
+
if (excluded.has(entry.replace(/\.swiftmodule$/, ''))) continue
|
|
978
|
+
symlinkSync(path.join(modules, entry), path.join(directory, entry))
|
|
979
|
+
}
|
|
980
|
+
writeFileSync(complete, '')
|
|
981
|
+
}
|
|
982
|
+
return directory
|
|
983
|
+
}
|
|
984
|
+
|
|
896
985
|
export function swiftTargetDependencies(
|
|
897
986
|
files: Record<string, string>,
|
|
898
987
|
targets: Pick<SwiftPackageTarget, 'name' | 'path' | 'dependencies'>[],
|
|
@@ -978,11 +1067,13 @@ const executableLinkFlags = (root: string) => ` "-Xclang-linker", "-O0"
|
|
|
978
1067
|
"-Xlinker", "--stack-first",
|
|
979
1068
|
"-Xlinker", "--global-base=8372224",
|
|
980
1069
|
"-Xlinker", "-lsetjmp",
|
|
1070
|
+
"-Xlinker", "--export-table",
|
|
1071
|
+
"-Xlinker", "--growable-table",
|
|
981
1072
|
`
|
|
982
1073
|
const REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n'
|
|
983
1074
|
|
|
984
1075
|
/** bump with any change to the emitted multi-target manifest text. */
|
|
985
|
-
export const MULTI_MANIFEST_VERSION =
|
|
1076
|
+
export const MULTI_MANIFEST_VERSION = 50
|
|
986
1077
|
|
|
987
1078
|
// build-cli replaces this in every bundle; source runs read the files directly.
|
|
988
1079
|
declare const __SWIFT_COMPILER_DIGEST__: string | undefined
|
|
@@ -1001,6 +1092,7 @@ export function swiftArtifactHash(
|
|
|
1001
1092
|
hash.update(compilerSourceDigest)
|
|
1002
1093
|
if (input.oneModule) hash.update('one-module\n')
|
|
1003
1094
|
hash.update(swiftModuleDigest(moduleRoot))
|
|
1095
|
+
if (input.lazyDistribution) hash.update('lazy-distribution\n')
|
|
1004
1096
|
for (const file of Object.keys(input.files).sort()) {
|
|
1005
1097
|
hash.update(createHash('sha256').update(file).digest())
|
|
1006
1098
|
hash.update(createHash('sha256').update(input.files[file]).digest())
|
|
@@ -1040,6 +1132,8 @@ export function swiftArtifactHash(
|
|
|
1040
1132
|
)
|
|
1041
1133
|
hash.update(JSON.stringify(input.nativeTargets ?? []))
|
|
1042
1134
|
hash.update(JSON.stringify(input.packageGuestImports ?? []))
|
|
1135
|
+
if (input.defaultLocalization)
|
|
1136
|
+
hash.update(`default-localization\n${input.defaultLocalization}\n`)
|
|
1043
1137
|
for (const file of Object.keys(input.packageFiles ?? {}).sort()) {
|
|
1044
1138
|
hash.update(`package-file\0${file}\0`)
|
|
1045
1139
|
hash.update(createHash('sha256').update(input.packageFiles![file]!).digest())
|
|
@@ -1161,8 +1255,16 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1161
1255
|
spriteKit?: boolean
|
|
1162
1256
|
/** link the prebuilt distribution at moduleRoot instead of its sources. */
|
|
1163
1257
|
distribution?: SwiftDistributionManifest
|
|
1164
|
-
/**
|
|
1258
|
+
/** distribution modules a local system library must win over. */
|
|
1259
|
+
distributionExcludes?: ReadonlySet<string>
|
|
1260
|
+
/**
|
|
1261
|
+
* ordered distribution objects, read by the linker without expanding argv.
|
|
1262
|
+
* absent when no source reaches a distribution framework: the executable
|
|
1263
|
+
* then links only the stdlib and system archives its sources reference.
|
|
1264
|
+
*/
|
|
1165
1265
|
distributionLink?: { path: string; files: Map<string, string | Buffer> }
|
|
1266
|
+
/** link the distribution objects other than its ObjC registrants lazily. */
|
|
1267
|
+
lazyDistribution?: boolean
|
|
1166
1268
|
/**
|
|
1167
1269
|
* framework products already built in their own scratch. objects link whole,
|
|
1168
1270
|
* and modules import from that scratch, so this package's targets never
|
|
@@ -1173,6 +1275,8 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1173
1275
|
libraries?: Map<string, string>
|
|
1174
1276
|
/** the sdk toolset already searches libc++ before the darwin overlay. */
|
|
1175
1277
|
deferDarwinOverlay?: boolean
|
|
1278
|
+
/** the development region SwiftPM needs as defaultLocalization beside localized resources. */
|
|
1279
|
+
defaultLocalization?: string
|
|
1176
1280
|
}): string {
|
|
1177
1281
|
const { targets, siblings, moduleRoot, oneModule, spriteKit, distribution } = args
|
|
1178
1282
|
const prebuilt = args.prebuilt
|
|
@@ -1196,26 +1300,37 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1196
1300
|
}
|
|
1197
1301
|
// the distribution builder names each object lib/<target>-<file>.o.
|
|
1198
1302
|
// preserve link order while leaving unreached optional module objects out.
|
|
1303
|
+
// the list is named by its content: SwiftPM relinks when the linker
|
|
1304
|
+
// command changes, never when a file the command reads does.
|
|
1305
|
+
let distributionLinkPath: string | undefined
|
|
1199
1306
|
const distributionLink = args.distributionLink
|
|
1200
|
-
if (distribution && !distributionLink)
|
|
1201
|
-
throw new Error(
|
|
1202
|
-
'swift-compile: distribution linking requires its object response file',
|
|
1203
|
-
)
|
|
1204
1307
|
if (distribution && distributionLink) {
|
|
1205
1308
|
const objects = distribution.objects.filter((object) =>
|
|
1206
1309
|
[...OPTIONAL_FRAMEWORKS, 'SpriteKit', 'PeachBox2D'].every(
|
|
1207
1310
|
(name) => !object.startsWith(`lib/${name}-`) || reachedFrameworks.has(name),
|
|
1208
1311
|
),
|
|
1209
1312
|
)
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1313
|
+
const quoted = (object: string) =>
|
|
1314
|
+
`"${path.join(moduleRoot, object).replaceAll('\\', '\\\\').replaceAll('"', '\\"')}"`
|
|
1315
|
+
const roots = args.lazyDistribution
|
|
1316
|
+
? swiftObjcRootObjects(distribution.id, moduleRoot, distribution.objects)
|
|
1317
|
+
: null
|
|
1318
|
+
// an archive region loads an object only when a loaded one references it
|
|
1319
|
+
const list =
|
|
1320
|
+
(roots
|
|
1321
|
+
? [
|
|
1322
|
+
...objects.filter((object) => roots.has(object)).map(quoted),
|
|
1323
|
+
'-Wl,--start-lib',
|
|
1324
|
+
...objects.filter((object) => !roots.has(object)).map(quoted),
|
|
1325
|
+
'-Wl,--end-lib',
|
|
1326
|
+
]
|
|
1327
|
+
: objects.map(quoted)
|
|
1328
|
+
).join('\n') + '\n'
|
|
1329
|
+
distributionLinkPath = distributionLink.path.replace(
|
|
1330
|
+
/\.rsp$/,
|
|
1331
|
+
`-${createHash('sha256').update(list).digest('hex').slice(0, 12)}.rsp`,
|
|
1218
1332
|
)
|
|
1333
|
+
distributionLink.files.set(distributionLinkPath, list)
|
|
1219
1334
|
}
|
|
1220
1335
|
const overlayFlags = swiftCrossImportFlags(moduleRoot, Boolean(distribution))
|
|
1221
1336
|
.map((flag) => `, ${JSON.stringify(flag)}`)
|
|
@@ -1265,7 +1380,9 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1265
1380
|
// the file opaquely so swift neither expands it nor scans every framework
|
|
1266
1381
|
// object for autolinks; distribution.link supplies those libraries.
|
|
1267
1382
|
const imports = distribution
|
|
1268
|
-
? `, "-I", ${JSON.stringify(
|
|
1383
|
+
? `, "-I", ${JSON.stringify(
|
|
1384
|
+
distributionModulesPath(args.root, moduleRoot, args.distributionExcludes),
|
|
1385
|
+
)}`
|
|
1269
1386
|
: prebuilt
|
|
1270
1387
|
? `, "-I", ${JSON.stringify(prebuilt.modules)}${prebuilt.moduleMaps
|
|
1271
1388
|
.map((map) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map}`)}`)
|
|
@@ -1378,16 +1495,20 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1378
1495
|
),
|
|
1379
1496
|
]),
|
|
1380
1497
|
].join(', ')
|
|
1381
|
-
const library =
|
|
1382
|
-
|
|
1383
|
-
|
|
1498
|
+
const library = distribution
|
|
1499
|
+
? [
|
|
1500
|
+
...(distributionLinkPath
|
|
1501
|
+
? ['-Xclang-linker', `--config=${distributionLinkPath}`]
|
|
1502
|
+
: []),
|
|
1503
|
+
...distribution.link,
|
|
1504
|
+
]
|
|
1505
|
+
.map((flag) => `, ${JSON.stringify(flag)}`)
|
|
1506
|
+
.join('')
|
|
1507
|
+
: prebuilt
|
|
1508
|
+
? ['-Xclang-linker', `--config=${prebuilt.linkFile}`, ...prebuilt.link]
|
|
1384
1509
|
.map((flag) => `, ${JSON.stringify(flag)}`)
|
|
1385
1510
|
.join('')
|
|
1386
|
-
:
|
|
1387
|
-
? ['-Xclang-linker', `--config=${prebuilt.linkFile}`, ...prebuilt.link]
|
|
1388
|
-
.map((flag) => `, ${JSON.stringify(flag)}`)
|
|
1389
|
-
.join('')
|
|
1390
|
-
: ''
|
|
1511
|
+
: ''
|
|
1391
1512
|
const kind = target.executable ? '.executableTarget' : '.target'
|
|
1392
1513
|
const linkedLibraries = (target.linkedLibraries ?? []).map(
|
|
1393
1514
|
(name) => `.linkedLibrary(${JSON.stringify(name)})`,
|
|
@@ -1464,6 +1585,9 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1464
1585
|
'// generated by swift-compile from the project package partition.',
|
|
1465
1586
|
'let package = Package(',
|
|
1466
1587
|
' name: "app",',
|
|
1588
|
+
...(args.defaultLocalization
|
|
1589
|
+
? [` defaultLocalization: ${JSON.stringify(args.defaultLocalization)},`]
|
|
1590
|
+
: []),
|
|
1467
1591
|
` products: [.executable(name: "${executable.name}", targets: ["${executable.name}"])],`,
|
|
1468
1592
|
` dependencies: [${[
|
|
1469
1593
|
...(linkedObjects ? [] : [`.package(path: ${JSON.stringify(moduleRoot)})`]),
|
|
@@ -1521,6 +1645,7 @@ export function syncSwiftTree(base: string, files: Map<string, string | Buffer>)
|
|
|
1521
1645
|
if (
|
|
1522
1646
|
dir === base &&
|
|
1523
1647
|
(entry.name === '.build' ||
|
|
1648
|
+
entry.name.startsWith('.peach-modules-') ||
|
|
1524
1649
|
entry.name === SWIFT_LINK_STAMP ||
|
|
1525
1650
|
entry.name === SWIFT_FRAMEWORK_KEY)
|
|
1526
1651
|
)
|
|
@@ -1566,7 +1691,7 @@ const DELEGATE_CLASS =
|
|
|
1566
1691
|
// init(style:reuseIdentifier:) and the header footer view's
|
|
1567
1692
|
// init(reuseIdentifier:).
|
|
1568
1693
|
const REUSABLE_INIT =
|
|
1569
|
-
/^override(?=\s+init\s*\(\s*(?:style\s*:[^,)]*,\s*reuseIdentifier|reuseIdentifier)\s*:)/
|
|
1694
|
+
/^override(?=\s+(?:(?:public|open|internal)\s+)?init\s*\(\s*(?:style\s*:[^,)]*,\s*reuseIdentifier|reuseIdentifier)\s*:)/
|
|
1570
1695
|
// a collection view makes its cells and supplementary views with
|
|
1571
1696
|
// init(frame:), so inside a class that inherits from one, directly or
|
|
1572
1697
|
// through a class declared earlier in the file, an override of it says
|
|
@@ -1770,34 +1895,12 @@ export function swiftCodeMask(source: string): string {
|
|
|
1770
1895
|
|
|
1771
1896
|
// darwin declares these in Foundation; the guest networking module owns them.
|
|
1772
1897
|
const FOUNDATION_NETWORKING_TYPES = new Set([
|
|
1773
|
-
'CachedURLResponse',
|
|
1774
|
-
'HTTPCookieStorage',
|
|
1775
|
-
'NSMutableURLRequest',
|
|
1776
1898
|
'NSURLConnection',
|
|
1777
1899
|
'NSURLConnectionDataDelegate',
|
|
1778
1900
|
'NSURLConnectionDelegate',
|
|
1779
1901
|
'NSURLConnectionDownloadDelegate',
|
|
1780
|
-
'URLCache',
|
|
1781
|
-
'URLCredentialStorage',
|
|
1782
1902
|
'URLProtocol',
|
|
1783
1903
|
'URLProtocolClient',
|
|
1784
|
-
'URLRequest',
|
|
1785
|
-
'URLSession',
|
|
1786
|
-
'URLSessionConfiguration',
|
|
1787
|
-
'URLSessionDataDelegate',
|
|
1788
|
-
'URLSessionDataTask',
|
|
1789
|
-
'URLSessionDelegate',
|
|
1790
|
-
'URLSessionDownloadDelegate',
|
|
1791
|
-
'URLSessionDownloadTask',
|
|
1792
|
-
'URLSessionStreamDelegate',
|
|
1793
|
-
'URLSessionStreamTask',
|
|
1794
|
-
'URLSessionTask',
|
|
1795
|
-
'URLSessionTaskDelegate',
|
|
1796
|
-
'URLSessionTaskMetrics',
|
|
1797
|
-
'URLSessionTaskTransactionMetrics',
|
|
1798
|
-
'URLSessionUploadTask',
|
|
1799
|
-
'URLSessionWebSocketDelegate',
|
|
1800
|
-
'URLSessionWebSocketTask',
|
|
1801
1904
|
])
|
|
1802
1905
|
|
|
1803
1906
|
// Foundation overlay declarations live in the shared guest overlay module.
|
|
@@ -1825,6 +1928,7 @@ const FOUNDATION_OVERLAY_TYPES = new Set([
|
|
|
1825
1928
|
'NSCollectionChangeType',
|
|
1826
1929
|
'NSConditionLock',
|
|
1827
1930
|
'NSDataDetector',
|
|
1931
|
+
'NSErrorPointer',
|
|
1828
1932
|
'NSException',
|
|
1829
1933
|
'NSExtensionContext',
|
|
1830
1934
|
'NSExtensionItem',
|
|
@@ -2466,6 +2570,26 @@ const CORE_FOUNDATION_HANDLE_IMPORTS = [
|
|
|
2466
2570
|
])
|
|
2467
2571
|
.join('; ')
|
|
2468
2572
|
|
|
2573
|
+
// the guest module that owns a name darwin's Foundation declares
|
|
2574
|
+
export function foundationOwnerOf(name: string): string | undefined {
|
|
2575
|
+
if (
|
|
2576
|
+
name === 'NSClassFromString' ||
|
|
2577
|
+
name === 'NSKeyValueChange' ||
|
|
2578
|
+
name === 'NSKeyValueObservedChange' ||
|
|
2579
|
+
name === 'NSKeyValueObservation'
|
|
2580
|
+
)
|
|
2581
|
+
return 'PeachObjC'
|
|
2582
|
+
if (name === 'DispatchData') return 'Dispatch'
|
|
2583
|
+
if (FOUNDATION_NETWORKING_TYPES.has(name)) return 'FoundationNetworking'
|
|
2584
|
+
if (
|
|
2585
|
+
FOUNDATION_OVERLAY_TYPES.has(name) ||
|
|
2586
|
+
FOUNDATION_OVERLAY_GLOBALS.has(name) ||
|
|
2587
|
+
CORE_FOUNDATION_OVERLAY_GLOBALS.has(name)
|
|
2588
|
+
)
|
|
2589
|
+
return 'PeachFoundation'
|
|
2590
|
+
return undefined
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2469
2593
|
export function swiftSourceAsIOS(source: string): string {
|
|
2470
2594
|
const { lineStarts, tokens } = swiftCodeScan(source)
|
|
2471
2595
|
let offset = 0
|
|
@@ -2541,25 +2665,8 @@ export function swiftSourceAsIOS(source: string): string {
|
|
|
2541
2665
|
const foundationMember =
|
|
2542
2666
|
/^Foundation\s*\.\s*(?:`([A-Za-z_]\w*)`|([A-Za-z_]\w*)\b)/.exec(rest)
|
|
2543
2667
|
const foundationName = foundationMember?.[1] ?? foundationMember?.[2]
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
if (
|
|
2547
|
-
foundationName === 'NSClassFromString' ||
|
|
2548
|
-
foundationName === 'NSKeyValueChange' ||
|
|
2549
|
-
foundationName === 'NSKeyValueObservedChange' ||
|
|
2550
|
-
foundationName === 'NSKeyValueObservation'
|
|
2551
|
-
)
|
|
2552
|
-
foundationOwner = 'PeachObjC'
|
|
2553
|
-
else if (foundationName === 'DispatchData') foundationOwner = 'Dispatch'
|
|
2554
|
-
else if (FOUNDATION_NETWORKING_TYPES.has(foundationName))
|
|
2555
|
-
foundationOwner = 'FoundationNetworking'
|
|
2556
|
-
else if (
|
|
2557
|
-
FOUNDATION_OVERLAY_TYPES.has(foundationName) ||
|
|
2558
|
-
FOUNDATION_OVERLAY_GLOBALS.has(foundationName) ||
|
|
2559
|
-
CORE_FOUNDATION_OVERLAY_GLOBALS.has(foundationName)
|
|
2560
|
-
)
|
|
2561
|
-
foundationOwner = 'PeachFoundation'
|
|
2562
|
-
}
|
|
2668
|
+
const foundationOwner =
|
|
2669
|
+
foundationName === undefined ? undefined : foundationOwnerOf(foundationName)
|
|
2563
2670
|
if (foundationOwner !== undefined) {
|
|
2564
2671
|
out += conditioned.slice(copied, at) + foundationOwner
|
|
2565
2672
|
copied = at + 'Foundation'.length
|
|
@@ -2705,6 +2812,18 @@ export function swiftApplicationEntry(file: string, source: string): boolean {
|
|
|
2705
2812
|
return false
|
|
2706
2813
|
}
|
|
2707
2814
|
|
|
2815
|
+
// a typed entry: @main on a struct, class or enum in a branch the wasm
|
|
2816
|
+
// compile reaches. inactive #if branches cannot introduce an entry.
|
|
2817
|
+
export function swiftTypedApplicationEntry(
|
|
2818
|
+
source: string,
|
|
2819
|
+
): { index: number; name: string } | null {
|
|
2820
|
+
const code = [...swiftConditionalLines(swiftCodeMask(source))]
|
|
2821
|
+
.map(({ line, active }) => (active === false ? ' '.repeat(line.length) : line))
|
|
2822
|
+
.join('\n')
|
|
2823
|
+
const match = /@main\b[\s\S]*?\b(?:struct|class|enum)\s+([A-Za-z_]\w*)/.exec(code)
|
|
2824
|
+
return match ? { index: match.index, name: match[1]! } : null
|
|
2825
|
+
}
|
|
2826
|
+
|
|
2708
2827
|
// a main.swift entry calls UIApplicationMain at file scope. a mixed target
|
|
2709
2828
|
// becomes a library, which cannot run that statement as process entry, so the
|
|
2710
2829
|
// call moves into the function the generated executable runs after linking.
|
|
@@ -3307,6 +3426,9 @@ export function writeSwiftProject(
|
|
|
3307
3426
|
},
|
|
3308
3427
|
]
|
|
3309
3428
|
: compileTargets(input)
|
|
3429
|
+
const distributionExcludes = distribution
|
|
3430
|
+
? swiftSystemLibraryExclusions(input.files, targets, distribution.modules)
|
|
3431
|
+
: undefined
|
|
3310
3432
|
const files = new Map<string, string | Buffer>()
|
|
3311
3433
|
const native = new Map<string, SwiftNativeTargetPlan>()
|
|
3312
3434
|
const targetFailures: string[] = []
|
|
@@ -3324,15 +3446,23 @@ export function writeSwiftProject(
|
|
|
3324
3446
|
// swiftpm builds a clang target's module only for an importer: a swift
|
|
3325
3447
|
// import, or a framework-style include or @import in any original source.
|
|
3326
3448
|
const importedModules = new Set<string>()
|
|
3449
|
+
const swiftImportedModules = new Set<string>()
|
|
3450
|
+
const clangImportedModules = new Set<string>()
|
|
3327
3451
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
3328
3452
|
if (file.endsWith('.swift'))
|
|
3329
|
-
for (const name of swiftImportNames(contents))
|
|
3453
|
+
for (const name of swiftImportNames(contents)) {
|
|
3454
|
+
importedModules.add(name)
|
|
3455
|
+
swiftImportedModules.add(name)
|
|
3456
|
+
}
|
|
3330
3457
|
else if (
|
|
3331
3458
|
SWIFT_NATIVE_SOURCE_EXTENSIONS.some(
|
|
3332
3459
|
(extension) => extension !== '.modulemap' && file.endsWith(extension),
|
|
3333
3460
|
)
|
|
3334
3461
|
)
|
|
3335
|
-
for (const name of clangImportNames(contents))
|
|
3462
|
+
for (const name of clangImportNames(contents)) {
|
|
3463
|
+
importedModules.add(name)
|
|
3464
|
+
clangImportedModules.add(name)
|
|
3465
|
+
}
|
|
3336
3466
|
}
|
|
3337
3467
|
const headerDirectory = path.join(layout.root, '.build', 'peach-cxx-headers')
|
|
3338
3468
|
let checkedToolchain: string | undefined
|
|
@@ -3758,7 +3888,7 @@ export function writeSwiftProject(
|
|
|
3758
3888
|
allowExisting: true,
|
|
3759
3889
|
})
|
|
3760
3890
|
const importFlags = [
|
|
3761
|
-
...stageFlags(importOriginalFlags, sdkInclude),
|
|
3891
|
+
...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
|
|
3762
3892
|
'-fmodule-map-file=' + path.join(layout.root, modulemap),
|
|
3763
3893
|
...clangImportModuleMapFlags(settings, layout.root, importModuleMaps),
|
|
3764
3894
|
]
|
|
@@ -4047,10 +4177,8 @@ export function writeSwiftProject(
|
|
|
4047
4177
|
),
|
|
4048
4178
|
)
|
|
4049
4179
|
const mains = entries.flatMap(([file, source]) => {
|
|
4050
|
-
const
|
|
4051
|
-
|
|
4052
|
-
)
|
|
4053
|
-
return match ? [{ file, source, match }] : []
|
|
4180
|
+
const entry = swiftTypedApplicationEntry(source)
|
|
4181
|
+
return entry ? [{ file, source, ...entry }] : []
|
|
4054
4182
|
})
|
|
4055
4183
|
let entryFile: string
|
|
4056
4184
|
let entrySource: string
|
|
@@ -4058,10 +4186,10 @@ export function writeSwiftProject(
|
|
|
4058
4186
|
const main = mains[0]!
|
|
4059
4187
|
entryFile = main.file
|
|
4060
4188
|
entrySource =
|
|
4061
|
-
main.source.slice(0, main.
|
|
4189
|
+
main.source.slice(0, main.index) +
|
|
4062
4190
|
' ' +
|
|
4063
|
-
main.source.slice(main.
|
|
4064
|
-
`\n@MainActor public func __peachRunApplication() { ${main.
|
|
4191
|
+
main.source.slice(main.index + 5) +
|
|
4192
|
+
`\n@MainActor public func __peachRunApplication() { ${main.name}.main() }\n`
|
|
4065
4193
|
} else if (mains.length === 0) {
|
|
4066
4194
|
const procedural = entries.filter(
|
|
4067
4195
|
([file, source]) =>
|
|
@@ -4126,6 +4254,10 @@ export function writeSwiftProject(
|
|
|
4126
4254
|
'-fobjc-exceptions',
|
|
4127
4255
|
'-fexceptions',
|
|
4128
4256
|
'-fwasm-exceptions',
|
|
4257
|
+
// the backend lowers direct setjmp-family calls; -lsetjmp is already
|
|
4258
|
+
// linked. no-op for units without setjmp calls (byte-identical).
|
|
4259
|
+
'-mllvm',
|
|
4260
|
+
'-wasm-enable-sjlj',
|
|
4129
4261
|
'-fobjc-arc',
|
|
4130
4262
|
...intake,
|
|
4131
4263
|
])
|
|
@@ -4189,8 +4321,10 @@ export function writeSwiftProject(
|
|
|
4189
4321
|
const base = layout.multi ? layout.root : layout.sources
|
|
4190
4322
|
const libraries = new Map<string, string>()
|
|
4191
4323
|
for (const [target, data] of Object.entries(input.libraries ?? {})) {
|
|
4192
|
-
const
|
|
4193
|
-
|
|
4324
|
+
const bytes = Buffer.from(data, 'base64')
|
|
4325
|
+
const digest = createHash('sha256').update(bytes).digest('hex')
|
|
4326
|
+
const file = path.join(layout.root, '.peach-libraries', `lib${target}-${digest}.a`)
|
|
4327
|
+
files.set(file, bytes)
|
|
4194
4328
|
libraries.set(target, file)
|
|
4195
4329
|
}
|
|
4196
4330
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
@@ -4212,6 +4346,33 @@ export function writeSwiftProject(
|
|
|
4212
4346
|
resources: false,
|
|
4213
4347
|
},
|
|
4214
4348
|
]
|
|
4349
|
+
// a package reaches the distribution's frameworks through any Swift source
|
|
4350
|
+
// but its entry (every target compiles with implicit framework imports),
|
|
4351
|
+
// through Objective-C, or by importing a distribution module. a C include
|
|
4352
|
+
// of a libsystem header family such as <os/log.h> links libsystem only. C that calls
|
|
4353
|
+
// libdispatch needs the run loop UIKit's host drives (rnx_tick). an entry
|
|
4354
|
+
// that only calls other C and C++ targets links none of the frameworks'
|
|
4355
|
+
// objects, so it carries no UIKit host and reserves no icu data.
|
|
4356
|
+
const reachesFrameworks =
|
|
4357
|
+
!distribution ||
|
|
4358
|
+
Object.entries(input.files).some(
|
|
4359
|
+
([file, source]) =>
|
|
4360
|
+
(file.endsWith('.swift') && file !== input.entry && file !== 'Package.swift') ||
|
|
4361
|
+
/\.mm?$/.test(file) ||
|
|
4362
|
+
source.includes('dispatch_'),
|
|
4363
|
+
) ||
|
|
4364
|
+
[...importedModules].some(
|
|
4365
|
+
(name) =>
|
|
4366
|
+
distribution.modules.includes(name) &&
|
|
4367
|
+
!targets.some((target) => target.name === name) &&
|
|
4368
|
+
!(
|
|
4369
|
+
clangImportedModules.has(name) &&
|
|
4370
|
+
!swiftImportedModules.has(name) &&
|
|
4371
|
+
existsSync(
|
|
4372
|
+
path.join(swiftSharedSdkRoot(moduleRoot, true), 'usr/include', name),
|
|
4373
|
+
)
|
|
4374
|
+
),
|
|
4375
|
+
)
|
|
4215
4376
|
const frameworkLink = prebuilt
|
|
4216
4377
|
? path.join(layout.root, '.peach-framework-objects.rsp')
|
|
4217
4378
|
: undefined
|
|
@@ -4258,15 +4419,21 @@ export function writeSwiftProject(
|
|
|
4258
4419
|
oneModule: input.oneModule,
|
|
4259
4420
|
spriteKit: importsSpriteKit(input.files),
|
|
4260
4421
|
distribution: distribution ?? undefined,
|
|
4422
|
+
distributionExcludes,
|
|
4261
4423
|
deferDarwinOverlay:
|
|
4262
4424
|
native.size > 0 &&
|
|
4263
4425
|
toolsetOrdersLibcxxBeforeDarwinOverlay(
|
|
4264
4426
|
swiftSdkPaths(moduleRoot, nativeToolchain()).cFlags,
|
|
4265
4427
|
),
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4428
|
+
...(reachesFrameworks
|
|
4429
|
+
? {
|
|
4430
|
+
distributionLink: {
|
|
4431
|
+
path: path.join(layout.root, '.peach-distribution-objects.rsp'),
|
|
4432
|
+
files,
|
|
4433
|
+
},
|
|
4434
|
+
lazyDistribution: input.lazyDistribution,
|
|
4435
|
+
}
|
|
4436
|
+
: {}),
|
|
4270
4437
|
...(prebuilt && frameworkLink
|
|
4271
4438
|
? {
|
|
4272
4439
|
prebuilt: {
|
|
@@ -4278,6 +4445,9 @@ export function writeSwiftProject(
|
|
|
4278
4445
|
}
|
|
4279
4446
|
: {}),
|
|
4280
4447
|
libraries,
|
|
4448
|
+
...(input.defaultLocalization
|
|
4449
|
+
? { defaultLocalization: input.defaultLocalization }
|
|
4450
|
+
: {}),
|
|
4281
4451
|
}) + moduleFiles,
|
|
4282
4452
|
)
|
|
4283
4453
|
}
|
|
@@ -4297,7 +4467,7 @@ export function writeSwiftProject(
|
|
|
4297
4467
|
extraCLIOptions: [
|
|
4298
4468
|
'-I',
|
|
4299
4469
|
distribution
|
|
4300
|
-
?
|
|
4470
|
+
? distributionModulesPath(layout.root, moduleRoot, distributionExcludes)
|
|
4301
4471
|
: prebuilt
|
|
4302
4472
|
? prebuilt.modules
|
|
4303
4473
|
: path.join(layout.root, '.build', WASM_TRIPLE, 'release', 'Modules'),
|
|
@@ -4923,6 +5093,15 @@ async function compileFrameworkProducts(args: {
|
|
|
4923
5093
|
.split('\n')
|
|
4924
5094
|
.map((line) => line.trim())
|
|
4925
5095
|
.filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index)
|
|
5096
|
+
// category-only archive members have no symbol reference to pull them in.
|
|
5097
|
+
// source consumers need the same direct Foundation input as distributions.
|
|
5098
|
+
if (link.includes('-lFoundation'))
|
|
5099
|
+
objects.push(
|
|
5100
|
+
path.join(
|
|
5101
|
+
swiftSdkPaths(args.moduleRoot, args.toolchainBin).resources,
|
|
5102
|
+
'wasi/NSStringFormatting.objc.o',
|
|
5103
|
+
),
|
|
5104
|
+
)
|
|
4926
5105
|
return {
|
|
4927
5106
|
modules: path.join(release, 'Modules'),
|
|
4928
5107
|
objects,
|
|
@@ -5021,7 +5200,7 @@ export function compileSwiftProjectUnit(
|
|
|
5021
5200
|
}
|
|
5022
5201
|
const hash = swiftArtifactHash(input, options.release, moduleRoot)
|
|
5023
5202
|
const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release)
|
|
5024
|
-
const sharedRoot = path.join(
|
|
5203
|
+
const sharedRoot = path.join(swiftCacheDir(), 'swift-projects', hash)
|
|
5025
5204
|
const report = (message: string) => {
|
|
5026
5205
|
console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`)
|
|
5027
5206
|
options.onStage?.(message)
|