Update config scripts and compare tool

This commit is contained in:
Sebastien L
2021-12-17 09:34:56 -05:00
parent 3a89597ff0
commit d0bcc72bce
4 changed files with 107 additions and 47 deletions

View File

@@ -857,8 +857,6 @@ CONFIG_DAC_CONFIG=""
CONFIG_SPDIF_CONFIG="" CONFIG_SPDIF_CONFIG=""
CONFIG_ETH_CONFIG="" CONFIG_ETH_CONFIG=""
CONFIG_DAC_CONTROLSET="" CONFIG_DAC_CONTROLSET=""
CONFIG_DAC_KNOWN_CONFIGURATIONS="ESP-A1S-AC101(audio kit 2.2)-Fixed GPIOs|ESP-A1S-ES8388(audio kit 2.2+)-Fixed GPIOs"
CONFIG_DAC_KNOWN_CONFIGURATIONS_GPIOS="model
CONFIG_I2C_SDA=-1 CONFIG_I2C_SDA=-1
CONFIG_I2C_SCL=-1 CONFIG_I2C_SCL=-1
CONFIG_SDIF_NUM=0 CONFIG_SDIF_NUM=0

View File

@@ -856,8 +856,6 @@ CONFIG_ETH_SPI_SPEED=20000000
CONFIG_BASIC_I2C_BT=y CONFIG_BASIC_I2C_BT=y
CONFIG_ETH_CONFIG="" CONFIG_ETH_CONFIG=""
CONFIG_DAC_CONTROLSET="" CONFIG_DAC_CONTROLSET=""
CONFIG_DAC_KNOWN_CONFIGURATIONS="ESP-A1S-AC101(audio kit 2.2)-Fixed GPIOs|ESP-A1S-ES8388(audio kit 2.2+)-Fixed GPIOs"
CONFIG_DAC_KNOWN_CONFIGURATIONS_GPIOS="model
CONFIG_I2S_BCK_IO=-1 CONFIG_I2S_BCK_IO=-1
CONFIG_I2S_WS_IO=-1 CONFIG_I2S_WS_IO=-1
CONFIG_I2S_DO_IO=-1 CONFIG_I2S_DO_IO=-1

View File

@@ -107,17 +107,6 @@ menu "Squeezelite-ESP32"
endmenu endmenu
menu "Audio settings" menu "Audio settings"
menu "Known Configurations"
visible if BASIC_I2C_BT
config DAC_KNOWN_CONFIGURATIONS
string "Known DAC configurations"
default "ESP32A1S Old (AC101)|ESP32A1S V2.2+ (ES8388)|Xiaomi Gateway" if BASIC_I2C_BT
default ""
config DAC_KNOWN_CONFIGURATIONS_GPIOS
string "GPIOs for known DAC configurations"
default "model=AC101,sda=33,scl=32,bck=27,ws=26,di=35,do=25|model=ES8388,bck=5,ws=25,do=26,sda=18,scl=23,i2c=16|model=I2S,bck=12,ws=26,do=25,i2c=106,sda=18,scl=23" if BASIC_I2C_BT
default ""
endmenu
menu "DAC settings" menu "DAC settings"
visible if BASIC_I2C_BT visible if BASIC_I2C_BT
menu "I2S settings" menu "I2S settings"

View File

