peachsim 0.1.1640 → 0.1.1641
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/cli/app-stubs.ts +38 -13
- package/cli/cloud-session.ts +16 -0
- package/cli/commands/assert.ts +17 -4
- package/cli/commands/box.ts +33 -19
- package/cli/commands/doctor.ts +24 -15
- package/cli/commands/inspect/actions.ts +3 -2
- package/cli/commands/inspect/core.ts +0 -8
- package/cli/commands/inspect.ts +0 -14
- package/cli/commands/platform.ts +2 -1
- package/cli/commands/record.ts +64 -28
- package/cli/commands/swift.ts +10 -2
- package/cli/commands/three-mode.ts +4 -38
- package/cli/commands/upload.ts +8 -8
- package/cli/flow-live-status.ts +0 -2
- package/cli/main.ts +1 -1
- package/cli/ws-bridge.ts +0 -6
- package/detox/attempt-events.cjs +41 -5
- package/detox/index.ts +155 -109
- package/detox/jest-environment.cjs +5 -1
- 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 +10 -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 +2059 -1368
- 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 +572 -125
- package/dist-lib/detox/jest-environment.cjs +5 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +1837 -1164
- 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 +2290 -1616
- 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 +44 -17
- 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 +33 -13
- package/dist-lib/native-app-identity-project.cjs +7 -4
- package/dist-lib/native-app-identity-project.mjs +7 -4
- 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/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +4 -3
- package/dist-lib/sdk.mjs +4 -3
- package/dist-lib/skills.cjs +2823 -2109
- package/dist-lib/swift-compile.cjs +370 -239
- package/dist-lib/swift-compile.mjs +368 -230
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +8 -3
- package/dist-lib/swift-submit.mjs +8 -3
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1757 -1108
- 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/backend-origin.ts +8 -0
- package/src/react-native-bridge-modules.ts +89 -76
- package/src/swift-compile.ts +134 -107
- package/src/swift-distribution.lock.json +9 -8
- package/src/swift-host.ts +6 -4
- package/src/swift-objc-compile.ts +385 -193
- package/src/swift-objc-metadata.ts +204 -0
- package/src/swift-objc-sdk.ts +195 -2
- package/src/swift-package-manifest.ts +6 -3
- package/src/swift-root-lock.ts +153 -0
- package/src/swift-submit.ts +15 -2
- package/src/swiftContract.ts +12 -0
- package/src/xcode-project.ts +10 -3
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.1641 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
|
|
3
3
|
// src/swift-compile.ts
|
|
4
|
-
import { spawn as spawn2, execFileSync as
|
|
5
|
-
import { createHash as
|
|
4
|
+
import { spawn as spawn2, execFileSync as execFileSync3 } from "node:child_process";
|
|
5
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
6
6
|
import {
|
|
7
7
|
cpSync,
|
|
8
8
|
existsSync as existsSync2,
|
|
9
|
-
mkdirSync,
|
|
9
|
+
mkdirSync as mkdirSync2,
|
|
10
10
|
mkdtempSync as mkdtempSync2,
|
|
11
|
-
readFileSync as
|
|
11
|
+
readFileSync as readFileSync5,
|
|
12
12
|
readdirSync as readdirSync2,
|
|
13
13
|
realpathSync,
|
|
14
|
-
renameSync,
|
|
15
|
-
rmSync as
|
|
14
|
+
renameSync as renameSync2,
|
|
15
|
+
rmSync as rmSync3,
|
|
16
16
|
statSync,
|
|
17
|
-
writeFileSync as
|
|
17
|
+
writeFileSync as writeFileSync3
|
|
18
18
|
} from "node:fs";
|
|
19
19
|
import os2 from "node:os";
|
|
20
|
-
import
|
|
20
|
+
import path6 from "node:path";
|
|
21
21
|
|
|
22
22
|
// src/admitted-mac-build.ts
|
|
23
23
|
import { spawnSync } from "node:child_process";
|
|
@@ -733,9 +733,9 @@ var EXCERPT = /^(\s*)(\d+)( \| )(.*)$/;
|
|
|
733
733
|
var MARKER = /^(\s*)( \| )(.*)$/;
|
|
734
734
|
function designTimeDiagnostic(output, files) {
|
|
735
735
|
const rewritten = /* @__PURE__ */ new Map();
|
|
736
|
-
const linesOf = (
|
|
736
|
+
const linesOf = (path7) => {
|
|
737
737
|
const file = Object.keys(files).find(
|
|
738
|
-
(name) => name.endsWith(".swift") && (
|
|
738
|
+
(name) => name.endsWith(".swift") && (path7 === name || path7.endsWith(`/${name}`))
|
|
739
739
|
);
|
|
740
740
|
if (file === void 0) return null;
|
|
741
741
|
let lines = rewritten.get(file);
|
|
@@ -1141,6 +1141,124 @@ function swiftPackagePartition(manifest, resourcePaths = []) {
|
|
|
1141
1141
|
return targets.length === 1 && targets[0].executable && targets[0].path === "." && targets[0].languageMode === 5 && !targets[0].mainActorIsolation && !targets[0].defines?.length && !targets[0].linkedLibraries?.length && !targets[0].cxxInterop && !swiftManifestCxxLanguageStandard(manifest) ? [] : targets;
|
|
1142
1142
|
}
|
|
1143
1143
|
|
|
1144
|
+
// src/swift-root-lock.ts
|
|
1145
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
1146
|
+
import { createHash as createHash4, randomUUID as randomUUID2 } from "node:crypto";
|
|
1147
|
+
import {
|
|
1148
|
+
linkSync,
|
|
1149
|
+
mkdirSync,
|
|
1150
|
+
readFileSync as readFileSync4,
|
|
1151
|
+
renameSync,
|
|
1152
|
+
rmSync as rmSync2,
|
|
1153
|
+
writeFileSync as writeFileSync2
|
|
1154
|
+
} from "node:fs";
|
|
1155
|
+
import path5 from "node:path";
|
|
1156
|
+
var POLL_MS = 250;
|
|
1157
|
+
function processStart(pid) {
|
|
1158
|
+
try {
|
|
1159
|
+
return execFileSync2("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
1160
|
+
encoding: "utf8",
|
|
1161
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
1162
|
+
}).trim() || null;
|
|
1163
|
+
} catch {
|
|
1164
|
+
return null;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
function parseHolder(text2) {
|
|
1168
|
+
try {
|
|
1169
|
+
const value = JSON.parse(text2);
|
|
1170
|
+
if (value && typeof value === "object" && "pid" in value && typeof value.pid === "number" && "start" in value && (typeof value.start === "string" || value.start === null))
|
|
1171
|
+
return { pid: value.pid, start: value.start };
|
|
1172
|
+
} catch {
|
|
1173
|
+
}
|
|
1174
|
+
return null;
|
|
1175
|
+
}
|
|
1176
|
+
function readLock(lock) {
|
|
1177
|
+
try {
|
|
1178
|
+
return readFileSync4(lock, "utf8");
|
|
1179
|
+
} catch (error) {
|
|
1180
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
|
|
1181
|
+
throw error;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
function holderAlive(text2) {
|
|
1185
|
+
const holder = parseHolder(text2);
|
|
1186
|
+
if (!holder) return false;
|
|
1187
|
+
const start = processStart(holder.pid);
|
|
1188
|
+
return start !== null && start === holder.start;
|
|
1189
|
+
}
|
|
1190
|
+
function pause(ms, signal) {
|
|
1191
|
+
return new Promise((resolve) => {
|
|
1192
|
+
const done = () => {
|
|
1193
|
+
clearTimeout(timer);
|
|
1194
|
+
signal?.removeEventListener("abort", done);
|
|
1195
|
+
resolve();
|
|
1196
|
+
};
|
|
1197
|
+
const timer = setTimeout(done, ms);
|
|
1198
|
+
signal?.addEventListener("abort", done, { once: true });
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
async function withSwiftRootLock(root, work, signal) {
|
|
1202
|
+
const directory = path5.join(rnxHomeDir(), "cache", "swift-root-locks");
|
|
1203
|
+
mkdirSync(directory, { recursive: true });
|
|
1204
|
+
const lock = path5.join(
|
|
1205
|
+
directory,
|
|
1206
|
+
`${createHash4("sha256").update(root).digest("hex").slice(0, 32)}.lock`
|
|
1207
|
+
);
|
|
1208
|
+
const token = randomUUID2();
|
|
1209
|
+
const owner = JSON.stringify({
|
|
1210
|
+
pid: process.pid,
|
|
1211
|
+
start: processStart(process.pid),
|
|
1212
|
+
token
|
|
1213
|
+
});
|
|
1214
|
+
const pending = `${lock}.${token}`;
|
|
1215
|
+
writeFileSync2(pending, owner);
|
|
1216
|
+
try {
|
|
1217
|
+
for (; ; ) {
|
|
1218
|
+
signal?.throwIfAborted();
|
|
1219
|
+
try {
|
|
1220
|
+
linkSync(pending, lock);
|
|
1221
|
+
break;
|
|
1222
|
+
} catch (error) {
|
|
1223
|
+
if (!(error instanceof Error && "code" in error && error.code === "EEXIST"))
|
|
1224
|
+
throw error;
|
|
1225
|
+
}
|
|
1226
|
+
const held = readLock(lock);
|
|
1227
|
+
if (held === null) continue;
|
|
1228
|
+
if (holderAlive(held)) {
|
|
1229
|
+
await pause(POLL_MS, signal);
|
|
1230
|
+
continue;
|
|
1231
|
+
}
|
|
1232
|
+
const dead = `${lock}.dead-${token}`;
|
|
1233
|
+
try {
|
|
1234
|
+
renameSync(lock, dead);
|
|
1235
|
+
} catch (error) {
|
|
1236
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") continue;
|
|
1237
|
+
throw error;
|
|
1238
|
+
}
|
|
1239
|
+
try {
|
|
1240
|
+
if (readLock(dead) !== held) {
|
|
1241
|
+
try {
|
|
1242
|
+
linkSync(dead, lock);
|
|
1243
|
+
} catch (error) {
|
|
1244
|
+
if (!(error instanceof Error && "code" in error && error.code === "EEXIST"))
|
|
1245
|
+
throw error;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
} finally {
|
|
1249
|
+
rmSync2(dead, { force: true });
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
} finally {
|
|
1253
|
+
rmSync2(pending, { force: true });
|
|
1254
|
+
}
|
|
1255
|
+
try {
|
|
1256
|
+
return await work();
|
|
1257
|
+
} finally {
|
|
1258
|
+
if (readLock(lock) === owner) rmSync2(lock, { force: true });
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1144
1262
|
// src/swiftContract.ts
|
|
1145
1263
|
function isSwiftResourcePath(value) {
|
|
1146
1264
|
return typeof value === "string" && value.length <= 4096 && !value.startsWith("/") && !value.includes("\\") && !value.includes("\0") && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
@@ -1244,12 +1362,12 @@ var BUILD_JOBS = String(
|
|
|
1244
1362
|
Math.min(4, Math.max(1, Math.floor(os2.availableParallelism() / 2)))
|
|
1245
1363
|
);
|
|
1246
1364
|
function swiftDistributionAt(root) {
|
|
1247
|
-
const file =
|
|
1365
|
+
const file = path6.join(root, SWIFT_DISTRIBUTION_MANIFEST);
|
|
1248
1366
|
if (!existsSync2(file)) return null;
|
|
1249
|
-
return parseSwiftDistributionManifest(JSON.parse(
|
|
1367
|
+
return parseSwiftDistributionManifest(JSON.parse(readFileSync5(file, "utf8")));
|
|
1250
1368
|
}
|
|
1251
1369
|
function swiftModuleSdk(root) {
|
|
1252
|
-
const pin = swiftDistributionAt(root) ?? JSON.parse(
|
|
1370
|
+
const pin = swiftDistributionAt(root) ?? JSON.parse(readFileSync5(path6.join(root, "toolchain.json"), "utf8"));
|
|
1253
1371
|
if (!pin || typeof pin !== "object" || typeof Reflect.get(pin, "wasmSdkId") !== "string" || typeof Reflect.get(pin, "wasmSdkUrl") !== "string" || typeof Reflect.get(pin, "wasmSdkChecksum") !== "string")
|
|
1254
1372
|
throw new Error(`${root} pins no wasm SDK id, url and checksum`);
|
|
1255
1373
|
return {
|
|
@@ -1275,7 +1393,7 @@ function swiftModuleInputFiles(root) {
|
|
|
1275
1393
|
"toolchain.json"
|
|
1276
1394
|
];
|
|
1277
1395
|
const walk = (dir) => {
|
|
1278
|
-
for (const entry of readdirSync2(
|
|
1396
|
+
for (const entry of readdirSync2(path6.join(root, dir), {
|
|
1279
1397
|
withFileTypes: true
|
|
1280
1398
|
})) {
|
|
1281
1399
|
const relative = `${dir}/${entry.name}`;
|
|
@@ -1293,38 +1411,38 @@ function swiftMacroPlugins(moduleRoot) {
|
|
|
1293
1411
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
1294
1412
|
if (distribution)
|
|
1295
1413
|
return {
|
|
1296
|
-
libraries: distribution.plugins.map((plugin) =>
|
|
1414
|
+
libraries: distribution.plugins.map((plugin) => path6.join(moduleRoot, plugin)),
|
|
1297
1415
|
stale: false
|
|
1298
1416
|
};
|
|
1299
|
-
const dir =
|
|
1417
|
+
const dir = path6.join(moduleRoot, ".build/host/RnxPreviewMacros");
|
|
1300
1418
|
const release = JSON.parse(
|
|
1301
|
-
|
|
1419
|
+
readFileSync5(path6.join(moduleRoot, "toolchain.json"), "utf8")
|
|
1302
1420
|
).release;
|
|
1303
|
-
const compilerStamp =
|
|
1421
|
+
const compilerStamp = path6.join(dir, "compiler-release");
|
|
1304
1422
|
const ext = process.platform === "darwin" ? "dylib" : "so";
|
|
1305
1423
|
const plugins = [
|
|
1306
1424
|
{
|
|
1307
|
-
library:
|
|
1308
|
-
sources: [
|
|
1425
|
+
library: path6.join(dir, `libRnxPreviewMacros.${ext}`),
|
|
1426
|
+
sources: [path6.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
|
|
1309
1427
|
},
|
|
1310
1428
|
{
|
|
1311
|
-
library:
|
|
1429
|
+
library: path6.join(dir, `libFoundationMacros.${ext}`),
|
|
1312
1430
|
sources: [
|
|
1313
|
-
|
|
1314
|
-
|
|
1431
|
+
path6.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
|
|
1432
|
+
path6.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
|
|
1315
1433
|
]
|
|
1316
1434
|
},
|
|
1317
1435
|
{
|
|
1318
|
-
library:
|
|
1436
|
+
library: path6.join(dir, `libTipKitMacros.${ext}`),
|
|
1319
1437
|
sources: [
|
|
1320
|
-
|
|
1321
|
-
|
|
1438
|
+
path6.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
|
|
1439
|
+
path6.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
|
|
1322
1440
|
]
|
|
1323
1441
|
}
|
|
1324
1442
|
];
|
|
1325
1443
|
return {
|
|
1326
1444
|
libraries: plugins.map(({ library }) => library),
|
|
1327
|
-
stale: !existsSync2(compilerStamp) ||
|
|
1445
|
+
stale: !existsSync2(compilerStamp) || readFileSync5(compilerStamp, "utf8").trim() !== release || plugins.some(
|
|
1328
1446
|
({ library, sources }) => !existsSync2(library) || sources.some((source) => statSync(source).mtimeMs > statSync(library).mtimeMs)
|
|
1329
1447
|
)
|
|
1330
1448
|
};
|
|
@@ -1335,14 +1453,14 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal) {
|
|
|
1335
1453
|
await runCompiler(
|
|
1336
1454
|
"sh",
|
|
1337
1455
|
[
|
|
1338
|
-
|
|
1456
|
+
path6.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
1339
1457
|
toolchainBin,
|
|
1340
1458
|
libraries[0]
|
|
1341
1459
|
],
|
|
1342
1460
|
{ signal }
|
|
1343
1461
|
);
|
|
1344
|
-
|
|
1345
|
-
|
|
1462
|
+
writeFileSync3(
|
|
1463
|
+
path6.join(path6.dirname(libraries[0]), "compiler-release"),
|
|
1346
1464
|
`${release}
|
|
1347
1465
|
`
|
|
1348
1466
|
);
|
|
@@ -1356,9 +1474,9 @@ function clearLinkedModuleDigests(root) {
|
|
|
1356
1474
|
}
|
|
1357
1475
|
function swiftModuleDigest(root) {
|
|
1358
1476
|
const files = swiftModuleInputFiles(root);
|
|
1359
|
-
const stampHash =
|
|
1477
|
+
const stampHash = createHash5("sha256");
|
|
1360
1478
|
for (const file of files) {
|
|
1361
|
-
const stat = statSync(
|
|
1479
|
+
const stat = statSync(path6.join(root, file), { bigint: true });
|
|
1362
1480
|
stampHash.update(file);
|
|
1363
1481
|
stampHash.update(
|
|
1364
1482
|
`${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
|
|
@@ -1368,11 +1486,11 @@ function swiftModuleDigest(root) {
|
|
|
1368
1486
|
const stamp = stampHash.digest("hex");
|
|
1369
1487
|
const cached = linkedModuleDigests.get(root);
|
|
1370
1488
|
if (cached?.stamp === stamp) return cached.digest;
|
|
1371
|
-
const hash =
|
|
1489
|
+
const hash = createHash5("sha256");
|
|
1372
1490
|
for (const file of files) {
|
|
1373
|
-
hash.update(
|
|
1491
|
+
hash.update(createHash5("sha256").update(file).digest());
|
|
1374
1492
|
hash.update(
|
|
1375
|
-
|
|
1493
|
+
createHash5("sha256").update(readFileSync5(path6.join(root, file))).digest()
|
|
1376
1494
|
);
|
|
1377
1495
|
}
|
|
1378
1496
|
const digest = hash.digest();
|
|
@@ -1380,7 +1498,7 @@ function swiftModuleDigest(root) {
|
|
|
1380
1498
|
return digest;
|
|
1381
1499
|
}
|
|
1382
1500
|
function swiftProjectBuildKey(moduleRoot, release) {
|
|
1383
|
-
return
|
|
1501
|
+
return createHash5("sha256").update(`${release}\0${swiftModuleSdk(moduleRoot).wasmSdkId}`).update(swiftModuleDigest(moduleRoot)).digest("hex").slice(0, 32);
|
|
1384
1502
|
}
|
|
1385
1503
|
function compileTargets(input) {
|
|
1386
1504
|
const manifest = input.files["Package.swift"];
|
|
@@ -1396,7 +1514,7 @@ function withNativeSourceGlue(input, glue) {
|
|
|
1396
1514
|
...input,
|
|
1397
1515
|
files: {
|
|
1398
1516
|
...input.files,
|
|
1399
|
-
[
|
|
1517
|
+
[path6.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
|
|
1400
1518
|
},
|
|
1401
1519
|
oneModule: true
|
|
1402
1520
|
};
|
|
@@ -1521,7 +1639,7 @@ function swiftImportNames(contents, available) {
|
|
|
1521
1639
|
function swiftPeachModules(moduleRoot) {
|
|
1522
1640
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
1523
1641
|
return distribution ? distribution.modules : [
|
|
1524
|
-
...
|
|
1642
|
+
...readFileSync5(path6.join(moduleRoot, "Package.swift"), "utf8").matchAll(
|
|
1525
1643
|
/\.(?:target|systemLibrary)\(\s*name:\s*"([^"]+)"/g
|
|
1526
1644
|
)
|
|
1527
1645
|
].map((match) => match[1]);
|
|
@@ -1532,8 +1650,8 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
1532
1650
|
const key = JSON.stringify([toolchainBin, sdk, swiftSdkOptions()]);
|
|
1533
1651
|
const cached = sdkPaths.get(key);
|
|
1534
1652
|
if (cached) return cached;
|
|
1535
|
-
const configuration =
|
|
1536
|
-
|
|
1653
|
+
const configuration = execFileSync3(
|
|
1654
|
+
path6.join(toolchainBin, "swift"),
|
|
1537
1655
|
[
|
|
1538
1656
|
"sdk",
|
|
1539
1657
|
"configure",
|
|
@@ -1564,14 +1682,14 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
1564
1682
|
if (cached) return cached;
|
|
1565
1683
|
const modules = new Set(swiftPeachModules(moduleRoot));
|
|
1566
1684
|
const { resources } = swiftSdkPaths(moduleRoot, toolchainBin);
|
|
1567
|
-
for (const entry of readdirSync2(
|
|
1685
|
+
for (const entry of readdirSync2(path6.join(resources, "wasi"))) {
|
|
1568
1686
|
if (entry.endsWith(".swiftmodule"))
|
|
1569
1687
|
modules.add(entry.slice(0, -".swiftmodule".length));
|
|
1570
1688
|
}
|
|
1571
1689
|
for (const entry of readdirSync2(resources)) {
|
|
1572
|
-
const map =
|
|
1690
|
+
const map = path6.join(resources, entry, "module.modulemap");
|
|
1573
1691
|
if (!existsSync2(map)) continue;
|
|
1574
|
-
for (const match of
|
|
1692
|
+
for (const match of readFileSync5(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
|
|
1575
1693
|
modules.add(match[1]);
|
|
1576
1694
|
}
|
|
1577
1695
|
availableModules.set(key, modules);
|
|
@@ -1635,9 +1753,9 @@ var EXECUTABLE_LINK_FLAGS = ` "-Xclang-linker", "-O0",
|
|
|
1635
1753
|
`;
|
|
1636
1754
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
1637
1755
|
var MULTI_MANIFEST_VERSION = 39;
|
|
1638
|
-
var compilerSourceDigest = true ? "
|
|
1756
|
+
var compilerSourceDigest = true ? "ee2738333bb81c79211d5bee8a503c539cf65f25c95fb024c45b840450b5359e" : swiftCompilerSourceDigest(import.meta.dirname);
|
|
1639
1757
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
1640
|
-
const hash =
|
|
1758
|
+
const hash = createHash5("sha256");
|
|
1641
1759
|
hash.update(`swift-compile
|
|
1642
1760
|
${release}
|
|
1643
1761
|
`);
|
|
@@ -1645,32 +1763,32 @@ ${release}
|
|
|
1645
1763
|
if (input.oneModule) hash.update("one-module\n");
|
|
1646
1764
|
hash.update(swiftModuleDigest(moduleRoot));
|
|
1647
1765
|
for (const file of Object.keys(input.files).sort()) {
|
|
1648
|
-
hash.update(
|
|
1649
|
-
hash.update(
|
|
1766
|
+
hash.update(createHash5("sha256").update(file).digest());
|
|
1767
|
+
hash.update(createHash5("sha256").update(input.files[file]).digest());
|
|
1650
1768
|
}
|
|
1651
1769
|
for (const file of Object.keys(input.metalSources ?? {}).sort()) {
|
|
1652
1770
|
hash.update("metal-source\n");
|
|
1653
|
-
hash.update(
|
|
1771
|
+
hash.update(createHash5("sha256").update(file).digest());
|
|
1654
1772
|
hash.update(
|
|
1655
|
-
|
|
1773
|
+
createHash5("sha256").update(input.metalSources?.[file] ?? "").digest()
|
|
1656
1774
|
);
|
|
1657
1775
|
}
|
|
1658
1776
|
for (const base of Object.keys(input.resources ?? {}).sort()) {
|
|
1659
|
-
hash.update(
|
|
1777
|
+
hash.update(createHash5("sha256").update(base).digest());
|
|
1660
1778
|
hash.update(
|
|
1661
|
-
|
|
1779
|
+
createHash5("sha256").update(input.resources?.[base] ?? "").digest()
|
|
1662
1780
|
);
|
|
1663
1781
|
}
|
|
1664
1782
|
for (const name of Object.keys(input.images ?? {}).sort()) {
|
|
1665
1783
|
const image = input.images?.[name];
|
|
1666
1784
|
if (!image) continue;
|
|
1667
|
-
hash.update(
|
|
1668
|
-
hash.update(
|
|
1669
|
-
hash.update(
|
|
1785
|
+
hash.update(createHash5("sha256").update(name).digest());
|
|
1786
|
+
hash.update(createHash5("sha256").update(image.file).digest());
|
|
1787
|
+
hash.update(createHash5("sha256").update(image.data).digest());
|
|
1670
1788
|
}
|
|
1671
1789
|
for (const file of [...new Set(input.resourcePaths ?? [])].sort()) {
|
|
1672
1790
|
hash.update("resource-path\n");
|
|
1673
|
-
hash.update(
|
|
1791
|
+
hash.update(createHash5("sha256").update(file).digest());
|
|
1674
1792
|
}
|
|
1675
1793
|
hash.update(
|
|
1676
1794
|
JSON.stringify(
|
|
@@ -1682,7 +1800,7 @@ ${release}
|
|
|
1682
1800
|
${target}
|
|
1683
1801
|
`);
|
|
1684
1802
|
hash.update(
|
|
1685
|
-
|
|
1803
|
+
createHash5("sha256").update(input.libraries?.[target] ?? "").digest()
|
|
1686
1804
|
);
|
|
1687
1805
|
}
|
|
1688
1806
|
const targets = compileTargets(input);
|
|
@@ -1729,11 +1847,11 @@ function emitSwiftPackageManifest(args) {
|
|
|
1729
1847
|
distributionLink.files.set(
|
|
1730
1848
|
distributionLink.path,
|
|
1731
1849
|
objects.map(
|
|
1732
|
-
(object) => `"${
|
|
1850
|
+
(object) => `"${path6.join(moduleRoot, object).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`
|
|
1733
1851
|
).join("\n") + "\n"
|
|
1734
1852
|
);
|
|
1735
1853
|
}
|
|
1736
|
-
const overlayRoot =
|
|
1854
|
+
const overlayRoot = path6.join(
|
|
1737
1855
|
moduleRoot,
|
|
1738
1856
|
distribution ? "modules" : "cross-import-overlays"
|
|
1739
1857
|
);
|
|
@@ -1741,9 +1859,9 @@ function emitSwiftPackageManifest(args) {
|
|
|
1741
1859
|
"-Xfrontend",
|
|
1742
1860
|
"-swift-module-cross-import",
|
|
1743
1861
|
"-Xfrontend",
|
|
1744
|
-
|
|
1862
|
+
path6.basename(path6.dirname(file), ".swiftcrossimport"),
|
|
1745
1863
|
"-Xfrontend",
|
|
1746
|
-
|
|
1864
|
+
path6.join(overlayRoot, file)
|
|
1747
1865
|
]).map((flag) => `, ${JSON.stringify(flag)}`).join("");
|
|
1748
1866
|
const executable = targets.find((target) => target.executable);
|
|
1749
1867
|
if (!executable) throw new Error("swift-compile: no executable target to emit");
|
|
@@ -1753,14 +1871,14 @@ function emitSwiftPackageManifest(args) {
|
|
|
1753
1871
|
const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
|
|
1754
1872
|
const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
|
|
1755
1873
|
const defines = (target.defines ?? []).map((name) => ` .define(${JSON.stringify(name)}),`).join("");
|
|
1756
|
-
const imports = distribution ? `, "-I", ${JSON.stringify(
|
|
1874
|
+
const imports = distribution ? `, "-I", ${JSON.stringify(path6.join(moduleRoot, "modules"))}` : "";
|
|
1757
1875
|
const native = args.native?.get(target.name);
|
|
1758
1876
|
const nativeImports = (siblings.get(target.name) ?? []).filter((name) => args.native?.has(name)).map(
|
|
1759
1877
|
(name) => `, "-Xfrontend", "-import-module", "-Xfrontend", ${JSON.stringify(swiftTargetModuleName(name))}`
|
|
1760
1878
|
).join("");
|
|
1761
1879
|
const header = args.headerDirectory && [...args.native?.values() ?? []].some(
|
|
1762
1880
|
(value) => value.late?.producers.includes(target.name)
|
|
1763
|
-
) ? `, "-emit-objc-header-path", ${JSON.stringify(
|
|
1881
|
+
) ? `, "-emit-objc-header-path", ${JSON.stringify(path6.join(args.headerDirectory, `${target.name}-Swift.h`))}` : "";
|
|
1764
1882
|
const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines} .unsafeFlags(["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImports}${header}])]`;
|
|
1765
1883
|
const deps = [
|
|
1766
1884
|
...target.executable ? [...args.native?.values() ?? []].flatMap(
|
|
@@ -1775,7 +1893,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
1775
1893
|
(dependency) => OPTIONAL_FRAMEWORKS.has(dependency) && !targets.some((candidate) => candidate.name === dependency) ? distribution ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
|
|
1776
1894
|
)
|
|
1777
1895
|
].join(", ");
|
|
1778
|
-
const library = distribution && distributionLink ? ["-
|
|
1896
|
+
const library = distribution && distributionLink ? ["-Xclang-linker", `--config=${distributionLink.path}`, ...distribution.link].map((flag) => `, ${JSON.stringify(flag)}`).join("") : "";
|
|
1779
1897
|
const kind = target.executable ? ".executableTarget" : ".target";
|
|
1780
1898
|
const linkedLibraries = (target.linkedLibraries ?? []).map(
|
|
1781
1899
|
(name) => `.linkedLibrary(${JSON.stringify(name)})`
|
|
@@ -1833,21 +1951,21 @@ function emitSwiftPackageManifest(args) {
|
|
|
1833
1951
|
].join("\n");
|
|
1834
1952
|
}
|
|
1835
1953
|
function syncSwiftTree(base, files) {
|
|
1836
|
-
|
|
1954
|
+
mkdirSync2(base, { recursive: true });
|
|
1837
1955
|
const walk = (dir) => {
|
|
1838
1956
|
for (const entry of readdirSync2(dir, { withFileTypes: true })) {
|
|
1839
|
-
const full =
|
|
1957
|
+
const full = path6.join(dir, entry.name);
|
|
1840
1958
|
if (dir === base && entry.name === ".build") continue;
|
|
1841
1959
|
if (entry.isDirectory()) walk(full);
|
|
1842
|
-
else if (!files.has(full))
|
|
1960
|
+
else if (!files.has(full)) rmSync3(full, { force: true });
|
|
1843
1961
|
}
|
|
1844
1962
|
};
|
|
1845
1963
|
walk(base);
|
|
1846
1964
|
for (const [full, contents] of files) {
|
|
1847
|
-
if (existsSync2(full) && (typeof contents === "string" ?
|
|
1965
|
+
if (existsSync2(full) && (typeof contents === "string" ? readFileSync5(full, "utf8") === contents : readFileSync5(full).equals(contents)))
|
|
1848
1966
|
continue;
|
|
1849
|
-
|
|
1850
|
-
|
|
1967
|
+
mkdirSync2(path6.dirname(full), { recursive: true });
|
|
1968
|
+
writeFileSync3(full, contents);
|
|
1851
1969
|
}
|
|
1852
1970
|
}
|
|
1853
1971
|
var DIRECTIVE = /^[ \t]*#(?:if|elseif)\b/;
|
|
@@ -5560,7 +5678,7 @@ function swiftApplicationEntry(file, source) {
|
|
|
5560
5678
|
else if (source[at] === "}") depth--;
|
|
5561
5679
|
else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
|
|
5562
5680
|
return true;
|
|
5563
|
-
else if (depth === 0 &&
|
|
5681
|
+
else if (depth === 0 && path6.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
|
|
5564
5682
|
return true;
|
|
5565
5683
|
}
|
|
5566
5684
|
return false;
|
|
@@ -5660,32 +5778,32 @@ function swiftCodeScan(source) {
|
|
|
5660
5778
|
return { lineStarts: starts, tokens };
|
|
5661
5779
|
}
|
|
5662
5780
|
function prepareSwiftDependency(source, destination) {
|
|
5663
|
-
|
|
5781
|
+
rmSync3(destination, { recursive: true, force: true });
|
|
5664
5782
|
const origins = {};
|
|
5665
5783
|
const gather = (from) => {
|
|
5666
5784
|
for (const entry of readdirSync2(from, { withFileTypes: true })) {
|
|
5667
5785
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
5668
5786
|
continue;
|
|
5669
|
-
const file =
|
|
5787
|
+
const file = path6.join(from, entry.name);
|
|
5670
5788
|
if (entry.isDirectory()) gather(file);
|
|
5671
5789
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
5672
|
-
origins[
|
|
5790
|
+
origins[path6.relative(source, file)] = readFileSync5(file, "utf8");
|
|
5673
5791
|
}
|
|
5674
5792
|
};
|
|
5675
5793
|
gather(source);
|
|
5676
|
-
const manifest =
|
|
5677
|
-
const targets = existsSync2(manifest) ? swiftManifestTargets(
|
|
5794
|
+
const manifest = path6.join(source, "Package.swift");
|
|
5795
|
+
const targets = existsSync2(manifest) ? swiftManifestTargets(readFileSync5(manifest, "utf8")) : [];
|
|
5678
5796
|
const compiled = compiledSwiftSources(origins, targets);
|
|
5679
5797
|
const copy = (from, to) => {
|
|
5680
|
-
|
|
5798
|
+
mkdirSync2(to, { recursive: true });
|
|
5681
5799
|
for (const entry of readdirSync2(from, { withFileTypes: true })) {
|
|
5682
5800
|
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
5683
5801
|
continue;
|
|
5684
|
-
const file =
|
|
5685
|
-
const target =
|
|
5802
|
+
const file = path6.join(from, entry.name);
|
|
5803
|
+
const target = path6.join(to, entry.name);
|
|
5686
5804
|
if (entry.isDirectory()) copy(file, target);
|
|
5687
5805
|
else if (entry.isFile() && entry.name.endsWith(".swift"))
|
|
5688
|
-
|
|
5806
|
+
writeFileSync3(target, compiled.get(path6.relative(source, file)));
|
|
5689
5807
|
else cpSync(file, target, { verbatimSymlinks: true });
|
|
5690
5808
|
}
|
|
5691
5809
|
};
|
|
@@ -5702,7 +5820,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
5702
5820
|
const targets = distribution && compileTargets(input).length === 0 ? [
|
|
5703
5821
|
{
|
|
5704
5822
|
name: "App",
|
|
5705
|
-
path:
|
|
5823
|
+
path: path6.relative(layout.root, layout.sources),
|
|
5706
5824
|
executable: true,
|
|
5707
5825
|
languageMode: 5,
|
|
5708
5826
|
mainActorIsolation: false,
|
|
@@ -5711,7 +5829,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
5711
5829
|
] : compileTargets(input);
|
|
5712
5830
|
const files = /* @__PURE__ */ new Map();
|
|
5713
5831
|
const native = /* @__PURE__ */ new Map();
|
|
5714
|
-
const headerDirectory =
|
|
5832
|
+
const headerDirectory = path6.join(layout.root, ".build", "peach-cxx-headers");
|
|
5715
5833
|
for (const target of targets) {
|
|
5716
5834
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
5717
5835
|
const entries = Object.entries(input.files).filter(
|
|
@@ -5734,7 +5852,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
5734
5852
|
if (producer && targets.some((value) => value.name === producer))
|
|
5735
5853
|
producers.add(producer);
|
|
5736
5854
|
const local = [
|
|
5737
|
-
|
|
5855
|
+
path6.posix.join(path6.posix.dirname(file), include),
|
|
5738
5856
|
`${includes}${include}`
|
|
5739
5857
|
].find((candidate) => input.files[candidate] !== void 0);
|
|
5740
5858
|
if (local) {
|
|
@@ -5756,7 +5874,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
5756
5874
|
const late = units.filter(([file]) => consumers.get(file).size > 0);
|
|
5757
5875
|
native.set(target.name, {
|
|
5758
5876
|
path: target.path,
|
|
5759
|
-
includeDirectory:
|
|
5877
|
+
includeDirectory: path6.join(layout.root, includes),
|
|
5760
5878
|
lateSources: late.map(([file]) => file.slice(prefix.length)),
|
|
5761
5879
|
...late.length > 0 ? {
|
|
5762
5880
|
late: {
|
|
@@ -5773,7 +5891,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
5773
5891
|
([file]) => file.startsWith(includes) && /\.(?:h|hpp|hh|hxx)$/.test(file) && consumers.get(file).size === 0
|
|
5774
5892
|
);
|
|
5775
5893
|
files.set(
|
|
5776
|
-
|
|
5894
|
+
path6.join(layout.root, includes, "module.modulemap"),
|
|
5777
5895
|
[
|
|
5778
5896
|
`module ${target.name} {`,
|
|
5779
5897
|
...roots.map(
|
|
@@ -5785,14 +5903,14 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
5785
5903
|
].join("\n")
|
|
5786
5904
|
);
|
|
5787
5905
|
}
|
|
5788
|
-
if (native.size > 0)
|
|
5789
|
-
const modulePlan =
|
|
5906
|
+
if (native.size > 0) mkdirSync2(headerDirectory, { recursive: true });
|
|
5907
|
+
const modulePlan = createHash5("sha256").update(
|
|
5790
5908
|
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
5791
5909
|
);
|
|
5792
5910
|
if (!distribution) {
|
|
5793
|
-
modulePlan.update(
|
|
5911
|
+
modulePlan.update(readFileSync5(path6.join(moduleRoot, "Package.swift")));
|
|
5794
5912
|
}
|
|
5795
|
-
const resourcePlan =
|
|
5913
|
+
const resourcePlan = createHash5("sha256").update(
|
|
5796
5914
|
JSON.stringify(
|
|
5797
5915
|
resourceTargets.filter((target) => target.resources).map((target) => [
|
|
5798
5916
|
target.name,
|
|
@@ -5817,10 +5935,10 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
5817
5935
|
if (targets.length === 0) {
|
|
5818
5936
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
5819
5937
|
if (file === "Package.swift") continue;
|
|
5820
|
-
files.set(
|
|
5938
|
+
files.set(path6.join(layout.sources, file), compiled.get(file) ?? contents);
|
|
5821
5939
|
}
|
|
5822
|
-
let manifest =
|
|
5823
|
-
|
|
5940
|
+
let manifest = readFileSync5(
|
|
5941
|
+
path6.join(moduleRoot, "scripts/contrast-app-Package.swift"),
|
|
5824
5942
|
"utf8"
|
|
5825
5943
|
).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
|
|
5826
5944
|
const reactor = ` ${REACTOR_FLAG}`;
|
|
@@ -5864,21 +5982,21 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
5864
5982
|
manifest = manifest.replace(anchor, `${anchor}
|
|
5865
5983
|
${SPRITEKIT_PRODUCT},`);
|
|
5866
5984
|
}
|
|
5867
|
-
files.set(
|
|
5985
|
+
files.set(path6.join(layout.root, "Package.swift"), manifest + moduleFiles);
|
|
5868
5986
|
} else {
|
|
5869
5987
|
const base = layout.multi ? layout.root : layout.sources;
|
|
5870
5988
|
const libraries = /* @__PURE__ */ new Map();
|
|
5871
5989
|
for (const [target, data] of Object.entries(input.libraries ?? {})) {
|
|
5872
|
-
const file =
|
|
5990
|
+
const file = path6.join(layout.root, ".peach-libraries", `lib${target}.a`);
|
|
5873
5991
|
files.set(file, Buffer.from(data, "base64"));
|
|
5874
5992
|
libraries.set(target, file);
|
|
5875
5993
|
}
|
|
5876
5994
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
5877
5995
|
if (file === "Package.swift") continue;
|
|
5878
|
-
files.set(
|
|
5996
|
+
files.set(path6.join(base, file), compiled.get(file) ?? contents);
|
|
5879
5997
|
}
|
|
5880
5998
|
files.set(
|
|
5881
|
-
|
|
5999
|
+
path6.join(layout.root, "Package.swift"),
|
|
5882
6000
|
emitSwiftPackageManifest({
|
|
5883
6001
|
targets,
|
|
5884
6002
|
native,
|
|
@@ -5895,7 +6013,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
5895
6013
|
spriteKit: importsSpriteKit(input.files),
|
|
5896
6014
|
distribution: distribution ?? void 0,
|
|
5897
6015
|
distributionLink: {
|
|
5898
|
-
path:
|
|
6016
|
+
path: path6.join(layout.root, ".peach-distribution-objects.rsp"),
|
|
5899
6017
|
files
|
|
5900
6018
|
},
|
|
5901
6019
|
libraries
|
|
@@ -5911,9 +6029,9 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
5911
6029
|
throw new Error(
|
|
5912
6030
|
`swift resource target ${target.name} has no matching bundle assignment`
|
|
5913
6031
|
);
|
|
5914
|
-
const directory = layout.multi ?
|
|
6032
|
+
const directory = layout.multi ? path6.join(layout.root, target.path) : layout.sources;
|
|
5915
6033
|
files.set(
|
|
5916
|
-
|
|
6034
|
+
path6.join(directory, "ResourceBundleAccessor.generated.swift"),
|
|
5917
6035
|
[
|
|
5918
6036
|
"import Foundation",
|
|
5919
6037
|
"",
|
|
@@ -5946,13 +6064,13 @@ function outputOf(error) {
|
|
|
5946
6064
|
return error instanceof Error ? error.message : String(error);
|
|
5947
6065
|
}
|
|
5948
6066
|
function builtArtifact(layout) {
|
|
5949
|
-
const binDir =
|
|
5950
|
-
const manifest =
|
|
6067
|
+
const binDir = path6.join(layout.root, ".build", WASM_TRIPLE, "release");
|
|
6068
|
+
const manifest = readFileSync5(path6.join(layout.root, "Package.swift"), "utf8");
|
|
5951
6069
|
const executable = swiftManifestTargets(manifest).find((target) => target.executable);
|
|
5952
6070
|
if (executable === void 0) {
|
|
5953
6071
|
throw new Error("swift-compile: the written manifest names no executable target");
|
|
5954
6072
|
}
|
|
5955
|
-
const file =
|
|
6073
|
+
const file = path6.join(binDir, `${executable.name}.wasm`);
|
|
5956
6074
|
if (!existsSync2(file)) {
|
|
5957
6075
|
const found = existsSync2(binDir) ? readdirSync2(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
|
|
5958
6076
|
throw new Error(
|
|
@@ -5963,7 +6081,7 @@ function builtArtifact(layout) {
|
|
|
5963
6081
|
}
|
|
5964
6082
|
function projectDiagnostic(output, layout, files) {
|
|
5965
6083
|
const base = layout.multi ? layout.root : layout.sources;
|
|
5966
|
-
const prefix = `${base}${
|
|
6084
|
+
const prefix = `${base}${path6.sep}`;
|
|
5967
6085
|
return designTimeDiagnostic(output, files).split("\n").filter((line) => !SWIFTPM_NOISE.test(line)).map((line) => line.startsWith(prefix) ? line.slice(prefix.length) : line).join("\n").trim();
|
|
5968
6086
|
}
|
|
5969
6087
|
var ROOT_LOCKS = Symbol.for("peachsim.swiftCompile.rootLocks");
|
|
@@ -5999,13 +6117,13 @@ function serialize(root, work, signal) {
|
|
|
5999
6117
|
function readCompiledArtifact(directory, hash) {
|
|
6000
6118
|
try {
|
|
6001
6119
|
const receipt = JSON.parse(
|
|
6002
|
-
|
|
6120
|
+
readFileSync5(path6.join(directory, "artifact.json"), "utf8")
|
|
6003
6121
|
);
|
|
6004
6122
|
if (!receipt || typeof receipt !== "object" || !("hash" in receipt) || receipt.hash !== hash || !("icu" in receipt) || typeof receipt.icu !== "string" || !("wasm" in receipt) || typeof receipt.wasm !== "string")
|
|
6005
6123
|
return null;
|
|
6006
|
-
const bytes =
|
|
6007
|
-
const gzip2 =
|
|
6008
|
-
if (
|
|
6124
|
+
const bytes = readFileSync5(path6.join(directory, "app.wasm"));
|
|
6125
|
+
const gzip2 = readFileSync5(path6.join(directory, "icu.gz"));
|
|
6126
|
+
if (createHash5("sha256").update(bytes).digest("hex") !== receipt.wasm || createHash5("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length < 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
|
|
6009
6127
|
return null;
|
|
6010
6128
|
return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 } };
|
|
6011
6129
|
} catch (error) {
|
|
@@ -6015,25 +6133,25 @@ function readCompiledArtifact(directory, hash) {
|
|
|
6015
6133
|
}
|
|
6016
6134
|
}
|
|
6017
6135
|
function saveCompiledArtifact(root, artifact) {
|
|
6018
|
-
const directory =
|
|
6019
|
-
|
|
6020
|
-
const pending = mkdtempSync2(
|
|
6136
|
+
const directory = path6.join(root, "artifact");
|
|
6137
|
+
mkdirSync2(directory, { recursive: true });
|
|
6138
|
+
const pending = mkdtempSync2(path6.join(root, ".artifact-"));
|
|
6021
6139
|
try {
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6140
|
+
writeFileSync3(path6.join(pending, "app.wasm"), artifact.bytes);
|
|
6141
|
+
writeFileSync3(path6.join(pending, "icu.gz"), artifact.icu.gzip);
|
|
6142
|
+
writeFileSync3(
|
|
6143
|
+
path6.join(pending, "artifact.json"),
|
|
6026
6144
|
JSON.stringify({
|
|
6027
6145
|
hash: artifact.hash,
|
|
6028
|
-
wasm:
|
|
6146
|
+
wasm: createHash5("sha256").update(artifact.bytes).digest("hex"),
|
|
6029
6147
|
icu: artifact.icu.sha256
|
|
6030
6148
|
})
|
|
6031
6149
|
);
|
|
6032
6150
|
for (const file of ["app.wasm", "icu.gz", "artifact.json"]) {
|
|
6033
|
-
|
|
6151
|
+
renameSync2(path6.join(pending, file), path6.join(directory, file));
|
|
6034
6152
|
}
|
|
6035
6153
|
} finally {
|
|
6036
|
-
|
|
6154
|
+
rmSync3(pending, { recursive: true, force: true });
|
|
6037
6155
|
}
|
|
6038
6156
|
}
|
|
6039
6157
|
var retainedArtifacts = /* @__PURE__ */ new Map();
|
|
@@ -6049,17 +6167,20 @@ function retain(root, artifact) {
|
|
|
6049
6167
|
}
|
|
6050
6168
|
function compileSwiftProjectUnit(input, options) {
|
|
6051
6169
|
options.signal?.throwIfAborted();
|
|
6052
|
-
|
|
6170
|
+
mkdirSync2(options.buildRoot, { recursive: true });
|
|
6053
6171
|
const root = realpathSync(options.buildRoot);
|
|
6054
|
-
const moduleRoot =
|
|
6172
|
+
const moduleRoot = path6.resolve(options.moduleRoot);
|
|
6055
6173
|
const layout = {
|
|
6056
6174
|
root,
|
|
6057
|
-
sources:
|
|
6175
|
+
sources: path6.join(root, "Sources", "App"),
|
|
6058
6176
|
multi: compileTargets(input).length > 0
|
|
6059
6177
|
};
|
|
6060
6178
|
const hash = swiftArtifactHash(input, options.release, moduleRoot);
|
|
6061
|
-
const sharedRoot =
|
|
6062
|
-
const report = (message) =>
|
|
6179
|
+
const sharedRoot = path6.join(rnxHomeDir(), "cache", "swift-projects", hash);
|
|
6180
|
+
const report = (message) => {
|
|
6181
|
+
console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
|
|
6182
|
+
options.onStage?.(message);
|
|
6183
|
+
};
|
|
6063
6184
|
report("checking verified artifacts");
|
|
6064
6185
|
return serialize(
|
|
6065
6186
|
root,
|
|
@@ -6069,18 +6190,18 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
6069
6190
|
report("reusing memory artifact");
|
|
6070
6191
|
return retain(root, retained);
|
|
6071
6192
|
}
|
|
6072
|
-
const cached = readCompiledArtifact(
|
|
6073
|
-
const previous = cached ?? readCompiledArtifact(
|
|
6193
|
+
const cached = readCompiledArtifact(path6.join(sharedRoot, "artifact"), hash);
|
|
6194
|
+
const previous = cached ?? readCompiledArtifact(path6.join(root, "artifact"), hash);
|
|
6074
6195
|
if (previous) {
|
|
6075
6196
|
if (!cached) saveCompiledArtifact(sharedRoot, previous);
|
|
6076
6197
|
report("reusing verified disk artifact");
|
|
6077
6198
|
return retain(root, previous);
|
|
6078
6199
|
}
|
|
6079
|
-
if (process.platform === "darwin" && process.env.TM_SESSION && !admittedMacBuilderSlot() && process.env.CI !== "true" && moduleRoot ===
|
|
6080
|
-
const requestRoot = mkdtempSync2(
|
|
6081
|
-
const output =
|
|
6082
|
-
const request =
|
|
6083
|
-
|
|
6200
|
+
if (process.platform === "darwin" && process.env.TM_SESSION && !admittedMacBuilderSlot() && process.env.CI !== "true" && moduleRoot === path6.resolve(import.meta.dirname, "../../sootsim-swift") && !swiftDistributionAt(moduleRoot)) {
|
|
6201
|
+
const requestRoot = mkdtempSync2(path6.join(root, ".builder-request-"));
|
|
6202
|
+
const output = path6.join(requestRoot, "output");
|
|
6203
|
+
const request = path6.join(requestRoot, "request.json");
|
|
6204
|
+
writeFileSync3(
|
|
6084
6205
|
request,
|
|
6085
6206
|
JSON.stringify({
|
|
6086
6207
|
input,
|
|
@@ -6093,12 +6214,12 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
6093
6214
|
})
|
|
6094
6215
|
);
|
|
6095
6216
|
try {
|
|
6096
|
-
const repo =
|
|
6217
|
+
const repo = path6.resolve(moduleRoot, "../..");
|
|
6097
6218
|
report("requesting builder admission or cached result");
|
|
6098
6219
|
await runCompiler(
|
|
6099
6220
|
"bun",
|
|
6100
6221
|
[
|
|
6101
|
-
|
|
6222
|
+
path6.join(repo, "scripts/build/swift-project.ts"),
|
|
6102
6223
|
"--request",
|
|
6103
6224
|
request,
|
|
6104
6225
|
"--output",
|
|
@@ -6115,93 +6236,88 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
6115
6236
|
if (options.signal?.aborted) throw error;
|
|
6116
6237
|
throw new Error(outputOf(error), { cause: error });
|
|
6117
6238
|
});
|
|
6118
|
-
const
|
|
6119
|
-
if (!
|
|
6239
|
+
const artifact = readCompiledArtifact(output, hash);
|
|
6240
|
+
if (!artifact) {
|
|
6120
6241
|
throw new Error(
|
|
6121
6242
|
"swift-compile: builder artifact source, digest or wasm header is invalid"
|
|
6122
6243
|
);
|
|
6123
6244
|
}
|
|
6124
|
-
saveCompiledArtifact(root,
|
|
6125
|
-
saveCompiledArtifact(sharedRoot,
|
|
6245
|
+
saveCompiledArtifact(root, artifact);
|
|
6246
|
+
saveCompiledArtifact(sharedRoot, artifact);
|
|
6126
6247
|
report("builder artifact verified");
|
|
6127
|
-
return retain(root,
|
|
6248
|
+
return retain(root, artifact);
|
|
6128
6249
|
} finally {
|
|
6129
|
-
|
|
6250
|
+
rmSync3(requestRoot, { recursive: true, force: true });
|
|
6130
6251
|
}
|
|
6131
6252
|
}
|
|
6132
|
-
|
|
6133
|
-
const swift = path5.join(options.toolchainBin, "swift");
|
|
6134
|
-
if (!existsSync2(swift)) {
|
|
6135
|
-
throw new Error(
|
|
6136
|
-
`swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
|
|
6137
|
-
);
|
|
6138
|
-
}
|
|
6139
|
-
report("preparing compiler plugins");
|
|
6140
|
-
const macroPlugins = await ensureMacroPlugins(
|
|
6141
|
-
moduleRoot,
|
|
6142
|
-
options.toolchainBin,
|
|
6143
|
-
options.release,
|
|
6144
|
-
options.signal
|
|
6145
|
-
);
|
|
6146
|
-
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
|
|
6147
|
-
const icu = swiftIcuAsset(options.toolchainBin, sdk);
|
|
6148
|
-
const buildArgs = [
|
|
6149
|
-
"build",
|
|
6150
|
-
...swiftPackageCacheOptions(),
|
|
6151
|
-
"--build-system",
|
|
6152
|
-
"native",
|
|
6153
|
-
"-j",
|
|
6154
|
-
BUILD_JOBS,
|
|
6155
|
-
"--package-path",
|
|
6253
|
+
return withSwiftRootLock(
|
|
6156
6254
|
root,
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
"
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6255
|
+
async () => {
|
|
6256
|
+
const built = readCompiledArtifact(path6.join(sharedRoot, "artifact"), hash);
|
|
6257
|
+
if (built) {
|
|
6258
|
+
report("reusing verified disk artifact");
|
|
6259
|
+
return retain(root, built);
|
|
6260
|
+
}
|
|
6261
|
+
writeSwiftProject(layout, input, moduleRoot);
|
|
6262
|
+
const swift = path6.join(options.toolchainBin, "swift");
|
|
6263
|
+
if (!existsSync2(swift)) {
|
|
6264
|
+
throw new Error(
|
|
6265
|
+
`swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
|
|
6266
|
+
);
|
|
6267
|
+
}
|
|
6268
|
+
report("preparing compiler plugins");
|
|
6269
|
+
const macroPlugins = await ensureMacroPlugins(
|
|
6270
|
+
moduleRoot,
|
|
6271
|
+
options.toolchainBin,
|
|
6272
|
+
options.release,
|
|
6273
|
+
options.signal
|
|
6274
|
+
);
|
|
6275
|
+
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
|
|
6276
|
+
const icu = swiftIcuAsset(options.toolchainBin, sdk);
|
|
6277
|
+
const buildArgs = [
|
|
6278
|
+
"build",
|
|
6279
|
+
...swiftPackageCacheOptions(),
|
|
6280
|
+
"--build-system",
|
|
6281
|
+
"native",
|
|
6282
|
+
"-j",
|
|
6283
|
+
BUILD_JOBS,
|
|
6284
|
+
"--package-path",
|
|
6285
|
+
root,
|
|
6286
|
+
...swiftSdkOptions(),
|
|
6287
|
+
"--swift-sdk",
|
|
6288
|
+
sdk,
|
|
6289
|
+
"-c",
|
|
6290
|
+
"release",
|
|
6291
|
+
"-Xswiftc",
|
|
6292
|
+
"-Osize",
|
|
6293
|
+
"-Xswiftc",
|
|
6294
|
+
"-num-threads",
|
|
6295
|
+
"-Xswiftc",
|
|
6296
|
+
BUILD_JOBS,
|
|
6297
|
+
...macroPlugins.flatMap((plugin) => [
|
|
6298
|
+
"-Xswiftc",
|
|
6299
|
+
"-load-plugin-library",
|
|
6300
|
+
"-Xswiftc",
|
|
6301
|
+
plugin
|
|
6302
|
+
])
|
|
6303
|
+
];
|
|
6304
|
+
const buildOptions = {
|
|
6305
|
+
env: {
|
|
6306
|
+
...process.env,
|
|
6307
|
+
// shipped host plugins resolve against the selected compiler's runtime.
|
|
6308
|
+
...process.platform === "linux" ? {
|
|
6309
|
+
LD_LIBRARY_PATH: [
|
|
6310
|
+
path6.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
6311
|
+
path6.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
6312
|
+
process.env.LD_LIBRARY_PATH
|
|
6313
|
+
].filter(Boolean).join(":")
|
|
6314
|
+
} : {}
|
|
6315
|
+
},
|
|
6316
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
6317
|
+
timeout: options.timeoutMs,
|
|
6318
|
+
signal: options.signal
|
|
6319
|
+
};
|
|
6320
|
+
report("compiling and linking Swift modules");
|
|
6205
6321
|
try {
|
|
6206
6322
|
await runCompiler(
|
|
6207
6323
|
swift,
|
|
@@ -6210,29 +6326,51 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
6210
6326
|
SWIFTPM_PROGRESS,
|
|
6211
6327
|
SWIFTPM_NOISE
|
|
6212
6328
|
);
|
|
6213
|
-
} catch (
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6329
|
+
} catch (error) {
|
|
6330
|
+
const output = outputOf(error);
|
|
6331
|
+
const moduleCache = path6.join(
|
|
6332
|
+
root,
|
|
6333
|
+
".build",
|
|
6334
|
+
WASM_TRIPLE,
|
|
6335
|
+
"release",
|
|
6336
|
+
"ModuleCache"
|
|
6219
6337
|
);
|
|
6338
|
+
if (output.includes("was compiled with module cache path") && existsSync2(moduleCache)) {
|
|
6339
|
+
rmSync3(moduleCache, { recursive: true, force: true });
|
|
6340
|
+
try {
|
|
6341
|
+
await runCompiler(
|
|
6342
|
+
swift,
|
|
6343
|
+
buildArgs,
|
|
6344
|
+
buildOptions,
|
|
6345
|
+
SWIFTPM_PROGRESS,
|
|
6346
|
+
SWIFTPM_NOISE
|
|
6347
|
+
);
|
|
6348
|
+
} catch (retryError) {
|
|
6349
|
+
throw new Error(
|
|
6350
|
+
projectDiagnostic(outputOf(retryError), layout, input.files),
|
|
6351
|
+
{
|
|
6352
|
+
cause: retryError
|
|
6353
|
+
}
|
|
6354
|
+
);
|
|
6355
|
+
}
|
|
6356
|
+
} else {
|
|
6357
|
+
throw new Error(projectDiagnostic(output, layout, input.files), {
|
|
6358
|
+
cause: error
|
|
6359
|
+
});
|
|
6360
|
+
}
|
|
6220
6361
|
}
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
saveCompiledArtifact(sharedRoot, artifact);
|
|
6234
|
-
report("compiled artifact verified");
|
|
6235
|
-
return retain(root, artifact);
|
|
6362
|
+
const artifact = {
|
|
6363
|
+
hash,
|
|
6364
|
+
bytes: readFileSync5(builtArtifact(layout)),
|
|
6365
|
+
icu: await icu
|
|
6366
|
+
};
|
|
6367
|
+
saveCompiledArtifact(root, artifact);
|
|
6368
|
+
saveCompiledArtifact(sharedRoot, artifact);
|
|
6369
|
+
report("compiled artifact verified");
|
|
6370
|
+
return retain(root, artifact);
|
|
6371
|
+
},
|
|
6372
|
+
options.signal
|
|
6373
|
+
);
|
|
6236
6374
|
},
|
|
6237
6375
|
options.signal
|
|
6238
6376
|
);
|