User board-specific terms in error messages #3886
just refactoring for now
This commit is contained in:
parent
2beca221a3
commit
caced85ad0
|
@ -76,7 +76,7 @@ public class ConfigDefinition {
|
||||||
String signaturePrependFile = null;
|
String signaturePrependFile = null;
|
||||||
List<String> enumInputFiles = new ArrayList<>();
|
List<String> enumInputFiles = new ArrayList<>();
|
||||||
boolean withC_Defines = true;
|
boolean withC_Defines = true;
|
||||||
File[] boardYamlFiles = null;
|
PinoutLogic pinoutLogic = null;
|
||||||
String tsOutputsDestination = null;
|
String tsOutputsDestination = null;
|
||||||
String definitionInputFile = null;
|
String definitionInputFile = null;
|
||||||
|
|
||||||
|
@ -162,15 +162,9 @@ public class ConfigDefinition {
|
||||||
break;
|
break;
|
||||||
case KEY_BOARD_NAME:
|
case KEY_BOARD_NAME:
|
||||||
String boardName = args[i + 1];
|
String boardName = args[i + 1];
|
||||||
String dirPath = "./config/boards/" + boardName + "/connectors";
|
pinoutLogic = PinoutLogic.create(boardName);
|
||||||
File dirName = new File(dirPath);
|
if (pinoutLogic != null)
|
||||||
FilenameFilter filter = (f, name) -> name.endsWith(".yaml");
|
inputFiles.addAll(pinoutLogic.getInputFiles());
|
||||||
boardYamlFiles = dirName.listFiles(filter);
|
|
||||||
if (boardYamlFiles != null) {
|
|
||||||
for (File yamlFile : boardYamlFiles) {
|
|
||||||
inputFiles.add("config/boards/" + boardName + "/connectors/" + yamlFile.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,8 +192,8 @@ public class ConfigDefinition {
|
||||||
for (String prependFile : prependFiles)
|
for (String prependFile : prependFiles)
|
||||||
state.variableRegistry.readPrependValues(prependFile);
|
state.variableRegistry.readPrependValues(prependFile);
|
||||||
|
|
||||||
if (boardYamlFiles != null) {
|
if (pinoutLogic != null) {
|
||||||
PinoutLogic.processYamls(state.variableRegistry, boardYamlFiles, state);
|
pinoutLogic.processYamls(state.variableRegistry, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the input files
|
// Parse the input files
|
||||||
|
|
|
@ -6,16 +6,20 @@ import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
|
import java.io.FilenameFilter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class PinoutLogic {
|
public class PinoutLogic {
|
||||||
public static void processYamls(VariableRegistry registry, File[] yamlFiles, ReaderState state) throws IOException {
|
private static final String CONFIG_BOARDS = "config/boards/";
|
||||||
ArrayList<Map<String, Object>> listPins = new ArrayList<>();
|
private static final String CONNECTORS = "/connectors";
|
||||||
for (File yamlFile : yamlFiles) {
|
|
||||||
processYamlFile(yamlFile, listPins);
|
private final File[] boardYamlFiles;
|
||||||
}
|
private final String boardName;
|
||||||
registerPins(listPins, registry, state);
|
|
||||||
|
public PinoutLogic(String boardName, File[] boardYamlFiles) {
|
||||||
|
this.boardName = boardName;
|
||||||
|
this.boardYamlFiles = boardYamlFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerPins(ArrayList<Map<String, Object>> listPins, VariableRegistry registry, ReaderState state) {
|
private static void registerPins(ArrayList<Map<String, Object>> listPins, VariableRegistry registry, ReaderState state) {
|
||||||
|
@ -141,4 +145,31 @@ public class PinoutLogic {
|
||||||
thisPin.put("class", pinClass);
|
thisPin.put("class", pinClass);
|
||||||
thisPinList.add(thisPin);
|
thisPinList.add(thisPin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PinoutLogic create(String boardName) {
|
||||||
|
String dirPath = PinoutLogic.CONFIG_BOARDS + boardName + PinoutLogic.CONNECTORS;
|
||||||
|
File dirName = new File(dirPath);
|
||||||
|
FilenameFilter filter = (f, name) -> name.endsWith(".yaml");
|
||||||
|
File[] boardYamlFiles = dirName.listFiles(filter);
|
||||||
|
if (boardYamlFiles == null)
|
||||||
|
return null;
|
||||||
|
return new PinoutLogic(boardName, boardYamlFiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processYamls(VariableRegistry registry, ReaderState state) throws IOException {
|
||||||
|
ArrayList<Map<String, Object>> listPins = new ArrayList<>();
|
||||||
|
for (File yamlFile : boardYamlFiles) {
|
||||||
|
processYamlFile(yamlFile, listPins);
|
||||||
|
}
|
||||||
|
registerPins(listPins, registry, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getInputFiles() {
|
||||||
|
List<String> result = new ArrayList<>();
|
||||||
|
for (File yamlFile : boardYamlFiles) {
|
||||||
|
result.add(PinoutLogic.CONFIG_BOARDS + boardName + PinoutLogic.CONNECTORS +
|
||||||
|
File.separator + yamlFile.getName());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue