test: split test in parallel/sequential
[platform/upstream/nodejs.git] / Makefile
1 -include config.mk
2
3 BUILDTYPE ?= Release
4 PYTHON ?= python
5 NINJA ?= ninja
6 DESTDIR ?=
7 SIGN ?=
8 PREFIX ?= /usr/local
9
10 # Determine EXEEXT
11 EXEEXT := $(shell $(PYTHON) -c \
12                 "import sys; print('.exe' if sys.platform == 'win32' else '')")
13
14 NODE ?= ./node$(EXEEXT)
15 NODE_EXE = node$(EXEEXT)
16 NODE_G_EXE = node_g$(EXEEXT)
17
18 # Default to verbose builds.
19 # To do quiet/pretty builds, run `make V=` to set V to an empty string,
20 # or set the V environment variable to an empty string.
21 V ?= 1
22
23 ifeq ($(USE_NINJA),1)
24 ifneq ($(V),)
25 NINJA := $(NINJA) -v
26 endif
27 endif
28
29 # BUILDTYPE=Debug builds both release and debug builds. If you want to compile
30 # just the debug build, run `make -C out BUILDTYPE=Debug` instead.
31 ifeq ($(BUILDTYPE),Release)
32 all: out/Makefile $(NODE_EXE)
33 else
34 all: out/Makefile $(NODE_EXE) $(NODE_G_EXE)
35 endif
36
37 # The .PHONY is needed to ensure that we recursively use the out/Makefile
38 # to check for changes.
39 .PHONY: $(NODE_EXE) $(NODE_G_EXE)
40
41 ifeq ($(USE_NINJA),1)
42 $(NODE_EXE): config.gypi
43         $(NINJA) -C out/Release/
44         ln -fs out/Release/$(NODE_EXE) $@
45
46 $(NODE_G_EXE): config.gypi
47         $(NINJA) -C out/Debug/
48         ln -fs out/Debug/$(NODE_EXE) $@
49 else
50 $(NODE_EXE): config.gypi out/Makefile
51         $(MAKE) -C out BUILDTYPE=Release V=$(V)
52         ln -fs out/Release/$(NODE_EXE) $@
53
54 $(NODE_G_EXE): config.gypi out/Makefile
55         $(MAKE) -C out BUILDTYPE=Debug V=$(V)
56         ln -fs out/Debug/$(NODE_EXE) $@
57 endif
58
59 out/Makefile: common.gypi deps/uv/uv.gyp deps/http_parser/http_parser.gyp deps/zlib/zlib.gyp deps/v8/build/toolchain.gypi deps/v8/build/features.gypi deps/v8/tools/gyp/v8.gyp node.gyp config.gypi
60 ifeq ($(USE_NINJA),1)
61         touch out/Makefile
62         $(PYTHON) tools/gyp_node.py -f ninja
63 else
64         $(PYTHON) tools/gyp_node.py -f make
65 endif
66
67 config.gypi: configure
68         if [ -f $@ ]; then
69                 $(error Stale $@, please re-run ./configure)
70         else
71                 $(error No $@, please run ./configure first)
72         fi
73
74 install: all
75         $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
76
77 uninstall:
78         $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
79
80 clean:
81         -rm -rf out/Makefile $(NODE_EXE) $(NODE_G_EXE) out/$(BUILDTYPE)/$(NODE_EXE) blog.html email.md
82         @if [ -d out ]; then find out/ -name '*.o' -o -name '*.a' | xargs rm -rf; fi
83         -rm -rf node_modules
84
85 distclean:
86         -rm -rf out
87         -rm -f config.gypi
88         -rm -f config.mk
89         -rm -rf $(NODE_EXE) $(NODE_G_EXE) blog.html email.md
90         -rm -rf node_modules
91
92 test: all
93         $(PYTHON) tools/test.py --mode=release message parallel sequential
94         $(MAKE) jslint
95         $(MAKE) cpplint
96
97 test-parallel: all
98         $(PYTHON) tools/test.py --mode=release parallel -J
99
100 test-http1: all
101         $(PYTHON) tools/test.py --mode=release --use-http1 sequential parallel message
102
103 test-valgrind: all
104         $(PYTHON) tools/test.py --mode=release --valgrind sequential parallel message
105
106 test/gc/node_modules/weak/build/Release/weakref.node:
107         @if [ ! -f $(NODE_EXE) ]; then make all; fi
108         ./$(NODE_EXE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
109                 --directory="$(shell pwd)/test/gc/node_modules/weak" \
110                 --nodedir="$(shell pwd)"
111
112 build-addons:
113         @if [ ! -f node ]; then make all; fi
114         rm -rf test/addons/doc-*/
115         ./node tools/doc/addon-verify.js
116         $(foreach dir, \
117                         $(sort $(dir $(wildcard test/addons/*/*.gyp))), \
118                         ./node deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
119                                         --directory="$(shell pwd)/$(dir)" \
120                                         --nodedir="$(shell pwd)" && ) echo "build done"
121
122 test-gc: all test/gc/node_modules/weak/build/Release/weakref.node
123         $(PYTHON) tools/test.py --mode=release gc
124
125 test-build: all build-addons
126
127 test-all: test-build test/gc/node_modules/weak/build/Release/weakref.node
128         $(PYTHON) tools/test.py --mode=debug,release
129         make test-npm
130
131 test-all-http1: test-build
132         $(PYTHON) tools/test.py --mode=debug,release --use-http1
133
134 test-all-valgrind: test-build
135         $(PYTHON) tools/test.py --mode=debug,release --valgrind
136
137 test-release: test-build
138         $(PYTHON) tools/test.py --mode=release
139
140 test-debug: test-build
141         $(PYTHON) tools/test.py --mode=debug
142
143 test-message: test-build
144         $(PYTHON) tools/test.py message
145
146 test-simple: all
147         $(PYTHON) tools/test.py parallel sequential
148
149 test-pummel: all wrk
150         $(PYTHON) tools/test.py pummel
151
152 test-internet: all
153         $(PYTHON) tools/test.py internet
154
155 test-debugger: all
156         $(PYTHON) tools/test.py debugger
157
158 test-npm: $(NODE_EXE)
159         rm -rf npm-cache npm-tmp npm-prefix
160         mkdir npm-cache npm-tmp npm-prefix
161         cd deps/npm ; npm_config_cache="$(shell pwd)/npm-cache" \
162              npm_config_prefix="$(shell pwd)/npm-prefix" \
163              npm_config_tmp="$(shell pwd)/npm-tmp" \
164              ../../$(NODE_EXE) cli.js install
165         cd deps/npm ; npm_config_cache="$(shell pwd)/npm-cache" \
166              npm_config_prefix="$(shell pwd)/npm-prefix" \
167              npm_config_tmp="$(shell pwd)/npm-tmp" \
168              ../../$(NODE_EXE) cli.js run-script test-all && \
169              ../../$(NODE_EXE) cli.js prune --prod && \
170              cd ../.. && \
171              rm -rf npm-cache npm-tmp npm-prefix
172
173 test-npm-publish: $(NODE_EXE)
174         npm_package_config_publishtest=true ./$(NODE_EXE) deps/npm/test/run.js
175
176 test-addons: test-build
177         $(PYTHON) tools/test.py --mode=release addons
178
179 test-timers:
180         $(MAKE) --directory=tools faketime
181         $(PYTHON) tools/test.py --mode=release timers
182
183 test-timers-clean:
184         $(MAKE) --directory=tools clean
185
186 apidoc_sources = $(wildcard doc/api/*.markdown)
187 apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \
188           $(addprefix out/,$(apidoc_sources:.markdown=.json))
189
190 apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets
191
192 apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
193
194 website_files = \
195         out/doc/sh_main.js    \
196         out/doc/sh_javascript.min.js
197
198 doc: $(apidoc_dirs) $(website_files) $(apiassets) $(apidocs) tools/doc/ out/doc/changelog.html $(NODE_EXE)
199
200 $(apidoc_dirs):
201         mkdir -p $@
202
203 out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
204         cp $< $@
205
206 out/doc/changelog.html: ChangeLog doc/changelog-head.html doc/changelog-foot.html tools/build-changelog.sh $(NODE_EXE)
207         bash tools/build-changelog.sh
208
209 out/doc/%: doc/%
210         cp -r $< $@
211
212 out/doc/api/%.json: doc/api/%.markdown $(NODE_EXE)
213         out/Release/$(NODE_EXE) tools/doc/generate.js --format=json $< > $@
214
215 out/doc/api/%.html: doc/api/%.markdown $(NODE_EXE)
216         out/Release/$(NODE_EXE) tools/doc/generate.js --format=html --template=doc/template.html $< > $@
217
218 email.md: ChangeLog tools/email-footer.md
219         bash tools/changelog-head.sh | sed 's|^\* #|* \\#|g' > $@
220         cat tools/email-footer.md | sed -e 's|__VERSION__|'$(VERSION)'|g' >> $@
221
222 blog.html: email.md
223         cat $< | ./$(NODE_EXE) tools/doc/node_modules/.bin/marked > $@
224
225 website-upload: doc
226         rsync -r out/doc/ node@nodejs.org:~/web/nodejs.org/
227         ssh node@nodejs.org '\
228     rm -f ~/web/nodejs.org/dist/latest &&\
229     ln -s $(VERSION) ~/web/nodejs.org/dist/latest &&\
230     rm -f ~/web/nodejs.org/docs/latest &&\
231     ln -s $(VERSION) ~/web/nodejs.org/docs/latest &&\
232     rm -f ~/web/nodejs.org/dist/node-latest.tar.gz &&\
233     ln -s $(VERSION)/node-$(VERSION).tar.gz ~/web/nodejs.org/dist/node-latest.tar.gz'
234
235 docopen: out/doc/api/all.html
236         -google-chrome out/doc/api/all.html
237
238 docclean:
239         -rm -rf out/doc
240
241 RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
242 VERSION=v$(RAWVER)
243 RELEASE=$(shell $(PYTHON) tools/getnodeisrelease.py)
244 PLATFORM=$(shell uname | tr '[:upper:]' '[:lower:]')
245 ifeq ($(findstring x86_64,$(shell uname -m)),x86_64)
246 DESTCPU ?= x64
247 else
248 DESTCPU ?= ia32
249 endif
250 ifeq ($(DESTCPU),x64)
251 ARCH=x64
252 else
253 ifeq ($(DESTCPU),arm)
254 ARCH=arm
255 else
256 ARCH=x86
257 endif
258 endif
259 TARNAME=node-$(VERSION)
260 ifdef NIGHTLY
261 TAG = nightly-$(NIGHTLY)
262 TARNAME=node-$(VERSION)-$(TAG)
263 endif
264 TARBALL=$(TARNAME).tar.gz
265 BINARYNAME=$(TARNAME)-$(PLATFORM)-$(ARCH)
266 BINARYTAR=$(BINARYNAME).tar.gz
267 PKG=out/$(TARNAME).pkg
268 packagemaker=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
269
270 PKGSRC=nodejs-$(DESTCPU)-$(RAWVER).tgz
271 ifdef NIGHTLY
272 PKGSRC=nodejs-$(DESTCPU)-$(RAWVER)-$(TAG).tgz
273 endif
274
275 dist: doc $(TARBALL) $(PKG)
276
277 PKGDIR=out/dist-osx
278
279 release-only:
280         @if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
281                 exit 0 ; \
282         else \
283           echo "" >&2 ; \
284                 echo "The git repository is not clean." >&2 ; \
285                 echo "Please commit changes before building release tarball." >&2 ; \
286                 echo "" >&2 ; \
287                 git status --porcelain | egrep -v '^\?\?' >&2 ; \
288                 echo "" >&2 ; \
289                 exit 1 ; \
290         fi
291         @if [ "$(NIGHTLY)" != "" -o "$(RELEASE)" = "1" ]; then \
292                 exit 0; \
293         else \
294           echo "" >&2 ; \
295                 echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE)." >&2 ; \
296           echo "Did you remember to update src/node_version.cc?" >&2 ; \
297           echo "" >&2 ; \
298                 exit 1 ; \
299         fi
300
301 pkg: $(PKG)
302
303 $(PKG): release-only
304         rm -rf $(PKGDIR)
305         rm -rf out/deps out/Release
306         $(PYTHON) ./configure --without-snapshot --dest-cpu=ia32 --tag=$(TAG)
307         $(MAKE) install V=$(V) DESTDIR=$(PKGDIR)/32
308         rm -rf out/deps out/Release
309         $(PYTHON) ./configure --without-snapshot --dest-cpu=x64 --tag=$(TAG)
310         $(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
311         SIGN="$(APP_SIGN)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
312         lipo $(PKGDIR)/32/usr/local/bin/node \
313                 $(PKGDIR)/usr/local/bin/node \
314                 -output $(PKGDIR)/usr/local/bin/node-universal \
315                 -create
316         mv $(PKGDIR)/usr/local/bin/node-universal $(PKGDIR)/usr/local/bin/node
317         rm -rf $(PKGDIR)/32
318         $(packagemaker) \
319                 --id "org.nodejs.Node" \
320                 --doc tools/osx-pkg.pmdoc \
321                 --out $(PKG)
322         SIGN="$(INT_SIGN)" PKG="$(PKG)" bash tools/osx-productsign.sh
323
324 $(TARBALL): release-only $(NODE_EXE) doc
325         git archive --format=tar --prefix=$(TARNAME)/ HEAD | tar xf -
326         mkdir -p $(TARNAME)/doc/api
327         cp doc/node.1 $(TARNAME)/doc/node.1
328         cp -r out/doc/api/* $(TARNAME)/doc/api/
329         rm -rf $(TARNAME)/deps/v8/test # too big
330         rm -rf $(TARNAME)/doc/images # too big
331         find $(TARNAME)/ -type l | xargs rm # annoying on windows
332         tar -cf $(TARNAME).tar $(TARNAME)
333         rm -rf $(TARNAME)
334         gzip -f -9 $(TARNAME).tar
335
336 tar: $(TARBALL)
337
338 $(BINARYTAR): release-only
339         rm -rf $(BINARYNAME)
340         rm -rf out/deps out/Release
341         $(PYTHON) ./configure --prefix=/ --without-snapshot --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
342         $(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1
343         cp README.md $(BINARYNAME)
344         cp LICENSE $(BINARYNAME)
345         cp ChangeLog $(BINARYNAME)
346         tar -cf $(BINARYNAME).tar $(BINARYNAME)
347         rm -rf $(BINARYNAME)
348         gzip -f -9 $(BINARYNAME).tar
349
350 binary: $(BINARYTAR)
351
352 $(PKGSRC): release-only
353         rm -rf dist out
354         $(PYTHON) configure --prefix=/ --without-snapshot \
355                 --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
356         $(MAKE) install DESTDIR=dist
357         (cd dist; find * -type f | sort) > packlist
358         pkg_info -X pkg_install | \
359                 egrep '^(MACHINE_ARCH|OPSYS|OS_VERSION|PKGTOOLS_VERSION)' > build-info
360         pkg_create -B build-info -c tools/pkgsrc/comment -d tools/pkgsrc/description \
361                 -f packlist -I /opt/local -p dist -U $(PKGSRC)
362
363 pkgsrc: $(PKGSRC)
364
365 dist-upload: $(TARBALL) $(PKG)
366         ssh node@nodejs.org mkdir -p web/nodejs.org/dist/$(VERSION)
367         scp $(TARBALL) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARBALL)
368         scp $(PKG) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARNAME).pkg
369
370 wrkclean:
371         $(MAKE) -C tools/wrk/ clean
372         rm tools/wrk/wrk
373
374 wrk: tools/wrk/wrk
375 tools/wrk/wrk:
376         $(MAKE) -C tools/wrk/
377
378 bench-net: all
379         @$(NODE) benchmark/common.js net
380
381 bench-crypto: all
382         @$(NODE) benchmark/common.js crypto
383
384 bench-tls: all
385         @$(NODE) benchmark/common.js tls
386
387 bench-http: wrk all
388         @$(NODE) benchmark/common.js http
389
390 bench-fs: all
391         @$(NODE) benchmark/common.js fs
392
393 bench-misc: all
394         @$(MAKE) -C benchmark/misc/function_call/
395         @$(NODE) benchmark/common.js misc
396
397 bench-array: all
398         @$(NODE) benchmark/common.js arrays
399
400 bench-buffer: all
401         @$(NODE) benchmark/common.js buffers
402
403 bench-all: bench bench-misc bench-array bench-buffer
404
405 bench: bench-net bench-http bench-fs bench-tls
406
407 bench-http-simple:
408          benchmark/http_simple_bench.sh
409
410 bench-idle:
411         ./$(NODE_EXE) benchmark/idle_server.js &
412         sleep 1
413         ./$(NODE_EXE) benchmark/idle_clients.js &
414
415 jslintfix:
416         PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/fixjsstyle.py --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js
417
418 jslint:
419         PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/gjslint.py --unix_mode --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js
420
421 CPPLINT_EXCLUDE ?=
422 CPPLINT_EXCLUDE += src/node_dtrace.cc
423 CPPLINT_EXCLUDE += src/node_dtrace.cc
424 CPPLINT_EXCLUDE += src/node_root_certs.h
425 CPPLINT_EXCLUDE += src/node_win32_perfctr_provider.cc
426 CPPLINT_EXCLUDE += src/queue.h
427 CPPLINT_EXCLUDE += src/tree.h
428 CPPLINT_EXCLUDE += src/v8abbr.h
429
430 CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard src/*.cc src/*.h src/*.c tools/icu/*.h tools/icu/*.cc deps/debugger-agent/include/* deps/debugger-agent/src/*))
431
432 cpplint:
433         @$(PYTHON) tools/cpplint.py $(CPPLINT_FILES)
434
435 lint: jslint cpplint
436
437 .PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean check uninstall install install-includes install-bin all staticlib dynamiclib test test-all test-addons build-addons website-upload pkg blog blogclean tar binary release-only bench-http-simple bench-idle bench-all bench bench-misc bench-array bench-buffer bench-net bench-http bench-fs bench-tls