Skip to content

http: fail loudly when wxUSE_WEBREQUEST is not set - #481

Merged
mrjimenez merged 1 commit into
amule-project:masterfrom
got3nks:http-wxwebrequest-guard
Apr 26, 2026
Merged

http: fail loudly when wxUSE_WEBREQUEST is not set#481
mrjimenez merged 1 commit into
amule-project:masterfrom
got3nks:http-wxwebrequest-guard

Conversation

@got3nks

@got3nks got3nks commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes the diagnostic gap surfaced by #479.

CHTTPDownloadThread is built directly on top of wxWebRequest / wxWebSession / wxWebRequestEvent, all of which are gated on wxUSE_WEBREQUEST in wx/webrequest.h. wxUSE_WEBREQUEST is itself gated on a backend being present at wx-build time:

Platform Backend macro Required dep
Linux / *BSD wxUSE_WEBREQUEST_CURL libcurl
Windows wxUSE_WEBREQUEST_WINHTTP WinHTTP (always present)
macOS / iOS wxUSE_WEBREQUEST_URLSESSION NSURLSession (always present)

When wx is compiled without that backend — wxGTK on Gentoo with USE="-curl", a hand-rolled wx source build that didn't pick up libcurl, etc. — wxUSE_WEBREQUEST collapses to 0 and none of the classes we depend on are defined. The compile then fails with a wall of "wxWebRequest does not name a type", "wxWebSession has not been declared", "wxEVT_WEBREQUEST_STATE was not declared" diagnostics. The "did you mean wxWebRequestEvent?" hint that follows is misleading — that name is only visible because of our forward declaration further down the same header (HTTPDownload.h:36), not because wx provides it.

What changes

A check_cxx_source_compiles probe added to cmake/wx.cmake after find_package(wxWidgets ...), gated on wx_NEED_NET (the same flag that pulls in the net component for HTTPDownload). The probe includes <wx/webrequest.h> against the wx include dirs and definitions reported by FindwxWidgets, and fails the configure step with a clear FATAL_ERROR if wxUSE_WEBREQUEST is 0.

Two small details worth noting in the cmake change:

  • wxWidgets_DEFINITIONS is reported by FindwxWidgets as bare names (WXUSINGDLL, __WXGTK__, _FILE_OFFSET_BITS=64); we re-prefix each with -D before assigning to CMAKE_REQUIRED_DEFINITIONS. Without that, wx/defs.h trips its own "No Target! You should use wx-config program for compilation flags!" #error and the probe fails for the wrong reason.
  • CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY keeps the probe compile-only — we are inspecting a preprocessor symbol from wx/setup.h, not exercising any wx symbols, so we don't need CMAKE_REQUIRED_LIBRARIES wired up.

Why CI didn't see this

Distro CI (Ubuntu, Debian, Fedora) ships wxgtk with libcurl, so wxUSE_WEBREQUEST=1 is the default and the project's GitHub Actions runners never hit this path. Gentoo is unusual because users compile wx themselves with explicit USE flags.

Test plan

Verified both directions on the same Linux ARM64 box, by switching only the wx that find_package(wxWidgets) resolves:

  • Positive — Ubuntu distro wxgtk-3.2.8 (wxUSE_WEBREQUEST=1, wxUSE_WEBREQUEST_CURL=1):

    -- Performing Test amule_HAVE_WXWEBREQUEST
    -- Performing Test amule_HAVE_WXWEBREQUEST - Success
    -- Configuring done (4.4s)
    
  • Negative — hand-built wx-3.3.2 configured without libcurl (wxUSE_WEBREQUEST=0, wxUSE_WEBREQUEST_CURL=0, mirroring the Gentoo USE="-curl" shape):

    -- Performing Test amule_HAVE_WXWEBREQUEST
    -- Performing Test amule_HAVE_WXWEBREQUEST - Failed
    CMake Error at cmake/wx.cmake:122 (message):
      wxWidgets was found but wxUSE_WEBREQUEST is 0 in this build.
    
      aMule's HTTP download path requires wxWebRequest, which needs a backend
      at wx-build time:
    
        - Linux / *BSD: libcurl   (rebuild wx with --with-libcurl,
                                  or on Gentoo emerge net-libs/wxGTK
                                  with USE="curl")
        - Windows     : WinHTTP   (always present on supported releases)
        - macOS       : NSURLSession (always present)
    
      Then re-run cmake.
    -- Configuring incomplete, errors occurred!
    
  • macOS Cocoa GUI build (Homebrew wxwidgets-3.3.2, wxUSE_WEBREQUEST=1) — clean.

@got3nks
got3nks force-pushed the http-wxwebrequest-guard branch 2 times, most recently from d7f50aa to 68faca9 Compare April 26, 2026 13:27
CHTTPDownloadThread is built directly on top of wxWebRequest /
wxWebSession / wxWebRequestEvent, all of which are gated on
wxUSE_WEBREQUEST in wx/webrequest.h.  wxUSE_WEBREQUEST is itself
gated on a backend being present at wx-build time:

    Linux / *BSD : wxUSE_WEBREQUEST_CURL    (libcurl)
    Windows      : wxUSE_WEBREQUEST_WINHTTP
    macOS / iOS  : wxUSE_WEBREQUEST_URLSESSION (NSURLSession)

When wx was compiled without that backend - wxGTK on Gentoo with
USE="-curl", a hand-rolled wx source build that did not pick up
libcurl, etc. - wxUSE_WEBREQUEST collapses to 0 and none of the
classes we depend on are defined.  The compile then fails with a
cascade of "wxWebRequest does not name a type" / "wxWebSession has
not been declared" / "wxEVT_WEBREQUEST_STATE was not declared"
diagnostics.  The "did you mean wxWebRequestEvent?" hint that follows
is misleading - that name is only visible because of our forward
declaration further down the same header, not because wx provides it.

Add a single #if/#error at the top of HTTPDownload.h so the next
person to build aMule against a wx without wxWebRequest gets one
actionable line pointing at the missing backend, instead of having
to bisect the wall of cascading errors above.

Distro CI (Ubuntu, Debian, Fedora, etc.) ships wxgtk with libcurl,
which is why this hasn't surfaced on the project's GitHub Actions
runners.  Reported by @perfect7gentleman on Gentoo in
amule-project#479.
@got3nks
got3nks force-pushed the http-wxwebrequest-guard branch from 68faca9 to e1f4877 Compare April 26, 2026 13:28
@mrjimenez
mrjimenez merged commit 663e878 into amule-project:master Apr 26, 2026
9 checks passed
@got3nks
got3nks deleted the http-wxwebrequest-guard branch May 3, 2026 15:19
mrjimenez pushed a commit to mrjimenez/amule that referenced this pull request Jul 15, 2026
…headers are missing (amule-project#483)

FindReadline set HAVE_LIBREADLINE from a check_function_exists(readline)
that a bare runtime library -- or libedit's readline() compatibility
symbol -- also satisfies, while the header probes look only for
<readline.h> / <readline/readline.h>. On a box with the library but no
development headers (e.g. Alpine with libedit-dev but no readline-dev),
config.h carried HAVE_LIBREADLINE with no header macro, and
ExternalConnector.cpp -- which gates its rl_* block on HAVE_LIBREADLINE
alone -- failed deep in the build with "rl_compentry_func_t does not name
a type" and friends (amule-project#481).

Require a usable header too: when the library is found but neither header
is, stop at configure time with a message naming the missing package
(Alpine readline-dev / Debian libreadline-dev / Fedora readline-devel /
Homebrew readline) instead of a confusing mid-build error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants