diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index 35bb597e32..b0a02a7243 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -193,6 +193,24 @@ include(cmake/CoreLib.cmake) # Create the GUI library add_library(SerialProgramsLib STATIC ${CORE_LIBRARY_SOURCES} ${LIBRARY_SOURCES}) +# PROGRAM_COMMIT (Source/CommonFramework/BuildCommit.h): the git commit the app is +# built from. BuildCommit.cpp is written at configure time and checked on every +# build; it changes, and recompiles, only when the commit does. +set(PA_BUILD_COMMIT_CPP "${CMAKE_CURRENT_BINARY_DIR}/generated/BuildCommit.cpp") +set(PA_BUILD_COMMIT_COMMAND + "${CMAKE_COMMAND}" "-DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}" "-DOUTPUT=${PA_BUILD_COMMIT_CPP}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/BuildCommit.cmake" +) +execute_process(COMMAND ${PA_BUILD_COMMIT_COMMAND}) +add_custom_target(BuildCommit + COMMAND ${PA_BUILD_COMMIT_COMMAND} + BYPRODUCTS "${PA_BUILD_COMMIT_CPP}" + COMMENT "Checking the git commit for PROGRAM_COMMIT" + VERBATIM +) +target_sources(SerialProgramsLib PRIVATE "${PA_BUILD_COMMIT_CPP}") +add_dependencies(SerialProgramsLib BuildCommit) + # Create binary target if (APPLE) diff --git a/SerialPrograms/Source/CommonFramework/BuildCommit.h b/SerialPrograms/Source/CommonFramework/BuildCommit.h new file mode 100644 index 0000000000..3e0568cd4f --- /dev/null +++ b/SerialPrograms/Source/CommonFramework/BuildCommit.h @@ -0,0 +1,24 @@ +/* Build Commit + * + * From: https://github.com/PokemonAutomation/ + * + * The git commit the app was built from. The build writes its definition + * (cmake/BuildCommit.cmake) into BuildCommit.cpp in the build folder, and + * rewrites it only when the commit changes, so a new commit recompiles + * that one file. + * + */ + +#ifndef PokemonAutomation_BuildCommit_H +#define PokemonAutomation_BuildCommit_H + +namespace PokemonAutomation{ + + +// "git describe" of the source tree: the commit's hash, with "-dirty" when +// tracked files had changes, or "unknown" when git could not tell. +extern const char* const PROGRAM_COMMIT; + + +} +#endif diff --git a/SerialPrograms/Source/CommonFramework/Windows/Lab.md b/SerialPrograms/Source/CommonFramework/Windows/Lab.md index 86172c1fde..df01c9afdf 100644 --- a/SerialPrograms/Source/CommonFramework/Windows/Lab.md +++ b/SerialPrograms/Source/CommonFramework/Windows/Lab.md @@ -28,6 +28,7 @@ takes effect at the next launch. | `Lab/outbox/.out` | app writes | The request's journal (below). It appears only once the request has finished; `.tmp` shows the progress so far. | | `Lab/outbox/_