1 # Build an SDK jar file out of the generated stubs 2 # Input variable: 3 # sdk_stub_name: the name of the SDK stubs; the stub source code should have been generated to 4 # $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/$(sdk_stub_name)_intermediates. 5 # stub_timestamp: the timestamp file we use as dependency of the generated source. 6 # Output variable: 7 # full_target: the built classes.jar 8 9 # The source files for this library are _all_ generated, something we don't do 10 # anywhere else, and the rules don't support. Aditionally, the depenencies on 11 # these files don't really matter, because they are all generated as part of 12 # building the docs. So for the dependency, we just use the 13 # api-stubs-timestamp file, which is the $@ of the droiddoc rule. 14 # We also need to depend on framework-res.apk, in order to pull the 15 # resource files out of there for aapt. 16 # 17 # Normally the package rule runs aapt, which includes the resource, 18 # but we're not running that in our package rule so just copy in the 19 # resource files here. 20 intermediates := $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/$(sdk_stub_name)_intermediates 21 full_target := $(intermediates)/classes.jar 22 src_dir := $(intermediates)/src 23 classes_dir := $(intermediates)/classes 24 framework_res_package := $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk 25 26 $(full_target): PRIVATE_SRC_DIR := $(src_dir) 27 $(full_target): PRIVATE_INTERMEDIATES_DIR := $(intermediates) 28 $(full_target): PRIVATE_CLASS_INTERMEDIATES_DIR := $(classes_dir) 29 $(full_target): PRIVATE_FRAMEWORK_RES_PACKAGE := $(framework_res_package) 30 31 $(full_target): $(stub_timestamp) $(framework_res_package) 32 @echo Compiling SDK Stubs: $@ 33 $(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) 34 $(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) 35 $(hide) find $(PRIVATE_SRC_DIR) -name "*.java" > \ 36 $(PRIVATE_INTERMEDIATES_DIR)/java-source-list 37 $(hide) $(TARGET_JAVAC) -encoding ascii -bootclasspath "" \ 38 -g $(xlint_unchecked) \ 39 -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \ 40 \@$(PRIVATE_INTERMEDIATES_DIR)/java-source-list \ 41 || ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) 42 $(hide) if [ ! -f $(PRIVATE_FRAMEWORK_RES_PACKAGE) ]; then \ 43 echo Missing file $(PRIVATE_FRAMEWORK_RES_PACKAGE); \ 44 rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR); \ 45 exit 1; \ 46 fi; 47 $(hide) unzip -qo $(PRIVATE_FRAMEWORK_RES_PACKAGE) -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) 48 $(hide) (cd $(PRIVATE_CLASS_INTERMEDIATES_DIR) && rm -rf classes.dex META-INF) 49 $(hide) mkdir -p $(dir $@) 50 $(hide) jar -cf $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) . 51 $(hide) jar -u0f $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) resources.arsc 52