xmake.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package("cpp-peglib")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://yhirose.github.io/cpp-peglib")
  4. set_description("A single file C++ header-only PEG (Parsing Expression Grammars) library")
  5. set_license("MIT")
  6. set_urls("https://github.com/yhirose/cpp-peglib/archive/refs/tags/v$(version).tar.gz",
  7. "https://github.com/yhirose/cpp-peglib.git")
  8. add_versions("1.8.3", "3de8aeb44a262f9c2478e2a7e7bc2bb9426a2bdd176cf0654ff5a3d291c77b73")
  9. on_install(function (package)
  10. if package:is_plat("windows") then
  11. package:add("cxxflags", "/Zc:__cplusplus")
  12. end
  13. os.cp("peglib.h", package:installdir("include"))
  14. end)
  15. on_test(function (package)
  16. assert(package:check_cxxsnippets({test = [[
  17. #include <peglib.h>
  18. #include <assert.h>
  19. using namespace peg;
  20. void test() {
  21. parser parser(R"(
  22. # Grammar for Calculator...
  23. Additive <- Multitive '+' Additive / Multitive
  24. Multitive <- Primary '*' Multitive / Primary
  25. Primary <- '(' Additive ')' / Number
  26. Number <- < [0-9]+ >
  27. %whitespace <- [ \t]*
  28. )");
  29. assert(static_cast<bool>(parser) == true);
  30. }
  31. ]]}, {configs = {languages = "c++17"}}))
  32. end)