-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
209 lines (167 loc) · 7.37 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
203
204
205
206
207
208
209
NODE_BIN := $(shell jiri profile env --profiles=v23:base,v23:nodejs NODE_BIN=)
PATH := node_modules/.bin:$(NODE_BIN):$(PATH)
NODE_MODULES_BIN := $(JIRI_ROOT)/release/javascript/core/node_modules/.bin
VDLPATH := $(JIRI_ROOT)/release/go/src:$(GOPATH)/src
VDLROOT := $(JIRI_ROOT)/release/go/src/v.io/v23/vdlroot
VGO := GOPATH="$(GOPATH)" VDLPATH="$(VDLPATH)" jiri go
GO_FILES := $(shell find $(JIRI_ROOT)/release/go/src/v.io -name "*.go")
NODE_MODULE_JS_FILES := $(shell find node_modules -name *.js | sed 's/ /\\ /')
SHELL := /bin/bash -e -o pipefail
UNAME := $(shell uname)
# NOTE: we run npm using 'node npm' to avoid relying on the shebang line in the
# npm script, which can exceed the Linux shebang length limit on Jenkins.
NPM := $(NODE_BIN)/npm
.DEFAULT_GOAL := all
ifdef XUNIT
OUTPUT_TRANSFORM := tap-xunit
endif
ifdef NODE_OUTPUT
NODE_OUTPUT_LOCAL = $(NODE_OUTPUT)
ifdef OUTPUT_TRANSFORM
NODE_OUTPUT_LOCAL := >($(OUTPUT_TRANSFORM) --package=javascript.node > $(NODE_OUTPUT_LOCAL))
endif
NODE_OUTPUT_LOCAL := | tee $(NODE_OUTPUT_LOCAL)
endif
JS_SRC_FILES = $(shell find src -name "*.js" | sed 's/ /\\ /')
all: gen-vdl lint build docs
build: docs
test-precheck: gen-vdl-test node_modules lint dependency-check
test: test-unit test-vdl test-vom
test-vdl: test-vdl-node
# This generates the VDL files and asks git if there are any changed files.
# The alternative is to use the vdl audit command, but that requires checking
# after both vdl commands in gen-vdl-impl as opposed to a single git status.
test-vdl-audit: gen-vdl
@if [ "`git status --porcelain | grep ' src/gen-vdl/' | sed 's/^ //'`" != "" ]; then \
echo "Some VDL files changed but were not committed!"; \
echo "`git status --porcelain | grep ' src/gen-vdl/' | sed 's/^ //'`"; \
echo "Run 'make gen-vdl' in the javascript/core repo, and commit the changed files."; \
exit 1; \
fi
test-vom: test-vom-node
# This generates the output of the vdl files in src/gen-vdl/v.io/<package-path>
# The command will generate all the dependent files as well.
gen-vdl: JS_VDL_DIR := "$(JIRI_ROOT)/release/javascript/core/src/gen-vdl"
gen-vdl: JS_VDL_PATH_TO_CORE := ".."
gen-vdl: gen-vdl-impl
# This generates the output of the vdl files in test/vdl-out/gen-vdl/v.io/<package-path>
# The command will generate all the dependent files as well.
gen-vdl-test: JS_VDL_DIR := "$(JIRI_ROOT)/release/javascript/core/test/vdl-out"
gen-vdl-test: EXTRA_VDL_PATHS := "javascript-test/..."
gen-vdl-test: VDLPATH := "$(JIRI_ROOT)/release/go/src:$(JIRI_ROOT)/release/javascript/core/test/vdl-in/src"
gen-vdl-test: JS_VDL_PATH_TO_CORE := "../../src"
gen-vdl-test: gen-vdl-impl
# This generates the vdl files used by test/vom/test-vdl-arith.js
# They are placed in test/vdl/expected-gen/v.io/<package-path>.
# This command is not normally run by the tests. It should only be run when the
# expected vdl files need to be updated.
gen-vdl-test-expected: JS_VDL_DIR := "$(JIRI_ROOT)/release/javascript/core/test/vdl/expected-gen"
gen-vdl-test-expected: JS_VDL_PATH_TO_CORE := "../../../src"
gen-vdl-test-expected: gen-vdl-test-expected-impl
gen-vdl-test-expected-impl:
rm -rf $(JS_VDL_DIR)
echo $(VDLPATH)
VDLPATH=$(VDLPATH) VDLROOT=$(VDLROOT) vdl generate -lang=javascript \
-js-relative-path-to-core=$(JS_VDL_PATH_TO_CORE) \
-js-out-dir=$(JS_VDL_DIR) \
v.io/x/ref/lib/vdl/testdata/...
gen-vdl-impl:
ifndef NOVDLGEN
rm -rf $(JS_VDL_DIR)
VDLPATH=$(VDLPATH) VDLROOT=$(VDLROOT) vdl generate -lang=javascript \
-js-relative-path-to-core=$(JS_VDL_PATH_TO_CORE) \
-js-out-dir=$(JS_VDL_DIR) \
v.io/x/ref/lib/vdl/testdata/... \
v.io/x/ref/services/wspr/... \
v.io/v23/rpc/... \
v.io/v23/naming/... \
v.io/v23/verror/... \
v.io/v23/vom/... \
$(EXTRA_VDL_PATHS)
# TODO(bjornick): We build the vdlroot stuff with a different set of command line options because the package
# path does not equal the directory path of the source file. This is not ideal, but bjornick and toddw will
# discuss how to fix this later.
VDLPATH=$(VDLPATH) VDLROOT=$(VDLROOT) vdl generate -lang=javascript \
-js-relative-path-to-core=../../../$(JS_VDL_PATH_TO_CORE) \
-js-out-dir=$(JS_VDL_DIR) \
$(VDLROOT)/...
endif
test-vdl-node: test-precheck
tape test/vdl/test-*.js $(NODE_OUTPUT_LOCAL)
test-vom-node: test-precheck
tape test/vom/test-*.js $(NODE_OUTPUT_LOCAL)
test-unit: test-unit-node
test-unit-node: test-precheck
tape test/unit/test-*.js $(NODE_OUTPUT_LOCAL)
lint: node_modules
ifdef NOLINT
@echo "Skipping lint - disabled by NOLINT environment variable"
else
jshint .
endif
dependency-check: node_modules
dependency-check package.json --entry src/vanadium.js
clean:
@$(RM) -fr docs
@$(RM) -fr node_modules
@$(RM) -fr npm-debug.log
@$(RM) -fr tmp
@$(RM) -fr xunit.xml
DOCSTRAP_LOC:= node_modules/ink-docstrap
docs: $(JS_SRC_FILES) jsdocs/docstrap-template/compiled/site.vanadium.css | node_modules
# Copy our compiled style template
cp -f jsdocs/docstrap-template/compiled/site.vanadium.css ${DOCSTRAP_LOC}/template/static/styles
# Build the docs
jsdoc $^ --readme ./jsdocs/index.md --configure ./jsdocs/conf.json --template ${DOCSTRAP_LOC}/template --destination $@
# Copy favicon
cp -f ./jsdocs/favicon.ico $@
# docs-template
#
# Builds the custom Vanadium jsdocs template and rebuilds the docs with it.
# It does so by copying the LESS files we have in jsdocs/styles to docstrap
# and rebuilding the compiled style file by following the "Customization"
# steps: https://github.com/terryweiss/docstrap#customizing-docstrap
# After the build is done, it copies back the compiled style file to our
# folder so it can be checked in and used later.
docs-template: node_modules node_modules/ink-docstrap/node_modules/grunt node_modules/ink-docstrap/bower_components
# Copy our raw LESS style assets to docstrap
cp -f jsdocs/docstrap-template/styles/*.* ${DOCSTRAP_LOC}/styles
# Rebuilt the styles
cd ${DOCSTRAP_LOC}; ${NODE_MODULES_BIN}/grunt less
# Copy back the compiled style file from docstrap
cp -f ${DOCSTRAP_LOC}/template/static/styles/site.cosmo.css jsdocs/docstrap-template/compiled/site.vanadium.css
# Rebuild docs
make docs
node_modules/ink-docstrap/node_modules/grunt:
cd ${DOCSTRAP_LOC}; node $(NPM) install
node_modules/ink-docstrap/bower_components:
cd ${DOCSTRAP_LOC}; ${NODE_MODULES_BIN}/bower install
# serve-docs
#
# Serve the docs at http://localhost:8020.
serve-docs: docs
static docs -p 8020
.PHONY: docs-template serve-docs
.PHONY: deploy-docs-production
deploy-docs-production: docs
make -C $(JIRI_ROOT)/infrastructure/deploy jsdoc-production
.PHONY: deploy-docs-staging
deploy-docs-staging: docs
make -C $(JIRI_ROOT)/infrastructure/deploy jsdoc-staging
node_modules: package.json check-that-npm-is-in-path
ifndef NONPMUPDATE
@node $(NPM) prune
@node $(NPM) install --quiet || (rm -fr $(HOME)/.npm && node $(NPM) install --quiet)
@touch node_modules
endif
check-that-npm-is-in-path:
@which npm > /dev/null || { echo "npm is not in the path. Did you remember to run 'jiri profile install v23:nodejs'?"; exit 1; }
.PHONY: all build clean dependency-check lint test
.PHONY: test-unit test-unit-node
.PHONY: check-that-npm-is-in-path
.PHONY: gen-vdl gen-vdl-test gen-vdl-test-expected gen-vdl-impl gen-vdl-test-expected-impl
# Prevent the tests from running in parallel, which causes problems because it
# starts multiple instances of the services at once, and also because it
# interleaves the test output.
.NOTPARALLEL: test-unit test-unit-node
.NOTPARALLEL: test-vdl test-vdl-node