187182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# Copyright (C) 2015 The Android Open Source Project 287182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# 387182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# Licensed under the Apache License, Version 2.0 (the "License"); 487182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# you may not use this file except in compliance with the License. 587182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# You may obtain a copy of the License at 687182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# 787182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# http://www.apache.org/licenses/LICENSE-2.0 887182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# 987182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# Unless required by applicable law or agreed to in writing, software 1087182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# distributed under the License is distributed on an "AS IS" BASIS, 1187182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1287182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# See the License for the specific language governing permissions and 1387182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# limitations under the License. 1487182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin 1587182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# Manages use of annotation processors. 1687182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# 1787182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# At the moment both the -processorpath and the -processor 1887182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# flags must be specified in order to use annotation processors 1987182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# as a code indexing tool that wraps javac doesn't as yet support 2087182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# the same behaviour as standard javac with regard to use of 2187182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# annotation processors. In particular it: 2287182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# - doesn't default -processorpath to be the same as -classpath 2387182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# - doesn't scan processorpath to automatically discover processors 2487182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# - doesn't support a comma separated list of processor class names 2587182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# on a single -processor option so need on option per class name. 2687182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# 2787182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# Input variables: 2887182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# 2987182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# PROCESSOR_LIBRARIES := <list of library names> 3087182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# Similar to names added to LOCAL_JAVA_LIBRARIES. 3187182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# 3287182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# PROCESSOR_CLASSES := <list of processor class names> 3387182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# 3487182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# Upon exit various LOCAL_ variables have been updated and the 3587182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# input variables have been cleared. 3687182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin 3787182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# Map the library names to actual JARs. 3887182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul DuffinPROCESSOR_JARS := $(call java-lib-deps, $(PROCESSOR_LIBRARIES), true) 3987182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin 4087182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# Add a javac -processorpath flag. 4187182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul DuffinLOCAL_JAVACFLAGS += -processorpath $(call normalize-path-list,$(PROCESSOR_JARS)) 4287182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin 4387182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# Specify only one processor class per -processor option as 4487182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# the indexing tool does not parse the -processor value as a 4587182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# comma separated list. 4687182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul DuffinLOCAL_JAVACFLAGS += $(foreach class,$(PROCESSOR_CLASSES),-processor $(class)) 4787182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin 4887182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# Create a source directory into which the code will be generated. 4987182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul DuffinGENERATED_SOURCE_DIR := $(local-generated-sources-dir)/annotation_processor_output/ 5087182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin 5187182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# Tell javac to generate source files in the source directory. 5287182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul DuffinLOCAL_JAVACFLAGS += -s $(GENERATED_SOURCE_DIR) 5387182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin 5487182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# Add dependency between the jar being built and the processor jars so that 5587182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# they are built before this one. 5687182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul DuffinLOCAL_ADDITIONAL_DEPENDENCIES += $(PROCESSOR_JARS) $(GENERATED_SOURCE_DIR) 5787182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin 5887182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin$(GENERATED_SOURCE_DIR): 5987182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin mkdir -p $@ 6087182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin 6187182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# Clean up all the extra variables to make sure that they don't escape to 6287182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul Duffin# another module. 6387182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul DuffinPROCESSOR_LIBRARIES := 6487182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul DuffinPROCESSOR_CLASSES := 6587182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul DuffinPROCESSOR_JARS := 6687182e06b8f6ec9a11ed6ebcaf74444e79b18ae2Paul DuffinGENERATED_SOURCE_DIR := 67