forked from RoboJackets/robocup-software
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
169 lines (145 loc) · 5.68 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
MAKE_FLAGS = --no-print-directory
TESTS = *
FIRMWR_TESTS = -i2c -io-expander -fpga -piezo -neopixel -attiny -led -radio-sender -radio-receiver
# circleci has 2 cores, but advertises 32, which causes OOMs
ifeq ($(CIRCLECI), true)
NINJA_FLAGS=-j2
endif
# build a specified target with CMake and Ninja
# usage: $(call cmake_build_target, target, extraCmakeFlags)
define cmake_build_target
mkdir -p build
cd build && cmake -GNinja -Wno-dev -DCMAKE_BUILD_TYPE=Debug --target $1 $2 .. && ninja $(NINJA_FLAGS) $1
endef
define cmake_build_target_release
mkdir -p build
cd build && cmake -GNinja -Wno-dev -DCMAKE_BUILD_TYPE=Release --target $1 $2 .. && ninja $(NINJA_FLAGS) $1
endef
define cmake_build_target_perf
mkdir -p build
cd build && cmake -GNinja -Wno-dev -DCMAKE_BUILD_TYPE=RelWithDebInfo --target $1 $2 .. && ninja $(NINJA_FLAGS) $1
endef
all:
$(call cmake_build_target, all)
all-release:
$(call cmake_build_target_release, all)
all-perf:
$(call cmake_build_target_perf, all)
perf: all-perf
run: all
./run/soccer
run-comp:
./runcomp.sh
r: run
rs: run-sim
run-sim: all backend-headless-simulator-soccer
run-headmore: all backend-simulator-soccer
run-sim2play: all
-pkill -f './grsim'
./run/grsim &
@echo '!!![WARNING]!!! Multiple soccer instances will not work unless your grSim is broadcasting over the proper IP.'
@echo 'Please set your grSim broadcast IP to "224.5.23.2:10020", or you will experience issues.'
./run/soccer -sim -b & sleep 2 && ./run/soccer -sim -y -defend plus
-pkill -f './grsim'
run-release: all-release
./run/soccer
run-sim-release: all-release backend-headless-simulator-soccer
rsr: run-sim-release
rrs: rsr
rr: run-release
view:
./run/soccer -vlog $(file)
# backend targets to launch soccer with grsim in headless
backend-headless-simulator-soccer:
-pkill -f './grsim'
./run/grsim --headless &
./run/soccer -sim -pbk testing.pbk
# Kill grSim once we unblock
-pkill -f './grsim'
# backend targets to launch soccer with a grsim window
backend-simulator-soccer:
-pkill -f './grsim'
./run/grsim &
./run/soccer -sim -pbk testing.pbk
# Kill grSim once we unblock
-pkill -f './grsim'
debug: all
ifeq ($(shell uname), Linux)
gdb ./run/soccer
else
lldb ./run/soccer.app
endif
debug-sim: all
-pkill -f './grsim'
./run/grsim &
ifeq ($(shell uname), Linux)
gdb --args ./run/soccer -sim
else
lldb -- ./run/soccer.app -sim
endif
# Run both C++ and python unit tests
tests: test-cpp test-python
test-cpp: test-soccer
test-soccer:
$(call cmake_build_target, test-soccer)
run/test-soccer --gtest_filter=$(TESTS)
test-python: all
cd soccer/gameplay && ./run_tests.sh
pylint:
pylint -j8 --reports=n soccer/gameplay
mypy:
mypy soccer/gameplay
COV_BUILD_DIR=build/coverage
coverage:
mkdir -p ${COV_BUILD_DIR}
cd ${COV_BUILD_DIR} && cmake -GNinja -Wno-dev --target test-soccer \
-D CMAKE_CXX_FLAGS="--coverage" ../../ && ninja $(NINJA_FLAGS) test-soccer
run/test-soccer # Kind of hacky, but w/e
-coveralls -b ${COV_BUILD_DIR} -r . \
-e ${COV_BUILD_DIR}/tmp/ -e ${COV_BUILD_DIR}/src/ \
-E '(^.*((moc_)|(automoc)|(ui_)|([Tt]est)).*$$)|(^.*((include)|(mbed)|(googletest)|(gtest)|(protobuf)|(qt5)).*$$)' \
--gcov-options '\-lp'
behavior-diagrams: all
cd soccer/gameplay && python3 generate_fsm_diagrams.py
@echo -e "\n=> Open up 'soccer/gameplay/diagrams' to view behavior state machine diagrams"
clean:
cd build && ninja clean || true
rm -rf build
static-analysis:
mkdir -p build/static-analysis
cd build/static-analysis; scan-build cmake ../.. -Wno-dev -DSTATIC_ANALYSIS=ON && scan-build -o output make $(MAKE_FLAGS)
modernize:
# Runs CMake with a sepcial flag telling it to output the compilation
# database, which lists the files to be compiled and the flags passed to
# the compiler for each one. Then runs clang-modernize, using the
# compilation database as input, on all c/c++ files in the repo.
mkdir -p build/modernize
cd build/modernize; cmake ../.. -Wno-dev -DCMAKE_EXPORT_COMPILE_COMMANDS=ON && make $(MAKE_FLAGS)
# You can pass specific flags to clang-modernize if you want it to only run some types of
# transformations, rather than all transformations that it's capable of.
# See `clang-modernize --help` for more info.
clang-modernize -p build/modernize -include=common,logging,soccer
apidocs:
doxygen doc/Doxyfile
cp doc/doxygen.css api_docs/html/
@echo "\n=> Open up 'api_docs/html/index.html' in a browser to view a local copy of the documentation"
STYLIZE_DIFFBASE ?= master
# automatically format code according to our style config defined in .clang-format
pretty:
@stylize.v1 -i --git_diffbase=$(STYLIZE_DIFFBASE)
# check if everything in our codebase is in accordance with the style config defined in .clang-format
# a nonzero exit code indicates that there's a formatting error somewhere
checkstyle:
@printf "Run this command to reformat code if needed:\n\ngit apply <(curl -L $${LINK_PREFIX:-file://}clean.patch)\n\n"
@stylize.v1 --git_diffbase=$(STYLIZE_DIFFBASE) --patch_output "$${CIRCLE_ARTIFACTS:-.}/clean.patch"
# Option to use old version of stylize
STYLE_EXCLUDE_DIRS=build \
external
# automatically format code according to our style config defined in .clang-format
pretty-old:
@stylize --diffbase=$(STYLIZE_DIFFBASE) --clang_style=file --yapf_style=.style.yapf --exclude_dirs $(STYLE_EXCLUDE_DIRS)
# check if everything in our codebase is in accordance with the style config defined in .clang-format
# a nonzero exit code indicates that there's a formatting error somewhere
checkstyle-old:
@printf "Run this command to reformat code if needed:\n\ngit apply <(curl -L $${LINK_PREFIX:-file://}clean.patch)\n\n"
@stylize --diffbase=$(STYLIZE_DIFFBASE) --clang_style=file --yapf_style=.style.yapf --exclude_dirs $(STYLE_EXCLUDE_DIRS) --check --output_patch_file="/tmp/clean.patch"