From a47effe083d70cae7f039ff207087447a7a82ee0 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sat, 5 Oct 2024 15:01:18 +0200 Subject: 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. --- Makefile | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'Makefile') 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 -- cgit v1.2.3