build: split .c and .h file lists in tests

It allows to pass `.h` files only where they are really needed, which is
`EXTRA_DIST` (or `*SOURCES`) for autotools.

Also:
- rename variables to be shorter and consistent.
- drop references to non-local headers. We don't need to pass them as
  dist sources.
- drop empty variables and references, after the above.
- server: add placeholder `UTIL_H`.

Closes #17745
This commit is contained in:
Viktor Szakats 2025-06-25 13:30:23 +02:00
parent f547bca4b6
commit 53c88435d8
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
15 changed files with 72 additions and 69 deletions

View file

@ -22,16 +22,16 @@
#
###########################################################################
# Get BUNDLE, FIRSTFILES, UTILS, CURLX_CFILES, TESTFILES variables
# Get BUNDLE, FIRST_C, FIRST_H, UTILS_C, UTILS_H, CURLX_C, TESTS_C variables
curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
add_custom_command(OUTPUT "${BUNDLE}.c"
COMMAND ${PERL_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl"
--include ${UTILS} ${CURLX_CFILES} --test ${TESTFILES} > "${BUNDLE}.c"
--include ${UTILS_C} ${CURLX_C} --test ${TESTS_C} > "${BUNDLE}.c"
DEPENDS
"${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc"
${FIRSTFILES} ${UTILS} ${CURLX_CFILES} ${TESTFILES}
${FIRST_C} ${UTILS_C} ${CURLX_C} ${TESTS_C}
VERBATIM)
add_executable(${BUNDLE} EXCLUDE_FROM_ALL "${BUNDLE}.c")
@ -55,4 +55,4 @@ if(WIN32)
endif()
set_target_properties(${BUNDLE} PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF C_CLANG_TIDY "")
curl_clang_tidy_tests(${BUNDLE} ${FIRSTFILES} ${UTILS} ${TESTFILES})
curl_clang_tidy_tests(${BUNDLE} ${FIRST_C} ${UTILS_C} ${TESTS_C})

View file

@ -38,10 +38,10 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \
-I$(top_srcdir)/lib \
-I$(srcdir)
# Get BUNDLE, FIRSTFILES, UTILS, CURLX_CFILES, TESTFILES variables
# Get BUNDLE, FIRST_C, FIRST_H, UTILS_C, UTILS_H, CURLX_C, TESTS_C variables
include Makefile.inc
EXTRA_DIST = CMakeLists.txt .checksrc $(FIRSTFILES) $(UTILS) $(TESTFILES)
EXTRA_DIST = CMakeLists.txt .checksrc $(FIRST_C) $(FIRST_H) $(UTILS_C) $(UTILS_H) $(TESTS_C)
CFLAGS += @CURL_CFLAG_EXTRAS@
@ -54,8 +54,8 @@ if DOING_NATIVE_WINDOWS
AM_CPPFLAGS += -DCURL_STATICLIB
endif
${BUNDLE}.c: $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRSTFILES) $(UTILS) $(CURLX_CFILES) $(TESTFILES)
@PERL@ $(top_srcdir)/scripts/mk-unity.pl --include $(UTILS) $(CURLX_CFILES) --test $(TESTFILES) > ${BUNDLE}.c
${BUNDLE}.c: $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRST_C) $(UTILS_C) $(CURLX_C) $(TESTS_C)
@PERL@ $(top_srcdir)/scripts/mk-unity.pl --include $(UTILS_C) $(CURLX_C) --test $(TESTS_C) > ${BUNDLE}.c
noinst_PROGRAMS = $(BUNDLE)
LDADD = @CURL_NETWORK_AND_TIME_LIBS@

View file

@ -26,12 +26,14 @@
BUNDLE = servers
# Files referenced from the bundle source
FIRSTFILES = first.c first.h
FIRST_C = first.c
FIRST_H = first.h
# Common files used by test programs
UTILS = memptr.c getpart.c util.c
UTILS_C = memptr.c getpart.c util.c
UTILS_H =
CURLX_CFILES = \
CURLX_C = \
../../lib/curlx/base64.c \
../../lib/curlx/inet_pton.c \
../../lib/curlx/inet_ntop.c \
@ -46,7 +48,7 @@ CURLX_CFILES = \
../../lib/curlx/winapi.c
# All test servers
TESTFILES = \
TESTS_C = \
dnsd.c \
mqttd.c \
resolve.c \