Selaa lähdekoodia

feat: add platform detection and ARM64 file copy for Taro build in .build/h5_for_production.js

- Add platform and CPU architecture detection logging
- Copy taro.linux-arm64-gnu.node file for Linux ARM64 systems before build
- Ensure ARM64 build dependencies are available before executing npm run build:h5
sw 2 viikkoa sitten
vanhempi
commit
3f03848dea
2 muutettua tiedostoa jossa 19 lisäystä ja 6 poistoa
  1. 16 1
      .build/h5_for_production.js
  2. 3 5
      README.md

+ 16 - 1
.build/h5_for_production.js

@@ -2,12 +2,27 @@
 
 const { execSync } = require('child_process');
 const path = require('path');
+const fs = require('fs');
 
 const TARO_API_URL = 'http://localhost:6001'; // 远程地址,这里写死,要做成部署后可配置
 const TARO_MQTT_URL ='ws://localhost:8083/mqtt';
 const rootDir = path.join(__dirname, '..');          // 项目根目录
 
 try {
+    // 打印当前平台信息和CPU架构信息
+    console.log(`当前操作系统平台: ${process.platform}`);
+    console.log(`当前CPU架构: ${process.arch}`);
+    
+    // 检测平台和CPU架构,只有当操作系统是linux且CPU架构是arm64时才执行复制行为
+    if (process.platform === 'linux' && process.arch === 'arm64') {
+        console.log(`复制arm平台必须构建文件taro.linux-arm64-gnu.node到目标位置`);
+        fs.copyFileSync(
+            path.join(rootDir, '.build', 'taro.linux-arm64-gnu.node'),
+            path.join(rootDir, 'node_modules', '@tarojs', 'binding', 'taro.linux-arm64-gnu.node')
+        );
+        console.log(`复制arm平台必须构建文件taro.linux-arm64-gnu.node到目标位置===完成`);
+    }
+    
     execSync(`npm run build:h5`, { cwd: rootDir, stdio: 'inherit', env: { ...process.env, TARO_API_URL ,TARO_MQTT_URL} }, (error, stdout, stderr) => {
     if (error) {
         console.error(`Error executing command: ${error.message}`);
@@ -23,4 +38,4 @@ try {
 } catch (err) {
     console.error('Failed to execute :', err.message);
     process.exit(1);
-}
+}

+ 3 - 5
README.md

@@ -11,14 +11,12 @@
 依次执行以下命令:
 
 - npm i
-- npm run prebuild:arm:linux
-- npm run build:h5
+- npm run h5_for_production
 
 ## 构建Windows平台的Electron应用程序分发包
 
 - npm i
-- npm run build:h5
-- npm run build:electron:win
+- npm run pack:win
 
 ## 构建linux平台的Electron应用程序分发包[arm64]
 
@@ -34,7 +32,7 @@
 ## 构建android平台的应用包[Hybrid]
 
 - npm i
-- npm run build:h5
+- npm run h5_for_production
 - npm run build:android
 
 环境要求: