From 0f348266fe3ca84b74dceea0f9ae4616602b8fad Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 6 Feb 2023 00:09:10 +0800 Subject: [PATCH] add litehtml (#1789) * add litehtml * add gumbo * improve gumbo * fix gumbo for windows * fix gumbo for windows * fix litehtml --- packages/g/gumbo-parser/xmake.lua | 33 +++++++++++++++++++++++++++++++ packages/l/litehtml/xmake.lua | 31 +++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 packages/g/gumbo-parser/xmake.lua create mode 100644 packages/l/litehtml/xmake.lua diff --git a/packages/g/gumbo-parser/xmake.lua b/packages/g/gumbo-parser/xmake.lua new file mode 100644 index 000000000..a28668839 --- /dev/null +++ b/packages/g/gumbo-parser/xmake.lua @@ -0,0 +1,33 @@ +package("gumbo-parser") + set_homepage("https://github.com/google/gumbo-parser") + set_description("An HTML5 parsing library in pure C99") + set_license("Apache-2.0") + + add_urls("https://github.com/google/gumbo-parser/archive/refs/tags/$(version).tar.gz", + "https://github.com/google/gumbo-parser.git") + add_versions("v0.10.1", "28463053d44a5dfbc4b77bcf49c8cee119338ffa636cc17fc3378421d714efad") + + on_install(function (package) + io.writefile("xmake.lua", [[ + add_rules("mode.debug", "mode.release") + target("gumbo") + set_kind("$(kind)") + add_files("src/*.c") + add_headerfiles("src/*.h") + if is_plat("windows") then + add_includedirs("visualc/include") + if is_kind("shared") then + add_rules("utils.symbols.export_all", {export_classes = true}) + end + end + ]]) + local configs = {} + if package:config("shared") then + configs.kind = "shared" + end + import("package.tools.xmake").install(package, configs) + end) + + on_test(function (package) + assert(package:has_cfuncs("gumbo_parse_with_options", {includes = "gumbo.h"})) + end) diff --git a/packages/l/litehtml/xmake.lua b/packages/l/litehtml/xmake.lua new file mode 100644 index 000000000..ff36be9c0 --- /dev/null +++ b/packages/l/litehtml/xmake.lua @@ -0,0 +1,31 @@ +package("litehtml") + set_homepage("http://www.litehtml.com/") + set_description("Fast and lightweight HTML/CSS rendering engine") + + add_urls("https://github.com/litehtml/litehtml.git") + add_versions("2023.01.05", "1e803393bdc8e586e8eefd4c33973e04994bb288") + + add_deps("cmake", "gumbo-parser") + + on_install(function (package) + local configs = {"-DBUILD_TESTING=OFF", "-DEXTERNAL_GUMBO=ON"} + if package:is_plat("windows") and package:config("shared") then + table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON") + end + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) + table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + import("package.tools.cmake").install(package, configs, {packagedeps = "gumbo-parser"}) + os.cp("include/litehtml.h", package:installdir("include")) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + #include + using namespace litehtml; + void test() { + css_element_selector selector; + selector.parse(".class"); + } + ]]}, {configs = {languages = "c++11"}})) + end)