mirror of
https://github.com/curl/curl.git
synced 2026-04-15 01:01:41 +03:00
build: sync tests unity builds between cmake and autotools
Instead of relying on CMake's built-in unity feature, use `mk-unity.pl`,
as already done with autotools. It simplified the build, shortens logs
and makes debugging easier because of the fewer build variations.
It also allows testing / fixing with cmake and those automatically apply
to autotools builds too. cmake builds can be much-much faster, esp.
when working the builds themselves.
It also enables "unity" in old cmake versions. Basically every test
target is a single generated .c source.
Also:
- drop a `lib` unity workaround for libtests with autotools after fixing
the issue in libtests itself. It drops a few exceptions and makes
libcurl build faster (in autotools unity).
- fix another `lib` autotools unity issue and drop the workaround for it
from `mk-unity.pl`. `srcdir` was missing from the header path.
- simplify `mk-unity.pl` command-lines, drop exclusions.
Follow-up to 2c27a67daa #17590
Closes #17628
This commit is contained in:
parent
3186a20483
commit
ee06673296
9 changed files with 48 additions and 45 deletions
|
|
@ -37,6 +37,5 @@ foreach(_target IN LISTS check_PROGRAMS)
|
|||
if(LIB_SELECTED STREQUAL LIB_STATIC AND WIN32)
|
||||
set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_STATICLIB")
|
||||
endif()
|
||||
set_target_properties(${_target_name} PROPERTIES OUTPUT_NAME "${_target}" PROJECT_LABEL "Example ${_target}"
|
||||
UNITY_BUILD OFF)
|
||||
set_target_properties(${_target_name} PROPERTIES OUTPUT_NAME "${_target}" PROJECT_LABEL "Example ${_target}" UNITY_BUILD OFF)
|
||||
endforeach()
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ CFLAGS += @CURL_CFLAG_EXTRAS@
|
|||
# $(top_builddir)/lib is for libcurl's generated lib/curl_config.h file
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include \
|
||||
-I$(top_builddir)/lib
|
||||
-I$(top_builddir)/lib \
|
||||
-I$(srcdir)
|
||||
|
||||
# Prevent LIBS from being used for all link targets
|
||||
LIBS = $(BLANK_AT_MAKETIME)
|
||||
|
|
@ -75,9 +76,7 @@ CSOURCES += dllmain.c
|
|||
endif
|
||||
|
||||
if USE_UNITY
|
||||
# Keep these separate to avoid duplicate definitions when linking libtests
|
||||
# in static mode.
|
||||
curl_EXCLUDE = curl_threads.c curlx/timediff.c curlx/warnless.c
|
||||
curl_EXCLUDE =
|
||||
if CURLDEBUG
|
||||
# We must compile this source separately to avoid memdebug.h redefinitions
|
||||
# applying to it.
|
||||
|
|
|
|||
|
|
@ -91,10 +91,10 @@ foreach my $src (@src) {
|
|||
if($src =~ /([a-z0-9]+)\.c$/ && !exists $exclude{$src}) {
|
||||
my $name = $1;
|
||||
my $fn = $src;
|
||||
if($srcdir ne "" && (exists $include{$src} || $embed) && -e "$srcdir/$fn") {
|
||||
$fn = $srcdir . "/" . $fn;
|
||||
}
|
||||
if($embed) {
|
||||
if($srcdir ne "" && -e "$srcdir/$fn") {
|
||||
$fn = $srcdir . "/" . $fn;
|
||||
}
|
||||
my $content = do { local $/; open my $fh, '<', $fn or die $!; <$fh> };
|
||||
print $content;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,11 @@
|
|||
curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
|
||||
include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
|
||||
|
||||
set(_bundle_extra "")
|
||||
if(LIB_SELECTED STREQUAL LIB_SHARED)
|
||||
list(APPEND _bundle_extra ${CURLX_SRCS}) # Not exported from the libcurl shared build. Build a copy.
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "lib1521.c"
|
||||
COMMAND ${PERL_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl" < "${PROJECT_SOURCE_DIR}/include/curl/curl.h" "lib1521.c"
|
||||
|
|
@ -36,18 +41,15 @@ add_custom_command(
|
|||
|
||||
add_custom_command(
|
||||
OUTPUT "${BUNDLE_SRC}"
|
||||
COMMAND ${PERL_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" --test ${TESTFILES} "lib1521.c"
|
||||
COMMAND ${PERL_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl"
|
||||
--include ${UTILS} ${MEMPTR} ${_bundle_extra} --test ${TESTFILES} "lib1521.c"
|
||||
${CURL_MK_UNITY_OPTION} --srcdir "${CMAKE_CURRENT_SOURCE_DIR}" > "${BUNDLE_SRC}"
|
||||
DEPENDS
|
||||
"${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc" ${FIRSTFILES} ${TESTFILES} "lib1521.c"
|
||||
"${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc"
|
||||
${FIRSTFILES} ${UTILS} ${MEMPTR} ${_bundle_extra} ${TESTFILES} "lib1521.c"
|
||||
VERBATIM)
|
||||
|
||||
set(_sources "")
|
||||
if(LIB_SELECTED STREQUAL LIB_SHARED)
|
||||
list(APPEND _sources ${MEMPTR} ${CURLX_SRCS}) # These are part of the libcurl static lib. Add them here when linking shared.
|
||||
endif()
|
||||
|
||||
add_executable(libtests EXCLUDE_FROM_ALL ${_sources} ${UTILS} "${BUNDLE_SRC}")
|
||||
add_executable(libtests EXCLUDE_FROM_ALL "${BUNDLE_SRC}")
|
||||
add_dependencies(testdeps libtests)
|
||||
target_link_libraries(libtests ${LIB_SELECTED} ${CURL_LIBS})
|
||||
target_include_directories(libtests PRIVATE
|
||||
|
|
@ -59,4 +61,4 @@ target_include_directories(libtests PRIVATE
|
|||
"${PROJECT_SOURCE_DIR}/tests/unit" # for curlcheck.h
|
||||
)
|
||||
set_property(TARGET libtests APPEND PROPERTY COMPILE_DEFINITIONS "${CURL_DEBUG_MACROS}" "CURL_NO_OLDIES" "CURL_DISABLE_DEPRECATION")
|
||||
set_target_properties(libtests PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}")
|
||||
set_target_properties(libtests PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF)
|
||||
|
|
|
|||
|
|
@ -88,17 +88,18 @@ libstubgss_la_LIBADD =
|
|||
libstubgss_la_DEPENDENCIES =
|
||||
endif
|
||||
|
||||
bundle_EXCLUDE =
|
||||
bundle_extra =
|
||||
if USE_CPPFLAG_CURL_STATICLIB
|
||||
else
|
||||
# These are part of the libcurl static lib. Add them here when linking shared.
|
||||
bundle_EXCLUDE += $(MEMPTR) $(CURLX_SRCS)
|
||||
bundle_extra += $(CURLX_SRCS)
|
||||
endif
|
||||
$(BUNDLE_SRC): $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRSTFILES) $(UTILS) $(MEMPTR) $(CURLX_SRCS) $(TESTFILES) lib1521.c
|
||||
@PERL@ $(top_srcdir)/scripts/mk-unity.pl --include $(UTILS) $(MEMPTR) $(CURLX_SRCS) --test $(TESTFILES) lib1521.c --exclude $(bundle_EXCLUDE) > $(BUNDLE_SRC)
|
||||
$(BUNDLE_SRC): $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRSTFILES) $(UTILS) $(MEMPTR) $(bundle_extra) $(TESTFILES) lib1521.c
|
||||
@PERL@ $(top_srcdir)/scripts/mk-unity.pl --include $(UTILS) $(MEMPTR) $(bundle_extra) --test $(TESTFILES) lib1521.c > $(BUNDLE_SRC)
|
||||
|
||||
noinst_PROGRAMS = $(BUNDLE)
|
||||
nodist_libtests_SOURCES = $(BUNDLE_SRC)
|
||||
libtests_SOURCES = $(bundle_EXCLUDE)
|
||||
libtests_SOURCES =
|
||||
CLEANFILES = $(BUNDLE_SRC) lib1521.c
|
||||
|
||||
lib1521.c: $(top_srcdir)/tests/libtest/mk-lib1521.pl $(top_srcdir)/include/curl/curl.h
|
||||
|
|
|
|||
|
|
@ -26,19 +26,22 @@
|
|||
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_SRC}"
|
||||
COMMAND ${PERL_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" --test ${TESTFILES}
|
||||
${CURL_MK_UNITY_OPTION} --srcdir "${CMAKE_CURRENT_SOURCE_DIR}" > "${BUNDLE_SRC}"
|
||||
DEPENDS
|
||||
"${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc" ${FIRSTFILES} ${TESTFILES}
|
||||
VERBATIM)
|
||||
|
||||
set(_sources_extra "")
|
||||
if(ENABLE_SERVER_DEBUG AND ENABLE_CURLDEBUG)
|
||||
set_source_files_properties("../../lib/memdebug.c" PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
|
||||
list(APPEND _sources_extra ${MEMDEBUG})
|
||||
endif()
|
||||
|
||||
add_executable(servers EXCLUDE_FROM_ALL ${MEMDEBUG} ${CURLX_SRCS} ${UTILS} "${BUNDLE_SRC}")
|
||||
add_custom_command(
|
||||
OUTPUT "${BUNDLE_SRC}"
|
||||
COMMAND ${PERL_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl"
|
||||
--include ${UTILS} ${CURLX_SRCS} --test ${TESTFILES}
|
||||
${CURL_MK_UNITY_OPTION} --srcdir "${CMAKE_CURRENT_SOURCE_DIR}" > "${BUNDLE_SRC}"
|
||||
DEPENDS
|
||||
"${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc"
|
||||
${FIRSTFILES} ${UTILS} ${CURLX_SRCS} ${TESTFILES}
|
||||
VERBATIM)
|
||||
|
||||
add_executable(servers EXCLUDE_FROM_ALL "${BUNDLE_SRC}" ${_sources_extra})
|
||||
add_dependencies(testdeps servers)
|
||||
target_include_directories(servers PRIVATE
|
||||
"${PROJECT_BINARY_DIR}/lib" # for "curl_config.h"
|
||||
|
|
@ -61,4 +64,4 @@ set_property(TARGET servers APPEND PROPERTY COMPILE_DEFINITIONS "WITHOUT_LIBCURL
|
|||
if(WIN32)
|
||||
set_property(TARGET servers APPEND PROPERTY COMPILE_DEFINITIONS "CURL_STATICLIB")
|
||||
endif()
|
||||
set_target_properties(servers PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}")
|
||||
set_target_properties(servers PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF)
|
||||
|
|
|
|||
|
|
@ -64,18 +64,17 @@ endif
|
|||
|
||||
AM_CPPFLAGS += -DWITHOUT_LIBCURL -DCURL_NO_OLDIES
|
||||
|
||||
bundle_EXCLUDE =
|
||||
if ENABLE_SERVER_DEBUG
|
||||
if CURLDEBUG
|
||||
bundle_EXCLUDE += $(MEMDEBUG)
|
||||
endif
|
||||
endif
|
||||
$(BUNDLE_SRC): $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRSTFILES) $(UTILS) $(MEMDEBUG) $(CURLX_SRCS) $(TESTFILES)
|
||||
@PERL@ $(top_srcdir)/scripts/mk-unity.pl --include $(UTILS) $(MEMDEBUG) $(CURLX_SRCS) --test $(TESTFILES) --exclude $(bundle_EXCLUDE) > $(BUNDLE_SRC)
|
||||
$(BUNDLE_SRC): $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRSTFILES) $(UTILS) $(CURLX_SRCS) $(TESTFILES)
|
||||
@PERL@ $(top_srcdir)/scripts/mk-unity.pl --include $(UTILS) $(CURLX_SRCS) --test $(TESTFILES) > $(BUNDLE_SRC)
|
||||
|
||||
noinst_PROGRAMS = $(BUNDLE)
|
||||
nodist_servers_SOURCES = $(BUNDLE_SRC)
|
||||
servers_SOURCES = $(bundle_EXCLUDE)
|
||||
servers_SOURCES =
|
||||
if ENABLE_SERVER_DEBUG
|
||||
if CURLDEBUG
|
||||
servers_SOURCES += $(MEMDEBUG)
|
||||
endif
|
||||
endif
|
||||
servers_LDADD = @CURL_NETWORK_AND_TIME_LIBS@
|
||||
servers_CFLAGS = $(AM_CFLAGS)
|
||||
CLEANFILES = $(BUNDLE_SRC)
|
||||
|
|
|
|||
|
|
@ -47,4 +47,4 @@ target_include_directories(tunits PRIVATE
|
|||
"${PROJECT_SOURCE_DIR}/tests/tunit"
|
||||
)
|
||||
set_property(TARGET tunits APPEND PROPERTY COMPILE_DEFINITIONS "${CURL_DEBUG_MACROS}" "CURL_NO_OLDIES" "CURL_DISABLE_DEPRECATION")
|
||||
set_target_properties(tunits PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}")
|
||||
set_target_properties(tunits PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF)
|
||||
|
|
|
|||
|
|
@ -47,4 +47,4 @@ target_include_directories(units PRIVATE
|
|||
)
|
||||
set_property(TARGET units APPEND PROPERTY COMPILE_DEFINITIONS "${CURL_DEBUG_MACROS}" "CURL_NO_OLDIES" "CURL_DISABLE_DEPRECATION")
|
||||
set_property(TARGET units APPEND PROPERTY COMPILE_DEFINITIONS "BUILDING_LIBCURL") # unit tests are small pretend-libcurl-programs
|
||||
set_target_properties(units PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}")
|
||||
set_target_properties(units PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue