You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.4 KiB

  1. NODE-GYP ?= node_modules/.bin/node-gyp
  2. # Sick of changing this. Do a check and try to use python 2 if it doesn't work
  3. PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1)))
  4. PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL})
  5. ifeq ($(PYTHON_VERSION_MAJOR), 2)
  6. PYTHON = python
  7. else
  8. PYTHON = python2
  9. endif
  10. NODE ?= node
  11. CPPLINT ?= cpplint.py
  12. BUILDTYPE ?= Release
  13. TESTS = "test/**/*.js"
  14. E2E_TESTS = $(wildcard e2e/*.spec.js)
  15. TEST_REPORTER =
  16. TEST_OUTPUT =
  17. CONFIG_OUTPUTS = \
  18. build/bindings.target.mk \
  19. build/Makefile \
  20. build/binding.Makefile build/config.gypi
  21. CPPLINT_FILES = $(wildcard src/*.cc src/*.h)
  22. CPPLINT_FILTER = -legal/copyright
  23. JSLINT_FILES = lib/*.js test/*.js e2e/*.js
  24. PACKAGE = $(shell node -pe 'require("./package.json").name.split("/")[1]')
  25. VERSION = $(shell node -pe 'require("./package.json").version')
  26. GYPBUILDARGS=
  27. ifeq ($(BUILDTYPE),Debug)
  28. GYPBUILDARGS=--debug
  29. endif
  30. .PHONY: all clean lint test lib docs e2e ghpages check
  31. all: lint lib test e2e
  32. lint: cpplint jslint
  33. cpplint:
  34. @$(PYTHON) $(CPPLINT) --filter=$(CPPLINT_FILTER) $(CPPLINT_FILES)
  35. jslint: node_modules/.dirstamp
  36. @./node_modules/.bin/jshint --verbose $(JSLINT_FILES)
  37. lib: node_modules/.dirstamp $(CONFIG_OUTPUTS)
  38. @PYTHONHTTPSVERIFY=0 $(NODE-GYP) build $(GYPBUILDARGS)
  39. node_modules/.dirstamp: package.json
  40. @npm update --loglevel warn
  41. @touch $@
  42. $(CONFIG_OUTPUTS): node_modules/.dirstamp binding.gyp
  43. @$(NODE-GYP) configure
  44. test: node_modules/.dirstamp
  45. @./node_modules/.bin/mocha $(TEST_REPORTER) $(TESTS) $(TEST_OUTPUT)
  46. check: node_modules/.dirstamp
  47. @$(NODE) util/test-compile.js
  48. e2e: $(E2E_TESTS)
  49. @./node_modules/.bin/mocha --exit $(TEST_REPORTER) $(E2E_TESTS) $(TEST_OUTPUT)
  50. define release
  51. NEXT_VERSION=$(shell node -pe 'require("semver").inc("$(VERSION)", "$(1)")')
  52. node -e "\
  53. var j = require('./package.json');\
  54. j.version = \"$$NEXT_VERSION\";\
  55. var s = JSON.stringify(j, null, 2);\
  56. require('fs').writeFileSync('./package.json', s);" && \
  57. git commit -m "release $$NEXT_VERSION" -- package.json && \
  58. git tag "$$NEXT_VERSION" -m "release $$NEXT_VERSION"
  59. endef
  60. docs: node_modules/.dirstamp
  61. @rm -rf docs
  62. @./node_modules/jsdoc/jsdoc.js --destination docs \
  63. --recurse -R ./README.md \
  64. -t "./node_modules/toolkit-jsdoc/" \
  65. --tutorials examples ./lib
  66. gh-pages: node_modules/.dirstamp
  67. @./make_docs.sh
  68. release-patch:
  69. @$(call release,patch)
  70. clean: node_modules/.dirstamp
  71. @rm -f deps/librdkafka/config.h
  72. @$(NODE-GYP) clean