vieter/Makefile

98 lines
1.9 KiB
Makefile
Raw Normal View History

# =====CONFIG=====
SRC_DIR := src
SOURCES != find '$(SRC_DIR)' -iname '*.v'
V_PATH ?= v
2022-04-29 22:56:29 +02:00
V := $(V_PATH) -showcc -gc boehm -d dynamic_boehm
2022-01-13 12:35:05 +01:00
all: vieter
2022-01-12 18:54:13 +01:00
2022-04-14 23:15:19 +02:00
2022-01-12 18:54:13 +01:00
# =====COMPILATION=====
2022-04-21 16:12:37 +02:00
# We force the boehm gc to be compiled dynamically because otherwise, our CI
# build breaks.
vieter: $(SOURCES)
2022-04-21 16:48:35 +02:00
$(V) -g -o vieter $(SRC_DIR)
2022-01-13 12:35:05 +01:00
# Debug build using gcc
# The debug build can't use the boehm garbage collector, as that is
# multi-threaded and causes issues when running vieter inside gdb.
2022-01-13 12:35:05 +01:00
.PHONY: debug
debug: dvieter
dvieter: $(SOURCES)
2022-04-21 09:58:54 +02:00
$(V_PATH) -showcc -keepc -cg -o dvieter $(SRC_DIR)
# Run the debug build inside gdb
.PHONY: gdb
gdb: dvieter
gdb --args ./dvieter -f vieter.toml server
2022-01-12 18:54:13 +01:00
2022-01-13 12:35:05 +01:00
# Optimised production build
2022-01-12 18:54:13 +01:00
.PHONY: prod
2022-01-13 12:35:05 +01:00
prod: pvieter
pvieter: $(SOURCES)
$(V) -o pvieter -prod $(SRC_DIR)
2022-01-12 18:54:13 +01:00
2022-01-27 21:47:25 +01:00
# Only generate C code
2022-01-12 21:50:17 +01:00
.PHONY: c
2022-04-14 23:15:19 +02:00
c: $(SOURCES)
2022-01-12 21:50:17 +01:00
$(V) -o vieter.c $(SRC_DIR)
2022-04-14 23:15:19 +02:00
2022-01-12 18:54:13 +01:00
# =====EXECUTION=====
# Run the server in the default 'data' directory
.PHONY: run
2022-01-13 12:35:05 +01:00
run: vieter
2022-04-14 23:15:19 +02:00
./vieter -f vieter.toml server
2022-01-12 21:22:23 +01:00
.PHONY: run-prod
run-prod: prod
./pvieter -f vieter.toml server
2022-04-14 23:15:19 +02:00
2022-01-12 18:54:13 +01:00
# =====OTHER=====
2022-01-13 14:33:06 +01:00
.PHONY: lint
lint:
$(V) fmt -verify $(SRC_DIR)
# Format the V codebase
.PHONY: fmt
fmt:
2022-01-13 14:33:06 +01:00
$(V) fmt -w $(SRC_DIR)
2022-01-09 23:02:55 +01:00
2022-01-14 21:02:34 +01:00
.PHONY: vet
vet:
$(V) vet -W $(SRC_DIR)
.PHONY: test
test:
2022-04-21 16:48:35 +02:00
$(V) test $(SRC_DIR)
# Build & patch the V compiler
.PHONY: v
v: v/v
v/v:
git clone --single-branch https://git.rustybever.be/Chewing_Bever/v v
make -C v
.PHONY: clean
clean:
rm -rf 'data' 'vieter' 'dvieter' 'pvieter' 'vieter.c' 'dvieterctl' 'vieterctl' 'pkg' 'src/vieter' *.pkg.tar.zst 'suvieter' 'afvieter' '$(SRC_DIR)/_docs'
.PHONY: docs
docs:
rm -rf '$(SRC_DIR)/_docs'
cd '$(SRC_DIR)' && v doc -all -f html -m -readme .
2022-04-14 23:15:19 +02:00
# =====EXPERIMENTAL=====
.PHONY: autofree
autofree: afvieter
afvieter: $(SOURCES)
$(V_PATH) -showcc -autofree -o afvieter $(SRC_DIR)
2022-04-21 09:58:54 +02:00
.PHONY: skip-unused
skip-unused: suvieter
suvieter: $(SOURCES)
$(V_PATH) -showcc -skip-unused -o suvieter $(SRC_DIR)