@@ -3,6 +3,13 @@
const fs = require("fs"); // Require the file system processing library const fs = require("fs"); // Require the file system processing library
const readline = require("readline"); // Require the readline processing library const readline = require("readline"); // Require the readline processing library
var map_types = {
"UNSET": 0,
"VALUE": 1,
"COMMENT": 2
};
// buildMap // buildMap
// Read the sdkconfig file specified by fileName and produce a map of the name/value pairs contained // Read the sdkconfig file specified by fileName and produce a map of the name/value pairs contained
// within. A Promise is returned that is fulfilled when the file has been read. // within. A Promise is returned that is fulfilled when the file has been read.
@@ -13,6 +20,8 @@ function buildMap(fileName) {
reject(err); reject(err);
}); });
const map = {}; const map = {};
const lines_index = [];
var lineNo = 1;
const lineReader = readline.createInterface({ const lineReader = readline.createInterface({
input: readStream, input: readStream,
@@ -26,20 +35,51 @@ function buildMap(fileName) {
if (line.length == 0) { // Ignore empty lines if (line.length == 0) { // Ignore empty lines
return; return;
} }
if (line.startsWith("#")) { // Ignore comment lines
return;
}
const parts = line.split("="); // Split the line into parts separated by the '=' character. // split lines using named capture group regex, and loop through the resulting array
if (map.hasOwnProperty(parts[0])) { var regexp = /^\s*[#]\s*(?<unset_key>CONFIG[^\s]*) is not set\s*$|^\s*(?<comment>[#].*)$|^\s*(?<key>[^#]{1}[^\s=]*)=(?<value>.*)$/gm;
console.log(`Odd ... we found ${parts[0]} twice.`); var match = regexp.exec(line);
var key="";
var map_entry={};
while (match != null) {
if (match.groups.unset_key) {
key = match.groups.unset_key;
map_entry = {
key:key,
type: map_types.UNSET,
value: undefined,
index: lineNo++,
};
} else if (match.groups.comment) {
// accumulate comments in an array
map_entry={
type: map_types.COMMENT,
value: match.groups.comment,
index: lineNo++,
};
}
else {
key = match.groups.key;
map_entry = {
key:key,
type: map_types.VALUE,
value: match.groups.value,
index: lineNo++,
};
}
if(map_entry.type!=map_types.COMMENT){
map[key] = map_entry;
}
lines_index.push(map_entry);
match = regexp.exec(line);
} }
map[parts[0]] = parts[1]; // Populate the map element.
}); // on(line) }); // on(line)
// Called when all the lines from the file have been consumed. // Called when all the lines from the file have been consumed.
lineReader.on("close", () => { lineReader.on("close", () => {
resolve(map); resolve({map, lines_index});
}); // on(close) }); // on(close)
}); });
@@ -48,46 +88,81 @@ function buildMap(fileName) {
const args = process.argv; const args = process.argv;
if (args.length != 4) { if (args.length != 3) {
console.log("Usage: node sdkconfig_compare file1 file2"); console.log("Usage: node sdkconfig_compare file1 ");
process.exit(); process.exit();
} }
const file1 = args[2]; const sdkconfig = ".\\sdkconfig";
const file2 = args[3]; const comparedFile = args[2];
buildMap(file1).then((result) => {
buildMap(file2).then((result2) => { buildMap(sdkconfig).then((sdkConfigResult ) => {
buildMap("./sdkconfig.defaults").then((result3) => { var sdkconfigMap = sdkConfigResult.map;
var sdkconfigLines = sdkConfigResult.lines_index;
buildMap(comparedFile).then((comparedResult) => {
var comparedFileMap = comparedResult.map;
var comparedLines = comparedResult.lines_index;
buildMap(".\\sdkconfig.defaults").then((sdkconfigResults) => {
var sdkconfig_defaults = sdkconfigResults.map;
var sdkconfig_defaults_lines = sdkconfigResults.lines_index;
// Three passes // Three passes
// In A and not B // In A and not B
// in B and not A // in B and not A
// value different in A and B // value different in A and B
console.log(`\n\n${file1} properties that are missing in ${file2}\n**************************`); var newmap = {};
for (const prop in result) { var entry={};
if (result.hasOwnProperty(prop)) { console.log(`\n\n${sdkconfig} properties that are missing in ${comparedFile}\n**************************`);
if (!result2.hasOwnProperty(prop) && !result3.hasOwnProperty(prop)) { for (const prop in sdkconfigMap) {
console.log(`${prop}=${result[prop]}`); entry = sdkconfigMap[prop];
if(entry.type==map_types.COMMENT || entry.type== map_types.UNSET) continue;
if (!comparedFileMap.hasOwnProperty(prop) && !sdkconfig_defaults.hasOwnProperty(prop)) {
newmap[prop] = entry;
console.log(`${prop}=${entry.value}`);
} }
else if(comparedFileMap.hasOwnProperty(prop)){
newmap[prop] =entry;
} }
} }
console.log(`\n\n${file2} properties that are missing in ${file1}\n**************************`); console.log(`\n\n${comparedFile} properties that are missing in ${sdkconfig}\n**************************`);
for (const prop in result2) { for (const prop in comparedFileMap) {
if (result2.hasOwnProperty(prop)) { entry = comparedFileMap[prop];
if (!result.hasOwnProperty(prop) && !result3.hasOwnProperty(prop)) { if(entry.type==map_types.COMMENT || entry.type== map_types.UNSET) continue;
console.log(`${prop}=${result2[prop]}`); if (comparedFileMap.hasOwnProperty(prop)) {
if (!sdkconfigMap.hasOwnProperty(prop) && !sdkconfig_defaults.hasOwnProperty(prop)) {
console.log(`${prop}=${entry.value}`);
} }
} }
} }
console.log(`\n\nproperties that are different between the 2 files \n**************************`); console.log(`\n\nproperties that are different between the 2 files \n**************************`);
for (const prop in result) { for (const prop in sdkconfigMap) {
if (result.hasOwnProperty(prop)) { entry = sdkconfigMap[prop];
if (result2.hasOwnProperty(prop)) { if(entry.type==map_types.COMMENT) continue;
if (result[prop] != result2[prop]) { if (sdkconfigMap.hasOwnProperty(prop)) {
console.log(`${prop} : [${result[prop]}] != [${result2[prop]}]`); if (comparedFileMap.hasOwnProperty(prop)) {
if (entry.value != comparedFileMap[prop].value) {
console.log(`${prop} : [${entry.value}] != [${comparedFileMap[prop].value}]`);
} }
} }
} }
} }
var newlines = [];
for(const prop in newmap){
newlines.splice(newmap[prop].index,0, `${prop}=${newmap[prop].value}`);
}
comparedLines.forEach(line=>{
if(line.type==map_types.COMMENT ) {
newlines.splice(line.index,0, line.value);
}
else if(line.type==map_types.UNSET){
newlines.splice(line.index,0, `# ${line.key} is not set`);
}
});
console.log(`\n\${comparedFile} with missing properties\n**************************`);
newlines.forEach(line => {
console.log(line);
});
}).catch((err) => { }).catch((err) => {
console.log(err); console.log(err);