current GIT hash is now available to firmware source code

This commit is contained in:
rusefi 2019-02-02 19:47:16 -05:00
parent d46ebf97de
commit 6709070817
4 changed files with 24 additions and 11 deletions

View File

@ -1,5 +1,9 @@
// This file was generated by Version2Header // This file was generated by Version2Header
// Fri Feb 01 18:26:44 EST 2019 // Sat Feb 02 19:45:56 EST 2019
#ifndef VCS_VERSION #ifndef GIT_HASH
#define VCS_VERSION "16581" #ifndef GIT_HASH
#define GIT_HASH "d46ebf97de076858e7654ba198dc2b19b1c4470d"
#endif
#ifndef VCS_VERSION
#define VCS_VERSION "16628"
#endif #endif

View File

@ -1,3 +1,6 @@
rem Let's regemerate 'svnversion.h' rem Let's regemerate 'svnversion.h'
rem TODO: handle std err - for example, in case svn needs upgrade rem TODO: handle std err - for example, in case svn needs upgrade
java -jar ../java_tools/version2header.jar 10000 https://github.com/rusefi/rusefi
for /f %%i in ('git rev-parse HEAD') do set git_hash=%%i
echo Git hash=%git_hash%
java -jar ../java_tools/version2header.jar 10000 https://github.com/rusefi/rusefi %git_hash%

Binary file not shown.

View File

@ -9,24 +9,26 @@ import java.util.Date;
public class Version2Header { public class Version2Header {
private static final String NL = "\n";//System.getProperty("line.separator"); private static final String NL = "\n";//System.getProperty("line.separator");
private static final String COMMAND = "svn info "; private static final String SVN_COMMAND = "svn info ";
private static final String VERSION_MARKER = "Last Changed Rev: "; private static final String VERSION_MARKER = "Last Changed Rev: ";
private static final String HEADER_TAG = "VCS_VERSION"; private static final String HEADER_TAG = "VCS_VERSION";
private static final String GIT_HASH_TAG = "GIT_HASH";
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
if (args.length != 1 && args.length != 2) { if (args.length != 3) {
System.out.println("Version offset value is now a mandatory parameter!"); System.out.println("offset, URL and githash should be specified");
System.exit(-1); System.exit(-1);
} }
int versionOffsetValue = Integer.parseInt(args[0]); int versionOffsetValue = Integer.parseInt(args[0]);
String url = args.length == 2 ? args[1] : ""; String url = args[1];
String gitHash = args[2];
System.out.println("Hi, it's " + new Date()); System.out.println("Hi, it's " + new Date());
if (url.isEmpty()) { if (url.isEmpty()) {
System.out.println("Looking for local version"); System.out.println("Looking for local version");
} else { } else {
System.out.println("Looking for remove version: " + url); System.out.println("Looking for remove version: " + url);
} }
String command = COMMAND + url; String command = SVN_COMMAND + url;
System.out.println("Working with " + NL.length() + " line ends, offset " + versionOffsetValue); System.out.println("Working with " + NL.length() + " line ends, offset " + versionOffsetValue);
Process simulatorProcess = null; Process simulatorProcess = null;
@ -47,7 +49,7 @@ public class Version2Header {
String ver = line.substring(VERSION_MARKER.length()); String ver = line.substring(VERSION_MARKER.length());
System.out.println("Version [" + ver + "]"); System.out.println("Version [" + ver + "]");
int version = Integer.parseInt(ver); int version = Integer.parseInt(ver);
writeFile(versionOffsetValue + version); writeFile(versionOffsetValue + version, gitHash);
} }
} }
System.out.println("Got " + counter + " lines of stdout"); System.out.println("Got " + counter + " lines of stdout");
@ -64,10 +66,14 @@ public class Version2Header {
} }
} }
private static void writeFile(int version) throws IOException { private static void writeFile(int version, String gitHash) throws IOException {
BufferedWriter bw = new BufferedWriter(new FileWriter("svnversion.h")); BufferedWriter bw = new BufferedWriter(new FileWriter("svnversion.h"));
bw.write("// This file was generated by Version2Header" + NL); bw.write("// This file was generated by Version2Header" + NL);
bw.write("// " + new Date() + NL); bw.write("// " + new Date() + NL);
bw.write("#ifndef " + GIT_HASH_TAG + NL);
bw.write("#ifndef " + GIT_HASH_TAG + NL);
bw.write("#define " + GIT_HASH_TAG + " \"" + gitHash + "\"" + NL);
bw.write("#endif" + NL);
bw.write("#ifndef " + HEADER_TAG + NL); bw.write("#ifndef " + HEADER_TAG + NL);
bw.write("#define " + HEADER_TAG + " \"" + version + "\"" + NL); bw.write("#define " + HEADER_TAG + " \"" + version + "\"" + NL);
bw.write("#endif" + NL); bw.write("#endif" + NL);