From: Phillip Wood <phillip.wood123@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, "Alejandro R. Sedeño" <asedeno@mit.edu>,
"Toon Claes" <toon@iotcl.com>, "Taylor Blau" <me@ttaylorr.com>,
"Ed Reel" <edreel@gmail.com>,
"Bagas Sanjaya" <bagasdotme@gmail.com>,
"Edgar Bonet" <bonet@grenoble.cnrs.fr>,
"Jeff King" <peff@peff.net>,
"brian m. carlson" <sandals@crustytoothpaste.net>
Subject: Re: [PATCH v2 5/5] cmake: set up proper dependencies for generated clar headers
Date: Wed, 6 Nov 2024 10:59:08 +0000 [thread overview]
Message-ID: <829fe630-e46a-4a3a-82dd-4e5feedd190c@gmail.com> (raw)
In-Reply-To: <3b2cb360-297a-915c-ae27-c45f38fa49b9@gmx.de>
Hi Johannes
On 05/11/2024 19:55, Johannes Schindelin wrote:
> Hi Patrick,
>
> On Mon, 21 Oct 2024, Patrick Steinhardt wrote:
>
>> The auto-generated headers used by clar are written at configure time
>> and thus do not get regenerated automatically. Refactor the build
>> recipes such that we use custom commands instead, which also has the
>> benefit that we can reuse the same infrastructure as our Makefile.
>
> For the record: I did not use a shell script to generate the header for a
> specific reason: Unix shell scripts are not native to Windows. Therefore
> they cannot in general be run on Windows, however that was precisely the
> idea for the CMake definition: to be run on a vanilla Windows with Visual
> Studio installed.
>
> Sadly, even Git's CI definition sets things up in a way that Git for
> Windows' Bash can be used in the CMake definition, but in the intended use
> case (opening a checkout of git/git in Visual Studio without any further
> tools required) won't have a usable Bash.
>
> Therefore I am unsure whether this patch is desirable.
CMakeLists.txt tries to find sh.exe from git-for-windows and errors out
if it cannot be found. It then uses that shell to run a number of
scripts. Perhaps we should do the same in this patch? It would certainly
be a worthwhile improvement to regenerate this file at build time if the
source has changed.
Best Wishes
Phillip
> Ciao,
> Johannes
>
>>
>> Signed-off-by: Patrick Steinhardt <ps@pks.im>
>> ---
>> contrib/buildsystems/CMakeLists.txt | 50 +++++++----------------------
>> 1 file changed, 12 insertions(+), 38 deletions(-)
>>
>> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
>> index 093852ad9d6..9f80ab92656 100644
>> --- a/contrib/buildsystems/CMakeLists.txt
>> +++ b/contrib/buildsystems/CMakeLists.txt
>> @@ -1002,46 +1002,20 @@ foreach(unit_test ${unit_test_PROGRAMS})
>> endforeach()
>>
>> parse_makefile_for_scripts(clar_test_SUITES "CLAR_TEST_SUITES" "")
>> -
>> -set(clar_decls "")
>> -set(clar_cbs "")
>> -set(clar_cbs_count 0)
>> -set(clar_suites "static struct clar_suite _clar_suites[] = {\n")
>> -list(LENGTH clar_test_SUITES clar_suites_count)
>> -foreach(suite ${clar_test_SUITES})
>> - file(STRINGS "${CMAKE_SOURCE_DIR}/t/unit-tests/${suite}.c" decls
>> - REGEX "^void test_${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*\\(void\\)$")
>> -
>> - list(LENGTH decls decls_count)
>> - string(REGEX REPLACE "void (test_${suite}__([a-zA-Z_0-9]*))\\(void\\)" " { \"\\2\", &\\1 },\n" cbs ${decls})
>> - string(JOIN "" cbs ${cbs})
>> - list(TRANSFORM decls PREPEND "extern ")
>> - string(JOIN ";\n" decls ${decls})
>> -
>> - string(APPEND clar_decls "${decls};\n")
>> - string(APPEND clar_cbs
>> - "static const struct clar_func _clar_cb_${suite}[] = {\n"
>> - ${cbs}
>> - "};\n")
>> - string(APPEND clar_suites
>> - " {\n"
>> - " \"${suite}\",\n"
>> - " { NULL, NULL },\n"
>> - " { NULL, NULL },\n"
>> - " _clar_cb_${suite}, ${decls_count}, 1\n"
>> - " },\n")
>> - math(EXPR clar_cbs_count "${clar_cbs_count}+${decls_count}")
>> -endforeach()
>> -string(APPEND clar_suites
>> - "};\n"
>> - "static const size_t _clar_suite_count = ${clar_suites_count};\n"
>> - "static const size_t _clar_callback_count = ${clar_cbs_count};\n")
>> -file(WRITE "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h" "${clar_decls}")
>> -file(WRITE "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite" "${clar_decls}" "${clar_cbs}" "${clar_suites}")
>> -
>> list(TRANSFORM clar_test_SUITES PREPEND "${CMAKE_SOURCE_DIR}/t/unit-tests/")
>> list(TRANSFORM clar_test_SUITES APPEND ".c")
>> -add_library(unit-tests-lib ${clar_test_SUITES} "${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c")
>> +add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h"
>> + COMMAND ${CMAKE_SOURCE_DIR}/t/unit-tests/generate-clar-decls.sh "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h" ${clar_test_SUITES}
>> + DEPENDS ${CMAKE_SOURCE_DIR}/t/unit-tests/generate-clar-decls.sh ${clar_test_SUITES})
>> +add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite"
>> + COMMAND awk -f "${CMAKE_SOURCE_DIR}/t/unit-tests/clar-generate.awk" "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h" > "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite"
>> + DEPENDS "${CMAKE_SOURCE_DIR}/t/unit-tests/clar-generate.awk" "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h")
>> +
>> +add_library(unit-tests-lib ${clar_test_SUITES}
>> + "${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c"
>> + "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h"
>> + "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite"
>> +)
>> target_include_directories(unit-tests-lib PUBLIC "${CMAKE_BINARY_DIR}/t/unit-tests")
>> add_executable(unit-tests "${CMAKE_SOURCE_DIR}/t/unit-tests/unit-test.c")
>> target_link_libraries(unit-tests unit-tests-lib common-main)
>> --
>> 2.47.0.72.gef8ce8f3d4.dirty
>>
>>
>
next prev parent reply other threads:[~2024-11-06 10:59 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-12 2:10 git no longer builds on SunOS 5.10, a report Alejandro R. Sedeño
2024-10-12 8:19 ` Patrick Steinhardt
2024-10-12 14:34 ` Alejandro R. Sedeño
2024-10-12 14:40 ` [PATCH] Makefile: adjust sed command for generating "clar-decls.h" Alejandro R. Sedeño
2024-10-12 14:42 ` git no longer builds on SunOS 5.10, a report Alejandro R. Sedeño
2024-10-13 19:57 ` Patrick Steinhardt
2024-10-13 22:50 ` Alejandro R. Sedeño
2024-10-14 6:20 ` Patrick Steinhardt
2024-10-14 11:45 ` [PATCH 0/2] t/unit-tests: improve clar platform compatibility Patrick Steinhardt
2024-10-14 11:45 ` [PATCH 1/2] t/unit-tests: update clar to 0810a36 Patrick Steinhardt
2024-10-14 11:45 ` [PATCH 2/2] Makefile: adjust sed command for generating "clar-decls.h" Patrick Steinhardt
2024-10-18 15:45 ` Toon Claes
2024-10-18 21:14 ` Taylor Blau
2024-10-21 7:00 ` Patrick Steinhardt
2024-10-21 10:56 ` [PATCH v2 0/5] t/unit-tests: improve clar platform compatibility Patrick Steinhardt
2024-10-21 10:56 ` [PATCH v2 1/5] t/unit-tests: update clar to 206accb Patrick Steinhardt
2024-10-21 10:56 ` [PATCH v2 2/5] Makefile: adjust sed command for generating "clar-decls.h" Patrick Steinhardt
2024-10-21 11:07 ` Kristoffer Haugsbakk
2024-10-21 11:35 ` Patrick Steinhardt
2024-10-21 10:56 ` [PATCH v2 3/5] Makefile: extract script to generate clar declarations Patrick Steinhardt
2024-10-21 10:56 ` [PATCH v2 4/5] cmake: fix compilation of clar-based unit tests Patrick Steinhardt
2024-10-21 10:56 ` [PATCH v2 5/5] cmake: set up proper dependencies for generated clar headers Patrick Steinhardt
2024-11-05 19:55 ` Johannes Schindelin
2024-11-06 10:59 ` Phillip Wood [this message]
2024-11-08 12:59 ` Patrick Steinhardt
2024-10-21 20:52 ` [PATCH v2 0/5] t/unit-tests: improve clar platform compatibility Taylor Blau
2024-10-25 12:17 ` karthik nayak
2024-10-26 5:01 ` Bagas Sanjaya
2024-10-27 13:01 ` Patrick Steinhardt
2024-10-27 23:56 ` Taylor Blau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=829fe630-e46a-4a3a-82dd-4e5feedd190c@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=asedeno@mit.edu \
--cc=bagasdotme@gmail.com \
--cc=bonet@grenoble.cnrs.fr \
--cc=edreel@gmail.com \
--cc=git@vger.kernel.org \
--cc=me@ttaylorr.com \
--cc=peff@peff.net \
--cc=phillip.wood@dunelm.org.uk \
--cc=ps@pks.im \
--cc=sandals@crustytoothpaste.net \
--cc=toon@iotcl.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).