-
-
Notifications
You must be signed in to change notification settings - Fork 328
Expand file tree
/
Copy pathxcuitest-build-settings.ts
More file actions
46 lines (43 loc) · 1.76 KB
/
Copy pathxcuitest-build-settings.ts
File metadata and controls
46 lines (43 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// The build-recipe half of the Apple runner cache identity, in the words `xcodebuild` takes.
// `scripts/build-xcuitest-apple.sh` passes what this prints, and
// `scripts/write-xcuitest-cache-metadata.ts` records what the same resolvers return, so the
// compiler invocation and the cache identity cannot drift apart.
import { pathToFileURL } from 'node:url';
import {
isRunnerXcuitestScriptPlatform,
resolveRunnerArchBuildSettings,
resolveRunnerBundleBuildSettings,
resolveRunnerPerformanceBuildSettings,
resolveRunnerSandboxBuildArgs,
resolveRunnerScriptDevice,
resolveRunnerSigningBuildSettings,
} from '@agent-device/platform-apple/runner/operations';
const USAGE = 'Usage: xcuitest-build-settings.ts <ios|macos|tvos|visionos> <destination>';
/** The `xcodebuild` build settings `scripts/build-xcuitest-apple.sh` is about to run with. */
function resolveXcuitestBuildSettings(
platform: string,
destination: string,
env: NodeJS.ProcessEnv = process.env,
): string[] {
if (!isRunnerXcuitestScriptPlatform(platform)) {
throw new Error(`Unsupported platform: ${platform}`);
}
const device = resolveRunnerScriptDevice(platform, destination);
return [
...resolveRunnerPerformanceBuildSettings(),
...resolveRunnerArchBuildSettings(env),
...resolveRunnerSandboxBuildArgs(),
...resolveRunnerBundleBuildSettings(env),
...resolveRunnerSigningBuildSettings(env, device.kind === 'device', device),
];
}
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
const [platform, destination] = process.argv.slice(2);
if (!platform || !destination) {
console.error(USAGE);
process.exit(1);
}
for (const setting of resolveXcuitestBuildSettings(platform, destination)) {
process.stdout.write(`${setting}\n`);
}
}