From 19bb26a789c24bed153c9575277b4d80b320cc59 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Mon, 15 Nov 2021 23:08:48 +0100 Subject: [PATCH 1/2] Add a makefile --- Makefile | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..c14dfc6e --- /dev/null +++ b/Makefile @@ -0,0 +1,118 @@ +# ----------------------- +# Compilation options +# ----------------------- + +RELEASE := 1 +STATIC := 0 + +DISABLE_LSQUIC := 0 +NO_DBG_SYMBOLS := 0 + + +FLAGS ?= + + +ifeq ($(RELEASE), 1) + FLAGS += --release +endif + +ifeq ($(STATIC), 1) + FLAGS += --static +endif + + +ifeq ($(NO_DBG_SYMBOLS), 1) + FLAGS += --no-debug +else + FLAGS += --debug +endif + +ifeq ($(DISABLE_LSQUIC), 1) + FLAGS += -Ddisable_lsquic +endif + + +# ----------------------- +# Main +# ----------------------- + +all: invidious + +get-libs: + shards install --production + +# TODO: add support for ARM64 via cross-compilation +invidious: get-libs + crystal build src/invidious.cr $(FLAGS) --progress --stats --error-trace + + +run: invidious + ./invidious + + +# ----------------------- +# Development +# ----------------------- + + +format: + crystal tool format + +test: + crystal spec + +verify: + crystal build src/invidious.cr --no-codegen --progress --stats --error-trace + + +# ----------------------- +# (Un)Install +# ----------------------- + +# TODO + + +# ----------------------- +# Cleaning +# ----------------------- + +clean: + rm invidious + +distclean: clean + rm -rf libs + + +# ----------------------- +# Help page +# ----------------------- + +help: + echo "Targets available in this Makefile:" + echo "" + echo "get-libs Fetch Crystal libraries" + echo "invidious Build Invidious" + echo "run Launch Invidious" + echo "" + echo "format Run the Crystal formatter" + echo "test Run tests" + echo "verify Just make sure that the code compiles, but without" + echo " generating any binaries. Useful to search for errors" + echo "" + echo "clean Remove build artifacts" + echo "distclean Remove build artifacts and libraries" + echo "" + echo "" + echo "Build options available for this Makefile:" + echo "" + echo "RELEASE Make a release build (Default: 1)" + echo "STATIC Link librariess tatically (Default: 1)" + echo "" + echo "DISABLE_LSQUIC Don't use lsquic (Default: 0)" + echo "NO_DBG_SYMBOLS Strip debug symbols (Default: 0)" + + + +# No targets generates an output named after themselves +.PHONY all get-libs build amd64 run +.PHONY format test verify clean distclean help From 6a204753c03ae4743d5355110c54ba42b2faee72 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Mon, 15 Nov 2021 23:36:52 +0100 Subject: [PATCH 2/2] Fix typo --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c14dfc6e..7271d9bd 100644 --- a/Makefile +++ b/Makefile @@ -114,5 +114,5 @@ help: # No targets generates an output named after themselves -.PHONY all get-libs build amd64 run -.PHONY format test verify clean distclean help +.PHONY: all get-libs build amd64 run +.PHONY: format test verify clean distclean help