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.

Makefile 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #
  2. # Copyright 2019 Joyent, Inc.
  3. #
  4. # Makefile for node-triton
  5. #
  6. #
  7. # Vars, Tools, Files, Flags
  8. #
  9. JS_FILES := bin/triton \
  10. $(shell find lib test -name '*.js' | grep -v '/tmp/')
  11. JSL_CONF_NODE = tools/jsl.node.conf
  12. JSL_FILES_NODE = $(JS_FILES)
  13. JSSTYLE_FILES = $(JS_FILES)
  14. JSSTYLE_FLAGS = -f tools/jsstyle.conf
  15. CLEAN_FILES += ./node_modules
  16. TAP_EXEC = ./node_modules/.bin/tap
  17. TEST_JOBS ?= 10
  18. TEST_TIMEOUT_S ?= 1200
  19. TEST_GLOB ?= *
  20. include ./tools/mk/Makefile.defs
  21. #
  22. # Targets
  23. #
  24. .PHONY: all
  25. all:
  26. npm install
  27. .PHONY: test
  28. test: test-unit test-integration
  29. .PHONY: ensure-node-v6-or-greater-for-test-suite
  30. ensure-node-v6-or-greater-for-test-suite:
  31. @NODE_VER=$(shell node --version) && \
  32. ./node_modules/.bin/semver -r '>=6.x' $$NODE_VER >/dev/null || \
  33. (echo "error: test suite requires node v6 or greater: you have $$NODE_VER"; exit 1)
  34. .PHONY: test-unit
  35. test-unit: ensure-node-v6-or-greater-for-test-suite
  36. NODE_NDEBUG= $(TAP_EXEC) --timeout $(TEST_TIMEOUT_S) -j $(TEST_JOBS) \
  37. -o ./test-unit.tap test/unit/$(TEST_GLOB).test.js
  38. .PHONY: test-integration
  39. test-integration: ensure-node-v6-or-greater-for-test-suite
  40. NODE_NDEBUG= $(TAP_EXEC) --timeout $(TEST_TIMEOUT_S) -j $(TEST_JOBS) \
  41. -o ./test-integration.tap test/integration/$(TEST_GLOB).test.js
  42. .PHONY: clean
  43. clean::
  44. rm -f triton-*.tgz
  45. check:: versioncheck
  46. # Ensure CHANGES.md and package.json have the same version.
  47. .PHONY: versioncheck
  48. versioncheck:
  49. @echo version is: $(shell cat package.json | json version)
  50. [[ `cat package.json | json version` == `grep '^## ' CHANGES.md | head -2 | tail -1 | awk '{print $$2}'` ]]
  51. .PHONY: cutarelease
  52. cutarelease: versioncheck
  53. [[ -z `git status --short` ]] # If this fails, the working dir is dirty.
  54. @which json 2>/dev/null 1>/dev/null && \
  55. ver=$(shell json -f package.json version) && \
  56. name=$(shell json -f package.json name) && \
  57. publishedVer=$(shell npm view -j $(shell json -f package.json name)@$(shell json -f package.json version) version 2>/dev/null) && \
  58. if [[ -n "$$publishedVer" ]]; then \
  59. echo "error: $$name@$$ver is already published to npm"; \
  60. exit 1; \
  61. fi && \
  62. echo "** Are you sure you want to tag and publish $$name@$$ver to npm?" && \
  63. echo "** Enter to continue, Ctrl+C to abort." && \
  64. read
  65. ver=$(shell cat package.json | json version) && \
  66. date=$(shell date -u "+%Y-%m-%d") && \
  67. git tag -a "$$ver" -m "version $$ver ($$date)" && \
  68. git push --tags origin && \
  69. npm publish
  70. .PHONY: git-hooks
  71. git-hooks:
  72. ln -sf ../../tools/pre-commit.sh .git/hooks/pre-commit
  73. .PHONY: dumpvar
  74. dumpvar:
  75. @if [[ -z "$(VAR)" ]]; then \
  76. echo "error: set 'VAR' to dump a var"; \
  77. exit 1; \
  78. fi
  79. @echo "$(VAR) is '$($(VAR))'"
  80. include ./tools/mk/Makefile.deps
  81. include ./tools/mk/Makefile.targ
  82. JSL_FLAGS += --nofilelist