Skip to content

Commit

Permalink
tidy-html5: add package (#5524)
Browse files Browse the repository at this point in the history
* tidy-html5: add package

* fix android & wasm
  • Loading branch information
star-hengxing authored Oct 17, 2024
1 parent 3858a4b commit f27605d
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions packages/t/tidy-html5/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package("tidy-html5")
set_homepage("http://www.html-tidy.org")
set_description("The granddaddy of HTML tools, with support for modern standards")

add_urls("https://github.com/htacg/tidy-html5.git")

add_versions("5.9.20", "d08ddc2860aa95ba8e301343a30837f157977cba")

if is_plat("mingw") and is_subhost("msys") then
add_extsources("pacman::tidy")
elseif is_plat("linux") then
add_extsources("pacman::tidy")
end

add_deps("cmake")

on_install(function (package)
io.replace("CMakeLists.txt", "set(name tidy-static)",
"set(name tidy-static)\nif(NOT BUILD_SHARED_LIB)", {plain = true})
io.replace("CMakeLists.txt", "install( FILES ${HFILES} DESTINATION ${INCLUDE_INSTALL_DIR} )",
"endif()\ninstall( FILES ${HFILES} DESTINATION ${INCLUDE_INSTALL_DIR} )", {plain = true})

if package:is_plat("windows") and not package:config("shared") then
package:add("defines", "TIDY_STATIC")
end

local configs = {
"-DBUILD_TAB2SPACE=OFF",
"-DSUPPORT_CONSOLE_APP=OFF",
"-DCMAKE_POLICY_DEFAULT_CMP0057=NEW"
}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DENABLE_DEBUG_LOG=" .. (package:is_debug() and "ON" or "OFF"))
table.insert(configs, "-DENABLE_ALLOC_DEBUG=" .. (package:is_debug() and "ON" or "OFF"))
table.insert(configs, "-DENABLE_MEMORY_DEBUG=" .. (package:is_debug() and "ON" or "OFF"))
table.insert(configs, "-DBUILD_SHARED_LIB=" .. (package:config("shared") and "ON" or "OFF"))

local opt = {}
if package:is_plat("wasm") then
opt.cxflags = "-DHAS_FUTIME=0"
package:add("defines", "HAS_FUTIME=0")
end
import("package.tools.cmake").install(package, configs, opt)
end)

on_test(function (package)
assert(package:has_cfuncs("tidyCreate", {includes = "tidy.h"}))
end)

0 comments on commit f27605d

Please sign in to comment.