{"thread":{"id":"58984","subject":"[PATCH 1/6] cmake: don't copy chainlint.pl to build directory","startedAt":"2022-12-19T18:39:36Z","lastAt":"2022-12-19T18:40:03Z","messageCount":7,"participants":["Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"469308","messageId":"patch-1.6-95a6ce2f1c7-20221219T183623Z-avarab@gmail.com","threadId":"58984","inReplyTo":"cover-0.6-00000000000-20221219T183623Z-avarab@gmail.com","subject":"[PATCH 1/6] cmake: don't copy chainlint.pl to build directory","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-12-19T18:39:19Z","receivedAt":"2022-12-19T18:39:36Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"When [1] made this copy of \"chainlint.sed\" the script was invoked in\nthe test-lib.sh as:\n\n\t[...] sed -f \"$GIT_BUILD_DIR/t/chainlint.sed\" [...]\n\nBut when [2] replaced \"chainlint.sed\" with a \"chainlint.pl\" it also\nreplaced that \"$GIT_BUILD_DIR\" with \"$TEST_DIRECTORY\", invoking it as:\n\n\t\"$PERL_PATH\" \"$TEST_DIRECTORY/chainlint.pl\" \"$0\"\n\nSo this line could have been deleted in [2] but wasn't. Let's do that\nnow.\n\n1. 7f5397a07c6 (cmake: support for testing git when building out of\n   the source tree, 2020-06-26)\n2. 23a14f30166 (test-lib: replace chainlint.sed with chainlint.pl,\n   2022-09-01)\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 80290edd72a..c641e9349c9 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -1106,7 +1106,6 @@ if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})\n \tfile(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake\n \t\t\"file(WRITE ${CMAKE_SOURCE_DIR}/GIT-BUILD-DIR \\\"${CMAKE_BINARY_DIR}\\\")\")\n \t#misc copies\n-\tfile(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.pl DESTINATION ${CMAKE_BINARY_DIR}/t/)\n \tfile(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)\n \tfile(GLOB mergetools \"${CMAKE_SOURCE_DIR}/mergetools/*\")\n \tfile(COPY ${mergetools} DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)\n-- \n2.39.0.1071.g97ce8966538\n\n"},{"id":"469309","messageId":"cover-0.6-00000000000-20221219T183623Z-avarab@gmail.com","threadId":"58984","inReplyTo":null,"subject":"[PATCH 0/6] cmake: guard OS-specific code & cleanup & chmod +x on *nix","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-12-19T18:39:18Z","receivedAt":"2022-12-19T18:39:39Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"As with [1] and [2] submitted today these are extracted from the\nejected [2]. This is independent from [1] and [2]. These are all the\ncmake changes I'll be submitting for now.\n\nThis series:\n\n - Cleans up some dead code in the recipe (1/6)\n - Adds a missing USE_LIBPCRE2 to GIT-BUILD-OPTIONS. We didn't see\n   failures due to this because the win+VS job doesn't build with\n   libpcre2 (2/6)\n - Wraps Windows-specific code in \"if\" checks for that platform\n   (3-4/6). We already support cmake on *nix, this makes it clearer\n   which bits are OS-specific\n - We had failing p4 tests due to omitting copying over\n   git-p4.py. This is anotehr case where we didn't see a failure\n   because the \"win+VS\" job doesn't test that part.\n - Do a \"chmod +x\" of the bin-wrappers, Windows didn't care, but on\n   *nix running the tests would fail *a lot* due to this.\n\nAll in all on my *nix box this brings us from:\n\n\t80% tests passed, 194 tests failed out of 983\n\nTo:\n\n\t99% tests passed, 3 tests failed out of 983\n\nThe remaining failures are due to \"gitweb\" being broken, but that's a\ngeneral known shortcoming of the \"cmake\" recipe (which again, isn't\nspotted by \"win+VS\" in CI because it skips those tests).\n\nThe remaining bits in [3] will get us to 100% passing. I still think\nthose are worthwhile, but there were some outstanding concerns about\nthem (e.g. changing how \"GIT-BUILD-DIR\" worked, and adding a *nix CI\njob for cmake).\n\nI don't think there's any outstanding comments or known or potential\nconcerns/breakages with these changes that have to be addressed, these\nare all straightforward fixes.\n\nCI & branch for this at [4] (where I have it on top of [1] and [2])\n\n1. https://lore.kernel.org/git/patch-1.1-0fa41115261-20221219T102205Z-avarab@gmail.com\n2. https://lore.kernel.org/git/cover-0.2-00000000000-20221219T102813Z-avarab@gmail.com/\n3. https://lore.kernel.org/git/cover-v6-00.15-00000000000-20221206T001617Z-avarab@gmail.com/\n4. https://github.com/avar/git/tree/avar/cmake-flags-and-os-specific\n\nÆvar Arnfjörð Bjarmason (6):\n  cmake: don't copy chainlint.pl to build directory\n  cmake: set \"USE_LIBPCRE2\" in \"GIT-BUILD-OPTIONS\" for test-lib.sh\n  cmake: increase test timeout on Windows only\n  cmake: only look for \"sh\" in \"C:/Program Files\" on Windows\n  cmake: copy over git-p4.py for t983[56] perforce test\n  cmake: chmod +x the bin-wrappers/* & SCRIPT_{SH,PERL} & git-p4\n\n contrib/buildsystems/CMakeLists.txt | 55 +++++++++++++++++++++--------\n 1 file changed, 41 insertions(+), 14 deletions(-)\n\nRange-diff:\n 1:  fc190b379cd <  -:  ----------- cmake: don't invoke msgfmt with --statistics\n 2:  1a11aa233a3 <  -:  ----------- cmake: use \"-S\" and \"-B\" to specify source and build directories\n 3:  b9ddb5db1d3 <  -:  ----------- cmake: update instructions for portable CMakeLists.txt\n 4:  7b7850c00ee =  1:  95a6ce2f1c7 cmake: don't copy chainlint.pl to build directory\n 7:  973c8038f54 =  2:  a1653607aaf cmake: set \"USE_LIBPCRE2\" in \"GIT-BUILD-OPTIONS\" for test-lib.sh\n12:  4905ce5321d !  3:  2b5a9d2c628 cmake: increase test timeout on Windows only\n    @@ Commit message\n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## contrib/buildsystems/CMakeLists.txt ##\n    -@@ contrib/buildsystems/CMakeLists.txt: if(NOT GIT_CTEST_SETS_BUILD_DIR)\n    - endif()\n    +@@ contrib/buildsystems/CMakeLists.txt: foreach(tsh ${test_scipts})\n    + \t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)\n      endforeach()\n      \n     -# This test script takes an extremely long time and is known to time out even\n13:  6c6b530965d =  4:  c23f659c054 cmake: only look for \"sh\" in \"C:/Program Files\" on Windows\n14:  563f1b9b045 !  5:  70a7f3e19b2 cmake: copy over git-p4.py for t983[56] perforce test\n    @@ contrib/buildsystems/CMakeLists.txt\n     @@ contrib/buildsystems/CMakeLists.txt: endforeach()\n      file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)\n      string(REPLACE \"#!/usr/bin/env python\" \"#!/usr/bin/python\" content \"${content}\")\n    - write_script(${CMAKE_BINARY_DIR}/git-p4 \"${content}\")\n    + file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})\n     +file(COPY ${CMAKE_SOURCE_DIR}/git-p4.py DESTINATION ${CMAKE_BINARY_DIR}/)\n      \n      #perl modules\n 5:  82ecb797915 !  6:  3724cad82e0 cmake: chmod +x the bin-wrappers/* & SCRIPT_{SH,PERL} & git-p4\n    @@ contrib/buildsystems/CMakeLists.txt: foreach(script ${git_perl_scripts})\n      string(REPLACE \"#!/usr/bin/env python\" \"#!/usr/bin/python\" content \"${content}\")\n     -file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})\n     +write_script(${CMAKE_BINARY_DIR}/git-p4 \"${content}\")\n    + file(COPY ${CMAKE_SOURCE_DIR}/git-p4.py DESTINATION ${CMAKE_BINARY_DIR}/)\n      \n      #perl modules\n    - file(GLOB_RECURSE perl_modules \"${CMAKE_SOURCE_DIR}/perl/*.pm\")\n     @@ contrib/buildsystems/CMakeLists.txt: foreach(script ${wrapper_scripts})\n      \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n      \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n 6:  1f326944a07 <  -:  ----------- cmake & test-lib.sh: add a $GIT_SOURCE_DIR variable\n 8:  b8448c7a8a6 <  -:  ----------- Makefile + test-lib.sh: don't prefer cmake-built to make-built git\n 9:  5135e40969e <  -:  ----------- test-lib.sh: support a \"GIT_TEST_BUILD_DIR\"\n10:  65204463730 <  -:  ----------- cmake: optionally be able to run tests before \"ctest\"\n11:  e25992b16f1 <  -:  ----------- cmake: support GIT_TEST_OPTS, abstract away WIN32 defaults\n15:  917a884eb65 <  -:  ----------- CI: add a \"linux-cmake-test\" to run cmake & ctest on linux\n-- \n2.39.0.1071.g97ce8966538\n\n"},{"id":"469310","messageId":"patch-2.6-a1653607aaf-20221219T183623Z-avarab@gmail.com","threadId":"58984","inReplyTo":"cover-0.6-00000000000-20221219T183623Z-avarab@gmail.com","subject":"[PATCH 2/6] cmake: set \"USE_LIBPCRE2\" in \"GIT-BUILD-OPTIONS\" for test-lib.sh","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-12-19T18:39:20Z","receivedAt":"2022-12-19T18:39:40Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"When we build with libpcre2 which cmake has supported since [1] we\nneed to set \"USE_LIBPCRE2='YesPlease'\" (or similar) in\n\"GIT-BUILD-OPTIONS\".\n\nWithout this e.g. t7810-grep.sh will fail, as it has tests that rely\non the behavior of !PCRE2. The reason this hasn't been noticed is that\nthe Windows CI doesn't have access to libpcre2.\n\nWith this the remaining two failures we had left after the preceding\nstep are resolved, but note that that test run didn't include the\ngit-p4 tests, which a subsequent commit will address).\n\n1. 80431510a2b (cmake: add pcre2 support, 2022-05-24)\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex c641e9349c9..040f5f31230 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -1086,6 +1086,9 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PYTHON_PATH='${PYTHON_PATH}'\\\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TAR='${TAR}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_CURL='${NO_CURL}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_EXPAT='${NO_EXPAT}'\\n\")\n+if(PCRE2_FOUND)\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"USE_LIBPCRE2='YesPlease'\\n\")\n+endif()\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PERL='${NO_PERL}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PTHREADS='${NO_PTHREADS}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\\n\")\n-- \n2.39.0.1071.g97ce8966538\n\n"},{"id":"469311","messageId":"patch-3.6-2b5a9d2c628-20221219T183623Z-avarab@gmail.com","threadId":"58984","inReplyTo":"cover-0.6-00000000000-20221219T183623Z-avarab@gmail.com","subject":"[PATCH 3/6] cmake: increase test timeout on Windows only","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-12-19T18:39:21Z","receivedAt":"2022-12-19T18:39:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Per c858750b41c (cmake: increase time-out for a long-running test,\n2022-10-18) the reason to set a custom timeout for\nt7112-reset-submodule.sh is Windows-specific. Let's only do that on\nWindows then.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 040f5f31230..d45b9c8e00a 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -1125,8 +1125,10 @@ foreach(tsh ${test_scipts})\n \t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)\n endforeach()\n \n-# This test script takes an extremely long time and is known to time out even\n-# on fast machines because it requires in excess of one hour to run\n-set_tests_properties(\"${CMAKE_SOURCE_DIR}/t/t7112-reset-submodule.sh\" PROPERTIES TIMEOUT 4000)\n+if(WIN32)\n+\t# This test script takes an extremely long time and is known to time out even\n+\t# on fast machines because it requires in excess of one hour to run\n+\tset_tests_properties(\"${CMAKE_SOURCE_DIR}/t/t7112-reset-submodule.sh\" PROPERTIES TIMEOUT 4000)\n+endif()\n \n endif()#BUILD_TESTING\n-- \n2.39.0.1071.g97ce8966538\n\n"},{"id":"469312","messageId":"patch-4.6-c23f659c054-20221219T183623Z-avarab@gmail.com","threadId":"58984","inReplyTo":"cover-0.6-00000000000-20221219T183623Z-avarab@gmail.com","subject":"[PATCH 4/6] cmake: only look for \"sh\" in \"C:/Program Files\" on Windows","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-12-19T18:39:22Z","receivedAt":"2022-12-19T18:39:47Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Guard the finding of \"SH_EXE\" in \"C:\\Program Files\" with a check for\nwhether we're on Windows.\n\nThis Windows-specific code was first added in [1], and later expanded\non [2], but since some of that was added this build recipe has been\nmade portable outside of Windows.\n\n1. 72b6eeb81b1 (cmake: do find Git for Windows' shell interpreter,\n   2020-09-28)\n2. 476e54b1c60 (cmake: support local installations of git,\n   2022-07-27).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 15 +++++++++++----\n 1 file changed, 11 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex d45b9c8e00a..560a15ed35a 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -107,10 +107,17 @@ if(USE_VCPKG)\n \tset(CMAKE_TOOLCHAIN_FILE ${VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake CACHE STRING \"Vcpkg toolchain file\")\n endif()\n \n-find_program(SH_EXE sh PATHS \"C:/Program Files/Git/bin\" \"$ENV{LOCALAPPDATA}/Programs/Git/bin\")\n-if(NOT SH_EXE)\n-\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n-\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n+if(WIN32)\n+\tfind_program(SH_EXE sh PATHS \"C:/Program Files/Git/bin\" \"$ENV{LOCALAPPDATA}/Programs/Git/bin\")\n+\tif(NOT SH_EXE)\n+\t\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n+\t\t\t\t\"You can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n+\tendif()\n+else()\n+\tfind_program(SH_EXE sh)\n+\tif(NOT SH_EXE)\n+\t\tmessage(FATAL_ERROR \"cannot find 'sh' in '$PATH'\")\n+\tendif()\n endif()\n \n #Create GIT-VERSION-FILE using GIT-VERSION-GEN\n-- \n2.39.0.1071.g97ce8966538\n\n"},{"id":"469313","messageId":"patch-6.6-3724cad82e0-20221219T183623Z-avarab@gmail.com","threadId":"58984","inReplyTo":"cover-0.6-00000000000-20221219T183623Z-avarab@gmail.com","subject":"[PATCH 6/6] cmake: chmod +x the bin-wrappers/* & SCRIPT_{SH,PERL} & git-p4","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-12-19T18:39:24Z","receivedAt":"2022-12-19T18:39:58Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Since the cmake file was made to run on *nix in [1] running the tests\nwith \"ctest\" broken, because we'd attempt to invoke our bin-wrappers/,\nbut they didn't have the executable bit.\n\nIn the best case, the \"t/test-lib.sh\" would be unable to find\n\"bin-wrappers/git\", and we'd fall back on\n\"GIT_EXEC_PATH=$GIT_BUILD_DIR\" using the fallback behavior added in\n[2]:\n\n\t$ ./t0001-init.sh\n\t<GIT_BUILD_DIR>/t/../contrib/buildsystems/out/bin-wrappers/git is not executable; using GIT_EXEC_PATH\n\nThis was recently somewhat swept under the rug in [3], as ctest would\nrun them with \"--no-bin-wrappers\". But still with [3], running e.g.:\n\n\tcmake -S contrib/buildsystems -B contrib/buildsystems/out -DCMAKE_BUILD_TYPE=Debug &&\n\tmake -C contrib/buildsystems/out &&\n\tctest --test-dir contrib/buildsystems/out --jobs=\"$(nproc)\" --output-on-failure\n\nFails around 20% of our tests on *nix. So even with [3] we'd fail any\ntest that needed to invoke one of our built shell, perl or Python\nscripts on *nix. E.g. t0012-help.sh would fail on a test that tried to\ninvoke \"git web--browse\". The equivalent of this (in the \"out\"\ndirectory) would happen:\n\n\t$ ./git --exec-path=$PWD web--browse\n\tgit: 'web--browse' is not a git command. See 'git --help'.\n\nWhich we can fix by \"chmod +x\"-ing the built \"git-web--browse\":\n\n\t$ chmod +x git-web--browse\n\t$ ./git --exec-path=$PWD web--browse\n\tusage: git web--browse [--browser=browser|--tool=browser] [--config=conf.var] url/file ...\n\nThe same goes for e.g. the \"git-p4\" tests, which would fail because\nour built \"git-p4\" wasn't executable, etc. There's also a few other\noutstanding issues, which will be fixed in subsequent commits.\n\nIdeally we'd use the file(CHMOD ...) form everywhere, but that syntax\nwas introduced in cmake 3.19[4], whereas we only require 3.14. Let's\nprovide a fallback behind a version check, so that we'll eventually be\nable to delete the \"else\" part. Both forms result in the same file\nmodes.\n\nBefore this change:\n\n\t80% tests passed, 196 tests failed out of 977\n\nAfter:\n\n\t99% tests passed, 5 tests failed out of 977\n\nThe remaining failures will be addressed in subsequent commits.\n\nAs this isn't needed on Windows let's skip this there. There's also an\nunconfirmed (it works in CI) report[5] that invoking the \"chmod\"\ncommand fails in some scenarios.\n\n1. f31b6244950 (Merge branch 'yw/cmake-updates', 2022-06-07)\n2. e4597aae659 (run test suite without dashed git-commands in PATH, 2009-12-02)\n3. 2ea1d8b5563 (cmake: make it easier to diagnose regressions in CTest\n   runs, 2022-10-18)\n4. https://cmake.org/cmake/help/latest/command/file.html#chmod\n5. https://lore.kernel.org/git/87f22a55-ee84-2f76-7b9b-924a97f44f89@dunelm.org.uk/\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n\nwrite script\n---\n contrib/buildsystems/CMakeLists.txt | 27 +++++++++++++++++++++------\n 1 file changed, 21 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 29b73ecbbbc..74b094ae5dc 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -847,6 +847,21 @@ add_custom_command(OUTPUT ${git_links} ${git_http_links}\n \t\tDEPENDS git git-remote-http)\n add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n \n+function(write_script path content)\n+\tfile(WRITE ${path} ${content})\n+\n+\tif(WIN32)\n+\t\tmessage(TRACE \"skipping chmod +x '${path}' on Windows\")\n+\telseif(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" VERSION_GREATER_EQUAL \"3.19\")\n+\t\tfile(CHMOD ${path} FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)\n+\telse()\n+\t\texecute_process(COMMAND chmod +x ${path}\n+\t\t\t\tRESULT_VARIABLE CHILD_ERROR)\n+\t\tif(CHILD_ERROR)\n+\t\t\tmessage(FATAL_ERROR \"failed to chmod +x '${path}': '${CHILD_ERROR}'\")\n+\t\tendif()\n+\tendif()\n+endfunction()\n \n #creating required scripts\n set(SHELL_PATH /bin/sh)\n@@ -872,7 +887,7 @@ foreach(script ${git_shell_scripts})\n \tstring(REPLACE \"# @@BROKEN_PATH_FIX@@\" \"\" content \"${content}\")\n \tstring(REPLACE \"@@PERL@@\" \"${PERL_PATH}\" content \"${content}\")\n \tstring(REPLACE \"@@PAGER_ENV@@\" \"LESS=FRX LV=-c\" content \"${content}\")\n-\tfile(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n+\twrite_script(${CMAKE_BINARY_DIR}/${script} \"${content}\")\n endforeach()\n \n #perl scripts\n@@ -887,13 +902,13 @@ foreach(script ${git_perl_scripts})\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)\n \tstring(REPLACE \"#!/usr/bin/perl\" \"#!/usr/bin/perl\\n${perl_header}\\n\" content \"${content}\")\n \tstring(REPLACE \"@@GIT_VERSION@@\" \"${PROJECT_VERSION}\" content \"${content}\")\n-\tfile(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n+\twrite_script(${CMAKE_BINARY_DIR}/${script} \"${content}\")\n endforeach()\n \n #python script\n file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)\n string(REPLACE \"#!/usr/bin/env python\" \"#!/usr/bin/python\" content \"${content}\")\n-file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})\n+write_script(${CMAKE_BINARY_DIR}/git-p4 \"${content}\")\n file(COPY ${CMAKE_SOURCE_DIR}/git-p4.py DESTINATION ${CMAKE_BINARY_DIR}/)\n \n #perl modules\n@@ -1032,20 +1047,20 @@ foreach(script ${wrapper_scripts})\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n \tstring(REPLACE \"@@PROG@@\" \"${script}${EXE_EXTENSION}\" content \"${content}\")\n-\tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n+\twrite_script(${CMAKE_BINARY_DIR}/bin-wrappers/${script} \"${content}\")\n endforeach()\n \n foreach(script ${wrapper_test_scripts})\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n \tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}${EXE_EXTENSION}\" content \"${content}\")\n-\tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n+\twrite_script(${CMAKE_BINARY_DIR}/bin-wrappers/${script} \"${content}\")\n endforeach()\n \n file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n string(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n string(REPLACE \"@@PROG@@\" \"git-cvsserver\" content \"${content}\")\n-file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})\n+write_script(${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver \"${content}\")\n \n #options for configuring test options\n option(PERL_TESTS \"Perform tests that use perl\" ON)\n-- \n2.39.0.1071.g97ce8966538\n\n"},{"id":"469314","messageId":"patch-5.6-70a7f3e19b2-20221219T183623Z-avarab@gmail.com","threadId":"58984","inReplyTo":"cover-0.6-00000000000-20221219T183623Z-avarab@gmail.com","subject":"[PATCH 5/6] cmake: copy over git-p4.py for t983[56] perforce test","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-12-19T18:39:23Z","receivedAt":"2022-12-19T18:40:03Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Since [1] two git-p4 tests have relied on there being a \"git-p4.py\" in\nthe build directory, but the cmake recipe was not updated to account\nfor this. Let's copy the \"git-p4.py\" over.\n\nWe could also change the test to e.g. grab the built \"git-p4\" and\nalter its shebang, which would be friendly to GIT_TEST_INSTALLED, but\nlet's just do the bare minimum here to get cmake+ctest working without\naltering the test itself.\n\nThe reason this hasn't been caught by \"vs-build\" and \"vs-test\" is\nbecause those tests added in [2] invoke \"cmake\" with\n\"-DPYTHON_TESTS=OFF\", and therefore we'd skip this part of the git-p4\ntests before getting past the \"do we have python?\" check. Even if we\ngot past that the Windows CI wouldn't have a \"p4\" or \"p4d\" binary\ninstalled, so we'd skip the tests anyway.\n\nIn a subsequent commit we'll run \"cmake\" and \"ctest\" in CI with\n\"ubuntu-latest\", so we'll need this \"git-p4.py\" file.\n\n1. f7b5ff607fa (git-p4: improve encoding handling to support\n   inconsistent encodings, 2022-04-30)\n2. 4c2c38e800f (ci: modification of main.yml to use cmake for vs-build\n   job, 2020-06-26)\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 560a15ed35a..29b73ecbbbc 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -894,6 +894,7 @@ endforeach()\n file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)\n string(REPLACE \"#!/usr/bin/env python\" \"#!/usr/bin/python\" content \"${content}\")\n file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})\n+file(COPY ${CMAKE_SOURCE_DIR}/git-p4.py DESTINATION ${CMAKE_BINARY_DIR}/)\n \n #perl modules\n file(GLOB_RECURSE perl_modules \"${CMAKE_SOURCE_DIR}/perl/*.pm\")\n-- \n2.39.0.1071.g97ce8966538\n\n"}]}