FSIO command-line compilation

This commit is contained in:
rusefi 2017-08-06 20:24:00 -04:00
parent d55aa6ac78
commit cb2b35b6f6
2 changed files with 32 additions and 13 deletions

View File

@ -13,12 +13,13 @@ import java.util.List;
*/
public class CompileTool {
private static String NEWLINE = "\n";
public static void run(List<String> args) throws IOException {
public static int run(List<String> args) throws IOException {
System.out.println("Params " + args);
if (args.size() != 2) {
System.out.println("Please specify input file and output file name");
return;
return -1;
}
String inputFileName = args.get(0);
@ -37,22 +38,25 @@ public class CompileTool {
while ((line = br.readLine()) != null) {
line = line.trim();
// line = line.replaceAll("\\s+", " ");
bw.write(handleOneFsioLine(line));
handleOneFsioLine(line, bw);
}
}
System.out.println("Done!");
return 0;
}
private static void handleOneFsioLine(String line, BufferedWriter bw) throws IOException {
public static String handleOneFsioLine(String line) throws IOException {
if (line.isEmpty())
return;
return "";
StringBuilder result = new StringBuilder();
if (line.charAt(0) == '#') {
// forwarding comment into the output
bw.write("//" + line.substring(1) + NEWLINE);
return;
result.append("//" + line.substring(1) + NEWLINE);
return result.toString();
}
int indexOfEquals = line.indexOf('=');
if (indexOfEquals == -1) {
@ -71,8 +75,8 @@ public class CompileTool {
} catch (Throwable e) {
throw new IllegalStateException("For " + expression, e);
}
bw.write(NEWLINE + "// Human-readable: " + expression + NEWLINE);
bw.write("#define " + name + " \"" + rpn + "\"" + NEWLINE);
result.append(NEWLINE + "// Human-readable: " + expression + NEWLINE);
result.append("#define " + name + " \"" + rpn + "\"" + NEWLINE);
return result.toString();
}
}

View File

@ -45,7 +45,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* @see EngineSnifferPanel
*/
public class Launcher {
public static final int CONSOLE_VERSION = 20170805;
public static final int CONSOLE_VERSION = 20170806;
public static final boolean SHOW_STIMULATOR = false;
private static final String TAB_INDEX = "main_tab";
protected static final String PORT_KEY = "port";
@ -287,10 +287,25 @@ public class Launcher {
public static void main(final String[] args) throws Exception {
String toolName = args.length == 0 ? null : args[0];
if ("compile_fsio_file".equalsIgnoreCase(toolName)) {
CompileTool.run(Arrays.asList(args).subList(1, args.length));
/**
* re-packaging array which contains input and output file names
*/
int returnCode = CompileTool.run(Arrays.asList(args).subList(1, args.length));
System.exit(returnCode);
return;
}
if ("compile".equals(toolName)) {
if (args.length != 2) {
System.err.println("input expression parameter expected");
System.exit(-1);
return;
}
String input = args[1];
System.out.println(CompileTool.handleOneFsioLine(input));
System.exit(0);
}
FileLog.MAIN.start();
getConfig().load();
@ -317,7 +332,7 @@ public class Launcher {
if (value != Fields.TS_FILE_VERSION) {
String message = "This copy of rusEfi console is not compatible with this version of firmware\r\n" +
"Console compatible with " + Fields.TS_FILE_VERSION + " while firmware compatible with " +
(int)value;
(int) value;
JOptionPane.showMessageDialog(Launcher.getFrame(), message);
assert wrongVersionListener != null;
SensorCentral.getInstance().removeListener(Sensor.FIRMWARE_VERSION, wrongVersionListener);