|
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 |
| -# ------------------------------------------------------------------- |
22 |
| -# NOTE: This file is is from https://github.com/basho/tools.mk. |
23 |
| -# It should not be edited in a project. It should simply be updated |
24 |
| -# wholesale when a new version of tools.mk is released. |
25 |
| -# ------------------------------------------------------------------- |
26 |
| - |
27 | 1 | REBAR ?= ./rebar
|
28 |
| -REVISION ?= $(shell git rev-parse --short HEAD) |
29 |
| -PROJECT ?= $(shell basename `find src -name "*.app.src"` .app.src) |
30 |
| -DEP_DIR ?= "deps" |
31 |
| -EBIN_DIR ?= "ebin" |
32 |
| - |
33 |
| -.PHONY: compile-no-deps test docs xref dialyzer-run dialyzer-quick dialyzer \ |
34 |
| - cleanplt upload-docs |
35 |
| - |
36 |
| -compile-no-deps: |
37 |
| - ${REBAR} compile skip_deps=true |
38 | 2 |
|
39 | 3 | test: compile
|
40 | 4 | ${REBAR} eunit skip_deps=true
|
41 | 5 |
|
42 |
| -upload-docs: docs |
43 |
| - @if [ -z "${BUCKET}" -o -z "${PROJECT}" -o -z "${REVISION}" ]; then \ |
44 |
| - echo "Set BUCKET, PROJECT, and REVISION env vars to upload docs"; \ |
45 |
| - exit 1; fi |
46 |
| - @cd doc; s3cmd put -P * "s3://${BUCKET}/${PROJECT}/${REVISION}/" > /dev/null |
47 |
| - @echo "Docs built at: http://${BUCKET}.s3-website-us-east-1.amazonaws.com/${PROJECT}/${REVISION}" |
48 |
| - |
49 | 6 | docs:
|
50 | 7 | ${REBAR} doc skip_deps=true
|
51 | 8 |
|
52 | 9 | xref: compile
|
53 | 10 | ${REBAR} xref skip_deps=true
|
54 | 11 |
|
55 |
| -dialyzer: compile |
56 |
| - ${REBAR} dialyzer |
| 12 | +PLT ?= $(HOME)/.combo_dialyzer_plt |
| 13 | +LOCAL_PLT = .local_dialyzer_plt |
| 14 | +DIALYZER_FLAGS ?= -Wunmatched_returns -Werror_handling -Wrace_conditions -Wunderspecs |
| 15 | + |
| 16 | +${PLT}: compile |
| 17 | + @if [ -f $(PLT) ]; then \ |
| 18 | + dialyzer --check_plt --plt $(PLT) --apps $(DIALYZER_APPS) && \ |
| 19 | + dialyzer --add_to_plt --plt $(PLT) --output_plt $(PLT) --apps $(DIALYZER_APPS) ; test $$? -ne 1; \ |
| 20 | + else \ |
| 21 | + dialyzer --build_plt --output_plt $(PLT) --apps $(DIALYZER_APPS); test $$? -ne 1; \ |
| 22 | + fi |
| 23 | + |
| 24 | +${LOCAL_PLT}: compile |
| 25 | + @if [ -d deps ]; then \ |
| 26 | + if [ -f $(LOCAL_PLT) ]; then \ |
| 27 | + dialyzer --check_plt --plt $(LOCAL_PLT) deps/*/ebin && \ |
| 28 | + dialyzer --add_to_plt --plt $(LOCAL_PLT) --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1; \ |
| 29 | + else \ |
| 30 | + dialyzer --build_plt --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1; \ |
| 31 | + fi \ |
| 32 | + fi |
| 33 | + |
| 34 | +dialyzer: ${PLT} ${LOCAL_PLT} |
| 35 | + @echo "==> $(shell basename $(shell pwd)) (dialyzer)" |
| 36 | + @if [ -f $(LOCAL_PLT) ]; then \ |
| 37 | + PLTS="$(PLT) $(LOCAL_PLT)"; \ |
| 38 | + else \ |
| 39 | + PLTS=$(PLT); \ |
| 40 | + fi; \ |
| 41 | + if [ -f dialyzer.ignore-warnings ]; then \ |
| 42 | + if [ $$(grep -cvE '[^[:space:]]' dialyzer.ignore-warnings) -ne 0 ]; then \ |
| 43 | + echo "ERROR: dialyzer.ignore-warnings contains a blank/empty line, this will match all messages!"; \ |
| 44 | + exit 1; \ |
| 45 | + fi; \ |
| 46 | + dialyzer $(DIALYZER_FLAGS) --plts $${PLTS} -c ebin > dialyzer_warnings ; \ |
| 47 | + egrep -v "^[[:space:]]*(done|Checking|Proceeding|Compiling)" dialyzer_warnings | grep -F -f dialyzer.ignore-warnings -v > dialyzer_unhandled_warnings ; \ |
| 48 | + cat dialyzer_unhandled_warnings ; \ |
| 49 | + [ $$(cat dialyzer_unhandled_warnings | wc -l) -eq 0 ] ; \ |
| 50 | + else \ |
| 51 | + dialyzer $(DIALYZER_FLAGS) --plts $${PLTS} -c ebin; \ |
| 52 | + fi |
| 53 | + |
| 54 | +cleanplt: |
| 55 | + @echo |
| 56 | + @echo "Are you sure? It takes several minutes to re-build." |
| 57 | + @echo Deleting $(PLT) and $(LOCAL_PLT) in 5 seconds. |
| 58 | + @echo |
| 59 | + sleep 5 |
| 60 | + rm $(PLT) |
| 61 | + rm $(LOCAL_PLT) |
| 62 | + |
0 commit comments