From d4f4dce41775434b4efc43f1c3dad027b715b66a Mon Sep 17 00:00:00 2001 From: jungle8023 Date: Mon, 18 Jan 2021 16:34:03 +0800 Subject: [PATCH] add scripts --- .../dist_scripts/connect_subsystem.js | 21 ++++++++ .../dist_scripts/parse_platform_hpm.js | 49 +++++++++++++++++ .../dist_scripts/select_product.js | 53 +++++++++++++++++++ .../Hi3516_AICamera/product.template.json | 28 ++++++++++ .../dist_scripts/connect_subsystem.js | 21 ++++++++ .../dist_scripts/parse_platform_hpm.js | 49 +++++++++++++++++ .../Hi3518_IPC/dist_scripts/select_product.js | 53 +++++++++++++++++++ Hisilicon/Hi3518_IPC/product.template.json | 24 +++++++++ .../dist_scripts/connect_subsystem.js | 21 ++++++++ .../dist_scripts/parse_platform_hpm.js | 49 +++++++++++++++++ .../dist_scripts/select_product.js | 53 +++++++++++++++++++ Hisilicon/Hi3861_WiFi/product.template.json | 22 ++++++++ 12 files changed, 443 insertions(+) create mode 100644 Hisilicon/Hi3516_AICamera/dist_scripts/connect_subsystem.js create mode 100644 Hisilicon/Hi3516_AICamera/dist_scripts/parse_platform_hpm.js create mode 100644 Hisilicon/Hi3516_AICamera/dist_scripts/select_product.js create mode 100644 Hisilicon/Hi3516_AICamera/product.template.json create mode 100644 Hisilicon/Hi3518_IPC/dist_scripts/connect_subsystem.js create mode 100644 Hisilicon/Hi3518_IPC/dist_scripts/parse_platform_hpm.js create mode 100644 Hisilicon/Hi3518_IPC/dist_scripts/select_product.js create mode 100644 Hisilicon/Hi3518_IPC/product.template.json create mode 100644 Hisilicon/Hi3861_WiFi/dist_scripts/connect_subsystem.js create mode 100644 Hisilicon/Hi3861_WiFi/dist_scripts/parse_platform_hpm.js create mode 100644 Hisilicon/Hi3861_WiFi/dist_scripts/select_product.js create mode 100644 Hisilicon/Hi3861_WiFi/product.template.json diff --git a/Hisilicon/Hi3516_AICamera/dist_scripts/connect_subsystem.js b/Hisilicon/Hi3516_AICamera/dist_scripts/connect_subsystem.js new file mode 100644 index 0000000..d3c11da --- /dev/null +++ b/Hisilicon/Hi3516_AICamera/dist_scripts/connect_subsystem.js @@ -0,0 +1,21 @@ +const path = require("path"); +const fs = require("fs"); + +function readJSONFile(filePath) { + return JSON.parse(fs.readFileSync(filePath).toString()) +} +function main(src) { + const args = process.argv.splice(2) + const filename = args[0]; + const mainProduct = readJSONFile(path.join(src, 'product.template.json')); + const subsystem = readJSONFile(path.join(src, 'select_product.json')) + const productPath = path.join(src, 'build', 'lite', 'product', `${filename}.json`) + mainProduct.subsystem = subsystem; + fs.writeFileSync(productPath, JSON.stringify(mainProduct, null, 4)) + console.log(`comple json generated at ${productPath}, start compile`) +} + + +const src = path.join(path.resolve(process.env.DEP_BUNDLE_BASE)); +console.log(src); +main(src); diff --git a/Hisilicon/Hi3516_AICamera/dist_scripts/parse_platform_hpm.js b/Hisilicon/Hi3516_AICamera/dist_scripts/parse_platform_hpm.js new file mode 100644 index 0000000..4861064 --- /dev/null +++ b/Hisilicon/Hi3516_AICamera/dist_scripts/parse_platform_hpm.js @@ -0,0 +1,49 @@ +const fs = require('fs'); +const path = require('path'); + +function readJSONFile(filePath) { + return JSON.parse(fs.readFileSync(filePath).toString()) +} + +function addFeatures(componentFeatures, targetIndex) { + if (componentFeatures instanceof Array && targetIndex === 0&&componentFeatures.length>0) { + + return componentFeatures.map(obj=>{ + const key=Object.keys(obj)[0]; + const value=obj[key]; + return `${key}=${value}` + }) + } + return [] +} + +function parseComponent(components) { + return components.reduce((result, component) => { + return result.concat(component.targets.map((target, index) => ({ + name: component.component, + dir: target, + optional: component.optional, + features: addFeatures(component.features, index) + }))) + }, []) +} + +function main(platformPath) { + + const platformJSON = readJSONFile(platformPath); + const resultJSON = []; + platformJSON.subsystems.forEach(subsystem => { + resultJSON.push({ + name: subsystem.subsystem, + optional: subsystem.optional, + component: parseComponent(subsystem.components) + }) + }); + + fs.writeFileSync(path.join(process.env.DEP_BUNDLE_BASE, 'subsystems_product.json'), JSON.stringify(resultJSON.sort((a, b) => a.name.localeCompare(b.name)), null, 4)); +} + +const args = process.argv.splice(2) +const platformPath = process.env.DEP_BUNDLE_BASE ? path.join(process.env.DEP_BUNDLE_BASE, 'build', 'lite', 'platform', args[0], 'platform.json') : path.resolve(args[0]);// hpm dist 调用 或手动指定位置 +console.log(platformPath); +main(platformPath); diff --git a/Hisilicon/Hi3516_AICamera/dist_scripts/select_product.js b/Hisilicon/Hi3516_AICamera/dist_scripts/select_product.js new file mode 100644 index 0000000..82bca37 --- /dev/null +++ b/Hisilicon/Hi3516_AICamera/dist_scripts/select_product.js @@ -0,0 +1,53 @@ +const fs = require('fs'); +const path = require('path'); +const execSync = require('child_process').execSync; + +function readJSONFile(filePath) { + return JSON.parse(fs.readFileSync(filePath).toString()) +} +function parseList() { + const depsoutput = execSync('hpm list').toString(); + const depStringList = depsoutput.substring(depsoutput.indexOf("+--")).split('\n'); + console.log(depStringList) + const depnamelist = depStringList.map(depString => { + return depString ? depString.split("@")[1].split('/')[1] : "" + }).filter(d => d) + return depnamelist +} + +function main(subsystemsProductPath) { + + const subsystemsProductJSON = readJSONFile(subsystemsProductPath); + const selectProduct = [] + const depnameList = parseList() + console.log(depnameList); + depnameList.forEach(depname => { + subsystemsProductJSON.forEach(subsystem => { + subsystem.component.forEach(component => { + if (component.name === depname) { + selectProduct.push({ ...component, subsystem: subsystem.name }) + } + }) + }); + }) + const selectProductObj = selectProduct.reduce((selectObj, product) => { + if (selectObj[product.subsystem]) { + selectObj[product.subsystem].push({ name: product.name, dir: product.dir, features: product.features }) + } else { + selectObj[product.subsystem] = [{ name: product.name, dir: product.dir, features: product.features }] + } + return selectObj; + }, {}) + + const result = Object.keys(selectProductObj).map(subsystem => { + return { + name: subsystem, + component: selectProductObj[subsystem] + } + }) + fs.writeFileSync(path.join(process.env.DEP_BUNDLE_BASE, 'select_product.json'), JSON.stringify(result.sort((a, b) => a.name.localeCompare(b.name)), null, 4)); +} + +const subsystemsProductPath = path.join(process.env.DEP_BUNDLE_BASE, 'subsystems_product.json') +console.log(subsystemsProductPath); +main(subsystemsProductPath); \ No newline at end of file diff --git a/Hisilicon/Hi3516_AICamera/product.template.json b/Hisilicon/Hi3516_AICamera/product.template.json new file mode 100644 index 0000000..13da4f7 --- /dev/null +++ b/Hisilicon/Hi3516_AICamera/product.template.json @@ -0,0 +1,28 @@ +{ + "ohos_version": "1.0.0", + "board": "hi3516dv300", + "kernel": "liteos_a", + "compiler": "clang", + "compiler_dir": "prebuilts/clang/harmonyos/linux-x86_64/llvm", + "subsystem": [ + + ], + "vendor_adapter_dir": "//vendor/hisi/hi35xx/hi3516dv300/hi3516dv300_adapter", + "third_party_dir": "//third_party", + "ohos_product_type":"", + "ohos_manufacture":"", + "ohos_brand":"", + "ohos_market_name":"", + "ohos_product_series":"", + "ohos_product_model":"", + "ohos_software_model":"", + "ohos_hardware_model":"", + "ohos_hardware_profile":"", + "ohos_serial":"", + "ohos_bootloader_version":"", + "ohos_secure_patch_level":"", + "ohos_abi_list":"", + "gn_dir":"/root/buildchain/gn/gn", + "ninja_dir":"/root/buildchain/nija/gn" + } + diff --git a/Hisilicon/Hi3518_IPC/dist_scripts/connect_subsystem.js b/Hisilicon/Hi3518_IPC/dist_scripts/connect_subsystem.js new file mode 100644 index 0000000..d3c11da --- /dev/null +++ b/Hisilicon/Hi3518_IPC/dist_scripts/connect_subsystem.js @@ -0,0 +1,21 @@ +const path = require("path"); +const fs = require("fs"); + +function readJSONFile(filePath) { + return JSON.parse(fs.readFileSync(filePath).toString()) +} +function main(src) { + const args = process.argv.splice(2) + const filename = args[0]; + const mainProduct = readJSONFile(path.join(src, 'product.template.json')); + const subsystem = readJSONFile(path.join(src, 'select_product.json')) + const productPath = path.join(src, 'build', 'lite', 'product', `${filename}.json`) + mainProduct.subsystem = subsystem; + fs.writeFileSync(productPath, JSON.stringify(mainProduct, null, 4)) + console.log(`comple json generated at ${productPath}, start compile`) +} + + +const src = path.join(path.resolve(process.env.DEP_BUNDLE_BASE)); +console.log(src); +main(src); diff --git a/Hisilicon/Hi3518_IPC/dist_scripts/parse_platform_hpm.js b/Hisilicon/Hi3518_IPC/dist_scripts/parse_platform_hpm.js new file mode 100644 index 0000000..4861064 --- /dev/null +++ b/Hisilicon/Hi3518_IPC/dist_scripts/parse_platform_hpm.js @@ -0,0 +1,49 @@ +const fs = require('fs'); +const path = require('path'); + +function readJSONFile(filePath) { + return JSON.parse(fs.readFileSync(filePath).toString()) +} + +function addFeatures(componentFeatures, targetIndex) { + if (componentFeatures instanceof Array && targetIndex === 0&&componentFeatures.length>0) { + + return componentFeatures.map(obj=>{ + const key=Object.keys(obj)[0]; + const value=obj[key]; + return `${key}=${value}` + }) + } + return [] +} + +function parseComponent(components) { + return components.reduce((result, component) => { + return result.concat(component.targets.map((target, index) => ({ + name: component.component, + dir: target, + optional: component.optional, + features: addFeatures(component.features, index) + }))) + }, []) +} + +function main(platformPath) { + + const platformJSON = readJSONFile(platformPath); + const resultJSON = []; + platformJSON.subsystems.forEach(subsystem => { + resultJSON.push({ + name: subsystem.subsystem, + optional: subsystem.optional, + component: parseComponent(subsystem.components) + }) + }); + + fs.writeFileSync(path.join(process.env.DEP_BUNDLE_BASE, 'subsystems_product.json'), JSON.stringify(resultJSON.sort((a, b) => a.name.localeCompare(b.name)), null, 4)); +} + +const args = process.argv.splice(2) +const platformPath = process.env.DEP_BUNDLE_BASE ? path.join(process.env.DEP_BUNDLE_BASE, 'build', 'lite', 'platform', args[0], 'platform.json') : path.resolve(args[0]);// hpm dist 调用 或手动指定位置 +console.log(platformPath); +main(platformPath); diff --git a/Hisilicon/Hi3518_IPC/dist_scripts/select_product.js b/Hisilicon/Hi3518_IPC/dist_scripts/select_product.js new file mode 100644 index 0000000..82bca37 --- /dev/null +++ b/Hisilicon/Hi3518_IPC/dist_scripts/select_product.js @@ -0,0 +1,53 @@ +const fs = require('fs'); +const path = require('path'); +const execSync = require('child_process').execSync; + +function readJSONFile(filePath) { + return JSON.parse(fs.readFileSync(filePath).toString()) +} +function parseList() { + const depsoutput = execSync('hpm list').toString(); + const depStringList = depsoutput.substring(depsoutput.indexOf("+--")).split('\n'); + console.log(depStringList) + const depnamelist = depStringList.map(depString => { + return depString ? depString.split("@")[1].split('/')[1] : "" + }).filter(d => d) + return depnamelist +} + +function main(subsystemsProductPath) { + + const subsystemsProductJSON = readJSONFile(subsystemsProductPath); + const selectProduct = [] + const depnameList = parseList() + console.log(depnameList); + depnameList.forEach(depname => { + subsystemsProductJSON.forEach(subsystem => { + subsystem.component.forEach(component => { + if (component.name === depname) { + selectProduct.push({ ...component, subsystem: subsystem.name }) + } + }) + }); + }) + const selectProductObj = selectProduct.reduce((selectObj, product) => { + if (selectObj[product.subsystem]) { + selectObj[product.subsystem].push({ name: product.name, dir: product.dir, features: product.features }) + } else { + selectObj[product.subsystem] = [{ name: product.name, dir: product.dir, features: product.features }] + } + return selectObj; + }, {}) + + const result = Object.keys(selectProductObj).map(subsystem => { + return { + name: subsystem, + component: selectProductObj[subsystem] + } + }) + fs.writeFileSync(path.join(process.env.DEP_BUNDLE_BASE, 'select_product.json'), JSON.stringify(result.sort((a, b) => a.name.localeCompare(b.name)), null, 4)); +} + +const subsystemsProductPath = path.join(process.env.DEP_BUNDLE_BASE, 'subsystems_product.json') +console.log(subsystemsProductPath); +main(subsystemsProductPath); \ No newline at end of file diff --git a/Hisilicon/Hi3518_IPC/product.template.json b/Hisilicon/Hi3518_IPC/product.template.json new file mode 100644 index 0000000..153cb58 --- /dev/null +++ b/Hisilicon/Hi3518_IPC/product.template.json @@ -0,0 +1,24 @@ +{ + "ohos_version": "OHOS 2.0", + "board": "hi3518ev300", + "kernel": "liteos_a", + "compiler": "clang", + "subsystem": [ + ], + "vendor_adapter_dir": "//vendor/hisi/hi35xx/hi3518ev300/hi3518ev300_adapter", + "third_party_dir": "//third_party", + "ohos_product_type":"", + "ohos_manufacture":"", + "ohos_brand":"", + "ohos_market_name":"", + "ohos_product_series":"", + "ohos_product_model":"", + "ohos_software_model":"", + "ohos_hardware_model":"", + "ohos_hardware_profile":"", + "ohos_serial":"", + "ohos_bootloader_version":"", + "ohos_secure_patch_level":"", + "ohos_abi_list":"" + } + diff --git a/Hisilicon/Hi3861_WiFi/dist_scripts/connect_subsystem.js b/Hisilicon/Hi3861_WiFi/dist_scripts/connect_subsystem.js new file mode 100644 index 0000000..d3c11da --- /dev/null +++ b/Hisilicon/Hi3861_WiFi/dist_scripts/connect_subsystem.js @@ -0,0 +1,21 @@ +const path = require("path"); +const fs = require("fs"); + +function readJSONFile(filePath) { + return JSON.parse(fs.readFileSync(filePath).toString()) +} +function main(src) { + const args = process.argv.splice(2) + const filename = args[0]; + const mainProduct = readJSONFile(path.join(src, 'product.template.json')); + const subsystem = readJSONFile(path.join(src, 'select_product.json')) + const productPath = path.join(src, 'build', 'lite', 'product', `${filename}.json`) + mainProduct.subsystem = subsystem; + fs.writeFileSync(productPath, JSON.stringify(mainProduct, null, 4)) + console.log(`comple json generated at ${productPath}, start compile`) +} + + +const src = path.join(path.resolve(process.env.DEP_BUNDLE_BASE)); +console.log(src); +main(src); diff --git a/Hisilicon/Hi3861_WiFi/dist_scripts/parse_platform_hpm.js b/Hisilicon/Hi3861_WiFi/dist_scripts/parse_platform_hpm.js new file mode 100644 index 0000000..4861064 --- /dev/null +++ b/Hisilicon/Hi3861_WiFi/dist_scripts/parse_platform_hpm.js @@ -0,0 +1,49 @@ +const fs = require('fs'); +const path = require('path'); + +function readJSONFile(filePath) { + return JSON.parse(fs.readFileSync(filePath).toString()) +} + +function addFeatures(componentFeatures, targetIndex) { + if (componentFeatures instanceof Array && targetIndex === 0&&componentFeatures.length>0) { + + return componentFeatures.map(obj=>{ + const key=Object.keys(obj)[0]; + const value=obj[key]; + return `${key}=${value}` + }) + } + return [] +} + +function parseComponent(components) { + return components.reduce((result, component) => { + return result.concat(component.targets.map((target, index) => ({ + name: component.component, + dir: target, + optional: component.optional, + features: addFeatures(component.features, index) + }))) + }, []) +} + +function main(platformPath) { + + const platformJSON = readJSONFile(platformPath); + const resultJSON = []; + platformJSON.subsystems.forEach(subsystem => { + resultJSON.push({ + name: subsystem.subsystem, + optional: subsystem.optional, + component: parseComponent(subsystem.components) + }) + }); + + fs.writeFileSync(path.join(process.env.DEP_BUNDLE_BASE, 'subsystems_product.json'), JSON.stringify(resultJSON.sort((a, b) => a.name.localeCompare(b.name)), null, 4)); +} + +const args = process.argv.splice(2) +const platformPath = process.env.DEP_BUNDLE_BASE ? path.join(process.env.DEP_BUNDLE_BASE, 'build', 'lite', 'platform', args[0], 'platform.json') : path.resolve(args[0]);// hpm dist 调用 或手动指定位置 +console.log(platformPath); +main(platformPath); diff --git a/Hisilicon/Hi3861_WiFi/dist_scripts/select_product.js b/Hisilicon/Hi3861_WiFi/dist_scripts/select_product.js new file mode 100644 index 0000000..82bca37 --- /dev/null +++ b/Hisilicon/Hi3861_WiFi/dist_scripts/select_product.js @@ -0,0 +1,53 @@ +const fs = require('fs'); +const path = require('path'); +const execSync = require('child_process').execSync; + +function readJSONFile(filePath) { + return JSON.parse(fs.readFileSync(filePath).toString()) +} +function parseList() { + const depsoutput = execSync('hpm list').toString(); + const depStringList = depsoutput.substring(depsoutput.indexOf("+--")).split('\n'); + console.log(depStringList) + const depnamelist = depStringList.map(depString => { + return depString ? depString.split("@")[1].split('/')[1] : "" + }).filter(d => d) + return depnamelist +} + +function main(subsystemsProductPath) { + + const subsystemsProductJSON = readJSONFile(subsystemsProductPath); + const selectProduct = [] + const depnameList = parseList() + console.log(depnameList); + depnameList.forEach(depname => { + subsystemsProductJSON.forEach(subsystem => { + subsystem.component.forEach(component => { + if (component.name === depname) { + selectProduct.push({ ...component, subsystem: subsystem.name }) + } + }) + }); + }) + const selectProductObj = selectProduct.reduce((selectObj, product) => { + if (selectObj[product.subsystem]) { + selectObj[product.subsystem].push({ name: product.name, dir: product.dir, features: product.features }) + } else { + selectObj[product.subsystem] = [{ name: product.name, dir: product.dir, features: product.features }] + } + return selectObj; + }, {}) + + const result = Object.keys(selectProductObj).map(subsystem => { + return { + name: subsystem, + component: selectProductObj[subsystem] + } + }) + fs.writeFileSync(path.join(process.env.DEP_BUNDLE_BASE, 'select_product.json'), JSON.stringify(result.sort((a, b) => a.name.localeCompare(b.name)), null, 4)); +} + +const subsystemsProductPath = path.join(process.env.DEP_BUNDLE_BASE, 'subsystems_product.json') +console.log(subsystemsProductPath); +main(subsystemsProductPath); \ No newline at end of file diff --git a/Hisilicon/Hi3861_WiFi/product.template.json b/Hisilicon/Hi3861_WiFi/product.template.json new file mode 100644 index 0000000..1dbb68c --- /dev/null +++ b/Hisilicon/Hi3861_WiFi/product.template.json @@ -0,0 +1,22 @@ +{ + "ohos_version": "OpenHarmony 1.0", + "board": "hi3861v100", + "kernel": "liteos_riscv", + "compiler": "gcc", + "subsystem": [], + "vendor_adapter_dir": "//vendor/hisi/hi3861/hi3861_adapter", + "third_party_dir": "//vendor/hisi/hi3861/hi3861/third_party", + "ohos_product_type":"", + "ohos_manufacture":"", + "ohos_brand":"", + "ohos_market_name":"", + "ohos_product_series":"", + "ohos_product_model":"", + "ohos_software_model":"", + "ohos_hardware_model":"", + "ohos_hardware_profile":"", + "ohos_serial":"", + "ohos_bootloader_version":"", + "ohos_secure_patch_level":"", + "ohos_abi_list":"" +} -- Gitee