aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-10-05 15:01:18 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-10-05 15:01:18 +0200
commita47effe083d70cae7f039ff207087447a7a82ee0 (patch)
treeceb05ac559b80e2d1a3f4ba3b7e21d163323e692
parent306a8cdf6fac4e3ec2bfeda6c9952f603a5577e1 (diff)
downloadcerrado-a47effe083d70cae7f039ff207087447a7a82ee0.tar.gz
cerrado-a47effe083d70cae7f039ff207087447a7a82ee0.tar.bz2
cerrado-a47effe083d70cae7f039ff207087447a7a82ee0.zip
ref: Refactor makefile
Now the makefile file takes into account the source folder for temaplating and scss, which means it will not regeneratem them every time you run "make" or "make run". This speeds up local development iterations.
-rw-r--r--Makefile41
1 files changed, 24 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index 068f872..17e424d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,16 @@
-SLUG ?= $(shell git rev-parse --short HEAD)
-LDFLAGS := "-X 'git.gabrielgio.me/cerrado/templates.Slug=.$(SLUG)' -s -w"
+GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
+LDFLAGS := "-X 'git.gabrielgio.me/cerrado/templates.Slug=.$(GIT_COMMIT)' -s -w"
-build: sass-slug tmpl
+TEMPLATES_DIR := templates
+TEMPLATES := $(wildcard $(TEMPLATES_DIR)/*.qtpl)
+GO_TEMPLATES_FILES := $(TEMPLATES:.qtpl=.qtpl.go)
+
+SASS_DIR := scss
+CSS_DIR := static
+OUTPUT_CSS := $(CSS_DIR)/main.$(GIT_COMMIT).css
+SASS_FILES := $(wildcard $(SASS_DIR)/*.scss)
+
+build: sass tmpl
go build \
-ldflags=$(LDFLAGS) \
-o bin/cerrado
@@ -12,20 +21,18 @@ run: sass tmpl
test:
go test -v --tags=unit ./...
-# this is meant for "prod" build
-sass-slug:
- mkdir -p static
- sassc \
- --style compressed \
- -I scss scss/main.scss static/main.$(SLUG).css
+sass: $(OUTPUT_CSS)
+
+$(OUTPUT_CSS): $(SASS_FILES)
+ @mkdir -p $(CSS_DIR)
+ sassc $(SASS_DIR)/main.scss $(OUTPUT_CSS)
+
+tmpl: $(GO_TEMPLATES_FILES)
-sass:
- mkdir -p static
- sassc \
- -I scss scss/main.scss static/main.css
+$(TEMPLATES_DIR)/%.qtpl.go: $(TEMPLATES_DIR)/%.qtpl
+ qtc $(TEMPLATES_DIR)/$*.qtpl
-tmpl:
- cd ./templates && \
- qtc *
+clean:
+ rm -f $(OUTPUT_CSS)
-.PHONY: sass
+.PHONY: sass tmpl