blob: edbb94ddb22a330705ea95463205c18646ab389a [file] [log] [blame]
Bart Searsa8cc0582015-05-07 03:23:20 +00001#
2# Copyright (C) 2008 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#
16LOCAL_PATH := $(call my-dir)
17
Colin Crosscf3a0b52017-11-16 00:15:28 -080018# Load framework-specific path mappings used later in the build.
19include $(LOCAL_PATH)/pathmap.mk
Bart Searsa8cc0582015-05-07 03:23:20 +000020
21# Build the master framework library.
22# The framework contains too many method references (>64K) for poor old DEX.
23# So we first build the framework as a monolithic static library then split it
24# up into smaller pieces.
25# ============================================================
26
27# embedded builds use nothing in frameworks/base
28ifneq ($(ANDROID_BUILD_EMBEDDED),true)
29
Bart Searsa8cc0582015-05-07 03:23:20 +000030# Copy AIDL files to be preprocessed and included in the SDK,
31# specified relative to the root of the build tree.
32# ============================================================
33include $(CLEAR_VARS)
34
Colin Cross77ebd082017-12-15 17:30:33 -080035aidl_parcelables :=
36define stubs-to-aidl-parcelables
37 gen := $(TARGET_OUT_COMMON_INTERMEDIATES)/$1.aidl
38 aidl_parcelables += $$(gen)
Colin Crossfdbe7d12018-02-09 11:24:14 -080039 $$(gen): $(call java-lib-header-files,$1) $(HOST_OUT_EXECUTABLES)/sdkparcelables
Colin Cross77ebd082017-12-15 17:30:33 -080040 @echo Extract SDK parcelables: $$@
41 rm -f $$@
42 $(HOST_OUT_EXECUTABLES)/sdkparcelables $$< $$@
43endef
44
45$(foreach stubs,android_stubs_current android_test_stubs_current android_system_stubs_current,\
46 $(eval $(call stubs-to-aidl-parcelables,$(stubs))))
47
Bart Searsa8cc0582015-05-07 03:23:20 +000048gen := $(TARGET_OUT_COMMON_INTERMEDIATES)/framework.aidl
Colin Cross77ebd082017-12-15 17:30:33 -080049.KATI_RESTAT: $(gen)
50$(gen): $(aidl_parcelables)
51 @echo Combining SDK parcelables: $@
52 rm -f $@.tmp
53 cat $^ | sort -u > $@.tmp
54 $(call commit-change-for-toc,$@)
Bart Searsa8cc0582015-05-07 03:23:20 +000055
56# the documentation
57# ============================================================
58
59# TODO: deal with com/google/android/googleapps
60packages_to_document := \
Colin Crosscf3a0b52017-11-16 00:15:28 -080061 android \
62 javax/microedition/khronos \
63 org/apache/http/conn \
64 org/apache/http/params \
Bart Searsa8cc0582015-05-07 03:23:20 +000065
66# include definition of libcore_to_document
67include libcore/Docs.mk
68
Bart Searsa8cc0582015-05-07 03:23:20 +000069non_base_dirs := \
Colin Crosscf3a0b52017-11-16 00:15:28 -080070 ../opt/telephony/src/java/android/telephony \
71 ../opt/telephony/src/java/android/telephony/gsm \
72 ../opt/net/voip/src/java/android/net/rtp \
73 ../opt/net/voip/src/java/android/net/sip \
Bart Searsa8cc0582015-05-07 03:23:20 +000074
Colin Crosscf3a0b52017-11-16 00:15:28 -080075# Find all files in specific directories (relative to frameworks/base)
76# to document and check apis
77files_to_check_apis := \
78 $(call find-other-java-files, \
Colin Crosscf3a0b52017-11-16 00:15:28 -080079 $(non_base_dirs) \
80 )
Bart Searsa8cc0582015-05-07 03:23:20 +000081
Colin Crosscf3a0b52017-11-16 00:15:28 -080082# Find all files in specific packages that were used to compile
83# framework.jar to document and check apis
84files_to_check_apis += \
85 $(addprefix ../../,\
86 $(filter \
87 $(foreach dir,$(FRAMEWORKS_BASE_JAVA_SRC_DIRS),\
88 $(foreach package,$(packages_to_document),\
89 $(dir)/$(package)/%.java)),\
90 $(SOONG_FRAMEWORK_SRCS)))
91
92# Find all generated files that were used to compile framework.jar
Colin Crossbd200ce2017-12-04 13:45:19 -080093files_to_check_apis_generated := \
94 $(filter $(OUT_DIR)/%,\
95 $(SOONG_FRAMEWORK_SRCS))
George Mountf6be9932015-12-03 07:39:55 -080096
Bart Searsa8cc0582015-05-07 03:23:20 +000097# These are relative to frameworks/base
98# FRAMEWORKS_BASE_SUBDIRS comes from build/core/pathmap.mk
Colin Crosscf3a0b52017-11-16 00:15:28 -080099files_to_document := \
100 $(files_to_check_apis) \
101 $(call find-other-java-files,\
Paul Duffin187a48d2017-12-13 14:34:31 +0000102 test-base/src \
Paul Duffin9f6282d2017-12-15 15:49:08 +0000103 test-mock/src \
Colin Crosscf3a0b52017-11-16 00:15:28 -0800104 test-runner/src)
George Mountf6be9932015-12-03 07:39:55 -0800105
Bart Searsa8cc0582015-05-07 03:23:20 +0000106# These are relative to frameworks/base
107html_dirs := \
108 $(FRAMEWORKS_BASE_SUBDIRS) \
Colin Crosscf3a0b52017-11-16 00:15:28 -0800109 $(non_base_dirs) \
Bart Searsa8cc0582015-05-07 03:23:20 +0000110
111# Common sources for doc check and api check
112common_src_files := \
113 $(call find-other-html-files, $(html_dirs)) \
Colin Crosscf3a0b52017-11-16 00:15:28 -0800114 $(addprefix ../../, $(libcore_to_document)) \
Bart Searsa8cc0582015-05-07 03:23:20 +0000115
116# These are relative to frameworks/base
117framework_docs_LOCAL_SRC_FILES := \
Colin Crosscf3a0b52017-11-16 00:15:28 -0800118 $(files_to_document) \
119 $(common_src_files) \
Bart Searsa8cc0582015-05-07 03:23:20 +0000120
121# These are relative to frameworks/base
122framework_docs_LOCAL_API_CHECK_SRC_FILES := \
Colin Crosscf3a0b52017-11-16 00:15:28 -0800123 $(files_to_check_apis) \
124 $(common_src_files) \
Bart Searsa8cc0582015-05-07 03:23:20 +0000125
126# This is used by ide.mk as the list of source files that are
127# always included.
128INTERNAL_SDK_SOURCE_DIRS := $(addprefix $(LOCAL_PATH)/,$(dirs_to_document))
129
130framework_docs_LOCAL_DROIDDOC_SOURCE_PATH := \
131 $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
132
Colin Crosscf3a0b52017-11-16 00:15:28 -0800133framework_docs_LOCAL_SRCJARS := $(SOONG_FRAMEWORK_SRCJARS)
134
Colin Crossbd200ce2017-12-04 13:45:19 -0800135framework_docs_LOCAL_GENERATED_SOURCES := \
136 $(libcore_to_document_generated) \
137 $(files_to_check_apis_generated) \
Bart Searsa8cc0582015-05-07 03:23:20 +0000138
139framework_docs_LOCAL_API_CHECK_JAVA_LIBRARIES := \
Piotr Jastrzebskicfa292e2015-02-17 16:58:52 +0000140 core-oj \
Bart Searsa8cc0582015-05-07 03:23:20 +0000141 core-libart \
142 conscrypt \
143 bouncycastle \
144 okhttp \
145 ext \
146 framework \
Paul Duffinc08090f2017-06-29 14:58:43 +0100147 voip-common \
Bart Searsa8cc0582015-05-07 03:23:20 +0000148
Alan Viverette9ca513e2017-04-05 10:21:58 -0400149# Platform docs can refer to Support Library APIs, but we don't actually build
150# them as part of the docs target, so we need to include them on the classpath.
Bart Searsa8cc0582015-05-07 03:23:20 +0000151framework_docs_LOCAL_JAVA_LIBRARIES := \
152 $(framework_docs_LOCAL_API_CHECK_JAVA_LIBRARIES) \
153 $(FRAMEWORKS_SUPPORT_JAVA_LIBRARIES)
154
155framework_docs_LOCAL_MODULE_CLASS := JAVA_LIBRARIES
156framework_docs_LOCAL_DROIDDOC_HTML_DIR := docs/html
157# The since flag (-since N.xml API_LEVEL) is used to add API Level information
158# to the reference documentation. Must be in order of oldest to newest.
159#
160# Conscrypt (com.android.org.conscrypt) is an implementation detail and should
161# not be referenced in the documentation.
162framework_docs_LOCAL_DROIDDOC_OPTIONS := \
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -0600163 -android \
Bart Searsa8cc0582015-05-07 03:23:20 +0000164 -knowntags ./frameworks/base/docs/knowntags.txt \
Narayan Kamath2c4f2842015-07-27 14:02:11 +0100165 -knowntags ./libcore/known_oj_tags.txt \
Jeff Sharkeybfc4fcd2017-06-05 17:38:17 -0600166 -manifest ./frameworks/base/core/res/AndroidManifest.xml \
Tobias Thiererdda16e82018-03-05 22:55:32 +0000167 -hidePackage com.android.internal \
168 -hidePackage com.android.internal.util \
Neil Fuller57157fb2017-11-24 15:58:38 +0000169 -hidePackage com.android.okhttp \
Bart Searsa8cc0582015-05-07 03:23:20 +0000170 -hidePackage com.android.org.conscrypt \
Anton Hansson6a9e7262018-04-19 16:23:53 +0100171 -hidePackage com.android.server
172
173# Convert an sdk level to a "since" argument.
Sundong Ahn4ff08f62018-07-16 18:19:31 +0900174since-arg = -since $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/$(1)/public/api/android.$(2)) $(1)
Anton Hansson6a9e7262018-04-19 16:23:53 +0100175
Sundong Ahn4ff08f62018-07-16 18:19:31 +0900176finalized_xml_sdks := $(call numerically_sort,\
177 $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/public/api/android.xml,%,\
178 $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/public/api/android.xml)))
179finalized_txt_sdks := $(call numerically_sort,\
180 $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/public/api/android.txt,%,\
181 $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/public/api/android.txt)))
Anton Hansson6a9e7262018-04-19 16:23:53 +0100182
Sundong Ahn4ff08f62018-07-16 18:19:31 +0900183framework_docs_LOCAL_DROIDDOC_OPTIONS += $(foreach sdk,$(finalized_xml_sdks),$(call since-arg,$(sdk),xml))
184framework_docs_LOCAL_DROIDDOC_OPTIONS += $(foreach sdk,$(finalized_txt_sdks),$(call since-arg,$(sdk),txt))
Anton Hansson6a9e7262018-04-19 16:23:53 +0100185ifneq ($(PLATFORM_VERSION_CODENAME),REL)
186 framework_docs_LOCAL_DROIDDOC_OPTIONS += \
187 -since ./frameworks/base/api/current.txt $(PLATFORM_VERSION_CODENAME)
188endif
189framework_docs_LOCAL_DROIDDOC_OPTIONS += \
Jeff Sharkeyc204c222017-11-27 15:02:10 -0700190 -werror -lerror -hide 111 -hide 113 -hide 125 -hide 126 -hide 127 -hide 128 \
Anton Hansson6a9e7262018-04-19 16:23:53 +0100191 -overview $(LOCAL_PATH)/core/java/overview.html
Bart Searsa8cc0582015-05-07 03:23:20 +0000192
193framework_docs_LOCAL_API_CHECK_ADDITIONAL_JAVA_DIR:= \
194 $(call intermediates-dir-for,JAVA_LIBRARIES,framework,,COMMON)
195
196framework_docs_LOCAL_ADDITIONAL_JAVA_DIR:= \
Alan Viverette9ca513e2017-04-05 10:21:58 -0400197 $(framework_docs_LOCAL_API_CHECK_ADDITIONAL_JAVA_DIR)
Bart Searsa8cc0582015-05-07 03:23:20 +0000198
199framework_docs_LOCAL_ADDITIONAL_DEPENDENCIES := \
Narayan Kamathc21739a2015-07-14 13:39:23 +0100200 frameworks/base/docs/knowntags.txt \
Colin Cross72d359f2017-10-27 10:46:53 -0700201 $(libcore_to_document_generated)
Bart Searsa8cc0582015-05-07 03:23:20 +0000202
203samples_dir := development/samples/browseable
204
205# Whitelist of valid groups, used for default TOC grouping. Each sample must
206# belong to one (and only one) group. Assign samples to groups by setting
207# a sample.group var to one of these groups in the sample's _index.jd.
208sample_groups := -samplegroup Admin \
209 -samplegroup Background \
210 -samplegroup Connectivity \
211 -samplegroup Content \
212 -samplegroup Input \
213 -samplegroup Media \
214 -samplegroup Notification \
215 -samplegroup RenderScript \
216 -samplegroup Security \
217 -samplegroup Sensors \
Trevor Johns4cbe3592015-05-27 14:50:51 -0700218 -samplegroup System \
Bart Searsa8cc0582015-05-07 03:23:20 +0000219 -samplegroup Testing \
220 -samplegroup UI \
221 -samplegroup Views \
222 -samplegroup Wearable
223
224## SDK version identifiers used in the published docs
225 # major[.minor] version for current SDK. (full releases only)
smain@google.comdde8deb2016-08-29 18:36:50 -0700226framework_docs_SDK_VERSION:=7.0
Bart Searsa8cc0582015-05-07 03:23:20 +0000227 # release version (ie "Release x") (full releases only)
228framework_docs_SDK_REL_ID:=1
229
230framework_docs_LOCAL_DROIDDOC_OPTIONS += \
Billy Lamberta75dbc8f2017-03-03 13:09:15 -0800231 -hdf dac true \
Scott Mainf8cdfc82017-03-21 13:43:31 -0700232 -hdf sdk.codename O \
233 -hdf sdk.preview.version 1 \
Bart Searsa8cc0582015-05-07 03:23:20 +0000234 -hdf sdk.version $(framework_docs_SDK_VERSION) \
235 -hdf sdk.rel.id $(framework_docs_SDK_REL_ID) \
Scott Mainf8cdfc82017-03-21 13:43:31 -0700236 -hdf sdk.preview 0 \
237 -resourcesdir $(LOCAL_PATH)/docs/html/reference/images/ \
238 -resourcesoutdir reference/android/images/
Bart Searsa8cc0582015-05-07 03:23:20 +0000239
Alan Viverette9ca513e2017-04-05 10:21:58 -0400240# Federate Support Library references against local API file.
241framework_docs_LOCAL_DROIDDOC_OPTIONS += \
242 -federate SupportLib https://developer.android.com \
243 -federationapi SupportLib prebuilts/sdk/current/support-api.txt
244
Alan Viverette67b51d42018-03-28 17:10:20 -0400245# Federate AndroidX references against local API file.
246framework_docs_LOCAL_DROIDDOC_OPTIONS += \
247 -federate AndroidX https://developer.android.com \
248 -federationapi AndroidX prebuilts/sdk/current/androidx-api.txt
249
Anton Hanssoncfa700d2018-04-23 17:34:18 +0100250# Get the highest numbered api txt for the given api level.
251# $(1): the api level (e.g. public, system)
252define highest_sdk_txt
253$(HISTORICAL_SDK_VERSIONS_ROOT)/$(lastword $(call numerically_sort, \
254 $(patsubst \
255 $(HISTORICAL_SDK_VERSIONS_ROOT)/%,\
256 %,\
257 $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/$(1)/api/android.txt)\
258 ) \
259))
260endef
261
Jeff Sharkeyd2bf31c2017-11-29 13:14:27 -0700262# ==== Public API diff ===========================
Alan Viverette6b7354c2017-07-13 17:10:14 -0400263include $(CLEAR_VARS)
264
265LOCAL_SRC_FILES := $(framework_docs_LOCAL_API_CHECK_SRC_FILES)
Colin Crossbd200ce2017-12-04 13:45:19 -0800266LOCAL_GENERATED_SOURCES := $(framework_docs_LOCAL_GENERATED_SOURCES)
Colin Crosscf3a0b52017-11-16 00:15:28 -0800267LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
Alan Viverette6b7354c2017-07-13 17:10:14 -0400268LOCAL_JAVA_LIBRARIES := $(framework_docs_LOCAL_API_CHECK_JAVA_LIBRARIES)
269LOCAL_MODULE_CLASS := $(framework_docs_LOCAL_MODULE_CLASS)
270LOCAL_ADDITIONAL_JAVA_DIR := $(framework_docs_LOCAL_API_CHECK_ADDITIONAL_JAVA_DIR)
271LOCAL_ADDITIONAL_DEPENDENCIES := \
272 $(framework_docs_LOCAL_ADDITIONAL_DEPENDENCIES) \
273 $(INTERNAL_PLATFORM_API_FILE)
274
275LOCAL_MODULE := offline-sdk-referenceonly
276
Anton Hanssoncfa700d2018-04-23 17:34:18 +0100277# Basename, because apidiff adds .txt internally.
278LOCAL_APIDIFF_OLDAPI := $(basename $(call highest_sdk_txt,public))
Alan Viverette6b7354c2017-07-13 17:10:14 -0400279LOCAL_APIDIFF_NEWAPI := $(LOCAL_PATH)/../../$(basename $(INTERNAL_PLATFORM_API_FILE))
280
281include $(BUILD_APIDIFF)
282
Jeff Sharkeyc8dc2542017-12-08 14:52:37 -0700283# Hack to get diffs included in docs output
284out_zip := $(OUT_DOCS)/$(LOCAL_MODULE)-docs.zip
285$(out_zip): $(full_target)
286
Jeff Sharkeyd2bf31c2017-11-29 13:14:27 -0700287# ==== System API diff ===========================
288include $(CLEAR_VARS)
289
290LOCAL_SRC_FILES := $(framework_docs_LOCAL_API_CHECK_SRC_FILES)
Colin Crossbd200ce2017-12-04 13:45:19 -0800291LOCAL_GENERATED_SOURCES := $(framework_docs_LOCAL_GENERATED_SOURCES)
Colin Crosscf3a0b52017-11-16 00:15:28 -0800292LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
Jeff Sharkeyd2bf31c2017-11-29 13:14:27 -0700293LOCAL_JAVA_LIBRARIES := $(framework_docs_LOCAL_API_CHECK_JAVA_LIBRARIES)
294LOCAL_MODULE_CLASS := $(framework_docs_LOCAL_MODULE_CLASS)
295LOCAL_ADDITIONAL_JAVA_DIR := $(framework_docs_LOCAL_API_CHECK_ADDITIONAL_JAVA_DIR)
296LOCAL_ADDITIONAL_DEPENDENCIES := \
297 $(framework_docs_LOCAL_ADDITIONAL_DEPENDENCIES) \
298 $(INTERNAL_PLATFORM_SYSTEM_API_FILE)
299
300LOCAL_MODULE := offline-system-sdk-referenceonly
301
Anton Hanssoncfa700d2018-04-23 17:34:18 +0100302# Basename, because apidiff adds .txt internally.
303LOCAL_APIDIFF_OLDAPI := $(basename $(call highest_sdk_txt,system))
Jeff Sharkeyd2bf31c2017-11-29 13:14:27 -0700304LOCAL_APIDIFF_NEWAPI := $(LOCAL_PATH)/../../$(basename $(INTERNAL_PLATFORM_SYSTEM_API_FILE))
305
306include $(BUILD_APIDIFF)
307
Jeff Sharkeyc8dc2542017-12-08 14:52:37 -0700308# Hack to get diffs included in docs output
309out_zip := $(OUT_DOCS)/$(LOCAL_MODULE)-docs.zip
310$(out_zip): $(full_target)
311
Bart Searsa8cc0582015-05-07 03:23:20 +0000312$(call dist-for-goals,sdk,$(INTERNAL_PLATFORM_API_FILE))
Bart Searsa8cc0582015-05-07 03:23:20 +0000313$(call dist-for-goals,sdk,$(INTERNAL_PLATFORM_SYSTEM_API_FILE))
Michael Wrightb2b2c0e2015-11-06 15:21:13 +0000314$(call dist-for-goals,sdk,$(INTERNAL_PLATFORM_TEST_API_FILE))
315
Nan Zhange9a76f72018-07-11 15:19:22 -0700316# sdk.atree needs to copy the whole dir: $(OUT_DOCS)/offline-sdk to the final zip.
317# So keep offline-sdk-timestamp target here, and unzip offline-sdk-docs.zip to
318# $(OUT_DOCS)/offline-sdk.
319$(OUT_DOCS)/offline-sdk-timestamp: $(OUT_DOCS)/offline-sdk-docs-docs.zip
320 $(hide) rm -rf $(OUT_DOCS)/offline-sdk
321 $(hide) mkdir -p $(OUT_DOCS)/offline-sdk
322 ( unzip -qo $< -d $(OUT_DOCS)/offline-sdk && touch -f $@ ) || exit 1
Bart Searsa8cc0582015-05-07 03:23:20 +0000323
Steven Timotius7ece0422017-08-03 13:37:26 -0700324# ==== java proto device library (for test only) ==============================
325include $(CLEAR_VARS)
326LOCAL_MODULE := platformprotosnano
Joe Onorato62c220b2017-11-18 20:32:56 -0800327LOCAL_MODULE_TAGS := tests
Steven Timotius7ece0422017-08-03 13:37:26 -0700328LOCAL_PROTOC_OPTIMIZE_TYPE := nano
329LOCAL_PROTOC_FLAGS := \
330 -Iexternal/protobuf/src
331LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
332 store_unknown_fields = true
Jiyong Parkf0048392018-02-12 21:57:59 +0900333LOCAL_SDK_VERSION := current
Steven Timotius7ece0422017-08-03 13:37:26 -0700334LOCAL_SRC_FILES := \
Yi Jin437aa6e2018-01-10 11:34:26 -0800335 $(call all-proto-files-under, core/proto) \
336 $(call all-proto-files-under, libs/incident/proto/android/os)
Steven Timotius7ece0422017-08-03 13:37:26 -0700337include $(BUILD_STATIC_JAVA_LIBRARY)
338
Bart Searsa8cc0582015-05-07 03:23:20 +0000339
Joe Onorato62c220b2017-11-18 20:32:56 -0800340# ==== java proto device library (for test only) ==============================
341include $(CLEAR_VARS)
342LOCAL_MODULE := platformprotoslite
343LOCAL_MODULE_TAGS := tests
344LOCAL_PROTOC_OPTIMIZE_TYPE := lite
345LOCAL_PROTOC_FLAGS := \
346 -Iexternal/protobuf/src
347LOCAL_SRC_FILES := \
Yi Jin437aa6e2018-01-10 11:34:26 -0800348 $(call all-proto-files-under, core/proto) \
349 $(call all-proto-files-under, libs/incident/proto/android/os)
Andreas Gampe93b64c92018-01-30 18:50:34 -0800350# Protos have lots of MissingOverride and similar.
351LOCAL_ERROR_PRONE_FLAGS := -XepDisableAllChecks
Joe Onorato62c220b2017-11-18 20:32:56 -0800352include $(BUILD_STATIC_JAVA_LIBRARY)
353
David Brazdil0649c8d2018-01-22 22:23:13 +0000354# ==== hiddenapi lists =======================================
David Brazdil721bc8e2018-05-08 15:04:20 +0100355include $(CLEAR_VARS)
David Brazdil0649c8d2018-01-22 22:23:13 +0000356
David Brazdil721bc8e2018-05-08 15:04:20 +0100357# File names of final API lists
358LOCAL_LIGHT_GREYLIST := $(INTERNAL_PLATFORM_HIDDENAPI_LIGHT_GREYLIST)
359LOCAL_DARK_GREYLIST := $(INTERNAL_PLATFORM_HIDDENAPI_DARK_GREYLIST)
360LOCAL_BLACKLIST := $(INTERNAL_PLATFORM_HIDDENAPI_BLACKLIST)
361
362# File names of source files we will use to generate the final API lists.
363LOCAL_SRC_GREYLIST := frameworks/base/config/hiddenapi-light-greylist.txt
364LOCAL_SRC_VENDOR_LIST := frameworks/base/config/hiddenapi-vendor-list.txt
David Brazdil4b34f792018-05-08 16:49:02 +0100365LOCAL_SRC_FORCE_BLACKLIST := frameworks/base/config/hiddenapi-force-blacklist.txt
David Brazdilb59c36f2018-08-01 09:27:26 +0000366LOCAL_SRC_PUBLIC_API := $(INTERNAL_PLATFORM_HIDDENAPI_PUBLIC_LIST)
367LOCAL_SRC_PRIVATE_API := $(INTERNAL_PLATFORM_HIDDENAPI_PRIVATE_LIST)
David Brazdil721bc8e2018-05-08 15:04:20 +0100368LOCAL_SRC_REMOVED_API := $(INTERNAL_PLATFORM_REMOVED_DEX_API_FILE)
369
370LOCAL_SRC_ALL := \
371 $(LOCAL_SRC_GREYLIST) \
372 $(LOCAL_SRC_VENDOR_LIST) \
David Brazdil4b34f792018-05-08 16:49:02 +0100373 $(LOCAL_SRC_FORCE_BLACKLIST) \
David Brazdil6f6a1262018-05-31 13:58:41 +0100374 $(LOCAL_SRC_PUBLIC_API) \
David Brazdil721bc8e2018-05-08 15:04:20 +0100375 $(LOCAL_SRC_PRIVATE_API) \
376 $(LOCAL_SRC_REMOVED_API)
377
378define assert-has-no-overlap
379if [ ! -z "`comm -12 <(sort $(1)) <(sort $(2))`" ]; then \
380 echo "$(1) and $(2) should not overlap" 1>&2; \
381 comm -12 <(sort $(1)) <(sort $(2)) 1>&2; \
382 exit 1; \
383fi
384endef
385
386define assert-is-subset
387if [ ! -z "`comm -23 <(sort $(1)) <(sort $(2))`" ]; then \
388 echo "$(1) must be a subset of $(2)" 1>&2; \
389 comm -23 <(sort $(1)) <(sort $(2)) 1>&2; \
390 exit 1; \
391fi
392endef
393
394define assert-has-no-duplicates
395if [ ! -z "`sort $(1) | uniq -D`" ]; then \
396 echo "$(1) has duplicate entries" 1>&2; \
397 sort $(1) | uniq -D 1>&2; \
398 exit 1; \
399fi
400endef
401
402# The following rules build API lists in the build folder.
403# By not using files from the source tree, ART buildbots can mock these lists
404# or have alternative rules for building them. Other rules in the build system
405# should depend on the files in the build folder.
David Brazdilf16ac002018-01-26 11:13:35 +0000406
David Brazdil05855332018-04-25 11:15:07 +0100407# Merge light greylist from multiple files:
David Brazdil721bc8e2018-05-08 15:04:20 +0100408# (1) manual greylist LOCAL_SRC_GREYLIST
409# (2) list of usages from vendor apps LOCAL_SRC_VENDOR_LIST
410# (3) list of removed APIs in LOCAL_SRC_REMOVED_API
David Brazdil05855332018-04-25 11:15:07 +0100411# @removed does not imply private in Doclava. We must take the subset also
David Brazdil721bc8e2018-05-08 15:04:20 +0100412# in LOCAL_SRC_PRIVATE_API.
David Brazdil05855332018-04-25 11:15:07 +0100413# (4) list of serialization APIs
414# Automatically adds all methods which match the signatures in
415# REGEX_SERIALIZATION. These are greylisted in order to allow applications
416# to write their own serializers.
David Brazdil721bc8e2018-05-08 15:04:20 +0100417$(LOCAL_LIGHT_GREYLIST): REGEX_SERIALIZATION := \
David Brazdil357170b12018-03-26 16:02:23 +0100418 "readObject\(Ljava/io/ObjectInputStream;\)V" \
419 "readObjectNoData\(\)V" \
420 "readResolve\(\)Ljava/lang/Object;" \
421 "serialVersionUID:J" \
422 "serialPersistentFields:\[Ljava/io/ObjectStreamField;" \
423 "writeObject\(Ljava/io/ObjectOutputStream;\)V" \
424 "writeReplace\(\)Ljava/lang/Object;"
David Brazdil721bc8e2018-05-08 15:04:20 +0100425$(LOCAL_LIGHT_GREYLIST): $(LOCAL_SRC_ALL)
Mathew Inwood1b045882018-07-11 15:55:32 +0100426 sort $(LOCAL_SRC_GREYLIST) $(LOCAL_SRC_VENDOR_LIST) $(PRIVATE_GREYLIST_INPUTS) \
David Brazdil721bc8e2018-05-08 15:04:20 +0100427 <(grep -E "\->("$(subst $(space),"|",$(REGEX_SERIALIZATION))")$$" \
428 $(LOCAL_SRC_PRIVATE_API)) \
429 <(comm -12 <(sort $(LOCAL_SRC_REMOVED_API)) <(sort $(LOCAL_SRC_PRIVATE_API))) \
430 > $@
431 $(call assert-has-no-duplicates,$@)
432 $(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API))
David Brazdil4b34f792018-05-08 16:49:02 +0100433 $(call assert-has-no-overlap,$@,$(LOCAL_SRC_FORCE_BLACKLIST))
David Brazdilf16ac002018-01-26 11:13:35 +0000434
David Brazdil4c3c0312018-05-10 15:50:02 +0100435# Generate dark greylist as remaining classes and class members in the same
436# package as classes listed in the light greylist.
David Brazdil185f00e2018-05-08 15:28:31 +0100437# The algorithm is as follows:
438# (1) extract the class descriptor from each entry in LOCAL_LIGHT_GREYLIST
David Brazdil4c3c0312018-05-10 15:50:02 +0100439# (2) strip everything after the last forward-slash,
440# e.g. 'Lpackage/subpackage/class$inner;' turns into 'Lpackage/subpackage/'
441# (3) insert all entries from LOCAL_SRC_PRIVATE_API which begin with the package
442# name but do not contain another forward-slash in the class name, e.g.
443# matching '^Lpackage/subpackage/[^/;]*;'
David Brazdil185f00e2018-05-08 15:28:31 +0100444# (4) subtract entries shared with LOCAL_LIGHT_GREYLIST
David Brazdil721bc8e2018-05-08 15:04:20 +0100445$(LOCAL_DARK_GREYLIST): $(LOCAL_SRC_ALL) $(LOCAL_LIGHT_GREYLIST)
David Brazdil4b34f792018-05-08 16:49:02 +0100446 comm -13 <(sort $(LOCAL_LIGHT_GREYLIST) $(LOCAL_SRC_FORCE_BLACKLIST)) \
David Brazdil6f6a1262018-05-31 13:58:41 +0100447 <(cat $(LOCAL_SRC_PUBLIC_API) $(LOCAL_LIGHT_GREYLIST) | \
448 sed 's/\->.*//' | sed 's/\(.*\/\).*/\1/' | sort | uniq | \
David Brazdil4c3c0312018-05-10 15:50:02 +0100449 while read PKG_NAME; do \
450 grep -E "^$${PKG_NAME}[^/;]*;" $(LOCAL_SRC_PRIVATE_API); \
David Brazdil185f00e2018-05-08 15:28:31 +0100451 done | sort | uniq) \
452 > $@
David Brazdil721bc8e2018-05-08 15:04:20 +0100453 $(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API))
454 $(call assert-has-no-duplicates,$@)
455 $(call assert-has-no-overlap,$@,$(LOCAL_LIGHT_GREYLIST))
David Brazdil4b34f792018-05-08 16:49:02 +0100456 $(call assert-has-no-overlap,$@,$(LOCAL_SRC_FORCE_BLACKLIST))
David Brazdil36bbf122018-03-28 11:28:39 +0100457
David Brazdil721bc8e2018-05-08 15:04:20 +0100458# Generate blacklist as private API minus (light greylist plus dark greylist).
459$(LOCAL_BLACKLIST): $(LOCAL_SRC_ALL) $(LOCAL_LIGHT_GREYLIST) $(LOCAL_DARK_GREYLIST)
460 comm -13 <(sort $(LOCAL_LIGHT_GREYLIST) $(LOCAL_DARK_GREYLIST)) \
461 <(sort $(LOCAL_SRC_PRIVATE_API)) \
462 > $@
463 $(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API))
464 $(call assert-has-no-duplicates,$@)
465 $(call assert-has-no-overlap,$@,$(LOCAL_LIGHT_GREYLIST))
466 $(call assert-has-no-overlap,$@,$(LOCAL_DARK_GREYLIST))
David Brazdil4b34f792018-05-08 16:49:02 +0100467 $(call assert-is-subset,$(LOCAL_SRC_FORCE_BLACKLIST),$@)
David Brazdil0649c8d2018-01-22 22:23:13 +0000468
Bart Searsa8cc0582015-05-07 03:23:20 +0000469# Include subdirectory makefiles
470# ============================================================
471
472# If we're building with ONE_SHOT_MAKEFILE (mm, mmm), then what the framework
473# team really wants is to build the stuff defined by this makefile.
474ifeq (,$(ONE_SHOT_MAKEFILE))
475include $(call first-makefiles-under,$(LOCAL_PATH))
476endif
477
Holly Jiuyu Sunbbc85802017-12-21 18:44:59 -0800478endif # ANDROID_BUILD_EMBEDDED