templates: add Makefile

This commit is contained in:
Adhityaa 2018-04-28 00:40:52 +05:30
parent 5652afa6d5
commit e0b78d912c
2 changed files with 49 additions and 4 deletions

View File

@ -12,9 +12,13 @@ API_BUILD_DIR = api
API_DEVEL_BUILD_DIR = $(API_BUILD_DIR)/$(DEVEL_BUILD_DIR) API_DEVEL_BUILD_DIR = $(API_BUILD_DIR)/$(DEVEL_BUILD_DIR)
API_PROD_BUILD_DIR = $(API_BUILD_DIR)/$(PROD_BUILD_DIR) API_PROD_BUILD_DIR = $(API_BUILD_DIR)/$(PROD_BUILD_DIR)
devel: frontend api devel-copy TMPL_BUILD_DIR = templates
TMPL_DEVEL_BUILD_DIR = $(TMPL_BUILD_DIR)/$(DEVEL_BUILD_DIR)
TMPL_PROD_BUILD_DIR = $(TMPL_BUILD_DIR)/$(PROD_BUILD_DIR)
prod: frontend api prod-copy devel: frontend api templates devel-copy
prod: frontend api templates prod-copy
# TODO: This can probably be written better: instead of explicitly defining # TODO: This can probably be written better: instead of explicitly defining
# each target subdirectory, define them at the top and automatically do stuff. # each target subdirectory, define them at the top and automatically do stuff.
@ -27,9 +31,13 @@ frontend:
api: api:
cd api && $(MAKE) $(MAKECMDGOALS) cd api && $(MAKE) $(MAKECMDGOALS)
devel-copy: devel-copy-frontend devel-copy-api .PHONY: templates
templates:
cd templates && $(MAKE) $(MAKECDMGOALS)
prod-copy: prod-copy-frontend prod-copy-api devel-copy: devel-copy-frontend devel-copy-api devel-copy-templates
prod-copy: prod-copy-frontend prod-copy-api prod-copy-templates
devel-copy-frontend: devel-copy-frontend:
cp -r $(FRONTEND_DEVEL_BUILD_DIR)/* $(DEVEL_BUILD_DIR) cp -r $(FRONTEND_DEVEL_BUILD_DIR)/* $(DEVEL_BUILD_DIR)
@ -37,12 +45,18 @@ devel-copy-frontend:
devel-copy-api: devel-copy-api:
cp -r $(API_DEVEL_BUILD_DIR)/* $(DEVEL_BUILD_DIR) cp -r $(API_DEVEL_BUILD_DIR)/* $(DEVEL_BUILD_DIR)
devel-copy-templates:
cp -r $(TMPL_DEVEL_BUILD_DIR)/* $(DEVEL_BUILD_DIR)
prod-copy-frontend: prod-copy-frontend:
cp -r $(FRONTEND_PROD_BUILD_DIR)/* $(PROD_BUILD_DIR) cp -r $(FRONTEND_PROD_BUILD_DIR)/* $(PROD_BUILD_DIR)
prod-copy-api: prod-copy-api:
cp -r $(API_PROD_BUILD_DIR)/* $(PROD_BUILD_DIR) cp -r $(API_PROD_BUILD_DIR)/* $(PROD_BUILD_DIR)
prod-copy-templates:
cp -r $(TMPL_PROD_BUILD_DIR)/* $(PROD_BUILD_DIR)
clean: clean-root clean-frontend clean-api clean: clean-root clean-frontend clean-api
clean-root: clean-root:

31
templates/Makefile Normal file
View File

@ -0,0 +1,31 @@
SHELL = bash
BUILD_DIR = build
DEVEL_BUILD_DIR = $(BUILD_DIR)/devel
PROD_BUILD_DIR = $(BUILD_DIR)/prod
TMPL_SRC_DIR = .
TMPL_SRC_FILES = $(wildcard $(TMPL_SRC_DIR)/*.tmpl)
TMPL_DEVEL_BUILD_DIR = $(DEVEL_BUILD_DIR)
TMPL_DEVEL_BUILD_FILES = $(patsubst $(TMPL_SRC_DIR)/%, $(TMPL_DEVEL_BUILD_DIR)/%, $(TMPL_SRC_FILES))
TMPL_PROD_BUILD_DIR = $(PROD_BUILD_DIR)
TMPL_PROD_BUILD_FILES = $(patsubst $(TMPL_SRC_DIR)/%, $(TMPL_PROD_BUILD_DIR)/%, $(TMPL_SRC_FILES))
devel: devel-templates
prod: prod-templates
clean:
rm -rf $(BUILD_DIR)
devel-templates: $(TMPL_DEVEL_BUILD_FILES)
$(TMPL_DEVEL_BUILD_FILES): $(TMPL_DEVEL_BUILD_DIR)/%.tmpl: $(TMPL_SRC_DIR)/%.tmpl
cp $^ $@;
prod-templates: $(TMPL_PROD_BUILD_FILES)
$(TMPL_PROD_BUILD_FILES): $(TMPL_PROD_BUILD_DIR)/%.tmpl: $(TMPL_SRC_DIR)/%.tmpl
cp $^ $@;
$(shell mkdir -p $(TMPL_DEVEL_BUILD_DIR) $(TMPL_PROD_BUILD_DIR))