2022-01-12 18:18:23 +01:00
|
|
|
# =====CONFIG=====
|
2022-01-12 20:54:54 +01:00
|
|
|
SRC_DIR := src
|
|
|
|
SOURCES != find '$(SRC_DIR)' -iname '*.v'
|
|
|
|
|
2022-02-19 15:27:41 +01:00
|
|
|
V_PATH ?= v/v
|
2022-02-04 13:17:12 +01:00
|
|
|
V := $(V_PATH) -showcc -gc boehm
|
2022-01-09 21:45:48 +01:00
|
|
|
|
2022-01-13 12:35:05 +01:00
|
|
|
all: vieter
|
2022-01-12 18:54:13 +01:00
|
|
|
|
|
|
|
# =====COMPILATION=====
|
2022-01-13 12:35:05 +01:00
|
|
|
# Regular binary
|
2022-01-12 20:54:54 +01:00
|
|
|
vieter: $(SOURCES)
|
2022-01-13 12:35:05 +01:00
|
|
|
$(V) -g -o vieter $(SRC_DIR)
|
|
|
|
|
|
|
|
# Debug build using gcc
|
2022-02-22 08:14:20 +01:00
|
|
|
# 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-02-21 22:22:36 +01:00
|
|
|
$(V_PATH) -showcc -keepc -cg -o dvieter $(SRC_DIR)
|
|
|
|
|
2022-02-22 08:14:20 +01:00
|
|
|
# Run the debug build inside gdb
|
2022-02-21 22:22:36 +01:00
|
|
|
.PHONY: gdb
|
|
|
|
gdb: dvieter
|
|
|
|
VIETER_API_KEY=test \
|
|
|
|
VIETER_DOWNLOAD_DIR=data/downloads \
|
|
|
|
VIETER_REPO_DIR=data/repo \
|
|
|
|
VIETER_PKG_DIR=data/pkgs \
|
|
|
|
VIETER_LOG_LEVEL=DEBUG \
|
|
|
|
VIETER_REPOS_FILE=data/repos.json \
|
|
|
|
gdb --args ./dvieter
|
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
|
|
|
|
c:
|
|
|
|
$(V) -o vieter.c $(SRC_DIR)
|
|
|
|
|
2022-02-22 18:04:54 +01:00
|
|
|
# Build the CLI tool
|
|
|
|
.PHONY: cli
|
|
|
|
cli: dvieterctl
|
|
|
|
dvieterctl: cli.v
|
2022-02-22 20:46:28 +01:00
|
|
|
$(V_PATH) -showcc -g -o dvieterctl cli.v
|
2022-02-22 18:04:54 +01:00
|
|
|
|
|
|
|
.PHONY: cli-prod
|
|
|
|
cli-prod: vieterctl
|
|
|
|
vieterctl: cli.v
|
|
|
|
cli-prod:
|
|
|
|
$(V_PATH) -showcc -o vieterctl -prod cli.v
|
2022-01-12 18:54:13 +01:00
|
|
|
|
|
|
|
# =====EXECUTION=====
|
2022-01-12 18:18:23 +01:00
|
|
|
# Run the server in the default 'data' directory
|
|
|
|
.PHONY: run
|
2022-01-13 12:35:05 +01:00
|
|
|
run: vieter
|
2022-02-21 20:40:13 +01:00
|
|
|
VIETER_API_KEY=test \
|
|
|
|
VIETER_DOWNLOAD_DIR=data/downloads \
|
|
|
|
VIETER_REPO_DIR=data/repo \
|
|
|
|
VIETER_PKG_DIR=data/pkgs \
|
|
|
|
VIETER_LOG_LEVEL=DEBUG \
|
2022-02-21 22:22:36 +01:00
|
|
|
VIETER_REPOS_FILE=data/repos.json \
|
2022-02-21 20:40:13 +01:00
|
|
|
./vieter server
|
2022-01-11 18:19:41 +01:00
|
|
|
|
2022-01-12 21:22:23 +01:00
|
|
|
.PHONY: run-prod
|
|
|
|
run-prod: prod
|
2022-02-21 20:40:13 +01:00
|
|
|
VIETER_API_KEY=test \
|
|
|
|
VIETER_DOWNLOAD_DIR=data/downloads \
|
|
|
|
VIETER_REPO_DIR=data/repo \
|
|
|
|
VIETER_PKG_DIR=data/pkgs \
|
|
|
|
VIETER_LOG_LEVEL=DEBUG \
|
|
|
|
./pvieter server
|
2022-01-09 09:29:11 +01: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)
|
|
|
|
|
2022-01-12 18:18:23 +01:00
|
|
|
# Format the V codebase
|
2022-01-09 09:29:11 +01:00
|
|
|
.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)
|
|
|
|
|
2022-01-27 19:18:11 +01:00
|
|
|
# Build & patch the V compiler
|
|
|
|
.PHONY: v
|
2022-02-19 15:27:41 +01:00
|
|
|
v: v/v
|
|
|
|
v/v:
|
|
|
|
git clone --single-branch --branch patches https://git.rustybever.be/Chewing_Bever/vieter-v v
|
|
|
|
make -C v
|
2022-01-12 18:18:23 +01:00
|
|
|
|
|
|
|
clean:
|
2022-02-22 20:46:28 +01:00
|
|
|
rm -rf 'data' 'vieter' 'dvieter' 'pvieter' 'vieter.c' 'dvieterctl' 'vieterctl'
|