diff --git a/core/definitions.mk b/core/definitions.mk index 033ab30fd..5f0bf551d 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2138,6 +2138,17 @@ $(hide) $(ZIPTIME) $@.tmp $(hide) $(call commit-change-for-toc,$@) endef +# Runs jarjar on an input file. Jarjar doesn't exit with a nonzero return code +# when there is a syntax error in a rules file and doesn't write the output +# file, so removes the output file before running jarjar and check if it exists +# after running jarjar. +define transform-jarjar +echo $($(PRIVATE_PREFIX)DISPLAY) JarJar: $@ +rm -f $@ +$(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ +[ -e $@ ] || (echo "Missing output file"; exit 1) +endef + # Moves $1.tmp to $1 if necessary. This is designed to be used with # .KATI_RESTAT. For kati, this function doesn't update the timestamp # of $1 when $1.tmp is identical to $1 so that ninja won't rebuild diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk index da329788e..5eeb8ac91 100644 --- a/core/host_dalvik_java_library.mk +++ b/core/host_dalvik_java_library.mk @@ -125,8 +125,7 @@ $(full_classes_turbine_jar): \ ifneq ($(strip $(LOCAL_JARJAR_RULES)),) $(full_classes_header_jarjar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) $(full_classes_header_jarjar): $(full_classes_turbine_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) - @echo Header JarJar: $@ - $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ + $(call transform-jarjar) else full_classes_header_jarjar := $(full_classes_turbine_jar) endif @@ -149,8 +148,7 @@ $(full_classes_combined_jar): $(full_classes_compiled_jar) \ ifneq ($(strip $(LOCAL_JARJAR_RULES)),) $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) $(full_classes_jarjar_jar): $(full_classes_combined_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) - @echo JarJar: $@ - $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ + $(call transform-jarjar) else full_classes_jarjar_jar := $(full_classes_combined_jar) endif diff --git a/core/host_java_library.mk b/core/host_java_library.mk index f9abe9bc4..0f9520297 100644 --- a/core/host_java_library.mk +++ b/core/host_java_library.mk @@ -113,8 +113,7 @@ $(full_classes_combined_jar): $(full_classes_compiled_jar) \ ifneq ($(strip $(LOCAL_JARJAR_RULES)),) $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) $(full_classes_jarjar_jar): $(full_classes_combined_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) - @echo JarJar: $@ - $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ + $(call transform-jarjar) else full_classes_jarjar_jar := $(full_classes_combined_jar) endif diff --git a/core/java.mk b/core/java.mk index 5fe8da571..d28c0c477 100644 --- a/core/java.mk +++ b/core/java.mk @@ -253,8 +253,7 @@ $(full_classes_turbine_jar): \ ifneq ($(strip $(LOCAL_JARJAR_RULES)),) $(full_classes_header_jarjar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) $(full_classes_header_jarjar): $(full_classes_turbine_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) - @echo Header JarJar: $@ - $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ + $(call transform-jarjar) else full_classes_header_jarjar := $(full_classes_turbine_jar) endif @@ -334,8 +333,7 @@ endif ifneq ($(strip $(LOCAL_JARJAR_RULES)),) $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) $(full_classes_jarjar_jar): $(full_classes_processed_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) - @echo JarJar: $@ - $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ + $(call transform-jarjar) else full_classes_jarjar_jar := $(full_classes_processed_jar) endif