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;
|
||||
List<String> enumInputFiles = new ArrayList<>();
|
||||
boolean withC_Defines = true;
|
||||
File[] boardYamlFiles = null;
|
||||
PinoutLogic pinoutLogic = null;
|
||||
String tsOutputsDestination = null;
|
||||
String definitionInputFile = null;
|
||||
|
||||
|
@ -162,15 +162,9 @@ public class ConfigDefinition {
|
|||
break;
|
||||
case KEY_BOARD_NAME:
|
||||
String boardName = args[i + 1];
|
||||
String dirPath = "./config/boards/" + boardName + "/connectors";
|
||||
File dirName = new File(dirPath);
|
||||
FilenameFilter filter = (f, name) -> name.endsWith(".yaml");
|
||||
boardYamlFiles = dirName.listFiles(filter);
|
||||
if (boardYamlFiles != null) {
|
||||
for (File yamlFile : boardYamlFiles) {
|
||||
inputFiles.add("config/boards/" + boardName + "/connectors/" + yamlFile.getName());
|
||||
}
|
||||
}
|
||||
pinoutLogic = PinoutLogic.create(boardName);
|
||||
if (pinoutLogic != null)
|
||||
inputFiles.addAll(pinoutLogic.getInputFiles());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -198,8 +192,8 @@ public class ConfigDefinition {
|
|||
for (String prependFile : prependFiles)
|
||||
state.variableRegistry.readPrependValues(prependFile);
|
||||
|
||||
if (boardYamlFiles != null) {
|
||||
PinoutLogic.processYamls(state.variableRegistry, boardYamlFiles, state);
|
||||
if (pinoutLogic != null) {
|
||||
pinoutLogic.processYamls(state.variableRegistry, state);
|
||||
}
|
||||
|
||||
// Parse the input files
|
||||
|
|
|
@ -6,16 +6,20 @@ import org.yaml.snakeyaml.Yaml;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class PinoutLogic {
|
||||
public static void processYamls(VariableRegistry registry, File[] yamlFiles, ReaderState state) throws IOException {
|
||||
ArrayList<Map<String, Object>> listPins = new ArrayList<>();
|
||||
for (File yamlFile : yamlFiles) {
|
||||
processYamlFile(yamlFile, listPins);
|
||||
}
|
||||
registerPins(listPins, registry, state);
|
||||
private static final String CONFIG_BOARDS = "config/boards/";
|
||||
private static final String CONNECTORS = "/connectors";
|
||||
|
||||
private final File[] boardYamlFiles;
|
||||
private final String boardName;
|
||||
|
||||
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) {
|
||||
|
@ -141,4 +145,31 @@ public class PinoutLogic {
|
|||
thisPin.put("class", pinClass);
|
||||
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