From patchwork Tue Oct 15 09:46:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13836011 Received: from fout-b6-smtp.messagingengine.com (fout-b6-smtp.messagingengine.com [202.12.124.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3CA9175A6 for ; Tue, 15 Oct 2024 09:46:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728985579; cv=none; b=kjVUJf9oHpphL+6hX5wxlAlphr+86+mThQy2NyvjgwOA+TGtd3iVnlj4oT8U+vXQ/nCQddvbzWi16t7APdig5nJ3aCkM+56E10H28uNRofO61/kewwfpyl3Llfq6WV5ggkAtWVW6TTsXkDd0KaTcsFJpMABeYcAB4caXtcHN3uU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728985579; c=relaxed/simple; bh=OV6U0d3vfE0IzI1n7/TAYc5yiiEPvG1KZTWVY2SUBYI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nFbrJerJLwBWBT42ivyE9Qq6yLUD27AdrqT9u4g7dxPyA88wvgxO5zHWLxuLSVwF/NolibcdDtxrf1Y/3Q960Zv7o/izbTpcjpmVPUnQEYM12u3P2EiVVJbTtJNlM9MKnTmrK9DQZv5IyAZTVolim9ToUdP/wBq20cCncBqExMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=HEvl6AIN; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=WOEciAE9; arc=none smtp.client-ip=202.12.124.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="HEvl6AIN"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="WOEciAE9" Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id A07FD11400AA; Tue, 15 Oct 2024 05:46:16 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Tue, 15 Oct 2024 05:46:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728985576; x=1729071976; bh=xsgcGpYc+A HRZqMJGfgUgEmvEDcq5E7CBkAURUnPOLA=; b=HEvl6AINhoohoC9F4Tiv7xu93e d1wrSB6eudO84FLgaEclHI4xDacDhs0TFDS++2vOUuGxfTGxuh/cH0LJhsL1wJhQ cRBgK0UEa05LC9b7R9Yh5smqaVIgSuYme4lwm0vtkNk/Lc77+Wn1cIysh9gNsMRD 9S+kyl5vbL65Tr5Q/7/+Db5Y9iOqgECuhM35nuXMzet9QpeqJ7jFJl43u55EYkBM /Lftd0AJw1Jm/AZilkQ3bGxY2OjJ1pag+ZhAvw619dHj7+GWrQoWa8iw/DTzCCvu c2XoAP6PWxuayfMM1JcG3+n/sJ9OzBDlrOZw6TybkFms15uR5t/wsAu0B7vQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728985576; x=1729071976; bh=xsgcGpYc+AHRZqMJGfgUgEmvEDcq 5E7CBkAURUnPOLA=; b=WOEciAE9cRiHVHg4YAdP6rS7Fc9pYHqJCopYkAgVQ2vK uBoiImiH8GizPPPxSltkwojA2sKxmRHCnSfl31Rp3MUoNHzH24tA51BX2+DyIrbq azs0xqolURZ8/pHYmI9hsoAJLdkU5OWkqteA4J+XcLV5/EFEB4J7cchWG0wrkJoD y8lgWvHktdhDbYYB7HlU0qED3edgV7FnnxAPVXAE/1Wr+M+2i0HlFFnBIGNd57uv s2HjI9l72ngIzuewPJIJuxr5TpHTtY16yIHQUXGXOR1NVvAJt3miF/DEUH+PmUSU aqIe667RmESB+MhDCtSAnB+CO4CQbP9TH8W4FHgAng== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdegjedgvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvden ucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimh eqnecuggftrfgrthhtvghrnhepveekkeffhfeitdeludeigfejtdetvdelvdduhefgueeg udfghfeukefhjedvkedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspghrtghpthhtohepgedpmhhouggvpehs mhhtphhouhhtpdhrtghpthhtohepghhithesvhhgvghrrdhkvghrnhgvlhdrohhrghdprh gtphhtthhopehjohhhrghnnhgvshdrshgthhhinhguvghlihhnsehgmhigrdguvgdprhgt phhtthhopegvughrvggvlhesghhmrghilhdrtghomhdprhgtphhtthhopehmvgesthhtrg ihlhhorhhrrdgtohhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 15 Oct 2024 05:46:15 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id b661a90e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 15 Oct 2024 09:44:59 +0000 (UTC) Date: Tue, 15 Oct 2024 11:46:11 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Ed Reel , Johannes Schindelin , Taylor Blau Subject: [PATCH v2 1/3] Makefile: extract script to generate clar declarations Message-ID: <7a619677c7af6ba8213a36208e20ab75c4318e38.1728985514.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Extract the script to generate function declarations for the clar unit testing framework into a standalone script. This is done such that we can reuse it in other build systems. Signed-off-by: Patrick Steinhardt --- Makefile | 4 +--- t/unit-tests/generate-clar-decls.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100755 t/unit-tests/generate-clar-decls.sh diff --git a/Makefile b/Makefile index feeed6f9321..87b86c5be1a 100644 --- a/Makefile +++ b/Makefile @@ -3904,9 +3904,7 @@ GIT-TEST-SUITES: FORCE fi $(UNIT_TEST_DIR)/clar-decls.h: $(patsubst %,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUITES)) GIT-TEST-SUITES - $(QUIET_GEN)for suite in $(CLAR_TEST_SUITES); do \ - sed -ne "s/^\(void test_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)$$\)/extern \1;/p" $(UNIT_TEST_DIR)/$$suite.c; \ - done >$@ + $(QUIET_GEN)$(SHELL_PATH) $(UNIT_TEST_DIR)/generate-clar-decls.sh "$@" $(patsubst %,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUITES)) $(UNIT_TEST_DIR)/clar.suite: $(UNIT_TEST_DIR)/clar-decls.h $(QUIET_GEN)awk -f $(UNIT_TEST_DIR)/clar-generate.awk $< >$(UNIT_TEST_DIR)/clar.suite $(CLAR_TEST_OBJS): $(UNIT_TEST_DIR)/clar-decls.h diff --git a/t/unit-tests/generate-clar-decls.sh b/t/unit-tests/generate-clar-decls.sh new file mode 100755 index 00000000000..81da732917a --- /dev/null +++ b/t/unit-tests/generate-clar-decls.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +if test $# -lt 2 +then + echo "USAGE: $0 ..." 2>&1 + exit 1 +fi + +OUTPUT="$1" +shift + +for suite in "$@" +do + sed -ne "s/^\(void test_$suite__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)$\)/extern \1;/p" "$suite" || + exit 1 +done >"$OUTPUT" From patchwork Tue Oct 15 09:46:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13836013 Received: from fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50E861C9B68 for ; Tue, 15 Oct 2024 09:46:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728985581; cv=none; b=AlfT/Z7Zg2uRTIFT0uof4217R0rRKfHTW3vv4norfws5yrSvJf8nHCTLa08OyJfsA/6kIezHngUYqJqfE52N4Jf0VW5ygcpqaQ5rqUfj3tjM9SpmkiiLiNT0jdX/c0VKBCC7L0EBP2fQAyZh3+Q4x1nw3CI2of2VDQyEm5cl1i8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728985581; c=relaxed/simple; bh=Kl0AJ4n9zhg/y++ngEQ4g9zCh71eOBfwRGehyqJxUVc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fjnwz7CPZZqgXNdbOCQbbuyZxR4NOC0rLANcF76CO1oWGSCnDEmOQ2Y2NrhDW64sV2GXtpkWTd9yY2Muhddn48f2bJemBNn7Qcebll/piiu9Ecz8SjGdEpYwQi1OsJHxopiQqgwrqVwc9v74Edjcvm3Mv6TNY5fdVfaWTkCj4xU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=K/88nyKi; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=RssLjTOv; arc=none smtp.client-ip=202.12.124.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="K/88nyKi"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="RssLjTOv" Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 2825E25400B4; Tue, 15 Oct 2024 05:46:18 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Tue, 15 Oct 2024 05:46:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728985578; x=1729071978; bh=zYLO5UFxdR kmyC0RNarrzCBBDTJNtE+GRF9vYzMzkMA=; b=K/88nyKiAffGp4Rzco50X0AXTH EXmwePkL3gdta5kA7DhNA/8tNXk6ShDNyUE8m5yJx97nCkDQqzpilP1FIUe3scDu UZoD4NOvKzpYuRtLea0N25APM9ynNi01ZtDt4akM5nFOJpTlEHOOXlybci7tNbcV JTsziQ6Rx64u5yrOeunVG4KUGW+F6+5JyA3hEPTd9jSuxX6v2A3vX1M0BNR8xUlH bBOgE/4xDfaf9cf4jWM8HtirGrVViUUPHA0wsAitmjQ+0e1LPY8SN0KNNUbV/Jvd h7eB4GE0jA5zo89LRw4AnEIbL+su+3Pz5Xikp1u2hGtXMQeiyG+O1cFw8IPg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728985578; x=1729071978; bh=zYLO5UFxdRkmyC0RNarrzCBBDTJN tE+GRF9vYzMzkMA=; b=RssLjTOv44iGzpUFIxT67Pd+jT9zDiUeq+Lf2dvdkqe3 QSMVsWN7N8+8HRGRSvbMYJuo7rNOKeWTxj6qZ4zzeC+/911UR+I7+pJFrU7cI1J3 u8V8kwPrMFg587NbpldzUZK4N8bXaVHoRTh32oS7/x2mikzcgcULeeyfgX+2qDJk am4vxxSsRmavCIPXFHiEpqSb/gyWp3VZ2z5dkMIsuaUGXazeU+TCkNbcGMkLp/v6 qwzjSCY51SVnpJxTDmXga6YT2TglEJtk2kzcKXwwpNu5BEuk2rq048n9j64oPU9B jkJMre0tt8uwCxFvm+OZN7vN83msUkotinKIGKl8MQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdegjedgvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvden ucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimh eqnecuggftrfgrthhtvghrnhepveekkeffhfeitdeludeigfejtdetvdelvdduhefgueeg udfghfeukefhjedvkedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspghrtghpthhtohepgedpmhhouggvpehs mhhtphhouhhtpdhrtghpthhtohepghhithesvhhgvghrrdhkvghrnhgvlhdrohhrghdprh gtphhtthhopehjohhhrghnnhgvshdrshgthhhinhguvghlihhnsehgmhigrdguvgdprhgt phhtthhopegvughrvggvlhesghhmrghilhdrtghomhdprhgtphhtthhopehmvgesthhtrg ihlhhorhhrrdgtohhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 15 Oct 2024 05:46:16 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 82cf4e02 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 15 Oct 2024 09:45:01 +0000 (UTC) Date: Tue, 15 Oct 2024 11:46:14 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Ed Reel , Johannes Schindelin , Taylor Blau Subject: [PATCH v2 2/3] cmake: fix compilation of clar-based unit tests Message-ID: <447afc4a0f37812b6488a51915a86302c20ddb12.1728985514.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The compilation of clar-based unit tests is broken because we do not add the binary directory into which we generate the "clar-decls.h" and "clar.suite" files as include directories. Instead, we accidentally set up the source directory as include directory. Fix this by including the binary directory instead of the source directory. Furthermore, set up the include directories as PUBLIC instead of PRIVATE such that they propagate from "unit-tests.lib" to the "unit-tests" executable, which needs to include the same directory. Reported-by: Ed Reel Signed-off-by: Patrick Steinhardt --- contrib/buildsystems/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt index 62af7b33d2f..093852ad9d6 100644 --- a/contrib/buildsystems/CMakeLists.txt +++ b/contrib/buildsystems/CMakeLists.txt @@ -1042,7 +1042,7 @@ file(WRITE "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite" "${clar_decls}" "${clar 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") -target_include_directories(unit-tests-lib PRIVATE "${CMAKE_SOURCE_DIR}/t/unit-tests") +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) set_target_properties(unit-tests From patchwork Tue Oct 15 09:46:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13836014 Received: from fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE4221C9B68 for ; Tue, 15 Oct 2024 09:46:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728985586; cv=none; b=W+UtjkZBhtstRdOCn3uOqJ3N5sx0qWrKwCSuAUEBk+fKh01bPzgv6A3DQDUFVyr5F0F2eJfS0rrEHMjWodch1nMCazjHFt7fONXObEECrrxjmwO3HvE8Bv4WI9o7OUljERgPMoA0SsIGZ9HF/ys1UC3IyUWTNSNQ3UPHprVve68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728985586; c=relaxed/simple; bh=GsLwj5/w33fv4cikxIvLwctBSP2ExHPAE6i4bKSo6PU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NqY5uMQuX1CWHosaXoeQLAddd97eO8koO3aiBEknKQRjKJqDTJjy2eHxmYUUaOWFcvOhP5BHeonyXYKwRZDmpgC0yc3t+IzYDCtGlkFJhmPkDwvgRmPExhYOcr9WqaNSZq7auyfy+XZI3Ox0+hKDtcTcWK1ZnZPSdk3GS5zswu0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=YiCtg+Lk; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=VLoR0ktL; arc=none smtp.client-ip=202.12.124.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="YiCtg+Lk"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VLoR0ktL" Received: from phl-compute-02.internal (phl-compute-02.phl.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id B555425400AC; Tue, 15 Oct 2024 05:46:23 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Tue, 15 Oct 2024 05:46:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728985583; x=1729071983; bh=nXEBxyoUXU 2vNAnXcDZ4i2LAL0iOEDM9z+7UIryYypU=; b=YiCtg+LkrYNN2EHuktnkvghLQQ nU5eUR1P+AsDHKZyFYJVtKvGaGW7XTNQzPYWWTP/SIq5PlGermMwDYJLEuRhc3kM QaNmHCv3R6okFko5rqDvSNqRFBfifvcOJOzAJ5a9NHTuTOYnaelh29m/WTI7JUik 5n0idmgIheplSnzKs5nDvslAQ5UroqAIfBERzbrNSWEKAVUO2ncIUhldZOGXvK+x VgEBuhDx+LAr26MHafsvO9oPNeRU2u05W9qCElf0G7umoIwkLS3dktXOLNZrFFFp HGLLGkqrPbJ+d2y2RwyQQ22s/tI5in6nTmtVwnQz0uchLEBZThgYfeBXQXsA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728985583; x=1729071983; bh=nXEBxyoUXU2vNAnXcDZ4i2LAL0iO EDM9z+7UIryYypU=; b=VLoR0ktLyx7WZkOpDelgSXK7cdykhPccGIrrl0RL1fjZ jwsasDa22aj5mCTAtuIhY9kO0vf0L6DNeSmWk2rUR7ilAzxcGW+TDKYPT7blveUc YXVrh3s41OlYqx955YjRoYKpbWW5Ht5uNxmDak2Sb9kSv+2HXgmwfvEZ4XXHaKPd 1ryTXYuueRv8qd6fHJkrM3T0pAflh+EseMAeOFiSg5c5RTGvgSRT0/r/EcVDqu6F hhssoryOfmkXarP3IzLwAznjGniH88tv3hl/KQae5x+WyDoDa9Iokm8xW6qgu27i 568fOorNmrzU8I+SDN8Y15M3wpIJGE5xDScsjjfKOA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdegjedgvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvden ucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimh eqnecuggftrfgrthhtvghrnhepveekkeffhfeitdeludeigfejtdetvdelvdduhefgueeg udfghfeukefhjedvkedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspghrtghpthhtohepgedpmhhouggvpehs mhhtphhouhhtpdhrtghpthhtohepvggurhgvvghlsehgmhgrihhlrdgtohhmpdhrtghpth htohepjhhohhgrnhhnvghsrdhstghhihhnuggvlhhinhesghhmgidruggvpdhrtghpthht ohepghhithesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehmvgesthhtrg ihlhhorhhrrdgtohhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 15 Oct 2024 05:46:22 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 7f23df85 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 15 Oct 2024 09:45:07 +0000 (UTC) Date: Tue, 15 Oct 2024 11:46:17 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Ed Reel , Johannes Schindelin , Taylor Blau Subject: [PATCH v2 3/3] cmake: set up proper dependencies for generated clar headers Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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. Signed-off-by: Patrick Steinhardt --- 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)