mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-19 03:40:04 -04:00
refactor(makefile): better powershell handling
- add missing $(MKDIR) variable - create a simple function to allow running `make clean` without an error if a file doesn't exist
This commit is contained in:
parent
c08821bb79
commit
24688a02bc
1 changed files with 9 additions and 9 deletions
|
|
@ -10,15 +10,16 @@ DEST_DIR ?= ./dest
|
||||||
|
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
SHELL := powershell.exe
|
SHELL := powershell.exe
|
||||||
.SHELLFLAGS := -NoProfile
|
.SHELLFLAGS := -NoProfile -command
|
||||||
RM := Remove-Item -Force
|
CP := Copy-Item -Recurse -ErrorAction SilentlyContinue
|
||||||
CP := Copy-Item -Recurse
|
MKDIR := New-Item -ItemType directory -ErrorAction SilentlyContinue
|
||||||
MKDIR := New-Item -ItemType directory
|
|
||||||
TARGET := parser.dll
|
TARGET := parser.dll
|
||||||
|
rmf = Write-Output $(1) | foreach { if (Test-Path $$_) { Remove-Item -Force } }
|
||||||
else
|
else
|
||||||
RM := rm -rf
|
|
||||||
CP := cp
|
CP := cp
|
||||||
|
MKDIR := mkdir -p
|
||||||
TARGET := parser.so
|
TARGET := parser.so
|
||||||
|
rmf = rm -rf $(1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(wildcard src/*.cc),)
|
ifneq ($(wildcard src/*.cc),)
|
||||||
|
|
@ -39,13 +40,12 @@ $(TARGET): $(OBJECTS)
|
||||||
$(CC) -c $(CXXFLAGS) -I$(SRC_DIR) -o $@ $<
|
$(CC) -c $(CXXFLAGS) -I$(SRC_DIR) -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(foreach file, $(OBJECTS), $(RM) $(file))
|
$(call rmf,$(TARGET) $(OBJECTS))
|
||||||
$(RM) $(TARGET)
|
|
||||||
|
|
||||||
$(DEST_DIR):
|
$(DEST_DIR):
|
||||||
test -d $(DEST_DIR) || $(MKDIR) $(DEST_DIR)
|
@$(MKDIR) $(DEST_DIR)
|
||||||
|
|
||||||
install: $(TARGET) $(DEST_DIR)
|
install: $(TARGET) $(DEST_DIR)
|
||||||
$(CP) $^ $(DEST_DIR)
|
$(CP) $(TARGET) $(DEST_DIR)/
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue