1# 2# Copyright (C) 2010 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17# Makefile for producing CTS coverage reports. 18# Run "make cts-test-coverage" in the $ANDROID_BUILD_TOP directory. 19 20cts_api_coverage_exe := $(HOST_OUT_EXECUTABLES)/cts-api-coverage 21dexdeps_exe := $(HOST_OUT_EXECUTABLES)/dexdeps 22 23coverage_out := $(HOST_OUT)/cts-api-coverage 24 25api_text_description := frameworks/base/api/current.txt 26api_xml_description := $(coverage_out)/api.xml 27$(api_xml_description) : $(api_text_description) $(APICHECK) 28 $(hide) echo "Converting API file to XML: $@" 29 $(hide) mkdir -p $(dir $@) 30 $(hide) $(APICHECK_COMMAND) -convert2xml $< $@ 31 32napi_text_description := cts/tools/cts-api-coverage/etc/ndk-api.xml 33napi_xml_description := $(coverage_out)/ndk-api.xml 34$(napi_xml_description) : $(napi_text_description) $(ACP) 35 $(hide) echo "Preparing NDK API XML: $@" 36 $(hide) mkdir -p $(dir $@) 37 $(hide) $(ACP) $< $@ 38 39cts-test-coverage-report := $(coverage_out)/test-coverage.html 40cts-verifier-coverage-report := $(coverage_out)/verifier-coverage.html 41cts-combined-coverage-report := $(coverage_out)/combined-coverage.html 42cts-combined-xml-coverage-report := $(coverage_out)/combined-coverage.xml 43 44cts_api_coverage_dependencies := $(cts_api_coverage_exe) $(dexdeps_exe) $(api_xml_description) $(napi_xml_description) 45 46android_cts_zip := $(HOST_OUT)/cts/android-cts.zip 47cts_verifier_apk := $(call intermediates-dir-for,APPS,CtsVerifier)/package.apk 48 49$(cts-test-coverage-report): PRIVATE_TEST_CASES := $(COMPATIBILITY_TESTCASES_OUT_cts) 50$(cts-test-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe) 51$(cts-test-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe) 52$(cts-test-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description) 53$(cts-test-coverage-report): PRIVATE_NAPI_XML_DESC := $(napi_xml_description) 54$(cts-test-coverage-report) : $(android_cts_zip) $(cts_api_coverage_dependencies) | $(ACP) 55 $(call generate-coverage-report-cts,"CTS Tests API-NDK Coverage Report",\ 56 $(PRIVATE_TEST_CASES),html) 57 58$(cts-verifier-coverage-report): PRIVATE_TEST_CASES := $(cts_verifier_apk) 59$(cts-verifier-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe) 60$(cts-verifier-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe) 61$(cts-verifier-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description) 62$(cts-verifier-coverage-report): PRIVATE_NAPI_XML_DESC := $(napi_xml_description) 63$(cts-verifier-coverage-report) : $(cts_verifier_apk) $(cts_api_coverage_dependencies) | $(ACP) 64 $(call generate-coverage-report-cts,"CTS Verifier API Coverage Report",\ 65 $(PRIVATE_TEST_CASES),html) 66 67$(cts-combined-coverage-report): PRIVATE_TEST_CASES := $(foreach c, $(cts_verifier_apk) $(COMPATIBILITY_TESTCASES_OUT_cts), $(c)) 68$(cts-combined-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe) 69$(cts-combined-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe) 70$(cts-combined-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description) 71$(cts-combined-coverage-report): PRIVATE_NAPI_XML_DESC := $(napi_xml_description) 72$(cts-combined-coverage-report) : $(android_cts_zip) $(cts_verifier_apk) $(cts_api_coverage_dependencies) | $(ACP) 73 $(call generate-coverage-report-cts,"CTS Combined API Coverage Report",\ 74 $(PRIVATE_TEST_CASES),html) 75 76$(cts-combined-xml-coverage-report): PRIVATE_TEST_CASES := $(foreach c, $(cts_verifier_apk) $(COMPATIBILITY_TESTCASES_OUT_cts), $(c)) 77$(cts-combined-xml-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe) 78$(cts-combined-xml-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe) 79$(cts-combined-xml-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description) 80$(cts-combined-xml-coverage-report): PRIVATE_NAPI_XML_DESC := $(napi_xml_description) 81$(cts-combined-xml-coverage-report) : $(android_cts_zip) $(cts_verifier_apk) $(cts_api_coverage_dependencies) | $(ACP) 82 $(call generate-coverage-report-cts,"CTS Combined API Coverage Report - XML",\ 83 $(PRIVATE_TEST_CASES),xml) 84 85.PHONY: cts-test-coverage 86cts-test-coverage : $(cts-test-coverage-report) 87 88.PHONY: cts-verifier-coverage 89cts-verifier-coverage : $(cts-verifier-coverage-report) 90 91.PHONY: cts-combined-coverage 92cts-combined-coverage : $(cts-combined-coverage-report) 93 94.PHONY: cts-combined-xml-coverage 95cts-combined-xml-coverage : $(cts-combined-xml-coverage-report) 96 97.PHONY: cts-api-coverage 98cts-coverage-report-all: cts-test-coverage cts-verifier-coverage cts-combined-coverage cts-combined-xml-coverage 99 100# Put the test coverage report in the dist dir if "cts-api-coverage" is among the build goals. 101$(call dist-for-goals, cts-api-coverage, $(cts-test-coverage-report):cts-test-coverage-report.html) 102$(call dist-for-goals, cts-api-coverage, $(cts-verifier-coverage-report):cts-verifier-coverage-report.html) 103$(call dist-for-goals, cts-api-coverage, $(cts-combined-coverage-report):cts-combined-coverage-report.html) 104$(call dist-for-goals, cts-api-coverage, $(cts-combined-xml-coverage-report):cts-combined-coverage-report.xml) 105 106# Arguments; 107# 1 - Name of the report printed out on the screen 108# 2 - List of apk files that will be scanned to generate the report 109# 3 - Format of the report 110define generate-coverage-report-cts 111 $(hide) mkdir -p $(dir $@) 112 $(hide) $(PRIVATE_CTS_API_COVERAGE_EXE) -d $(PRIVATE_DEXDEPS_EXE) -a $(PRIVATE_API_XML_DESC) -n $(PRIVATE_NAPI_XML_DESC) -f $(3) -o $@ $(2) 113 @ echo $(1): file://$$(cd $(dir $@); pwd)/$(notdir $@) 114endef 115 116# Reset temp vars 117cts_api_coverage_dependencies := 118cts-combined-coverage-report := 119cts-combined-xml-coverage-report := 120cts-verifier-coverage-report := 121cts-test-coverage-report := 122api_xml_description := 123api_text_description := 124napi_xml_description := 125napi_text_description := 126coverage_out := 127dexdeps_exe := 128cts_api_coverage_exe := 129cts_verifier_apk := 130android_cts_zip := 131