[PATCH 0/6] cmake: guard OS-specific code & cleanup & chmod +x on *nix
As with [1] and [2] submitted today these are extracted from the ejected [2]. This is independent from [1] and [2]. These are all the cmake changes I'll be submitting for now.
This series:
- Cleans up some dead code in the recipe (1/6) - Adds a missing USE_LIBPCRE2 to GIT-BUILD-OPTIONS. We didn't see failures due to this because the win+VS job doesn't build with libpcre2 (2/6) - Wraps Windows-specific code in "if" checks for that platform (3-4/6). We already support cmake on *nix, this makes it clearer which bits are OS-specific - We had failing p4 tests due to omitting copying over git-p4.py. This is anotehr case where we didn't see a failure because the "win+VS" job doesn't test that part. - Do a "chmod +x" of the bin-wrappers, Windows didn't care, but on *nix running the tests would fail *a lot* due to this.
All in all on my *nix box this brings us from:
80% tests passed, 194 tests failed out of 983
To:
99% tests passed, 3 tests failed out of 983
The remaining failures are due to "gitweb" being broken, but that's a general known shortcoming of the "cmake" recipe (which again, isn't spotted by "win+VS" in CI because it skips those tests).
The remaining bits in [3] will get us to 100% passing. I still think those are worthwhile, but there were some outstanding concerns about them (e.g. changing how "GIT-BUILD-DIR" worked, and adding a *nix CI job for cmake).
I don't think there's any outstanding comments or known or potential concerns/breakages with these changes that have to be addressed, these are all straightforward fixes.
CI & branch for this at [4] (where I have it on top of [1] and [2])
1. https://lore.kernel.org/git/patch-1.1-0fa41115261-20221219T102205Z-avarab@gmail.com 2. https://lore.kernel.org/git/cover-0.2-00000000000-20221219T102813Z-avarab@gmail.com/ 3. https://lore.kernel.org/git/cover-v6-00.15-00000000000-20221206T001617Z-avarab@gmail.com/ 4. https://github.com/avar/git/tree/avar/cmake-flags-and-os-specific
Ævar Arnfjörð Bjarmason (6):
cmake: don't copy chainlint.pl to build directory
cmake: set "USE_LIBPCRE2" in "GIT-BUILD-OPTIONS" for test-lib.sh
cmake: increase test timeout on Windows only
cmake: only look for "sh" in "C:/Program Files" on Windows
cmake: copy over git-p4.py for t983[56] perforce test
cmake: chmod +x the bin-wrappers/* & SCRIPT_{SH,PERL} & git-p4contrib/buildsystems/CMakeLists.txt | 55 +++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 14 deletions(-)
Range-diff:
1: fc190b379cd < -: ----------- cmake: don't invoke msgfmt with --statistics
2: 1a11aa233a3 < -: ----------- cmake: use "-S" and "-B" to specify source and build directories
3: b9ddb5db1d3 < -: ----------- cmake: update instructions for portable CMakeLists.txt
4: 7b7850c00ee = 1: 95a6ce2f1c7 cmake: don't copy chainlint.pl to build directory
7: 973c8038f54 = 2: a1653607aaf cmake: set "USE_LIBPCRE2" in "GIT-BUILD-OPTIONS" for test-lib.sh
12: 4905ce5321d ! 3: 2b5a9d2c628 cmake: increase test timeout on Windows only
@@ Commit message
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
## contrib/buildsystems/CMakeLists.txt ##
-@@ contrib/buildsystems/CMakeLists.txt: if(NOT GIT_CTEST_SETS_BUILD_DIR)
- endif()
+@@ contrib/buildsystems/CMakeLists.txt: foreach(tsh ${test_scipts})
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
endforeach()
-# This test script takes an extremely long time and is known to time out even
13: 6c6b530965d = 4: c23f659c054 cmake: only look for "sh" in "C:/Program Files" on Windows
14: 563f1b9b045 ! 5: 70a7f3e19b2 cmake: copy over git-p4.py for t983[56] perforce test
@@ contrib/buildsystems/CMakeLists.txt
@@ contrib/buildsystems/CMakeLists.txt: endforeach()
file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
- write_script(${CMAKE_BINARY_DIR}/git-p4 "${content}")
+ file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
+file(COPY ${CMAKE_SOURCE_DIR}/git-p4.py DESTINATION ${CMAKE_BINARY_DIR}/)
#perl modules
5: 82ecb797915 ! 6: 3724cad82e0 cmake: chmod +x the bin-wrappers/* & SCRIPT_{SH,PERL} & git-p4
@@ contrib/buildsystems/CMakeLists.txt: foreach(script ${git_perl_scripts})
string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
-file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
+write_script(${CMAKE_BINARY_DIR}/git-p4 "${content}")
+ file(COPY ${CMAKE_SOURCE_DIR}/git-p4.py DESTINATION ${CMAKE_BINARY_DIR}/)
#perl modules
- file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
@@ contrib/buildsystems/CMakeLists.txt: foreach(script ${wrapper_scripts})
file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
6: 1f326944a07 < -: ----------- cmake & test-lib.sh: add a $GIT_SOURCE_DIR variable
8: b8448c7a8a6 < -: ----------- Makefile + test-lib.sh: don't prefer cmake-built to make-built git
9: 5135e40969e < -: ----------- test-lib.sh: support a "GIT_TEST_BUILD_DIR"
10: 65204463730 < -: ----------- cmake: optionally be able to run tests before "ctest"
11: e25992b16f1 < -: ----------- cmake: support GIT_TEST_OPTS, abstract away WIN32 defaults
15: 917a884eb65 < -: ----------- CI: add a "linux-cmake-test" to run cmake & ctest on linux-- 2.39.0.1071.g97ce8966538