peachsim 0.1.2406 → 0.1.2409
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/agent-note.ts +231 -0
- package/cli/cloud-client.ts +8 -3
- package/cli/cloud-dispatch.ts +1 -1
- package/cli/command-agent.ts +122 -0
- package/cli/commands/agent.ts +29 -26
- package/cli/commands/stream.ts +11 -7
- package/cli/main.ts +16 -2
- package/cli/outbound-endpoints.ts +15 -0
- package/cli/ws-bridge.ts +4 -1
- package/dist-lib/agent-daemon-client.cjs +23 -3
- 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 +205 -62
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +20 -1
- package/dist-lib/cloud-contract.mjs +18 -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 +1630 -1513
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +203 -60
- 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 +394 -102
- package/dist-lib/host/fetch-proxy-handler.cjs +5 -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 +392 -272
- 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 +5 -5
- 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 +70 -60
- 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 +1199 -821
- package/dist-lib/swift-compile.cjs +197 -55
- package/dist-lib/swift-compile.mjs +197 -55
- 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 +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +213 -58
- package/dist-lib/vite.cjs +5 -5
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +2 -2
- package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
- package/dist-types/packages/peach-globals/src/replayBridgeContract.d.ts +7 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/skills/peach-setup/SKILL.md +8 -3
- package/src/agent-daemon-client.ts +35 -2
- package/src/agent-prompt.ts +68 -0
- package/src/bridge-contract.ts +4 -0
- package/src/canvas-agent-note-delivery.ts +83 -0
- package/src/cloud-contract.ts +30 -0
- package/src/host/agent-host.ts +128 -18
- package/src/swift-compile.ts +124 -66
- package/src/swift-host.ts +2 -1
- package/src/swift-objc-import.ts +99 -0
- package/src/swift-packages.ts +1 -0
- package/src/swift-shared-sdk.ts +2 -1
- package/src/xcode-header-search.ts +33 -0
package/src/swift-compile.ts
CHANGED
|
@@ -63,6 +63,8 @@ import {
|
|
|
63
63
|
import { swiftObjcRootObjects } from './swift-link-roots'
|
|
64
64
|
import {
|
|
65
65
|
SWIFT_OBJC_INTEROP_FLAGS,
|
|
66
|
+
compactSwiftClangDefines,
|
|
67
|
+
compactSwiftClangOverlays,
|
|
66
68
|
swiftClangImporterFlags,
|
|
67
69
|
swiftObjCModuleMap,
|
|
68
70
|
swiftSubmoduleImports,
|
|
@@ -145,7 +147,7 @@ import {
|
|
|
145
147
|
} from './swiftRuntimeProductContract'
|
|
146
148
|
import { KEEP_WASM_NAMES, lowerWasm, WASM_LOWER_IDENTITY } from './wasm-optimize'
|
|
147
149
|
import { writeBuildFile } from './write-build-file'
|
|
148
|
-
import { writeXcodeHeaderSearch } from './xcode-header-search'
|
|
150
|
+
import { coalescibleHeaderOverlays, writeXcodeHeaderSearch } from './xcode-header-search'
|
|
149
151
|
import type { SwiftImageUpload } from './swift-submit'
|
|
150
152
|
import type { SwiftResourceBundle } from './swiftContract'
|
|
151
153
|
|
|
@@ -1611,6 +1613,15 @@ export function swiftTargetDependencies(
|
|
|
1611
1613
|
),
|
|
1612
1614
|
)
|
|
1613
1615
|
const names = new Set([...frameworks, ...targets.map((target) => target.name)])
|
|
1616
|
+
const entriesByPrefix = new Map<string, [string, string][]>(
|
|
1617
|
+
targets.map(({ path }) => [path === '.' ? '' : `${path}/`, []]),
|
|
1618
|
+
)
|
|
1619
|
+
for (const entry of Object.entries(files)) {
|
|
1620
|
+
const [file] = entry
|
|
1621
|
+
entriesByPrefix.get('')?.push(entry)
|
|
1622
|
+
for (let end = file.indexOf('/'); end !== -1; end = file.indexOf('/', end + 1))
|
|
1623
|
+
entriesByPrefix.get(file.slice(0, end + 1))?.push(entry)
|
|
1624
|
+
}
|
|
1614
1625
|
const siblings = new Map<string, string[]>()
|
|
1615
1626
|
for (const target of targets) {
|
|
1616
1627
|
const prefix = target.path === '.' ? '' : `${target.path}/`
|
|
@@ -1637,8 +1648,18 @@ export function swiftTargetDependencies(
|
|
|
1637
1648
|
: [],
|
|
1638
1649
|
),
|
|
1639
1650
|
)
|
|
1640
|
-
|
|
1641
|
-
|
|
1651
|
+
const nested =
|
|
1652
|
+
target.sources === undefined
|
|
1653
|
+
? targets.flatMap((candidate) =>
|
|
1654
|
+
candidate.name !== target.name &&
|
|
1655
|
+
candidate.path !== '.' &&
|
|
1656
|
+
candidate.path.startsWith(prefix)
|
|
1657
|
+
? [`${candidate.path}/`]
|
|
1658
|
+
: [],
|
|
1659
|
+
)
|
|
1660
|
+
: []
|
|
1661
|
+
for (const [file, contents] of entriesByPrefix.get(prefix) ?? []) {
|
|
1662
|
+
if (file === 'Package.swift') continue
|
|
1642
1663
|
const relative = file.slice(prefix.length)
|
|
1643
1664
|
if (
|
|
1644
1665
|
target.sources !== undefined &&
|
|
@@ -1654,17 +1675,7 @@ export function swiftTargetDependencies(
|
|
|
1654
1675
|
)
|
|
1655
1676
|
)
|
|
1656
1677
|
continue
|
|
1657
|
-
if (
|
|
1658
|
-
target.sources === undefined &&
|
|
1659
|
-
targets.some(
|
|
1660
|
-
(candidate) =>
|
|
1661
|
-
candidate.name !== target.name &&
|
|
1662
|
-
candidate.path !== '.' &&
|
|
1663
|
-
candidate.path.startsWith(prefix) &&
|
|
1664
|
-
file.startsWith(`${candidate.path}/`),
|
|
1665
|
-
)
|
|
1666
|
-
)
|
|
1667
|
-
continue
|
|
1678
|
+
if (nested.some((path) => file.startsWith(path))) continue
|
|
1668
1679
|
const imports = file.endsWith('.swift')
|
|
1669
1680
|
? swiftImportNames(contents)
|
|
1670
1681
|
: SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension))
|
|
@@ -1773,7 +1784,7 @@ const darwinRecordsRegion = (quoted: readonly string[]): string[] =>
|
|
|
1773
1784
|
const REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n'
|
|
1774
1785
|
|
|
1775
1786
|
/** bump with any change to the emitted multi-target manifest text. */
|
|
1776
|
-
export const MULTI_MANIFEST_VERSION =
|
|
1787
|
+
export const MULTI_MANIFEST_VERSION = 71
|
|
1777
1788
|
const SWIFT_HEADER_PRODUCTS_TARGET = 'PeachHeaderProducts'
|
|
1778
1789
|
|
|
1779
1790
|
// build-cli replaces this in every bundle; source runs read the files directly.
|
|
@@ -1978,6 +1989,7 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1978
1989
|
/** the objective-c runtime and sdk flags every original native unit compiles with. */
|
|
1979
1990
|
nativeFlags?: Map<string, string[]>
|
|
1980
1991
|
nativeImportFlags?: Map<string, string[]>
|
|
1992
|
+
coalescibleOverlays?: ReadonlySet<string>
|
|
1981
1993
|
nativeHeaderFlags?: string[]
|
|
1982
1994
|
nativeSwiftHeaderMaps?: ReadonlyMap<string, string>
|
|
1983
1995
|
nativeHeaderDeclarations?: Readonly<Record<string, readonly string[]>>
|
|
@@ -2166,7 +2178,11 @@ export function emitSwiftPackageManifest(args: {
|
|
|
2166
2178
|
!mapsPackageModule(flag) &&
|
|
2167
2179
|
!(flag === '-Xcc' && mapsPackageModule(all[index + 1] ?? '')),
|
|
2168
2180
|
)
|
|
2169
|
-
const
|
|
2181
|
+
const macros = compactSwiftClangDefines(flags)
|
|
2182
|
+
const compact = args.coalescibleOverlays
|
|
2183
|
+
? compactSwiftClangOverlays(macros, args.coalescibleOverlays)
|
|
2184
|
+
: macros
|
|
2185
|
+
const content = compact.map((flag) => JSON.stringify(flag)).join('\n') + '\n'
|
|
2170
2186
|
const digest = createHash('sha256').update(content).digest('hex')
|
|
2171
2187
|
const file = path.join(args.root, '.peach-swift-arguments', `${digest}.rsp`)
|
|
2172
2188
|
args.files.set(file, content)
|
|
@@ -2332,7 +2348,7 @@ export function emitSwiftPackageManifest(args: {
|
|
|
2332
2348
|
[...(args.native?.values() ?? [])].some((value) =>
|
|
2333
2349
|
value.late?.producers.includes(target.name),
|
|
2334
2350
|
))
|
|
2335
|
-
? `, "-emit-objc-header-path", ${JSON.stringify(path.join(args.headerDirectory, `${target.name}-Swift
|
|
2351
|
+
? `, "-emit-objc-header-path", ${JSON.stringify(path.join(args.headerDirectory, `${target.name}-Swift.original.h`))}`
|
|
2336
2352
|
: ''
|
|
2337
2353
|
const clangMode = target.cxxInterop ? '' : ', "-Xcc", "-fno-cxx-modules"'
|
|
2338
2354
|
const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`
|
|
@@ -5781,6 +5797,9 @@ export function writeSwiftProject(
|
|
|
5781
5797
|
}
|
|
5782
5798
|
|
|
5783
5799
|
const nativeFlags = native.size > 0 ? new Map<string, string[]>() : undefined
|
|
5800
|
+
const generatedOverlays = new Set(
|
|
5801
|
+
headerSearch.files.filter((file) => file.endsWith('.yaml')),
|
|
5802
|
+
)
|
|
5784
5803
|
if (nativeFlags) {
|
|
5785
5804
|
const toolchainBin = nativeToolchain()
|
|
5786
5805
|
const headers = path.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, 'darwin')
|
|
@@ -5803,8 +5822,11 @@ export function writeSwiftProject(
|
|
|
5803
5822
|
': missing or unsupported declared iOS deployment target ' +
|
|
5804
5823
|
JSON.stringify(version),
|
|
5805
5824
|
)
|
|
5825
|
+
const sdkIntake = objcSdkIntakeFlags(headers, toolchainBin, minimum)
|
|
5826
|
+
const sdkOverlay = sdkIntake.indexOf('-ivfsoverlay')
|
|
5827
|
+
if (sdkOverlay >= 0) generatedOverlays.add(sdkIntake[sdkOverlay + 1]!)
|
|
5806
5828
|
const intake = [
|
|
5807
|
-
...
|
|
5829
|
+
...sdkIntake,
|
|
5808
5830
|
'-ivfsoverlay',
|
|
5809
5831
|
headerSearch.files[0]!,
|
|
5810
5832
|
'-I',
|
|
@@ -6028,6 +6050,9 @@ export function writeSwiftProject(
|
|
|
6028
6050
|
sourceSwiftTargets: swiftTargets,
|
|
6029
6051
|
nativeFlags,
|
|
6030
6052
|
nativeImportFlags,
|
|
6053
|
+
coalescibleOverlays: nativeFlags
|
|
6054
|
+
? coalescibleHeaderOverlays(generatedOverlays)
|
|
6055
|
+
: undefined,
|
|
6031
6056
|
nativeHeaderFlags,
|
|
6032
6057
|
nativeSwiftHeaderMaps,
|
|
6033
6058
|
nativeHeaderDeclarations,
|
|
@@ -7712,6 +7737,9 @@ function compileSwiftProjectOnce(
|
|
|
7712
7737
|
{ file: string; header: string; module: boolean } | null
|
|
7713
7738
|
>()
|
|
7714
7739
|
const nativeDeclarations = new Map<string, Set<string>>()
|
|
7740
|
+
const nativeHeaders = Object.entries(input.files)
|
|
7741
|
+
.filter(([name]) => name.endsWith('.h') && !name.endsWith('-Swift.h'))
|
|
7742
|
+
.map(([, source]) => source)
|
|
7715
7743
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
7716
7744
|
if (!file.endsWith('.modulemap')) continue
|
|
7717
7745
|
const name = moduleMapName(contents)
|
|
@@ -7812,64 +7840,97 @@ function compileSwiftProjectOnce(
|
|
|
7812
7840
|
)
|
|
7813
7841
|
return value
|
|
7814
7842
|
}
|
|
7815
|
-
|
|
7843
|
+
const compileApp = async () => {
|
|
7816
7844
|
// clang consumes the real emitted headers after swift finishes.
|
|
7817
7845
|
// swiftpm's transitive swift module maps are not C declarations:
|
|
7818
7846
|
// importing them would shadow SDK modules such as ObjectiveC.
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
[
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7847
|
+
const stages = [
|
|
7848
|
+
...preparation.headerBuilds,
|
|
7849
|
+
...(preparation.nativeProductTarget
|
|
7850
|
+
? [{ target: preparation.nativeProductTarget, producers: [] }]
|
|
7851
|
+
: []),
|
|
7852
|
+
]
|
|
7853
|
+
const checkpoints = path.join(root, '.build', 'peach-product-checkpoints')
|
|
7854
|
+
const recipe = createHash('sha256')
|
|
7855
|
+
.update(hash)
|
|
7856
|
+
.update(readFileSync(path.join(root, 'Package.swift')))
|
|
7857
|
+
.update(JSON.stringify(buildArgs))
|
|
7858
|
+
.digest('hex')
|
|
7859
|
+
for (const { target, producers } of stages) {
|
|
7860
|
+
const receipt = path.join(
|
|
7861
|
+
checkpoints,
|
|
7862
|
+
createHash('sha256').update(target).digest('hex'),
|
|
7826
7863
|
)
|
|
7827
|
-
|
|
7828
|
-
const
|
|
7864
|
+
const headers = producers.map((producer) => {
|
|
7865
|
+
const stem = path.join(
|
|
7829
7866
|
root,
|
|
7830
7867
|
'.build',
|
|
7831
7868
|
'peach-cxx-headers',
|
|
7832
|
-
`${producer}-Swift
|
|
7869
|
+
`${producer}-Swift`,
|
|
7833
7870
|
)
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
:
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
...(preparation.nativeHeaderDeclarations[producer] ?? []),
|
|
7847
|
-
...nativelyDeclaredFunctions(
|
|
7848
|
-
generated,
|
|
7849
|
-
Object.entries(input.files)
|
|
7850
|
-
.filter(
|
|
7851
|
-
([name]) =>
|
|
7852
|
-
name.endsWith('.h') && !name.endsWith('-Swift.h'),
|
|
7853
|
-
)
|
|
7854
|
-
.map(([, source]) => source),
|
|
7855
|
-
),
|
|
7856
|
-
]),
|
|
7857
|
-
`#import <${producer}/${producer}.h>`,
|
|
7858
|
-
),
|
|
7871
|
+
return {
|
|
7872
|
+
producer,
|
|
7873
|
+
original: `${stem}.original.h`,
|
|
7874
|
+
emitted: `${stem}.h`,
|
|
7875
|
+
}
|
|
7876
|
+
})
|
|
7877
|
+
const fingerprint = (): string | undefined => {
|
|
7878
|
+
const digest = createHash('sha256').update(recipe)
|
|
7879
|
+
for (const { emitted } of headers) {
|
|
7880
|
+
if (!existsSync(emitted)) return
|
|
7881
|
+
digest.update(
|
|
7882
|
+
createHash('sha256').update(readFileSync(emitted)).digest(),
|
|
7859
7883
|
)
|
|
7860
7884
|
}
|
|
7885
|
+
return digest.digest('hex')
|
|
7861
7886
|
}
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7887
|
+
if (
|
|
7888
|
+
!options.project &&
|
|
7889
|
+
existsSync(receipt) &&
|
|
7890
|
+
readFileSync(receipt, 'utf8') === fingerprint()
|
|
7891
|
+
)
|
|
7892
|
+
continue
|
|
7893
|
+
if (!options.project) rmSync(receipt, { force: true })
|
|
7894
|
+
// swiftpm doesn't track custom objc header paths as outputs.
|
|
7895
|
+
for (const { producer, original } of headers)
|
|
7896
|
+
if (!existsSync(original))
|
|
7897
|
+
rmSync(
|
|
7898
|
+
path.join(
|
|
7899
|
+
root,
|
|
7900
|
+
'.build',
|
|
7901
|
+
WASM_TRIPLE,
|
|
7902
|
+
'release',
|
|
7903
|
+
'Modules',
|
|
7904
|
+
`${swiftTargetModuleName(producer)}.swiftmodule`,
|
|
7905
|
+
),
|
|
7906
|
+
{ force: true },
|
|
7907
|
+
)
|
|
7866
7908
|
await runCompiler(
|
|
7867
7909
|
swift,
|
|
7868
|
-
[...buildArgs, '--target',
|
|
7910
|
+
[...buildArgs, '--target', target],
|
|
7869
7911
|
appOptions,
|
|
7870
7912
|
SWIFTPM_PROGRESS,
|
|
7871
7913
|
SWIFTPM_NOISE,
|
|
7872
7914
|
)
|
|
7915
|
+
for (const { producer, original, emitted } of headers) {
|
|
7916
|
+
const generated = clangInterfaceHeader(readFileSync(original, 'utf8'))
|
|
7917
|
+
writeBuildFile(
|
|
7918
|
+
emitted,
|
|
7919
|
+
withoutSwiftDeclarations(
|
|
7920
|
+
swiftHeaderWithSuperclassImports(generated, frameworkInterface),
|
|
7921
|
+
new Set([
|
|
7922
|
+
...(preparation.nativeHeaderDeclarations[producer] ?? []),
|
|
7923
|
+
...nativelyDeclaredFunctions(generated, nativeHeaders),
|
|
7924
|
+
]),
|
|
7925
|
+
`#import <${producer}/${producer}.h>`,
|
|
7926
|
+
),
|
|
7927
|
+
)
|
|
7928
|
+
}
|
|
7929
|
+
if (!options.project) {
|
|
7930
|
+
mkdirSync(checkpoints, { recursive: true })
|
|
7931
|
+
writeFileSync(`${receipt}.partial`, fingerprint()!)
|
|
7932
|
+
renameSync(`${receipt}.partial`, receipt)
|
|
7933
|
+
}
|
|
7873
7934
|
}
|
|
7874
7935
|
// always let swiftpm check the full graph, including missing outputs.
|
|
7875
7936
|
await runCompiler(
|
|
@@ -7879,6 +7940,9 @@ function compileSwiftProjectOnce(
|
|
|
7879
7940
|
SWIFTPM_PROGRESS,
|
|
7880
7941
|
SWIFTPM_NOISE,
|
|
7881
7942
|
)
|
|
7943
|
+
}
|
|
7944
|
+
try {
|
|
7945
|
+
await compileApp()
|
|
7882
7946
|
} catch (error) {
|
|
7883
7947
|
const output = outputOf(error)
|
|
7884
7948
|
const moduleCache = path.join(
|
|
@@ -7894,13 +7958,7 @@ function compileSwiftProjectOnce(
|
|
|
7894
7958
|
) {
|
|
7895
7959
|
rmSync(moduleCache, { recursive: true, force: true })
|
|
7896
7960
|
try {
|
|
7897
|
-
await
|
|
7898
|
-
swift,
|
|
7899
|
-
buildArgs,
|
|
7900
|
-
appOptions,
|
|
7901
|
-
SWIFTPM_PROGRESS,
|
|
7902
|
-
SWIFTPM_NOISE,
|
|
7903
|
-
)
|
|
7961
|
+
await compileApp()
|
|
7904
7962
|
} catch (retryError) {
|
|
7905
7963
|
throw new Error(
|
|
7906
7964
|
[
|
package/src/swift-host.ts
CHANGED
|
@@ -678,7 +678,8 @@ async function swiftPackages(
|
|
|
678
678
|
// compiling, or a placeholder package's swift target: each stands in from
|
|
679
679
|
// its public surface.
|
|
680
680
|
const standinArtifact = (binary: SwiftPackageBinary) =>
|
|
681
|
-
binary.
|
|
681
|
+
!binary.rustCrate &&
|
|
682
|
+
(binary.publicHeaders === undefined || binary.unloweredSources !== undefined)
|
|
682
683
|
const artifacts = reached.filter(standinArtifact)
|
|
683
684
|
if (entry.moduleRoot && entry.provided && artifacts.length > 0) {
|
|
684
685
|
const { provided } = entry
|
package/src/swift-objc-import.ts
CHANGED
|
@@ -24,6 +24,105 @@ export function swiftClangImporterFlags(flags: readonly string[]): string[] {
|
|
|
24
24
|
)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
const CLANG_PATH_OPTIONS = new Set([
|
|
28
|
+
'-I',
|
|
29
|
+
'-F',
|
|
30
|
+
'-idirafter',
|
|
31
|
+
'-iframework',
|
|
32
|
+
'-iframeworkwithsysroot',
|
|
33
|
+
'-imacros',
|
|
34
|
+
'-include',
|
|
35
|
+
'-iprefix',
|
|
36
|
+
'-iquote',
|
|
37
|
+
'-isystem',
|
|
38
|
+
'-isysroot',
|
|
39
|
+
'-ivfsoverlay',
|
|
40
|
+
'-iwithprefix',
|
|
41
|
+
'-iwithprefixbefore',
|
|
42
|
+
'--sysroot',
|
|
43
|
+
])
|
|
44
|
+
|
|
45
|
+
export function compactSwiftClangDefines(flags: string[]): string[] {
|
|
46
|
+
const definitions = new Map<string, string | null>()
|
|
47
|
+
const macros: { index: number; name: string; flag: string }[] = []
|
|
48
|
+
for (let index = 0; index < flags.length; index++) {
|
|
49
|
+
if (flags[index]!.startsWith('@')) return flags
|
|
50
|
+
if (flags[index] !== '-Xcc') continue
|
|
51
|
+
const flag = flags[++index]
|
|
52
|
+
if (
|
|
53
|
+
flag === undefined ||
|
|
54
|
+
flags[index - 2] === '-Xfrontend' ||
|
|
55
|
+
flag === '-Xclang' ||
|
|
56
|
+
flag === '-Xpreprocessor' ||
|
|
57
|
+
flag.startsWith('-Wp,') ||
|
|
58
|
+
flag.startsWith('--config') ||
|
|
59
|
+
flag.startsWith('@')
|
|
60
|
+
)
|
|
61
|
+
return flags
|
|
62
|
+
if (CLANG_PATH_OPTIONS.has(flag) && flags[index + 1] === '-Xcc') {
|
|
63
|
+
index += 2
|
|
64
|
+
continue
|
|
65
|
+
}
|
|
66
|
+
if (!flag.startsWith('-D') && !flag.startsWith('-U')) continue
|
|
67
|
+
const name = /^-[DU]([A-Za-z_$][\w$]*)(?=[(=]|$)/.exec(flag)?.[1]
|
|
68
|
+
if (!name) return flags
|
|
69
|
+
const previous = definitions.get(name)
|
|
70
|
+
definitions.set(name, previous === undefined || previous === flag ? flag : null)
|
|
71
|
+
macros.push({ index, name, flag })
|
|
72
|
+
}
|
|
73
|
+
// clang hashes repeated preprocessor options even when they define the same macro.
|
|
74
|
+
const seen = new Set<string>()
|
|
75
|
+
const duplicates = new Set<number>()
|
|
76
|
+
for (const { index, name, flag } of macros) {
|
|
77
|
+
if (definitions.get(name) !== flag) continue
|
|
78
|
+
if (seen.has(name)) {
|
|
79
|
+
duplicates.add(index - 1)
|
|
80
|
+
duplicates.add(index)
|
|
81
|
+
}
|
|
82
|
+
seen.add(name)
|
|
83
|
+
}
|
|
84
|
+
return duplicates.size === 0
|
|
85
|
+
? flags
|
|
86
|
+
: flags.filter((_, index) => !duplicates.has(index))
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function compactSwiftClangOverlays(
|
|
90
|
+
flags: string[],
|
|
91
|
+
generated: ReadonlySet<string>,
|
|
92
|
+
): string[] {
|
|
93
|
+
if (generated.size === 0) return flags
|
|
94
|
+
const overlays = new Map<string, number>()
|
|
95
|
+
const duplicates = new Set<number>()
|
|
96
|
+
for (let index = 0; index < flags.length; index++) {
|
|
97
|
+
const flag = flags[index]!
|
|
98
|
+
if (flag.startsWith('@')) return flags
|
|
99
|
+
if (flag === '-Xcc' && flags[index - 1] === '-Xfrontend') return flags
|
|
100
|
+
if (
|
|
101
|
+
flags[index - 1] === '-Xcc' &&
|
|
102
|
+
(flag.startsWith('--config') || flag === '-Xclang')
|
|
103
|
+
)
|
|
104
|
+
return flags
|
|
105
|
+
if (!flag.startsWith('-ivfsoverlay') && !flag.startsWith('-vfsoverlay')) continue
|
|
106
|
+
if (
|
|
107
|
+
flag !== '-ivfsoverlay' ||
|
|
108
|
+
flags[index - 1] !== '-Xcc' ||
|
|
109
|
+
flags[index + 1] !== '-Xcc'
|
|
110
|
+
)
|
|
111
|
+
return flags
|
|
112
|
+
const file = flags[index + 2]
|
|
113
|
+
if (file === undefined || !generated.has(file)) return flags
|
|
114
|
+
const previous = overlays.get(file)
|
|
115
|
+
// later clang overlays take precedence.
|
|
116
|
+
if (previous !== undefined)
|
|
117
|
+
for (let offset = -1; offset < 3; offset++) duplicates.add(previous + offset)
|
|
118
|
+
overlays.set(file, index)
|
|
119
|
+
index += 2
|
|
120
|
+
}
|
|
121
|
+
return duplicates.size === 0
|
|
122
|
+
? flags
|
|
123
|
+
: flags.filter((_, index) => !duplicates.has(index))
|
|
124
|
+
}
|
|
125
|
+
|
|
27
126
|
// swift names a header's submodule as `import Module.Header`, which xcode
|
|
28
127
|
// infers for every header of a framework. a header an app source imports that
|
|
29
128
|
// way becomes its own submodule, visible with the module; the rest stay in it.
|
package/src/swift-packages.ts
CHANGED
|
@@ -493,6 +493,7 @@ const checkoutKey = (dir: string, pin: Pin) => `${dir}\0${pin.revision}`
|
|
|
493
493
|
// `checkout FETCH_HEAD`) must still be the pin.
|
|
494
494
|
function fetchedCheckout(checkouts: string, identity: string, pin: Pin): string {
|
|
495
495
|
const dir = path.join(checkouts, identity)
|
|
496
|
+
if (preparedSwiftPin(checkouts, identity, pin.location, pin.revision)) return dir
|
|
496
497
|
const head = path.join(dir, '.git', 'HEAD')
|
|
497
498
|
if (
|
|
498
499
|
!verified.has(checkoutKey(dir, pin)) ||
|
package/src/swift-shared-sdk.ts
CHANGED
|
@@ -263,7 +263,7 @@ export function swiftSharedSdkViewOptions(
|
|
|
263
263
|
.sort()
|
|
264
264
|
const key = JSON.stringify([
|
|
265
265
|
// bump the recipe when the transformation changes; bundling changes function text.
|
|
266
|
-
'
|
|
266
|
+
'v25',
|
|
267
267
|
[...WEAKEN_FOUNDATION_SYMS],
|
|
268
268
|
toolchainBin,
|
|
269
269
|
sdk,
|
|
@@ -339,6 +339,7 @@ export function swiftSharedSdkViewOptions(
|
|
|
339
339
|
'objc/NSObject.h',
|
|
340
340
|
'ObjectiveC.apinotes',
|
|
341
341
|
'net/if.h',
|
|
342
|
+
'netinet/tcp.h',
|
|
342
343
|
'notify.h',
|
|
343
344
|
'notify.modulemap',
|
|
344
345
|
'module.modulemap',
|
|
@@ -8,6 +8,39 @@ import { caseInsensitiveHeaderOverlay } from './case-insensitive-header-overlay'
|
|
|
8
8
|
import { writeBuildFile } from './write-build-file'
|
|
9
9
|
import type { SwiftNativeHeaderMap } from './swiftContract'
|
|
10
10
|
|
|
11
|
+
type OverlayEntry =
|
|
12
|
+
| { name: string; type: 'directory'; contents: OverlayEntry[] }
|
|
13
|
+
| { name: string; type: 'file'; 'external-contents': string }
|
|
14
|
+
|
|
15
|
+
export function coalescibleHeaderOverlays(
|
|
16
|
+
files: ReadonlySet<string>,
|
|
17
|
+
): ReadonlySet<string> {
|
|
18
|
+
const aliases = new Map<string, string>()
|
|
19
|
+
const key = (file: string) => file.replace(/[A-Z]/g, (letter) => letter.toLowerCase())
|
|
20
|
+
const index = (directory: string, entry: OverlayEntry): boolean => {
|
|
21
|
+
const name = path.resolve(directory, entry.name)
|
|
22
|
+
if (entry.type === 'directory')
|
|
23
|
+
return entry.contents.every((child) => index(name, child))
|
|
24
|
+
const source = entry['external-contents']
|
|
25
|
+
const previous = aliases.get(key(name))
|
|
26
|
+
if (previous !== undefined && previous !== source) return false
|
|
27
|
+
aliases.set(key(name), source)
|
|
28
|
+
return true
|
|
29
|
+
}
|
|
30
|
+
for (const file of files) {
|
|
31
|
+
const overlay: { roots: OverlayEntry[] } = JSON.parse(fs.readFileSync(file, 'utf8'))
|
|
32
|
+
if (!overlay.roots.every((entry) => index(path.dirname(file), entry)))
|
|
33
|
+
return new Set()
|
|
34
|
+
}
|
|
35
|
+
// removing duplicate layers preserves lookup only when the overlays share
|
|
36
|
+
// mappings and their real files cannot redirect through another layer.
|
|
37
|
+
for (const file of [...files, ...aliases.values()]) {
|
|
38
|
+
const source = aliases.get(key(path.normalize(file)))
|
|
39
|
+
if (source !== undefined && source !== file) return new Set()
|
|
40
|
+
}
|
|
41
|
+
return files
|
|
42
|
+
}
|
|
43
|
+
|
|
11
44
|
// clang's header map format: case-insensitive keys hashed into a power-of-two
|
|
12
45
|
// bucket table, each value split into a prefix and suffix string.
|
|
13
46
|
function headerMap(entries: readonly (readonly [string, string])[]): Buffer {
|