-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
203 lines (167 loc) · 7.93 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# THIS FILE IS CODE-GENERATED
# Encapsule holistic v0.4.4 "colfaxpeak" cOPp4PdPRXKyaPt5tQTCqQ e2ac2697de97dbe7b68722e9de19e7f6d6e282cc
# See: https://github.com/Encapsule/holistic/README.md
# https://www.gnu.org/software/make/manual/make.html
# https://timmurphy.org/2015/09/27/how-to-get-a-makefile-directory-path/
# https://stackoverflow.com/questions/33126425/how-to-remove-the-last-trailing-backslash-in-gnu-make-file
# $(patsubst %\,%,$(__PATHS_FEATURE))
DIR_ROOT=$(patsubst %/,%,$(dir $(realpath $(firstword $(MAKEFILE_LIST)))))
$(info ***** HOLISTIC APP/SERVICE CORE BUILD Makefile (created by appgen) *****)
$(info DIR_ROOT is $(DIR_ROOT))
DIR_MODULES=$(DIR_ROOT)/node_modules
DIR_TOOLBIN=$(DIR_MODULES)/.bin
DIR_HOLISTIC=$(DIR_ROOT)/HOLISTIC
DIR_PROJECT=$(DIR_ROOT)/PROJECT
DIR_PROJECT_BUILD=$(DIR_PROJECT)/BUILD
DIR_PROJECT_TEST=$(DIR_PROJECT)/TEST
DIR_PROJECT_DEPLOY=$(DIR_PROJECT)/DEPLOY
TOOL_GEN_APP_RUNTIME_BUILDTAG=$(DIR_PROJECT_BUILD)/generate-runtime-buildtag.js
TOOL_GEN_APP_RUNTIME_PACKAGE=$(DIR_PROJECT_BUILD)/generate-runtime-package-manifest.js
TOOL_ESLINT=$(DIR_TOOLBIN)/eslint
TOOL_BABEL=$(DIR_TOOLBIN)/babel
TOOL_WEBPACK=$(DIR_TOOLBIN)/webpack-cli
TOOL_WEBPACK_FLAGS=--progress --color --devtool source-map --output-pathinfo
TOOL_COPY_HOLARCHY_RESOURCES=$(DIR_TOOLBIN)/copy_resources
DIR_SOURCES=$(DIR_ROOT)/SOURCES
DIR_SOURCES_ASSETS=$(DIR_SOURCES)/ASSETS
DIR_SOURCES_CLIENT=$(DIR_SOURCES)/CLIENT
DIR_SOURCES_COMMON=$(DIR_SOURCES)/COMMON
DIR_SOURCES_SERVER=$(DIR_SOURCES)/SERVER
DIR_SOURCES_DEPLOY=$(DIR_SOURCES)/DEPLOY
DIR_BUILD=$(DIR_ROOT)/BUILD
DIR_BUILD_PHASE1=$(DIR_BUILD)/transpile-phase1
DIR_BUILD_PHASE2=$(DIR_BUILD)/webpack-phase2
DIR_BUILD_PHASE3=$(DIR_BUILD)/runtime-phase3
DIR_DISTS=$(DIR_ROOT)/DISTS
DIR_DIST_APP_SERVICE=$(DIR_DISTS)/encapsule-org-service-deploy
.PHONY: default
default:
@echo ================================================================
@echo Please specify Makefile target\(s\) to evaluate as arguments to \'make\'.
@echo Type \'make\' and use shell auto-complete to enumerate Makefile targets.
@echo ================================================================
# ================================================================
# ================================================================
# ================================================================
# Holistic app service sources git repo build environment targets.
.PHONY: configure
configure:
@echo Configuring build environment...
npm install
@echo Localhost build environment has been configured.
.PHONY: clean
clean:
@echo Cleaning up the output of the last application build...
rm -rf $(DIR_BUILD)
@echo Localhost build environment ./BUILD directory and its contents has been removed.
@echo The next run of \'make application\' will generate a clean runtime image package from ./SOURCES.
.PHONY: scrub
scrub: clean
@echo Scrubbing the local build environment...
@echo ... removing previously-installed package dependencies.
rm -rf $(DIR_MODULES)
@echo Localhost build environment ./node_modules caches has been removed.
@echo The next run of \'make application\' will re-install a clean copy of ./node_modules.
.PHONY: reset
reset: scrub
@echo Verifying local npm cache integrity...
npm cache verify
@echo Dependencies will be re-installed from refreshed package cache \(requires Internet\) on next \'make configure\'.
# ================================================================
# ================================================================
# ================================================================
# Holistic app service runtime image package build targets.
# Create/rebuild a development version of the holistic app service from ./SOURCES/*
.PHONY: application
application: _applicationPrebuild _applicationService _applicationPostbuild
@echo Your derived app service has been rebuilt from generic library + your unique specializations.
@echo The output of this rebuild has been written into the ./BUILD/runtime-phase3 directory.
@echo ---
# Makefile-App service-specific runtime image package prebuild extension:
.PHONY: _applicationPrebuild
_applicationPrebuild: configure
-make --makefile=Makefile-App applicationPrebuild
# Makefile-App service-specific runtime image package postbuild extension:
.PHONY: _applicationPostbuild
_applicationPostbuild:
-make --makefile=Makefile-App applicationPostbuild
# Service-agnostic runtime image package build target:
.PHONY: _applicationService
_applicationService:
# PHASE0 - create a copy of the SOURCES directory structure.
@echo ================================================================
@echo 'O o O o O o'
@echo '| O o | | O o | | O o |'
@echo '| | O | | | | O | | | | O | |'
@echo '| o O | | o O | | o O |'
@echo 'o O o O o O'
@echo ================================================================
@echo 'HOLISTIC APPLICATION SERVICE BUILD PHASE 0 (PREP SOURCES)'
@echo ================================================================
@echo '(=)'
@echo ' X'
@echo '(=)'
@echo ' X'
@echo '(=)'
mkdir -p $(DIR_BUILD_PHASE1)
cp -rv $(DIR_SOURCES)/* $(DIR_BUILD_PHASE1)
$(TOOL_COPY_HOLARCHY_RESOURCES) $(DIR_BUILD_PHASE1)/ASSETS
# PHASE1 - transpile modules from SOURCES into PHASE1 directory overwriting PHASE0 clone copies.
@echo ================================================================
@echo 'HOLISTIC APPLICATION SERVICE BUILD PHASE 1 (TRANSPILATION)goto-l'
@echo ================================================================
@echo '(=)'
@echo ' X'
@echo '(=)'
@echo ' X'
@echo '(=)'
$(TOOL_BABEL) --config-file $(DIR_ROOT)/.babelrc --out-dir $(DIR_BUILD_PHASE1) --keep-file-extension --verbose $(DIR_SOURCES)
# Create the app-build.json manifest so that it is available for optional inclusion in phase2
node $(TOOL_GEN_APP_RUNTIME_BUILDTAG) > $(DIR_BUILD_PHASE1)/app-build.json
# PHASE2 - create application server and client bundles via webpack.
# https://stackoverflow.com/questions/25956937/how-to-build-minified-and-uncompressed-bundle-with-webpack
@echo ================================================================
@echo 'HOLISTIC APPLICATION SERVICE BUILD PHASE 2 (BUNDLING)'
@echo ================================================================
@echo '(=)'
@echo ' X'
@echo '(=)'
@echo ' X'
@echo '(=)'
# $(TOOL_WEBPACK) $(TOOL_WEBPACK_FLAGS) --config $(DIR_PROJECT_BUILD)/webpack.config.app.server.js
$(TOOL_WEBPACK) $(TOOL_WEBPACK_FLAGS) --config $(DIR_PROJECT_BUILD)/webpack.config.app.client.js
# PHASE3 - create application image
@echo ================================================================
@echo 'HOLISTIC APPLICATION SERVICE BUILD PHASE 3 (PACKAGING)'
@echo ================================================================
@echo '(=)'
@echo ' X'
@echo '(=)'
@echo ' X'
@echo '(=)'
mkdir -p $(DIR_BUILD_PHASE3)
cp -r $(DIR_BUILD_PHASE2)/* $(DIR_BUILD_PHASE3)/
cp -r $(DIR_BUILD_PHASE1)/ASSETS $(DIR_BUILD_PHASE3)/
cp $(DIR_BUILD_PHASE1)/app-build.json $(DIR_BUILD_PHASE3)/
cp -r $(DIR_BUILD_PHASE1)/COMMON $(DIR_BUILD_PHASE3)/
cp -r $(DIR_BUILD_PHASE1)/SERVER $(DIR_BUILD_PHASE3)/
cp -r $(DIR_HOLISTIC) $(DIR_BUILD_PHASE3)/
node $(TOOL_GEN_APP_RUNTIME_PACKAGE) --appBuildManifest $(DIR_BUILD_PHASE3)/app-build.json > $(DIR_BUILD_PHASE3)/package.json
@echo ================================================================
@echo 'HOLISTIC APPLICATION SERVICE BUILD COMPLETE.'
@echo ================================================================
@echo '(=)'
@echo ' X'
@echo '(=)'
@echo ' X'
@echo '(=)'
# ================================================================
# ================================================================
# ================================================================
# Holistic app service distribution package build targets.
.PHONY: distribution
distribution:
@echo App service distribution package build start...
mkdir -p $(DIR_DIST_APP_SERVICE)
cp -r $(DIR_BUILD_PHASE3)/. $(DIR_DIST_APP_SERVICE)/
cp -r $(DIR_SOURCES_DEPLOY)/. $(DIR_DIST_APP_SERVICE)/