plusui-native-builder 0.1.5 → 0.1.8

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/index.js +44 -16
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "plusui-native-builder",
3
- "version": "0.1.5",
4
- "description": "Multi-platform build tool for PlusUI projeplusui",
3
+ "version": "0.1.8",
4
+ "description": "Multi-platform build tool for PlusUI",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
7
7
  "bin": {
@@ -25,6 +25,6 @@
25
25
  ],
26
26
  "license": "MIT",
27
27
  "dependencies": {
28
- "plusui-native-bindgen": "^0.1.5"
28
+ "plusui-native-bindgen": "^0.1.8"
29
29
  }
30
30
  }
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { execSync, spawn } from 'child_process';
4
- import { existsSync, mkdirSync } from 'fs';
4
+ import { existsSync, mkdirSync, copyFileSync } from 'fs';
5
5
  import { join, dirname } from 'path';
6
6
  import { fileURLToPath } from 'url';
7
7
 
@@ -48,13 +48,39 @@ Options:
48
48
  `;
49
49
 
50
50
  const PLATFORMS = {
51
- win32: { name: 'Windows', ext: '.exe', arch: ['x64'] },
52
- macos: { name: 'macOS', ext: '', arch: ['x64', 'arm64'] },
53
- linux: { name: 'Linux', ext: '', arch: ['x64'] },
54
- android: { name: 'Android', ext: '.so', arch: ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'] },
55
- ios: { name: 'iOS', ext: '.app', arch: ['simulator', 'device'] },
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
56
  };
57
57
 
58
+ function resolveBindgenScriptPath() {
59
+ const candidates = [
60
+ join(__dirname, '..', '..', 'plusui-bindgen', 'src', 'index.js'),
61
+ join(__dirname, '..', '..', 'plusui-native-bindgen', 'src', 'index.js'),
62
+ join(process.cwd(), 'node_modules', 'plusui-native-bindgen', 'src', 'index.js'),
63
+ ];
64
+
65
+ for (const candidate of candidates) {
66
+ if (existsSync(candidate)) {
67
+ return candidate;
68
+ }
69
+ }
70
+
71
+ return null;
72
+ }
73
+
74
+ function syncGeneratedTsBindings(backendOutputDir, frontendOutputDir) {
75
+ const tsSource = join(backendOutputDir, 'bindings.gen.ts');
76
+ if (!existsSync(tsSource)) {
77
+ return;
78
+ }
79
+
80
+ mkdirSync(frontendOutputDir, { recursive: true });
81
+ copyFileSync(tsSource, join(frontendOutputDir, 'bindings.gen.ts'));
82
+ }
83
+
58
84
  function runCommand(cmd, options = {}) {
59
85
  const { cwd = process.cwd(), env = process.env, fatal = true } = options;
60
86
  try {
@@ -68,17 +94,16 @@ function runCommand(cmd, options = {}) {
68
94
 
69
95
  function generateBindings() {
70
96
  log('Generating bindings...', 'blue');
71
- let bindgenPath = join(__dirname, '..', '..', 'plusui-bindgen', 'src', 'index.js');
72
- if (!existsSync(bindgenPath)) {
73
- // Try installed location (node_modules/plusui-native-bindgen)
74
- bindgenPath = join(__dirname, '..', '..', 'plusui-native-bindgen', 'src', 'index.js');
75
- }
76
-
77
- if (!existsSync(bindgenPath)) {
97
+ const bindgenPath = resolveBindgenScriptPath();
98
+
99
+ if (!bindgenPath) {
78
100
  error('plusui-bindgen not found. Please ensure plusui-native-bindgen is installed.');
79
101
  }
80
-
81
- runCommand(`node ${bindgenPath} ./src/services ./src`);
102
+
103
+ const featuresDir = './src/features';
104
+ const outputDir = './src/Bindings_Generated';
105
+ runCommand(`node ${bindgenPath} ${featuresDir} ${outputDir}`);
106
+ syncGeneratedTsBindings('./src/Bindings_Generated', './frontend/src/Bindings_Generated');
82
107
  log('Bindings generated ✓', 'green');
83
108
  }
84
109
 
@@ -139,7 +164,10 @@ function buildPlatform(platform, arch = null) {
139
164
  for (const targetArch of archs) {
140
165
  log(`Building ${cfg.name} (${targetArch})...`, 'blue');
141
166
 
142
- const buildDir = join(sourceDir, 'build', platform, targetArch);
167
+ const desktopSingleArch = ['win32', 'linux'].includes(platform) || (platform === 'macos' && archs.length === 1);
168
+ const buildDir = desktopSingleArch
169
+ ? join(sourceDir, 'build', cfg.folder)
170
+ : join(sourceDir, 'build', cfg.folder, targetArch);
143
171
  mkdirSync(buildDir, { recursive: true });
144
172
 
145
173
  const cmakeArgs = ['-S' + sourceDir, `-B${buildDir}`, '-DCMAKE_BUILD_TYPE=Release'];