diff --git a/devel/0086.md b/devel/0086.md new file mode 100644 index 000000000..269260679 --- /dev/null +++ b/devel/0086.md @@ -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 排除 diff --git a/src/goldfish.hpp b/src/goldfish.hpp index e41ec51dd..c9eaff407 100644 --- a/src/goldfish.hpp +++ b/src/goldfish.hpp @@ -106,8 +106,10 @@ static string find_goldfish_library (); static vector 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); @@ -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 diff --git a/xmake.lua b/xmake.lua index a60fbffb6..42f763308 100644 --- a/xmake.lua +++ b/xmake.lua @@ -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 @@ -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") @@ -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") diff --git a/xmake/packages/c/cpr/xmake.lua b/xmake/packages/c/cpr/xmake.lua index dadd085f7..9ca1bddab 100644 --- a/xmake/packages/c/cpr/xmake.lua +++ b/xmake/packages/c/cpr/xmake.lua @@ -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"} diff --git a/xmake/packages/l/libcurl/xmake.lua b/xmake/packages/l/libcurl/xmake.lua index 6dbc3c384..7862cd968 100644 --- a/xmake/packages/l/libcurl/xmake.lua +++ b/xmake/packages/l/libcurl/xmake.lua @@ -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"}