Home | History | Annotate | Download | only in core
      1 #
      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 #
     16 
     17 $(call record-module-type,HOST_JAVA_LIBRARY)
     18 
     19 #
     20 # Standard rules for building a host java library.
     21 #
     22 
     23 #######################################
     24 include $(BUILD_SYSTEM)/host_java_library_common.mk
     25 #######################################
     26 
     27 # Enable emma instrumentation only if the module asks so.
     28 ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
     29 ifneq (true,$(EMMA_INSTRUMENT))
     30 LOCAL_EMMA_INSTRUMENT :=
     31 endif
     32 endif
     33 
     34 full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar
     35 full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
     36 emma_intermediates_dir := $(intermediates.COMMON)/emma_out
     37 # emma is hardcoded to use the leaf name of its input for the output file --
     38 # only the output directory can be changed
     39 full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(notdir $(full_classes_jarjar_jar))
     40 full_classes_jar := $(intermediates.COMMON)/classes.jar
     41 
     42 LOCAL_INTERMEDIATE_TARGETS += \
     43     $(full_classes_compiled_jar) \
     44     $(full_classes_jarjar_jar) \
     45     $(full_classes_emma_jar)
     46 
     47 #######################################
     48 include $(BUILD_SYSTEM)/base_rules.mk
     49 #######################################
     50 
     51 java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) \
     52                 $(filter %.java,$(LOCAL_GENERATED_SOURCES))
     53 all_java_sources := $(java_sources)
     54 
     55 include $(BUILD_SYSTEM)/java_common.mk
     56 
     57 # The layers file allows you to enforce a layering between java packages.
     58 # Run build/tools/java-layers.py for more details.
     59 layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))
     60 
     61 # If error prone is enabled then add LOCAL_ERROR_PRONE_FLAGS to LOCAL_JAVACFLAGS
     62 ifeq ($(RUN_ERROR_PRONE),true)
     63 LOCAL_JAVACFLAGS += $(LOCAL_ERROR_PRONE_FLAGS)
     64 endif
     65 
     66 $(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
     67 $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS)
     68 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
     69 $(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
     70 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
     71 $(full_classes_compiled_jar): \
     72         $(java_sources) \
     73         $(java_resource_sources) \
     74         $(full_java_lib_deps) \
     75         $(jar_manifest_file) \
     76         $(proto_java_sources_file_stamp) \
     77         $(NORMALIZE_PATH) \
     78         $(LOCAL_ADDITIONAL_DEPENDENCIES)
     79 	$(transform-host-java-to-package)
     80 
     81 javac-check : $(full_classes_compiled_jar)
     82 javac-check-$(LOCAL_MODULE) : $(full_classes_compiled_jar)
     83 
     84 # Run jarjar if necessary, otherwise just copy the file.
     85 ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
     86 $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
     87 $(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
     88 	@echo JarJar: $@
     89 	$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
     90 else
     91 full_classes_jarjar_jar := $(full_classes_compiled_jar)
     92 endif
     93 
     94 ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
     95 $(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILE := $(intermediates.COMMON)/coverage.em
     96 $(full_classes_emma_jar): PRIVATE_EMMA_INTERMEDIATES_DIR := $(emma_intermediates_dir)
     97 ifdef LOCAL_EMMA_COVERAGE_FILTER
     98 $(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := $(LOCAL_EMMA_COVERAGE_FILTER)
     99 else
    100 # by default, avoid applying emma instrumentation onto emma classes itself,
    101 # otherwise there will be exceptions thrown
    102 $(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := *,-emma,-emmarun,-com.vladium.*
    103 endif
    104 # this rule will generate both $(PRIVATE_EMMA_COVERAGE_FILE) and
    105 # $(full_classes_emma_jar)
    106 $(full_classes_emma_jar) : $(full_classes_jarjar_jar) | $(EMMA_JAR)
    107 	$(transform-classes.jar-to-emma)
    108 else # LOCAL_EMMA_INSTRUMENT
    109 full_classes_emma_jar := $(full_classes_jarjar_jar)
    110 endif # LOCAL_EMMA_INSTRUMENT
    111 
    112 $(eval $(call copy-one-file,$(full_classes_emma_jar),$(LOCAL_BUILT_MODULE)))
    113 $(eval $(call copy-one-file,$(full_classes_emma_jar),$(full_classes_jar)))
    114