gen_config new hash (#1561)
Co-authored-by: Andrei <andreikagit@users.noreply.github.com>
This commit is contained in:
parent
f2247cf5c0
commit
2ccae8669c
|
@ -9,11 +9,7 @@ date=$(date +"%Y.%m.%d")
|
||||||
echo "#define SIGNATURE_DATE $date" > tunerstudio/signature_${SHORT_BOARDNAME}.txt
|
echo "#define SIGNATURE_DATE $date" > tunerstudio/signature_${SHORT_BOARDNAME}.txt
|
||||||
echo "#define SIGNATURE_BOARD ${SHORT_BOARDNAME}" >> tunerstudio/signature_${SHORT_BOARDNAME}.txt
|
echo "#define SIGNATURE_BOARD ${SHORT_BOARDNAME}" >> tunerstudio/signature_${SHORT_BOARDNAME}.txt
|
||||||
|
|
||||||
nanosec=$(date +"%N")
|
echo "// SIGNATURE_HASH is a built-in variable generated by ConfigDefinition.jar" >> tunerstudio/signature_${SHORT_BOARDNAME}.txt
|
||||||
# prevent octal numbers once and for all
|
|
||||||
nanosec="1$nanosec"
|
|
||||||
hash=$(($nanosec % 2147483648))
|
|
||||||
echo "#define SIGNATURE_HASH $hash" >> tunerstudio/signature_${SHORT_BOARDNAME}.txt
|
|
||||||
|
|
||||||
echo "#define TS_SIGNATURE \"rusEFI @@SIGNATURE_DATE@@.@@SIGNATURE_BOARD@@.@@SIGNATURE_HASH@@\"" >> tunerstudio/signature_${SHORT_BOARDNAME}.txt
|
echo "#define TS_SIGNATURE \"rusEFI @@SIGNATURE_DATE@@.@@SIGNATURE_BOARD@@.@@SIGNATURE_HASH@@\"" >> tunerstudio/signature_${SHORT_BOARDNAME}.txt
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Andrey Belomutskiy, (c) 2013-2020
|
* Andrey Belomutskiy, (c) 2013-2020
|
||||||
|
@ -169,6 +170,9 @@ public class ConfigDefinition {
|
||||||
boolean needToUpdateTsFiles = false;
|
boolean needToUpdateTsFiles = false;
|
||||||
if (tsPath != null) {
|
if (tsPath != null) {
|
||||||
inputAllFiles.add(TSProjectConsumer.getTsFileInputName(tsPath));
|
inputAllFiles.add(TSProjectConsumer.getTsFileInputName(tsPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsPath != null) {
|
||||||
SystemOut.println("Check the input/output TS files:");
|
SystemOut.println("Check the input/output TS files:");
|
||||||
needToUpdateTsFiles = checkIfOutputFilesAreOutdated(inputAllFiles, cachePath, cacheZipFile);
|
needToUpdateTsFiles = checkIfOutputFilesAreOutdated(inputAllFiles, cachePath, cacheZipFile);
|
||||||
}
|
}
|
||||||
|
@ -180,6 +184,17 @@ public class ConfigDefinition {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get CRC32 of given input files
|
||||||
|
long crc32 = 0;
|
||||||
|
for (String iFile : inputAllFiles) {
|
||||||
|
long c = getCrc32(iFile) & 0xffffffffL;
|
||||||
|
SystemOut.println("CRC32 from " + iFile + " = " + c);
|
||||||
|
crc32 ^= c;
|
||||||
|
}
|
||||||
|
SystemOut.println("CRC32 from all input files = " + crc32);
|
||||||
|
// store the CRC32 as a built-in variable
|
||||||
|
VariableRegistry.INSTANCE.register("SIGNATURE_HASH", "" + crc32);
|
||||||
|
|
||||||
if (firingEnumFileName != null) {
|
if (firingEnumFileName != null) {
|
||||||
SystemOut.println("Reading firing from " + firingEnumFileName);
|
SystemOut.println("Reading firing from " + firingEnumFileName);
|
||||||
VariableRegistry.INSTANCE.register("FIRINGORDER", FiringOrderTSLogic.invoke(firingEnumFileName));
|
VariableRegistry.INSTANCE.register("FIRINGORDER", FiringOrderTSLogic.invoke(firingEnumFileName));
|
||||||
|
@ -210,6 +225,8 @@ public class ConfigDefinition {
|
||||||
destinations.add(new TSProjectConsumer(tsWriter, tsPath, state));
|
destinations.add(new TSProjectConsumer(tsWriter, tsPath, state));
|
||||||
|
|
||||||
VariableRegistry tmpRegistry = new VariableRegistry();
|
VariableRegistry tmpRegistry = new VariableRegistry();
|
||||||
|
// store the CRC32 as a built-in variable
|
||||||
|
tmpRegistry.register("SIGNATURE_HASH", "" + crc32);
|
||||||
readPrependValues(tmpRegistry, signaturePrependFile);
|
readPrependValues(tmpRegistry, signaturePrependFile);
|
||||||
destinations.add(new SignatureConsumer(signatureDestination, tmpRegistry));
|
destinations.add(new SignatureConsumer(signatureDestination, tmpRegistry));
|
||||||
}
|
}
|
||||||
|
@ -440,4 +457,18 @@ public class ConfigDefinition {
|
||||||
private static String getCachedInputFileName(String inputFile, String cachePath) {
|
private static String getCachedInputFileName(String inputFile, String cachePath) {
|
||||||
return cachePath + File.separator + inputFile;
|
return cachePath + File.separator + inputFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static long getCrc32(String fileName) throws IOException {
|
||||||
|
File file = new File(fileName);
|
||||||
|
byte[] f1 = Files.readAllBytes(file.toPath());
|
||||||
|
CRC32 c = new CRC32();
|
||||||
|
c.update(f1, 0, f1.length);
|
||||||
|
return c.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void deleteFile(String fileName) throws IOException {
|
||||||
|
File file = new File(fileName);
|
||||||
|
// todo: validate?
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue