# -*- 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 endif PLATFORM_EC=$(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/**' 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/**' \ '$(THIRD_PARTY)/zephyr/main/subsys/emul/**' \ '$(THIRD_PARTY)/zephyr/main/arch/posix/**' \ '**/*_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-llvm/coverage.info # EC_ZEPHYR_TESTS 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 endif ifdef COVERAGE zmake_unit_tests: zmake/run_tests.sh --coverage else zmake_unit_tests: zmake/run_tests.sh endif 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 $(PLATFORM_EC)/twister-out-llvm/coverage.info $(BUILD)/coverage/lcov.info /usr/bin/lcov -o $@ --rc lcov_branch_coverage=1 \ -a $(BUILD)/coverage/lcov.info -a $(PLATFORM_EC)/twister-out-llvm/coverage.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 lcov_branch_coverage=1 \ -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 lcov_branch_coverage=1 \ -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 lcov_branch_coverage=1 \ -r $(BUILD)/zephyr/lcov.info \ $(TEST_PATTERNS) $(BUILD)/zephyr/lcov_rpt: $(BUILD)/zephyr/lcov.info /usr/bin/genhtml --branch-coverage -q -o $@ \ -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 lcov_branch_coverage=1 \ -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 lcov_branch_coverage=1 \ -r $< \ '$(THIRD_PARTY)/**' \ '$(PLATFORM_EC)/zephyr/drivers/**' \ '$(PLATFORM_EC)/zephyr/include/drivers/**' \ '$(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 $@ \ -t '$* ec code only' -s $^