Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

149 строки
5.6 KiB

10 лет назад
11 лет назад
10 лет назад
11 лет назад
10 лет назад
11 лет назад
11 лет назад
10 лет назад
10 лет назад
11 лет назад
10 лет назад
11 лет назад
10 лет назад
11 лет назад
10 лет назад
10 лет назад
10 лет назад
11 лет назад
10 лет назад
11 лет назад
10 лет назад
11 лет назад
10 лет назад
11 лет назад
  1. # -------------------------------------------------------------------
  2. #
  3. # Copyright (c) 2014 Basho Technologies, Inc.
  4. #
  5. # This file is provided to you under the Apache License,
  6. # Version 2.0 (the "License"); you may not use this file
  7. # except in compliance with the License. You may obtain
  8. # a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing,
  13. # software distributed under the License is distributed on an
  14. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. # KIND, either express or implied. See the License for the
  16. # specific language governing permissions and limitations
  17. # under the License.
  18. #
  19. # -------------------------------------------------------------------
  20. # -------------------------------------------------------------------
  21. # NOTE: This file is is from https://github.com/basho/tools.mk.
  22. # It should not be edited in a project. It should simply be updated
  23. # wholesale when a new version of tools.mk is released.
  24. # -------------------------------------------------------------------
  25. REBAR ?= ./rebar
  26. REVISION ?= $(shell git rev-parse --short HEAD)
  27. PROJECT ?= $(shell basename `find src -name "*.app.src"` .app.src)
  28. .PHONY: compile-no-deps test docs xref dialyzer-run dialyzer-quick dialyzer \
  29. cleanplt upload-docs
  30. compile-no-deps:
  31. ${REBAR} compile skip_deps=true
  32. test: compile
  33. ${REBAR} eunit skip_deps=true
  34. upload-docs: docs
  35. @if [ -z "${BUCKET}" -o -z "${PROJECT}" -o -z "${REVISION}" ]; then \
  36. echo "Set BUCKET, PROJECT, and REVISION env vars to upload docs"; \
  37. exit 1; fi
  38. @cd doc; s3cmd put -P * "s3://${BUCKET}/${PROJECT}/${REVISION}/" > /dev/null
  39. @echo "Docs built at: http://${BUCKET}.s3-website-us-east-1.amazonaws.com/${PROJECT}/${REVISION}"
  40. docs:
  41. ${REBAR} doc skip_deps=true
  42. xref: compile
  43. ${REBAR} xref skip_deps=true
  44. PLT ?= $(HOME)/.combo_dialyzer_plt
  45. LOCAL_PLT = .local_dialyzer_plt
  46. DIALYZER_FLAGS ?= -Wunmatched_returns
  47. ${PLT}: compile
  48. @if [ -f $(PLT) ]; then \
  49. dialyzer --check_plt --plt $(PLT) --apps $(DIALYZER_APPS) && \
  50. dialyzer --add_to_plt --plt $(PLT) --output_plt $(PLT) --apps $(DIALYZER_APPS) ; test $$? -ne 1; \
  51. else \
  52. dialyzer --build_plt --output_plt $(PLT) --apps $(DIALYZER_APPS); test $$? -ne 1; \
  53. fi
  54. ${LOCAL_PLT}: compile
  55. @if [ -d deps ]; then \
  56. if [ -f $(LOCAL_PLT) ]; then \
  57. dialyzer --check_plt --plt $(LOCAL_PLT) deps/*/ebin && \
  58. dialyzer --add_to_plt --plt $(LOCAL_PLT) --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1; \
  59. else \
  60. dialyzer --build_plt --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1; \
  61. fi \
  62. fi
  63. dialyzer-run:
  64. @echo "==> $(shell basename $(shell pwd)) (dialyzer)"
  65. # The bulk of the code below deals with the dialyzer.ignore-warnings file
  66. # which contains strings to ignore if output by dialyzer.
  67. # Typically the strings include line numbers. Using them exactly is hard
  68. # to maintain as the code changes. This approach instead ignores the line
  69. # numbers, but takes into account the number of times a string is listed
  70. # for a given file. So if one string is listed once, for example, and it
  71. # appears twice in the warnings, the user is alerted. It is possible but
  72. # unlikely that this approach could mask a warning if one ignored warning
  73. # is removed and two warnings of the same kind appear in the file, for
  74. # example. But it is a trade-off that seems worth it.
  75. # Details of the cryptic commands:
  76. # - Remove line numbers from dialyzer.ignore-warnings
  77. # - Pre-pend duplicate count to each warning with sort | uniq -c
  78. # - Remove annoying white space around duplicate count
  79. # - Save in dialyer.ignore-warnings.tmp
  80. # - Do the same to dialyzer_warnings
  81. # - Remove matches from dialyzer.ignore-warnings.tmp from output
  82. # - Remove duplicate count
  83. # - Escape regex special chars to use lines as regex patterns
  84. # - Add pattern to match any line number (file.erl:\d+:)
  85. # - Anchor to match the entire line (^entire line$)
  86. # - Save in dialyzer_unhandled_warnings
  87. # - Output matches for those patterns found in the original warnings
  88. @if [ -f $(LOCAL_PLT) ]; then \
  89. PLTS="$(PLT) $(LOCAL_PLT)"; \
  90. else \
  91. PLTS=$(PLT); \
  92. fi; \
  93. if [ -f dialyzer.ignore-warnings ]; then \
  94. if [ $$(grep -cvE '[^[:space:]]' dialyzer.ignore-warnings) -ne 0 ]; then \
  95. echo "ERROR: dialyzer.ignore-warnings contains a blank/empty line, this will match all messages!"; \
  96. exit 1; \
  97. fi; \
  98. dialyzer $(DIALYZER_FLAGS) --plts $${PLTS} -c ebin > dialyzer_warnings ; \
  99. cat dialyzer.ignore-warnings \
  100. | sed -E 's/^([^:]+:)[^:]+:/\1/' \
  101. | sort \
  102. | uniq -c \
  103. | sed -E '/.*\.erl: /!s/^[[:space:]]*[0-9]+[[:space:]]*//' \
  104. > dialyzer.ignore-warnings.tmp ; \
  105. egrep -v "^[[:space:]]*(done|Checking|Proceeding|Compiling)" dialyzer_warnings \
  106. | sed -E 's/^([^:]+:)[^:]+:/\1/' \
  107. | sort \
  108. | uniq -c \
  109. | sed -E '/.*\.erl: /!s/^[[:space:]]*[0-9]+[[:space:]]*//' \
  110. | grep -F -f dialyzer.ignore-warnings.tmp -v \
  111. | sed -E 's/^[[:space:]]*[0-9]+[[:space:]]*//' \
  112. | sed -E 's/([]\^:+?|()*.$${}\[])/\\\1/g' \
  113. | sed -E 's/(\\\.erl\\\:)/\1\\d+:/g' \
  114. | sed -E 's/^(.*)$$/^\1$$/g' \
  115. > dialyzer_unhandled_warnings ; \
  116. rm dialyzer.ignore-warnings.tmp; \
  117. if [ $$(cat dialyzer_unhandled_warnings | wc -l) -gt 0 ]; then \
  118. egrep -f dialyzer_unhandled_warnings dialyzer_warnings ; \
  119. found_warnings=1; \
  120. fi; \
  121. [ "$$found_warnings" != 1 ] ; \
  122. else \
  123. dialyzer $(DIALYZER_FLAGS) --plts $${PLTS} -c ebin; \
  124. fi
  125. dialyzer-quick: compile-no-deps dialyzer-run
  126. dialyzer: ${PLT} ${LOCAL_PLT} dialyzer-run
  127. cleanplt:
  128. @echo
  129. @echo "Are you sure? It takes several minutes to re-build."
  130. @echo Deleting $(PLT) and $(LOCAL_PLT) in 5 seconds.
  131. @echo
  132. sleep 5
  133. rm $(PLT)
  134. rm $(LOCAL_PLT)