Added battery cell count based automatic PID profile switching.
[betaflight.git] / src / test / Makefile
blob4efb7c6e65e68299b4dbddd3bda001932d184b1d
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.
6 # SYNOPSIS:
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.
14 USER_DIR = ../main
15 TEST_DIR = unit
16 ROOT = ../..
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 # specify which files that are included in the test in addition to the unittest file.
24 # variables available:
25 # <test_name>_SRC
26 # <test_name>_DEFINES
27 # <test_name>_INCLUDE_DIRS
28 # <test_name>_EXPAND (run for each target, call the above with target as $1)
29 # <test_name>_BLACKLIST (targets to exclude from an expanded test's run)
31 alignsensor_unittest_SRC := \
32 $(USER_DIR)/sensors/boardalignment.c \
33 $(USER_DIR)/common/maths.c
35 arming_prevention_unittest_SRC := \
36 $(USER_DIR)/fc/core.c \
37 $(USER_DIR)/fc/dispatch.c \
38 $(USER_DIR)/fc/rc_controls.c \
39 $(USER_DIR)/fc/rc_modes.c \
40 $(USER_DIR)/fc/runtime_config.c \
41 $(USER_DIR)/flight/gps_rescue.c \
42 $(USER_DIR)/common/bitarray.c
44 arming_prevention_unittest_DEFINES := \
45 USE_GPS_RESCUE=
47 atomic_unittest_SRC := \
48 $(USER_DIR)/build/atomic.c \
49 $(TEST_DIR)/atomic_unittest_c.c
51 # This test is disabled due to build errors.
52 # Its source code is archived in unit/baro_bmp085_unittest.cc.txt
54 #baro_bmp085_unittest_SRC := \
55 # $(USER_DIR)/drivers/barometer/barometer_bmp085.c \
56 # $(USER_DIR)/drivers/io.c
59 baro_bmp280_unittest_SRC := \
60 $(USER_DIR)/drivers/barometer/barometer_bmp280.c
62 baro_bmp280_unittest_DEFINES := \
63 USE_BARO_BMP280= \
64 USE_BARO_SPI_BMP280=
66 baro_ms5611_unittest_SRC := \
67 $(USER_DIR)/drivers/barometer/barometer_ms5611.c
69 baro_ms5611_unittest_DEFINES := \
70 USE_BARO_MS5611= \
71 USE_BARO_SPI_MS5611=
73 # This test is disabled due to build errors.
74 # Its source code is archived in unit/battery_unittest.cc.txt
76 #battery_unittest_SRC := \
77 # $(USER_DIR)/sensors/battery.c \
78 # $(USER_DIR)/common/maths.c
81 blackbox_unittest_SRC := \
82 $(USER_DIR)/blackbox/blackbox.c \
83 $(USER_DIR)/blackbox/blackbox_encoding.c \
84 $(USER_DIR)/blackbox/blackbox_io.c \
85 $(USER_DIR)/common/encoding.c \
86 $(USER_DIR)/common/printf.c \
87 $(USER_DIR)/common/maths.c \
88 $(USER_DIR)/common/typeconversion.c \
89 $(USER_DIR)/drivers/accgyro/gyro_sync.c
91 blackbox_encoding_unittest_SRC := \
92 $(USER_DIR)/blackbox/blackbox_encoding.c \
93 $(USER_DIR)/common/encoding.c \
94 $(USER_DIR)/common/printf.c \
95 $(USER_DIR)/common/typeconversion.c
97 cli_unittest_SRC := \
98 $(USER_DIR)/cli/cli.c \
99 $(USER_DIR)/config/feature.c \
100 $(USER_DIR)/pg/pg.c \
101 $(USER_DIR)/common/typeconversion.c
103 cli_unittest_DEFINES := \
104 USE_OSD= \
105 USE_CLI= \
106 SystemCoreClock=1000000
108 cms_unittest_SRC := \
109 $(USER_DIR)/cms/cms.c \
110 $(USER_DIR)/cms/cms_menu_saveexit.c \
111 $(USER_DIR)/common/typeconversion.c \
112 $(USER_DIR)/drivers/display.c
115 common_filter_unittest_SRC := \
116 $(USER_DIR)/common/filter.c \
117 $(USER_DIR)/common/maths.c
120 encoding_unittest_SRC := \
121 $(USER_DIR)/common/encoding.c
124 flight_failsafe_unittest_SRC := \
125 $(USER_DIR)/common/bitarray.c \
126 $(USER_DIR)/fc/rc_modes.c \
127 $(USER_DIR)/fc/runtime_config.c \
128 $(USER_DIR)/flight/failsafe.c
131 flight_imu_unittest_SRC := \
132 $(USER_DIR)/common/bitarray.c \
133 $(USER_DIR)/common/maths.c \
134 $(USER_DIR)/config/feature.c \
135 $(USER_DIR)/fc/rc_modes.c \
136 $(USER_DIR)/flight/position.c \
137 $(USER_DIR)/flight/imu.c
140 flight_mixer_unittest := \
141 $(USER_DIR)/flight/mixer.c \
142 $(USER_DIR)/flight/servos.c \
143 $(USER_DIR)/common/maths.c
146 gps_conversion_unittest_SRC := \
147 $(USER_DIR)/common/gps_conversion.c
150 io_serial_unittest_SRC := \
151 $(USER_DIR)/io/serial.c \
152 $(USER_DIR)/drivers/serial_pinconfig.c
155 ledstrip_unittest_SRC := \
156 $(USER_DIR)/common/bitarray.c \
157 $(USER_DIR)/fc/rc_modes.c \
158 $(USER_DIR)/io/ledstrip.c
160 ledstrip_unittest_DEFINES := \
161 USE_LED_STRIP=
164 maths_unittest_SRC := \
165 $(USER_DIR)/common/maths.c
168 osd_unittest_SRC := \
169 $(USER_DIR)/io/osd.c \
170 $(USER_DIR)/common/typeconversion.c \
171 $(USER_DIR)/drivers/display.c \
172 $(USER_DIR)/common/maths.c \
173 $(USER_DIR)/common/printf.c \
174 $(USER_DIR)/common/time.c \
175 $(USER_DIR)/fc/runtime_config.c
177 osd_unittest_DEFINES := \
178 USE_OSD= \
179 USE_GPS= \
180 USE_RTC_TIME= \
181 USE_ADC_INTERNAL=
184 pg_unittest_SRC := \
185 $(USER_DIR)/pg/pg.c
188 rc_controls_unittest_SRC := \
189 $(USER_DIR)/fc/rc_controls.c \
190 $(USER_DIR)/pg/pg.c \
191 $(USER_DIR)/common/bitarray.c \
192 $(USER_DIR)/common/maths.c \
193 $(USER_DIR)/fc/rc_adjustments.c \
194 $(USER_DIR)/fc/rc_modes.c
197 rx_crsf_unittest_SRC := \
198 $(USER_DIR)/rx/crsf.c \
199 $(USER_DIR)/common/crc.c \
200 $(USER_DIR)/common/printf.c \
201 $(USER_DIR)/common/typeconversion.c \
202 $(USER_DIR)/common/streambuf.c \
203 $(USER_DIR)/drivers/serial.c
206 rx_ibus_unittest_SRC := \
207 $(USER_DIR)/rx/ibus.c
210 rx_ranges_unittest_SRC := \
211 $(USER_DIR)/common/bitarray.c \
212 $(USER_DIR)/common/maths.c \
213 $(USER_DIR)/fc/rc_modes.c \
214 $(USER_DIR)/rx/rx.c \
215 $(USER_DIR)/pg/pg.c \
216 $(USER_DIR)/pg/rx.c
219 rx_rx_unittest_SRC := \
220 $(USER_DIR)/rx/rx.c \
221 $(USER_DIR)/fc/rc_modes.c \
222 $(USER_DIR)/common/bitarray.c \
223 $(USER_DIR)/common/maths.c \
224 $(USER_DIR)/config/feature.c \
225 $(USER_DIR)/pg/rx.c
228 scheduler_unittest_SRC := \
229 $(USER_DIR)/scheduler/scheduler.c \
230 $(USER_DIR)/common/crc.c \
231 $(USER_DIR)/common/streambuf.c
234 sensor_gyro_unittest_SRC := \
235 $(USER_DIR)/sensors/gyro.c \
236 $(USER_DIR)/sensors/boardalignment.c \
237 $(USER_DIR)/common/filter.c \
238 $(USER_DIR)/common/maths.c \
239 $(USER_DIR)/drivers/accgyro/accgyro_fake.c \
240 $(USER_DIR)/drivers/accgyro/gyro_sync.c \
241 $(USER_DIR)/pg/pg.c \
242 $(USER_DIR)/pg/gyrodev.c
244 telemetry_crsf_unittest_SRC := \
245 $(USER_DIR)/rx/crsf.c \
246 $(USER_DIR)/telemetry/crsf.c \
247 $(USER_DIR)/common/crc.c \
248 $(USER_DIR)/common/maths.c \
249 $(USER_DIR)/common/streambuf.c \
250 $(USER_DIR)/common/gps_conversion.c \
251 $(USER_DIR)/common/printf.c \
252 $(USER_DIR)/common/typeconversion.c \
253 $(USER_DIR)/fc/runtime_config.c
255 telemetry_crsf_unittest_DEFINES := \
256 FLASH_SIZE=128 \
257 STM32F10X_MD= \
258 __TARGET__="TEST" \
259 __REVISION__="revision"
262 telemetry_crsf_msp_unittest_SRC := \
263 $(USER_DIR)/rx/crsf.c \
264 $(USER_DIR)/build/atomic.c \
265 $(USER_DIR)/common/crc.c \
266 $(USER_DIR)/common/streambuf.c \
267 $(USER_DIR)/common/printf.c \
268 $(USER_DIR)/common/streambuf.c \
269 $(USER_DIR)/drivers/serial.c \
270 $(USER_DIR)/common/typeconversion.c \
271 $(USER_DIR)/telemetry/crsf.c \
272 $(USER_DIR)/common/gps_conversion.c \
273 $(USER_DIR)/telemetry/msp_shared.c \
274 $(USER_DIR)/fc/runtime_config.c
276 telemetry_crsf_msp_unittest_DEFINES := \
277 USE_MSP_OVER_TELEMETRY=
280 telemetry_hott_unittest_SRC := \
281 $(USER_DIR)/telemetry/hott.c \
282 $(USER_DIR)/common/gps_conversion.c
285 telemetry_ibus_unittest_SRC := \
286 $(USER_DIR)/telemetry/ibus_shared.c \
287 $(USER_DIR)/telemetry/ibus.c
289 timer_definition_unittest_EXPAND := yes
291 # SITL is a simulator with empty timerHardware and many hearders in target.c.
292 timer_definition_unittest_BLACKLIST := SITL
294 timer_definition_unittest_SRC = \
295 $(TARGET_DIR)/$(call get_base_target,$1)/target.c
297 timer_definition_unittest_DEFINES = \
298 TARGET=$1 \
299 BASE_TARGET=$(call get_base_target,$1)
301 timer_definition_unittest_INCLUDE_DIRS = \
302 $(TEST_DIR)/timer_definition_unittest.include \
303 $(TARGET_DIR)/$(call get_base_target,$1)
305 transponder_ir_unittest_SRC := \
306 $(USER_DIR)/drivers/transponder_ir_ilap.c \
307 $(USER_DIR)/drivers/transponder_ir_arcitimer.c
309 ws2811_unittest_SRC := \
310 $(USER_DIR)/drivers/light_ws2811strip.c
312 huffman_unittest_SRC := \
313 $(USER_DIR)/common/huffman.c \
314 $(USER_DIR)/common/huffman_table.c
316 huffman_unittest_DEFINES := \
317 USE_HUFFMAN=
319 rcdevice_unittest_SRC := \
320 $(USER_DIR)/common/crc.c \
321 $(USER_DIR)/common/bitarray.c \
322 $(USER_DIR)/fc/rc_modes.c \
323 $(USER_DIR)/io/rcdevice.c \
324 $(USER_DIR)/io/rcdevice_cam.c \
326 pid_unittest_SRC := \
327 $(USER_DIR)/common/filter.c \
328 $(USER_DIR)/common/maths.c \
329 $(USER_DIR)/drivers/accgyro/gyro_sync.c \
330 $(USER_DIR)/flight/pid.c \
331 $(USER_DIR)/pg/pg.c \
332 $(USER_DIR)/fc/runtime_config.c
334 pid_unittest_DEFINES := \
335 USE_ITERM_RELAX= \
336 USE_RC_SMOOTHING_FILTER= \
337 USE_ABSOLUTE_CONTROL= \
338 USE_LAUNCH_CONTROL=
340 rcdevice_unittest_DEFINES := \
341 USE_RCDEVICE=
343 vtx_unittest_SRC := \
344 $(USER_DIR)/fc/core.c \
345 $(USER_DIR)/fc/dispatch.c \
346 $(USER_DIR)/fc/rc_controls.c \
347 $(USER_DIR)/fc/rc_modes.c \
348 $(USER_DIR)/fc/runtime_config.c \
349 $(USER_DIR)/drivers/vtx_common.c \
350 $(USER_DIR)/io/vtx_control.c \
351 $(USER_DIR)/io/vtx_string.c \
352 $(USER_DIR)/io/vtx.c \
353 $(USER_DIR)/common/bitarray.c
355 vtx_unittest_DEFINES := \
356 USE_VTX_COMMON= \
357 USE_VTX_CONTROL= \
358 USE_VTX_SMARTAUDIO=
360 rx_spi_spektrum_unittest_SRC := \
361 $(USER_DIR)/rx/cyrf6936_spektrum.c
363 rx_spi_spektrum_unittest_DEFINES := \
364 USE_RX_SPI \
365 USE_RX_SPEKTRUM
367 # Please tweak the following variable definitions as needed by your
368 # project, except GTEST_HEADERS, which you can use in your own targets
369 # but shouldn't modify.
371 # Points to the root of Google Test, relative to where this file is.
372 # Remember to tweak this if you move this file.
373 GTEST_DIR = ../../lib/test/gtest
375 # Use clang/clang++ by default
376 CC := clang
377 CXX := clang++
378 #CC := gcc
379 #CXX := g++
381 COMMON_FLAGS = \
382 -g \
383 -Wall \
384 -Wextra \
385 -Werror \
386 -ggdb3 \
387 -O0 \
388 -DUNIT_TEST \
389 -isystem $(GTEST_DIR)/inc \
390 -MMD -MP
392 ifeq ($(shell $(CC) -v 2>&1 | grep -q "clang version" && echo "clang"),clang)
393 COMMON_FLAGS += -fblocks
394 LDFLAGS += -lBlocksRuntime
395 endif
397 ifndef MACOSX
398 COMMON_FLAGS += -pthread
399 endif
401 # Flags passed to the C compiler.
402 C_FLAGS = $(COMMON_FLAGS) \
403 -std=gnu99
405 # Flags passed to the C++ compiler.
406 CXX_FLAGS = $(COMMON_FLAGS) \
407 -std=gnu++11
409 # Compiler flags for coverage instrumentation
410 COVERAGE_FLAGS := --coverage
412 C_FLAGS += $(COVERAGE_FLAGS)
413 CXX_FLAGS += $(COVERAGE_FLAGS)
415 C_FLAGS += -D_GNU_SOURCE
417 # Set up the parameter group linker flags according to OS
418 ifdef MACOSX
419 LDFLAGS += -Wl,-map,$(OBJECT_DIR)/$@.map
420 else
421 LDFLAGS += -Wl,-T,$(TEST_DIR)/pg.ld -Wl,-Map,$(OBJECT_DIR)/$@.map
422 endif
424 # Gather up all of the tests.
425 TEST_SRCS = $(sort $(wildcard $(TEST_DIR)/*.cc))
426 TEST_BASENAMES = $(TEST_SRCS:$(TEST_DIR)/%.cc=%)
427 TESTS = $(foreach test,$(TEST_BASENAMES),$(if $($(test)_EXPAND),$(foreach \
428 target,$(filter-out $($(test)_BLACKLIST),$(VALID_TARGETS)),$(test).$(target)),$(test)))
429 TESTS_REPRESENTATIVE = $(foreach test,$(TEST_BASENAMES),$(if $($(test)_EXPAND),$(test).$(word \
430 1,$(filter-out $($(test)_BLACKLIST),$(VALID_TARGETS))),$(test)))
432 # All Google Test headers. Usually you shouldn't change this
433 # definition.
434 GTEST_HEADERS = $(GTEST_DIR)/inc/gtest/*.h
436 ## V : Set verbosity level based on the V= parameter
437 ## V=0 Low
438 ## V=1 High
439 include ../../make/build_verbosity.mk
441 # House-keeping build targets.
443 ## test : Build and run the Unit Tests (default goal)
444 test: $(TESTS:%=test_%)
446 ## test-representative : Build and run a representative subset of the Unit Tests (i.e. run every expanded test only for the first target)
447 test-representative: $(TESTS_REPRESENTATIVE:%=test_%)
449 ## junittest : Build and run the Unit Tests, producing Junit XML result files."
450 junittest: EXEC_OPTS = "--gtest_output=xml:$<_results.xml"
451 junittest: $(TESTS:%=test_%)
455 ## help : print this help message and exit
456 ## what : print this help message and exit
457 ## usage : print this help message and exit
458 help what usage: Makefile
459 @echo ""
460 @echo "Makefile for Unit Tests"
461 @echo ""
462 @echo "Usage:"
463 @echo " make [goal] "
464 @echo ""
465 @echo "Valid goals are:"
466 @echo ""
467 @sed -n 's/^## //p' $<
468 @echo ""
469 @echo "Any of the Unit Test programs can be used as goals to build:"
470 @$(foreach test, $(TESTS), echo " $(OBJECT_DIR)/$(test)/$(test)";)
471 @echo ""
472 @echo "Any of the Unit Test programs can be used as goals to build and run:"
473 @$(foreach test, $(TESTS), echo " test_$(test)";)
475 ## clean : Cleanup the UnitTest binaries.
476 clean :
477 rm -rf $(OBJECT_DIR)
480 # Builds gtest.a and gtest_main.a.
482 # Usually you shouldn't tweak such internal variables, indicated by a
483 # trailing _.
484 GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/inc/gtest/*.h $(GTEST_HEADERS)
486 # For simplicity and to avoid depending on Google Test's
487 # implementation details, the dependencies specified below are
488 # conservative and not optimized. This is fine as Google Test
489 # compiles fast and for ordinary users its source rarely changes.
490 $(OBJECT_DIR)/gtest-all.o : $(GTEST_SRCS_)
491 @echo "compiling $@" "$(STDOUT)"
492 @mkdir -p $(dir $@)
493 $(V1) $(CXX) $(CXX_FLAGS) -I$(GTEST_DIR) -Wno-missing-field-initializers -Wno-unused-const-variable -c \
494 $(GTEST_DIR)/src/gtest-all.cc -o $@
496 $(OBJECT_DIR)/gtest_main.o : $(GTEST_SRCS_)
497 @echo "compiling $@" "$(STDOUT)"
498 @mkdir -p $(dir $@)
499 $(V1) $(CXX) $(CXX_FLAGS) -I$(GTEST_DIR) -c \
500 $(GTEST_DIR)/src/gtest_main.cc -o $@
502 $(OBJECT_DIR)/gtest.a : $(OBJECT_DIR)/gtest-all.o
503 @echo "linking $@" "$(STDOUT)"
504 $(V1) $(AR) $(ARFLAGS) $@ $^
506 $(OBJECT_DIR)/gtest_main.a : $(OBJECT_DIR)/gtest-all.o $(OBJECT_DIR)/gtest_main.o
507 @echo "linking $@" "$(STDOUT)"
508 $(V1) $(AR) $(ARFLAGS) $@ $^
510 -include $(OBJECT_DIR)/gtest-all.d \
511 $(OBJECT_DIR)/gtest_main.d
514 # includes in test dir must override includes in user dir, unless the user
515 # specifies a list of endorsed directories in ${target}_INCLUDE_DIRS.
516 test_include_dirs = $1 $(TEST_DIR) $(USER_DIR)
517 test_cflags = $(addprefix -I,$(call test_include_dirs,$1))
520 # target name extractor
521 # param $1 = expanded test name in the form of test.target
522 target = $(1:$(basename $1).%=%)
524 # canned recipe for all test builds
526 # variable expansion rules of thumb (number of $'s):
527 # * parameters: one $, e.g. $1
528 # * statically accessed variables set elsewhere: one $, e.g. $(C_FLAGS)
529 # * dynamically accessed variables set elsewhere: one $, e.g. $($1_SRC)
530 # * make functions accessing only the above: one $, e.g. $(basename $1)
531 # * dynamically set and accessed variables: two $, e.g. $$($1_OBJS)
532 # * make functions accessing dynamically set variables: two $,
533 # e.g. $$(call test_cflags,$$($1_INCLUDE_DIRS))
535 # param $1 = plain test name for global tests, test.target for per-target tests
536 define test-specific-stuff
538 ifeq ($1,$(basename $1))
539 # standard global test
540 $1_OBJS = $(patsubst \
541 $(TEST_DIR)/%,$(OBJECT_DIR)/$1/%,$(patsubst \
542 $(USER_DIR)/%,$(OBJECT_DIR)/$1/%,$($1_SRC:=.o)))
543 else
544 # test executed for each target, $1 has the form of test.target
545 $1_SRC = $(addsuffix .o,$(call $(basename $1)_SRC,$(call target,$1)))
546 $1_OBJS = $$(patsubst \
547 $(TEST_DIR)/%,$(OBJECT_DIR)/$1/%,$$(patsubst \
548 $(USER_DIR)/%,$(OBJECT_DIR)/$1/%,$$(patsubst \
549 $(TARGET_DIR)/$(call get_base_target,$(call target,$1))/%,$(OBJECT_DIR)/$1/%,$$($1_SRC))))
550 $1_DEFINES = $(call $(basename $1)_DEFINES,$(call target,$1))
551 $1_INCLUDE_DIRS = $(call $(basename $1)_INCLUDE_DIRS,$(call target,$1))
552 endif
554 # $$(info $1 -v-v-------)
555 # $$(info $1_SRC: $$($1_SRC))
556 # $$(info $1_OBJS: $$($1_OBJS))
557 # $$(info $1 -^-^-------)
559 # include generated dependencies
560 -include $$($1_OBJS:.o=.d)
561 -include $(OBJECT_DIR)/$1/$(basename $1).d
563 $(OBJECT_DIR)/$1/%.c.o: $(USER_DIR)/%.c
564 @echo "compiling $$<" "$(STDOUT)"
565 $(V1) mkdir -p $$(dir $$@)
566 $(V1) $(CC) $(C_FLAGS) $$(call test_cflags,$$($1_INCLUDE_DIRS)) \
567 $$(foreach def,$$($1_DEFINES),-D $$(def)) \
568 -c $$< -o $$@
570 $(OBJECT_DIR)/$1/%.c.o: $(TEST_DIR)/%.c
571 @echo "compiling test c file: $$<" "$(STDOUT)"
572 $(V1) mkdir -p $$(dir $$@)
573 $(V1) $(CC) $(C_FLAGS) $$(call test_cflags,$$($1_INCLUDE_DIRS)) \
574 $$(foreach def,$$($1_DEFINES),-D $$(def)) \
575 -c $$< -o $$@
577 ifneq ($1,$(basename $1))
578 # per-target tests may compile files from the target directory
579 $(OBJECT_DIR)/$1/%.c.o: $(TARGET_DIR)/$(call get_base_target,$(call target,$1))/%.c
580 @echo "compiling target c file: $$<" "$(STDOUT)"
581 $(V1) mkdir -p $$(dir $$@)
582 $(V1) $(CC) $(C_FLAGS) $$(call test_cflags,$$($1_INCLUDE_DIRS)) \
583 $$(foreach def,$$($1_DEFINES),-D $$(def)) \
584 -c $$< -o $$@
585 endif
587 $(OBJECT_DIR)/$1/$(basename $1).o: $(TEST_DIR)/$(basename $1).cc
588 @echo "compiling $$<" "$(STDOUT)"
589 $(V1) mkdir -p $$(dir $$@)
590 $(V1) $(CXX) $(CXX_FLAGS) $$(call test_cflags,$$($1_INCLUDE_DIRS)) \
591 $$(foreach def,$$($1_DEFINES),-D $$(def)) \
592 -c $$< -o $$@
594 $(OBJECT_DIR)/$1/$(basename $1): $$($1_OBJS) \
595 $(OBJECT_DIR)/$1/$(basename $1).o \
596 $(OBJECT_DIR)/gtest_main.a
598 @echo "linking $$@" "$(STDOUT)"
599 $(V1) mkdir -p $(dir $$@)
600 $(V1) $(CXX) $(CXX_FLAGS) $(LDFLAGS) $$^ -o $$@
602 test_$1: $(OBJECT_DIR)/$1/$(basename $1)
603 $(V1) $$< $$(EXEC_OPTS) "$(STDOUT)" && echo "running $$@: PASS"
605 endef
608 $(eval $(foreach test,$(TESTS),$(call test-specific-stuff,$(test))))
610 $(foreach test,$(TESTS),$(if $($(basename $(test))_SRC),,$(error \
611 Test 'unit/$(basename $(test)).cc' has no '$(basename $(test))_SRC' variable defined)))
612 $(foreach var,$(filter-out TARGET_SRC,$(filter %_SRC,$(.VARIABLES))),$(if $(filter $(var:_SRC=)%,$(TESTS)),,$(error \
613 Variable '$(var)' has no 'unit/$(var:_SRC=).cc' test)))
616 target_list:
617 @echo ========== BASE TARGETS ==========
618 @echo $(BASE_TARGETS)
619 @echo ========== ALT TARGETS ==========
620 @echo $(ALT_TARGETS)
621 @echo ========== VALID_TARGETS ==========
622 @echo $(VALID_TARGETS)
623 @echo ========== BASE/ALT PAIRS ==========
624 @echo $(BASE_ALT_PAIRS)
625 @echo ========== ALT/BASE MAPPING ==========
626 @echo $(foreach target,$(ALT_TARGETS),$(target)\>$(call get_base_target,$(target)))
627 @echo ========== ALT/BASE FULL MAPPING ==========
628 @echo $(foreach target,$(VALID_TARGETS),$(target)\>$(call get_base_target,$(target)))