-
Notifications
You must be signed in to change notification settings - Fork 4
/
vendor-build
executable file
·102 lines (99 loc) · 3.2 KB
/
vendor-build
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
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env node
const path = require("path");
const CommandLine = require('./lib/CommandLine');
const Vendor = require('./lib/Vendor');
const Platform = require("./lib/Platform");
const optionDeclarations = [
{
name: "source",
shortName: "s",
type: "string",
description: "Specify the source path where the vendor.json is located. Default is current working directory."
},
{
name: "platform",
shortName: "p",
type: "string",
description: "Specifies current platform. Supported platforms: [\"win\", \"mac\", \"ios\", \"linux\", \"android\", \"web\", \"ohos\"]."
},
{
name: "arch",
shortName: "a",
type: "string",
description: "Builds the specified arch only. Supported archs: [\"x86\", \"x64\", \"arm\", \"arm64\", \"arm64-simulator\", \"wasm\", \"wasm-mt\"]."
},
{
name: "output",
shortName: "o",
type: "string",
description: "Publishing all vendor libraries to specified output directory. All shared libraries are copied and all static libraries are merged."
},
{
name: "xcframework",
shortName: "x",
type: "boolean",
description: "Merges all arches of the output libraries into one xcframework if current platform supports it. Ignored if --output is not specified."
},
{
name: "debug",
shortName: "d",
type: "boolean",
description: "Builds with debug mode enabled."
},
{
name: "verbose",
shortName: "v",
type: "boolean",
description: "Prints message in verbose mode."
},
{
name: "help",
shortName: "h",
type: "boolean",
description: "Prints help message."
},
];
function printHelp(cmd) {
let output = "";
output += "Syntax: " + cmd + " [vendorName] [vendorName]... [options]\n";
output += "Examples: " + cmd + " libpng libwebp\n";
output += "Examples: " + cmd + " --debug\n";
output += "Examples: " + cmd + " -p mac -a arm64 --verbose\n";
output += CommandLine.printOptions(optionDeclarations);
process.stdout.write(output);
}
let args = process.argv;
let options = CommandLine.parse(args.slice(2), optionDeclarations);
if (options.help) {
let cmd = "node " + path.basename(args[1]);
printHelp(cmd);
if (options.errors.length > 0) {
process.exit(1);
}
return;
}
if (!options.debug) {
if (process.env["VENDOR_BUILD_TYPE"] === "Debug") {
options.debug = true;
}
}
if (options.xcframework) {
delete options.arch;
}
let execPath = path.resolve(process.argv[1]);
let isCustomBuild = execPath !== __filename;
if (!options.source) {
options.source = isCustomBuild ? path.dirname(execPath) : process.cwd();
} else {
options.source = path.resolve(options.source);
}
let configFile = path.join(options.source, "vendor.json");
if (options.output) {
options.output = path.resolve(options.output);
}
let platform = Platform.Create(options.platform, options.debug, options.verbose);
if (options.arch) {
platform.archs = [options.arch.toLowerCase()];
}
let vendor = new Vendor(configFile, platform);
vendor.buildAll(options.targets, options.output, options.xcframework);