From cf78ae9d84685e1193a1a1e91b536bef5e383940 Mon Sep 17 00:00:00 2001 From: Tom Gallacher Date: Mon, 24 Oct 2016 15:52:46 +0100 Subject: [PATCH] Cleaning up Makefiles --- Makefile | 45 +++++++++++++------------------------ backend/Makefile | 26 ++++++++++++++++++++- cloudapi-graphql/Dockerfile | 3 ++- cloudapi-graphql/Makefile | 16 +++++++++++++ frontend/Makefile | 20 +++++++++++++++++ tools/node-install.mk | 7 ------ ui/Makefile | 12 ++++++++++ 7 files changed, 91 insertions(+), 38 deletions(-) delete mode 100644 tools/node-install.mk diff --git a/Makefile b/Makefile index 43aa8075..e53a01b1 100644 --- a/Makefile +++ b/Makefile @@ -2,36 +2,23 @@ check: @./bin/setup -.PHONY: test-cloudapi-graphql -test-cloudapi-graphql: - $(MAKE) -C cloudapi-graphql test +SUBDIRS := $(shell find -maxdepth 2 -mindepth 2 -name 'Makefile' -printf '%h/.\n') +TARGETS := clean install test # whatever else, but must not contain '/' -.PHONY: test-frontend -test-frontend: - $(MAKE) -C frontend test +# foo/.all bar/.all foo/.clean bar/.clean +SUBDIRS_TARGETS := \ + $(foreach t,$(TARGETS),$(addsuffix $t,$(SUBDIRS))) -.PHONY: test-ui -test-ui: - $(MAKE) -C ui test +.PHONY: $(TARGETS) $(SUBDIRS_TARGETS) -.PHONY: test -test: test-cloudapi-graphql test-frontend test-ui +# static pattern rule, expands into: +# all clean: %: foo/.% bar/.% +$(TARGETS): %: $(addsuffix %,$(SUBDIRS)) + @echo 'Done "$*" target' -.PHONY: install-cloudapi-graphql -install-cloudapi-graphql: - $(MAKE) -C cloudapi-graphql install - -.PHONY: install-frontend -install-frontend: - $(MAKE) -C frontend install - -.PHONY: install-ui -install-ui: - $(MAKE) -C ui install - -.PHONY: install-backend -install-backend: - $(MAKE) -C backend install - -.PHONY: install -install: install-cloudapi-graphql install-frontend install-backend install-ui +# here, for foo/.all: +# $(@D) is foo +# $(@F) is .all, with leading period +# $(@F:.%=%) is just all +$(SUBDIRS_TARGETS): + $(MAKE) -C $(@D) $(@F:.%=%) diff --git a/backend/Makefile b/backend/Makefile index f525884d..6ceee709 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -1,5 +1,29 @@ include ../tools/node-install.mk +FRONTEND = "../frontend" + +.PHONY: install +install: + yarn install + +.PHONY: install-production +install-production: + yarn install --production --pure-lockfile + +.PHONY: clean +clean: + @rm -rf node_modules + .PHONY: test test: - ./node_modules/.bin/ava + @echo "No tests for backend" + +.PHONY: app-install +app-install: + $(MAKE) -C $(FRONTEND) copy + +install: app-install + +.PHONY: start +start: + npm run start diff --git a/cloudapi-graphql/Dockerfile b/cloudapi-graphql/Dockerfile index 6d1c45b3..616f423c 100644 --- a/cloudapi-graphql/Dockerfile +++ b/cloudapi-graphql/Dockerfile @@ -1 +1,2 @@ -FROM quay.io/yldio/alpine-node-containerpilot:latest +# FROM quay.io/yldio/alpine-node-containerpilot:latest +FROM 7510c64b7b41 diff --git a/cloudapi-graphql/Makefile b/cloudapi-graphql/Makefile index f525884d..709b2cae 100644 --- a/cloudapi-graphql/Makefile +++ b/cloudapi-graphql/Makefile @@ -1,5 +1,21 @@ include ../tools/node-install.mk +.PHONY: install +install: + yarn install + +.PHONY: install-production +install-production: + yarn install --production --pure-lockfile + +.PHONY: clean +clean: + @rm -rf node_modules + .PHONY: test test: ./node_modules/.bin/ava + +.PHONY: start +start: + npm run start diff --git a/frontend/Makefile b/frontend/Makefile index f2765010..bff4a3e2 100644 --- a/frontend/Makefile +++ b/frontend/Makefile @@ -1,5 +1,19 @@ include ../tools/node-install.mk +BACKEND = "../backend/static" + +.PHONY: install +install: + yarn install + +.PHONY: install-production +install-production: + yarn install --production --pure-lockfile + +.PHONY: clean +clean: + @rm -rf node_modules + .PHONY: test test: npm run test @@ -7,3 +21,9 @@ test: .PHONY: compile compile: install NODE_ENV=production ./node_modules/.bin/webpack --config webpack/index.js + +# I'm not sure this is the best idea, let's see how this works out for us +# and then go with something better once we find pain points +.PHONY: copy +copy: compile + @cp -r static/* $(BACKEND) diff --git a/tools/node-install.mk b/tools/node-install.mk deleted file mode 100644 index 44890c1d..00000000 --- a/tools/node-install.mk +++ /dev/null @@ -1,7 +0,0 @@ -.PHONY: install -install: - yarn install - -.PHONY: install-production -install-production: - yarn install --production --pure-lockfile diff --git a/ui/Makefile b/ui/Makefile index c2d49283..0bf9247f 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -3,3 +3,15 @@ include ../tools/node-install.mk .PHONY: test test: yarn run test + +.PHONY: install +install: + yarn install + +.PHONY: install-production +install-production: + yarn install --production --pure-lockfile + +.PHONY: clean +clean: + @rm -rf node_modules