From c2084a19642c66e69248ec706094e79a1e1d2ca3 Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Mon, 4 Mar 2024 15:11:03 +0100 Subject: [PATCH 01/15] Minor. --- scripts/gen-current-build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/gen-current-build.sh b/scripts/gen-current-build.sh index 93a32eafc..5d8d42c7f 100755 --- a/scripts/gen-current-build.sh +++ b/scripts/gen-current-build.sh @@ -9,7 +9,7 @@ if [[ $? -ne 0 ]]; then exit 1 fi -COMPILER_INFO="$($CPLUSPLUS -v 2>&1)" +COMPILER_INFO="$(${CPLUSPLUS:-g++} -v 2>&1)" if [[ $? -ne 0 ]]; then exit 1 fi @@ -44,7 +44,7 @@ if [[ $? -ne 0 ]]; then exit 1 fi -cat >$1 << EOF +cat >${1:-/dev/stdout} << EOF // clang-format off #ifndef CURRENT_BUILD_H @@ -68,7 +68,7 @@ constexpr static const char* kBuildDateTime = __DATE__ ", " __TIME__; constexpr static const char* kGitCommit = "$GIT_COMMIT"; constexpr static const char* kGitBranch = "$GIT_BRANCH"; constexpr static const char* kOS = "$OS_VERSION"; -constexpr static const char* kCompiler = "$CPLUSPLUS"; +constexpr static const char* kCompiler = "${CPLUSPLUS:-default[g++]}"; constexpr static const char* kCompilerFlags = "$CPPFLAGS"; constexpr static const char* kLinkerFlags = "$LDFLAGS"; constexpr static const char* kCompilerInfo = "$COMPILER_INFO"; From 9cc8050c84742f3b3b3d8d476dc891f871b5a845 Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Mon, 4 Mar 2024 15:23:38 +0100 Subject: [PATCH 02/15] Preparing for `cmake`-built `current_build.h`. --- scripts/gen-current-build.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/gen-current-build.sh b/scripts/gen-current-build.sh index 5d8d42c7f..8d32ca448 100755 --- a/scripts/gen-current-build.sh +++ b/scripts/gen-current-build.sh @@ -45,21 +45,23 @@ if [[ $? -ne 0 ]]; then fi cat >${1:-/dev/stdout} << EOF +// NOTE: With 'CURRENT_BUILD_H_FOR_CMAKE_BASED_PROJECT' '#define'-d it takes ~0.03 seconds to "build" this file. + // clang-format off #ifndef CURRENT_BUILD_H #define CURRENT_BUILD_H +#ifndef CURRENT_BUILD_H_FOR_CMAKE_BASED_PROJECT #include "$SCRIPT_DIR/../port.h" - #include #include #include #include - #include "$SCRIPT_DIR/../typesystem/struct.h" #include "$SCRIPT_DIR/../typesystem/optional.h" #include "$SCRIPT_DIR/../bricks/strings/split.h" +#endif // CURRENT_BUILD_H_FOR_CMAKE_BASED_PROJECT namespace current { namespace build { @@ -73,6 +75,7 @@ constexpr static const char* kCompilerFlags = "$CPPFLAGS"; constexpr static const char* kLinkerFlags = "$LDFLAGS"; constexpr static const char* kCompilerInfo = "$COMPILER_INFO"; +#ifndef CURRENT_BUILD_H_FOR_CMAKE_BASED_PROJECT inline const std::vector& GitDiffNames() { static std::vector result = current::strings::Split("$GIT_DIFF_NAMES", '\n'); return result; @@ -201,6 +204,7 @@ CURRENT_STRUCT(BuildInfo) { return !operator==(rhs); } }; +#endif // CURRENT_BUILD_H_FOR_CMAKE_BASED_PROJECT } // namespace current::build } // namespace current From 9f669db22796b494a7db7d2a50aca6ed1a5f1dd6 Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Tue, 5 Mar 2024 10:39:33 +0100 Subject: [PATCH 03/15] Added `C5T_CMAKE_PROJECT`. --- cmake/CMakeLists.txt | 3 +++ cmake/run-cmake-test.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f3bfaddef..2a964024b 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -46,6 +46,7 @@ foreach(SHARED_LIBRARY_SOURCE_FILE ${BINARY_SOURCE_FILES}) get_filename_component(SHARED_LIBRARY_TARGET_NAME "${SHARED_LIBRARY_SOURCE_FILE}" NAME_WE) add_library(${SHARED_LIBRARY_TARGET_NAME} SHARED "${SHARED_LIBRARY_SOURCE_FILE}") # TODO(dkorolev): Might be worth it to `grep` this `dlib_*.cc` source file for required library dependencies. + target_compile_definitions(${SHARED_LIBRARY_TARGET_NAME} PRIVATE C5T_CMAKE_PROJECT) target_link_libraries(${SHARED_LIBRARY_TARGET_NAME} PRIVATE "${C5T_LIBRARIES}") endforeach() @@ -55,6 +56,7 @@ file(GLOB_RECURSE LIBRARY_SOURCE_FILES "src/lib_*.cc") foreach(LIBRARY_SOURCE_FILE ${LIBRARY_SOURCE_FILES}) get_filename_component(LIBRARY_TARGET_NAME "${LIBRARY_SOURCE_FILE}" NAME_WE) add_library(${LIBRARY_TARGET_NAME} "${LIBRARY_SOURCE_FILE}") + target_compile_definitions(${LIBRARY_TARGET_NAME} PRIVATE C5T_CMAKE_PROJECT) target_link_libraries(${LIBRARY_TARGET_NAME} PRIVATE "${C5T_LIBRARIES}") list(APPEND ALL_LIBRARIES "${LIBRARY_TARGET_NAME}") endforeach() @@ -65,6 +67,7 @@ foreach(BINARY_SOURCE_FILE ${BINARY_SOURCE_FILES}) get_filename_component(BINARY_TARGET_NAME "${BINARY_SOURCE_FILE}" NAME_WE) if(NOT (BINARY_TARGET_NAME MATCHES "^lib_.*$" OR BINARY_TARGET_NAME MATCHES "^test_.*$" OR BINARY_TARGET_NAME MATCHES "^dlib_.*$")) add_executable(${BINARY_TARGET_NAME} "${BINARY_SOURCE_FILE}") + target_compile_definitions(${BINARY_TARGET_NAME} PRIVATE C5T_CMAKE_PROJECT) target_link_libraries(${BINARY_TARGET_NAME} PRIVATE "${ALL_LIBRARIES}") endif() endforeach() diff --git a/cmake/run-cmake-test.sh b/cmake/run-cmake-test.sh index 910e89967..73de76243 100755 --- a/cmake/run-cmake-test.sh +++ b/cmake/run-cmake-test.sh @@ -37,6 +37,9 @@ fi mkdir -p src cat >src/hw.cc < +#ifndef C5T_CMAKE_PROJECT +#error "'C5T_CMAKE_PROJECT' is not defined, are you using Current under 'cmake' with the proper 'CMakeLists.txt'?" +#endif int main() { #ifdef NDEBUG std::cout << "Hello, World! NDEBUG=1." << std::endl; From 993f406dac7b84d24c8cd9c411c0f70ecad32241 Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Tue, 5 Mar 2024 10:49:27 +0100 Subject: [PATCH 04/15] Minor renaming. --- scripts/gen-current-build.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/gen-current-build.sh b/scripts/gen-current-build.sh index 8d32ca448..55852b0e1 100755 --- a/scripts/gen-current-build.sh +++ b/scripts/gen-current-build.sh @@ -45,14 +45,14 @@ if [[ $? -ne 0 ]]; then fi cat >${1:-/dev/stdout} << EOF -// NOTE: With 'CURRENT_BUILD_H_FOR_CMAKE_BASED_PROJECT' '#define'-d it takes ~0.03 seconds to "build" this file. +// NOTE: With 'C5T_CMAKE_PROJECT' '#define'-d it takes ~0.03 seconds to "build" this file. // clang-format off #ifndef CURRENT_BUILD_H #define CURRENT_BUILD_H -#ifndef CURRENT_BUILD_H_FOR_CMAKE_BASED_PROJECT +#ifndef C5T_CMAKE_PROJECT #include "$SCRIPT_DIR/../port.h" #include #include @@ -61,11 +61,15 @@ cat >${1:-/dev/stdout} << EOF #include "$SCRIPT_DIR/../typesystem/struct.h" #include "$SCRIPT_DIR/../typesystem/optional.h" #include "$SCRIPT_DIR/../bricks/strings/split.h" -#endif // CURRENT_BUILD_H_FOR_CMAKE_BASED_PROJECT +#endif // C5T_CMAKE_PROJECT namespace current { namespace build { +#ifdef C5T_CMAKE_PROJECT +namespace cmake { +#endif // C5T_CMAKE_PROJECT + constexpr static const char* kBuildDateTime = __DATE__ ", " __TIME__; constexpr static const char* kGitCommit = "$GIT_COMMIT"; constexpr static const char* kGitBranch = "$GIT_BRANCH"; @@ -75,12 +79,14 @@ constexpr static const char* kCompilerFlags = "$CPPFLAGS"; constexpr static const char* kLinkerFlags = "$LDFLAGS"; constexpr static const char* kCompilerInfo = "$COMPILER_INFO"; -#ifndef CURRENT_BUILD_H_FOR_CMAKE_BASED_PROJECT +#ifndef C5T_CMAKE_PROJECT inline const std::vector& GitDiffNames() { static std::vector result = current::strings::Split("$GIT_DIFF_NAMES", '\n'); return result; } +// TODO(dkorolev): Maybe this function should be elsewhere, under some "proper" Current source dir? + // A hacky, but cross-platform way to parse \`kBuildDateTime\` since: // * \`__DATE__\` always contains English months, // * GCC < 5.0 doesn't have \`get_time\`, @@ -204,7 +210,12 @@ CURRENT_STRUCT(BuildInfo) { return !operator==(rhs); } }; -#endif // CURRENT_BUILD_H_FOR_CMAKE_BASED_PROJECT +#endif // C5T_CMAKE_PROJECT + +#ifdef C5T_CMAKE_PROJECT +} // namespace current::build::cmake +using namespace cmake; +#endif // C5T_CMAKE_PROJECT } // namespace current::build } // namespace current From f0b164452541f3981bdabfa9d761238d67591367 Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Tue, 5 Mar 2024 10:57:47 +0100 Subject: [PATCH 05/15] TO REMOVE: Temporarily point the "auto-build" script to this branch. --- cmake/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 2a964024b..0a46825c1 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -35,7 +35,7 @@ function(UseOrGitClone dep remote branch) endif() endfunction() -UseOrGitClone(current https://github.com/c5t/current stable) +UseOrGitClone(current https://github.com/dkorolev/current current_build_autogen_header_for_cmake) UseOrGitClone(googletest https://github.com/c5t/googletest v1.14) set(C5T_LIBRARIES "Threads::Threads" "C5T") From 9aa674f98b48e1f597c3c95fccc8951d643203a9 Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Tue, 5 Mar 2024 10:58:08 +0100 Subject: [PATCH 06/15] Test with manually created `current_build.h`, baby steps. --- cmake/run-cmake-test.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/run-cmake-test.sh b/cmake/run-cmake-test.sh index 73de76243..3c02f385b 100755 --- a/cmake/run-cmake-test.sh +++ b/cmake/run-cmake-test.sh @@ -35,17 +35,20 @@ fi # No need to `curl` the very `CMakeLists.txt` file, as the `Makefile` will do it if and as needed. mkdir -p src +./current/scripts/gen-current-build.sh src/tmp_current_build.h cat >src/hw.cc < #ifndef C5T_CMAKE_PROJECT #error "'C5T_CMAKE_PROJECT' is not defined, are you using Current under 'cmake' with the proper 'CMakeLists.txt'?" #endif +#include "tmp_current_build.h" int main() { #ifdef NDEBUG std::cout << "Hello, World! NDEBUG=1." << std::endl; #else std::cout << "Hello, World! NDEBUG is unset." << std::endl; #endif + std::cout << current::build::cmake::kBuildDateTime << std::endl; } EOF From 8b69b978cca3e215f4ec848861dab11fa1de88c1 Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Tue, 5 Mar 2024 11:02:03 +0100 Subject: [PATCH 07/15] A cleaner test. --- cmake/run-cmake-test.sh | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/cmake/run-cmake-test.sh b/cmake/run-cmake-test.sh index 3c02f385b..d9937f964 100755 --- a/cmake/run-cmake-test.sh +++ b/cmake/run-cmake-test.sh @@ -35,20 +35,14 @@ fi # No need to `curl` the very `CMakeLists.txt` file, as the `Makefile` will do it if and as needed. mkdir -p src -./current/scripts/gen-current-build.sh src/tmp_current_build.h cat >src/hw.cc < -#ifndef C5T_CMAKE_PROJECT -#error "'C5T_CMAKE_PROJECT' is not defined, are you using Current under 'cmake' with the proper 'CMakeLists.txt'?" -#endif -#include "tmp_current_build.h" int main() { #ifdef NDEBUG std::cout << "Hello, World! NDEBUG=1." << std::endl; #else std::cout << "Hello, World! NDEBUG is unset." << std::endl; #endif - std::cout << current::build::cmake::kBuildDateTime << std::endl; } EOF @@ -98,6 +92,28 @@ echo "::group::.current_debug/hw" .current_debug/hw echo "::endgroup::" +echo "::group::build_info" +# TODO(dkorolev): It should make it into `CMakeLists.txt` to generate this file.s +./current/scripts/gen-current-build.sh src/tmp_current_build.h +cat >src/build_info.cc < +#ifndef C5T_CMAKE_PROJECT +#error "'C5T_CMAKE_PROJECT' is not defined, are you using Current under 'cmake' with the proper 'CMakeLists.txt'?" +#endif +#include "tmp_current_build.h" +int main() { + std::cout << current::build::cmake::kBuildDateTime << std::endl; +} +EOF +make +.current/build_info +echo "::endgroup::" + +# This runs `cmake .` for Release mode, which is output into `.current`. +echo "::group::configure" +make .current +echo "::endgroup::" + cat >src/lib_add.cc < Date: Tue, 5 Mar 2024 11:06:23 +0100 Subject: [PATCH 08/15] Have `scripts/gen-current-build.sh` not fail when not under a git repo (important for the test). --- scripts/gen-current-build.sh | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/scripts/gen-current-build.sh b/scripts/gen-current-build.sh index 55852b0e1..c5e2429f4 100755 --- a/scripts/gen-current-build.sh +++ b/scripts/gen-current-build.sh @@ -15,22 +15,10 @@ if [[ $? -ne 0 ]]; then fi COMPILER_INFO=${COMPILER_INFO//$'\n'/\\n} # JSON-friendly newlines. -GIT_COMMIT="$(git rev-parse HEAD)" -if [[ $? -ne 0 ]]; then - exit 1 -fi - -GIT_BRANCH="$(git rev-parse --abbrev-ref HEAD)" -if [[ $? -ne 0 ]]; then - exit 1 -fi - -GIT_STATUS="$(git status)" -if [[ $? -ne 0 ]]; then - exit 1 -fi - -GIT_DIFF_NAMES_MULTILINE="$(git diff --name-only)" +GIT_COMMIT="$(git rev-parse HEAD || echo '')" +GIT_BRANCH="$(git rev-parse --abbrev-ref HEAD || echo '')" +GIT_STATUS="$(git status || echo '')" +GIT_DIFF_NAMES_MULTILINE="$(git diff --name-only || echo '')" GIT_DIFF_NAMES=${GIT_DIFF_NAMES_MULTILINE//$'\n'/\\n} if [[ "$OSTYPE" == "darwin"* ]]; then @@ -39,10 +27,7 @@ else MD5SUM=md5sum fi -GIT_DIFF_MD5SUM="$(git diff --no-ext-diff | $MD5SUM)" -if [[ $? -ne 0 ]]; then - exit 1 -fi +GIT_DIFF_MD5SUM="$(git diff --no-ext-diff | $MD5SUM || echo '')" cat >${1:-/dev/stdout} << EOF // NOTE: With 'C5T_CMAKE_PROJECT' '#define'-d it takes ~0.03 seconds to "build" this file. From 7b9d2ae64fd4b398eb18e15df188b69cfd7d242a Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Tue, 5 Mar 2024 11:09:06 +0100 Subject: [PATCH 09/15] Incremental. --- cmake/run-cmake-test.sh | 7 +++++-- scripts/gen-current-build.sh | 10 +++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cmake/run-cmake-test.sh b/cmake/run-cmake-test.sh index d9937f964..693b20a0f 100755 --- a/cmake/run-cmake-test.sh +++ b/cmake/run-cmake-test.sh @@ -92,7 +92,7 @@ echo "::group::.current_debug/hw" .current_debug/hw echo "::endgroup::" -echo "::group::build_info" +echo "::group::build build_info" # TODO(dkorolev): It should make it into `CMakeLists.txt` to generate this file.s ./current/scripts/gen-current-build.sh src/tmp_current_build.h cat >src/build_info.cc <src/build_info.cc <${1:-/dev/stdout} << EOF // NOTE: With 'C5T_CMAKE_PROJECT' '#define'-d it takes ~0.03 seconds to "build" this file. From 5331b9e4fa403928eecf8942d953212bf21617d9 Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Tue, 5 Mar 2024 11:13:08 +0100 Subject: [PATCH 10/15] Minor. --- cmake/run-cmake-test.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/run-cmake-test.sh b/cmake/run-cmake-test.sh index 693b20a0f..ef2bb73d0 100755 --- a/cmake/run-cmake-test.sh +++ b/cmake/run-cmake-test.sh @@ -92,8 +92,12 @@ echo "::group::.current_debug/hw" .current_debug/hw echo "::endgroup::" +echo + +# Test that the `current_build.h` file is generated automatically and added into the path. +# TODO(dkorolev): It should make it into `CMakeLists.txt` to generate this file. + echo "::group::build build_info" -# TODO(dkorolev): It should make it into `CMakeLists.txt` to generate this file.s ./current/scripts/gen-current-build.sh src/tmp_current_build.h cat >src/build_info.cc < @@ -108,6 +112,8 @@ EOF make echo "::endgroup::" +echo + echo "::group::run build_info" .current/build_info echo "::endgroup::" From 49cdc28ffa5f73fd052c9d1926d59c412f97d8d6 Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Tue, 5 Mar 2024 12:21:32 +0100 Subject: [PATCH 11/15] Comment. --- cmake/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 0a46825c1..36daff0ee 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -35,6 +35,7 @@ function(UseOrGitClone dep remote branch) endif() endfunction() +# NOTE(dkorolev): This is about to be changed back once https://github.com/C5T/Current/pull/966 is merged! UseOrGitClone(current https://github.com/dkorolev/current current_build_autogen_header_for_cmake) UseOrGitClone(googletest https://github.com/c5t/googletest v1.14) From c56daf6843ad6c998e57382c2dc903b04bb9fefb Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Tue, 5 Mar 2024 12:56:50 +0100 Subject: [PATCH 12/15] Added the custom CMake target to always [re]build `${current_src_dir}/current_build.h`. --- cmake/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 36daff0ee..cba49feaf 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -17,14 +17,17 @@ function(UseOrGitClone dep remote branch) message(STATUS "Using `${dep}` from `CMAKE_SOURCE_DIR/${dep}'.") add_subdirectory("${CMAKE_SOURCE_DIR}/${dep}" ${dep}) message(STATUS "Using `${dep}` from `CMAKE_SOURCE_DIR/${dep}': Configured.") + set("SRC_DIR_${dep}" "${CMAKE_SOURCE_DIR}/${dep}" PARENT_SCOPE) elseif(EXISTS "${CMAKE_SOURCE_DIR}/../${dep}" AND IS_DIRECTORY "${CMAKE_SOURCE_DIR}/../${dep}") message(STATUS "Using `${dep}` from `CMAKE_SOURCE_DIR/../${dep}'.") add_subdirectory("${CMAKE_SOURCE_DIR}/../${dep}" ${dep}) message(STATUS "Using `${dep}` from `CMAKE_SOURCE_DIR/../${dep}': Configured.") + set("SRC_DIR_${dep}" "${CMAKE_SOURCE_DIR}/../${dep}" PARENT_SCOPE) elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../${dep}" AND IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../${dep}") message(STATUS "Using `${dep}` from `CMAKE_CURRENT_SOURCE_DIR/../${dep}'.") add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../${dep}" ${dep}) message(STATUS "Using `${dep}` from `CMAKE_CURRENT_SOURCE_DIR/../${dep}': Configured.") + set("SRC_DIR_${dep}" "${CMAKE_CURRENT_SOURCE_DIR}/../${dep}" PARENT_SCOPE) else() message(STATUS "Cloning `${dep}` from `${remote}:${branch}` ...") execute_process(OUTPUT_QUIET ERROR_QUIET COMMAND git clone --depth 1 -b ${branch} ${remote}) @@ -32,6 +35,7 @@ function(UseOrGitClone dep remote branch) file(APPEND .gitignore "${dep}/\n") add_subdirectory("${CMAKE_SOURCE_DIR}/${dep}" ${dep}) message(STATUS "Cloning `${dep}` from `${remote}:${branch}`: Configured.") + set("SRC_DIR_${dep}" "${CMAKE_SOURCE_DIR}/${dep}" PARENT_SCOPE) endif() endfunction() @@ -39,6 +43,13 @@ endfunction() UseOrGitClone(current https://github.com/dkorolev/current current_build_autogen_header_for_cmake) UseOrGitClone(googletest https://github.com/c5t/googletest v1.14) +add_custom_target(C5T_CURRENT_BUILD_H_TARGET ALL DEPENDS "${SRC_DIR_current}/current_build.h") + +add_custom_command(OUTPUT "${SRC_DIR_current}/current_build.h" + COMMAND "${SRC_DIR_current}/scripts/gen-current-build.sh" + ARGS "${SRC_DIR_current}/current_build.h" + DEPENDS src) + set(C5T_LIBRARIES "Threads::Threads" "C5T") # Declare shared libraries as shared library targets. Do not link them against anything external. From 4b003a252646850fc368122ea8eba0ea2023e6b3 Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Tue, 5 Mar 2024 12:58:01 +0100 Subject: [PATCH 13/15] And testing this target/command in full. --- cmake/run-cmake-test.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cmake/run-cmake-test.sh b/cmake/run-cmake-test.sh index ef2bb73d0..c9a981de5 100755 --- a/cmake/run-cmake-test.sh +++ b/cmake/run-cmake-test.sh @@ -94,17 +94,14 @@ echo "::endgroup::" echo -# Test that the `current_build.h` file is generated automatically and added into the path. -# TODO(dkorolev): It should make it into `CMakeLists.txt` to generate this file. - +# Test that the `current_build.h` file is generated automatically for each build. echo "::group::build build_info" -./current/scripts/gen-current-build.sh src/tmp_current_build.h cat >src/build_info.cc < #ifndef C5T_CMAKE_PROJECT #error "'C5T_CMAKE_PROJECT' is not defined, are you using Current under 'cmake' with the proper 'CMakeLists.txt'?" #endif -#include "tmp_current_build.h" +#include "current_build.h" int main() { std::cout << "Successfully built at: " << current::build::cmake::kBuildDateTime << std::endl; } @@ -118,6 +115,14 @@ echo "::group::run build_info" .current/build_info echo "::endgroup::" +echo + +echo "::group::re-run build_info" +touch src/build_info.cc +make +.current/build_info +echo "::endgroup::" + # This runs `cmake .` for Release mode, which is output into `.current`. echo "::group::configure" make .current From bbc30b2151f4efb2584fceac72372e4f3301c061 Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Tue, 5 Mar 2024 14:08:32 +0100 Subject: [PATCH 14/15] Hopefully final touches. --- cmake/run-cmake-test.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/run-cmake-test.sh b/cmake/run-cmake-test.sh index c9a981de5..63e09737c 100755 --- a/cmake/run-cmake-test.sh +++ b/cmake/run-cmake-test.sh @@ -162,6 +162,9 @@ TEST(SmokeCurrentGoogletest, TwoPlusThree) { } EOF +# Force re-configure after adding more into `src/`, appears to be important on the `macos-latest` GitHub test runner. +touch CMakeLists.txt + echo echo "::group::release_test" From e75696b99cd484f732b110e13962eb2db75f9a55 Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Tue, 5 Mar 2024 18:07:09 +0100 Subject: [PATCH 15/15] Added `sleep 1` to make sure the build timestamp is different =) --- cmake/run-cmake-test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/run-cmake-test.sh b/cmake/run-cmake-test.sh index 63e09737c..9dba2d7bb 100755 --- a/cmake/run-cmake-test.sh +++ b/cmake/run-cmake-test.sh @@ -118,6 +118,7 @@ echo "::endgroup::" echo echo "::group::re-run build_info" +sleep 1 touch src/build_info.cc make .current/build_info