1 # A sample Makefile for building Google Test and using it in user
2 # A sample Makefile for building Google Test and using it in user
3 # tests. Please tweak it to suit your environment and project. You
4 # may want to move it to your project's root directory.
8 # make [all] - makes everything.
9 # make TARGET - makes the given target.
10 # make clean - removes all files generated by make.
13 # Where to find user code.
17 OBJECT_DIR
= ..
/..
/obj
/test
18 TARGET_DIR
= $(USER_DIR
)/target
20 include $(ROOT
)/make
/system-id.mk
21 include $(ROOT
)/make
/targets_list.mk
23 VPATH
:= $(VPATH
):$(USER_DIR
):$(TEST_DIR
)
25 # specify which files that are included in the test in addition to the unittest file.
26 # variables available:
29 # <test_name>_INCLUDE_DIRS
30 # <test_name>_EXPAND (run for each target, call the above with target as $1)
31 # <test_name>_BLACKLIST (targets to exclude from an expanded test's run)
33 alignsensor_unittest_SRC
:= \
34 $(USER_DIR
)/sensors
/boardalignment.c \
35 $(USER_DIR
)/common
/sensor_alignment.c \
36 $(USER_DIR
)/common
/maths.c
38 arming_prevention_unittest_SRC
:= \
39 $(USER_DIR
)/fc/core.c \
40 $(USER_DIR
)/fc/dispatch.c \
41 $(USER_DIR
)/fc/rc_controls.c \
42 $(USER_DIR
)/fc/rc_modes.c \
43 $(USER_DIR
)/fc/runtime_config.c \
44 $(USER_DIR
)/flight
/gps_rescue.c \
45 $(USER_DIR
)/common
/bitarray.c
47 arming_prevention_unittest_DEFINES
:= \
50 atomic_unittest_SRC
:= \
51 $(USER_DIR
)/build
/atomic.c \
52 $(TEST_DIR
)/atomic_unittest_c.c
54 # This test is disabled due to build errors.
55 # Its source code is archived in unit/baro_bmp085_unittest.cc.txt
57 #baro_bmp085_unittest_SRC := \
58 # $(USER_DIR)/drivers/barometer/barometer_bmp085.c \
59 # $(USER_DIR)/drivers/io.c
62 baro_bmp280_unittest_SRC
:= \
63 $(USER_DIR
)/drivers
/barometer
/barometer_bmp280.c
65 baro_bmp280_unittest_DEFINES
:= \
69 baro_bmp388_unittest_SRC
:= \
70 $(USER_DIR
)/common
/maths.c \
71 $(USER_DIR
)/drivers
/barometer
/barometer_bmp388.c
73 baro_bmp388_unittest_DEFINES
:= \
78 baro_ms5611_unittest_SRC
:= \
79 $(USER_DIR
)/drivers
/barometer
/barometer_ms5611.c
81 baro_ms5611_unittest_DEFINES
:= \
85 # This test is disabled due to build errors.
86 # Its source code is archived in unit/battery_unittest.cc.txt
88 #battery_unittest_SRC := \
89 # $(USER_DIR)/sensors/battery.c \
90 # $(USER_DIR)/common/maths.c
93 blackbox_unittest_SRC
:= \
94 $(USER_DIR
)/blackbox
/blackbox.c \
95 $(USER_DIR
)/blackbox
/blackbox_encoding.c \
96 $(USER_DIR
)/blackbox
/blackbox_io.c \
97 $(USER_DIR
)/common
/encoding.c \
98 $(USER_DIR
)/common
/printf.c \
99 $(USER_DIR
)/common
/maths.c \
100 $(USER_DIR
)/common
/typeconversion.c \
101 $(USER_DIR
)/drivers
/accgyro
/gyro_sync.c
103 blackbox_encoding_unittest_SRC
:= \
104 $(USER_DIR
)/blackbox
/blackbox_encoding.c \
105 $(USER_DIR
)/common
/encoding.c \
106 $(USER_DIR
)/common
/printf.c \
107 $(USER_DIR
)/common
/typeconversion.c
109 cli_unittest_SRC
:= \
110 $(USER_DIR
)/cli
/cli.c \
111 $(USER_DIR
)/common
/printf.c \
112 $(USER_DIR
)/config
/feature.c \
113 $(USER_DIR
)/pg
/pg.c \
114 $(USER_DIR
)/common
/typeconversion.c
116 cli_unittest_DEFINES
:= \
119 SystemCoreClock
=1000000
121 cms_unittest_SRC
:= \
122 $(USER_DIR
)/cms
/cms.c \
123 $(USER_DIR
)/cms
/cms_menu_saveexit.c \
124 $(USER_DIR
)/common
/typeconversion.c \
125 $(USER_DIR
)/drivers
/display.c
128 common_filter_unittest_SRC
:= \
129 $(USER_DIR
)/common
/filter.c \
130 $(USER_DIR
)/common
/maths.c
133 encoding_unittest_SRC
:= \
134 $(USER_DIR
)/common
/encoding.c
137 flight_failsafe_unittest_SRC
:= \
138 $(USER_DIR
)/common
/bitarray.c \
139 $(USER_DIR
)/fc/rc_modes.c \
140 $(USER_DIR
)/fc/runtime_config.c \
141 $(USER_DIR
)/flight
/failsafe.c
143 flight_failsafe_unittest_DEFINES
:= \
147 flight_imu_unittest_SRC
:= \
148 $(USER_DIR
)/common
/bitarray.c \
149 $(USER_DIR
)/common
/maths.c \
150 $(USER_DIR
)/config
/feature.c \
151 $(USER_DIR
)/fc/rc_modes.c \
152 $(USER_DIR
)/flight
/position.c \
153 $(USER_DIR
)/flight
/imu.c
156 flight_mixer_unittest
:= \
157 $(USER_DIR
)/flight
/mixer.c \
158 $(USER_DIR
)/flight
/servos.c \
159 $(USER_DIR
)/common
/maths.c
162 gps_conversion_unittest_SRC
:= \
163 $(USER_DIR
)/common
/gps_conversion.c
166 io_serial_unittest_SRC
:= \
167 $(USER_DIR
)/io
/serial.c \
168 $(USER_DIR
)/drivers
/serial_pinconfig.c
171 ledstrip_unittest_SRC
:= \
172 $(USER_DIR
)/common
/bitarray.c \
173 $(USER_DIR
)/fc/rc_modes.c \
174 $(USER_DIR
)/io
/ledstrip.c
176 ledstrip_unittest_DEFINES
:= \
180 maths_unittest_SRC
:= \
181 $(USER_DIR
)/common
/maths.c
184 osd_unittest_SRC
:= \
185 $(USER_DIR
)/osd
/osd.c \
186 $(USER_DIR
)/osd
/osd_elements.c \
187 $(USER_DIR
)/common
/typeconversion.c \
188 $(USER_DIR
)/drivers
/display.c \
189 $(USER_DIR
)/common
/maths.c \
190 $(USER_DIR
)/common
/printf.c \
191 $(USER_DIR
)/common
/time.c \
192 $(USER_DIR
)/fc/runtime_config.c
194 osd_unittest_DEFINES
:= \
200 link_quality_unittest_SRC
:= \
201 $(USER_DIR
)/osd
/osd.c \
202 $(USER_DIR
)/osd
/osd_elements.c \
203 $(USER_DIR
)/common
/typeconversion.c \
204 $(USER_DIR
)/drivers
/display.c \
205 $(USER_DIR
)/drivers
/serial.c \
206 $(USER_DIR
)/common
/crc.c \
207 $(USER_DIR
)/common
/maths.c \
208 $(USER_DIR
)/common
/printf.c \
209 $(USER_DIR
)/common
/streambuf.c \
210 $(USER_DIR
)/common
/time.c \
211 $(USER_DIR
)/fc/runtime_config.c \
212 $(USER_DIR
)/common
/bitarray.c \
213 $(USER_DIR
)/fc/rc_modes.c \
214 $(USER_DIR
)/rx
/rx.c \
215 $(USER_DIR
)/pg
/pg.c \
216 $(USER_DIR
)/rx
/crsf.c \
219 link_quality_unittest_DEFINES
:= \
221 USE_CRSF_LINK_STATISTICS
= \
222 USE_RX_LINK_QUALITY_INFO
=
228 rc_controls_unittest_SRC
:= \
229 $(USER_DIR
)/fc/rc_controls.c \
230 $(USER_DIR
)/pg
/pg.c \
231 $(USER_DIR
)/common
/bitarray.c \
232 $(USER_DIR
)/common
/maths.c \
233 $(USER_DIR
)/fc/rc_adjustments.c \
234 $(USER_DIR
)/fc/rc_modes.c
237 rx_crsf_unittest_SRC
:= \
238 $(USER_DIR
)/rx
/crsf.c \
239 $(USER_DIR
)/common
/crc.c \
240 $(USER_DIR
)/common
/printf.c \
241 $(USER_DIR
)/common
/typeconversion.c \
242 $(USER_DIR
)/common
/streambuf.c \
243 $(USER_DIR
)/drivers
/serial.c
246 rx_ibus_unittest_SRC
:= \
247 $(USER_DIR
)/rx
/ibus.c
250 rx_ranges_unittest_SRC
:= \
251 $(USER_DIR
)/common
/bitarray.c \
252 $(USER_DIR
)/common
/maths.c \
253 $(USER_DIR
)/fc/rc_modes.c \
254 $(USER_DIR
)/rx
/rx.c \
255 $(USER_DIR
)/pg
/pg.c \
259 rx_rx_unittest_SRC
:= \
260 $(USER_DIR
)/rx
/rx.c \
261 $(USER_DIR
)/fc/rc_modes.c \
262 $(USER_DIR
)/common
/bitarray.c \
263 $(USER_DIR
)/common
/maths.c \
264 $(USER_DIR
)/config
/feature.c \
267 rx_sumd_unittest_SRC
:= \
268 $(USER_DIR
)/common
/crc.c \
269 $(USER_DIR
)/common
/streambuf.c \
270 $(USER_DIR
)/rx
/sumd.c
272 scheduler_unittest_SRC
:= \
273 $(USER_DIR
)/scheduler
/scheduler.c \
274 $(USER_DIR
)/common
/crc.c \
275 $(USER_DIR
)/common
/streambuf.c
278 sensor_gyro_unittest_SRC
:= \
279 $(USER_DIR
)/sensors
/gyro.c \
280 $(USER_DIR
)/sensors
/boardalignment.c \
281 $(USER_DIR
)/common
/filter.c \
282 $(USER_DIR
)/common
/maths.c \
283 $(USER_DIR
)/common
/sensor_alignment.c \
284 $(USER_DIR
)/drivers
/accgyro
/accgyro_fake.c \
285 $(USER_DIR
)/drivers
/accgyro
/gyro_sync.c \
286 $(USER_DIR
)/pg
/pg.c \
287 $(USER_DIR
)/pg
/gyrodev.c
289 telemetry_crsf_unittest_SRC
:= \
290 $(USER_DIR
)/rx
/crsf.c \
291 $(USER_DIR
)/telemetry
/crsf.c \
292 $(USER_DIR
)/common
/crc.c \
293 $(USER_DIR
)/common
/maths.c \
294 $(USER_DIR
)/common
/streambuf.c \
295 $(USER_DIR
)/common
/gps_conversion.c \
296 $(USER_DIR
)/common
/printf.c \
297 $(USER_DIR
)/common
/typeconversion.c \
298 $(USER_DIR
)/fc/runtime_config.c
300 telemetry_crsf_unittest_DEFINES
:= \
304 __REVISION__
="revision"
307 telemetry_crsf_msp_unittest_SRC
:= \
308 $(USER_DIR
)/rx
/crsf.c \
309 $(USER_DIR
)/build
/atomic.c \
310 $(USER_DIR
)/common
/crc.c \
311 $(USER_DIR
)/common
/streambuf.c \
312 $(USER_DIR
)/common
/printf.c \
313 $(USER_DIR
)/common
/streambuf.c \
314 $(USER_DIR
)/drivers
/serial.c \
315 $(USER_DIR
)/common
/typeconversion.c \
316 $(USER_DIR
)/telemetry
/crsf.c \
317 $(USER_DIR
)/common
/gps_conversion.c \
318 $(USER_DIR
)/telemetry
/msp_shared.c \
319 $(USER_DIR
)/fc/runtime_config.c
321 telemetry_crsf_msp_unittest_DEFINES
:= \
322 USE_MSP_OVER_TELEMETRY
=
325 telemetry_hott_unittest_SRC
:= \
326 $(USER_DIR
)/telemetry
/hott.c \
327 $(USER_DIR
)/common
/gps_conversion.c
330 telemetry_ibus_unittest_SRC
:= \
331 $(USER_DIR
)/telemetry
/ibus_shared.c \
332 $(USER_DIR
)/telemetry
/ibus.c
334 timer_definition_unittest_EXPAND
:= yes
336 # SITL is a simulator with empty timerHardware and many hearders in target.c.
337 timer_definition_unittest_BLACKLIST
:= SITL
339 timer_definition_unittest_SRC
= \
340 $(TARGET_DIR
)/$(call get_base_target
,$1)/target.c
342 timer_definition_unittest_DEFINES
= \
344 BASE_TARGET
=$(call get_base_target
,$1)
346 timer_definition_unittest_INCLUDE_DIRS
= \
347 $(TEST_DIR
)/timer_definition_unittest.
include \
348 $(TARGET_DIR
)/$(call get_base_target
,$1)
350 transponder_ir_unittest_SRC
:= \
351 $(USER_DIR
)/drivers
/transponder_ir_ilap.c \
352 $(USER_DIR
)/drivers
/transponder_ir_arcitimer.c
354 ws2811_unittest_SRC
:= \
355 $(USER_DIR
)/drivers
/light_ws2811strip.c
357 huffman_unittest_SRC
:= \
358 $(USER_DIR
)/common
/huffman.c \
359 $(USER_DIR
)/common
/huffman_table.c
361 huffman_unittest_DEFINES
:= \
364 rcdevice_unittest_SRC
:= \
365 $(USER_DIR
)/common
/crc.c \
366 $(USER_DIR
)/common
/bitarray.c \
367 $(USER_DIR
)/fc/rc_modes.c \
368 $(USER_DIR
)/io
/rcdevice.c \
369 $(USER_DIR
)/io
/rcdevice_cam.c \
370 $(USER_DIR
)/pg
/pg.c \
372 pid_unittest_SRC
:= \
373 $(USER_DIR
)/common
/filter.c \
374 $(USER_DIR
)/common
/maths.c \
375 $(USER_DIR
)/drivers
/accgyro
/gyro_sync.c \
376 $(USER_DIR
)/fc/runtime_config.c \
377 $(USER_DIR
)/flight
/pid.c \
380 pid_unittest_DEFINES
:= \
382 USE_RC_SMOOTHING_FILTER
= \
383 USE_ABSOLUTE_CONTROL
= \
386 rcdevice_unittest_DEFINES
:= \
389 vtx_unittest_SRC
:= \
390 $(USER_DIR
)/fc/core.c \
391 $(USER_DIR
)/fc/dispatch.c \
392 $(USER_DIR
)/fc/rc_controls.c \
393 $(USER_DIR
)/fc/rc_modes.c \
394 $(USER_DIR
)/fc/runtime_config.c \
395 $(USER_DIR
)/drivers
/vtx_common.c \
396 $(USER_DIR
)/drivers
/vtx_table.c \
397 $(USER_DIR
)/io
/vtx_control.c \
398 $(USER_DIR
)/io
/vtx.c \
399 $(USER_DIR
)/common
/bitarray.c
401 vtx_unittest_DEFINES
:= \
406 rx_spi_spektrum_unittest_SRC
:= \
407 $(USER_DIR
)/rx
/cyrf6936_spektrum.c
409 rx_spi_spektrum_unittest_DEFINES
:= \
413 # Please tweak the following variable definitions as needed by your
414 # project, except GTEST_HEADERS, which you can use in your own targets
415 # but shouldn't modify.
417 # Points to the root of Google Test, relative to where this file is.
418 # Remember to tweak this if you move this file.
419 GTEST_DIR
= ..
/..
/lib
/test/gtest
421 # Use clang/clang++ by default
432 -Wno-error
=unused-command-line-argument \
436 -isystem
$(GTEST_DIR
)/inc \
439 ifeq ($(shell $(CC
) -v
2>&1 | grep
-q
"clang version" && echo
"clang"),clang
)
440 COMMON_FLAGS
+= -fblocks
442 LDFLAGS
+= -lBlocksRuntime
457 COMMON_FLAGS
+= -pthread
460 # Flags passed to the C compiler.
461 C_FLAGS
= $(COMMON_FLAGS
) \
464 # Flags passed to the C++ compiler.
465 CXX_FLAGS
= $(COMMON_FLAGS
) \
468 # Compiler flags for coverage instrumentation
470 COVERAGE_FLAGS
:= --coverage
473 C_FLAGS
+= $(COVERAGE_FLAGS
)
474 CXX_FLAGS
+= $(COVERAGE_FLAGS
)
476 C_FLAGS
+= -D_GNU_SOURCE
478 # Set up the parameter group linker flags according to OS
480 LDFLAGS
+= -Wl
,-map
,$(OBJECT_DIR
)/$@.map
482 LDFLAGS
+= -Wl
,-T
,$(TEST_DIR
)/pg.
ld -Wl
,-Map
,$(OBJECT_DIR
)/$@.map
485 # Gather up all of the tests.
486 TEST_SRCS
= $(sort $(wildcard $(TEST_DIR
)/*.
cc))
487 TEST_BASENAMES
= $(TEST_SRCS
:$(TEST_DIR
)/%.
cc=%)
488 TESTS_TARGET_SPECIFIC
= $(foreach test,$(TEST_BASENAMES
),$(if
$($(test)_EXPAND
),$(test)))
489 TESTS_TARGET_SPECIFIC_EXPANDED
= $(foreach test,$(TESTS_TARGET_SPECIFIC
),$(foreach \
490 target
,$(filter-out $($(test)_BLACKLIST
),$(VALID_TARGETS
)),$(test).
$(target
)))
492 TESTS
= $(foreach test,$(TEST_BASENAMES
),$(if
$($(test)_EXPAND
),,$(test)))
493 TESTS_ALL
= $(TESTS
) $(TESTS_TARGET_SPECIFIC_EXPANDED
)
494 TESTS_REPRESENTATIVE
= $(TESTS
) $(foreach test,$(TESTS_TARGET_SPECIFIC
), \
495 $(test).
$(word 1,$(filter-out $($(test)_BLACKLIST
),$(VALID_TARGETS
))))
497 # All Google Test headers. Usually you shouldn't change this
499 GTEST_HEADERS
= $(GTEST_DIR
)/inc
/gtest
/*.h
501 ## V : Set verbosity level based on the V= parameter
504 include ..
/..
/make
/build_verbosity.mk
506 # House-keeping build targets.
508 ## test : Build and run the non target specific Unit Tests (default goal)
509 test: $(TESTS
:%=test_
%)
511 ## test-all : Build and run all Unit Tests
512 test-all
: $(TESTS_ALL
:%=test_
%)
514 ## test-representative : Build and run a representative subset of the Unit Tests (i.e. run every expanded test only for the first target)
515 test-representative
: $(TESTS_REPRESENTATIVE
:%=test_
%)
517 ## junittest : Build and run the Unit Tests, producing Junit XML result files."
518 junittest
: EXEC_OPTS
= "--gtest_output=xml:$<_results.xml"
519 junittest
: $(TESTS
:%=test_
%)
523 ## help : print this help message and exit
524 ## what : print this help message and exit
525 ## usage : print this help message and exit
526 help what usage
: Makefile
528 @echo
"Makefile for Unit Tests"
531 @echo
" make [goal] "
533 @echo
"Valid goals are:"
535 @sed
-n
's/^## //p' $<
537 @echo
"Any of the Unit Test programs can be used as goals to build:"
538 @
$(foreach test, $(TESTS
), echo
" $(OBJECT_DIR)/$(test)/$(test)";)
540 @echo
"Any of the Unit Test programs (except for target specific unit tests) can be used as goals to build and run:"
541 @
$(foreach test, $(TESTS
), echo
" test_$(test)";)
543 ## clean : Cleanup the UnitTest binaries.
548 # Builds gtest.a and gtest_main.a.
550 # Usually you shouldn't tweak such internal variables, indicated by a
552 GTEST_SRCS_
= $(GTEST_DIR
)/src
/*.
cc $(GTEST_DIR
)/inc
/gtest
/*.h
$(GTEST_HEADERS
)
554 # For simplicity and to avoid depending on Google Test's
555 # implementation details, the dependencies specified below are
556 # conservative and not optimized. This is fine as Google Test
557 # compiles fast and for ordinary users its source rarely changes.
558 $(OBJECT_DIR
)/gtest-all.o
: $(GTEST_SRCS_
)
559 @echo
"compiling $@" "$(STDOUT)"
561 $(V1
) $(CXX
) $(CXX_FLAGS
) -I
$(GTEST_DIR
) -Wno-missing-field-initializers
-Wno-unused-const-variable
-c \
562 $(GTEST_DIR
)/src
/gtest-all.
cc -o
$@
564 $(OBJECT_DIR
)/gtest_main.o
: $(GTEST_SRCS_
)
565 @echo
"compiling $@" "$(STDOUT)"
567 $(V1
) $(CXX
) $(CXX_FLAGS
) -I
$(GTEST_DIR
) -c \
568 $(GTEST_DIR
)/src
/gtest_main.
cc -o
$@
570 $(OBJECT_DIR
)/gtest.a
: $(OBJECT_DIR
)/gtest-all.o
571 @echo
"linking $@" "$(STDOUT)"
572 $(V1
) $(AR
) $(ARFLAGS
) $@
$^
574 $(OBJECT_DIR
)/gtest_main.a
: $(OBJECT_DIR
)/gtest-all.o
$(OBJECT_DIR
)/gtest_main.o
575 @echo
"linking $@" "$(STDOUT)"
576 $(V1
) $(AR
) $(ARFLAGS
) $@
$^
578 -include $(OBJECT_DIR
)/gtest-all.d \
579 $(OBJECT_DIR
)/gtest_main.d
582 # includes in test dir must override includes in user dir, unless the user
583 # specifies a list of endorsed directories in ${target}_INCLUDE_DIRS.
584 test_include_dirs
= $1 $(TEST_DIR
) $(USER_DIR
)
585 test_cflags
= $(addprefix -I
,$(call test_include_dirs
,$1))
588 # target name extractor
589 # param $1 = expanded test name in the form of test.target
590 target
= $(1:$(basename $1).
%=%)
592 # canned recipe for all test builds
594 # variable expansion rules of thumb (number of $'s):
595 # * parameters: one $, e.g. $1
596 # * statically accessed variables set elsewhere: one $, e.g. $(C_FLAGS)
597 # * dynamically accessed variables set elsewhere: one $, e.g. $($1_SRC)
598 # * make functions accessing only the above: one $, e.g. $(basename $1)
599 # * dynamically set and accessed variables: two $, e.g. $$($1_OBJS)
600 # * make functions accessing dynamically set variables: two $,
601 # e.g. $$(call test_cflags,$$($1_INCLUDE_DIRS))
603 # param $1 = plain test name for global tests, test.target for per-target tests
604 define test-specific-stuff
606 ifeq ($1,$(basename $1))
607 # standard global test
608 $1_OBJS = $(patsubst \
609 $(TEST_DIR
)/%,$(OBJECT_DIR
)/$1/%,$(patsubst \
610 $(USER_DIR
)/%,$(OBJECT_DIR
)/$1/%,$($1_SRC:=.o
)))
612 # test executed for each target, $1 has the form of test.target
613 $1_SRC = $(addsuffix .o
,$(call
$(basename $1)_SRC
,$(call target
,$1)))
614 $1_OBJS = $$(patsubst \
615 $(TEST_DIR
)/%,$(OBJECT_DIR
)/$1/%,$$(patsubst \
616 $(USER_DIR
)/%,$(OBJECT_DIR
)/$1/%,$$(patsubst \
617 $(TARGET_DIR
)/$(call get_base_target
,$(call target
,$1))/%,$(OBJECT_DIR
)/$1/%,$$($1_SRC))))
618 $1_DEFINES = $(call
$(basename $1)_DEFINES
,$(call target
,$1))
619 $1_INCLUDE_DIRS = $(call
$(basename $1)_INCLUDE_DIRS
,$(call target
,$1))
622 # $$(info $1 -v-v-------)
623 # $$(info $1_SRC: $$($1_SRC))
624 # $$(info $1_OBJS: $$($1_OBJS))
625 # $$(info $1 -^-^-------)
627 # include generated dependencies
628 -include $$($1_OBJS:.o
=.d
)
629 -include $(OBJECT_DIR
)/$1/$(basename $1).d
631 $(OBJECT_DIR
)/$1/%.c.o
: $(USER_DIR
)/%.c
632 @echo
"compiling $$<" "$(STDOUT)"
633 $(V1
) mkdir
-p
$$(dir $$@
)
634 $(V1
) $(CC
) $(C_FLAGS
) $$(call test_cflags
,$$($1_INCLUDE_DIRS)) \
635 $$(foreach def
,$$($1_DEFINES),-D
$$(def
)) \
638 $(OBJECT_DIR
)/$1/%.c.o
: $(TEST_DIR
)/%.c
639 @echo
"compiling test c file: $$<" "$(STDOUT)"
640 $(V1
) mkdir
-p
$$(dir $$@
)
641 $(V1
) $(CC
) $(C_FLAGS
) $$(call test_cflags
,$$($1_INCLUDE_DIRS)) \
642 $$(foreach def
,$$($1_DEFINES),-D
$$(def
)) \
645 ifneq ($1,$(basename $1))
646 # per-target tests may compile files from the target directory
647 $(OBJECT_DIR
)/$1/%.c.o
: $(TARGET_DIR
)/$(call get_base_target
,$(call target
,$1))/%.c
648 @echo
"compiling target c file: $$<" "$(STDOUT)"
649 $(V1
) mkdir
-p
$$(dir $$@
)
650 $(V1
) $(CC
) $(C_FLAGS
) $$(call test_cflags
,$$($1_INCLUDE_DIRS)) \
651 $$(foreach def
,$$($1_DEFINES),-D
$$(def
)) \
655 $(OBJECT_DIR
)/$1/$(basename $1).o
: $(TEST_DIR
)/$(basename $1).
cc
656 @echo
"compiling $$<" "$(STDOUT)"
657 $(V1
) mkdir
-p
$$(dir $$@
)
658 $(V1
) $(CXX
) $(CXX_FLAGS
) $$(call test_cflags
,$$($1_INCLUDE_DIRS)) \
659 $$(foreach def
,$$($1_DEFINES),-D
$$(def
)) \
662 $(OBJECT_DIR
)/$1/$(basename $1): $$($1_OBJS) \
663 $(OBJECT_DIR
)/$1/$(basename $1).o \
664 $(OBJECT_DIR
)/gtest_main.a
666 @echo
"linking $$@" "$(STDOUT)"
667 $(V1
) mkdir
-p
$(dir $$@
)
668 $(V1
) $(CXX
) $(CXX_FLAGS
) $(LDFLAGS
) $$^
-o
$$@
670 test_
$1: $(OBJECT_DIR
)/$1/$(basename $1)
671 $(V1
) $$< $$(EXEC_OPTS
) "$(STDOUT)" && echo
"running $$@: PASS"
676 ifeq ($(MAKECMDGOALS
),test-all
)
677 $(eval
$(foreach test,$(TESTS_ALL
),$(call test-specific-stuff
,$(test))))
679 ifeq ($(MAKECMDGOALS
),test-representative
)
680 $(eval
$(foreach test,$(TESTS_REPRESENTATIVE
),$(call test-specific-stuff
,$(test))))
682 $(eval
$(foreach test,$(TESTS
),$(call test-specific-stuff
,$(test))))
686 $(foreach test,$(TESTS_ALL
),$(if
$($(basename $(test))_SRC
),,$(error \
687 Test
'unit/$(basename $(test)).cc' has no
'$(basename $(test))_SRC' variable defined
)))
688 $(foreach var
,$(filter-out TARGET_SRC
,$(filter %_SRC
,$(.VARIABLES
))),$(if
$(filter $(var
:_SRC
=)%,$(TESTS_ALL
)),,$(error \
689 Variable
'$(var)' has no
'unit/$(var:_SRC=).cc' test)))
693 @echo
========== BASE TARGETS
==========
694 @echo
$(BASE_TARGETS
)
695 @echo
========== ALT TARGETS
==========
697 @echo
========== VALID_TARGETS
==========
698 @echo
$(VALID_TARGETS
)
699 @echo
========== BASE
/ALT PAIRS
==========
700 @echo
$(BASE_ALT_PAIRS
)
701 @echo
========== ALT
/BASE MAPPING
==========
702 @echo
$(foreach target
,$(ALT_TARGETS
),$(target
)\
>$(call get_base_target
,$(target
)))
703 @echo
========== ALT
/BASE FULL MAPPING
==========
704 @echo
$(foreach target
,$(VALID_TARGETS
),$(target
)\
>$(call get_base_target
,$(target
)))