xmake.lua 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. package("tinyxml")
  2. set_homepage("https://sourceforge.net/projects/tinyxml/")
  3. set_description("TinyXML is a simple, small, minimal, C++ XML parser that can be easily integrating into other programs.")
  4. set_license("zlib")
  5. add_urls("https://sourceforge.net/projects/tinyxml/files/tinyxml/$(version).zip", {version = function (version) return version .. "/tinyxml_" .. version:gsub("%.", "_") end})
  6. add_versions("2.6.2", "ac6bb9501c6f50cc922d22f26b02fab168db47521be5e845b83d3451a3e1d512")
  7. add_configs("stl", {description = "Enable STL support.", default = true, type = "boolean"})
  8. on_install(function (package)
  9. if package:config("stl") then
  10. io.replace("tinyxml.h", "#define TINYXML_INCLUDED", "#define TINYXML_INCLUDED\n#define TIXML_USE_STL", {plain = true})
  11. end
  12. io.writefile("xmake.lua", [[
  13. add_rules("mode.debug", "mode.release")
  14. target("tinyxml")
  15. set_kind("$(kind)")
  16. add_files("tinyxml.cpp", "tinystr.cpp", "tinyxmlerror.cpp", "tinyxmlparser.cpp")
  17. add_headerfiles("tinyxml.h", "tinystr.h")
  18. ]])
  19. local configs = {}
  20. if not package:is_plat("windows") and package:config("shared") then
  21. configs.kind = "shared"
  22. elseif package:is_plat("linux") and package:config("pic") ~= false then
  23. configs.cxflags = "-fPIC"
  24. end
  25. import("package.tools.xmake").install(package, configs)
  26. end)
  27. on_test(function (package)
  28. assert(package:has_cxxtypes("TiXmlDocument", {includes = "tinyxml.h"}))
  29. end)