build: drop tool_hugehelp.c.cvs, tidy up macros, drop buildconf.bat

Rework the way `tool_hugehelp.c` is included in builds.

After this patch, with `./configure` and CMake `tool_hugehelp.c` is only
compiled when building with manuals enabled. With manuals disabled this
source file is not used anymore. The method is similar to how
8a3740bc8e implemented `tool_ca_embed.c`.
`./configure` always generates it as before, otherwise the build fails.

- winbuild: rework to not need `buildconf.bat`, but automatically use
  `tool_hugehelp.c` if present (e.g. when building from an official
  source tarball) and enable `USE_MANUAL` accordingly.

- `buildconf.bat`: after dropping `tool_hugehelp.c` generation, the only
  logic left was `cp Makefile.dist Makefile`. This allowed to launch
  winbuild builds via GNU Make in a Git repo. Drop this option together
  with the batch file.

- build `libcurltool` without `USE_MANUAL` macro to exclude the manual
  and the dependence on the generator commands. Drop relying on
  `UNITTESTS` for this purpose.
  Follow-up to 96843f4ef7 #16068

- `src/mkhelp.pl`: include `tool_hugehelp.h` before using `USE_MANUAL`
  to have it set in `config-*.h` builds with source tarballs created
  with manual but without zlib.

Closes #16081
This commit is contained in:
Viktor Szakats 2025-01-24 14:22:23 +01:00
parent 1a36923d73
commit 0035ff45c5
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
18 changed files with 32 additions and 374 deletions

View file

