add library tree-sitter (#3394)
parent
4f9e4013d7
commit
f41dfce6ec
2 changed files with 45 additions and 0 deletions
@ -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…
Reference in new issue