peachsim 0.1.1674 → 0.1.1684
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/control.ts +13 -1
- package/cli/commands/coverage-swift.ts +83 -27
- package/cli/commands/coverage.ts +219 -20
- package/cli/commands/detect.ts +10 -6
- package/cli/commands/inspect/core.ts +2 -0
- package/cli/commands/inspect/wait-ready.ts +7 -0
- package/cli/outbound-endpoints.ts +12 -0
- package/detox/index.ts +11 -1
- package/detox/jest-environment.cjs +14 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +3274 -1663
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +6 -4
- package/dist-lib/detox/jest-environment.cjs +14 -0
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +2407 -1126
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +2879 -1598
- package/dist-lib/host/fetch-proxy-handler.cjs +18 -5
- 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 +1904 -741
- 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 +6215 -4283
- package/dist-lib/native-app-identity-project.cjs +31 -6
- package/dist-lib/native-app-identity-project.mjs +31 -6
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +24 -23
- package/dist-lib/public-origins-lib-static.json +1 -1
- package/dist-lib/public-origins-lib.json +134 -78
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +2 -2
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +2 -1
- package/dist-lib/sdk.mjs +2 -1
- package/dist-lib/skills.cjs +3570 -2160
- package/dist-lib/swift-compile.cjs +473 -351
- package/dist-lib/swift-compile.mjs +471 -349
- package/dist-lib/swift-package.cjs +36 -6
- package/dist-lib/swift-package.mjs +35 -6
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +26 -11
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +2418 -1132
- package/dist-lib/vite.cjs +1907 -766
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/clipboardContract.d.ts +9 -1
- package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +11 -3
- package/dist-types/packages/peach-engine/src/webview-automation-host.d.ts +6 -0
- package/dist-types/packages/peach-globals/src/clipboardBridgeContract.d.ts +2 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +51 -2
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +21 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFComposeAssistantViewController.h +29 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeControllerDeferredAction.h +14 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeViewController.h +162 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailDraft.h +24 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController+UPI.h +31 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController.h +169 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MessageUI.h +13 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Modules/module.modulemap +11 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +10 -0
- package/sdk/ios/usr/include/arm/param.h +151 -0
- package/sdk/ios/usr/include/dispatch/dispatch.h +3 -0
- package/sdk/ios/usr/include/dlfcn.h +1 -2
- package/sdk/ios/usr/include/machine/param.h +42 -0
- package/sdk/ios/usr/include/net/if.h +1 -2
- package/sdk/ios/usr/include/peach/pthread.h +4 -4
- package/sdk/ios/usr/include/pthread/qos.h +304 -0
- package/sdk/ios/usr/include/sys/_types/_fd_clr.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_copy.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_def.h +121 -0
- package/sdk/ios/usr/include/sys/_types/_fd_isset.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_set.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_setsize.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_zero.h +31 -0
- package/sdk/ios/usr/include/sys/cdefs.h +3 -0
- package/sdk/ios/usr/include/sys/param.h +235 -0
- package/sdk/ios/usr/include/sys/proc.h +1 -0
- package/sdk/ios/usr/include/sys/qos.h +151 -12
- package/sdk/ios/wasm/include/__typedef_sigset_t.h +7 -0
- package/sdk/ios/wasm/include/fcntl.h +11 -0
- package/sdk/ios/wasm/include/mach/machine/boolean.h +2 -0
- package/sdk/ios/wasm/include/mach/machine/exception.h +5 -0
- package/sdk/ios/wasm/include/mach/machine/kern_return.h +2 -0
- package/sdk/ios/wasm/include/mach/machine/processor_info.h +2 -0
- package/sdk/ios/wasm/include/mach/machine/rpc.h +2 -0
- package/sdk/ios/wasm/include/mach/machine/thread_state.h +3 -0
- package/sdk/ios/wasm/include/mach/machine/thread_status.h +3 -0
- package/sdk/ios/wasm/include/mach/machine/vm_param.h +3 -0
- package/sdk/ios/wasm/include/mach/machine/vm_types.h +18 -0
- package/sdk/ios/wasm/include/machine/_types.h +153 -0
- package/sdk/ios/wasm/include/machine/endian.h +2 -0
- package/sdk/ios/wasm/include/machine/limits.h +2 -0
- package/sdk/ios/wasm/include/machine/types.h +30 -0
- package/sdk/ios/wasm/include/poll.h +8 -0
- package/sdk/ios/wasm/include/pthread.h +50 -0
- package/sdk/ios/wasm/include/signal.h +72 -0
- package/sdk/ios/wasm/include/stdlib.h +3 -0
- package/sdk/ios/wasm/include/string.h +10 -0
- package/sdk/ios/wasm/include/sys/_pthread/_pthread_attr_t.h +7 -0
- package/sdk/ios/wasm/include/sys/_pthread/_pthread_t.h +7 -0
- package/sdk/ios/wasm/include/sys/mman.h +122 -0
- package/sdk/ios/wasm/include/sys/select.h +37 -0
- package/sdk/ios/wasm/include/sys/signal.h +259 -0
- package/sdk/ios/wasm/include/sys/socket.h +8 -0
- package/sdk/ios/wasm/include/sys/types.h +14 -0
- package/sdk/ios/wasm/include/sys/ucontext.h +1 -0
- package/sdk/ios/wasm/include/sys/uio.h +11 -0
- package/sdk/ios/wasm/include/sys/wait.h +89 -0
- package/sdk/ios/wasm/include/time.h +8 -0
- package/sdk/ios/wasm/include/unistd.h +17 -0
- package/src/bridge-contract.ts +2 -0
- package/src/chromium-admission.ts +10 -5
- package/src/device-catalog.ts +4 -4
- package/src/host/fetch-proxy-handler.ts +20 -0
- package/src/metro-plugin.ts +5 -2
- package/src/nitro-adapter.lock.json +6 -6
- package/src/nitro-compile.ts +63 -2
- package/src/numbered-lock.ts +72 -0
- package/src/react-native-coverage/capability-reference-resolution.ts +62 -5
- package/src/react-native-coverage/capability-source-references.ts +50 -13
- package/src/react-native-coverage/native-source-credit.ts +126 -0
- package/src/react-native-coverage/native-source-ranges-file.ts +38 -0
- package/src/react-native-coverage/native-surface.ts +49 -0
- package/src/react-native-coverage/verified-reach.ts +22 -2
- package/src/runtime-assets.ts +17 -0
- package/src/swift-compile.ts +84 -48
- package/src/swift-coverage/indexing.ts +17 -1
- package/src/swift-coverage/sdk.ts +71 -0
- package/src/swift-coverage/source.ts +74 -2
- package/src/swift-coverage/types.ts +6 -0
- package/src/swift-distribution.lock.json +12 -12
- package/src/swift-host.ts +133 -14
- package/src/swift-objc-compile.ts +6 -21
- package/src/swift-objc-metadata.ts +2 -8
- package/src/swift-objc-platform.ts +53 -0
- package/src/swift-objc-standin.ts +45 -1
- package/src/swift-package-manifest.ts +48 -3
- package/src/swift-package.ts +59 -9
- package/src/swift-packages.ts +157 -44
- package/src/swift-source-pods.ts +288 -0
- package/src/swift-toolchain.ts +32 -10
- package/src/vite-plugin-one.ts +5 -4
- package/src/worker-system-chunks.ts +7 -1
- package/src/xcode-project.ts +40 -11
|
@@ -17,6 +17,7 @@ import { execFileSync, spawnSync } from 'node:child_process'
|
|
|
17
17
|
import { createHash } from 'node:crypto'
|
|
18
18
|
import fs from 'node:fs'
|
|
19
19
|
import path from 'node:path'
|
|
20
|
+
import { swiftObjCPlatformFlags } from './swift-objc-platform'
|
|
20
21
|
import { IOS_SDK_HEADERS, IOS_SDK_OVERLAYS, IOS_SDK_TARGET } from './swift-objc-sdk'
|
|
21
22
|
import { swiftEnvironment } from './swift-toolchain'
|
|
22
23
|
import type { SymbolGraph } from './swift-standin-emit'
|
|
@@ -47,7 +48,11 @@ export const NATIVE_GRAPH_SDK_VERSION = '27.1'
|
|
|
47
48
|
|
|
48
49
|
/** the installed libc's emulated surfaces: its signal.h is an #error without them,
|
|
49
50
|
* so every clang that builds original c or objective-c for wasm passes them. */
|
|
50
|
-
export const WASI_EMULATION = [
|
|
51
|
+
export const WASI_EMULATION = [
|
|
52
|
+
'_WASI_EMULATED_SIGNAL',
|
|
53
|
+
'_WASI_EMULATED_MMAN',
|
|
54
|
+
'_WASI_EMULATED_PROCESS_CLOCKS',
|
|
55
|
+
]
|
|
51
56
|
export const WASI_EMULATION_FLAGS = WASI_EMULATION.map((name) => `-D${name}`)
|
|
52
57
|
|
|
53
58
|
const NATIVE_GRAPH_INPUTS = {
|
|
@@ -185,6 +190,45 @@ export function materializeObjcSdk(cacheDir: string): string {
|
|
|
185
190
|
return sdk
|
|
186
191
|
}
|
|
187
192
|
|
|
193
|
+
/** the libc intake of every original c and objective-c unit over the sdk at
|
|
194
|
+
* `headers`: the iOS platform predefines for its deployment minimum, the
|
|
195
|
+
* installed libc's emulated surfaces that every app links, the sdk
|
|
196
|
+
* frameworks, the darwin extension headers in front of the installed libc,
|
|
197
|
+
* and the installed libc and objc runtime headers owning the target abi. */
|
|
198
|
+
export function objcSdkIntakeFlags(
|
|
199
|
+
headers: string,
|
|
200
|
+
toolchainBin: string,
|
|
201
|
+
minimum: number,
|
|
202
|
+
): string[] {
|
|
203
|
+
return [
|
|
204
|
+
...swiftObjCPlatformFlags(toolchainBin, minimum),
|
|
205
|
+
// AvailabilityInternal.h derives this through __is_target_os(ios), which
|
|
206
|
+
// is false for wasm32.
|
|
207
|
+
`-D__IPHONE_OS_VERSION_MIN_REQUIRED=${minimum}`,
|
|
208
|
+
// apple's build setting for a 32-bit target to keep NSInteger and
|
|
209
|
+
// NSUInteger long, the nominal types they have on arm64.
|
|
210
|
+
'-DNS_BUILD_32_LIKE_64=1',
|
|
211
|
+
// the installed libc's default feature set otherwise defines
|
|
212
|
+
// _XOPEN_SOURCE, which darwin's sys/cdefs.h turns into a strict posix
|
|
213
|
+
// level; iOS compiles at darwin's full level with neither defined.
|
|
214
|
+
'-D_BSD_SOURCE',
|
|
215
|
+
...WASI_EMULATION_FLAGS,
|
|
216
|
+
'-iframework',
|
|
217
|
+
path.join(headers, 'System/Library/Frameworks'),
|
|
218
|
+
'-isystem',
|
|
219
|
+
path.join(headers, 'wasm/include'),
|
|
220
|
+
'-idirafter',
|
|
221
|
+
path.join(headers, 'usr/include'),
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** an IPHONEOS_DEPLOYMENT_TARGET as clang's version number (16.4 is 160400). */
|
|
226
|
+
export function iosDeploymentMinimum(version: string | null): number | undefined {
|
|
227
|
+
const parts = /^(\d{1,2})(?:\.(\d{1,2}))?(?:\.(\d{1,2}))?$/.exec(version ?? '')
|
|
228
|
+
if (!parts) return undefined
|
|
229
|
+
return Number(parts[1]) * 10_000 + Number(parts[2] ?? 0) * 100 + Number(parts[3] ?? 0)
|
|
230
|
+
}
|
|
231
|
+
|
|
188
232
|
const headerFiles = (dir: string): string[] =>
|
|
189
233
|
fs
|
|
190
234
|
.readdirSync(dir, { recursive: true, encoding: 'utf8' })
|
|
@@ -49,6 +49,9 @@ export interface SwiftManifestTarget {
|
|
|
49
49
|
mainActorIsolation: boolean
|
|
50
50
|
defines: SwiftManifestSetting[]
|
|
51
51
|
libraries: SwiftManifestSetting[]
|
|
52
|
+
experimentalFeatures: SwiftManifestSetting[]
|
|
53
|
+
upcomingFeatures: SwiftManifestSetting[]
|
|
54
|
+
swiftFlags: { flags: string[]; configuration: 'debug' | 'release' | null }[]
|
|
52
55
|
nativeSettings: {
|
|
53
56
|
tool: 'c' | 'cxx'
|
|
54
57
|
flags: string[]
|
|
@@ -298,6 +301,9 @@ export function swiftPackageManifest(dir: string): SwiftPackageManifest {
|
|
|
298
301
|
let mainActorIsolation = false
|
|
299
302
|
const defines: SwiftManifestSetting[] = []
|
|
300
303
|
const libraries: SwiftManifestSetting[] = []
|
|
304
|
+
const experimentalFeatures: SwiftManifestSetting[] = []
|
|
305
|
+
const upcomingFeatures: SwiftManifestSetting[] = []
|
|
306
|
+
const swiftFlags: SwiftManifestTarget['swiftFlags'] = []
|
|
301
307
|
const nativeSettings: SwiftManifestTarget['nativeSettings'] = []
|
|
302
308
|
const unsupportedSwiftSettings: string[] = []
|
|
303
309
|
for (const [tool, standard] of [
|
|
@@ -312,6 +318,12 @@ export function swiftPackageManifest(dir: string): SwiftPackageManifest {
|
|
|
312
318
|
const settingKind = record(rawKind)
|
|
313
319
|
if (tool === 'swift') {
|
|
314
320
|
const kinds = Object.keys(settingKind)
|
|
321
|
+
// a feature is a name with an optional =value (StrictConcurrency=complete).
|
|
322
|
+
const feature = (kind: string) =>
|
|
323
|
+
/^[A-Za-z_][A-Za-z0-9_]*(?:=[A-Za-z_][A-Za-z0-9_.-]*)?$/.test(
|
|
324
|
+
string(record(settingKind[kind])._0) ?? '',
|
|
325
|
+
)
|
|
326
|
+
const unsafe = record(settingKind.unsafeFlags)._0
|
|
315
327
|
const supported =
|
|
316
328
|
kinds.length === 1 &&
|
|
317
329
|
((kinds[0] === 'define' &&
|
|
@@ -324,7 +336,13 @@ export function swiftPackageManifest(dir: string): SwiftPackageManifest {
|
|
|
324
336
|
Object.keys(record(condition)).length === 0 &&
|
|
325
337
|
['MainActor', 'nonisolated'].includes(
|
|
326
338
|
string(record(settingKind.defaultIsolation)._0) ?? '',
|
|
327
|
-
))
|
|
339
|
+
)) ||
|
|
340
|
+
(kinds[0] === 'enableExperimentalFeature' &&
|
|
341
|
+
feature('enableExperimentalFeature')) ||
|
|
342
|
+
(kinds[0] === 'enableUpcomingFeature' && feature('enableUpcomingFeature')) ||
|
|
343
|
+
(kinds[0] === 'unsafeFlags' &&
|
|
344
|
+
Array.isArray(unsafe) &&
|
|
345
|
+
unsafe.every((flag) => typeof flag === 'string')))
|
|
328
346
|
if (!supported)
|
|
329
347
|
unsupportedSwiftSettings.push(JSON.stringify({ kind: rawKind, condition }))
|
|
330
348
|
}
|
|
@@ -373,6 +391,27 @@ export function swiftPackageManifest(dir: string): SwiftPackageManifest {
|
|
|
373
391
|
configuration: config === 'debug' || config === 'release' ? config : null,
|
|
374
392
|
})
|
|
375
393
|
}
|
|
394
|
+
// experimental and upcoming features and raw swift flags ride the same
|
|
395
|
+
// conditions a define does; a target that needs BuiltinModule or library
|
|
396
|
+
// evolution compiles with it exactly as swiftpm builds it.
|
|
397
|
+
if (string(tool) === 'swift' && linksOnIOS(condition, traits)) {
|
|
398
|
+
const config = string(record(condition).config)
|
|
399
|
+
const configuration = config === 'debug' || config === 'release' ? config : null
|
|
400
|
+
for (const [kind, into] of [
|
|
401
|
+
['enableExperimentalFeature', experimentalFeatures],
|
|
402
|
+
['enableUpcomingFeature', upcomingFeatures],
|
|
403
|
+
] as const) {
|
|
404
|
+
const name = string(record(settingKind[kind])._0)
|
|
405
|
+
if (name && /^[A-Za-z_][A-Za-z0-9_]*(?:=[A-Za-z_][A-Za-z0-9_.-]*)?$/.test(name))
|
|
406
|
+
into.push({ name, configuration })
|
|
407
|
+
}
|
|
408
|
+
const flags = record(settingKind.unsafeFlags)._0
|
|
409
|
+
if (Array.isArray(flags) && flags.every((flag) => typeof flag === 'string'))
|
|
410
|
+
swiftFlags.push({
|
|
411
|
+
flags: flags.filter((flag): flag is string => typeof flag === 'string'),
|
|
412
|
+
configuration,
|
|
413
|
+
})
|
|
414
|
+
}
|
|
376
415
|
const library = string(record(settingKind.linkedLibrary)._0)
|
|
377
416
|
if (library && string(tool) === 'linker' && linksOnIOS(condition, traits)) {
|
|
378
417
|
const config = string(record(condition).config)
|
|
@@ -400,6 +439,9 @@ export function swiftPackageManifest(dir: string): SwiftPackageManifest {
|
|
|
400
439
|
mainActorIsolation,
|
|
401
440
|
defines,
|
|
402
441
|
libraries,
|
|
442
|
+
experimentalFeatures,
|
|
443
|
+
upcomingFeatures,
|
|
444
|
+
swiftFlags,
|
|
403
445
|
nativeSettings,
|
|
404
446
|
declaresResources: array(target.resources).length > 0,
|
|
405
447
|
hasPluginUsages: array(target.pluginUsages).length > 0,
|
|
@@ -425,6 +467,9 @@ function walk(dir: string): string[] {
|
|
|
425
467
|
const out: string[] = []
|
|
426
468
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
427
469
|
if (entry.name.startsWith('.')) continue
|
|
470
|
+
// swiftpm never assigns a documentation catalog's contents to a target
|
|
471
|
+
// (`swift package describe` omits them; other dotted directories stay).
|
|
472
|
+
if (entry.isDirectory() && entry.name.endsWith('.docc')) continue
|
|
428
473
|
const full = path.join(dir, entry.name)
|
|
429
474
|
if (entry.isDirectory()) out.push(...walk(full))
|
|
430
475
|
else if (entry.isFile()) out.push(full)
|
|
@@ -434,8 +479,8 @@ function walk(dir: string): string[] {
|
|
|
434
479
|
|
|
435
480
|
/**
|
|
436
481
|
* the files swiftpm assigns a target, absolute and sorted: its `sources:`
|
|
437
|
-
* (else its whole directory), less its `exclude
|
|
438
|
-
* the package's other targets nested inside it.
|
|
482
|
+
* (else its whole directory), less its `exclude:`, documentation catalogs
|
|
483
|
+
* and the directories of the package's other targets nested inside it.
|
|
439
484
|
*/
|
|
440
485
|
export function swiftTargetFiles(
|
|
441
486
|
manifest: SwiftPackageManifest,
|
package/src/swift-package.ts
CHANGED
|
@@ -18,6 +18,12 @@ export interface SwiftPackageTarget {
|
|
|
18
18
|
cxxInterop?: boolean
|
|
19
19
|
/** compilation conditions the target declares unconditionally in swiftSettings. */
|
|
20
20
|
defines?: string[]
|
|
21
|
+
/** experimental features the target declares unconditionally in swiftSettings. */
|
|
22
|
+
experimentalFeatures?: string[]
|
|
23
|
+
/** upcoming features the target declares unconditionally in swiftSettings. */
|
|
24
|
+
upcomingFeatures?: string[]
|
|
25
|
+
/** raw swift flags the target declares unconditionally in swiftSettings. */
|
|
26
|
+
swiftFlags?: string[]
|
|
21
27
|
/** `NAME` or `NAME=value` macros the target declares unconditionally in cSettings. */
|
|
22
28
|
cDefines?: string[]
|
|
23
29
|
/** `NAME` or `NAME=value` macros the target declares unconditionally in cxxSettings. */
|
|
@@ -76,7 +82,10 @@ const MANIFEST_DECLARATIONS = [
|
|
|
76
82
|
'package',
|
|
77
83
|
]
|
|
78
84
|
|
|
79
|
-
function manifestCalls(
|
|
85
|
+
export function manifestCalls(
|
|
86
|
+
manifest: string,
|
|
87
|
+
kinds: readonly string[],
|
|
88
|
+
): ManifestCall[] {
|
|
80
89
|
const code = manifest
|
|
81
90
|
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
82
91
|
.replace(/(^|[^:"])\/\/[^\n]*/g, '$1')
|
|
@@ -190,10 +199,13 @@ export function swiftTargetModuleName(name: string): string {
|
|
|
190
199
|
return name.replace(/[^A-Za-z0-9_]/g, '_').replace(/^[0-9]/, '_')
|
|
191
200
|
}
|
|
192
201
|
|
|
193
|
-
// swiftpm's identity for a remote package
|
|
194
|
-
//
|
|
202
|
+
// swiftpm's identity for a remote package, per PackageIdentityParser in
|
|
203
|
+
// swift-package-manager's Sources/PackageModel/PackageIdentity.swift: the
|
|
204
|
+
// url's last path component after dropping one trailing slash, without a
|
|
205
|
+
// `.git` suffix, lowercased.
|
|
195
206
|
export function swiftPackageIdentity(url: string): string {
|
|
196
|
-
|
|
207
|
+
const path = url.endsWith('/') ? url.slice(0, -1) : url
|
|
208
|
+
return (path.split('/').pop() ?? path).replace(/\.git$/, '').toLowerCase()
|
|
197
209
|
}
|
|
198
210
|
|
|
199
211
|
/** the SwiftPM `.define` call for a `NAME` or `NAME=value` macro. */
|
|
@@ -218,8 +230,9 @@ const swiftEscapes: Record<string, string> = {
|
|
|
218
230
|
* as `NAME` or `NAME=value`. swiftSettings conditions never reach clang, and
|
|
219
231
|
* cSettings and cxxSettings macros never reach swift.
|
|
220
232
|
*/
|
|
221
|
-
|
|
222
|
-
|
|
233
|
+
// the bracketed bodies of one tool's settings blocks in a target call.
|
|
234
|
+
function settingsBlocks(call: string, tool: 'swift' | 'c' | 'cxx'): string[] {
|
|
235
|
+
const bodies: string[] = []
|
|
223
236
|
for (const open of call.matchAll(new RegExp(`\\b${tool}Settings\\s*:\\s*\\[`, 'g'))) {
|
|
224
237
|
let depth = 1
|
|
225
238
|
let index = open.index + open[0].length
|
|
@@ -232,7 +245,35 @@ function settingDefines(call: string, tool: 'swift' | 'c' | 'cxx'): string[] {
|
|
|
232
245
|
} else if (char === '[') depth++
|
|
233
246
|
else if (char === ']') depth--
|
|
234
247
|
}
|
|
235
|
-
|
|
248
|
+
bodies.push(call.slice(start, index - 1))
|
|
249
|
+
}
|
|
250
|
+
return bodies
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// the feature names and raw flags a target's swiftSettings carry: features
|
|
254
|
+
// are identifiers, flags round-trip through json exactly as rendered.
|
|
255
|
+
function settingFeatures(call: string, setting: string): string[] {
|
|
256
|
+
const found: string[] = []
|
|
257
|
+
for (const body of settingsBlocks(call, 'swift')) {
|
|
258
|
+
if (setting === '.unsafeFlags') {
|
|
259
|
+
for (const list of body.matchAll(/\.unsafeFlags\(\s*\[([^\]]*)\]/g))
|
|
260
|
+
for (const match of list[1]!.matchAll(/"((?:[^"\\]|\\.)*)"/g))
|
|
261
|
+
found.push(JSON.parse(`"${match[1]}"`))
|
|
262
|
+
} else {
|
|
263
|
+
const name = '([A-Za-z_][A-Za-z0-9_]*(?:=[A-Za-z_][A-Za-z0-9_.-]*)?)'
|
|
264
|
+
const pattern =
|
|
265
|
+
setting === '.enableExperimentalFeature'
|
|
266
|
+
? new RegExp(`\\.enableExperimentalFeature\\(\\s*"${name}"\\s*\\)`, 'g')
|
|
267
|
+
: new RegExp(`\\.enableUpcomingFeature\\(\\s*"${name}"\\s*\\)`, 'g')
|
|
268
|
+
for (const match of body.matchAll(pattern)) found.push(match[1]!)
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return found
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function settingDefines(call: string, tool: 'swift' | 'c' | 'cxx'): string[] {
|
|
275
|
+
const defines: string[] = []
|
|
276
|
+
for (const body of settingsBlocks(call, tool)) {
|
|
236
277
|
for (const match of body.matchAll(
|
|
237
278
|
/\.define\(\s*"([A-Za-z_][A-Za-z0-9_]*)"\s*(?:,\s*to:\s*"((?:[^"\\]|\\.)*)"\s*)?\)/g,
|
|
238
279
|
)) {
|
|
@@ -261,8 +302,8 @@ function settingDefines(call: string, tool: 'swift' | 'c' | 'cxx'): string[] {
|
|
|
261
302
|
* A manifest is Swift code, not data, so this is a scanner, not a parser:
|
|
262
303
|
* each `.target(` / `.executableTarget(` call is matched to its balanced
|
|
263
304
|
* close paren (string-aware, so a paren inside a literal cannot end it
|
|
264
|
-
* early), and `name:` / `path:` are read from the call's own depth only,
|
|
265
|
-
* a nested `.product(name: "SwiftUI", ...)` inside dependencies never wins.
|
|
305
|
+
* it early), and `name:` / `path:` are read from the call's own depth only,
|
|
306
|
+
* so a nested `.product(name: "SwiftUI", ...)` inside dependencies never wins.
|
|
266
307
|
*/
|
|
267
308
|
export function swiftManifestTargets(
|
|
268
309
|
manifest: string,
|
|
@@ -300,6 +341,9 @@ export function swiftManifestTargets(
|
|
|
300
341
|
call.replace(/"(?:\\.|[^"\\])*"/g, ''),
|
|
301
342
|
)
|
|
302
343
|
const defines = settingDefines(call, 'swift').map((define) => define.split('=')[0]!)
|
|
344
|
+
const experimentalFeatures = settingFeatures(call, '.enableExperimentalFeature')
|
|
345
|
+
const upcomingFeatures = settingFeatures(call, '.enableUpcomingFeature')
|
|
346
|
+
const swiftFlags = settingFeatures(call, '.unsafeFlags')
|
|
303
347
|
const cDefines = settingDefines(call, 'c')
|
|
304
348
|
const cxxDefines = settingDefines(call, 'cxx')
|
|
305
349
|
const linkedLibraries = [...call.matchAll(/\.linkedLibrary\(\s*"([^"]+)"\s*\)/g)].map(
|
|
@@ -350,6 +394,9 @@ export function swiftManifestTargets(
|
|
|
350
394
|
mainActorIsolation,
|
|
351
395
|
...(cxxInterop ? { cxxInterop: true } : {}),
|
|
352
396
|
...(defines.length === 0 ? {} : { defines }),
|
|
397
|
+
...(experimentalFeatures.length === 0 ? {} : { experimentalFeatures }),
|
|
398
|
+
...(upcomingFeatures.length === 0 ? {} : { upcomingFeatures }),
|
|
399
|
+
...(swiftFlags.length === 0 ? {} : { swiftFlags }),
|
|
353
400
|
...(cDefines.length === 0 ? {} : { cDefines }),
|
|
354
401
|
...(cxxDefines.length === 0 ? {} : { cxxDefines }),
|
|
355
402
|
...(linkedLibraries.length === 0 ? {} : { linkedLibraries }),
|
|
@@ -552,6 +599,9 @@ export function swiftPackagePartition(
|
|
|
552
599
|
targets[0].languageMode === 5 &&
|
|
553
600
|
!targets[0].mainActorIsolation &&
|
|
554
601
|
!targets[0].defines?.length &&
|
|
602
|
+
!targets[0].experimentalFeatures?.length &&
|
|
603
|
+
!targets[0].upcomingFeatures?.length &&
|
|
604
|
+
!targets[0].swiftFlags?.length &&
|
|
555
605
|
!targets[0].linkedLibraries?.length &&
|
|
556
606
|
!targets[0].cxxInterop &&
|
|
557
607
|
!swiftManifestCxxLanguageStandard(manifest)
|
package/src/swift-packages.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { createHash } from 'node:crypto'
|
|
|
12
12
|
import fs from 'node:fs'
|
|
13
13
|
import path from 'node:path'
|
|
14
14
|
import { cacheDir } from './home-paths'
|
|
15
|
+
import { tryAcquireNumberedLock } from './numbered-lock'
|
|
15
16
|
import {
|
|
16
17
|
swiftImplicitResourcePaths,
|
|
17
18
|
swiftPackageIdentity,
|
|
@@ -22,6 +23,7 @@ import {
|
|
|
22
23
|
swiftPackageManifest,
|
|
23
24
|
swiftTargetFiles,
|
|
24
25
|
type SwiftManifestSetting,
|
|
26
|
+
type SwiftManifestTarget,
|
|
25
27
|
type SwiftPackageManifest,
|
|
26
28
|
} from './swift-package-manifest'
|
|
27
29
|
|
|
@@ -29,8 +31,8 @@ import {
|
|
|
29
31
|
export type SwiftPackageSource =
|
|
30
32
|
| { kind: 'local'; dir: string }
|
|
31
33
|
| { kind: 'remote'; url: string }
|
|
32
|
-
/** a product xcode finds by name among the
|
|
33
|
-
| { kind: 'unnamed' }
|
|
34
|
+
/** a product xcode finds by name among the packages the workspace references. */
|
|
35
|
+
| { kind: 'unnamed'; remoteUrls: string[] }
|
|
34
36
|
|
|
35
37
|
export interface SwiftLinkedProduct {
|
|
36
38
|
product: string
|
|
@@ -47,6 +49,9 @@ export interface SwiftPackageSourceTarget extends SwiftPackageTarget {
|
|
|
47
49
|
/** the conditions its manifest defines, before a build configuration picks them. */
|
|
48
50
|
packageDefines: SwiftManifestSetting[]
|
|
49
51
|
packageLibraries: SwiftManifestSetting[]
|
|
52
|
+
packageExperimentalFeatures: SwiftManifestSetting[]
|
|
53
|
+
packageUpcomingFeatures: SwiftManifestSetting[]
|
|
54
|
+
packageSwiftFlags: SwiftManifestTarget['swiftFlags']
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
/** why a product or module does not compile, and where it comes from. */
|
|
@@ -106,38 +111,71 @@ interface Pin {
|
|
|
106
111
|
revision: string
|
|
107
112
|
}
|
|
108
113
|
|
|
114
|
+
interface ResolvedPin extends Pin {
|
|
115
|
+
identity: string
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// a Package.resolved's pins in any of swiftpm's three lockfile generations:
|
|
119
|
+
// v1 nests them under `object` with the package name and repository url, and
|
|
120
|
+
// the identity is derived from the url as swiftpm derives it; v2 and v3 list
|
|
121
|
+
// them at the top level with their explicit identity and location. entries
|
|
122
|
+
// without a usable revision are skipped, as today.
|
|
123
|
+
function resolvedPins(data: unknown): ResolvedPin[] | null {
|
|
124
|
+
if (!data || typeof data !== 'object') return null
|
|
125
|
+
const version =
|
|
126
|
+
'version' in data && typeof data.version === 'number' ? data.version : null
|
|
127
|
+
// swiftpm fails a lockfile with no version or one it does not know, and
|
|
128
|
+
// each generation decodes its own pin shape: v1 carries repositoryURL,
|
|
129
|
+
// v2 and v3 carry location.
|
|
130
|
+
if (version !== 1 && version !== 2 && version !== 3) return null
|
|
131
|
+
const top = 'pins' in data && Array.isArray(data.pins) ? data.pins : null
|
|
132
|
+
const nested =
|
|
133
|
+
'object' in data &&
|
|
134
|
+
data.object &&
|
|
135
|
+
typeof data.object === 'object' &&
|
|
136
|
+
'pins' in data.object &&
|
|
137
|
+
Array.isArray(data.object.pins)
|
|
138
|
+
? data.object.pins
|
|
139
|
+
: null
|
|
140
|
+
const v1 = version === 1
|
|
141
|
+
const pins = v1 ? nested : top
|
|
142
|
+
if (!pins) return null
|
|
143
|
+
const out: ResolvedPin[] = []
|
|
144
|
+
for (const pin of pins) {
|
|
145
|
+
const location = v1 ? pin?.repositoryURL : pin?.location
|
|
146
|
+
const identity =
|
|
147
|
+
v1 && typeof location === 'string' ? swiftPackageIdentity(location) : pin?.identity
|
|
148
|
+
const revision = pin?.state?.revision
|
|
149
|
+
if (
|
|
150
|
+
typeof identity === 'string' &&
|
|
151
|
+
typeof location === 'string' &&
|
|
152
|
+
typeof revision === 'string'
|
|
153
|
+
)
|
|
154
|
+
out.push({ identity, location, revision })
|
|
155
|
+
}
|
|
156
|
+
return out
|
|
157
|
+
}
|
|
158
|
+
|
|
109
159
|
function readPins(resolved: readonly string[]): Map<string, Pin> {
|
|
110
160
|
const out = new Map<string, Pin>()
|
|
111
161
|
const owners = new Map<string, string>()
|
|
112
162
|
for (const file of resolved) {
|
|
113
163
|
const data: unknown = JSON.parse(fs.readFileSync(file, 'utf8'))
|
|
114
|
-
const pins =
|
|
115
|
-
data && typeof data === 'object' && 'pins' in data && Array.isArray(data.pins)
|
|
116
|
-
? data.pins
|
|
117
|
-
: null
|
|
164
|
+
const pins = resolvedPins(data)
|
|
118
165
|
if (!pins) throw new Error(`${file} has no pins; resolve packages in a current Xcode`)
|
|
119
|
-
for (const
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
const revision = pin?.state?.revision
|
|
166
|
+
for (const { identity, location, revision } of pins) {
|
|
167
|
+
const previous = out.get(identity)
|
|
168
|
+
const repository = (url: string) => url.replace(/(?:\.git)?\/?$/, '')
|
|
123
169
|
if (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
previous &&
|
|
132
|
-
(previous.revision !== revision ||
|
|
133
|
-
repository(previous.location) !== repository(location))
|
|
170
|
+
previous &&
|
|
171
|
+
(previous.revision !== revision ||
|
|
172
|
+
repository(previous.location) !== repository(location))
|
|
173
|
+
)
|
|
174
|
+
throw new Error(
|
|
175
|
+
`conflicting Package.resolved pins for ${identity}: ${owners.get(identity)} pins ${previous.location} at ${previous.revision}; ${file} pins ${location} at ${revision}`,
|
|
134
176
|
)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
)
|
|
138
|
-
out.set(identity, { location, revision })
|
|
139
|
-
owners.set(identity, file)
|
|
140
|
-
}
|
|
177
|
+
out.set(identity, { location, revision })
|
|
178
|
+
owners.set(identity, file)
|
|
141
179
|
}
|
|
142
180
|
}
|
|
143
181
|
return out
|
|
@@ -150,26 +188,64 @@ function checkout(checkouts: string, identity: string, pin: Pin): string {
|
|
|
150
188
|
const dir = path.join(checkouts, identity)
|
|
151
189
|
const key = `${dir}\0${pin.revision}`
|
|
152
190
|
if (verified.has(key)) return dir
|
|
153
|
-
const git = (...args: string[]) =>
|
|
154
|
-
execFileSync('git', ['-C',
|
|
191
|
+
const git = (cwd: string, ...args: string[]) =>
|
|
192
|
+
execFileSync('git', ['-C', cwd, ...args], {
|
|
155
193
|
encoding: 'utf8',
|
|
156
194
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
157
195
|
}).trim()
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
fs.
|
|
161
|
-
|
|
196
|
+
// an interrupted clone leaves a .git without a HEAD commit, which counts as no checkout
|
|
197
|
+
const head = (at = dir) => {
|
|
198
|
+
if (!fs.existsSync(path.join(at, '.git'))) return ''
|
|
199
|
+
try {
|
|
200
|
+
return git(at, 'rev-parse', 'HEAD')
|
|
201
|
+
} catch {
|
|
202
|
+
return ''
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (head() !== pin.revision) {
|
|
206
|
+
// staging dirs of killed runs are never reused
|
|
207
|
+
for (const name of fs.readdirSync(checkouts)) {
|
|
208
|
+
if (!name.startsWith(`${identity}.tmp-`)) continue
|
|
209
|
+
const stale = path.join(checkouts, name)
|
|
210
|
+
try {
|
|
211
|
+
if (Date.now() - fs.statSync(stale).mtimeMs > 24 * 3600_000)
|
|
212
|
+
fs.rmSync(stale, { recursive: true, force: true })
|
|
213
|
+
} catch {}
|
|
214
|
+
}
|
|
215
|
+
// fetch beside the final path and rename, so a killed run never leaves a partial dir
|
|
216
|
+
const staging = `${dir}.tmp-${process.pid}-${Date.now()}`
|
|
217
|
+
fs.rmSync(staging, { recursive: true, force: true })
|
|
218
|
+
fs.mkdirSync(staging, { recursive: true })
|
|
162
219
|
try {
|
|
163
|
-
git('init', '-q')
|
|
164
|
-
git('fetch', '-q', '--depth', '1', pin.location, pin.revision)
|
|
165
|
-
git('checkout', '-q', 'FETCH_HEAD')
|
|
220
|
+
git(staging, 'init', '-q')
|
|
221
|
+
git(staging, 'fetch', '-q', '--depth', '1', pin.location, pin.revision)
|
|
222
|
+
git(staging, 'checkout', '-q', 'FETCH_HEAD')
|
|
223
|
+
// the final dir changes only under a per-package lock, so the head check
|
|
224
|
+
// and the replacement are one step: a tree published by another run is
|
|
225
|
+
// kept as is and a stale publisher never removes it
|
|
226
|
+
let release = tryAcquireNumberedLock(`${dir}.lock`)
|
|
227
|
+
while (!release) {
|
|
228
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 25)
|
|
229
|
+
release = tryAcquireNumberedLock(`${dir}.lock`)
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
if (head() !== pin.revision) {
|
|
233
|
+
const aside = `${dir}.tmp-old-${process.pid}-${Date.now()}`
|
|
234
|
+
if (fs.existsSync(dir)) fs.renameSync(dir, aside)
|
|
235
|
+
fs.renameSync(staging, dir)
|
|
236
|
+
fs.rmSync(aside, { recursive: true, force: true })
|
|
237
|
+
}
|
|
238
|
+
} finally {
|
|
239
|
+
release()
|
|
240
|
+
}
|
|
166
241
|
} catch (error) {
|
|
167
|
-
fs.rmSync(dir, { recursive: true, force: true })
|
|
168
242
|
const stderr =
|
|
169
243
|
error instanceof Error && 'stderr' in error ? String(error.stderr).trim() : ''
|
|
170
244
|
throw new Error(
|
|
171
245
|
`could not fetch ${pin.location} at ${pin.revision}${stderr ? `: ${stderr}` : ''}`,
|
|
172
246
|
)
|
|
247
|
+
} finally {
|
|
248
|
+
fs.rmSync(staging, { recursive: true, force: true })
|
|
173
249
|
}
|
|
174
250
|
}
|
|
175
251
|
verified.add(key)
|
|
@@ -183,6 +259,22 @@ interface LoadedPackage {
|
|
|
183
259
|
manifest: SwiftPackageManifest
|
|
184
260
|
}
|
|
185
261
|
|
|
262
|
+
/**
|
|
263
|
+
* fetch every pinned checkout, as xcode's package resolution does before a
|
|
264
|
+
* build. run script phases read checkouts from disk, so they need them
|
|
265
|
+
* before the resolver runs for the compile.
|
|
266
|
+
*/
|
|
267
|
+
export function prefetchSwiftCheckouts(
|
|
268
|
+
rootDir: string,
|
|
269
|
+
resolved: readonly string[],
|
|
270
|
+
): void {
|
|
271
|
+
const pins = resolved.length > 0 ? readPins(resolved) : null
|
|
272
|
+
if (!pins) return
|
|
273
|
+
const checkouts = remoteSwiftCheckouts(rootDir)
|
|
274
|
+
fs.mkdirSync(checkouts, { recursive: true })
|
|
275
|
+
for (const [identity, pin] of pins) checkout(checkouts, identity, pin)
|
|
276
|
+
}
|
|
277
|
+
|
|
186
278
|
/**
|
|
187
279
|
* resolves `products` to the source targets that build them. products named
|
|
188
280
|
* in `provided` are peach modules and link as those instead. without
|
|
@@ -285,6 +377,9 @@ export function resolveSwiftPackages(options: {
|
|
|
285
377
|
remote: pkg.remote,
|
|
286
378
|
packageDefines: target.defines,
|
|
287
379
|
packageLibraries: target.libraries,
|
|
380
|
+
packageExperimentalFeatures: target.experimentalFeatures,
|
|
381
|
+
packageUpcomingFeatures: target.upcomingFeatures,
|
|
382
|
+
packageSwiftFlags: target.swiftFlags,
|
|
288
383
|
dependencies: target.dependencies.flatMap((dependency) => {
|
|
289
384
|
if (dependency.kind === 'target') return [dependency]
|
|
290
385
|
if (provided.has(dependency.name)) return []
|
|
@@ -344,17 +439,35 @@ export function resolveSwiftPackages(options: {
|
|
|
344
439
|
return typeof loaded === 'string' ? [loaded] : resolveProduct(loaded, product)
|
|
345
440
|
}
|
|
346
441
|
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
442
|
+
const unnamedProducts = new Map<string, LoadedPackage | string | undefined>()
|
|
443
|
+
const unnamed = (
|
|
444
|
+
source: Extract<SwiftPackageSource, { kind: 'unnamed' }>,
|
|
445
|
+
product: string,
|
|
446
|
+
): LoadedPackage | string | undefined => {
|
|
447
|
+
const key = JSON.stringify([source, product])
|
|
448
|
+
if (unnamedProducts.has(key)) return unnamedProducts.get(key)
|
|
449
|
+
const candidates = [
|
|
450
|
+
...localDirs.map((dir) => load({ kind: 'local', dir })),
|
|
451
|
+
...(options.provided ? source.remoteUrls : []).map((url) =>
|
|
452
|
+
load({ kind: 'remote', url }),
|
|
453
|
+
),
|
|
454
|
+
]
|
|
350
455
|
.filter((pkg) => typeof pkg !== 'string')
|
|
456
|
+
.filter((pkg) => pkg.manifest.products.has(product))
|
|
457
|
+
const matches = [
|
|
458
|
+
...new Map(candidates.map((pkg) => [pkg.manifest.dir, pkg])).values(),
|
|
459
|
+
]
|
|
460
|
+
const pkg =
|
|
461
|
+
matches.length > 1
|
|
462
|
+
? `ambiguous library product ${product} is vended by ${matches.map((match) => match.source).join(', ')}`
|
|
463
|
+
: matches[0]
|
|
464
|
+
unnamedProducts.set(key, pkg)
|
|
465
|
+
return pkg
|
|
466
|
+
}
|
|
351
467
|
for (const { product, source } of products) {
|
|
352
468
|
if (provided.has(product)) continue
|
|
353
469
|
if (source.kind === 'remote' && !options.provided) continue
|
|
354
|
-
const pkg =
|
|
355
|
-
source.kind === 'unnamed'
|
|
356
|
-
? unnamed().find((candidate) => candidate.manifest.products.has(product))
|
|
357
|
-
: load(source)
|
|
470
|
+
const pkg = source.kind === 'unnamed' ? unnamed(source, product) : load(source)
|
|
358
471
|
const reason =
|
|
359
472
|
pkg === undefined
|
|
360
473
|
? ['no package the workspace references vends it']
|
|
@@ -441,7 +554,7 @@ export function resolveSwiftPackages(options: {
|
|
|
441
554
|
for (const { product, source } of products) {
|
|
442
555
|
const pkg =
|
|
443
556
|
source.kind === 'unnamed'
|
|
444
|
-
? unnamed(
|
|
557
|
+
? unnamed(source, product)
|
|
445
558
|
: packages.get(source.kind === 'local' ? path.resolve(source.dir) : source.url)
|
|
446
559
|
if (!pkg || typeof pkg === 'string') continue
|
|
447
560
|
for (const root of pkg.manifest.products.get(product) ?? []) reach(pkg, root)
|