From 4348bc6ee530151090f79882daa3d5dfb9868aa2 Mon Sep 17 00:00:00 2001 From: star9029 Date: Sun, 7 May 2023 00:11:58 +0800 Subject: [PATCH] add cpp-peglib (#2059) * add cpp-peglib * use is_plat * remove flag * add flag * improve is_plat --- packages/c/cpp-peglib/xmake.lua | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 packages/c/cpp-peglib/xmake.lua diff --git a/packages/c/cpp-peglib/xmake.lua b/packages/c/cpp-peglib/xmake.lua new file mode 100644 index 000000000..1a21885b5 --- /dev/null +++ b/packages/c/cpp-peglib/xmake.lua @@ -0,0 +1,39 @@ +package("cpp-peglib") + + set_kind("library", {headeronly = true}) + set_homepage("https://yhirose.github.io/cpp-peglib") + set_description("A single file C++ header-only PEG (Parsing Expression Grammars) library") + set_license("MIT") + + set_urls("https://github.com/yhirose/cpp-peglib/archive/refs/tags/v$(version).tar.gz", + "https://github.com/yhirose/cpp-peglib.git") + + add_versions("1.8.3", "3de8aeb44a262f9c2478e2a7e7bc2bb9426a2bdd176cf0654ff5a3d291c77b73") + + on_install(function (package) + if package:is_plat("windows") then + package:add("cxxflags", "/Zc:__cplusplus") + end + os.cp("peglib.h", package:installdir("include")) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + #include + using namespace peg; + + void test() { + parser parser(R"( + # Grammar for Calculator... + Additive <- Multitive '+' Additive / Multitive + Multitive <- Primary '*' Multitive / Primary + Primary <- '(' Additive ')' / Number + Number <- < [0-9]+ > + %whitespace <- [ \t]* + )"); + + assert(static_cast(parser) == true); + } + ]]}, {configs = {languages = "c++17"}})) + end)