diff --git a/CMakeLists.txt b/CMakeLists.txt index f744402..e4bf8b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,14 +19,30 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_C_STANDARD 11) # custom options -execute_process( - COMMAND git log -1 --format=%h - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE GIT_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE -) +#execute_process( +# COMMAND git log -1 --format=%h +# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} +# OUTPUT_VARIABLE GIT_HASH +# OUTPUT_STRIP_TRAILING_WHITESPACE +#) +# +#add_definitions(-DGIT_HASH=${GIT_HASH}) + +set(GIT_HASH "undefined") +find_package(Git QUIET) +if(GIT_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%h + OUTPUT_VARIABLE GIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) +endif() + +message(STATUS "Burning in git hash: ${GIT_HASH}") + +add_definitions("-DGIT_HASH=\"${GIT_HASH}\"") -add_definitions(-DGIT_HASH=${GIT_HASH}) #Uncomment for hardware floating point #add_compile_definitions(ARM_MATH_CM4;ARM_MATH_MATRIX_CHECK;ARM_MATH_ROUNDING) @@ -40,7 +56,7 @@ add_compile_options(-mcpu=cortex-m4 -mthumb -mthumb-interwork) add_compile_options(-ffunction-sections -fdata-sections -fno-common -fmessage-length=0) # uncomment to mitigate c++17 absolute addresses warnings -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-register") +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-register") # Enable assembler files preprocessing add_compile_options($<$:-x$assembler-with-cpp>) @@ -96,4 +112,4 @@ add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex $ ${HEX_FILE} COMMAND ${CMAKE_OBJCOPY} -Obinary $ ${BIN_FILE} COMMENT "Building ${HEX_FILE} -Building ${BIN_FILE}") +Building ${BIN_FILE}") \ No newline at end of file diff --git a/Tools/floatpytools/__init__.py b/Tools/floatpytools/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/Tools/floatpytools/gen_git_rev.py b/Tools/floatpytools/gen_git_rev.py deleted file mode 100644 index 66f072b..0000000 --- a/Tools/floatpytools/gen_git_rev.py +++ /dev/null @@ -1,30 +0,0 @@ -import os.path -import subprocess -from jinja2 import Environment, PackageLoader, select_autoescape - -def shortgitrev() -> str: - return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip() - -def gengitrev(): - env = Environment( - loader=PackageLoader("gen_git_rev"), - autoescape=select_autoescape() - ) - - template = env.get_template("git_revision.h") - - stream = template.stream(hash=shortgitrev()) - - # Check if in Project root - print(os.path.abspath("Core/Inc")) - if(os.path.exists(os.path.abspath("Core/Inc"))): - print("Core/Inc dir found, generating file...") - with open(os.path.abspath("Core/Inc/git_rev.h"), 'w') as fp: - stream.dump(fp) - else: - print("ERROR: Run this script from the Project root!") - exit(-1) - - -if __name__ == "__main__": - gengitrev() \ No newline at end of file diff --git a/Tools/floatpytools/templates/git_revision.h b/Tools/floatpytools/templates/git_revision.h deleted file mode 100644 index 87b0ca9..0000000 --- a/Tools/floatpytools/templates/git_revision.h +++ /dev/null @@ -1,12 +0,0 @@ -// -// Created by robtor on 15.12.22. -// - -#ifndef FLOATPUMP_GIT_REVISION_TEMPLATE_H -#define FLOATPUMP_GIT_REVISION_TEMPLATE_H - -// Auto generated header file containing the last git revision - -#define GIT_HASH "{{ hash }}" - -#endif //FLOATPUMP_GIT_REVISION_TEMPLATE_H diff --git a/floatpump/Core/Inc/git_rev.h b/floatpump/Core/Inc/git_rev.h deleted file mode 100644 index 432616a..0000000 --- a/floatpump/Core/Inc/git_rev.h +++ /dev/null @@ -1,12 +0,0 @@ -// -// Created by robtor on 15.12.22. -// - -#ifndef FLOATPUMP_GIT_REVISION_TEMPLATE_H -#define FLOATPUMP_GIT_REVISION_TEMPLATE_H - -// Auto generated header file containing the last git revision - -#define GIT_HASH "8f1aed9" - -#endif //FLOATPUMP_GIT_REVISION_TEMPLATE_H \ No newline at end of file diff --git a/floatpump/Middlewares/floatpump/Inc/InitSequence.h b/floatpump/Middlewares/floatpump/Inc/InitSequence.h index a184992..ed0a548 100644 --- a/floatpump/Middlewares/floatpump/Inc/InitSequence.h +++ b/floatpump/Middlewares/floatpump/Inc/InitSequence.h @@ -9,7 +9,6 @@ #include "main.h" #include "LCD_I2C_Driver.h" -#include "git_rev.h" namespace floatpump {