1 # Defines a target named $(my_target) for generating a coverage report. 2 3 my_report_dir := $(my_coverage_dir)/reports 4 my_coverage_output := $(my_report_dir)/html 5 6 # Private variables. 7 $(my_coverage_output): \ 8 PRIVATE_MODULE := $(LOCAL_MODULE) 9 $(my_coverage_output): \ 10 PRIVATE_COVERAGE_FILE := $(my_coverage_file) 11 $(my_coverage_output): \ 12 PRIVATE_COVERAGE_SRCS_JARS := $(my_coverage_srcs_jars) 13 $(my_coverage_output): \ 14 PRIVATE_INSTRUMENT_SOURCE_DIRS := $(my_instrument_source_dirs) 15 $(my_coverage_output): \ 16 PRIVATE_COVERAGE_REPORT_CLASS := $(my_coverage_report_class) 17 $(my_coverage_output): \ 18 PRIVATE_COVERAGE_REPORT_JAR := $(my_coverage_report_jar) 19 $(my_coverage_output): \ 20 PRIVATE_REPORT_DIR := $(my_report_dir) 21 22 # Generate the coverage report. 23 $(my_coverage_output): $(my_collect_target) $(my_coverage_report_jar) 24 $(hide) rm -rf $(PRIVATE_REPORT_DIR) 25 $(hide) mkdir -p $(PRIVATE_REPORT_DIR) 26 $(hide) java \ 27 -cp $(PRIVATE_COVERAGE_REPORT_JAR) \ 28 $(PRIVATE_COVERAGE_REPORT_CLASS) \ 29 --classpath $(strip $(call normalize-path-list, $(PRIVATE_COVERAGE_SRCS_JARS))) \ 30 --exec-file $(PRIVATE_COVERAGE_FILE) \ 31 --name $(PRIVATE_MODULE) \ 32 --report-dir $(PRIVATE_REPORT_DIR)/ \ 33 --srcs $(strip $(call normalize-path-list, $(PRIVATE_INSTRUMENT_SOURCE_DIRS))) \ 34 >$(PRIVATE_REPORT_DIR)/reporter.txt 2>&1 35 $(hide) abs="$$(realpath "$(PRIVATE_REPORT_DIR)")"; \ 36 echo "Coverage report:" \ 37 "file://$$abs/index.html" \ 38 39 # Generate a ZIP file of the coverage report. 40 my_coverage_output_zip := \ 41 $(my_coverage_dir)/report-$(my_coverage_report_format).zip 42 43 $(my_coverage_output_zip): \ 44 PRIVATE_REPORT_DIR := $(my_report_dir) 45 $(my_coverage_output_zip): $(my_coverage_output) 46 $(hide) cd $(PRIVATE_REPORT_DIR) && zip -r $(PWD)/$@ . 47 48 # Add coverage report zip to dist files. 49 $(call dist-for-goals, $(my_target), \ 50 $(my_coverage_output_zip):robotests/$(my_coverage_report_dist_file)) 51 52 # Running the coverage will always generate the report. 53 $(my_target): $(my_coverage_output) 54 55 # Reset local variables. 56 my_coverage_output := 57 my_coverage_output_zip := 58 my_report_dir := 59