From b059713df5a215b1cef3078db79812b15eaf4d2d Mon Sep 17 00:00:00 2001 From: jomjol <30766535+jomjol@users.noreply.github.com> Date: Mon, 21 Sep 2020 22:15:11 +0200 Subject: [PATCH] Update --- code/CMakeLists.txt | 3 +++ code/src/CMakeLists.txt | 14 ++++++++++++++ code/src/githash.cmd | 8 ++++++++ code/src/main.cpp | 5 ++++- code/src/version.h | 23 +++++++++++++++++++++++ 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 code/src/githash.cmd create mode 100644 code/src/version.h diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index c4d868ae..0de4f611 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 3.16.0) + +COMMAND (${CMAKE_SOURCE_DIR}/src/get_git_hash.cmd) + list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) set(PROJECT_VER "0.0.9.3") diff --git a/code/src/CMakeLists.txt b/code/src/CMakeLists.txt index ddbff466..0322c3d8 100644 --- a/code/src/CMakeLists.txt +++ b/code/src/CMakeLists.txt @@ -1,7 +1,21 @@ # This file was automatically generated for projects # without default 'CMakeLists.txt' file. +<<<<<<< Updated upstream FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*) +======= + + +#if(NOT CMAKE_BUILD_EARLY_EXPANSION) +#ADD_CUSTOM_COMMAND( +# OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp +# ${CMAKE_CURRENT_SOURCE_DIR}/_version.cpp +# COMMAND ${CMAKE_COMMAND} -P +# ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake) +##endif() + +FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.* ) +>>>>>>> Stashed changes idf_component_register(SRCS ${app_sources} INCLUDE_DIRS ".") diff --git a/code/src/githash.cmd b/code/src/githash.cmd new file mode 100644 index 00000000..2dbd2ca5 --- /dev/null +++ b/code/src/githash.cmd @@ -0,0 +1,8 @@ +@echo off +FOR /F "tokens=* USEBACKQ" %%F IN (`git describe --dirty --always --tags`) DO ( +SET var=%%F +) +ECHO #ifndef GITHASH_H > githash.h +ECHO #define GITHASH_H >> githash.h +ECHO const std::string kGitHash = "%var%"; >> githash.h +ECHO #endif // GITHASH_H >> githash.h \ No newline at end of file diff --git a/code/src/main.cpp b/code/src/main.cpp index 67cbf1cd..40f5a47d 100644 --- a/code/src/main.cpp +++ b/code/src/main.cpp @@ -5,7 +5,7 @@ #include "driver/gpio.h" #include "sdkconfig.h" -//#include "version.h" +#include "version.h" #include "ClassLogFile.h" @@ -135,6 +135,9 @@ extern "C" void app_main() std::string zw = gettimestring("%Y%m%d-%H%M%S"); printf("time %s\n", zw.c_str()); + printf("libfive_git_version: %s\n", libfive_git_version()); + printf("libfive_git_revision: %s\n", libfive_git_revision()); + printf("libfive_git_branch: %s\n", libfive_git_branch()); Camera.InitCam(); Camera.LightOnOff(false); diff --git a/code/src/version.h b/code/src/version.h new file mode 100644 index 00000000..684fcd28 --- /dev/null +++ b/code/src/version.h @@ -0,0 +1,23 @@ +// These variables are autogenerated and compiled +// into the library by the version.cmake script +extern "C" +{ + extern const char* GIT_TAG; + extern const char* GIT_REV; + extern const char* GIT_BRANCH; +} + +const char* libfive_git_version(void) +{ + return GIT_TAG; +} + +const char* libfive_git_revision(void) +{ + return GIT_REV; +} + +const char* libfive_git_branch(void) +{ + return GIT_BRANCH; +} \ No newline at end of file