more dead code & reducing static magic
This commit is contained in:
parent
2117738d13
commit
9ed57e36cd
|
@ -11,7 +11,6 @@ import java.util.regex.Pattern;
|
|||
public class LazyFile implements Output {
|
||||
public static final String LAZY_FILE_TAG = "was generated automatically by rusEFI tool ";
|
||||
public static final String LAZY_FILE_TAG_LOWER = LAZY_FILE_TAG.toLowerCase();
|
||||
private static boolean isLazyCheckEnabled = true;
|
||||
|
||||
private final String filename;
|
||||
|
||||
|
@ -38,7 +37,7 @@ public class LazyFile implements Output {
|
|||
String fileContent = unifySpaces(readCurrentContent(filename));
|
||||
String newContent = unifySpaces(contentWithoutTag.toString());
|
||||
|
||||
if (fileContent.equals(newContent) && LazyFile.isLazyCheckEnabled()) {
|
||||
if (fileContent.equals(newContent)) {
|
||||
SystemOut.println(getClass().getSimpleName() + ": Not updating " + filename + " since looks to be the same content, new content size=" + contentWithoutTag.length());
|
||||
return;
|
||||
}
|
||||
|
@ -57,14 +56,6 @@ public class LazyFile implements Output {
|
|||
fw.close();
|
||||
}
|
||||
|
||||
public static void setLazyFileEnabled(boolean isEnabled) {
|
||||
LazyFile.isLazyCheckEnabled = isEnabled;
|
||||
}
|
||||
|
||||
public static boolean isLazyCheckEnabled() {
|
||||
return LazyFile.isLazyCheckEnabled;
|
||||
}
|
||||
|
||||
public static String unifySpaces(String line) {
|
||||
line = line.replace("\r", "");
|
||||
return line.replaceAll("\n[\n]*", "");
|
||||
|
|
Binary file not shown.
|
@ -4,7 +4,6 @@ import com.rusefi.newparse.ParseState;
|
|||
import com.rusefi.newparse.parsing.Definition;
|
||||
import com.rusefi.output.*;
|
||||
import com.rusefi.util.IoUtils;
|
||||
import com.rusefi.util.LazyFile;
|
||||
import com.rusefi.util.SystemOut;
|
||||
|
||||
import java.io.*;
|
||||
|
@ -26,9 +25,6 @@ public class ConfigDefinition {
|
|||
private static final String KEY_TS_DESTINATION = "-ts_destination";
|
||||
private static final String KEY_C_DESTINATION = "-c_destination";
|
||||
private static final String KEY_C_DEFINES = "-c_defines";
|
||||
/**
|
||||
* @see CHeaderConsumer#withC_Defines
|
||||
*/
|
||||
private static final String KEY_WITH_C_DEFINES = "-with_c_defines";
|
||||
private static final String KEY_JAVA_DESTINATION = "-java_destination";
|
||||
private static final String KEY_ROMRAIDER_DESTINATION = "-romraider_destination";
|
||||
|
@ -81,15 +77,13 @@ public class ConfigDefinition {
|
|||
String signatureDestination = null;
|
||||
String signaturePrependFile = null;
|
||||
List<String> enumInputFiles = new ArrayList<>();
|
||||
CHeaderConsumer.withC_Defines = true;
|
||||
boolean withC_Defines = true;
|
||||
File[] boardYamlFiles = null;
|
||||
String tsOutputsDestination = null;
|
||||
String definitionInputFile = null;
|
||||
|
||||
// used to update other files
|
||||
List<String> inputFiles = new ArrayList<>();
|
||||
// disable the lazy checks because we use timestamps to detect changes
|
||||
LazyFile.setLazyFileEnabled(true);
|
||||
|
||||
List<ConfigurationConsumer> destinations = new ArrayList<>();
|
||||
ReaderState state = new ReaderState();
|
||||
|
@ -111,13 +105,13 @@ public class ConfigDefinition {
|
|||
tsOutputsDestination = args[i + 1];
|
||||
break;
|
||||
case KEY_C_DESTINATION:
|
||||
destinations.add(new CHeaderConsumer(state.variableRegistry, args[i + 1]));
|
||||
destinations.add(new CHeaderConsumer(state.variableRegistry, args[i + 1], withC_Defines));
|
||||
break;
|
||||
case KEY_ZERO_INIT:
|
||||
needZeroInit = Boolean.parseBoolean(args[i + 1]);
|
||||
break;
|
||||
case KEY_WITH_C_DEFINES:
|
||||
CHeaderConsumer.withC_Defines = Boolean.parseBoolean(args[i + 1]);
|
||||
withC_Defines = Boolean.parseBoolean(args[i + 1]);
|
||||
break;
|
||||
case KEY_C_DEFINES:
|
||||
destCDefinesFileName = args[i + 1];
|
||||
|
|
|
@ -16,12 +16,13 @@ public class CHeaderConsumer extends BaseCHeaderConsumer {
|
|||
* looks like sometimes we want to not include "define XXX value" into generated C headers
|
||||
* TODO: document the use-case better
|
||||
*/
|
||||
public static boolean withC_Defines;
|
||||
private final boolean withC_Defines;
|
||||
private final LazyFile cHeader;
|
||||
private final VariableRegistry variableRegistry;
|
||||
|
||||
public CHeaderConsumer(VariableRegistry variableRegistry, String destCHeader) {
|
||||
public CHeaderConsumer(VariableRegistry variableRegistry, String destCHeader, boolean withC_Defines) {
|
||||
this.variableRegistry = variableRegistry;
|
||||
this.withC_Defines = withC_Defines;
|
||||
SystemOut.println("Writing C header to " + destCHeader);
|
||||
cHeader = new LazyFile(destCHeader);
|
||||
cHeader.write("// this section " + ConfigDefinition.MESSAGE + EOL);
|
||||
|
|
Loading…
Reference in New Issue