blob: 7dae36772eb28662505b5df866986c586927df00 [file] [log] [blame]
# -*- makefile -*-
# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This makefile is used only by firmware_builder.py to achieve parallelism.
# The paths in this file need to match the ones in firmware_builder.py,
# so be careful.
# This also assumes that you ran zmake build -a before this in the build stage
TWISTER_COMMAND=cd $(PLATFORM_EC) && ./twister --outdir \
twister-out-$(TOOLCHAIN) -v -i --no-upload-cros-rdb --toolchain \
$(TOOLCHAIN)
ifdef COVERAGE
TWISTER_COMMAND+=--coverage --coverage-formats=lcov
endif
PLATFORM_EC=$(abspath ..)
PLATFORM=$(abspath ../..)
THIRD_PARTY=$(abspath ../../../third_party)
BUILD=$(PLATFORM_EC)/build
GENERATED_AND_SYSTEM_PATTERNS='$(PLATFORM_EC)/build/**' \
'$(PLATFORM_EC)/twister-out*/**' \
'/usr/include/**' \
'/usr/lib/**' \
'**/picolibc/picolibc/include/**' \
'**/third_party/boringssl/crypto/**' \
'**/lib/gcc/**' \
'**/.cache/**'
TEST_PATTERNS='$(PLATFORM_EC)/test/**' \
'$(PLATFORM_EC)/include/tests/**' \
'$(PLATFORM)/ec-private/test/**' \
'$(PLATFORM)/ec-private/fingerprint/*/mcutest/**' \
'$(PLATFORM_EC)/zephyr/test/**' \
'$(THIRD_PARTY)/zephyr/main/subsys/testsuite/**' \
'$(PLATFORM_EC)/include/mock/**' \
'$(PLATFORM_EC)/common/mock/**' \
'$(PLATFORM_EC)/board/host/**' \
'$(PLATFORM_EC)/chip/host/**' \
'$(PLATFORM_EC)/core/host/**' \
'$(PLATFORM_EC)/zephyr/emul/**' \
'$(PLATFORM_EC)/zephyr/mock/**' \
'$(PLATFORM_EC)/zephyr/drivers/fingerprint/*_sim.c' \
'$(PLATFORM_EC)/zephyr/drivers/pw_fsm/test_*.cc' \
'$(PLATFORM_EC)/zephyr/program/dev/**' \
'$(THIRD_PARTY)/zephyr/main/subsys/emul/**' \
'$(THIRD_PARTY)/zephyr/main/arch/posix/**' \
'$(THIRD_PARTY)/zephyr/main/scripts/native_simulator/**' \
'$(THIRD_PARTY)/zephyr/main/boards/native/native_posix/**' \
'$(THIRD_PARTY)/zephyr/main/boards/native/native_sim/**' \
'$(THIRD_PARTY)/pigweed/pw_unit_test/**' \
'**/*_benchmark.cc' \
'**/*_test.c' \
'**/*_test.cc' \
'**/*_test.h' \
'**/*_emul.c' \
'**/*_emul.cc' \
'**/*_emul.h' \
'$(PLATFORM_EC)/include/test_util.h' \
'$(PLATFORM_EC)/common/test_util.c' \
'$(PLATFORM_EC)/zephyr/shim/src/test_util.c' \
'$(PLATFORM_EC)/zephyr/shim/src/ztest_system.c'
.PHONY: test twister_host twister_llvm
test: zmake_unit_tests
ifdef COVERAGE
# List all of the files expected by firmware_builder.py
test: $(PLATFORM_EC)/twister-out-host/coverage.info # EC_ZEPHYR_TESTS_GCC
test: $(BUILD)/coverage/lcov.info # EC_LEGACY_TESTS
test: $(BUILD)/zephyr/all_tests.info # ALL_TESTS
test: $(BUILD)/zephyr/zephyr_merged.info # EC_ZEPHYR_MERGED
test: $(BUILD)/zephyr/lcov.info # ALL_MERGED
test: $(BUILD)/zephyr/lcov_no_tests.info # ALL_FILTERED
test: $(BUILD)/zephyr/lcov_rpt # html artifact
test: special_boards # BOARD_ metric and html artifact
else
test: twister_host twister_llvm zephyr_check_compliance_unittest
endif
ifdef COVERAGE
zmake_unit_tests:
zmake/run_tests.sh --coverage
else
zmake_unit_tests:
zmake/run_tests.sh
endif
zephyr_check_compliance_unittest:
$(PLATFORM_EC)/util/zephyr_check_compliance_unittest.py
twister_host $(PLATFORM_EC)/twister-out-host/coverage.info: TOOLCHAIN=host
twister_host $(PLATFORM_EC)/twister-out-host/coverage.info:
+$(TWISTER_COMMAND)
twister_llvm $(PLATFORM_EC)/twister-out-llvm/coverage.info: TOOLCHAIN=llvm
twister_llvm $(PLATFORM_EC)/twister-out-llvm/coverage.info:
+$(TWISTER_COMMAND)
$(BUILD)/coverage/lcov.info:
$(MAKE) -C .. test-coverage
$(BUILD)/zephyr/all_tests.info: $(PLATFORM_EC)/twister-out-host/coverage.info $(BUILD)/coverage/lcov.info
/usr/bin/lcov -o $@ --rc branch_coverage=1 --rc no_exception_branch=1 \
--ignore-errors inconsistent,inconsistent --ignore-errors unused,unused --ignore-errors gcov,gcov \
-a $(BUILD)/coverage/lcov.info \
-a $(PLATFORM_EC)/twister-out-host/coverage.info
$(BUILD)/zephyr/zephyr_merged.info: $(BUILD)/zephyr/all_tests.info $(BUILD)/zephyr/all_builds.info
/usr/bin/lcov -o $@ --rc branch_coverage=1 --rc no_exception_branch=1 \
--ignore-errors inconsistent,inconsistent --ignore-errors unused,unused --ignore-errors gcov,gcov \
-a $(BUILD)/zephyr/all_tests.info -a $(BUILD)/zephyr/all_builds.info
$(BUILD)/zephyr/lcov.info: $(BUILD)/zephyr/zephyr_merged.info
/usr/bin/lcov -o $@ --rc branch_coverage=1 --rc no_exception_branch=1 \
--ignore-errors inconsistent,inconsistent --ignore-errors unused,unused --ignore-errors gcov,gcov \
-r $(BUILD)/zephyr/zephyr_merged.info \
$(GENERATED_AND_SYSTEM_PATTERNS)
$(BUILD)/zephyr/lcov_no_tests.info: $(BUILD)/zephyr/lcov.info
/usr/bin/lcov -o $@ --rc branch_coverage=1 --rc no_exception_branch=1 \
--ignore-errors inconsistent,inconsistent --ignore-errors unused,unused --ignore-errors gcov,gcov \
-r $(BUILD)/zephyr/lcov.info \
$(TEST_PATTERNS)
$(BUILD)/zephyr/lcov_rpt: $(BUILD)/zephyr/lcov.info
/usr/bin/genhtml --branch-coverage -q -o $@ \
--ignore-errors inconsistent,inconsistent --ignore-errors unused \
-t 'All boards and tests merged' -s $^
special_boards: $(foreach b, $(SPECIAL_BOARDS), $(BUILD)/zephyr/$(b)_rpt)
$(BUILD)/zephyr/%_merged.info: $(BUILD)/zephyr/%/output/zephyr.info $(BUILD)/zephyr/all_tests.info
/usr/bin/lcov -o $@ --rc branch_coverage=1 --rc no_exception_branch=1 \
--ignore-errors inconsistent,inconsistent --ignore-errors unused,unused --ignore-errors gcov,gcov \
-a $(BUILD)/zephyr/all_tests.info -a $<
$(BUILD)/zephyr/%_stenciled.info: $(BUILD)/zephyr/%/output/zephyr.info $(BUILD)/zephyr/%_merged.info
$(PLATFORM_EC)/util/lcov_stencil.py -o $@ $^
.PRECIOUS: $(BUILD)/zephyr/%_final.info
$(BUILD)/zephyr/%_final.info: $(BUILD)/zephyr/%_stenciled.info
/usr/bin/lcov -o $@ --rc branch_coverage=1 --rc no_exception_branch=1 \
--ignore-errors inconsistent,inconsistent --ignore-errors unused,unused --ignore-errors gcov,gcov \
-r $< \
'$(PLATFORM_EC)/zephyr/drivers/cros_displight/*' \
'$(PLATFORM_EC)/zephyr/drivers/cros_flash/*' \
'$(PLATFORM_EC)/zephyr/drivers/cros_kb_raw*' \
'$(PLATFORM_EC)/zephyr/drivers/cros_kblight/*' \
'$(PLATFORM_EC)/zephyr/drivers/cros_rtc/*' \
'$(PLATFORM_EC)/zephyr/drivers/cros_shi/*' \
'$(PLATFORM_EC)/zephyr/drivers/cros_system/*' \
'$(PLATFORM_EC)/zephyr/drivers/cros_tabletmode_interrupt/*' \
'$(PLATFORM_EC)/zephyr/drivers/fingerprint/*' \
'$(PLATFORM_EC)/zephyr/drivers/keyboard_input/*' \
'$(PLATFORM_EC)/zephyr/drivers/sm5803/*' \
'$(PLATFORM_EC)/zephyr/drivers/vivaldi_kbd/*' \
'$(THIRD_PARTY)/**' \
'$(PLATFORM_EC)/zephyr/include/drivers/cros_displight.h' \
'$(PLATFORM_EC)/zephyr/include/drivers/cros_flash.h' \
'$(PLATFORM_EC)/zephyr/include/drivers/cros_kb_raw.h' \
'$(PLATFORM_EC)/zephyr/include/drivers/cros_rtc.h' \
'$(PLATFORM_EC)/zephyr/include/drivers/cros_shi.h' \
'$(PLATFORM_EC)/zephyr/include/drivers/cros_system.h' \
'$(PLATFORM_EC)/zephyr/include/drivers/fingerprint_sim.h' \
'$(PLATFORM_EC)/zephyr/include/drivers/fingerprint.h' \
'$(PLATFORM_EC)/zephyr/include/drivers/vivaldi_kbd.h' \
'$(PLATFORM_EC)/zephyr/shim/chip/**' \
'$(PLATFORM_EC)/zephyr/shim/chip/npcx/npcx_monitor/**' \
'$(PLATFORM_EC)/zephyr/shim/core/**' \
'$(PLATFORM_EC)/driver/tcpm/it8xxx2.c' \
$(GENERATED_AND_SYSTEM_PATTERNS) $(TEST_PATTERNS)
.PRECIOUS: $(BUILD)/zephyr/%_rpt
$(BUILD)/zephyr/%_rpt: $(BUILD)/zephyr/%_final.info
/usr/bin/genhtml --branch-coverage -q -o $@ \
--ignore-errors inconsistent,inconsistent --ignore-errors unused \
-t '$* ec code only' -s $^
OSZAR »