The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame^] | 1 | # Requires: |
| 2 | # LOCAL_MODULE_SUFFIX |
| 3 | # LOCAL_MODULE_CLASS |
| 4 | # all_res_assets |
| 5 | |
| 6 | # Make sure there's something to build. |
| 7 | # It's possible to build a package that doesn't contain any classes. |
| 8 | ifeq (,$(strip $(LOCAL_SRC_FILES)$(all_res_assets))) |
| 9 | $(error $(LOCAL_PATH): Target java module does not define any source or resource files) |
| 10 | endif |
| 11 | |
| 12 | LOCAL_NO_STANDARD_LIBRARIES:=$(strip $(LOCAL_NO_STANDARD_LIBRARIES)) |
| 13 | LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION)) |
| 14 | |
| 15 | ifneq ($(LOCAL_SDK_VERSION),) |
| 16 | ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
| 17 | $(error $(LOCAL_PATH): Must not define both LOCAL_NO_STANDARD_LIBRARIES and LOCAL_SDK_VERSION) |
| 18 | else |
| 19 | ifeq ($(strip $(filter $(LOCAL_SDK_VERSION),$(TARGET_AVAILABLE_SDK_VERSIONS))),) |
| 20 | $(error $(LOCAL_PATH): Invalid LOCAL_SDK_VERSION '$(LOCAL_SDK_VERSION)' \ |
| 21 | Choices are: $(TARGET_AVAILABLE_SDK_VERSIONS)) |
| 22 | else |
| 23 | LOCAL_JAVA_LIBRARIES := android_stubs_$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES) |
| 24 | endif |
| 25 | endif |
| 26 | else |
| 27 | ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
| 28 | LOCAL_JAVA_LIBRARIES := core ext framework $(LOCAL_JAVA_LIBRARIES) |
| 29 | endif |
| 30 | endif |
| 31 | |
| 32 | LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM)) |
| 33 | ifeq ($(LOCAL_BUILT_MODULE_STEM),) |
| 34 | $(error $(LOCAL_PATH): Target java template must define LOCAL_BUILT_MODULE_STEM) |
| 35 | endif |
| 36 | ifeq ($(LOCAL_BUILT_MODULE_STEM),classes.jar) |
| 37 | $(error LOCAL_BUILT_MODULE_STEM may not be "classes.jar") |
| 38 | endif |
| 39 | |
| 40 | ####################################### |
| 41 | include $(BUILD_SYSTEM)/base_rules.mk |
| 42 | ####################################### |
| 43 | |
| 44 | # We use intermediates.COMMON because the classes.jar/.dex files will be |
| 45 | # common even if LOCAL_BUILT_MODULE isn't. |
| 46 | # |
| 47 | # Override some target variables that base_rules set up for us. |
| 48 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
| 49 | PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes |
| 50 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
| 51 | PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src |
| 52 | |
| 53 | # Since we're using intermediates.COMMON, make sure that it gets cleaned |
| 54 | # properly. |
| 55 | $(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON) |
| 56 | |
| 57 | # If the module includes java code (i.e., it's not framework-res), compile it. |
| 58 | full_classes_jar := |
| 59 | built_dex := |
| 60 | ifneq (,$(strip $(all_java_sources))) |
| 61 | |
| 62 | # If LOCAL_BUILT_MODULE_STEM wasn't overridden by our caller, |
| 63 | # full_classes_jar will be the same module as LOCAL_BUILT_MODULE. |
| 64 | # Otherwise, the caller will define it as a prerequisite of |
| 65 | # LOCAL_BUILT_MODULE, so it will inherit the necessary PRIVATE_* |
| 66 | # variable definitions. |
| 67 | # |
| 68 | # This intentionally depends on java_sources, not all_java_sources. |
| 69 | # Deps for generated source files must be handled separately, |
| 70 | # via deps on the target that generates the sources. |
| 71 | full_classes_jar := $(intermediates.COMMON)/classes.jar |
| 72 | $(full_classes_jar): $(java_sources) $(full_java_lib_deps) |
| 73 | $(transform-java-to-classes.jar) |
| 74 | |
| 75 | built_dex := $(intermediates.COMMON)/classes.dex |
| 76 | |
| 77 | # Override PRIVATE_INTERMEDIATES_DIR so that install-dex-debug |
| 78 | # will work even when intermediates != intermediates.COMMON. |
| 79 | $(built_dex): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON) |
| 80 | $(built_dex): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS) |
| 81 | $(built_dex): $(full_classes_jar) $(DX) |
| 82 | $(transform-classes.jar-to-dex) |
| 83 | ifneq ($(GENERATE_DEX_DEBUG),) |
| 84 | $(install-dex-debug) |
| 85 | endif |
| 86 | |
| 87 | findbugs_xml := $(intermediates.COMMON)/findbugs.xml |
| 88 | $(findbugs_xml) : PRIVATE_JAR_FILE := $(full_classes_jar) |
| 89 | $(findbugs_xml) : PRIVATE_AUXCLASSPATH := $(addprefix -auxclasspath ,$(strip \ |
| 90 | $(call normalize-path-list,$(filter %.jar,\ |
| 91 | $(full_java_libs))))) |
| 92 | # We can't depend directly on full_classes_jar because the PRIVATE_ |
| 93 | # vars won't be set up correctly. |
| 94 | $(findbugs_xml) : $(LOCAL_BUILT_MODULE) |
| 95 | @echo Findbugs: $@ |
| 96 | $(hide) $(FINDBUGS) -textui -effort:min -xml:withMessages \ |
| 97 | $(PRIVATE_AUXCLASSPATH) \ |
| 98 | $(PRIVATE_JAR_FILE) \ |
| 99 | > $@ |
| 100 | |
| 101 | ALL_FINDBUGS_FILES += $(findbugs_xml) |
| 102 | |
| 103 | findbugs_html := $(PRODUCT_OUT)/findbugs/$(LOCAL_MODULE).html |
| 104 | $(findbugs_html) : PRIVATE_XML_FILE := $(findbugs_xml) |
| 105 | $(LOCAL_MODULE)-findbugs : $(findbugs_html) |
| 106 | $(findbugs_html) : $(findbugs_xml) |
| 107 | @mkdir -p $(dir $@) |
| 108 | @echo UnionBugs: $@ |
| 109 | $(hide) prebuilt/common/findbugs/bin/unionBugs $(PRIVATE_XML_FILE) \ |
| 110 | | prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \ |
| 111 | > $@ |
| 112 | |
| 113 | $(LOCAL_MODULE)-findbugs : $(findbugs_html) |
| 114 | |
| 115 | endif |