Skip to content

Commit

Permalink
Ability to disable default implementations of HTTP and WebSocket clie…
Browse files Browse the repository at this point in the history
…nts (#1656)

* Allow HttpClient and Websocket implementations to be excluded from build

* Allow LLHTTP to be excluded from build

* Add descriptions of new options

* Rename options based on current convention of AX_ENABLE_XXX
  • Loading branch information
rh101 authored Feb 6, 2024
1 parent b4877b4 commit a1a4443
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CMakeOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- AX_ENABLE_MSEDGE_WEBVIEW2: whether enable msedge webview2, default: `TRUE`
- AX_ENABLE_MFMEDIA: whether enable microsoft media foundation for windows video player support, default: `TRUE`
- AX_ENABLE_VLC_MEDIA: whether enable libvlc media, default: `TRUE on Linux`, `FALSE on Windows`, not support other platforms
- AX_ENABLE_HTTP: whether enable http client, default: `TRUE`
- AX_ENABLE_WEBSOCKET: whether enable websockets client, default: `TRUE`
- AX_USE_XXX:
- AX_USE_ALSOFT: whether use openal-soft for all platforms
- Apple platform: Use openal-soft instead system deprecated: `OpenAL.framework`
Expand Down
69 changes: 55 additions & 14 deletions core/network/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,82 @@

option(AX_ENABLE_HTTP "Build HTTP client based on yasio" ON)
option(AX_ENABLE_WEBSOCKET "Build Websocket client based on yasio" ON)

if(EMSCRIPTEN)
set(_AX_NETWORK_HEADER
network/Downloader-wasm.h
network/IDownloaderImpl.h
network/Downloader.h
network/Uri.h
network/HttpClient.h
network/HttpResponse.h
network/HttpRequest.h
)

set(_AX_NETWORK_SRC
network/HttpClient-wasm.cpp
network/Downloader.cpp
network/Downloader-wasm.cpp
network/HttpCookie.cpp
network/Uri.cpp
network/WebSocket-wasm.cpp
)

if (AX_ENABLE_HTTP)
list(APPEND _AX_NETWORK_HEADER
network/HttpClient.h
network/HttpResponse.h
network/HttpRequest.h
network/HttpCookie.h
)

list(APPEND _AX_NETWORK_SRC
network/HttpClient-wasm.cpp
network/HttpCookie.cpp
)
endif()

if (AX_ENABLE_WEBSOCKET)
list(APPEND _AX_NETWORK_HEADER
network/WebSocket.h
)

list(APPEND _AX_NETWORK_SRC
network/WebSocket-wasm.cpp
)
endif()

else()
set(_AX_NETWORK_HEADER
network/Downloader-curl.h
network/IDownloaderImpl.h
network/Downloader.h
network/Uri.h
network/HttpClient.h
network/HttpResponse.h
network/HttpRequest.h
network/HttpCookie.h
network/WebSocket.h
)

set(_AX_NETWORK_SRC
network/HttpClient.cpp
network/Downloader.cpp
network/Downloader-curl.cpp
network/HttpCookie.cpp
network/Uri.cpp
network/WebSocket.cpp
)

if (AX_ENABLE_HTTP)
list(APPEND _AX_NETWORK_HEADER
network/HttpClient.h
network/HttpResponse.h
network/HttpRequest.h
network/HttpCookie.h
)

list(APPEND _AX_NETWORK_SRC
network/HttpClient.cpp
network/HttpCookie.cpp
)
endif()

if (AX_ENABLE_WEBSOCKET)
list(APPEND _AX_NETWORK_HEADER
network/WebSocket.h
)

list(APPEND _AX_NETWORK_SRC
network/WebSocket.cpp
)
endif()
endif()


5 changes: 4 additions & 1 deletion thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ option(AX_WITH_CARES "Build with internal c-ares support" OFF)
option(AX_WITH_YAML_CPP "Build with yaml-cpp support" OFF)
option(AX_WITH_KCP "Build with internal kcp support" OFF)
option(AX_WITH_OBOE "Build with oboe support" OFF)
option(AX_WITH_LLHTTP "Build with internal LLHTTP support" ON)

# by default, enable ios,macOS openal-soft framework for legal license LGPL-2.1
option(ALSOFT_OSX_FRAMEWORK "" ON)
Expand Down Expand Up @@ -458,7 +459,9 @@ if(AX_WITH_CARES)
ax_add_3rd(c-ares)
endif()

ax_add_3rd(llhttp)
if(AX_WITH_LLHTTP)
ax_add_3rd(llhttp)
endif()

# libvlc
if (AX_ENABLE_VLC_MEDIA AND (NOT _AX_HAVE_VLC))
Expand Down

0 comments on commit a1a4443

Please sign in to comment.