1# Add compiled framework resources to a robolectric jar file 2# Input variable: 3# robo_stub_module_name: the name of the make module that produces the Java library; the jar file should have been generated to 4# $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/$(robo_stub_module_name)_intermediates. 5# Output variable: 6# robo_full_target: the built classes-with-res.jar 7# 8# Depends on framework-res.apk, in order to pull the 9# resource files out of there. 10# 11robo_intermediates := $(call intermediates-dir-for,JAVA_LIBRARIES,$(robo_stub_module_name),,COMMON) 12robo_full_target := $(robo_intermediates)/classes-with-res.jar 13robo_input_jar := $(robo_intermediates)/classes.jar 14robo_classes_dir := $(robo_intermediates)/classes 15framework_res_package := $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk 16 17$(robo_full_target): PRIVATE_INTERMEDIATES_DIR := $(robo_intermediates) 18$(robo_full_target): PRIVATE_FRAMEWORK_RES_PACKAGE := $(framework_res_package) 19 20$(robo_full_target): PRIVATE_CLASS_INTERMEDIATES_DIR := $(robo_classes_dir) 21 22.KATI_RESTAT: $(robo_full_target) 23$(robo_full_target): $(framework_res_package) $(robo_input_jar) $(ZIPTIME) 24 @echo Adding framework resources: $@ 25 $(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) 26 $(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) 27 $(hide) if [ ! -f $(robo_input_jar) ]; then \ 28 echo Missing file $(robo_input_jar); \ 29 rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR); \ 30 exit 1; \ 31 fi; 32 $(hide) unzip -qo $(robo_input_jar) -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) 33 # Move the raw/uncompiled resources into raw-res/ 34 # This logic can be removed once the transition to binary resources is complete 35 $(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR)/raw-res 36 $(hide) mv $(PRIVATE_CLASS_INTERMEDIATES_DIR)/res $(PRIVATE_CLASS_INTERMEDIATES_DIR)/raw-res/ 37 $(hide) mv $(PRIVATE_CLASS_INTERMEDIATES_DIR)/assets $(PRIVATE_CLASS_INTERMEDIATES_DIR)/raw-res/ 38 $(hide) if [ ! -f $(PRIVATE_FRAMEWORK_RES_PACKAGE) ]; then \ 39 echo Missing file $(PRIVATE_FRAMEWORK_RES_PACKAGE); \ 40 rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR); \ 41 exit 1; \ 42 fi; 43 $(hide) unzip -qo $(PRIVATE_FRAMEWORK_RES_PACKAGE) -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) 44 $(hide) (cd $(PRIVATE_CLASS_INTERMEDIATES_DIR) && rm -rf classes.dex META-INF) 45 $(hide) mkdir -p $(dir $@) 46 $(hide) jar -cf $@.tmp -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) . 47 $(hide) jar -u0f $@.tmp -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) resources.arsc 48 $(hide) $(ZIPTIME) $@.tmp 49 $(hide) $(call commit-change-for-toc,$@) 50 51