peachsim 0.1.1963 → 0.1.1965
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/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 +194 -49
- 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 +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +192 -48
- 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 +193 -49
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- 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 +3 -3
- 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 +3 -3
- package/dist-lib/native-app-identity-project.cjs +3 -3
- package/dist-lib/native-app-identity-project.mjs +3 -3
- 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 +24 -24
- package/dist-lib/public-origins-lib.json +53 -53
- 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 +194 -49
- package/dist-lib/swift-compile.cjs +2 -2
- package/dist-lib/swift-compile.mjs +2 -2
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +6 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +191 -47
- package/dist-lib/vite.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/package.json +1 -1
- package/src/swift-objc-standin.ts +3 -4
- package/src/swift-packages.ts +13 -1
- package/src/swift-standin-emit.ts +16 -3
- package/src/swift-standins.ts +188 -33
- package/src/swift-toolchain.ts +6 -0
|
@@ -168,6 +168,7 @@ export type StandinOptions = {
|
|
|
168
168
|
behavior?: ReadonlyMap<string, StandinBehavior>
|
|
169
169
|
/** modules whose protocols a declaration may conform to, beside its own. */
|
|
170
170
|
family?: string[]
|
|
171
|
+
dependencyGraphs?: SymbolGraph[]
|
|
171
172
|
/** paths left out, with why: the compiler rejected their declaration. */
|
|
172
173
|
omit?: ReadonlyMap<string, string>
|
|
173
174
|
/** inert paths whose return value the compiler rejected: their bodies trap. */
|
|
@@ -638,7 +639,12 @@ export function emitSwiftStandin(
|
|
|
638
639
|
): StandinResult {
|
|
639
640
|
const imported = new Set(options.imports)
|
|
640
641
|
const importedTypeModules = options.importedTypeModules ?? new Map<string, string>()
|
|
641
|
-
const
|
|
642
|
+
const ownIds = new Set(
|
|
643
|
+
sourceGraphs.flatMap((graph) =>
|
|
644
|
+
graph.symbols.map((symbol) => symbol.identifier.precise),
|
|
645
|
+
),
|
|
646
|
+
)
|
|
647
|
+
const graphs = [...sourceGraphs, ...(options.dependencyGraphs ?? [])].map((graph) =>
|
|
642
648
|
qualifyImportedTypes(graph, imported, importedTypeModules),
|
|
643
649
|
)
|
|
644
650
|
const nativeObjcProtocols = objcProtocolsInSwiftSignatures(graphs)
|
|
@@ -1453,7 +1459,8 @@ export function emitSwiftStandin(
|
|
|
1453
1459
|
),
|
|
1454
1460
|
].filter((name, at, all) => all.indexOf(name) === at)
|
|
1455
1461
|
const parentSymbol = superId.has(id) ? byId.get(superId.get(id)!) : undefined
|
|
1456
|
-
if (!parentSymbol
|
|
1462
|
+
if (!parentSymbol || !ownIds.has(parentSymbol.identifier.precise))
|
|
1463
|
+
list.push(standinMarker)
|
|
1457
1464
|
const open =
|
|
1458
1465
|
symbol.accessLevel === 'open' &&
|
|
1459
1466
|
(!parentSymbol || parentSymbol.accessLevel === 'open')
|
|
@@ -1936,7 +1943,12 @@ export function emitSwiftStandin(
|
|
|
1936
1943
|
}),
|
|
1937
1944
|
)
|
|
1938
1945
|
const roots = [...byId.values()]
|
|
1939
|
-
.filter(
|
|
1946
|
+
.filter(
|
|
1947
|
+
(symbol) =>
|
|
1948
|
+
ownIds.has(symbol.identifier.precise) &&
|
|
1949
|
+
!owner.has(symbol.identifier.precise) &&
|
|
1950
|
+
!unavailable(symbol),
|
|
1951
|
+
)
|
|
1940
1952
|
.filter((symbol) => {
|
|
1941
1953
|
const name = /^c:@M@[^@]+@F@([^@]+)$/.exec(symbol.identifier.precise)?.[1]
|
|
1942
1954
|
return !name || !cExports.has(`${name}|${text(symbol)}`)
|
|
@@ -1950,6 +1962,7 @@ export function emitSwiftStandin(
|
|
|
1950
1962
|
for (const [name, members] of [...external].sort(([a], [b]) => a.localeCompare(b))) {
|
|
1951
1963
|
const seen = new Set<string>()
|
|
1952
1964
|
const kept = members.filter((member) => {
|
|
1965
|
+
if (!ownIds.has(member.identifier.precise)) return false
|
|
1953
1966
|
const key = `${member.kind.identifier}|${text(member)}`
|
|
1954
1967
|
if (unavailable(member) || seen.has(key)) return false
|
|
1955
1968
|
seen.add(key)
|
package/src/swift-standins.ts
CHANGED
|
@@ -43,10 +43,12 @@ import {
|
|
|
43
43
|
type ObjcSurface,
|
|
44
44
|
} from './swift-objc-standin'
|
|
45
45
|
import {
|
|
46
|
+
clangImportNames,
|
|
46
47
|
moduleMapName,
|
|
47
48
|
swiftManifestDeclarations,
|
|
48
49
|
swiftTargetModuleName,
|
|
49
50
|
} from './swift-package'
|
|
51
|
+
import { swiftBinaryOnDisk, type SwiftPackageBinary } from './swift-packages'
|
|
50
52
|
import { swiftSharedSdkRoot } from './swift-shared-sdk'
|
|
51
53
|
import { STANDIN_SOURCE_DIGEST, standinSourceDigest } from './swift-standin-digest'
|
|
52
54
|
import {
|
|
@@ -64,10 +66,10 @@ import {
|
|
|
64
66
|
import {
|
|
65
67
|
sourceSwiftCheckout,
|
|
66
68
|
swiftEnvironment,
|
|
69
|
+
withoutCoreDump,
|
|
67
70
|
swiftPackageCacheOptions,
|
|
68
71
|
} from './swift-toolchain'
|
|
69
72
|
import { simulatorNativeLibrary } from './swift-xcframework'
|
|
70
|
-
import type { SwiftPackageBinary } from './swift-packages'
|
|
71
73
|
|
|
72
74
|
const TRIPLE = 'wasm32-unknown-wasip1'
|
|
73
75
|
// every stand-in artifact and temporary workspace belongs to peach.
|
|
@@ -105,6 +107,7 @@ interface Toolchain {
|
|
|
105
107
|
interface NativeFrameworkInputs {
|
|
106
108
|
dirs: string[]
|
|
107
109
|
digest: string
|
|
110
|
+
surfaces: Map<string, ObjcSurface>
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
function exec(file: string, args: string[], cwd?: string): string {
|
|
@@ -397,13 +400,13 @@ export function binaryHeaderSearchPaths(
|
|
|
397
400
|
): { frameworks: string[]; headers: string[] } {
|
|
398
401
|
const artifact = xcframework(binary)
|
|
399
402
|
const slice = simulatorSlice(artifact.dir)
|
|
400
|
-
const found = surfaces(artifact.dir, slice)
|
|
403
|
+
const found = surfaces(artifact.dir, binary.target, slice)
|
|
401
404
|
const frameworks = [
|
|
402
405
|
...new Set(
|
|
403
406
|
found.flatMap((surface) =>
|
|
404
407
|
'modulemap' in surface &&
|
|
405
408
|
path.basename(path.dirname(surface.modulemap)) === 'Modules'
|
|
406
|
-
? [path.dirname(
|
|
409
|
+
? [path.dirname(surface.headers)]
|
|
407
410
|
: [],
|
|
408
411
|
),
|
|
409
412
|
),
|
|
@@ -496,8 +499,21 @@ export function binaryHeaderSearchPaths(
|
|
|
496
499
|
path.join(pending, 'frameworks', path.basename(framework), part),
|
|
497
500
|
{ recursive: true, dereference: true },
|
|
498
501
|
)
|
|
502
|
+
const surface = found.find(
|
|
503
|
+
(item) => 'headers' in item && path.dirname(item.headers) === framework,
|
|
504
|
+
)
|
|
505
|
+
if (surface && 'modulemap' in surface) {
|
|
506
|
+
const modules = path.join(
|
|
507
|
+
pending,
|
|
508
|
+
'frameworks',
|
|
509
|
+
path.basename(framework),
|
|
510
|
+
'Modules',
|
|
511
|
+
)
|
|
512
|
+
fs.mkdirSync(modules, { recursive: true })
|
|
513
|
+
fs.copyFileSync(surface.modulemap, path.join(modules, 'module.modulemap'))
|
|
514
|
+
}
|
|
499
515
|
}
|
|
500
|
-
for (const [index, directory] of headers.entries())
|
|
516
|
+
for (const [index, directory] of headers.entries()) {
|
|
501
517
|
fs.cpSync(directory, path.join(pending, 'headers', String(index)), {
|
|
502
518
|
recursive: true,
|
|
503
519
|
dereference: true,
|
|
@@ -511,6 +527,15 @@ export function binaryHeaderSearchPaths(
|
|
|
511
527
|
}
|
|
512
528
|
: {}),
|
|
513
529
|
})
|
|
530
|
+
const surface = found.find(
|
|
531
|
+
(item) => 'headers' in item && item.headers === directory,
|
|
532
|
+
)
|
|
533
|
+
if (surface && 'modulemap' in surface)
|
|
534
|
+
fs.copyFileSync(
|
|
535
|
+
surface.modulemap,
|
|
536
|
+
path.join(pending, 'headers', String(index), 'module.modulemap'),
|
|
537
|
+
)
|
|
538
|
+
}
|
|
514
539
|
const contents = createHash('sha256')
|
|
515
540
|
for (const relative of fs
|
|
516
541
|
.readdirSync(pending, { recursive: true, encoding: 'utf8' })
|
|
@@ -599,6 +624,7 @@ function simulatorSlice(xcframeworkDir: string): string | null {
|
|
|
599
624
|
|
|
600
625
|
function surfaces(
|
|
601
626
|
xcframeworkDir: string,
|
|
627
|
+
target: string,
|
|
602
628
|
slice = simulatorSlice(xcframeworkDir),
|
|
603
629
|
): SliceSurface[] {
|
|
604
630
|
const standaloneMap = path.join(xcframeworkDir, 'module.modulemap')
|
|
@@ -627,7 +653,20 @@ function surfaces(
|
|
|
627
653
|
)
|
|
628
654
|
const chosen =
|
|
629
655
|
interfaces.find((name) => name.startsWith('arm64-')) ?? interfaces[0] ?? null
|
|
630
|
-
|
|
656
|
+
let modulemap = path.join(framework, 'Modules', 'module.modulemap')
|
|
657
|
+
const headers = path.join(framework, 'Headers')
|
|
658
|
+
if (
|
|
659
|
+
!fs.existsSync(modulemap) &&
|
|
660
|
+
files(headers, (name) => name.endsWith('.h')).length
|
|
661
|
+
) {
|
|
662
|
+
const umbrella = fs.existsSync(path.join(headers, `${module}.h`))
|
|
663
|
+
? `umbrella header "${module}.h"`
|
|
664
|
+
: 'umbrella "Headers"'
|
|
665
|
+
modulemap = generatedModuleMap(
|
|
666
|
+
`framework module ${module} { ${umbrella} export * module * { export * } }\n`,
|
|
667
|
+
true,
|
|
668
|
+
)
|
|
669
|
+
}
|
|
631
670
|
if (chosen) {
|
|
632
671
|
const privateInterface = path.join(
|
|
633
672
|
swiftmodule,
|
|
@@ -666,9 +705,34 @@ function surfaces(
|
|
|
666
705
|
const module = moduleMapName(fs.readFileSync(modulemap, 'utf8'))
|
|
667
706
|
if (module) found.push(headerSurface(module, modulemap, path.dirname(modulemap)))
|
|
668
707
|
}
|
|
708
|
+
if (found.length === 0 && files(headers, (name) => name.endsWith('.h')).length) {
|
|
709
|
+
const module = swiftTargetModuleName(target)
|
|
710
|
+
const modulemap = generatedModuleMap(
|
|
711
|
+
`module ${module} { umbrella "." export * }\n`,
|
|
712
|
+
false,
|
|
713
|
+
)
|
|
714
|
+
found.push(headerSurface(module, modulemap, headers))
|
|
715
|
+
}
|
|
669
716
|
return found
|
|
670
717
|
}
|
|
671
718
|
|
|
719
|
+
function generatedModuleMap(text: string, framework: boolean): string {
|
|
720
|
+
const dir = path.join(
|
|
721
|
+
cacheDir,
|
|
722
|
+
'modulemaps',
|
|
723
|
+
key(text),
|
|
724
|
+
framework ? 'Modules' : 'Headers',
|
|
725
|
+
)
|
|
726
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
727
|
+
const file = path.join(dir, 'module.modulemap')
|
|
728
|
+
if (!fs.existsSync(file)) {
|
|
729
|
+
const pending = `${file}.${process.pid}.tmp`
|
|
730
|
+
fs.writeFileSync(pending, text)
|
|
731
|
+
fs.renameSync(pending, file)
|
|
732
|
+
}
|
|
733
|
+
return file
|
|
734
|
+
}
|
|
735
|
+
|
|
672
736
|
// the peach modules an interface imports, compiled for wasm: a distribution
|
|
673
737
|
// ships them; a checkout builds the ones named into its own build directory,
|
|
674
738
|
// with the flags scripts/build.sh uses, so the two share one build.
|
|
@@ -890,22 +954,24 @@ function swiftStandin(
|
|
|
890
954
|
// no -Xllvm either, so the -mllvm half of the toolset's sjlj pair never reaches the
|
|
891
955
|
// backend that wraps each clang module as an object; raw modules skip it.
|
|
892
956
|
symbolgraphWasm.push('-Xcc', '-Xclang', '-Xcc', '-fmodule-format=raw')
|
|
893
|
-
exec(
|
|
894
|
-
'-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
957
|
+
exec(
|
|
958
|
+
...withoutCoreDump(path.join(toolchain.toolchainBin, 'swift-symbolgraph-extract'), [
|
|
959
|
+
'-module-name',
|
|
960
|
+
surface.module,
|
|
961
|
+
...symbolgraphWasm,
|
|
962
|
+
'-I',
|
|
963
|
+
search,
|
|
964
|
+
// at public the graph drops underscored public declarations, which other
|
|
965
|
+
// public ones name; the emitter keeps only public and open symbols
|
|
966
|
+
'-minimum-access-level',
|
|
967
|
+
'internal',
|
|
968
|
+
'-include-spi-symbols',
|
|
969
|
+
'-skip-synthesized-members',
|
|
970
|
+
'-omit-extension-block-symbols',
|
|
971
|
+
'-output-dir',
|
|
972
|
+
out,
|
|
973
|
+
]),
|
|
974
|
+
)
|
|
909
975
|
const graphs = fs
|
|
910
976
|
.readdirSync(out)
|
|
911
977
|
.filter((name) => name.endsWith('.symbols.json'))
|
|
@@ -1250,6 +1316,8 @@ function objcStandin(
|
|
|
1250
1316
|
toolchain: Toolchain,
|
|
1251
1317
|
work: string,
|
|
1252
1318
|
behavior: ReadonlyMap<string, StandinBehavior>,
|
|
1319
|
+
frameworks: NativeFrameworkInputs,
|
|
1320
|
+
siblings: ReadonlySet<string>,
|
|
1253
1321
|
): SwiftStandin {
|
|
1254
1322
|
const view = objcView(
|
|
1255
1323
|
surface,
|
|
@@ -1257,13 +1325,35 @@ function objcStandin(
|
|
|
1257
1325
|
path.join(toolchain.moduleRoot, 'ios-simulator-stdlib'),
|
|
1258
1326
|
cacheDir,
|
|
1259
1327
|
path.join(work, 'objc'),
|
|
1328
|
+
undefined,
|
|
1329
|
+
frameworks.dirs,
|
|
1260
1330
|
)
|
|
1261
1331
|
// the modules its headers import carry the types its declarations name; a
|
|
1262
1332
|
// module peach does not ship stays unimported and drops what needs it
|
|
1263
1333
|
const provided = new Set(swiftPeachModules(toolchain.moduleRoot))
|
|
1264
1334
|
const headerModules = view.imports.filter(
|
|
1265
|
-
(name) =>
|
|
1335
|
+
(name) =>
|
|
1336
|
+
!STANDIN_IMPORTS.includes(name) && (provided.has(name) || siblings.has(name)),
|
|
1266
1337
|
)
|
|
1338
|
+
const dependencyGraphs = headerModules.flatMap((module) => {
|
|
1339
|
+
const dependency = frameworks.surfaces.get(module)
|
|
1340
|
+
if (!dependency || module === surface.module) return []
|
|
1341
|
+
return objcView(
|
|
1342
|
+
{
|
|
1343
|
+
module: dependency.module,
|
|
1344
|
+
modulemap: dependency.modulemap,
|
|
1345
|
+
headers: dependency.headers,
|
|
1346
|
+
},
|
|
1347
|
+
toolchain.toolchainBin,
|
|
1348
|
+
path.join(toolchain.moduleRoot, 'ios-simulator-stdlib'),
|
|
1349
|
+
cacheDir,
|
|
1350
|
+
path.join(work, 'dependencies', module),
|
|
1351
|
+
undefined,
|
|
1352
|
+
frameworks.dirs.filter(
|
|
1353
|
+
(dir) => !fs.existsSync(path.join(dir, `${module}.framework`)),
|
|
1354
|
+
),
|
|
1355
|
+
).graphs
|
|
1356
|
+
})
|
|
1267
1357
|
return graphStandin(
|
|
1268
1358
|
surface.module,
|
|
1269
1359
|
view.graphs,
|
|
@@ -1281,6 +1371,12 @@ function objcStandin(
|
|
|
1281
1371
|
) ?? []),
|
|
1282
1372
|
]),
|
|
1283
1373
|
],
|
|
1374
|
+
false,
|
|
1375
|
+
new Map(),
|
|
1376
|
+
null,
|
|
1377
|
+
new Map(),
|
|
1378
|
+
new Map(),
|
|
1379
|
+
dependencyGraphs,
|
|
1284
1380
|
)
|
|
1285
1381
|
}
|
|
1286
1382
|
|
|
@@ -1309,6 +1405,7 @@ function graphStandin(
|
|
|
1309
1405
|
placeholder: { peachImports: string[]; exported: string[] } | null = null,
|
|
1310
1406
|
inheritedConformances: ReadonlyMap<string, ReadonlySet<string>> = new Map(),
|
|
1311
1407
|
projections: ReadonlyMap<string, string> = new Map(),
|
|
1408
|
+
dependencyGraphs: SymbolGraph[] = [],
|
|
1312
1409
|
): SwiftStandin {
|
|
1313
1410
|
const paths = new Set(
|
|
1314
1411
|
graphs.flatMap((graph) =>
|
|
@@ -1378,6 +1475,7 @@ function graphStandin(
|
|
|
1378
1475
|
objcProperties,
|
|
1379
1476
|
inheritedConformances,
|
|
1380
1477
|
projections,
|
|
1478
|
+
dependencyGraphs,
|
|
1381
1479
|
...(placeholder
|
|
1382
1480
|
? { exported: placeholder.exported, placeholder: binary.placeholder!.gap }
|
|
1383
1481
|
: {}),
|
|
@@ -2200,6 +2298,11 @@ async function sourceStandins(
|
|
|
2200
2298
|
})),
|
|
2201
2299
|
})
|
|
2202
2300
|
} else {
|
|
2301
|
+
const absent = missingArtifactGap(binary)
|
|
2302
|
+
if (absent !== null) {
|
|
2303
|
+
gaps.set(binary.target, absent)
|
|
2304
|
+
continue
|
|
2305
|
+
}
|
|
2203
2306
|
const resolved = xcframework(binary)
|
|
2204
2307
|
const dir = path.join(artifact, String(index), path.basename(resolved.dir))
|
|
2205
2308
|
fs.cpSync(resolved.dir, dir, { recursive: true, dereference: true })
|
|
@@ -2387,7 +2490,9 @@ export function standinGenerationInputs(
|
|
|
2387
2490
|
try {
|
|
2388
2491
|
return binary.publicHeaders !== undefined || binary.placeholder !== undefined
|
|
2389
2492
|
? [swiftTargetModuleName(binary.target)]
|
|
2390
|
-
: surfaces(xcframework(binary).dir).map(
|
|
2493
|
+
: surfaces(xcframework(binary).dir, binary.target).map(
|
|
2494
|
+
(surface) => surface.module,
|
|
2495
|
+
)
|
|
2391
2496
|
} catch {
|
|
2392
2497
|
return []
|
|
2393
2498
|
}
|
|
@@ -2431,7 +2536,9 @@ export function standinGenerationInputs(
|
|
|
2431
2536
|
try {
|
|
2432
2537
|
if (
|
|
2433
2538
|
binary.publicHeaders === undefined &&
|
|
2434
|
-
surfaces(xcframework(binary).dir).some(
|
|
2539
|
+
surfaces(xcframework(binary).dir, binary.target).some(
|
|
2540
|
+
(surface) => surface.kind === 'swift',
|
|
2541
|
+
)
|
|
2435
2542
|
)
|
|
2436
2543
|
parts.push(`interface-emulation/${WASI_EMULATION.join(',')}`)
|
|
2437
2544
|
parts.push(
|
|
@@ -2465,6 +2572,14 @@ export function standinGenerationInputs(
|
|
|
2465
2572
|
return createHash('sha256').update(parts.join('\0')).digest('hex')
|
|
2466
2573
|
}
|
|
2467
2574
|
|
|
2575
|
+
// a local artifact a script downloads or builds is absent from a fresh
|
|
2576
|
+
// checkout. Xcode fails on it too, and its headers alone say what the app
|
|
2577
|
+
// calls, so peach names the path and asks for the artifact
|
|
2578
|
+
function missingArtifactGap(binary: SwiftPackageBinary): string | null {
|
|
2579
|
+
if (swiftBinaryOnDisk(binary)) return null
|
|
2580
|
+
return `${path.relative(process.cwd(), binary.dir) || binary.dir} is not on disk, and Xcode fails without it too; run the script that downloads or builds it, then run again`
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2468
2583
|
// one binary target's stand-ins, or why it has none, cached by what they are
|
|
2469
2584
|
// generated from. surfaces peach already ships (by target name or by the
|
|
2470
2585
|
// module names the slice carries, which differ: _FirebaseCore vends
|
|
@@ -2479,11 +2594,8 @@ async function binaryStandins(
|
|
|
2479
2594
|
siblings: ReadonlySet<string>,
|
|
2480
2595
|
): Promise<SwiftStandin[] | string> {
|
|
2481
2596
|
if (provided.has(binary.target)) return []
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
// calls, so peach names the path and asks for the artifact
|
|
2485
|
-
if (!binary.url && !fs.existsSync(binary.dir))
|
|
2486
|
-
return `${path.relative(process.cwd(), binary.dir) || binary.dir} is not on disk, and Xcode fails without it too; run the script that downloads or builds it, then run again`
|
|
2597
|
+
const absent = missingArtifactGap(binary)
|
|
2598
|
+
if (absent !== null) return absent
|
|
2487
2599
|
fs.mkdirSync(cacheDir, { recursive: true })
|
|
2488
2600
|
const work = fs.mkdtempSync(path.join(cacheDir, 'work-'))
|
|
2489
2601
|
let all: Surface[]
|
|
@@ -2536,7 +2648,7 @@ async function binaryStandins(
|
|
|
2536
2648
|
].join('\0')
|
|
2537
2649
|
} else {
|
|
2538
2650
|
const artifact = xcframework(binary)
|
|
2539
|
-
all = surfaces(artifact.dir)
|
|
2651
|
+
all = surfaces(artifact.dir, binary.target)
|
|
2540
2652
|
digest = artifact.digest
|
|
2541
2653
|
}
|
|
2542
2654
|
} catch (error) {
|
|
@@ -2556,7 +2668,8 @@ async function binaryStandins(
|
|
|
2556
2668
|
)
|
|
2557
2669
|
hash.update(digest)
|
|
2558
2670
|
hash.update([...siblings].sort().join('\0'))
|
|
2559
|
-
if (found.some((surface) => surface.kind === 'mixed'
|
|
2671
|
+
if (found.some((surface) => surface.kind === 'mixed' || surface.kind === 'objc'))
|
|
2672
|
+
hash.update(frameworks.digest)
|
|
2560
2673
|
for (const surface of found) {
|
|
2561
2674
|
hash.update(`${surface.kind}\0${surface.module}\0`)
|
|
2562
2675
|
for (const file of surface.kind === 'swift'
|
|
@@ -2649,6 +2762,8 @@ async function binaryStandins(
|
|
|
2649
2762
|
toolchain,
|
|
2650
2763
|
dir,
|
|
2651
2764
|
new Map(Object.entries(configured.get(surface.module) ?? {})),
|
|
2765
|
+
frameworks,
|
|
2766
|
+
siblings,
|
|
2652
2767
|
)
|
|
2653
2768
|
: binary.cxxHeaders
|
|
2654
2769
|
? await cxxStandin(surface, binary, toolchain, dir)
|
|
@@ -2693,6 +2808,31 @@ export async function swiftStandins(
|
|
|
2693
2808
|
toolchain: Toolchain,
|
|
2694
2809
|
provided: ReadonlySet<string> = new Set(),
|
|
2695
2810
|
behavior: SwiftStandinBehaviors = {},
|
|
2811
|
+
): Promise<SwiftStandins> {
|
|
2812
|
+
const built = await buildStandins(binaries, toolchain, provided, behavior)
|
|
2813
|
+
return {
|
|
2814
|
+
standins: built.standins,
|
|
2815
|
+
gaps: new Map([...built.gaps].map(([target, gap]) => [target, gapText(gap)])),
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
// a gap prints inside the blocker report, so it keeps the tool's error lines
|
|
2820
|
+
// and drops compiler dumps (clang AST JSON) a failed probe printed with them.
|
|
2821
|
+
function gapText(gap: string): string {
|
|
2822
|
+
const lines = gap
|
|
2823
|
+
.split('\n')
|
|
2824
|
+
.map((line) => line.trim())
|
|
2825
|
+
.filter((line) => line && !/^[{[\]}",]/.test(line) && !/"kind":/.test(line))
|
|
2826
|
+
const errors = lines.filter((line) => /\berror:/.test(line))
|
|
2827
|
+
const text = (errors.length > 0 ? errors : lines).slice(0, 4).join('; ')
|
|
2828
|
+
return text.length > 600 ? `${text.slice(0, 600)}…` : text
|
|
2829
|
+
}
|
|
2830
|
+
|
|
2831
|
+
async function buildStandins(
|
|
2832
|
+
binaries: readonly SwiftPackageBinary[],
|
|
2833
|
+
toolchain: Toolchain,
|
|
2834
|
+
provided: ReadonlySet<string>,
|
|
2835
|
+
behavior: SwiftStandinBehaviors,
|
|
2696
2836
|
): Promise<SwiftStandins> {
|
|
2697
2837
|
const requested = binaries.filter((binary) => !provided.has(binary.target))
|
|
2698
2838
|
if (requested.length === 0) return { standins: [], gaps: new Map() }
|
|
@@ -2710,6 +2850,7 @@ export async function swiftStandins(
|
|
|
2710
2850
|
fs.mkdirSync(cacheDir, { recursive: true })
|
|
2711
2851
|
const modules = fs.mkdtempSync(path.join(cacheDir, 'modules-'))
|
|
2712
2852
|
const frameworkDirs = new Set<string>()
|
|
2853
|
+
const frameworkSurfaces = new Map<string, ObjcSurface>()
|
|
2713
2854
|
const frameworkInputs: string[] = []
|
|
2714
2855
|
const byModule = new Map(
|
|
2715
2856
|
binaries.map((binary) => [swiftTargetModuleName(binary.target), binary]),
|
|
@@ -2734,18 +2875,31 @@ export async function swiftStandins(
|
|
|
2734
2875
|
frameworkInputs.push(`${binary.target}\0${artifact.digest}`)
|
|
2735
2876
|
const imports = new Set<string>()
|
|
2736
2877
|
interfaceImports.set(binary, imports)
|
|
2737
|
-
for (const surface of surfaces(artifact.dir)) {
|
|
2878
|
+
for (const surface of surfaces(artifact.dir, binary.target)) {
|
|
2738
2879
|
byModule.set(surface.module, binary)
|
|
2739
2880
|
if (surface.kind === 'swift' || surface.kind === 'mixed')
|
|
2740
2881
|
for (const module of swiftImportNames(
|
|
2741
2882
|
fs.readFileSync(surface.interface, 'utf8'),
|
|
2742
2883
|
))
|
|
2743
2884
|
imports.add(module)
|
|
2885
|
+
if (surface.kind === 'objc' || surface.kind === 'mixed')
|
|
2886
|
+
for (const file of files(surface.headers, (name) => name.endsWith('.h')))
|
|
2887
|
+
for (const module of clangImportNames(
|
|
2888
|
+
fs.readFileSync(path.join(surface.headers, file), 'utf8'),
|
|
2889
|
+
))
|
|
2890
|
+
imports.add(module)
|
|
2744
2891
|
if (surface.kind === 'c') continue
|
|
2892
|
+
if (surface.kind === 'objc' || surface.kind === 'mixed')
|
|
2893
|
+
frameworkSurfaces.set(surface.module, surface)
|
|
2894
|
+
if (
|
|
2895
|
+
surface.kind !== 'swift' &&
|
|
2896
|
+
path.basename(path.dirname(surface.modulemap)) !== 'Modules'
|
|
2897
|
+
)
|
|
2898
|
+
continue
|
|
2745
2899
|
frameworkDirs.add(
|
|
2746
2900
|
surface.kind === 'swift'
|
|
2747
2901
|
? path.resolve(surface.interface, '../../../..')
|
|
2748
|
-
: path.resolve(surface.
|
|
2902
|
+
: path.resolve(surface.headers, '../..'),
|
|
2749
2903
|
)
|
|
2750
2904
|
}
|
|
2751
2905
|
} catch {
|
|
@@ -2756,6 +2910,7 @@ export async function swiftStandins(
|
|
|
2756
2910
|
const frameworks: NativeFrameworkInputs = {
|
|
2757
2911
|
dirs: [...frameworkDirs].sort(),
|
|
2758
2912
|
digest: createHash('sha256').update(frameworkInputs.sort().join('\0')).digest('hex'),
|
|
2913
|
+
surfaces: frameworkSurfaces,
|
|
2759
2914
|
}
|
|
2760
2915
|
// another binary's module a swift interface imports: its stand-in is built
|
|
2761
2916
|
// first and imported, as the vendor framework imports the other framework
|
package/src/swift-toolchain.ts
CHANGED
|
@@ -636,6 +636,12 @@ function processRuns(pid: number): boolean {
|
|
|
636
636
|
}
|
|
637
637
|
}
|
|
638
638
|
|
|
639
|
+
/** a crashed swift tool dumps a core file the size of its memory into its
|
|
640
|
+
* working directory, which is the caller's repository. */
|
|
641
|
+
export function withoutCoreDump(file: string, args: string[]): [string, string[]] {
|
|
642
|
+
return ['/bin/sh', ['-c', 'ulimit -c 0; exec "$@"', 'sh', file, ...args]]
|
|
643
|
+
}
|
|
644
|
+
|
|
639
645
|
/** every swift child's temporary and xdg paths stay in peach's cache. only
|
|
640
646
|
* linux changes HOME; macOS keeps its account and idiomatic SDK discovery. */
|
|
641
647
|
export function swiftEnvironment(
|