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
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import { execFileSync, spawn } from 'node:child_process'
|
|
2
|
-
import {
|
|
2
|
+
import { createHash } from 'node:crypto'
|
|
3
|
+
import { mkdirSync, readFileSync, realpathSync } from 'node:fs'
|
|
4
|
+
import { join } from 'node:path'
|
|
3
5
|
import type { SwiftIndexCommand, SwiftIndexLeg, SwiftIndexRef } from './types'
|
|
4
6
|
|
|
7
|
+
export function swiftSdkIdentity(swiftc: string, sdk: string, target: string) {
|
|
8
|
+
const sha256 = (bytes: Buffer) => createHash('sha256').update(bytes).digest('hex')
|
|
9
|
+
return {
|
|
10
|
+
sdk: realpathSync(sdk),
|
|
11
|
+
settings: sha256(readFileSync(join(sdk, 'SDKSettings.json'))),
|
|
12
|
+
build: sha256(
|
|
13
|
+
readFileSync(join(sdk, 'System/Library/CoreServices/SystemVersion.plist')),
|
|
14
|
+
),
|
|
15
|
+
compiler: realpathSync(swiftc),
|
|
16
|
+
version: execFileSync(swiftc, ['--version'], { encoding: 'utf8' }).trim(),
|
|
17
|
+
target,
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
5
21
|
// explicit references only: a reference role without the implicit role.
|
|
6
22
|
const REFERENCE = 1 << 2
|
|
7
23
|
const IMPLICIT = 1 << 8
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { homedir } from 'node:os'
|
|
3
|
+
import { dirname, join } from 'node:path'
|
|
4
|
+
import type { SwiftSdkSymbolSnapshot } from './types'
|
|
5
|
+
|
|
6
|
+
export function swiftSdkSymbolCachePath(fingerprint: string) {
|
|
7
|
+
if (!/^[a-f0-9]{64}$/.test(fingerprint))
|
|
8
|
+
throw new Error('invalid Swift SDK fingerprint')
|
|
9
|
+
return join(
|
|
10
|
+
homedir(),
|
|
11
|
+
'.cache/contrast-swift-yet/native/sdk-symbols',
|
|
12
|
+
`${fingerprint}.json`,
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function writeSwiftSdkSymbolCache(snapshot: SwiftSdkSymbolSnapshot) {
|
|
17
|
+
const path = swiftSdkSymbolCachePath(snapshot.sdk.fingerprint)
|
|
18
|
+
mkdirSync(dirname(path), { recursive: true })
|
|
19
|
+
const temporary = `${path}.${process.pid}.tmp`
|
|
20
|
+
writeFileSync(temporary, JSON.stringify(snapshot) + '\n')
|
|
21
|
+
renameSync(temporary, path)
|
|
22
|
+
return path
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function readSwiftSdkSymbolCache(fingerprint: string): SwiftSdkSymbolSnapshot {
|
|
26
|
+
const path = swiftSdkSymbolCachePath(fingerprint)
|
|
27
|
+
let value: unknown
|
|
28
|
+
try {
|
|
29
|
+
value = JSON.parse(readFileSync(path, 'utf8'))
|
|
30
|
+
} catch {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`native Swift SDK symbols are not cached for this compiler and SDK; run swift:yet --front-doors <artifact-path> on this host (${fingerprint})`,
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
if (
|
|
36
|
+
typeof value !== 'object' ||
|
|
37
|
+
value === null ||
|
|
38
|
+
!('schemaVersion' in value) ||
|
|
39
|
+
value.schemaVersion !== 1 ||
|
|
40
|
+
!('sdk' in value) ||
|
|
41
|
+
typeof value.sdk !== 'object' ||
|
|
42
|
+
value.sdk === null ||
|
|
43
|
+
!('version' in value.sdk) ||
|
|
44
|
+
typeof value.sdk.version !== 'string' ||
|
|
45
|
+
!('fingerprint' in value.sdk) ||
|
|
46
|
+
value.sdk.fingerprint !== fingerprint ||
|
|
47
|
+
!('symbols' in value) ||
|
|
48
|
+
!Array.isArray(value.symbols)
|
|
49
|
+
)
|
|
50
|
+
throw new Error('invalid native Swift SDK symbol cache')
|
|
51
|
+
const symbols: SwiftSdkSymbolSnapshot['symbols'] = value.symbols.map(
|
|
52
|
+
(entry: unknown) => {
|
|
53
|
+
if (
|
|
54
|
+
!Array.isArray(entry) ||
|
|
55
|
+
entry.length !== 4 ||
|
|
56
|
+
!entry.every((field: unknown) => typeof field === 'string' && field.length > 0)
|
|
57
|
+
)
|
|
58
|
+
throw new Error('invalid native Swift SDK symbol tuple')
|
|
59
|
+
const [module, usr, path, kind]: unknown[] = entry
|
|
60
|
+
if (
|
|
61
|
+
typeof module !== 'string' ||
|
|
62
|
+
typeof usr !== 'string' ||
|
|
63
|
+
typeof path !== 'string' ||
|
|
64
|
+
typeof kind !== 'string'
|
|
65
|
+
)
|
|
66
|
+
throw new Error('invalid native Swift SDK symbol tuple')
|
|
67
|
+
return [module, usr, path, kind]
|
|
68
|
+
},
|
|
69
|
+
)
|
|
70
|
+
return { schemaVersion: 1, sdk: { version: value.sdk.version, fingerprint }, symbols }
|
|
71
|
+
}
|
|
@@ -3,10 +3,82 @@ import { createHash } from 'node:crypto'
|
|
|
3
3
|
import { mkdtempSync, readFileSync, realpathSync, rmSync, statSync } from 'node:fs'
|
|
4
4
|
import { tmpdir } from 'node:os'
|
|
5
5
|
import { basename, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
6
|
+
import {
|
|
7
|
+
fileReachesFeature,
|
|
8
|
+
referenceFeatures,
|
|
9
|
+
} from '../react-native-coverage/verified-reach'
|
|
6
10
|
import { SWIFT_INDEX_READER_SOURCE } from './indexdump'
|
|
7
11
|
import { createSwiftIndexer } from './indexing'
|
|
8
12
|
import { swiftCoverageProvenance } from './provenance'
|
|
9
|
-
import type {
|
|
13
|
+
import type { CapabilityInventoryRow } from '../../../peach-compat/src/capability-inventory-types'
|
|
14
|
+
import type { VerifiedFeature } from '../../../peach-compat/src/verified-map-types'
|
|
15
|
+
import type {
|
|
16
|
+
SwiftIndexRef,
|
|
17
|
+
SwiftSourceInput,
|
|
18
|
+
SwiftSourceLeg,
|
|
19
|
+
SwiftSdkSymbolSnapshot,
|
|
20
|
+
} from './types'
|
|
21
|
+
|
|
22
|
+
// the inventory owns SDK identities, and the existing reach rules own feature
|
|
23
|
+
// attribution. a compiler reference establishes possible reach, never proof.
|
|
24
|
+
export function resolveSwiftFrontDoors(
|
|
25
|
+
index: Awaited<ReturnType<typeof indexSwiftApp>>,
|
|
26
|
+
rows: readonly Pick<
|
|
27
|
+
CapabilityInventoryRow,
|
|
28
|
+
'id' | 'packageName' | 'sourceFingerprint' | 'publicReferencePaths' | 'subsystem'
|
|
29
|
+
>[],
|
|
30
|
+
sdkFingerprint: string,
|
|
31
|
+
features: readonly VerifiedFeature[],
|
|
32
|
+
sdk: SwiftSdkSymbolSnapshot,
|
|
33
|
+
) {
|
|
34
|
+
const mappedRows = new Set<string>()
|
|
35
|
+
for (const row of rows) {
|
|
36
|
+
if (row.packageName !== 'swift-sdk' || row.sourceFingerprint !== sdkFingerprint)
|
|
37
|
+
continue
|
|
38
|
+
mappedRows.add(row.id)
|
|
39
|
+
}
|
|
40
|
+
const sdkMatched = sdk.sdk.fingerprint === sdkFingerprint
|
|
41
|
+
const byUSR = new Map<string, Set<string>>()
|
|
42
|
+
if (sdkMatched)
|
|
43
|
+
for (const [module, usr] of sdk.symbols) {
|
|
44
|
+
const modules = byUSR.get(usr) ?? new Set<string>()
|
|
45
|
+
modules.add(module)
|
|
46
|
+
byUSR.set(usr, modules)
|
|
47
|
+
}
|
|
48
|
+
const sites = index.sites.map((site) => {
|
|
49
|
+
const modules = site.nativeTypechecked ? [...(byUSR.get(site.usr) ?? [])] : []
|
|
50
|
+
const frontDoorIds = modules.map((module) => `swift:${module}:${site.usr}`)
|
|
51
|
+
const capabilityIds = frontDoorIds.filter((id) => mappedRows.has(id))
|
|
52
|
+
return {
|
|
53
|
+
...site,
|
|
54
|
+
declarationModules: modules,
|
|
55
|
+
declarationModule: modules.length === 1 ? modules[0]! : null,
|
|
56
|
+
origin: modules.length ? 'sdk' : 'unknown',
|
|
57
|
+
frontDoorIds,
|
|
58
|
+
capabilityIds,
|
|
59
|
+
features: [
|
|
60
|
+
...new Set(capabilityIds.flatMap((id) => referenceFeatures(features, id, null))),
|
|
61
|
+
],
|
|
62
|
+
mapping: capabilityIds.length
|
|
63
|
+
? 'attributed'
|
|
64
|
+
: modules.length
|
|
65
|
+
? 'unmapped'
|
|
66
|
+
: 'unknown',
|
|
67
|
+
verification: 'unknown',
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
const reached = new Set<string>()
|
|
71
|
+
for (const file of index.input.sources) {
|
|
72
|
+
const references = sites
|
|
73
|
+
.filter((site) => site.file === file.path)
|
|
74
|
+
.flatMap((site) =>
|
|
75
|
+
site.capabilityIds.map((capabilityId) => ({ capabilityId, value: null })),
|
|
76
|
+
)
|
|
77
|
+
for (const feature of features)
|
|
78
|
+
if (fileReachesFeature(feature, references)) reached.add(feature.id)
|
|
79
|
+
}
|
|
80
|
+
return { sites, features: [...reached].sort(), sdkMatched }
|
|
81
|
+
}
|
|
10
82
|
|
|
11
83
|
const sha256 = (bytes: string | Buffer) =>
|
|
12
84
|
createHash('sha256').update(bytes).digest('hex')
|
|
@@ -239,7 +311,7 @@ export async function indexSwiftApp(input: SwiftSourceInput) {
|
|
|
239
311
|
'The caller supplies source membership and compiler flags; project discovery and dependency closure are unknown.',
|
|
240
312
|
'Flags and compiler versions are recorded; SDK versions, dependency module contents and IndexStore library provenance are unknown.',
|
|
241
313
|
'The reader source hash identifies this repository source only; its binding to the caller-supplied reader binary is unknown.',
|
|
242
|
-
'USR sites
|
|
314
|
+
'USR sites alone establish no SDK origin, front door, feature or native proof. Attribution requires a matching SDK inventory.',
|
|
243
315
|
'Missing sites do not establish platform inactivity. Failed primaries may omit references; partial indexes establish no coverage percentage.',
|
|
244
316
|
...(peach
|
|
245
317
|
? []
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { SwiftCompileInput } from '../swift-compile'
|
|
2
2
|
|
|
3
|
+
export type SwiftSdkSymbolSnapshot = {
|
|
4
|
+
schemaVersion: 1
|
|
5
|
+
sdk: { version: string; fingerprint: string }
|
|
6
|
+
symbols: [module: string, usr: string, path: string, kind: string][]
|
|
7
|
+
}
|
|
8
|
+
|
|
3
9
|
export type SwiftIndexRef = {
|
|
4
10
|
line: number
|
|
5
11
|
col: number
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
3
|
-
"release": "swift-6.4.0-RELEASE-custom-
|
|
4
|
-
"wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-
|
|
5
|
-
"wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-
|
|
6
|
-
"wasmSdkChecksum": "
|
|
7
|
-
"source": "
|
|
2
|
+
"id": "2a88c78372024d5a",
|
|
3
|
+
"release": "swift-6.4.0-RELEASE-custom-8be2e4a7a393b003",
|
|
4
|
+
"wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-2d2602d0",
|
|
5
|
+
"wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-2d2602d0.artifactbundle.tar.gz",
|
|
6
|
+
"wasmSdkChecksum": "05181637294f73285610478231c04d79c9710648198f5423ed26b718da6d3df6",
|
|
7
|
+
"source": "392c8e4f247fd9ee304313a94a1b3f56e60e3ac2",
|
|
8
8
|
"targets": [
|
|
9
9
|
"ImagePlayground",
|
|
10
10
|
"QuickLookThumbnailing",
|
|
@@ -193,16 +193,16 @@
|
|
|
193
193
|
},
|
|
194
194
|
"hosts": {
|
|
195
195
|
"darwin-arm64": {
|
|
196
|
-
"sha256": "
|
|
197
|
-
"size":
|
|
196
|
+
"sha256": "890c0d4887c063bccd8597dd6c32f04266015fb3f2b059cc10fcfca752a8430b",
|
|
197
|
+
"size": 71192522
|
|
198
198
|
},
|
|
199
199
|
"linux-x64": {
|
|
200
|
-
"sha256": "
|
|
201
|
-
"size":
|
|
200
|
+
"sha256": "67bd5c088204b0ac93c364b3c46bc1d3626d7c2680e0c0c03f367069c0fc28f6",
|
|
201
|
+
"size": 71198414
|
|
202
202
|
},
|
|
203
203
|
"linux-arm64": {
|
|
204
|
-
"sha256": "
|
|
205
|
-
"size":
|
|
204
|
+
"sha256": "a0cb72050f4256a2d89cff92210f39a2d3e6adeef763b327bb45cdec15b957d7",
|
|
205
|
+
"size": 71196672
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
}
|
package/src/swift-host.ts
CHANGED
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
} from './swift-package'
|
|
45
45
|
import { swiftPackageManifest } from './swift-package-manifest'
|
|
46
46
|
import {
|
|
47
|
+
prefetchSwiftCheckouts,
|
|
47
48
|
remoteSwiftCheckouts,
|
|
48
49
|
resolveSwiftPackages,
|
|
49
50
|
type SwiftPackageBinary,
|
|
@@ -189,6 +190,8 @@ export interface SwiftProject {
|
|
|
189
190
|
hosted?: SwiftHostedCompileOptions
|
|
190
191
|
signal?: AbortSignal
|
|
191
192
|
libraries?: Record<string, string>
|
|
193
|
+
nativeTargets?: SwiftNativeTarget[]
|
|
194
|
+
resourceBundles?: SwiftResourceBundle[]
|
|
192
195
|
}
|
|
193
196
|
|
|
194
197
|
// a project is its swiftpm package: the build, the artifact, and the dev
|
|
@@ -257,6 +260,55 @@ interface XcodeProjectEntry {
|
|
|
257
260
|
|
|
258
261
|
const xcodeProjects = new Map<string, XcodeProjectEntry>()
|
|
259
262
|
|
|
263
|
+
// run script phases read SourcePackages/checkouts from disk, but the pins
|
|
264
|
+
// and the checkout root only exist after a first read. read once without
|
|
265
|
+
// running scripts, fetch the pins the way xcode's resolution does, link
|
|
266
|
+
// each used project's derived-data sibling at them, then read for real.
|
|
267
|
+
// once per project per process: the checkouts persist and the link is
|
|
268
|
+
// idempotent, and a later re-resolve refetches through the same writer.
|
|
269
|
+
const preparedScriptInputs = new Set<string>()
|
|
270
|
+
function readXcodeAppTargetPrepared(
|
|
271
|
+
input: string,
|
|
272
|
+
target: string | undefined,
|
|
273
|
+
configuration: string | undefined,
|
|
274
|
+
options: {
|
|
275
|
+
requireSources?: boolean
|
|
276
|
+
prepareGeneratedSources?: boolean
|
|
277
|
+
installedPods?: boolean
|
|
278
|
+
},
|
|
279
|
+
): XcodeAppTarget {
|
|
280
|
+
if (options.prepareGeneratedSources !== true)
|
|
281
|
+
return readXcodeAppTarget(input, target, configuration, options)
|
|
282
|
+
const key = JSON.stringify([input, target, configuration])
|
|
283
|
+
if (!preparedScriptInputs.has(key)) {
|
|
284
|
+
const probe = readXcodeAppTarget(input, target, configuration, {
|
|
285
|
+
...options,
|
|
286
|
+
prepareGeneratedSources: false,
|
|
287
|
+
requireSources: false,
|
|
288
|
+
})
|
|
289
|
+
prefetchSwiftCheckouts(probe.rootDir, probe.packageResolved)
|
|
290
|
+
const checkouts = remoteSwiftCheckouts(probe.rootDir)
|
|
291
|
+
for (const projectDir of probe.projectDirs) {
|
|
292
|
+
const packages = path.join(projectDir, '.build', 'peach-xcode', 'SourcePackages')
|
|
293
|
+
fs.mkdirSync(packages, { recursive: true })
|
|
294
|
+
const link = path.join(packages, 'checkouts')
|
|
295
|
+
let linked: string | null = null
|
|
296
|
+
try {
|
|
297
|
+
linked = fs.lstatSync(link).isSymbolicLink() ? fs.readlinkSync(link) : null
|
|
298
|
+
} catch {
|
|
299
|
+
linked = null
|
|
300
|
+
}
|
|
301
|
+
if (linked !== null) {
|
|
302
|
+
if (path.resolve(packages, linked) === checkouts) continue
|
|
303
|
+
fs.unlinkSync(link)
|
|
304
|
+
} else if (fs.existsSync(link)) continue
|
|
305
|
+
fs.symlinkSync(checkouts, link)
|
|
306
|
+
}
|
|
307
|
+
preparedScriptInputs.add(key)
|
|
308
|
+
}
|
|
309
|
+
return readXcodeAppTarget(input, target, configuration, options)
|
|
310
|
+
}
|
|
311
|
+
|
|
260
312
|
/**
|
|
261
313
|
* registers an xcode project's application target as a compile unit and
|
|
262
314
|
* returns the package path that names it. compiling locally against
|
|
@@ -269,7 +321,7 @@ export function openXcodeProject(
|
|
|
269
321
|
moduleRoot: string | undefined,
|
|
270
322
|
configuration?: string,
|
|
271
323
|
): string {
|
|
272
|
-
const app =
|
|
324
|
+
const app = readXcodeAppTargetPrepared(xcodeproj, target, configuration, {
|
|
273
325
|
prepareGeneratedSources: true,
|
|
274
326
|
installedPods: true,
|
|
275
327
|
})
|
|
@@ -459,7 +511,7 @@ interface XcodeLayout {
|
|
|
459
511
|
function xcodeLayout(root: string): XcodeLayout | null {
|
|
460
512
|
const registered = xcodeProjects.get(root)
|
|
461
513
|
if (!registered) return null
|
|
462
|
-
const app =
|
|
514
|
+
const app = readXcodeAppTargetPrepared(
|
|
463
515
|
registered.xcodeproj,
|
|
464
516
|
registered.target,
|
|
465
517
|
registered.configuration,
|
|
@@ -557,6 +609,27 @@ function xcodeLayout(root: string): XcodeLayout | null {
|
|
|
557
609
|
)
|
|
558
610
|
.map((define) => define.name),
|
|
559
611
|
],
|
|
612
|
+
experimentalFeatures: target.packageExperimentalFeatures
|
|
613
|
+
.filter(
|
|
614
|
+
(feature) =>
|
|
615
|
+
feature.configuration === null ||
|
|
616
|
+
feature.configuration === packageConfiguration,
|
|
617
|
+
)
|
|
618
|
+
.map((feature) => feature.name),
|
|
619
|
+
upcomingFeatures: target.packageUpcomingFeatures
|
|
620
|
+
.filter(
|
|
621
|
+
(feature) =>
|
|
622
|
+
feature.configuration === null ||
|
|
623
|
+
feature.configuration === packageConfiguration,
|
|
624
|
+
)
|
|
625
|
+
.map((feature) => feature.name),
|
|
626
|
+
swiftFlags: target.packageSwiftFlags
|
|
627
|
+
.filter(
|
|
628
|
+
(setting) =>
|
|
629
|
+
setting.configuration === null ||
|
|
630
|
+
setting.configuration === packageConfiguration,
|
|
631
|
+
)
|
|
632
|
+
.flatMap((setting) => setting.flags),
|
|
560
633
|
linkedLibraries: target.packageLibraries
|
|
561
634
|
.filter(
|
|
562
635
|
(library) =>
|
|
@@ -737,11 +810,25 @@ function xcodeManifest(layout: XcodeLayout): string {
|
|
|
737
810
|
languageMode: number
|
|
738
811
|
mainActorIsolation: boolean
|
|
739
812
|
defines?: string[]
|
|
813
|
+
experimentalFeatures?: string[]
|
|
814
|
+
upcomingFeatures?: string[]
|
|
815
|
+
swiftFlags?: string[]
|
|
740
816
|
}) =>
|
|
741
817
|
`swiftSettings: [${[
|
|
742
818
|
`.swiftLanguageMode(.v${target.languageMode})`,
|
|
743
819
|
...(target.mainActorIsolation ? ['.defaultIsolation(MainActor.self)'] : []),
|
|
744
820
|
...(target.defines ?? []).map((name) => `.define(${JSON.stringify(name)})`),
|
|
821
|
+
...(target.experimentalFeatures ?? []).map(
|
|
822
|
+
(name) => `.enableExperimentalFeature(${JSON.stringify(name)})`,
|
|
823
|
+
),
|
|
824
|
+
...(target.upcomingFeatures ?? []).map(
|
|
825
|
+
(name) => `.enableUpcomingFeature(${JSON.stringify(name)})`,
|
|
826
|
+
),
|
|
827
|
+
...(target.swiftFlags?.length
|
|
828
|
+
? [
|
|
829
|
+
`.unsafeFlags([${target.swiftFlags.map((flag) => JSON.stringify(flag)).join(', ')}])`,
|
|
830
|
+
]
|
|
831
|
+
: []),
|
|
745
832
|
].join(', ')}]`
|
|
746
833
|
const clangSettings = (target: SwiftPackageTarget) =>
|
|
747
834
|
(
|
|
@@ -1010,7 +1097,10 @@ export function buildSwiftResourceTable(
|
|
|
1010
1097
|
)
|
|
1011
1098
|
}
|
|
1012
1099
|
const layout = xcodeLayout(project.packagePath)
|
|
1013
|
-
const bundles =
|
|
1100
|
+
const bundles =
|
|
1101
|
+
project.resourceBundles ??
|
|
1102
|
+
layout?.resourceBundles ??
|
|
1103
|
+
swiftResourceBundles(inputs, relative)
|
|
1014
1104
|
const catalogFiles = relative.filter((file) => {
|
|
1015
1105
|
const disk = byRelative.get(file)
|
|
1016
1106
|
return !disk || !layout?.targetDirs.get(disk)?.startsWith(`${XCODE_FRAMEWORKS_DIR}/`)
|
|
@@ -1144,6 +1234,7 @@ export function buildSwiftBundleFiles(
|
|
|
1144
1234
|
packagePath: string,
|
|
1145
1235
|
hosted: boolean,
|
|
1146
1236
|
inputs?: Record<string, string>,
|
|
1237
|
+
resourceBundles?: SwiftResourceBundle[],
|
|
1147
1238
|
): SwiftBundlePack {
|
|
1148
1239
|
packagePath = fs.realpathSync(packagePath)
|
|
1149
1240
|
const limits = inputLimits(hosted)
|
|
@@ -1158,6 +1249,7 @@ export function buildSwiftBundleFiles(
|
|
|
1158
1249
|
let total = 0
|
|
1159
1250
|
const xcode = xcodeLayout(packagePath)
|
|
1160
1251
|
const bundles =
|
|
1252
|
+
resourceBundles ??
|
|
1161
1253
|
xcode?.resourceBundles ??
|
|
1162
1254
|
swiftResourceBundles(inputs ?? packageSources(packagePath, hosted), relative)
|
|
1163
1255
|
const addFile = (key: string, bytes: Buffer) => {
|
|
@@ -1267,6 +1359,8 @@ export function sourceStamp(
|
|
|
1267
1359
|
hash.update(JSON.stringify(xcodeProjects.get(packagePath)?.behavior ?? {}))
|
|
1268
1360
|
const libraries = projects.get(packagePath)?.libraries
|
|
1269
1361
|
if (libraries) hash.update(JSON.stringify(libraries))
|
|
1362
|
+
hash.update(JSON.stringify(projects.get(packagePath)?.nativeTargets ?? []))
|
|
1363
|
+
hash.update(JSON.stringify(projects.get(packagePath)?.resourceBundles ?? []))
|
|
1270
1364
|
const projectInputs = new Set(packageFiles(packagePath))
|
|
1271
1365
|
for (const file of [...projectInputs].sort()) {
|
|
1272
1366
|
hash.update(path.relative(packagePath, file))
|
|
@@ -1287,6 +1381,8 @@ export function sourceContentStamp(
|
|
|
1287
1381
|
hash.update(JSON.stringify(xcodeProjects.get(packagePath)?.behavior ?? {}))
|
|
1288
1382
|
const libraries = projects.get(packagePath)?.libraries
|
|
1289
1383
|
if (libraries) hash.update(JSON.stringify(libraries))
|
|
1384
|
+
hash.update(JSON.stringify(projects.get(packagePath)?.nativeTargets ?? []))
|
|
1385
|
+
hash.update(JSON.stringify(projects.get(packagePath)?.resourceBundles ?? []))
|
|
1290
1386
|
for (const file of [...new Set(packageFiles(packagePath))].sort()) {
|
|
1291
1387
|
hash.update(path.relative(packagePath, file))
|
|
1292
1388
|
hash.update(fs.readFileSync(file))
|
|
@@ -1429,7 +1525,9 @@ function packageSnapshot(project: SwiftProject, entry: string): SwiftPackageSnap
|
|
|
1429
1525
|
const native = nativeSourceDescriptor(project.packagePath)
|
|
1430
1526
|
return {
|
|
1431
1527
|
files,
|
|
1432
|
-
...(
|
|
1528
|
+
...((project.nativeTargets ?? layout?.nativeTargets)?.length
|
|
1529
|
+
? { nativeTargets: project.nativeTargets ?? layout?.nativeTargets }
|
|
1530
|
+
: {}),
|
|
1433
1531
|
entry: layout
|
|
1434
1532
|
? xcodeInputKey(layout, path.resolve(project.packagePath, entry), entry)
|
|
1435
1533
|
: entry,
|
|
@@ -1447,6 +1545,7 @@ function packageSnapshot(project: SwiftProject, entry: string): SwiftPackageSnap
|
|
|
1447
1545
|
project.packagePath,
|
|
1448
1546
|
Boolean(project.hosted),
|
|
1449
1547
|
files,
|
|
1548
|
+
project.resourceBundles,
|
|
1450
1549
|
),
|
|
1451
1550
|
native,
|
|
1452
1551
|
...(linked.size > 0 || project.libraries
|
|
@@ -1542,9 +1641,18 @@ async function compile(
|
|
|
1542
1641
|
module: moduleStamp(packagePath, moduleRootOverride, false),
|
|
1543
1642
|
}
|
|
1544
1643
|
// targets are imported by their module names
|
|
1545
|
-
const
|
|
1546
|
-
|
|
1547
|
-
|
|
1644
|
+
const parsed = compileTargets(input)
|
|
1645
|
+
const targets = parsed.map((target) => swiftTargetModuleName(target.name))
|
|
1646
|
+
// the compiler synthesizes Builtin for a file whose own target enables the
|
|
1647
|
+
// feature, exactly when its import compiles. longest path first, so a
|
|
1648
|
+
// nested target's files read its own settings.
|
|
1649
|
+
const byPath = [...parsed].sort((left, right) => right.path.length - left.path.length)
|
|
1650
|
+
const providedByFile = (file: string): readonly string[] => {
|
|
1651
|
+
const owner = byPath.find((target) =>
|
|
1652
|
+
target.path === '.' ? true : file.startsWith(`${target.path}/`),
|
|
1653
|
+
)
|
|
1654
|
+
return owner?.experimentalFeatures?.includes('BuiltinModule') ? ['Builtin'] : []
|
|
1655
|
+
}
|
|
1548
1656
|
const missing = missingSwiftModules(
|
|
1549
1657
|
input.files,
|
|
1550
1658
|
new Set([
|
|
@@ -1552,6 +1660,7 @@ async function compile(
|
|
|
1552
1660
|
// a project without a manifest compiles as the template's one App target
|
|
1553
1661
|
...(targets.length > 0 ? targets : ['App']),
|
|
1554
1662
|
]),
|
|
1663
|
+
providedByFile,
|
|
1555
1664
|
)
|
|
1556
1665
|
if (missing.size > 0)
|
|
1557
1666
|
throw new SwiftMissingModulesError(await missingModulesMessage(packagePath, missing))
|
|
@@ -1969,13 +2078,23 @@ export async function swiftPackageMetadata(
|
|
|
1969
2078
|
packagePath = fs.realpathSync(packagePath)
|
|
1970
2079
|
const project = projectFor(packagePath, hosted, signal)
|
|
1971
2080
|
const limits = inputLimits(Boolean(project.hosted))
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
2081
|
+
// an xcode project runs its selected application target: the entry is one
|
|
2082
|
+
// of the target's own swift sources, never a framework, package or sibling
|
|
2083
|
+
// target's @main elsewhere in the inputs. a plain package scans its tree.
|
|
2084
|
+
const registered = xcodeProjects.get(packagePath)
|
|
2085
|
+
const candidates = registered
|
|
2086
|
+
? readXcodeAppTargetPrepared(
|
|
2087
|
+
registered.xcodeproj,
|
|
2088
|
+
registered.target,
|
|
2089
|
+
registered.configuration,
|
|
2090
|
+
{ prepareGeneratedSources: true, installedPods: true },
|
|
2091
|
+
).sources
|
|
2092
|
+
: sourceFiles(packagePath).filter((file) => file.endsWith('.swift'))
|
|
2093
|
+
const mains = candidates.filter((file) =>
|
|
2094
|
+
swiftApplicationEntry(
|
|
2095
|
+
file,
|
|
2096
|
+
readPackageFile(packagePath, file, limits.sourceBytes).toString('utf8'),
|
|
2097
|
+
),
|
|
1979
2098
|
)
|
|
1980
2099
|
const native = nativeSourceDescriptor(packagePath)
|
|
1981
2100
|
if (mains.length > 1 || (mains.length === 0 && !native)) {
|
|
@@ -13,9 +13,10 @@ import {
|
|
|
13
13
|
} from './swift-objc-metadata'
|
|
14
14
|
import {
|
|
15
15
|
IOS_SDK_ID,
|
|
16
|
+
iosDeploymentMinimum,
|
|
16
17
|
materializeObjcSdk,
|
|
17
18
|
OBJC_IMPORT_VERSION,
|
|
18
|
-
|
|
19
|
+
objcSdkIntakeFlags,
|
|
19
20
|
} from './swift-objc-standin'
|
|
20
21
|
import { SWIFT_NATIVE_SOURCE_EXTENSIONS, swiftTargetModuleName } from './swift-package'
|
|
21
22
|
import { swiftPackageManifest, swiftTargetFiles } from './swift-package-manifest'
|
|
@@ -244,7 +245,7 @@ export function prepareXcodeObjCImplementations(
|
|
|
244
245
|
[...sources].map(([file, bytes]) => [file, digest(bytes)]),
|
|
245
246
|
)
|
|
246
247
|
const identity = {
|
|
247
|
-
version:
|
|
248
|
+
version: 16,
|
|
248
249
|
importer: OBJC_IMPORT_VERSION,
|
|
249
250
|
peers,
|
|
250
251
|
metadataDeploymentTarget: peers ? app.iosDeploymentTarget : undefined,
|
|
@@ -481,19 +482,13 @@ export function prepareXcodeObjCImplementations(
|
|
|
481
482
|
name: string
|
|
482
483
|
deploymentTarget: string | null
|
|
483
484
|
}): number => {
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
)
|
|
487
|
-
if (!version) {
|
|
485
|
+
const minimum = iosDeploymentMinimum(target.deploymentTarget)
|
|
486
|
+
if (minimum === undefined) {
|
|
488
487
|
return finish(
|
|
489
488
|
'unsupported-deployment-target',
|
|
490
489
|
`${target.name}: Objective-C compilation requires an explicit numeric IPHONEOS_DEPLOYMENT_TARGET; received ${JSON.stringify(target.deploymentTarget)}. Inputs: ${receipt}`,
|
|
491
490
|
)
|
|
492
491
|
}
|
|
493
|
-
const minimum =
|
|
494
|
-
Number(version[1]) * 10_000 +
|
|
495
|
-
Number(version[2] ?? 0) * 100 +
|
|
496
|
-
Number(version[3] ?? 0)
|
|
497
492
|
return minimum
|
|
498
493
|
}
|
|
499
494
|
if (targets.length === 0)
|
|
@@ -559,20 +554,10 @@ export function prepareXcodeObjCImplementations(
|
|
|
559
554
|
`--sysroot=${sdk.sysroot}`,
|
|
560
555
|
'-fwasm-exceptions',
|
|
561
556
|
'-fexceptions',
|
|
562
|
-
...WASI_EMULATION_FLAGS,
|
|
563
|
-
`-D__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__=${minimum}`,
|
|
564
|
-
`-D__IPHONE_OS_VERSION_MIN_REQUIRED=${minimum}`,
|
|
565
557
|
...(objc
|
|
566
558
|
? ['-fobjc-runtime=gnustep-2.2', '-fobjc-exceptions', '-fblocks']
|
|
567
559
|
: []),
|
|
568
|
-
|
|
569
|
-
path.join(headers, 'System/Library/Frameworks'),
|
|
570
|
-
// the extension headers include the installed libc before adding darwin declarations.
|
|
571
|
-
'-isystem',
|
|
572
|
-
path.join(headers, 'wasm/include'),
|
|
573
|
-
// installed libc and objc runtime headers own the target ABI.
|
|
574
|
-
'-idirafter',
|
|
575
|
-
path.join(headers, 'usr/include'),
|
|
560
|
+
...objcSdkIntakeFlags(headers, toolchain.toolchainBin, minimum),
|
|
576
561
|
...headerSearch.flags[index]!,
|
|
577
562
|
...target.includes.flatMap((include) => ['-I', staged(include)]),
|
|
578
563
|
...target.frameworks.flatMap((framework) => ['-F', staged(framework)]),
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
IOS_SDK_ID,
|
|
9
9
|
materializeObjcSdk,
|
|
10
10
|
OBJC_IMPORT_VERSION,
|
|
11
|
-
|
|
11
|
+
objcSdkIntakeFlags,
|
|
12
12
|
objcView,
|
|
13
13
|
type ObjcView,
|
|
14
14
|
} from './swift-objc-standin'
|
|
@@ -434,9 +434,6 @@ export function compileObjcPeerMetadata(args: {
|
|
|
434
434
|
`--sysroot=${args.sysroot}`,
|
|
435
435
|
'-fwasm-exceptions',
|
|
436
436
|
'-fexceptions',
|
|
437
|
-
...WASI_EMULATION_FLAGS,
|
|
438
|
-
`-D__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__=${args.minimum}`,
|
|
439
|
-
`-D__IPHONE_OS_VERSION_MIN_REQUIRED=${args.minimum}`,
|
|
440
437
|
'-fobjc-runtime=gnustep-2.2',
|
|
441
438
|
'-fobjc-exceptions',
|
|
442
439
|
'-fobjc-arc',
|
|
@@ -445,10 +442,7 @@ export function compileObjcPeerMetadata(args: {
|
|
|
445
442
|
'-Xclang',
|
|
446
443
|
'-disable-objc-default-synthesize-properties',
|
|
447
444
|
'-Werror=objc-root-class',
|
|
448
|
-
|
|
449
|
-
path.join(headers, 'System/Library/Frameworks'),
|
|
450
|
-
'-idirafter',
|
|
451
|
-
path.join(headers, 'usr/include'),
|
|
445
|
+
...objcSdkIntakeFlags(headers, args.toolchainBin, args.minimum),
|
|
452
446
|
'-Os',
|
|
453
447
|
'-c',
|
|
454
448
|
source,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { swiftEnvironment } from './swift-toolchain'
|
|
4
|
+
|
|
5
|
+
const platforms = new Map<string, readonly string[]>()
|
|
6
|
+
|
|
7
|
+
/** iOS source selection with the implementation compiler's wasm storage and runtime. */
|
|
8
|
+
export function swiftObjCPlatformFlags(
|
|
9
|
+
toolchainBin: string,
|
|
10
|
+
minimum: number,
|
|
11
|
+
): readonly string[] {
|
|
12
|
+
const key = `${toolchainBin}:${minimum}`
|
|
13
|
+
const cached = platforms.get(key)
|
|
14
|
+
if (cached) return cached
|
|
15
|
+
const version = [
|
|
16
|
+
Math.floor(minimum / 10_000),
|
|
17
|
+
Math.floor((minimum % 10_000) / 100),
|
|
18
|
+
minimum % 100,
|
|
19
|
+
].join('.')
|
|
20
|
+
const result = spawnSync(
|
|
21
|
+
path.join(toolchainBin, 'clang'),
|
|
22
|
+
[
|
|
23
|
+
'-target',
|
|
24
|
+
`arm64-apple-ios${version}-simulator`,
|
|
25
|
+
'-dM',
|
|
26
|
+
'-E',
|
|
27
|
+
'-x',
|
|
28
|
+
'objective-c',
|
|
29
|
+
'-',
|
|
30
|
+
],
|
|
31
|
+
{
|
|
32
|
+
input: '',
|
|
33
|
+
encoding: 'utf8',
|
|
34
|
+
env: swiftEnvironment(),
|
|
35
|
+
timeout: 30_000,
|
|
36
|
+
maxBuffer: 1024 * 1024,
|
|
37
|
+
},
|
|
38
|
+
)
|
|
39
|
+
if (result.error || result.status !== 0)
|
|
40
|
+
throw new Error(
|
|
41
|
+
`could not read iOS compiler platform predefines: ${result.error?.message ?? result.stderr}`,
|
|
42
|
+
)
|
|
43
|
+
// copy OS and vendor identity, never arm64 widths, instructions or Apple's objc ABI.
|
|
44
|
+
const flags = [
|
|
45
|
+
...result.stdout.matchAll(
|
|
46
|
+
/^#define (TARGET_OS_\w+|TARGET_IPHONE_SIMULATOR|__APPLE\w*__|__MACH__|__ENVIRONMENT_\w+) (.*)$/gm,
|
|
47
|
+
),
|
|
48
|
+
].map(([, name, value]) => `-D${name}=${value}`)
|
|
49
|
+
if (!flags.includes('-D__APPLE__=1') || !flags.includes('-D__MACH__=1'))
|
|
50
|
+
throw new Error('iOS compiler platform predefines lack Apple and Mach identity')
|
|
51
|
+
platforms.set(key, flags)
|
|
52
|
+
return flags
|
|
53
|
+
}
|