Igor Murashkin | 34a08fb | 2016-03-16 12:03:09 -0700 | [diff] [blame] | 1 | # 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 | # |
| 29 | guice_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 | |
| 38 | guice_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 | |
| 44 | guice_munge_flags := \ |
| 45 | -DNO_AOP |
| 46 | # |
| 47 | # |
| 48 | # |
| 49 | |
| 50 | LOCAL_PATH := $(call my-dir) |
| 51 | |
| 52 | guice_src_files_raw := $(call all-java-files-under,core/src) |
| 53 | guice_test_files_raw := $(call all-java-files-under,core/test) |
| 54 | guice_src_files := $(filter-out $(guice_exclude_src_files),$(guice_src_files_raw)) |
| 55 | guice_test_files := $(filter-out $(guice_exclude_test_files),$(guice_test_files_raw)) |
| 56 | munge_host_jar := $(HOST_OUT)/framework/munge-host.jar |
| 57 | munge_zip_location := lib/build/munge.jar |
| 58 | |
| 59 | # |
Igor Murashkin | 83b7ddb | 2016-04-01 14:22:51 -0700 | [diff] [blame] | 60 | # Target-side Dalvik build |
| 61 | include $(CLEAR_VARS) |
| 62 | LOCAL_SRC_FILES := # None. Everything is post-processed by munge. See below. |
| 63 | LOCAL_MODULE := guice |
| 64 | LOCAL_STATIC_JAVA_LIBRARIES := guava jsr330 |
| 65 | LOCAL_MODULE_CLASS := JAVA_LIBRARIES |
| 66 | munge_src_arguments := $(guice_src_files) |
| 67 | include $(LOCAL_PATH)/AndroidCallMunge.mk |
| 68 | include $(BUILD_STATIC_JAVA_LIBRARY) |
| 69 | |
| 70 | |
| 71 | # |
Igor Murashkin | 34a08fb | 2016-03-16 12:03:09 -0700 | [diff] [blame] | 72 | # Host-side Java build |
| 73 | include $(CLEAR_VARS) |
| 74 | LOCAL_SRC_FILES := # None. Everything is post-processed by munge. See below. |
| 75 | LOCAL_MODULE := guice-host |
Igor Murashkin | 34a08fb | 2016-03-16 12:03:09 -0700 | [diff] [blame] | 76 | LOCAL_STATIC_JAVA_LIBRARIES := guavalib jsr330-host |
| 77 | |
| 78 | munge_src_arguments := $(guice_src_files) |
| 79 | include $(LOCAL_PATH)/AndroidCallMunge.mk |
| 80 | include $(BUILD_HOST_JAVA_LIBRARY) |
| 81 | |
| 82 | |
| 83 | # |
| 84 | # Host-side Dalvik build |
| 85 | include $(CLEAR_VARS) |
| 86 | LOCAL_SRC_FILES := # None. Everything is post-processed by munge. See below. |
| 87 | LOCAL_MODULE := guice-hostdex |
Igor Murashkin | 34a08fb | 2016-03-16 12:03:09 -0700 | [diff] [blame] | 88 | LOCAL_STATIC_JAVA_LIBRARIES := guava-hostdex jsr330-hostdex |
| 89 | LOCAL_MODULE_CLASS := JAVA_LIBRARIES |
| 90 | munge_src_arguments := $(guice_src_files) |
| 91 | include $(LOCAL_PATH)/AndroidCallMunge.mk |
Colin Cross | 0afca74 | 2017-01-19 14:13:48 -0800 | [diff] [blame] | 92 | include $(BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY) |
Igor Murashkin | 34a08fb | 2016-03-16 12:03:09 -0700 | [diff] [blame] | 93 | |
| 94 | ################################### |
| 95 | # Munge # |
| 96 | ################################### |
| 97 | |
| 98 | # This is required to post-process the guice source to strip out the AOP-specific code. |
| 99 | # We build it from source (conveniently zipped inside of lib/build/munge.jar) instead |
| 100 | # of relying on a prebuilt. |
| 101 | |
| 102 | munge_zipped_src_files_raw := $(filter %.java,$(shell unzip -Z1 "$(LOCAL_PATH)/$(munge_zip_location)")) |
| 103 | munge_zipped_unsupported_files := MungeTask.java # Missing ant dependencies in Android. |
| 104 | munge_zipped_src_files := $(filter-out $(munge_zipped_unsupported_files),$(munge_zipped_src_files_raw)) |
| 105 | |
| 106 | # |
| 107 | # We build munge from lib/build/munge.jar source code. |
| 108 | # |
| 109 | |
| 110 | # (Munge) Host-side Java build |
| 111 | include $(CLEAR_VARS) |
| 112 | LOCAL_SRC_FILES := # None because we get everything by unzipping the munge jar first. |
| 113 | LOCAL_MODULE := munge-host |
Paul Duffin | 788548b | 2016-11-29 12:29:15 +0000 | [diff] [blame] | 114 | LOCAL_JAVA_LIBRARIES := junit-host |
Igor Murashkin | 34a08fb | 2016-03-16 12:03:09 -0700 | [diff] [blame] | 115 | LOCAL_MODULE_CLASS := JAVA_LIBRARIES |
| 116 | # Unzip munge and build it |
| 117 | intermediates:= $(local-generated-sources-dir) |
| 118 | GEN := $(addprefix $(intermediates)/, $(munge_zipped_src_files)) # List of all files that need to be patched. |
| 119 | $(GEN) : PRIVATE_PATH := $(LOCAL_PATH) |
| 120 | $(GEN) : PRIVATE_INPUT_FILE := $(munge_zipped_src_files) |
| 121 | $(GEN) : PRIVATE_ZIP_LOCATION := $(munge_zip_location) |
| 122 | $(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 |
| 123 | $(GEN): $(intermediates)/%.java : $(LOCAL_PATH)/$(PRIVATE_ZIP_LOCATION) |
| 124 | $(transform-generated-source) |
| 125 | LOCAL_GENERATED_SOURCES += $(GEN) |
| 126 | |
| 127 | include $(BUILD_HOST_JAVA_LIBRARY) |
| 128 | |
| 129 | |
| 130 | # Rules for target, hostdex, etc., are omitted since munge is only used during the build. |
| 131 | |
| 132 | # TODO: Consider adding tests. |