add scripts

This commit is contained in:
jungle8023 2021-01-18 16:34:03 +08:00
parent 2751e65bdc
commit d4f4dce417
12 changed files with 443 additions and 0 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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"
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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":""
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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":""
}