MCPcopy Index your code
hub / github.com/callstack/agent-device / compileSwiftSourceText

Function compileSwiftSourceText

src/utils/swift-cache.ts:53–70  ·  view source on GitHub ↗
(params: {
  source: string;
  cacheName: string;
  timeoutMs?: number;
})

Source from the content-addressed store, hash-verified

51}
52
53export async function compileSwiftSourceText(params: {
54 source: string;
55 cacheName: string;
56 timeoutMs?: number;
57}): Promise<string> {
58 const cacheName = sanitizeCacheName(params.cacheName);
59 const key = hashParts([SWIFT_CACHE_VERSION, process.platform, process.arch, params.source]);
60 const sourcePath = path.join(getSwiftCacheRoot(), 'sources', `${cacheName}-${key}.swift`);
61 const executablePath = path.join(getSwiftCacheRoot(), 'bin', `${cacheName}-${key}`);
62
63 await ensureSwiftExecutable({
64 sourcePath,
65 executablePath,
66 sourceText: params.source,
67 timeoutMs: params.timeoutMs,
68 });
69 return executablePath;
70}
71
72function getSwiftCacheRoot(): string {
73 const configured = process.env.AGENT_DEVICE_SWIFT_CACHE_DIR?.trim();

Callers 1

Calls 4

sanitizeCacheNameFunction · 0.85
hashPartsFunction · 0.85
getSwiftCacheRootFunction · 0.85
ensureSwiftExecutableFunction · 0.85

Tested by

no test coverage detected