mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-12 00:10:04 -04:00
chore(makefile): apply fixes to original makefile
This commit is contained in:
parent
81f2a5d702
commit
5639b74db0
2 changed files with 48 additions and 10 deletions
|
|
@ -113,7 +113,7 @@ function M.select_compile_command(repo, cc, compile_location)
|
||||||
args = {
|
args = {
|
||||||
"--makefile=" .. utils.join_path(utils.get_package_path(), "scripts", "compile_parsers.makefile"),
|
"--makefile=" .. utils.join_path(utils.get_package_path(), "scripts", "compile_parsers.makefile"),
|
||||||
"CC=" .. cc,
|
"CC=" .. cc,
|
||||||
"CXX_STANDARD=" .. (repo.cxx_standard or 'c++14'),
|
"CXX_STANDARD=" .. (repo.cxx_standard or "c++14"),
|
||||||
},
|
},
|
||||||
cwd = compile_location,
|
cwd = compile_location,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,51 @@
|
||||||
CC?=cc
|
CFLAGS ?= -Os -std=c99 -fPIC
|
||||||
CXX_STANDARD?=c++14
|
CXXFLAGS ?= -Os -std=c++14 -fPIC
|
||||||
|
LDFLAGS ?=
|
||||||
|
SRC_DIR ?= ./src
|
||||||
|
DEST_DIR ?= ./dest
|
||||||
|
|
||||||
all: parser.so
|
ifeq ($(OS),Windows_NT)
|
||||||
|
SHELL := powershell.exe
|
||||||
|
.SHELLFLAGS := -NoProfile -command
|
||||||
|
CP := Copy-Item -Recurse -ErrorAction SilentlyContinue
|
||||||
|
MKDIR := New-Item -ItemType directory -ErrorAction SilentlyContinue
|
||||||
|
TARGET := parser.dll
|
||||||
|
rmf = Write-Output $(1) | foreach { if (Test-Path $$_) { Remove-Item -Force } }
|
||||||
|
else
|
||||||
|
CP := cp
|
||||||
|
MKDIR := mkdir -p
|
||||||
|
TARGET := parser.so
|
||||||
|
rmf = rm -rf $(1)
|
||||||
|
endif
|
||||||
|
|
||||||
parser.o: src/parser.c
|
ifneq ($(wildcard $(SRC_DIR)/*.cc),)
|
||||||
$(CC) -c src/parser.c -std=c99 -Os -fPIC -I./src
|
LDFLAGS += -lstdc++
|
||||||
|
endif
|
||||||
|
|
||||||
scanner.o: src/scanner.cc
|
OBJECTS := parser.o
|
||||||
$(CC) -c src/scanner.cc -std=$(CXX_STANDARD) -Os -fPIC -I./src
|
|
||||||
|
|
||||||
parser.so: parser.o scanner.o
|
ifneq ($(wildcard $(SRC_DIR)/scanner.*),)
|
||||||
$(CC) parser.o scanner.o -o parser.so -shared -lstdc++
|
OBJECTS += scanner.o
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
$(TARGET): $(OBJECTS)
|
||||||
|
$(CC) $(OBJECTS) -o $(TARGET) -shared $(LDFLAGS)
|
||||||
|
|
||||||
|
%.o: $(SRC_DIR)/%.c
|
||||||
|
$(CC) -c $(CFLAGS) -I$(SRC_DIR) -o $@ $<
|
||||||
|
|
||||||
|
%.o: $(SRC_DIR)/%.cc
|
||||||
|
$(CC) -c $(CXXFLAGS) -I$(SRC_DIR) -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(call rmf,$(TARGET) $(OBJECTS))
|
||||||
|
|
||||||
|
$(DEST_DIR):
|
||||||
|
@$(MKDIR) $(DEST_DIR)
|
||||||
|
|
||||||
|
install: $(TARGET) $(DEST_DIR)
|
||||||
|
$(CP) $(TARGET) $(DEST_DIR)/
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue