plusui-native-builder 0.1.106 → 0.1.107
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/package.json +2 -2
- package/src/index.js +262 -262
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plusui-native-builder",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.107",
|
|
4
4
|
"description": "Multi-platform build tool for PlusUI",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
],
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"plusui-native-connect": "^0.1.
|
|
28
|
+
"plusui-native-connect": "^0.1.107"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/index.js
CHANGED
|
@@ -1,263 +1,263 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { execSync, spawn } from 'child_process';
|
|
4
|
-
import { existsSync, mkdirSync, copyFileSync } from 'fs';
|
|
5
|
-
import { join, dirname } from 'path';
|
|
6
|
-
import { fileURLToPath } from 'url';
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = dirname(__filename);
|
|
10
|
-
|
|
11
|
-
const COLORS = {
|
|
12
|
-
reset: '\x1b[0m',
|
|
13
|
-
bright: '\x1b[1m',
|
|
14
|
-
green: '\x1b[32m',
|
|
15
|
-
blue: '\x1b[34m',
|
|
16
|
-
yellow: '\x1b[33m',
|
|
17
|
-
red: '\x1b[31m',
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
function log(msg, color = 'reset') {
|
|
21
|
-
console.log(`${COLORS[color]}${msg}${COLORS.reset}`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function error(msg) {
|
|
25
|
-
console.error(`${COLORS.red}Error: ${msg}${COLORS.reset}`);
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const USAGE = `
|
|
30
|
-
PlusUI Builder - Multi-platform build tool
|
|
31
|
-
|
|
32
|
-
Usage:
|
|
33
|
-
plusui-builder Build for current platform
|
|
34
|
-
plusui-builder <platform> Build for specific platform
|
|
35
|
-
plusui-builder all Build for all platforms
|
|
36
|
-
plusui-builder generate Generate connection bindings only
|
|
37
|
-
|
|
38
|
-
Platforms:
|
|
39
|
-
win32 - Windows (x64)
|
|
40
|
-
macos - macOS (x64, arm64)
|
|
41
|
-
linux - Linux (x64)
|
|
42
|
-
android - Android (arm64-v8a, armeabi-v7a, x86, x86_64)
|
|
43
|
-
ios - iOS (simulator, device)
|
|
44
|
-
|
|
45
|
-
Options:
|
|
46
|
-
-h, --help Show this help
|
|
47
|
-
-v, --version Show version
|
|
48
|
-
`;
|
|
49
|
-
|
|
50
|
-
const PLATFORMS = {
|
|
51
|
-
win32: { name: 'Windows', folder: 'Windows', ext: '.exe', arch: ['x64'] },
|
|
52
|
-
macos: { name: 'macOS', folder: 'MacOS', ext: '', arch: ['x64', 'arm64'] },
|
|
53
|
-
linux: { name: 'Linux', folder: 'Linux', ext: '', arch: ['x64'] },
|
|
54
|
-
android: { name: 'Android', folder: 'Android', ext: '.so', arch: ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'] },
|
|
55
|
-
ios: { name: 'iOS', folder: 'iOS', ext: '.app', arch: ['simulator', 'device'] },
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
function resolveBindgenScriptPath() {
|
|
59
|
-
const candidates = [
|
|
60
|
-
join(__dirname, '..', '..', 'plusui-connect', 'src', 'connect.js'),
|
|
61
|
-
join(__dirname, '..', '..', 'plusui-connect', 'src', 'index.js'),
|
|
62
|
-
join(__dirname, '..', '..', 'plusui-native-connect', 'src', 'index.js'),
|
|
63
|
-
join(__dirname, '..', '..', 'plusui-native-bindgen', 'src', 'index.js'),
|
|
64
|
-
join(process.cwd(), 'node_modules', 'plusui-native-connect', 'src', 'connect.js'),
|
|
65
|
-
join(__dirname, '..', '..', 'plusui-native-connect', 'src', 'connect.js'),
|
|
66
|
-
join(process.cwd(), 'node_modules', 'plusui-native-connect', 'src', 'index.js'),
|
|
67
|
-
join(process.cwd(), 'node_modules', 'plusui-native-bindgen', 'src', 'index.js'),
|
|
68
|
-
];
|
|
69
|
-
|
|
70
|
-
for (const candidate of candidates) {
|
|
71
|
-
if (existsSync(candidate)) {
|
|
72
|
-
return candidate;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function syncGeneratedTsBindings(backendOutputDir, frontendOutputDir) {
|
|
80
|
-
const tsSource = join(backendOutputDir, 'bindings.gen.ts');
|
|
81
|
-
if (!existsSync(tsSource)) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
mkdirSync(frontendOutputDir, { recursive: true });
|
|
86
|
-
copyFileSync(tsSource, join(frontendOutputDir, 'bindings.gen.ts'));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function runCommand(cmd, options = {}) {
|
|
90
|
-
const { cwd = process.cwd(), env = process.env, fatal = true } = options;
|
|
91
|
-
try {
|
|
92
|
-
execSync(cmd, { cwd, env, stdio: 'inherit' });
|
|
93
|
-
return true;
|
|
94
|
-
} catch (e) {
|
|
95
|
-
if (fatal) error(`Command failed: ${cmd}`);
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function generateBindings() {
|
|
101
|
-
log('Generating connection bindings...', 'blue');
|
|
102
|
-
const bindgenPath = resolveBindgenScriptPath();
|
|
103
|
-
|
|
104
|
-
if (!bindgenPath) {
|
|
105
|
-
error('plusui-connect tool not found. Please ensure plusui-native-connect is installed.');
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const projectRoot = '.';
|
|
109
|
-
// Output goes to Connections/ at project root
|
|
110
|
-
const outputDir = './Connections';
|
|
111
|
-
runCommand(`node ${bindgenPath} ${projectRoot} ${outputDir}`);
|
|
112
|
-
log('Connection bindings generated ✓', 'green');
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function getCMakePlatformArgs(platform) {
|
|
116
|
-
const args = [];
|
|
117
|
-
|
|
118
|
-
switch (platform) {
|
|
119
|
-
case 'win32':
|
|
120
|
-
break;
|
|
121
|
-
case 'macos':
|
|
122
|
-
args.push('-G', 'Xcode');
|
|
123
|
-
break;
|
|
124
|
-
case 'linux':
|
|
125
|
-
args.push('-G', 'Ninja');
|
|
126
|
-
break;
|
|
127
|
-
case 'android':
|
|
128
|
-
const sdkRoot = process.env.ANDROID_SDK_ROOT || process.env.ANDROID_HOME;
|
|
129
|
-
if (!sdkRoot) {
|
|
130
|
-
error('ANDROID_SDK_ROOT or ANDROID_HOME not set');
|
|
131
|
-
}
|
|
132
|
-
args.push('-G', 'Ninja');
|
|
133
|
-
args.push('-DCMAKE_TOOLCHAIN_FILE=' + join(sdkRoot, 'build-tools', 'cmake', 'android.toolchain.cmake'));
|
|
134
|
-
args.push('-DANDROID_NATIVE_API_LEVEL=24');
|
|
135
|
-
break;
|
|
136
|
-
case 'ios':
|
|
137
|
-
args.push('-G', 'Xcode');
|
|
138
|
-
args.push('-DCMAKE_SYSTEM_NAME=iOS');
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return args;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function findCMakeLists() {
|
|
146
|
-
const root = process.cwd();
|
|
147
|
-
if (existsSync(join(root, 'CMakeLists.txt'))) {
|
|
148
|
-
return root;
|
|
149
|
-
}
|
|
150
|
-
const subdirs = ['.', 'src', 'app', 'core'];
|
|
151
|
-
for (const dir of subdirs) {
|
|
152
|
-
const path = join(root, dir, 'CMakeLists.txt');
|
|
153
|
-
if (existsSync(path)) {
|
|
154
|
-
return join(root, dir);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
error('CMakeLists.txt not found. Run from a PlusUI project directory.');
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function buildPlatform(platform, arch = null) {
|
|
161
|
-
const cfg = PLATFORMS[platform];
|
|
162
|
-
if (!cfg) {
|
|
163
|
-
error(`Unknown platform: ${platform}`);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const sourceDir = findCMakeLists();
|
|
167
|
-
const archs = arch ? [arch] : cfg.arch;
|
|
168
|
-
|
|
169
|
-
for (const targetArch of archs) {
|
|
170
|
-
log(`Building ${cfg.name} (${targetArch})...`, 'blue');
|
|
171
|
-
|
|
172
|
-
const desktopSingleArch = ['win32', 'linux'].includes(platform) || (platform === 'macos' && archs.length === 1);
|
|
173
|
-
const buildDir = desktopSingleArch
|
|
174
|
-
? join(sourceDir, 'build', cfg.folder)
|
|
175
|
-
: join(sourceDir, 'build', cfg.folder, targetArch);
|
|
176
|
-
mkdirSync(buildDir, { recursive: true });
|
|
177
|
-
|
|
178
|
-
const cmakeArgs = ['-S' + sourceDir, `-B${buildDir}`, '-DCMAKE_BUILD_TYPE=Release'];
|
|
179
|
-
cmakeArgs.push(...getCMakePlatformArgs(platform));
|
|
180
|
-
|
|
181
|
-
if (platform === 'android') {
|
|
182
|
-
cmakeArgs.push(`-DANDROID_ABI=${targetArch}`);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const cmakeCmd = 'cmake ' + cmakeArgs.join(' ');
|
|
186
|
-
runCommand(cmakeCmd);
|
|
187
|
-
runCommand(`cmake --build ${buildDir} --config Release`);
|
|
188
|
-
|
|
189
|
-
log(`Built ${cfg.name} (${targetArch}) ✓`, 'green');
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function buildCurrentPlatform() {
|
|
194
|
-
const platform = process.platform;
|
|
195
|
-
const platformMap = { 'win32': 'win32', 'darwin': 'macos', 'linux': 'linux' };
|
|
196
|
-
const targetPlatform = platformMap[platform];
|
|
197
|
-
|
|
198
|
-
if (targetPlatform) {
|
|
199
|
-
buildPlatform(targetPlatform);
|
|
200
|
-
} else {
|
|
201
|
-
error(`Unsupported platform: ${platform}`);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function buildAll() {
|
|
206
|
-
generateBindings();
|
|
207
|
-
|
|
208
|
-
for (const platform of Object.keys(PLATFORMS)) {
|
|
209
|
-
log(`\n=== Building for ${PLATFORMS[platform].name} ===`, 'yellow');
|
|
210
|
-
buildPlatform(platform);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
log('\n✓ All builds complete!', 'green');
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
function main() {
|
|
217
|
-
const args = process.argv.slice(2);
|
|
218
|
-
const cmd = args[0];
|
|
219
|
-
|
|
220
|
-
switch (cmd) {
|
|
221
|
-
case 'generate':
|
|
222
|
-
case 'gen':
|
|
223
|
-
generateBindings();
|
|
224
|
-
break;
|
|
225
|
-
case 'all':
|
|
226
|
-
buildAll();
|
|
227
|
-
break;
|
|
228
|
-
case 'win32':
|
|
229
|
-
case 'windows':
|
|
230
|
-
generateBindings();
|
|
231
|
-
buildPlatform('win32');
|
|
232
|
-
break;
|
|
233
|
-
case 'macos':
|
|
234
|
-
generateBindings();
|
|
235
|
-
buildPlatform('macos');
|
|
236
|
-
break;
|
|
237
|
-
case 'linux':
|
|
238
|
-
generateBindings();
|
|
239
|
-
buildPlatform('linux');
|
|
240
|
-
break;
|
|
241
|
-
case 'android':
|
|
242
|
-
generateBindings();
|
|
243
|
-
buildPlatform('android');
|
|
244
|
-
break;
|
|
245
|
-
case 'ios':
|
|
246
|
-
generateBindings();
|
|
247
|
-
buildPlatform('ios');
|
|
248
|
-
break;
|
|
249
|
-
case '-h':
|
|
250
|
-
case '--help':
|
|
251
|
-
console.log(USAGE);
|
|
252
|
-
break;
|
|
253
|
-
case '-v':
|
|
254
|
-
case '--version':
|
|
255
|
-
console.log('plusui-builder v0.1.0');
|
|
256
|
-
break;
|
|
257
|
-
default:
|
|
258
|
-
generateBindings();
|
|
259
|
-
buildCurrentPlatform();
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
main();
|
|
2
|
+
|
|
3
|
+
import { execSync, spawn } from 'child_process';
|
|
4
|
+
import { existsSync, mkdirSync, copyFileSync } from 'fs';
|
|
5
|
+
import { join, dirname } from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = dirname(__filename);
|
|
10
|
+
|
|
11
|
+
const COLORS = {
|
|
12
|
+
reset: '\x1b[0m',
|
|
13
|
+
bright: '\x1b[1m',
|
|
14
|
+
green: '\x1b[32m',
|
|
15
|
+
blue: '\x1b[34m',
|
|
16
|
+
yellow: '\x1b[33m',
|
|
17
|
+
red: '\x1b[31m',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function log(msg, color = 'reset') {
|
|
21
|
+
console.log(`${COLORS[color]}${msg}${COLORS.reset}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function error(msg) {
|
|
25
|
+
console.error(`${COLORS.red}Error: ${msg}${COLORS.reset}`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const USAGE = `
|
|
30
|
+
PlusUI Builder - Multi-platform build tool
|
|
31
|
+
|
|
32
|
+
Usage:
|
|
33
|
+
plusui-builder Build for current platform
|
|
34
|
+
plusui-builder <platform> Build for specific platform
|
|
35
|
+
plusui-builder all Build for all platforms
|
|
36
|
+
plusui-builder generate Generate connection bindings only
|
|
37
|
+
|
|
38
|
+
Platforms:
|
|
39
|
+
win32 - Windows (x64)
|
|
40
|
+
macos - macOS (x64, arm64)
|
|
41
|
+
linux - Linux (x64)
|
|
42
|
+
android - Android (arm64-v8a, armeabi-v7a, x86, x86_64)
|
|
43
|
+
ios - iOS (simulator, device)
|
|
44
|
+
|
|
45
|
+
Options:
|
|
46
|
+
-h, --help Show this help
|
|
47
|
+
-v, --version Show version
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
const PLATFORMS = {
|
|
51
|
+
win32: { name: 'Windows', folder: 'Windows', ext: '.exe', arch: ['x64'] },
|
|
52
|
+
macos: { name: 'macOS', folder: 'MacOS', ext: '', arch: ['x64', 'arm64'] },
|
|
53
|
+
linux: { name: 'Linux', folder: 'Linux', ext: '', arch: ['x64'] },
|
|
54
|
+
android: { name: 'Android', folder: 'Android', ext: '.so', arch: ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'] },
|
|
55
|
+
ios: { name: 'iOS', folder: 'iOS', ext: '.app', arch: ['simulator', 'device'] },
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
function resolveBindgenScriptPath() {
|
|
59
|
+
const candidates = [
|
|
60
|
+
join(__dirname, '..', '..', 'plusui-connect', 'src', 'connect.js'),
|
|
61
|
+
join(__dirname, '..', '..', 'plusui-connect', 'src', 'index.js'),
|
|
62
|
+
join(__dirname, '..', '..', 'plusui-native-connect', 'src', 'index.js'),
|
|
63
|
+
join(__dirname, '..', '..', 'plusui-native-bindgen', 'src', 'index.js'),
|
|
64
|
+
join(process.cwd(), 'node_modules', 'plusui-native-connect', 'src', 'connect.js'),
|
|
65
|
+
join(__dirname, '..', '..', 'plusui-native-connect', 'src', 'connect.js'),
|
|
66
|
+
join(process.cwd(), 'node_modules', 'plusui-native-connect', 'src', 'index.js'),
|
|
67
|
+
join(process.cwd(), 'node_modules', 'plusui-native-bindgen', 'src', 'index.js'),
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
for (const candidate of candidates) {
|
|
71
|
+
if (existsSync(candidate)) {
|
|
72
|
+
return candidate;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function syncGeneratedTsBindings(backendOutputDir, frontendOutputDir) {
|
|
80
|
+
const tsSource = join(backendOutputDir, 'bindings.gen.ts');
|
|
81
|
+
if (!existsSync(tsSource)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
mkdirSync(frontendOutputDir, { recursive: true });
|
|
86
|
+
copyFileSync(tsSource, join(frontendOutputDir, 'bindings.gen.ts'));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function runCommand(cmd, options = {}) {
|
|
90
|
+
const { cwd = process.cwd(), env = process.env, fatal = true } = options;
|
|
91
|
+
try {
|
|
92
|
+
execSync(cmd, { cwd, env, stdio: 'inherit' });
|
|
93
|
+
return true;
|
|
94
|
+
} catch (e) {
|
|
95
|
+
if (fatal) error(`Command failed: ${cmd}`);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function generateBindings() {
|
|
101
|
+
log('Generating connection bindings...', 'blue');
|
|
102
|
+
const bindgenPath = resolveBindgenScriptPath();
|
|
103
|
+
|
|
104
|
+
if (!bindgenPath) {
|
|
105
|
+
error('plusui-connect tool not found. Please ensure plusui-native-connect is installed.');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const projectRoot = '.';
|
|
109
|
+
// Output goes to Connections/ at project root
|
|
110
|
+
const outputDir = './Connections';
|
|
111
|
+
runCommand(`node ${bindgenPath} ${projectRoot} ${outputDir}`);
|
|
112
|
+
log('Connection bindings generated ✓', 'green');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function getCMakePlatformArgs(platform) {
|
|
116
|
+
const args = [];
|
|
117
|
+
|
|
118
|
+
switch (platform) {
|
|
119
|
+
case 'win32':
|
|
120
|
+
break;
|
|
121
|
+
case 'macos':
|
|
122
|
+
args.push('-G', 'Xcode');
|
|
123
|
+
break;
|
|
124
|
+
case 'linux':
|
|
125
|
+
args.push('-G', 'Ninja');
|
|
126
|
+
break;
|
|
127
|
+
case 'android':
|
|
128
|
+
const sdkRoot = process.env.ANDROID_SDK_ROOT || process.env.ANDROID_HOME;
|
|
129
|
+
if (!sdkRoot) {
|
|
130
|
+
error('ANDROID_SDK_ROOT or ANDROID_HOME not set');
|
|
131
|
+
}
|
|
132
|
+
args.push('-G', 'Ninja');
|
|
133
|
+
args.push('-DCMAKE_TOOLCHAIN_FILE=' + join(sdkRoot, 'build-tools', 'cmake', 'android.toolchain.cmake'));
|
|
134
|
+
args.push('-DANDROID_NATIVE_API_LEVEL=24');
|
|
135
|
+
break;
|
|
136
|
+
case 'ios':
|
|
137
|
+
args.push('-G', 'Xcode');
|
|
138
|
+
args.push('-DCMAKE_SYSTEM_NAME=iOS');
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return args;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function findCMakeLists() {
|
|
146
|
+
const root = process.cwd();
|
|
147
|
+
if (existsSync(join(root, 'CMakeLists.txt'))) {
|
|
148
|
+
return root;
|
|
149
|
+
}
|
|
150
|
+
const subdirs = ['.', 'src', 'app', 'core'];
|
|
151
|
+
for (const dir of subdirs) {
|
|
152
|
+
const path = join(root, dir, 'CMakeLists.txt');
|
|
153
|
+
if (existsSync(path)) {
|
|
154
|
+
return join(root, dir);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
error('CMakeLists.txt not found. Run from a PlusUI project directory.');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function buildPlatform(platform, arch = null) {
|
|
161
|
+
const cfg = PLATFORMS[platform];
|
|
162
|
+
if (!cfg) {
|
|
163
|
+
error(`Unknown platform: ${platform}`);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const sourceDir = findCMakeLists();
|
|
167
|
+
const archs = arch ? [arch] : cfg.arch;
|
|
168
|
+
|
|
169
|
+
for (const targetArch of archs) {
|
|
170
|
+
log(`Building ${cfg.name} (${targetArch})...`, 'blue');
|
|
171
|
+
|
|
172
|
+
const desktopSingleArch = ['win32', 'linux'].includes(platform) || (platform === 'macos' && archs.length === 1);
|
|
173
|
+
const buildDir = desktopSingleArch
|
|
174
|
+
? join(sourceDir, 'build', cfg.folder)
|
|
175
|
+
: join(sourceDir, 'build', cfg.folder, targetArch);
|
|
176
|
+
mkdirSync(buildDir, { recursive: true });
|
|
177
|
+
|
|
178
|
+
const cmakeArgs = ['-S' + sourceDir, `-B${buildDir}`, '-DCMAKE_BUILD_TYPE=Release'];
|
|
179
|
+
cmakeArgs.push(...getCMakePlatformArgs(platform));
|
|
180
|
+
|
|
181
|
+
if (platform === 'android') {
|
|
182
|
+
cmakeArgs.push(`-DANDROID_ABI=${targetArch}`);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const cmakeCmd = 'cmake ' + cmakeArgs.join(' ');
|
|
186
|
+
runCommand(cmakeCmd);
|
|
187
|
+
runCommand(`cmake --build ${buildDir} --config Release`);
|
|
188
|
+
|
|
189
|
+
log(`Built ${cfg.name} (${targetArch}) ✓`, 'green');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function buildCurrentPlatform() {
|
|
194
|
+
const platform = process.platform;
|
|
195
|
+
const platformMap = { 'win32': 'win32', 'darwin': 'macos', 'linux': 'linux' };
|
|
196
|
+
const targetPlatform = platformMap[platform];
|
|
197
|
+
|
|
198
|
+
if (targetPlatform) {
|
|
199
|
+
buildPlatform(targetPlatform);
|
|
200
|
+
} else {
|
|
201
|
+
error(`Unsupported platform: ${platform}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function buildAll() {
|
|
206
|
+
generateBindings();
|
|
207
|
+
|
|
208
|
+
for (const platform of Object.keys(PLATFORMS)) {
|
|
209
|
+
log(`\n=== Building for ${PLATFORMS[platform].name} ===`, 'yellow');
|
|
210
|
+
buildPlatform(platform);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
log('\n✓ All builds complete!', 'green');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function main() {
|
|
217
|
+
const args = process.argv.slice(2);
|
|
218
|
+
const cmd = args[0];
|
|
219
|
+
|
|
220
|
+
switch (cmd) {
|
|
221
|
+
case 'generate':
|
|
222
|
+
case 'gen':
|
|
223
|
+
generateBindings();
|
|
224
|
+
break;
|
|
225
|
+
case 'all':
|
|
226
|
+
buildAll();
|
|
227
|
+
break;
|
|
228
|
+
case 'win32':
|
|
229
|
+
case 'windows':
|
|
230
|
+
generateBindings();
|
|
231
|
+
buildPlatform('win32');
|
|
232
|
+
break;
|
|
233
|
+
case 'macos':
|
|
234
|
+
generateBindings();
|
|
235
|
+
buildPlatform('macos');
|
|
236
|
+
break;
|
|
237
|
+
case 'linux':
|
|
238
|
+
generateBindings();
|
|
239
|
+
buildPlatform('linux');
|
|
240
|
+
break;
|
|
241
|
+
case 'android':
|
|
242
|
+
generateBindings();
|
|
243
|
+
buildPlatform('android');
|
|
244
|
+
break;
|
|
245
|
+
case 'ios':
|
|
246
|
+
generateBindings();
|
|
247
|
+
buildPlatform('ios');
|
|
248
|
+
break;
|
|
249
|
+
case '-h':
|
|
250
|
+
case '--help':
|
|
251
|
+
console.log(USAGE);
|
|
252
|
+
break;
|
|
253
|
+
case '-v':
|
|
254
|
+
case '--version':
|
|
255
|
+
console.log('plusui-builder v0.1.0');
|
|
256
|
+
break;
|
|
257
|
+
default:
|
|
258
|
+
generateBindings();
|
|
259
|
+
buildCurrentPlatform();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
main();
|