diff options
| author | MatthieuCoder <matthieu@matthieu-dev.xyz> | 2023-01-16 15:43:10 +0400 |
|---|---|---|
| committer | MatthieuCoder <matthieu@matthieu-dev.xyz> | 2023-01-16 15:43:10 +0400 |
| commit | 0f90d0f3d30a728457e6bc5c4d1d933a8014e099 (patch) | |
| tree | b1468081a32546e8d01fba622f978cdd326cf6fd /Makefile | |
| parent | 277f38bbe89e4db57b73a4e28bf1be2f5c50ce27 (diff) | |
new build system
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 68 |
1 files changed, 37 insertions, 31 deletions
@@ -1,37 +1,43 @@ -# Build nova all-in-one bin -all: - # Creates bin folder for artifacts - @mkdir -p build/bin - @mkdir -p build/lib - - @echo "Using cc, go, rust and ld versions" - cc -v - go version - rustc --version - ld -v - - # Builds rust - @echo "Building rust project" - cargo build --release - @cp target/release/liball_in_one.a build/lib/ - @cp target/release/cache build/bin/ - @cp target/release/gateway build/bin/ - @cp target/release/ratelimit build/bin/ - @cp target/release/rest build/bin/ - @cp target/release/webhook build/bin/ - - # Builds go +EXTENSION := +ifeq ($(OS),Windows_NT) + EXTENSION += .exe +endif +dir_guard=@mkdir -p $(@D) +PROJECTS = $(shell find exes/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n') +BINS=$(PROJECTS:%=build/bin/%$(EXTENSION)) + +# Static libraries +target/release/lib%.a: + cargo build --release -p $* + +# Executables +target/release/%$(EXTENSION): + cargo build --release -p $* + +# Copy static libraries +build/lib/%: target/release/% + $(dir_guard) + cp target/release/$* build/lib + +# Copy executables +build/bin/%$(EXTENSION): target/release/%$(EXTENSION) + $(dir_guard) + cp target/release/$*$(EXTENSION) build/lib/ + +# All in one binary +build/bin/nova$(EXTENSION): build/lib/liball_in_one.a + $(dir_guard) go build -a -ldflags '-s' -o build/bin/nova cmd/nova/nova.go -docker-images: - docker-compose build +all: $(BINS) build/bin/nova$(EXTENSION) -docker-push: - docker-compose push +clean: + rm -rf build + rm -rf $(PROJECTS:%=target/release/%$(EXTENSION)) + rm -rf target/release/liball_in_one.a -rust-test: +test: cargo test + go test -test: rust-test - -.PHONY: all docker-images docker-push test rust-test +.PHONY: clean all test |
