-
Notifications
You must be signed in to change notification settings - Fork 397
/
Makefile
94 lines (72 loc) · 2.47 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
NODE-GYP ?= node_modules/.bin/node-gyp
# Sick of changing this. Do a check and try to use python 2 if it doesn't work
PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1)))
PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL})
ifeq ($(PYTHON_VERSION_MAJOR), 2)
PYTHON = python
else
PYTHON = python2
endif
NODE ?= node
CPPLINT ?= cpplint.py
BUILDTYPE ?= Release
TESTS = "test/**/*.js"
E2E_TESTS = $(wildcard e2e/*.spec.js)
TEST_REPORTER =
TEST_OUTPUT =
CONFIG_OUTPUTS = \
build/bindings.target.mk \
build/Makefile \
build/binding.Makefile build/config.gypi
CPPLINT_FILES = $(wildcard src/*.cc src/*.h)
CPPLINT_FILTER = -legal/copyright
JSLINT_FILES = lib/*.js test/*.js e2e/*.js
PACKAGE = $(shell node -pe 'require("./package.json").name.split("/")[1]')
VERSION = $(shell node -pe 'require("./package.json").version')
GYPBUILDARGS=
ifeq ($(BUILDTYPE),Debug)
GYPBUILDARGS=--debug
endif
.PHONY: all clean lint test lib docs e2e ghpages check
all: lint lib test e2e
lint: cpplint jslint
cpplint:
@$(PYTHON) $(CPPLINT) --filter=$(CPPLINT_FILTER) $(CPPLINT_FILES)
jslint: node_modules/.dirstamp
@./node_modules/.bin/jshint --verbose $(JSLINT_FILES)
lib: node_modules/.dirstamp $(CONFIG_OUTPUTS)
@PYTHONHTTPSVERIFY=0 $(NODE-GYP) build $(GYPBUILDARGS)
node_modules/.dirstamp: package.json
@npm update --loglevel warn
@touch $@
$(CONFIG_OUTPUTS): node_modules/.dirstamp binding.gyp
@$(NODE-GYP) configure
test: node_modules/.dirstamp
@./node_modules/.bin/mocha --ui exports $(TEST_REPORTER) $(TESTS) $(TEST_OUTPUT)
check: node_modules/.dirstamp
@$(NODE) util/test-compile.js
e2e: $(E2E_TESTS)
@./node_modules/.bin/mocha --exit --timeout 120000 --ui exports $(TEST_REPORTER) $(E2E_TESTS) $(TEST_OUTPUT)
define release
NEXT_VERSION=$(shell node -pe 'require("semver").inc("$(VERSION)", "$(1)")')
node -e "\
var j = require('./package.json');\
j.version = \"$$NEXT_VERSION\";\
var s = JSON.stringify(j, null, 2);\
require('fs').writeFileSync('./package.json', s);" && \
git commit -m "release $$NEXT_VERSION" -- package.json && \
git tag "$$NEXT_VERSION" -m "release $$NEXT_VERSION"
endef
docs: node_modules/.dirstamp
@rm -rf docs
@./node_modules/jsdoc/jsdoc.js --destination docs \
--recurse -R ./README.md \
-t "./node_modules/toolkit-jsdoc/" \
--tutorials examples ./lib
gh-pages: node_modules/.dirstamp
@./make_docs.sh
release-patch:
@$(call release,patch)
clean: node_modules/.dirstamp
@rm -f deps/librdkafka/config.h
@$(NODE-GYP) clean