blob: 87ef47f9f3071969f906915248985fdf92c99141 [file] [log] [blame]
Igor Murashkin34a08fb2016-03-16 12:03:09 -07001# Copyright (C) 2016 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16#
17# Build support for guice within the Android Open Source Project
18# See https://source.android.com/source/building.html for more information
19#
20
21###################################
22# Guice #
23###################################
24
25#
26# Builds the 'no_aop' flavor for Android.
27# -- see core/pom.xml NO_AOP rule.
28#
29guice_exclude_src_files := \
30 core/src/com/google/inject/spi/InterceptorBinding.java \
31 core/src/com/google/inject/internal/InterceptorBindingProcessor.java \
32 core/src/com/google/inject/internal/InterceptorStackCallback.java \
33 core/src/com/google/inject/internal/InterceptorStackCallback.java \
34 core/src/com/google/inject/internal/util/LineNumbers.java \
35 core/src/com/google/inject/internal/MethodAspect.java \
36 core/src/com/google/inject/internal/ProxyFactory.java
37
38guice_exclude_test_files := \
39 core/test/com/googlecode/guice/BytecodeGenTest.java \
40 core/test/com/google/inject/IntegrationTest.java \
41 core/test/com/google/inject/MethodInterceptionTest.java \
42 core/test/com/google/inject/internal/ProxyFactoryTest.java
43
44guice_munge_flags := \
45 -DNO_AOP
46#
47#
48#
49
50LOCAL_PATH := $(call my-dir)
51
52guice_src_files_raw := $(call all-java-files-under,core/src)
53guice_test_files_raw := $(call all-java-files-under,core/test)
54guice_src_files := $(filter-out $(guice_exclude_src_files),$(guice_src_files_raw))
55guice_test_files := $(filter-out $(guice_exclude_test_files),$(guice_test_files_raw))
56munge_host_jar := $(HOST_OUT)/framework/munge-host.jar
57munge_zip_location := lib/build/munge.jar
58
59#
60# Host-side Java build
61include $(CLEAR_VARS)
62LOCAL_SRC_FILES := # None. Everything is post-processed by munge. See below.
63LOCAL_MODULE := guice-host
64LOCAL_MODULE_TAGS := optional
65LOCAL_STATIC_JAVA_LIBRARIES := guavalib jsr330-host
66
67munge_src_arguments := $(guice_src_files)
68include $(LOCAL_PATH)/AndroidCallMunge.mk
69include $(BUILD_HOST_JAVA_LIBRARY)
70
71
72#
73# Host-side Dalvik build
74include $(CLEAR_VARS)
75LOCAL_SRC_FILES := # None. Everything is post-processed by munge. See below.
76LOCAL_MODULE := guice-hostdex
77LOCAL_MODULE_TAGS := optional
78LOCAL_STATIC_JAVA_LIBRARIES := guava-hostdex jsr330-hostdex
79LOCAL_MODULE_CLASS := JAVA_LIBRARIES
80munge_src_arguments := $(guice_src_files)
81include $(LOCAL_PATH)/AndroidCallMunge.mk
82include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
83
84###################################
85# Munge #
86###################################
87
88# This is required to post-process the guice source to strip out the AOP-specific code.
89# We build it from source (conveniently zipped inside of lib/build/munge.jar) instead
90# of relying on a prebuilt.
91
92munge_zipped_src_files_raw := $(filter %.java,$(shell unzip -Z1 "$(LOCAL_PATH)/$(munge_zip_location)"))
93munge_zipped_unsupported_files := MungeTask.java # Missing ant dependencies in Android.
94munge_zipped_src_files := $(filter-out $(munge_zipped_unsupported_files),$(munge_zipped_src_files_raw))
95
96#
97# We build munge from lib/build/munge.jar source code.
98#
99
100# (Munge) Host-side Java build
101include $(CLEAR_VARS)
102LOCAL_SRC_FILES := # None because we get everything by unzipping the munge jar first.
103LOCAL_MODULE := munge-host
104LOCAL_MODULE_TAGS := optional
105LOCAL_JAVA_LIBRARIES := junit
106LOCAL_MODULE_CLASS := JAVA_LIBRARIES
107# Unzip munge and build it
108intermediates:= $(local-generated-sources-dir)
109GEN := $(addprefix $(intermediates)/, $(munge_zipped_src_files)) # List of all files that need to be patched.
110$(GEN) : PRIVATE_PATH := $(LOCAL_PATH)
111$(GEN) : PRIVATE_INPUT_FILE := $(munge_zipped_src_files)
112$(GEN) : PRIVATE_ZIP_LOCATION := $(munge_zip_location)
113$(GEN) : PRIVATE_CUSTOM_TOOL = unzip -p "$(PRIVATE_PATH)/$(PRIVATE_ZIP_LOCATION)" $(shell echo $@ | awk -F / "{if (NF>1) {print \$$NF}}") >$@ ## unzip -p munge.jar Filename.java > intermediates/Filename.java
114$(GEN): $(intermediates)/%.java : $(LOCAL_PATH)/$(PRIVATE_ZIP_LOCATION)
115 $(transform-generated-source)
116LOCAL_GENERATED_SOURCES += $(GEN)
117
118include $(BUILD_HOST_JAVA_LIBRARY)
119
120
121# Rules for target, hostdex, etc., are omitted since munge is only used during the build.
122
123# TODO: Consider adding tests.