mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
Allow compilation via makefile
This commit is contained in:
parent
045cb86d44
commit
a37c97545f
4 changed files with 42 additions and 9 deletions
|
|
@ -325,15 +325,7 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync,
|
|||
})
|
||||
end
|
||||
vim.list_extend(command_list, {
|
||||
{
|
||||
cmd = cc,
|
||||
info = "Compiling...",
|
||||
err = "Error during compilation",
|
||||
opts = {
|
||||
args = vim.tbl_flatten(shell.select_compiler_args(repo, cc)),
|
||||
cwd = compile_location,
|
||||
},
|
||||
},
|
||||
shell.select_compile_command(repo, cc, compile_location),
|
||||
shell.select_mv_cmd("parser.so", parser_lib_name, compile_location),
|
||||
{
|
||||
cmd = function()
|
||||
|
|
|
|||
|
|
@ -896,6 +896,7 @@ list.norg = {
|
|||
url = "https://github.com/vhyrro/tree-sitter-norg",
|
||||
branch = "main",
|
||||
files = { "src/parser.c", "src/scanner.cc" },
|
||||
use_makefile = true,
|
||||
},
|
||||
maintainers = { "@JoeyGrajciar", "@vhyrro" },
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,6 +93,30 @@ function M.select_compiler_args(repo, compiler)
|
|||
end
|
||||
end
|
||||
|
||||
function M.select_compile_command(repo, cc, compile_location)
|
||||
if string.match(cc, "cl$") or string.match(cc, "cl.exe$") or not repo.use_makefile then
|
||||
return {
|
||||
cmd = cc,
|
||||
info = "Compiling...",
|
||||
err = "Error during compilation",
|
||||
opts = {
|
||||
args = vim.tbl_flatten(M.select_compiler_args(repo, cc)),
|
||||
cwd = compile_location,
|
||||
},
|
||||
}
|
||||
else
|
||||
return {
|
||||
cmd = "make",
|
||||
info = "Compiling...",
|
||||
err = "Error during compilation",
|
||||
opts = {
|
||||
args = { "--makefile=" .. utils.join_path(utils.get_package_path(), "scripts", "compile_parsers.makefile"), "CC=" .. cc },
|
||||
cwd = compile_location,
|
||||
},
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function M.select_install_rm_cmd(cache_folder, project_name)
|
||||
if fn.has "win32" == 1 then
|
||||
local dir = cache_folder .. "\\" .. project_name
|
||||
|
|
|
|||
16
scripts/compile_parsers.makefile
Normal file
16
scripts/compile_parsers.makefile
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#
|
||||
# compile_parsers.makefile
|
||||
# Stephan Seitz, 2021-09-09 21:36
|
||||
#
|
||||
CC?=cc
|
||||
|
||||
all: parser.so
|
||||
|
||||
parser.o: src/parser.c
|
||||
$(CC) -c src/parser.c -std=c99 -fPIC -I./src
|
||||
|
||||
scanner.o: src/scanner.cc
|
||||
$(CC) -c src/scanner.cc -std=c++17 -fPIC -I./src
|
||||
|
||||
parser.so: parser.o scanner.o
|
||||
$(CC) parser.o scanner.o -o parser.so -shared -Os -lstdc++
|
||||
Loading…
Add table
Add a link
Reference in a new issue