-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMakefile
115 lines (93 loc) · 3.49 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Makefile for Pynq
SHELL := /bin/bash
# Internal variables.
file_version=0.1.0
root_dir=.
build_dir=${root_dir}/build
src_dir=${root_dir}/pynq
tests_dir=${root_dir}/tests
unit_tests_dir=${tests_dir}/unit
functional_tests_dir=${tests_dir}/functional
compile_log_file=${build_dir}/compile.log
unit_log_file=${build_dir}/unit.log
functional_log_file=${build_dir}/functional.log
nocoverage=false
help:
@echo
@echo " Pynq Makefile v${file_version}"
@echo " usage: make <target>"
@echo
@echo " targets:"
@echo " help displays this help text"
@echo " all compiles the code and runs all tests"
@echo " clean cleans the build directory"
@echo " compile compiles the python code"
@echo " test runs all tests (unit and functional)"
@echo " unit runs all unit tests"
@echo " functional runs all functional tests"
@echo " codeanalyis generates code analysis info"
@echo " sdist creates a source-based distribution"
@echo " deb creates a debian-based distribution"
@echo
# orchestrator targets
unit: prepare_build compile run_unit report_success
functional: prepare_build compile run_functional report_success
all: prepare_build compile test report_success
prepare_build: clean create_build_dir
test: run_unit run_functional
clean: remove_build_dir remove_dist_dir
# action targets
report_success:
@echo "Build succeeded!"
remove_build_dir:
@rm -fr ${build_dir}
remove_dist_dir:
@rm -fr dist/
@rm -fr Pynq.egg-info/
create_build_dir:
@mkdir -p ${build_dir}
compile:
@echo "Compiling source code..."
@rm -f ${compile_log_file} >> /dev/null
@rm -f -r ${src_dir}/*.pyc >> /dev/null
@python -m compileall ${src_dir} >> ${compile_log_file} 2>> ${compile_log_file}
run_unit: compile
@echo "Running unit tests..."
@rm -f ${unit_log_file} >> /dev/null
@if [ "$(nocoverage)" = "true" ]; then nosetests --verbose ${unit_tests_dir} >> ${unit_log_file} 2>> ${unit_log_file}; else nosetests --verbose --with-coverage --cover-package=pynq ${unit_tests_dir} >> ${unit_log_file} 2>> ${unit_log_file}; fi
@echo "============="
@echo "Unit coverage"
@echo "============="
@if [ "$(nocoverage)" != "true" ]; then cat ${unit_log_file} | egrep '(Name)|(TOTAL)'; fi
@if [ "$(nocoverage)" = "true" ]; then echo 'Coverage Disabled.'; fi
@echo
run_functional: compile
@echo "Running functional tests..."
@rm -f ${functional_log_file} >> /dev/null
@if [ "$(nocoverage)" = "true" ]; then nosetests --verbose ${functional_tests_dir} >> ${functional_log_file} 2>> ${functional_log_file}; else nosetests --verbose --with-coverage --cover-package=pynq ${functional_tests_dir} >> ${functional_log_file} 2>> ${functional_log_file}; fi
@echo "==================="
@echo "Functional coverage"
@echo "==================="
@if [ "$(nocoverage)" != "true" ]; then cat ${functional_log_file} | egrep '(Name)|(TOTAL)'; fi
@if [ "$(nocoverage)" = "true" ]; then echo 'Coverage Disabled.'; fi
@echo
codeanalysis:
@echo "Generating code analysis..."
@sloccount ${root_dir}
sdist:
@echo "===================================="
@echo "Generating Source-Based Distribution"
@echo "===================================="
@rm -fr dist
@python setup.py sdist
deb:
@echo "=============================="
@echo "Generating Debian Distribution"
@echo "=============================="
mv .git /tmp/pynq_git
debuild
mkdir -p dist
cp ../python-pynq_* ./dist
rm -f ../python-pynq_*
debuild clean
mv /tmp/pynq_git .git