Forráskód Böngészése

cmake: Work-around gcc 7 not supporting SOURCE_DATE_EPOCH

Yuri D'Elia 2 éve
szülő
commit
a8e85bd146
3 módosított fájl, 15 hozzáadás és 4 törlés
  1. 6 0
      CMakeLists.txt
  2. 8 3
      Firmware/Configuration.h
  3. 1 1
      Firmware/ultralcd.cpp

+ 6 - 0
CMakeLists.txt

@@ -240,6 +240,12 @@ if(CMAKE_CROSSCOMPILING)
 
     # TODO: get date from the last git commit to set as epoch
     set(ENV{SOURCE_DATE_EPOCH} 0)
+    if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8")
+        string(TIMESTAMP SOURCE_DATE_EPOCH "%Y-%m-%d")
+        add_compile_definitions(SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH}")
+        string(TIMESTAMP SOURCE_TIME_EPOCH "%H:%M:%S")
+        add_compile_definitions(SOURCE_TIME_EPOCH="${SOURCE_TIME_EPOCH}")
+    endif()
 
     # default optimization flags
     set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")

+ 8 - 3
Firmware/Configuration.h

@@ -63,6 +63,13 @@ extern PGM_P sPrinterName;
 #undef DEBUG_BUILD
 #endif
 
+#ifndef SOURCE_DATE_EPOCH
+#define SOURCE_DATE_EPOCH __DATE__
+#endif
+#ifndef SOURCE_TIME_EPOCH
+#define SOURCE_TIME_EPOCH __TIME__
+#endif
+
 #include "Configuration_prusa.h"
 
 #define FW_PRUSA3D_MAGIC "PRUSA3DFW"
@@ -78,9 +85,7 @@ extern PGM_P sPrinterName;
 // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
 // build by the user have been successfully uploaded into firmware.
 
-//#define STRING_VERSION "1.0.2"
-
-#define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time
+#define STRING_VERSION_CONFIG_H SOURCE_DATE_EPOCH " " SOURCE_TIME_EPOCH // build date and time
 #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes.
 
 // SERIAL_PORT selects which serial port should be used for communication with the host.

+ 1 - 1
Firmware/ultralcd.cpp

@@ -1657,7 +1657,7 @@ static void lcd_support_menu()
   MENU_ITEM_BACK_P(PSTR(NOZZLE_TYPE));
   MENU_ITEM_BACK_P(STR_SEPARATOR);
   MENU_ITEM_BACK_P(_i("Date:"));////MSG_DATE c=17
-  MENU_ITEM_BACK_P(PSTR(__DATE__));
+  MENU_ITEM_BACK_P(PSTR(SOURCE_DATE_EPOCH));
 
 #if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
   MENU_ITEM_BACK_P(STR_SEPARATOR);