-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
116 lines (89 loc) · 3.42 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Makefile the whole ease.ml project.
# Summary and context path of this makefile.
SUMMARY := This the main Makefile of the ease.ml project. All commands in this \
makefile will be performed on every single component of the project. \
To build individual components such as the javascript client or the engine, \
go to the corresponding component subdirectory.
CONTEXT_PATH := .
FOOTER := To specify the target directory for make package use the DIST_PATH environment variable \
\(default: DIST_PATH=./dist\).
# Paths to the parent directory of this makefile and the repo root directory.
MY_DIR_PATH := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
ROOT_DIR_PATH := $(realpath $(MY_DIR_PATH))
# Include common make functions.
include $(ROOT_DIR_PATH)/dev/makefiles/show-help.mk
include $(ROOT_DIR_PATH)/dev/makefiles/show-prompt.mk
# All available components. To include a component subdirectory in the build-all command, simply
# ensure it implements all commands (at least with an empty recipe) and add its directory name here.
COMPONENTS := client schema web engine
# Other config variables.
PROJECT_NAME := easeml
VERSION := $(shell cat $(ROOT_DIR_PATH)/VERSION)
# Importable config variables.
ifeq ($(strip $(DIST_PATH)),)
DIST_PATH := ./dist
endif
# Function that repeats the same action for all components.
define repeat-for-all
for component in $(COMPONENTS) ; do \
$(MAKE) -C $$component $(1) $(if $(DIST_PATH),DIST_PATH=$(abspath $(DIST_PATH)/$$component),); \
done
endef
# Handle export rules -- keep local variables private, pass everything else.
unexport SUMMARY CONTEXT_PATH MY_DIR_PATH COMPONENTS
.PHONY: clean
## Clean all the files resulting from building and testing.
clean:
$(call show-prompt,Cleaning the build files)
$(call repeat-for-all,$@)
ifneq ($(DIST_PATH),)
# Clean the component directories if they were created.
for component in $(COMPONENTS) ; do \
rm -rf $(DIST_PATH)/$$component; \
done
if [ -d $(DIST_PATH) ]; then \
rmdir $(DIST_PATH) --ignore-fail-on-non-empty; \
fi
endif
.PHONY: build
## Build all components.
build:
$(call show-prompt,Compiling component code)
$(call repeat-for-all,$@)
.PHONY: package
## Build all the components and assemble deployable packages and place them under the dist directory.
package:
$(call show-prompt,Building the deployment package)
$(call repeat-for-all,$@)
.PHONY: test
## Run all tests.
test:
$(call show-prompt,Running all tests)
$(call repeat-for-all,$@)
.PHONY: lint
## Run the linting checks.
lint:
$(call show-prompt,Running all linting checks)
$(call repeat-for-all,$@)
.PHONY: init
## Run initialization script in all Makefiles
init:
$(call show-prompt,Running all init scripts)
$(call repeat-for-all,$@)
.PHONY: publish
## Publish to the respective indexing service
publish:
$(call show-prompt,Running all publishing scripts)
$(call repeat-for-all,$@)
.PHONY: version
## Set the version of all components according to version file found in the repo root. To update the version,
## make sure to first update the VERSION file.
version:
$(call show-prompt,Increasing package version)
$(eval MAJOR=$(word 1,$(subst ., ,$(VERSION))))
$(eval MINOR=$(word 2,$(subst ., ,$(VERSION))))
$(eval PATCH=$(word 3,$(subst ., ,$(VERSION))))
$(eval PATCH=$(shell echo $$(($(PATCH)+1))))
@echo $(MAJOR).$(MINOR).$(PATCH) > $(ROOT_DIR_PATH)/VERSION
$(call show-prompt,Updating package version)
$(call repeat-for-all,$@)