peachsim 0.1.1808 → 0.1.1811
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/cli/app-bundle-resources.ts +15 -2
- package/cli/cloud-box-artifact.ts +115 -0
- package/cli/cloud-client.ts +95 -53
- package/cli/cloud-dispatch.ts +4 -4
- package/cli/cloud-session.ts +60 -22
- package/cli/commands/box.ts +8 -2
- package/cli/commands/compat.ts +7 -4
- package/cli/commands/control.ts +60 -3
- package/cli/commands/coverage.ts +14 -4
- package/cli/commands/daemon.ts +41 -0
- package/cli/commands/no-bridge-hint.ts +9 -0
- package/cli/commands/package.ts +31 -56
- package/cli/commands/platform.ts +70 -52
- package/cli/commands/preview.ts +73 -24
- package/cli/commands/record.ts +10 -2
- package/cli/commands/screenshot.ts +17 -60
- package/cli/commands/setup.ts +3 -1
- package/cli/commands/three-mode.ts +22 -12
- package/cli/commands/upload.ts +2 -1
- package/cli/desktop-companion.ts +6 -1
- package/cli/drivers/desktop.ts +4 -1
- package/cli/main.ts +12 -2
- package/cli/metro-bundle-assets.ts +14 -4
- package/cli/outbound-endpoints.ts +7 -3
- package/cli/output-redaction.ts +38 -0
- package/cli/privacy.ts +2 -2
- package/cli/recording-access.ts +5 -0
- package/cli/remote-project-bundle.ts +83 -0
- package/cli/shell-init.ts +7 -11
- package/cli/telemetry.ts +41 -4
- package/cli/usage-error.ts +3 -0
- package/cli/ws-bridge.ts +42 -6
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +42783 -40717
- package/dist-lib/capture-contract.cjs +7 -8
- package/dist-lib/capture-contract.mjs +7 -8
- 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 +13 -7
- package/dist-lib/dev-bundle-resolution.cjs +10 -4
- package/dist-lib/expo-swift-bundle.cjs +15819 -15559
- package/dist-lib/expo-swift-metadata.cjs +2 -1
- package/dist-lib/expo-swift-metadata.mjs +2 -1
- package/dist-lib/home-paths.cjs +2 -33
- package/dist-lib/host/bridge-host.cjs +20857 -18756
- package/dist-lib/host/fetch-proxy-handler.cjs +10 -10
- 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 +588 -544
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +25 -19
- package/dist-lib/native-app-identity-project.cjs +15 -6
- package/dist-lib/native-app-identity-project.mjs +23 -12
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +27 -26
- package/dist-lib/public-origins-lib.json +104 -81
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +30496 -24309
- package/dist-lib/swift-compile.cjs +292 -213
- package/dist-lib/swift-compile.mjs +334 -254
- package/dist-lib/swift-package.cjs +8 -4
- package/dist-lib/swift-package.mjs +8 -4
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +32 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +19172 -18941
- package/dist-lib/vite.cjs +11 -11
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/animated.d.ts +4 -0
- package/dist-types/packages/peach-engine/src/engine/animation-graph.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/expo-manifest.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +8 -1
- package/dist-types/packages/peach-globals/src/electronBridgeContract.d.ts +2 -1
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCall.h +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCallCenter.h +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCarrier.h +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTSubscriber.h +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTSubscriberInfo.h +1 -1
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h +1 -1
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSDictionary.h +1 -1
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSExtensionItem.h +1 -1
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/AVFoundation+MPNowPlayingInfoLanguageOptionAdditions.h +39 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/AVPlayerItem+MediaPlayerAdditions.h +26 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPContentItem.h +67 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPError.h +33 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaEntity.h +53 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaItem.h +346 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaItemCollection.h +42 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaLibrary.h +76 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPickerController.h +64 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPlayback.h +47 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPlaylist.h +82 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaQuery.h +120 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaQuerySection.h +26 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMoviePlayerController.h +444 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMoviePlayerViewController.h +43 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerApplicationController.h +47 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerController.h +147 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerQueueDescriptor.h +75 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingInfoCenter.h +197 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingInfoLanguageOption.h +107 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingSession.h +89 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentDataSource.h +59 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentDelegate.h +64 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentManager.h +46 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentManagerContext.h +32 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommand.h +143 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommandCenter.h +66 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommandEvent.h +128 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteControlTypes.h +27 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPVolumeSettings.h +20 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPVolumeView.h +82 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayer.apinotes +74 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayer.h +40 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayerDefines.h +84 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/NSUserActivity+MediaPlayerAdditions.h +20 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityCustomRotor.h +2 -2
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAction.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBackgroundConfiguration.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIButtonConfiguration.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIContextMenuConfiguration.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIContextMenuInteraction.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDeferredMenuElement.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIMenu.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIPointerStyle.h +5 -5
- package/sdk/ios/usr/include/dispatch.modulemap +22 -0
- package/sdk/ios/usr/include/net/if.h +24 -0
- package/sdk/ios/usr/include/sys/time.h +1 -1
- package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +265 -0
- package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2 -0
- package/sdk/ios/wasm/include/fcntl.h +2 -0
- package/sdk/ios/wasm/include/pthread.h +3 -0
- package/sdk/ios/wasm/include/stdlib.h +2 -0
- package/sdk/ios/wasm/include/unistd.h +2 -2
- package/skills/contrast/SKILL.md +2 -2
- package/src/bundle-channel.mjs +9 -72
- package/src/capture-contract.ts +12 -9
- package/src/desktop-host-delivery.ts +16 -2
- package/src/dev-bundle-resolution.ts +12 -3
- package/src/expo-native-workspace.ts +57 -19
- package/src/expo-swift-host.ts +17 -12
- package/src/expo-swift-ready.ts +4 -1
- package/src/expoSwiftContract.ts +1 -0
- package/src/home-paths.ts +4 -48
- package/src/host/bridge-host.ts +1 -0
- package/src/installed-native-libraries.ts +2 -8
- package/src/metro-project-root.ts +2 -1
- package/src/native-bundles.ts +122 -0
- package/src/native-static-libraries.ts +65 -8
- package/src/nitro-adapter.lock.json +278 -278
- package/src/nitro-bundle.ts +2 -2
- package/src/nitro-compile.ts +68 -28
- package/src/nitro-source.ts +24 -6
- package/src/nitro-superset.lock.json +94 -34
- package/src/nitroContract.ts +2 -0
- package/src/podspec-sources.ts +1966 -0
- package/src/storageSnapshotContract.ts +40 -0
- package/src/swift-compile.ts +57 -20
- package/src/swift-design-time.ts +18 -1
- package/src/swift-distribution.lock.json +11 -11
- package/src/swift-distribution.ts +9 -6
- package/src/swift-host.ts +1 -2
- package/src/swift-objc-standin.ts +316 -112
- package/src/swift-package-manifest.ts +4 -3
- package/src/swift-package.ts +10 -3
- package/src/swift-root-lock.ts +11 -0
- package/src/swift-shared-sdk.ts +10 -9
- package/src/swift-source-pods.ts +2 -2
- package/src/swift-standins.ts +40 -143
- package/src/swift-toolchain.ts +42 -0
- package/src/swift-wasm-prune.ts +53 -21
- package/src/turbo-bundle.ts +2 -2
- package/src/turbo-codegen-intake.ts +111 -108
- package/src/turbo-compile.ts +63 -33
- package/src/turbo-runtime.lock.json +21 -21
- package/src/turbo-source.ts +171 -76
- package/src/wasm-optimize.ts +31 -2
- package/src/xcode-project.ts +36 -3
|
@@ -18,11 +18,12 @@ import { execFileSync, spawnSync } from 'node:child_process'
|
|
|
18
18
|
import { createHash } from 'node:crypto'
|
|
19
19
|
import fs from 'node:fs'
|
|
20
20
|
import path from 'node:path'
|
|
21
|
+
import { isRecord } from './is-record'
|
|
21
22
|
import { swiftObjCPlatformFlags } from './swift-objc-platform'
|
|
22
23
|
import { IOS_SDK_HEADERS, IOS_SDK_OVERLAYS, IOS_SDK_TARGET } from './swift-objc-sdk'
|
|
23
24
|
import { clangImportNames, moduleMapTokens } from './swift-package'
|
|
25
|
+
import { objcProtocolsInSwiftSignatures, type SymbolGraph } from './swift-standin-emit'
|
|
24
26
|
import { swiftEnvironment } from './swift-toolchain'
|
|
25
|
-
import type { SymbolGraph } from './swift-standin-emit'
|
|
26
27
|
|
|
27
28
|
/** a module map and the headers it reaches: a framework's, or a library
|
|
28
29
|
* slice's headers directory. */
|
|
@@ -33,12 +34,17 @@ export interface ObjcSurface {
|
|
|
33
34
|
dependencies?: { module: string; headers: string }[]
|
|
34
35
|
/** clang `-fmodule-map-file` flags this import's modules need. */
|
|
35
36
|
moduleMapFlags?: readonly string[]
|
|
37
|
+
/** a mixed framework's swift interface, read over its own headers. */
|
|
38
|
+
interface?: string
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
export interface ObjcView {
|
|
39
42
|
graphs: SymbolGraph[]
|
|
40
|
-
/** external superclass conformances read from the same
|
|
43
|
+
/** external superclass conformances read from the same sdk. */
|
|
41
44
|
inheritedConformances?: ReadonlyMap<string, ReadonlySet<string>>
|
|
45
|
+
/** a mixed framework's objc protocol properties by symbol id: symbol
|
|
46
|
+
* graphs omit custom accessor selectors, which clang reads from the headers. */
|
|
47
|
+
protocolProperties?: Map<string, { getter: string; setter?: string }>
|
|
42
48
|
/** present for original implementations, read without repairing declarations. */
|
|
43
49
|
clangAST?: unknown
|
|
44
50
|
/** precise enum case and option ids → their header values. */
|
|
@@ -65,7 +71,7 @@ const NATIVE_GRAPH_INPUTS = {
|
|
|
65
71
|
compiler: 'Apple Swift version 6.4 (swiftlang-6.4.0.34.1 clang-2100.3.34.1)',
|
|
66
72
|
target: IOS_SDK_TARGET,
|
|
67
73
|
}
|
|
68
|
-
|
|
74
|
+
const NATIVE_GRAPH_ID = createHash('sha256')
|
|
69
75
|
.update(JSON.stringify(NATIVE_GRAPH_INPUTS))
|
|
70
76
|
.digest('hex')
|
|
71
77
|
|
|
@@ -169,7 +175,7 @@ function nativeGraphMismatches(read: {
|
|
|
169
175
|
]
|
|
170
176
|
}
|
|
171
177
|
|
|
172
|
-
function pinnedNativeSdk(): PinnedNativeSdk {
|
|
178
|
+
export function pinnedNativeSdk(): PinnedNativeSdk {
|
|
173
179
|
if (resolvedPinnedSdk) return resolvedPinnedSdk
|
|
174
180
|
let mismatches: string[] | undefined
|
|
175
181
|
for (const developerDir of developerDirs()) {
|
|
@@ -200,98 +206,6 @@ function pinnedNativeSdk(): PinnedNativeSdk {
|
|
|
200
206
|
throw new Error(`native declaration SDK ${NATIVE_GRAPH_SDK_VERSION} is not installed`)
|
|
201
207
|
}
|
|
202
208
|
|
|
203
|
-
/** true when this machine can extract against the pinned sdk. a mismatch or
|
|
204
|
-
* an older selected xcode is not usable. */
|
|
205
|
-
export function pinnedNativeSdkReady(): boolean {
|
|
206
|
-
try {
|
|
207
|
-
pinnedNativeSdk()
|
|
208
|
-
return true
|
|
209
|
-
} catch (error) {
|
|
210
|
-
if (error instanceof Error && error.message.startsWith('native declaration SDK'))
|
|
211
|
-
return false
|
|
212
|
-
throw error
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/** a mixed framework's swift overlay and underlying clang module load together. */
|
|
217
|
-
export function nativeInterfaceView(
|
|
218
|
-
surface: ObjcSurface,
|
|
219
|
-
frameworks: readonly string[],
|
|
220
|
-
work: string,
|
|
221
|
-
): ObjcView {
|
|
222
|
-
if (process.platform !== 'darwin')
|
|
223
|
-
throw new Error('mixed framework declarations require the pinned native iOS SDK')
|
|
224
|
-
const { sdkPath: sdk, compiler } = pinnedNativeSdk()
|
|
225
|
-
const toolchainBin = path.dirname(compiler)
|
|
226
|
-
const search = ['-sdk', sdk, ...frameworks.flatMap((dir) => ['-F', dir])]
|
|
227
|
-
const extract = (module: string, out: string): SymbolGraph[] => {
|
|
228
|
-
fs.mkdirSync(out, { recursive: true })
|
|
229
|
-
const run = spawnSync(
|
|
230
|
-
path.join(toolchainBin, 'swift-symbolgraph-extract'),
|
|
231
|
-
[
|
|
232
|
-
'-module-name',
|
|
233
|
-
module,
|
|
234
|
-
'-target',
|
|
235
|
-
IOS_SDK_TARGET,
|
|
236
|
-
...search,
|
|
237
|
-
// at public the graph hides underscored public names other public
|
|
238
|
-
// declarations use; the emitter keeps only public and open symbols
|
|
239
|
-
'-minimum-access-level',
|
|
240
|
-
'internal',
|
|
241
|
-
'-include-spi-symbols',
|
|
242
|
-
'-skip-synthesized-members',
|
|
243
|
-
'-omit-extension-block-symbols',
|
|
244
|
-
'-output-dir',
|
|
245
|
-
out,
|
|
246
|
-
],
|
|
247
|
-
{ encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 },
|
|
248
|
-
)
|
|
249
|
-
if (run.error) throw run.error
|
|
250
|
-
if (run.status !== 0)
|
|
251
|
-
throw new Error(
|
|
252
|
-
`native interface extraction ${run.signal ?? `exit ${run.status}`}: ${run.stderr.trim().slice(-4000)}`,
|
|
253
|
-
)
|
|
254
|
-
const graphs = fs
|
|
255
|
-
.readdirSync(out)
|
|
256
|
-
.filter((file) => file.endsWith('.symbols.json'))
|
|
257
|
-
.sort()
|
|
258
|
-
.map(
|
|
259
|
-
(file): SymbolGraph => JSON.parse(fs.readFileSync(path.join(out, file), 'utf8')),
|
|
260
|
-
)
|
|
261
|
-
if (graphs.length === 0)
|
|
262
|
-
throw new Error('native interface extraction returned no graphs')
|
|
263
|
-
return graphs
|
|
264
|
-
}
|
|
265
|
-
const graphs = extract(surface.module, path.join(work, 'native-graphs'))
|
|
266
|
-
const own = new Set(
|
|
267
|
-
graphs.flatMap((graph) => graph.symbols.map((symbol) => symbol.identifier.precise)),
|
|
268
|
-
)
|
|
269
|
-
const parents = new Map<string, Set<string>>()
|
|
270
|
-
for (const graph of graphs)
|
|
271
|
-
for (const edge of graph.relationships)
|
|
272
|
-
if (edge.kind === 'inheritsFrom' && !own.has(edge.target) && edge.targetFallback) {
|
|
273
|
-
const module = edge.targetFallback.split('.')[0]!
|
|
274
|
-
const ids = parents.get(module) ?? new Set<string>()
|
|
275
|
-
ids.add(edge.target)
|
|
276
|
-
parents.set(module, ids)
|
|
277
|
-
}
|
|
278
|
-
const inheritedConformances = new Map<string, Set<string>>()
|
|
279
|
-
for (const [module, ids] of parents)
|
|
280
|
-
for (const graph of extract(module, path.join(work, 'native-parents', module)))
|
|
281
|
-
for (const edge of graph.relationships)
|
|
282
|
-
if (edge.kind === 'conformsTo' && ids.has(edge.source)) {
|
|
283
|
-
const protocols = inheritedConformances.get(edge.source) ?? new Set<string>()
|
|
284
|
-
protocols.add(edge.target)
|
|
285
|
-
inheritedConformances.set(edge.source, protocols)
|
|
286
|
-
}
|
|
287
|
-
return {
|
|
288
|
-
graphs,
|
|
289
|
-
inheritedConformances,
|
|
290
|
-
values: enumValues(graphs, surface, true, toolchainBin, search, work),
|
|
291
|
-
imports: [],
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
209
|
// the opaque declarations a failed import asks for, by name.
|
|
296
210
|
type Missing = Map<string, 'class' | 'protocol' | 'struct' | 'macro'>
|
|
297
211
|
|
|
@@ -528,6 +442,7 @@ export function objcView(
|
|
|
528
442
|
cacheDir: string,
|
|
529
443
|
work: string,
|
|
530
444
|
original?: { flags: readonly string[]; target: string },
|
|
445
|
+
vendorFrameworks: readonly string[] = [],
|
|
531
446
|
): ObjcView {
|
|
532
447
|
if (!fs.existsSync(stdlib))
|
|
533
448
|
throw new Error(
|
|
@@ -565,6 +480,29 @@ export function objcView(
|
|
|
565
480
|
surface.modulemap,
|
|
566
481
|
path.join(frameworks, `${surface.module}.framework`, 'Modules', 'module.modulemap'),
|
|
567
482
|
)
|
|
483
|
+
// a mixed framework's swift overlay loads over the same learned headers.
|
|
484
|
+
// the intake reads CoreFoundation's headers textually, so a type the
|
|
485
|
+
// interface qualifies with CoreFoundation lives in CoreGraphics (CGSize,
|
|
486
|
+
// CGFloat) or Foundation.
|
|
487
|
+
if (surface.interface) {
|
|
488
|
+
const from = path.dirname(surface.interface)
|
|
489
|
+
const to = path.join(
|
|
490
|
+
frameworks,
|
|
491
|
+
`${surface.module}.framework`,
|
|
492
|
+
'Modules',
|
|
493
|
+
path.basename(from),
|
|
494
|
+
)
|
|
495
|
+
fs.mkdirSync(to, { recursive: true })
|
|
496
|
+
for (const name of fs.readdirSync(from))
|
|
497
|
+
if (name.endsWith('.swiftinterface'))
|
|
498
|
+
fs.writeFileSync(
|
|
499
|
+
path.join(to, name),
|
|
500
|
+
fs
|
|
501
|
+
.readFileSync(path.join(from, name), 'utf8')
|
|
502
|
+
.replace(/\bCoreFoundation\.(?=CG)/g, 'CoreGraphics.')
|
|
503
|
+
.replace(/\bCoreFoundation\.(?=\w)/g, 'Foundation.'),
|
|
504
|
+
)
|
|
505
|
+
}
|
|
568
506
|
} else {
|
|
569
507
|
fs.copyFileSync(surface.modulemap, path.join(headersDir, 'module.modulemap'))
|
|
570
508
|
}
|
|
@@ -622,6 +560,7 @@ export function objcView(
|
|
|
622
560
|
stubs,
|
|
623
561
|
'-I',
|
|
624
562
|
stubIncludes,
|
|
563
|
+
...vendorFrameworks.flatMap((dir) => ['-F', dir]),
|
|
625
564
|
]
|
|
626
565
|
const missing: Missing = new Map()
|
|
627
566
|
const stubbed = new Set<string>()
|
|
@@ -630,11 +569,12 @@ export function objcView(
|
|
|
630
569
|
const out = path.join(work, 'graphs')
|
|
631
570
|
// a framework the headers import and the sdk lacks: an empty framework
|
|
632
571
|
// module with the asked-for header, which reaches the opaque declarations.
|
|
633
|
-
|
|
572
|
+
// a module import names its framework whatever its case (zlib).
|
|
573
|
+
const stub = (include: string, module = false): boolean => {
|
|
634
574
|
if (stubbed.has(include)) return false
|
|
635
575
|
stubbed.add(include)
|
|
636
576
|
const slash = include.indexOf('/')
|
|
637
|
-
if (slash > 0 && /^[A-Z]/.test(include)) {
|
|
577
|
+
if (slash > 0 && (module || /^[A-Z]/.test(include))) {
|
|
638
578
|
const name = include.slice(0, slash)
|
|
639
579
|
const umbrella = `${name}/${name}.h`
|
|
640
580
|
if (
|
|
@@ -668,6 +608,31 @@ export function objcView(
|
|
|
668
608
|
}
|
|
669
609
|
return true
|
|
670
610
|
}
|
|
611
|
+
// an sdk framework the intake reads textually (CoreFoundation) still
|
|
612
|
+
// answers a module import, as a module that re-exports Foundation. a swift
|
|
613
|
+
// module the toolchain lacks (the standard library's _StringProcessing off
|
|
614
|
+
// a Mac) declares nothing: whatever it re-exported would answer qualified
|
|
615
|
+
// standard library names, since `Swift.Duration` also searches it.
|
|
616
|
+
const stubModule = (name: string, swift: boolean): boolean => {
|
|
617
|
+
const sdk = Object.hasOwn(
|
|
618
|
+
IOS_SDK_HEADERS,
|
|
619
|
+
`System/Library/Frameworks/${name}.framework/Headers/${name}.h`,
|
|
620
|
+
)
|
|
621
|
+
if (!sdk && !swift) return stub(`${name}/${name}.h`, true)
|
|
622
|
+
if (stubbed.has(name)) return false
|
|
623
|
+
stubbed.add(name)
|
|
624
|
+
const dir = path.join(stubIncludes, name)
|
|
625
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
626
|
+
fs.writeFileSync(
|
|
627
|
+
path.join(dir, 'PeachModule.h'),
|
|
628
|
+
sdk ? '#import <Foundation/Foundation.h>\n' : '',
|
|
629
|
+
)
|
|
630
|
+
fs.writeFileSync(
|
|
631
|
+
path.join(dir, 'module.modulemap'),
|
|
632
|
+
`module ${name} [system] {\n header "PeachModule.h"\n export *\n}\n`,
|
|
633
|
+
)
|
|
634
|
+
return true
|
|
635
|
+
}
|
|
671
636
|
// the opaque declarations, plus the sdk modules that own a named type.
|
|
672
637
|
const writeHeaders = () => {
|
|
673
638
|
if (missing.size > 0) {
|
|
@@ -726,8 +691,10 @@ export function objcView(
|
|
|
726
691
|
path.join(cacheDir, 'ios-module-cache'),
|
|
727
692
|
'-minimum-access-level',
|
|
728
693
|
// symbol graphs hide public underscored names at the public threshold.
|
|
729
|
-
// original clang headers remain the declaration boundary
|
|
730
|
-
|
|
694
|
+
// original clang headers remain the declaration boundary, and a swift
|
|
695
|
+
// overlay names its underscored and spi declarations.
|
|
696
|
+
original || surface.interface ? 'internal' : 'public',
|
|
697
|
+
...(surface.interface ? ['-include-spi-symbols'] : []),
|
|
731
698
|
'-skip-synthesized-members',
|
|
732
699
|
'-omit-extension-block-symbols',
|
|
733
700
|
'-output-dir',
|
|
@@ -766,9 +733,11 @@ export function objcView(
|
|
|
766
733
|
if (stub(found[1]!)) progress = true
|
|
767
734
|
continue
|
|
768
735
|
}
|
|
736
|
+
// clang's module import, or a swift interface's
|
|
769
737
|
const module = /^module '(\w+)' not found$/.exec(message!)
|
|
770
|
-
|
|
771
|
-
|
|
738
|
+
const swiftModule = /^no such module '(\w+)[\w.]*'$/.exec(message!)
|
|
739
|
+
if (module || swiftModule) {
|
|
740
|
+
if (stubModule((module ?? swiftModule)![1]!, !module)) progress = true
|
|
772
741
|
continue
|
|
773
742
|
}
|
|
774
743
|
const protocol =
|
|
@@ -815,11 +784,111 @@ export function objcView(
|
|
|
815
784
|
)
|
|
816
785
|
writeHeaders()
|
|
817
786
|
}
|
|
787
|
+
// a header-scoped declaration belongs to the module only when one of its
|
|
788
|
+
// own headers makes it. the intake's textual headers otherwise hand it
|
|
789
|
+
// clang's builtin typedefs (stddef's size_t), which an apple sdk keeps in
|
|
790
|
+
// their own builtin modules.
|
|
791
|
+
const ownHeaders = new Set(headerFiles(headersDir).map((name) => path.basename(name)))
|
|
818
792
|
const graphs = fs
|
|
819
793
|
.readdirSync(out)
|
|
820
794
|
.filter((name) => name.endsWith('.symbols.json'))
|
|
821
795
|
.sort()
|
|
822
|
-
.map((name): SymbolGraph =>
|
|
796
|
+
.map((name): SymbolGraph => {
|
|
797
|
+
const graph: SymbolGraph = JSON.parse(fs.readFileSync(path.join(out, name), 'utf8'))
|
|
798
|
+
return {
|
|
799
|
+
...graph,
|
|
800
|
+
symbols: graph.symbols.filter((symbol) => {
|
|
801
|
+
const header = /^c:([^@]+\.h)@/.exec(symbol.identifier.precise)?.[1]
|
|
802
|
+
return !header || ownHeaders.has(header)
|
|
803
|
+
}),
|
|
804
|
+
}
|
|
805
|
+
})
|
|
806
|
+
// a swift class whose superclass another module declares must not restate
|
|
807
|
+
// a conformance that superclass already brings, through its ancestors,
|
|
808
|
+
// categories, protocol parents or a swift overlay. the swift compiler
|
|
809
|
+
// answers from the same sdk: restating one is a redundant conformance, and
|
|
810
|
+
// an inherited unchecked Sendable asks to be restated as such.
|
|
811
|
+
const inheritedConformances = new Map<string, Set<string>>()
|
|
812
|
+
if (surface.interface) {
|
|
813
|
+
const own = new Set(
|
|
814
|
+
graphs.flatMap((graph) => graph.symbols.map((symbol) => symbol.identifier.precise)),
|
|
815
|
+
)
|
|
816
|
+
const superclasses = new Map<string, string>()
|
|
817
|
+
const subclasses = new Set<string>()
|
|
818
|
+
for (const graph of graphs)
|
|
819
|
+
for (const edge of graph.relationships)
|
|
820
|
+
if (
|
|
821
|
+
edge.kind === 'inheritsFrom' &&
|
|
822
|
+
!own.has(edge.target) &&
|
|
823
|
+
edge.targetFallback
|
|
824
|
+
) {
|
|
825
|
+
superclasses.set(edge.target, edge.targetFallback)
|
|
826
|
+
subclasses.add(edge.source)
|
|
827
|
+
}
|
|
828
|
+
const protocols = new Map<string, string>()
|
|
829
|
+
for (const graph of graphs)
|
|
830
|
+
for (const edge of graph.relationships)
|
|
831
|
+
if (
|
|
832
|
+
edge.kind === 'conformsTo' &&
|
|
833
|
+
subclasses.has(edge.source) &&
|
|
834
|
+
!own.has(edge.target) &&
|
|
835
|
+
edge.targetFallback
|
|
836
|
+
)
|
|
837
|
+
protocols.set(edge.target, edge.targetFallback)
|
|
838
|
+
const pairs = [...superclasses].flatMap((superclass) =>
|
|
839
|
+
[...protocols].map((protocol) => ({ superclass, protocol })),
|
|
840
|
+
)
|
|
841
|
+
if (pairs.length > 0) {
|
|
842
|
+
const probe = path.join(work, 'inherited-conformances.swift')
|
|
843
|
+
fs.writeFileSync(
|
|
844
|
+
probe,
|
|
845
|
+
[
|
|
846
|
+
...new Set(
|
|
847
|
+
[...superclasses.values(), ...protocols.values()].map(
|
|
848
|
+
(name) => `import ${name.split('.')[0]}`,
|
|
849
|
+
),
|
|
850
|
+
),
|
|
851
|
+
...pairs.map(
|
|
852
|
+
({ superclass, protocol }, index) =>
|
|
853
|
+
`class PeachConforms${index}: ${superclass[1]}, ${protocol[1]} {}`,
|
|
854
|
+
),
|
|
855
|
+
].join('\n'),
|
|
856
|
+
)
|
|
857
|
+
const run = spawnSync(
|
|
858
|
+
path.join(toolchainBin, 'swift-frontend'),
|
|
859
|
+
[
|
|
860
|
+
'-typecheck',
|
|
861
|
+
'-target',
|
|
862
|
+
IOS_SDK_TARGET,
|
|
863
|
+
...search,
|
|
864
|
+
...(surface.moduleMapFlags ?? []).flatMap((flag) => ['-Xcc', flag]),
|
|
865
|
+
'-module-cache-path',
|
|
866
|
+
path.join(cacheDir, 'ios-module-cache'),
|
|
867
|
+
probe,
|
|
868
|
+
],
|
|
869
|
+
{ encoding: 'utf8', env: swiftEnvironment() },
|
|
870
|
+
)
|
|
871
|
+
if (run.error) throw run.error
|
|
872
|
+
const unknown = /error: (?:no such module|cannot find type) .*/.exec(run.stderr)
|
|
873
|
+
if (unknown)
|
|
874
|
+
throw new Error(`superclass conformances do not typecheck: ${unknown[0]}`)
|
|
875
|
+
const inherit = (superclass: string, protocol: string) => {
|
|
876
|
+
const inherited = inheritedConformances.get(superclass) ?? new Set<string>()
|
|
877
|
+
inherited.add(protocol)
|
|
878
|
+
inheritedConformances.set(superclass, inherited)
|
|
879
|
+
}
|
|
880
|
+
for (const match of run.stderr.matchAll(
|
|
881
|
+
/error: redundant conformance of 'PeachConforms(\d+)'/g,
|
|
882
|
+
)) {
|
|
883
|
+
const { superclass, protocol } = pairs[Number(match[1])]!
|
|
884
|
+
inherit(superclass[0], protocol[0])
|
|
885
|
+
}
|
|
886
|
+
for (const match of run.stderr.matchAll(
|
|
887
|
+
/warning: class 'PeachConforms(\d+)' must restate inherited '@unchecked Sendable'/g,
|
|
888
|
+
))
|
|
889
|
+
inherit(pairs[Number(match[1])]!.superclass[0], 's:s8SendableP')
|
|
890
|
+
}
|
|
891
|
+
}
|
|
823
892
|
const imports = new Set<string>(['Foundation', 'UIKit'])
|
|
824
893
|
for (const text of originals.values())
|
|
825
894
|
for (const name of clangImportNames(text)) imports.add(name)
|
|
@@ -827,6 +896,19 @@ export function objcView(
|
|
|
827
896
|
imports.delete(surface.module)
|
|
828
897
|
return {
|
|
829
898
|
graphs,
|
|
899
|
+
...(surface.interface
|
|
900
|
+
? {
|
|
901
|
+
inheritedConformances,
|
|
902
|
+
protocolProperties: protocolProperties(
|
|
903
|
+
surface,
|
|
904
|
+
headersDir,
|
|
905
|
+
graphs,
|
|
906
|
+
toolchainBin,
|
|
907
|
+
search,
|
|
908
|
+
work,
|
|
909
|
+
),
|
|
910
|
+
}
|
|
911
|
+
: {}),
|
|
830
912
|
...(original
|
|
831
913
|
? {
|
|
832
914
|
clangAST: objcDeclarationAST(
|
|
@@ -845,6 +927,126 @@ export function objcView(
|
|
|
845
927
|
}
|
|
846
928
|
}
|
|
847
929
|
|
|
930
|
+
/** the swift search flags as clang spells them. */
|
|
931
|
+
function clangSearchFlags(search: readonly string[]): string[] {
|
|
932
|
+
const flags: string[] = []
|
|
933
|
+
for (let index = 0; index < search.length; index += 2) {
|
|
934
|
+
const [flag, value] = [search[index]!, search[index + 1]!]
|
|
935
|
+
// the swift resource directory contains swift overlays, not clang builtins.
|
|
936
|
+
if (flag === '-resource-dir') continue
|
|
937
|
+
flags.push(flag === '-sdk' ? '-isysroot' : flag, value)
|
|
938
|
+
}
|
|
939
|
+
return flags
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
// clang reads the custom accessors of each objc protocol a swift signature
|
|
943
|
+
// names from the same learned headers the graphs came from.
|
|
944
|
+
function protocolProperties(
|
|
945
|
+
surface: ObjcSurface,
|
|
946
|
+
headersDir: string,
|
|
947
|
+
graphs: SymbolGraph[],
|
|
948
|
+
toolchainBin: string,
|
|
949
|
+
search: string[],
|
|
950
|
+
work: string,
|
|
951
|
+
): Map<string, { getter: string; setter?: string }> {
|
|
952
|
+
const properties = new Map<string, { getter: string; setter?: string }>()
|
|
953
|
+
const protocols = objcProtocolsInSwiftSignatures(graphs)
|
|
954
|
+
if (protocols.size === 0) return properties
|
|
955
|
+
const headers = headerFiles(headersDir).map((name) => ({
|
|
956
|
+
file: path.join(headersDir, name),
|
|
957
|
+
text: fs.readFileSync(path.join(headersDir, name), 'utf8'),
|
|
958
|
+
}))
|
|
959
|
+
const flags = clangSearchFlags(search)
|
|
960
|
+
for (const id of protocols) {
|
|
961
|
+
const name = /^c:objc\(pl\)(\w+)$/.exec(id)?.[1]
|
|
962
|
+
if (!name) throw new Error(`unknown Objective-C protocol identity ${id}`)
|
|
963
|
+
const pattern = new RegExp(`@protocol\\s+${name}\\b(?!\\s*;)`)
|
|
964
|
+
const candidates = headers.filter((header) => pattern.test(header.text))
|
|
965
|
+
if (candidates.length === 0)
|
|
966
|
+
throw new Error(`its headers have no definition of Objective-C protocol ${name}`)
|
|
967
|
+
const probe = path.join(work, 'objc-protocol-properties.m')
|
|
968
|
+
fs.writeFileSync(
|
|
969
|
+
probe,
|
|
970
|
+
// the module's own roots first: a defining header may rely on the
|
|
971
|
+
// declarations its umbrella imports before it, as NS_ENUM does
|
|
972
|
+
[
|
|
973
|
+
...moduleMapHeaders(surface.modulemap).map((file) => path.join(headersDir, file)),
|
|
974
|
+
...candidates.map(({ file }) => file),
|
|
975
|
+
]
|
|
976
|
+
.map((file) => `#import ${JSON.stringify(file)}\n`)
|
|
977
|
+
.join(''),
|
|
978
|
+
)
|
|
979
|
+
const run = spawnSync(
|
|
980
|
+
path.join(toolchainBin, 'clang'),
|
|
981
|
+
[
|
|
982
|
+
'-x',
|
|
983
|
+
'objective-c',
|
|
984
|
+
'-fobjc-arc',
|
|
985
|
+
'-fblocks',
|
|
986
|
+
'-fmodules',
|
|
987
|
+
`-fmodule-name=${surface.module}`,
|
|
988
|
+
'-fsyntax-only',
|
|
989
|
+
'-target',
|
|
990
|
+
IOS_SDK_TARGET,
|
|
991
|
+
...flags,
|
|
992
|
+
...(surface.moduleMapFlags ?? []),
|
|
993
|
+
'-I',
|
|
994
|
+
headersDir,
|
|
995
|
+
'-Xclang',
|
|
996
|
+
'-ast-dump-all=json',
|
|
997
|
+
'-Xclang',
|
|
998
|
+
'-ast-dump-filter',
|
|
999
|
+
'-Xclang',
|
|
1000
|
+
name,
|
|
1001
|
+
probe,
|
|
1002
|
+
],
|
|
1003
|
+
{
|
|
1004
|
+
encoding: 'utf8',
|
|
1005
|
+
env: swiftEnvironment(),
|
|
1006
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
1007
|
+
},
|
|
1008
|
+
)
|
|
1009
|
+
if (run.error) throw run.error
|
|
1010
|
+
if (run.status !== 0)
|
|
1011
|
+
throw new Error(`Objective-C protocol ${name} does not parse: ${run.stderr.trim()}`)
|
|
1012
|
+
let found = false
|
|
1013
|
+
for (const chunk of run.stdout.split(/\n(?=\{\n)/).filter((part) => part.trim())) {
|
|
1014
|
+
const declaration: unknown = JSON.parse(chunk)
|
|
1015
|
+
if (
|
|
1016
|
+
!isRecord(declaration) ||
|
|
1017
|
+
declaration.kind !== 'ObjCProtocolDecl' ||
|
|
1018
|
+
declaration.name !== name ||
|
|
1019
|
+
!Array.isArray(declaration.inner)
|
|
1020
|
+
)
|
|
1021
|
+
continue
|
|
1022
|
+
found = true
|
|
1023
|
+
for (const child of declaration.inner) {
|
|
1024
|
+
if (
|
|
1025
|
+
!isRecord(child) ||
|
|
1026
|
+
child.kind !== 'ObjCPropertyDecl' ||
|
|
1027
|
+
typeof child.name !== 'string'
|
|
1028
|
+
)
|
|
1029
|
+
continue
|
|
1030
|
+
const getter =
|
|
1031
|
+
isRecord(child.getter) && typeof child.getter.name === 'string'
|
|
1032
|
+
? child.getter.name
|
|
1033
|
+
: child.name
|
|
1034
|
+
const setter =
|
|
1035
|
+
isRecord(child.setter) && typeof child.setter.name === 'string'
|
|
1036
|
+
? child.setter.name
|
|
1037
|
+
: `set${child.name[0]?.toUpperCase() ?? ''}${child.name.slice(1)}:`
|
|
1038
|
+
properties.set(`${id}(py)${child.name}`, {
|
|
1039
|
+
getter,
|
|
1040
|
+
...(child.readonly === true ? {} : { setter }),
|
|
1041
|
+
})
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
if (!found)
|
|
1045
|
+
throw new Error(`clang found no definition of Objective-C protocol ${name}`)
|
|
1046
|
+
}
|
|
1047
|
+
return properties
|
|
1048
|
+
}
|
|
1049
|
+
|
|
848
1050
|
function objcDeclarationAST(
|
|
849
1051
|
surface: ObjcSurface,
|
|
850
1052
|
framework: boolean,
|
|
@@ -864,13 +1066,7 @@ function objcDeclarationAST(
|
|
|
864
1066
|
)
|
|
865
1067
|
.join(''),
|
|
866
1068
|
)
|
|
867
|
-
const flags
|
|
868
|
-
for (let index = 0; index < search.length; index += 2) {
|
|
869
|
-
const [flag, value] = [search[index]!, search[index + 1]!]
|
|
870
|
-
// the swift resource directory contains swift overlays, not clang builtins.
|
|
871
|
-
if (flag === '-resource-dir') continue
|
|
872
|
-
flags.push(flag === '-sdk' ? '-isysroot' : flag, value)
|
|
873
|
-
}
|
|
1069
|
+
const flags = clangSearchFlags(search)
|
|
874
1070
|
const args = [
|
|
875
1071
|
'-x',
|
|
876
1072
|
'objective-c',
|
|
@@ -894,7 +1090,11 @@ function objcDeclarationAST(
|
|
|
894
1090
|
...(filter ? ['-Xclang', '-ast-dump-filter', '-Xclang', filter] : []),
|
|
895
1091
|
probe,
|
|
896
1092
|
],
|
|
897
|
-
{
|
|
1093
|
+
{
|
|
1094
|
+
encoding: 'utf8',
|
|
1095
|
+
env: swiftEnvironment(),
|
|
1096
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
1097
|
+
},
|
|
898
1098
|
)
|
|
899
1099
|
if (run.error) throw run.error
|
|
900
1100
|
if (run.status !== 0)
|
|
@@ -1015,7 +1215,11 @@ function enumValues(
|
|
|
1015
1215
|
'-ast-dump=json',
|
|
1016
1216
|
probe,
|
|
1017
1217
|
],
|
|
1018
|
-
{
|
|
1218
|
+
{
|
|
1219
|
+
encoding: 'utf8',
|
|
1220
|
+
env: swiftEnvironment(),
|
|
1221
|
+
maxBuffer: 1024 * 1024 * 1024,
|
|
1222
|
+
},
|
|
1019
1223
|
)
|
|
1020
1224
|
if (run.status !== 0)
|
|
1021
1225
|
throw new Error(
|
|
@@ -16,8 +16,8 @@ import fs from 'node:fs'
|
|
|
16
16
|
import os from 'node:os'
|
|
17
17
|
import path from 'node:path'
|
|
18
18
|
import { promisify } from 'node:util'
|
|
19
|
-
import { cacheDir as peachCacheDir
|
|
20
|
-
import { ensureSwiftToolchain,
|
|
19
|
+
import { cacheDir as peachCacheDir } from './home-paths'
|
|
20
|
+
import { ensureSwiftToolchain, swiftModuleCompiler } from './swift-distribution'
|
|
21
21
|
import lock from './swift-distribution.lock.json' with { type: 'json' }
|
|
22
22
|
import {
|
|
23
23
|
isSwiftNativeTranslationUnit,
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
import {
|
|
28
28
|
privateSwiftDistributionRoot,
|
|
29
29
|
swiftEnvironment,
|
|
30
|
+
swiftPackageCacheOptions,
|
|
30
31
|
swiftToolchainBin,
|
|
31
32
|
} from './swift-toolchain'
|
|
32
33
|
|
|
@@ -167,7 +168,7 @@ const string = (value: Json | undefined): string | undefined =>
|
|
|
167
168
|
function swiftCommand(): string {
|
|
168
169
|
const privateRoot = privateSwiftDistributionRoot()
|
|
169
170
|
if (privateRoot)
|
|
170
|
-
return path.join(
|
|
171
|
+
return path.join(swiftModuleCompiler(privateRoot).toolchainBin, 'swift')
|
|
171
172
|
return path.join(swiftToolchainBin(lock.release), 'swift')
|
|
172
173
|
}
|
|
173
174
|
|
package/src/swift-package.ts
CHANGED
|
@@ -282,10 +282,17 @@ export function swiftNativeSupportFiles(
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
/** the modules a c-family source imports framework-style or with @import. */
|
|
285
|
-
export function clangImportNames(
|
|
285
|
+
export function clangImportNames(
|
|
286
|
+
text: string,
|
|
287
|
+
isLocalHeader?: (header: string) => boolean,
|
|
288
|
+
): string[] {
|
|
286
289
|
return [
|
|
287
|
-
...text.matchAll(
|
|
288
|
-
|
|
290
|
+
...text.matchAll(
|
|
291
|
+
/^\s*(?:#\s*(?:import|include)\s*<((\w+)\/[^>]+)>|@import\s+(\w+))/gm,
|
|
292
|
+
),
|
|
293
|
+
].flatMap((match) =>
|
|
294
|
+
match[1] && isLocalHeader?.(match[1]) ? [] : [(match[2] ?? match[3])!],
|
|
295
|
+
)
|
|
289
296
|
}
|
|
290
297
|
|
|
291
298
|
/**
|
package/src/swift-root-lock.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
rmSync,
|
|
14
14
|
writeFileSync,
|
|
15
15
|
} from 'node:fs'
|
|
16
|
+
import { homedir } from 'node:os'
|
|
16
17
|
import path from 'node:path'
|
|
17
18
|
import { rnxHomeDir } from './home-paths'
|
|
18
19
|
import { terminateProcessGroup } from './process-group'
|
|
@@ -152,6 +153,16 @@ export interface SwiftRootLease {
|
|
|
152
153
|
register(child: ChildProcess): void
|
|
153
154
|
}
|
|
154
155
|
|
|
156
|
+
/** CocoaPods keeps one download cache per user and rewrites a pod's cache
|
|
157
|
+
* entry with rsync --delete, so two installs fetching the same pod tear each
|
|
158
|
+
* other's tree. installs on one Mac take turns on that cache. */
|
|
159
|
+
export function withCocoaPodsCacheLock<T>(work: () => Promise<T>): Promise<T> {
|
|
160
|
+
return withSwiftRootLock(
|
|
161
|
+
process.env.CP_CACHE_DIR || path.join(homedir(), 'Library/Caches/CocoaPods'),
|
|
162
|
+
work,
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
155
166
|
/** runs `work` as the only process using a swift build root. the in-process
|
|
156
167
|
* queue orders one process's requests; two processes sharing a root each
|
|
157
168
|
* rewrite its sources and manifest, and swiftpm's own build lock only orders
|
package/src/swift-shared-sdk.ts
CHANGED
|
@@ -2,8 +2,7 @@ import { execFileSync } from 'node:child_process'
|
|
|
2
2
|
import { createHash } from 'node:crypto'
|
|
3
3
|
import fs, { readdirSync, readFileSync } from 'node:fs'
|
|
4
4
|
import path from 'node:path'
|
|
5
|
-
import { swiftCacheDir } from './
|
|
6
|
-
import { swiftEnvironment, swiftSdkOptions } from './swift-toolchain'
|
|
5
|
+
import { swiftCacheDir, swiftEnvironment, swiftSdkOptions } from './swift-toolchain'
|
|
7
6
|
|
|
8
7
|
// records targets share the same native declarations as original c units.
|
|
9
8
|
// storage overlays carry wasm scalar identities without changing wasi libc abi.
|
|
@@ -254,7 +253,7 @@ export function swiftSharedSdkViewOptions(
|
|
|
254
253
|
.map((entry) => path.join(entry.parentPath, entry.name))
|
|
255
254
|
.sort()
|
|
256
255
|
const key = JSON.stringify([
|
|
257
|
-
'
|
|
256
|
+
'v11',
|
|
258
257
|
toolchainBin,
|
|
259
258
|
sdk,
|
|
260
259
|
frameworks,
|
|
@@ -299,13 +298,15 @@ export function swiftSharedSdkViewOptions(
|
|
|
299
298
|
// directory a second home for the same clang modules. mirror the whole sysroot as
|
|
300
299
|
// real directories so ".." always stays in the view. the shared frameworks replace
|
|
301
300
|
// the bundle's, and the shared MacTypes.h replaces the bundle's, which wins the
|
|
302
|
-
// include search and predates the Fixed family the frameworks rely on.
|
|
303
|
-
|
|
301
|
+
// include search and predates the Fixed family the frameworks rely on. the shared
|
|
302
|
+
// net/if.h replaces the bundle's for the same reason: the bundle's stub lacks the
|
|
303
|
+
// IFF_* flags and if_indextoname that native packages compile against.
|
|
304
|
+
const overrides = new Map<string, string>([
|
|
304
305
|
[path.join(sysroot, 'darwin/System/Library/Frameworks'), frameworks],
|
|
305
|
-
[
|
|
306
|
-
path.join(sysroot, 'darwin/usr/include
|
|
307
|
-
path.join(swiftSharedSdkRoot(moduleRoot, distribution), 'usr/include
|
|
308
|
-
],
|
|
306
|
+
...['MacTypes.h', 'net/if.h'].map((header): [string, string] => [
|
|
307
|
+
path.join(sysroot, 'darwin/usr/include', header),
|
|
308
|
+
path.join(swiftSharedSdkRoot(moduleRoot, distribution), 'usr/include', header),
|
|
309
|
+
]),
|
|
309
310
|
])
|
|
310
311
|
// preserve bundle-only support headers while taking the shared darwin
|
|
311
312
|
// overlays from the same owner as the framework declarations.
|