@ -26,9 +26,10 @@ add_definitions("-DBUILDING_CURL")
set(_curl_cfiles_gen "")
set(_curl_hfiles_gen "")
set(_curl_definitions "")
if(ENABLE_CURL_MANUAL AND HAVE_MANUAL_TOOLS)
add_definitions("-DUSE_MANUAL")
list(APPEND _curl_definitions "USE_MANUAL")
add_custom_command(
OUTPUT "tool_hugehelp.c"
COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_setup.h\"" > "tool_hugehelp.c"
@ -43,20 +44,13 @@ if(ENABLE_CURL_MANUAL AND HAVE_MANUAL_TOOLS)
"${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
"${CURL_ASCIIPAGE}"
VERBATIM)
list(APPEND _curl_cfiles_gen "tool_hugehelp.c")
list(APPEND _curl_hfiles_gen "tool_hugehelp.h")
else()
add_custom_command(
OUTPUT "tool_hugehelp.c"
COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_hugehelp.h\"" > "tool_hugehelp.c"
DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
VERBATIM)
list(APPEND _curl_cfiles_gen "tool_hugehelp.c")
list(APPEND _curl_hfiles_gen "tool_hugehelp.h")
endif()
if(CURL_CA_EMBED_SET)
if(PERL_FOUND)
add_definitions("-DCURL_CA_EMBED")
list(APPEND _curl_definitions "CURL_CA_EMBED")
add_custom_command(
OUTPUT "tool_ca_embed.c"
COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mk-file-embed.pl" --var curl_ca_embed
@ -93,6 +87,7 @@ add_executable(
${EXE_NAME}
${CURL_CFILES} ${_curl_cfiles_gen} ${CURLX_CFILES} ${CURL_HFILES} ${_curl_hfiles_gen}
)
target_compile_definitions(${EXE_NAME} PRIVATE ${_curl_definitions})
add_executable(
${PROJECT_NAME}::${EXE_NAME}

View file

@ -129,9 +129,11 @@ HUGEIT_0 = @echo " HUGE " $@;
HUGEIT_1 =
HUGEIT_ = $(HUGEIT_0)
curl_CPPFLAGS = $(AM_CPPFLAGS)
if USE_MANUAL
# Here are the stuff to create a built-in manual
AM_CPPFLAGS += -DUSE_MANUAL
curl_CPPFLAGS += -DUSE_MANUAL
$(ASCIIPAGE):
cd $(top_builddir)/docs && $(MAKE)
@ -167,7 +169,7 @@ CA_EMBED_CSOURCE = tool_ca_embed.c
curl_cfiles_gen += $(CA_EMBED_CSOURCE)
CLEANFILES += $(CA_EMBED_CSOURCE)
if CURL_CA_EMBED_SET
AM_CPPFLAGS += -DCURL_CA_EMBED
curl_CPPFLAGS += -DCURL_CA_EMBED
MK_FILE_EMBED = $(top_srcdir)/src/mk-file-embed.pl
$(CA_EMBED_CSOURCE): $(MK_FILE_EMBED) $(CURL_CA_EMBED)
$(PERL) $(MK_FILE_EMBED) --var curl_ca_embed < $(CURL_CA_EMBED) > $(CA_EMBED_CSOURCE)

View file

@ -43,8 +43,8 @@ print <<HEAD
/*
* NEVER EVER edit this manually, fix the mkhelp.pl script instead!
*/
#ifdef USE_MANUAL
#include "tool_hugehelp.h"
#ifdef USE_MANUAL
#include "tool_help.h"
HEAD

View file

@ -30,9 +30,7 @@
#include "tool_util.h"
#include "tool_version.h"
#include "tool_cb_prg.h"
#ifndef UNITTESTS
#include "tool_hugehelp.h"
#endif
#include "tool_getparam.h"
#include "terminal.h"
@ -286,7 +284,7 @@ void tool_help(char *category)
msnprintf(cmdbuf, sizeof(cmdbuf), "\n --no-%s", a->lname);
else
msnprintf(cmdbuf, sizeof(cmdbuf), "\n %s", category);
#ifndef UNITTESTS
#ifdef USE_MANUAL
if(a->cmd == C_XATTR)
/* this is the last option, which then ends when FILES starts */
showhelp("\nALL OPTIONS\n", cmdbuf, "\nFILES");

View file

@ -1,39 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "tool_setup.h"
#include "tool_hugehelp.h"
void hugehelp(void)
{
puts("built-in manual was disabled at build-time");
}
void showhelp(const char *trigger, const char *arg, const char *endarg)
{
(void)trigger;
(void)arg;
(void)endarg;
hugehelp();
}

View file

@ -25,13 +25,9 @@
***************************************************************************/
#include "tool_setup.h"
void showhelp(const char *trigger, const char *arg, const char *endarg);
#ifdef USE_MANUAL
void showhelp(const char *trigger, const char *arg, const char *endarg);
void hugehelp(void);
#else
/* do nothing if not there */
#define hugehelp()
#endif
#endif /* HEADER_CURL_TOOL_HUGEHELP_H */

View file

@ -94,9 +94,7 @@
#include "tool_xattr.h"
#include "tool_vms.h"
#include "tool_help.h"
#ifndef UNITTESTS
#include "tool_hugehelp.h"
#endif
#include "tool_progress.h"
#include "tool_ipfs.h"
#include "dynbuf.h"
@ -107,10 +105,6 @@ CURL_EXTERN CURLcode curl_easy_perform_ev(CURL *easy);
#include "memdebug.h" /* keep this as LAST include */
#ifdef UNITTESTS
#undef CURL_CA_EMBED
#endif
#ifdef CURL_CA_EMBED
#ifndef CURL_DECLARED_CURL_CA_EMBED
#define CURL_DECLARED_CURL_CA_EMBED
@ -3191,8 +3185,10 @@ CURLcode operate(struct GlobalConfig *global, int argc, argv_item_t argv[])
tool_help(global->help_category);
/* Check if we were asked for the manual */
else if(res == PARAM_MANUAL_REQUESTED) {
#ifndef UNITTESTS
#ifdef USE_MANUAL
hugehelp();
#else
puts("built-in manual was disabled at build-time");
#endif
}
/* Check if we were asked for the version information */