58 lines
1.3 KiB
Plaintext
58 lines
1.3 KiB
Plaintext
|
|
.PHONY: all build release debug clean test coverage lint install uninstall
|
||
|
|
|
||
|
|
NIM := nim
|
||
|
|
NIM_FLAGS := --hints:off --warnings:off
|
||
|
|
SRC_DIR := src
|
||
|
|
BIN_DIR := bin
|
||
|
|
TEST_DIR := tests
|
||
|
|
BUILD_DIR := build
|
||
|
|
|
||
|
|
SOURCES := $(shell find $(SRC_DIR) -name '*.nim')
|
||
|
|
TESTS := $(shell find $(TEST_DIR) -name '*.nim')
|
||
|
|
OBJECTS := $(patsubst $(SRC_DIR)/%.nim,$(BUILD_DIR)/%.o,$(SOURCES))
|
||
|
|
|
||
|
|
BINARY := $(BIN_DIR)/nimcheck
|
||
|
|
|
||
|
|
all: build
|
||
|
|
|
||
|
|
$(BIN_DIR):
|
||
|
|
mkdir -p $(BIN_DIR)
|
||
|
|
|
||
|
|
$(BUILD_DIR):
|
||
|
|
mkdir -p $(BUILD_DIR)
|
||
|
|
|
||
|
|
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.nim | $(BUILD_DIR)
|
||
|
|
$(NIM) compile --compileOnly -d:release -o:$@ $<
|
||
|
|
|
||
|
|
$(BINARY): $(OBJECTS) | $(BIN_DIR)
|
||
|
|
$(NIM) compile -d:release --out:$(BINARY) $(SRC_DIR)/nimcheck.nim
|
||
|
|
|
||
|
|
build: $(BINARY)
|
||
|
|
|
||
|
|
release:
|
||
|
|
$(NIM) compile -d:release --opt:speed --passC:-flto --passL:-flto \
|
||
|
|
--out:$(BINARY) $(SRC_DIR)/nimcheck.nim
|
||
|
|
|
||
|
|
debug:
|
||
|
|
$(NIM) compile -d:debug --lineDir:on --stacktrace:on \
|
||
|
|
--out:$(BINARY) $(SRC_DIR)/nimcheck.nim
|
||
|
|
|
||
|
|
test: build
|
||
|
|
$(NIM) compile --run $(TEST_DIR)/test_all.nim
|
||
|
|
|
||
|
|
coverage:
|
||
|
|
$(NIM) compile --run -d:coverage $(TEST_DIR)/test_all.nim
|
||
|
|
|
||
|
|
lint:
|
||
|
|
$(NIM) check $(SRC_DIR)/nimcheck.nim
|
||
|
|
|
||
|
|
clean:
|
||
|
|
rm -rf $(BIN_DIR) $(BUILD_DIR)
|
||
|
|
find . -name 'nimcache' -type d -exec rm -rf {} + 2>/dev/null || true
|
||
|
|
|
||
|
|
install: release
|
||
|
|
install -m 755 $(BINARY) /usr/local/bin/nimcheck
|
||
|
|
|
||
|
|
uninstall:
|
||
|
|
rm -f /usr/local/bin/nimcheck
|