diff --git a/packages/t/tree-sitter/port/xmake.lua b/packages/t/tree-sitter/port/xmake.lua new file mode 100644 index 000000000..da2fbc704 --- /dev/null +++ b/packages/t/tree-sitter/port/xmake.lua @@ -0,0 +1,8 @@ +add_rules("mode.debug", "mode.release") +target("tree-sitter") + set_kind("$(kind)") + add_files("lib/src/lib.c") + add_includedirs({ + "lib/src", + "lib/include"}) + add_headerfiles("lib/include/(**.h)") \ No newline at end of file diff --git a/packages/t/tree-sitter/xmake.lua b/packages/t/tree-sitter/xmake.lua new file mode 100644 index 000000000..cac580d1a --- /dev/null +++ b/packages/t/tree-sitter/xmake.lua @@ -0,0 +1,37 @@ +package("tree-sitter") + + set_homepage("https://tree-sitter.github.io/") + set_description("An incremental parsing system for programming tools") + + add_urls("https://github.com/tree-sitter/tree-sitter/archive/refs/tags/v$(version).zip") + + add_versions("0.21.0", "874794e6b3b985f7f9e87dfe29e4bfdbe5c0339e67740f35dfc4fa85804ba708") + + on_install(function(package) + os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua") + + 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:check_csnippets({ + test = [[ + #include + #include + void test() { + TSParser *parser = ts_parser_new(); + const char *source_code = "[1, null]"; + TSTree *tree = ts_parser_parse_string( + parser, + NULL, + source_code, + strlen(source_code) + ); + } + ]] + })) + end)