Created
March 8, 2023 14:36
-
-
Save ricardodeazambuja/4b779a9eaf3174719c19644ef9363c31 to your computer and use it in GitHub Desktop.
INAV 6 patch to add repository name and commit to the generated hex file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To apply this patch: | |
# git apply add_repo_commit_to_hex.patch | |
diff --git a/CMakeLists.txt b/CMakeLists.txt | |
index 04623c677..7a8005eea 100644 | |
--- a/CMakeLists.txt | |
+++ b/CMakeLists.txt | |
@@ -1,5 +1,20 @@ | |
cmake_minimum_required(VERSION 3.13...3.18) | |
+execute_process(COMMAND bash "-c" "echo $(git remote get-url origin | sed -e 's&https://github.com/&&; s&[email protected]:&&; s&.git&&; s&/&_&;')" | |
+ OUTPUT_STRIP_TRAILING_WHITESPACE | |
+ OUTPUT_VARIABLE REPO | |
+) | |
+ | |
+execute_process(COMMAND bash "-c" "echo $(git rev-parse --abbrev-ref HEAD)" | |
+ OUTPUT_STRIP_TRAILING_WHITESPACE | |
+ OUTPUT_VARIABLE BRANCH | |
+) | |
+ | |
+execute_process(COMMAND bash "-c" "echo $(git rev-parse --short HEAD)" | |
+ OUTPUT_STRIP_TRAILING_WHITESPACE | |
+ OUTPUT_VARIABLE COMMIT_ID | |
+) | |
+ | |
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") | |
set(MAIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}") | |
diff --git a/cmake/stm32.cmake b/cmake/stm32.cmake | |
index f852e44e0..c6acf4829 100644 | |
--- a/cmake/stm32.cmake | |
+++ b/cmake/stm32.cmake | |
@@ -347,7 +347,7 @@ function(target_stm32) | |
# Main firmware | |
add_stm32_executable( | |
NAME ${name} | |
- FILENAME ${binary_name} | |
+ FILENAME ${binary_name}_${REPO}-${BRANCH}-${COMMIT_ID} | |
SOURCES ${target_sources} ${msc_sources} ${CMSIS_DSP_SRC} ${COMMON_SRC} | |
COMPILE_DEFINITIONS ${target_definitions} | |
COMPILE_OPTIONS ${args_COMPILE_OPTIONS} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment