diff --git a/devel/0747.md b/devel/0747.md new file mode 100644 index 0000000000..e9258a733d --- /dev/null +++ b/devel/0747.md @@ -0,0 +1,11 @@ +# [0747] 添加选项排除 goldfish + +## What +在 options.lua 中添加了选项排除 goldfish 构建 + +## 如何测试 +``` +xmake f -m debug --goldfish=no +xmake b stem +``` +观察无 goldfish 构建产物 diff --git a/moebius/xmake.lua b/moebius/xmake.lua index 250741addc..e837c944aa 100644 --- a/moebius/xmake.lua +++ b/moebius/xmake.lua @@ -30,8 +30,6 @@ local moe_includedirs = { add_requires("liii-doctest", {system=false}) add_requires("nanobench", {system=false}) -add_requires("goldfish", {system=false}) - target("libmoebius") do set_kind ("static") @@ -43,7 +41,7 @@ target("libmoebius") do add_files(moe_files) add_deps("liblolly") - add_packages("goldfish") + add_deps("goldfish") add_headerfiles("Data/Convert/(*.hpp)") add_headerfiles("Data/History/(*.hpp)") diff --git a/xmake/goldfish.lua b/xmake/goldfish.lua index 8ef7b8abd0..b028eb3601 100644 --- a/xmake/goldfish.lua +++ b/xmake/goldfish.lua @@ -13,49 +13,19 @@ -- binary target 内联编译的那一份完全相同。不使用 set_sourcedir() 直接指向 -- 工作树(否则 package.tools.xmake 会把 port 出来的 xmake.lua 写进工作树, -- 污染源码目录),而是在 on_install 里把源码拷贝到包缓存目录后构建。 -local goldfish_src = "$(projectdir)/TeXmacs/plugins/goldfish/src" - -package("goldfish") - set_homepage("https://github.com/goldfishscheme/goldfish") - set_description("Goldfish Scheme: a Scheme interpreter intended as an extension language for other applications.") - - add_deps("liii-tbox") - - on_load(function (package) - package:addenv("PATH", "bin") - package:add("deps", "argh v1.3.2") - end) - - on_test(function (package) - assert(package:check_csnippets([[ - static s7_pointer old_add; /* the original "+" function for non-string cases */ - static s7_pointer old_string_append; /* same, for "string-append" */ - - static s7_pointer our_add(s7_scheme *sc, s7_pointer args) - { - /* this will replace the built-in "+" operator, extending it to include strings: - * (+ "hi" "ho") -> "hiho" and (+ 3 4) -> 7 - */ - if ((s7_is_pair(args)) && - (s7_is_string(s7_car(args)))) - return(s7_apply_function(sc, old_string_append, args)); - return(s7_apply_function(sc, old_add, args)); - } - ]], {includes = "s7.h"})) - end) -package_end() target("libgoldfish") do - set_kind("$(kind)") + set_kind("static") set_languages("c11") add_packages("liii-tbox") + add_packages("argh", {public = true}) add_defines("WITH_SYSTEM_EXTRAS=0") if not is_plat("wasm") then add_defines("HAVE_OVERFLOW_CHECKS=0") end add_defines("WITH_WARNINGS") add_defines("WITH_R7RS=1") - set_basename("goldfish") + set_basename("libgoldfish") add_files( "$(projectdir)/TeXmacs/plugins/goldfish/src/s7.c", "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_continuation.c", @@ -77,8 +47,7 @@ target("libgoldfish") do "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_liii_string.c", "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_liii_vector.c" ) - add_headerfiles("$(curdir)/s7.h") - add_includedirs(".", {public = true}) + add_headerfiles("$(projectdir)/TeXmacs/plugins/goldfish/src/s7.h") if is_plat("windows") then set_optimize("faster") add_cxxflags("/fp:precise") @@ -89,10 +58,9 @@ target("libgoldfish") do end target ("goldfish") do + set_kind("static") set_languages("c++17") add_deps("libgoldfish") - set_targetdir("$(projectdir)/TeXmacs/plugins/goldfish/bin/") - add_files ("$(projectdir)/TeXmacs/plugins/goldfish/src/goldfish.cpp") add_files({ "$(projectdir)/TeXmacs/plugins/goldfish/src/liii_base64.cpp", "$(projectdir)/TeXmacs/plugins/goldfish/src/liii_hashlib.cpp", @@ -102,27 +70,6 @@ target ("goldfish") do "$(projectdir)/TeXmacs/plugins/goldfish/src/liii_subprocess.cpp", "$(projectdir)/TeXmacs/plugins/goldfish/src/scheme_base.cpp", }) - add_files({ - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_continuation.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_ctables.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_dtoa.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_module.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_op_names.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_scheme_base.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_scheme_char.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_scheme_complex.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_scheme_format.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_scheme_inexact.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_scheme_predicate.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_scheme_symbol.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_scheme_write.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_liii_bitwise.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_liii_hash_table.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_liii_list.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_liii_string.c", - "$(projectdir)/TeXmacs/plugins/goldfish/src/s7_liii_vector.c", - }, {languages = "c11"}) add_files({ "$(projectdir)/3rdparty/json-schema-validator/src/smtp-address-validator.cpp", "$(projectdir)/3rdparty/json-schema-validator/src/json-schema-draft7.json.cpp", @@ -139,7 +86,7 @@ target ("goldfish") do "$(projectdir)/TeXmacs/plugins/goldfish/src", "$(projectdir)/3rdparty/nlohmann_json/include", "$(projectdir)/3rdparty/json-schema-validator/src", - }) + }, {public = true}) add_defines("WITH_SYSTEM_EXTRAS=0") if not is_plat("wasm") then @@ -158,7 +105,15 @@ target ("goldfish") do if not is_plat("wasm") then add_packages("cpr") end - add_packages("argh") - on_install(function (target) - end) + add_packages("argh", {public = true}) +end + +target ("goldfish-bin") do + set_kind("binary") + add_deps("goldfish") + set_basename("goldfish") + add_packages("liii-tbox") + add_packages("argh", {public = true}) + set_targetdir("$(projectdir)/TeXmacs/plugins/goldfish/bin/") + add_files ("$(projectdir)/TeXmacs/plugins/goldfish/src/goldfish.cpp") end diff --git a/xmake/options.lua b/xmake/options.lua index 31d9e65530..8b9237d487 100644 --- a/xmake/options.lua +++ b/xmake/options.lua @@ -29,6 +29,11 @@ option("pdfhummus") set_description("Enable PDFHummus plugin") option_end() +option("goldfish") + set_default(true) + set_description("Enable Goldfish plugin") +option_end() + option("mupdf") set_default(true) set_description("Enable MuPDF library") diff --git a/xmake/requires.lua b/xmake/requires.lua index 8923fe90da..e573cf614a 100644 --- a/xmake/requires.lua +++ b/xmake/requires.lua @@ -8,7 +8,6 @@ -- It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE -- in the root directory or . -add_requires("goldfish", {system=false}) add_requires("liii-tbox", {system=false}) if not is_plat("wasm") then add_requires("cpr", {system=false}) diff --git a/xmake/targets/libmogan.lua b/xmake/targets/libmogan.lua index 96840ae489..99c380088c 100644 --- a/xmake/targets/libmogan.lua +++ b/xmake/targets/libmogan.lua @@ -27,6 +27,7 @@ target("libmogan") do add_deps("libmoebius") add_deps("liblolly") + add_deps("goldfish") if has_config("qt_frontend") then add_deps("QWKCore", "QWKWidgets") add_rules("qt.static") @@ -85,7 +86,6 @@ target("libmogan") do add_packages("liii-pdfhummus") end add_packages("freetype") - add_packages("goldfish") add_packages("liii-tbox") if not is_plat("wasm") then add_packages("cpr") @@ -247,10 +247,7 @@ target("libmogan") do "$(projectdir)/src/Mogan/TemplateCenter", "$(projectdir)/src/Mogan/Telemetry", "$(projectdir)/TeXmacs/include", - "$(builddir)/glue", - "$(projectdir)/TeXmacs/plugins/goldfish/src/", - "$(projectdir)/3rdparty/nlohmann_json/include", - "$(projectdir)/3rdparty/json-schema-validator/src" + "$(builddir)/glue" }, {public = true}) add_files({ @@ -278,9 +275,7 @@ target("libmogan") do "$(projectdir)/src/Plugins/Tex/**.cpp", "$(projectdir)/src/Plugins/Xml/**.cpp", "$(projectdir)/src/Plugins/Html/**.cpp", - "$(projectdir)/src/Plugins/Updater/**.cpp", - "$(projectdir)/TeXmacs/plugins/goldfish/src/**.cpp", - "$(projectdir)/3rdparty/json-schema-validator/src/**.cpp"}) + "$(projectdir)/src/Plugins/Updater/**.cpp",}) if has_config("pdfhummus") then add_includedirs("$(projectdir)/src/Plugins/Pdf/**.hpp", {public=true}) @@ -298,7 +293,6 @@ target("libmogan") do add_files("$(projectdir)/src/Plugins/Qt/moganqml.qrc") else add_files("$(projectdir)/src/Plugins/ImGui/**.cpp") - remove_files("$(projectdir)/TeXmacs/plugins/goldfish/src/liii_http.cpp") end if is_plat("macosx") then diff --git a/xmake/targets/stem.lua b/xmake/targets/stem.lua index f88cf9059b..d6b2dead56 100644 --- a/xmake/targets/stem.lua +++ b/xmake/targets/stem.lua @@ -26,7 +26,6 @@ local stem_files = { } target("stem") do - add_deps("goldfish") if is_plat("windows") and is_mode("release") then add_deps("liii_windows_icon") end @@ -121,11 +120,14 @@ target("stem") do add_frameworks("QtQml", "QtQuick", "QtBodymovin") end - add_packages("goldfish") add_packages("mupdf") if not has_config("qt_frontend") and not is_plat("wasm") then -- WASM GLFW is in EMCC add_packages("glfw") end + if has_config("goldfish") then + add_deps("goldfish-bin") + end + add_deps("goldfish") add_deps("liblolly") add_deps("libmogan") add_deps("libmoebius") diff --git a/xmake/tests.lua b/xmake/tests.lua index 400588987d..3e544cb2dd 100644 --- a/xmake/tests.lua +++ b/xmake/tests.lua @@ -29,7 +29,9 @@ function add_target_cpp_test(filepath, dep1, dep2) if not is_plat("windows") then add_syslinks("pthread") end - add_packages("goldfish") + if has_config("goldfish") then + add_deps("goldfish") + end add_packages("liii-pdfhummus") add_includedirs({"$(builddir)", "tests/Base"}) @@ -78,7 +80,9 @@ function add_target_cpp_bench(filepath, dep) if not is_plat("windows") then add_syslinks("pthread") end - add_packages("goldfish") + if has_config("goldfish") then + add_deps("goldfish") + end add_packages("liii-pdfhummus") add_includedirs({"$(builddir)", "tests/Base"}) diff --git a/xmake/vars.lua b/xmake/vars.lua index 436a2f38ad..f90ae14cf2 100644 --- a/xmake/vars.lua +++ b/xmake/vars.lua @@ -117,6 +117,8 @@ libstem_headers = { "$(builddir)/glue", "$(projectdir)/TeXmacs/include", "$(projectdir)/TeXmacs/plugins/goldfish/src", + "$(projectdir)/3rdparty/nlohmann_json/include", + "$(projectdir)/3rdparty/json-schema-validator/src" } libstem_srcs = {