-
Notifications
You must be signed in to change notification settings - Fork 4
/
xcode-gen
executable file
·92 lines (86 loc) · 2.55 KB
/
xcode-gen
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env node
const path = require("path");
const Utils = require('./lib/Utils');
const XCode = require('./lib/XCode');
const CommandLine = require('./lib/CommandLine');
const KnownPlatforms = ["mac", "ios", "simulator"];
const KnownArchs = ["x64", "arm64"];
const optionDeclarations = [
{
name: "source",
shortName: "s",
type: "string",
description: "Specify the root of the cmake project. Default is current working directory."
},
{
name: "output",
shortName: "o",
type: "string",
description: "Specify the output path of the generated project. Default is current working directory."
},
{
name: "platform",
shortName: "p",
type: "string",
description: "Specify the platform to generate. Supported platforms: [\"mac\", \"ios\", \"simulator\"]."
},
{
name: "arch",
shortName: "a",
type: "string",
description: "Specify the arch of the generated project. Supported arches: [\"x64\", \"arm64\"]."
},
{
name: "workspace",
shortName: "w",
type: "boolean",
description: "Generate an additional *.xcworkspace for the existing xcode project in the output directory."
},
{
name: "help",
shortName: "h",
type: "boolean",
description: "Print help message."
}
];
function printHelp(cmd) {
let output = "";
output += "Syntax: " + cmd + " sourcePath [options] [-Dcmake_variable=value]... [-Dcmake_variable=value]\n";
output += "Examples: " + cmd + " ../ -p mac -DTGFX_USE_WEBP_ENCODE=ON\n";
output += "Examples: " + cmd + " ../ -p simulator -a arm64\n";
output += CommandLine.printOptions(optionDeclarations);
Utils.log(output);
}
let args = process.argv;
let cmd = "node " + path.basename(args[1]);
args = args.slice(2);
let cmakeArgs = [];
let cmdArgs = [];
for (let arg of args) {
if (arg.indexOf("-D") === 0) {
cmakeArgs.push(arg);
} else {
cmdArgs.push(arg);
}
}
let options = CommandLine.parse(cmdArgs, optionDeclarations, KnownPlatforms, KnownArchs);
options.cmakeArgs = cmakeArgs;
if (!options.source) {
if (options.targets && options.targets.length === 1) {
options.source = options.targets[0];
delete options.targets;
} else {
options.source = process.cwd();
}
}
if (!options.output) {
options.output = process.cwd();
}
if (options.help) {
printHelp(cmd);
if (options.errors.length > 0) {
process.exit(1);
}
return;
}
XCode.Generate(options);