Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions devel/0086.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# [0086] 添加无 http 模块的编译选项并排除 CPR 依赖
## What
1. 添加了宏 `GOLDFISH_ENABLE_HTTP` 用于条件编译 HTTP 模块
2. 撤销了对 cpr, libcurl 的 xmake.lua 的更改
3. 在无 HTTP 模块的条件下,排除 cpr 依赖

## Why?
1. 目前 goldfish 缺少 http 模块的编译选项,因此添加了相关的变量以及条件
2. cpr、libcurl 不支持 WASM,因此不被 WASM 构建需要,应当被 WASM 排除
4 changes: 4 additions & 0 deletions src/goldfish.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ static string find_goldfish_library ();
static vector<string> find_function_libraries_in_load_path (s7_scheme* sc, const string& function_name);

void glue_njson (s7_scheme* sc);
#ifdef GOLDFISH_ENABLE_HTTP
void glue_http (s7_scheme* sc);
void glue_http_async (s7_scheme* sc);
#endif
void glue_liii_base64 (s7_scheme* sc);
void glue_scheme_base (s7_scheme* sc);
void glue_liii_hashlib (s7_scheme* sc);
Expand Down Expand Up @@ -704,8 +706,10 @@ glue_for_community_edition (s7_scheme* sc) {
glue_liii_base64 (sc);
glue_scheme_base (sc);
glue_njson (sc);
#ifdef GOLDFISH_ENABLE_HTTP
glue_http (sc);
glue_http_async (sc);
#endif
}

static void
Expand Down
11 changes: 8 additions & 3 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ option("http")
set_values(false, true)
option_end()

if has_config("http") then
if has_config("http") and not is_plat("wasm") then
add_requires("cpr")
end

Expand Down Expand Up @@ -105,7 +105,10 @@ target ("goldfish") do
add_files ("src/goldfish.cpp")
add_files ("src/liii_subprocess.cpp")
add_files ("src/liii_njson.cpp")
add_files ("src/liii_http.cpp")
if has_config("http") and not is_plat("wasm") then
add_files ("src/liii_http.cpp")
add_defines("GOLDFISH_ENABLE_HTTP")
end
add_files ("src/liii_os.cpp")
add_files ("src/liii_path.cpp")
add_files ("src/liii_hashlib.cpp")
Expand Down Expand Up @@ -134,7 +137,9 @@ target ("goldfish") do
add_packages("argh")
add_packages("nlohmann_json")
add_packages("json_schema_validator")
add_packages("cpr")
if has_config("http") and not is_plat("wasm") then
add_packages("cpr")
end

-- S7 configuration from original 3rdparty/s7/xmake.lua
add_defines("WITH_SYSTEM_EXTRAS=0")
Expand Down
2 changes: 1 addition & 1 deletion xmake/packages/c/cpr/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package("cpr")
end
end)

on_install("linux", "macosx", "windows", "mingw@windows", "wasm", function (package)
on_install("linux", "macosx", "windows", "mingw@windows", function (package)
local configs = {"-DCPR_BUILD_TESTS=OFF",
"-DCPR_FORCE_USE_SYSTEM_CURL=ON",
"-DCPR_USE_SYSTEM_CURL=ON"}
Expand Down
2 changes: 1 addition & 1 deletion xmake/packages/l/libcurl/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ package("libcurl")
end
end)

on_install("windows", "mingw", "linux", "macosx", "iphoneos", "cross", "android", "wasm", function (package)
on_install("windows", "mingw", "linux", "macosx", "iphoneos", "cross", "android", function (package)
local version = package:version()

local configs = {"-DBUILD_TESTING=OFF", "-DENABLE_MANUAL=OFF", "-DENABLE_CURL_MANUAL=OFF"}
Expand Down
Loading