add library tree-sitter (#3394)

pull/3399/head
Yiheng Wu 9 months ago committed by GitHub
parent 4f9e4013d7
commit f41dfce6ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      packages/t/tree-sitter/port/xmake.lua
  2. 37
      packages/t/tree-sitter/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)")

@ -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 <string.h>
#include <tree_sitter/api.h>
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)
Loading…
Cancel
Save