blob: f74d23c0f189778fbbf19fa110be956a20712b2e [file] [log] [blame]
Ying Wang78e75a92014-06-03 10:40:10 -07001# 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.
20intermediates := $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/$(sdk_stub_name)_intermediates
21full_target := $(intermediates)/classes.jar
Yohann Roussel83efd5e2014-09-08 14:48:26 +020022jack_lib := $(intermediates)/classes.jack
Ying Wang78e75a92014-06-03 10:40:10 -070023src_dir := $(intermediates)/src
24classes_dir := $(intermediates)/classes
25framework_res_package := $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
26
27$(full_target): PRIVATE_SRC_DIR := $(src_dir)
28$(full_target): PRIVATE_INTERMEDIATES_DIR := $(intermediates)
29$(full_target): PRIVATE_CLASS_INTERMEDIATES_DIR := $(classes_dir)
30$(full_target): PRIVATE_FRAMEWORK_RES_PACKAGE := $(framework_res_package)
31
32$(full_target): $(stub_timestamp) $(framework_res_package)
33 @echo Compiling SDK Stubs: $@
34 $(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR)
35 $(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR)
36 $(hide) find $(PRIVATE_SRC_DIR) -name "*.java" > \
37 $(PRIVATE_INTERMEDIATES_DIR)/java-source-list
38 $(hide) $(TARGET_JAVAC) -encoding ascii -bootclasspath "" \
39 -g $(xlint_unchecked) \
40 -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \
41 \@$(PRIVATE_INTERMEDIATES_DIR)/java-source-list \
42 || ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 )
43 $(hide) if [ ! -f $(PRIVATE_FRAMEWORK_RES_PACKAGE) ]; then \
44 echo Missing file $(PRIVATE_FRAMEWORK_RES_PACKAGE); \
45 rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR); \
46 exit 1; \
47 fi;
48 $(hide) unzip -qo $(PRIVATE_FRAMEWORK_RES_PACKAGE) -d $(PRIVATE_CLASS_INTERMEDIATES_DIR)
49 $(hide) (cd $(PRIVATE_CLASS_INTERMEDIATES_DIR) && rm -rf classes.dex META-INF)
50 $(hide) mkdir -p $(dir $@)
51 $(hide) jar -cf $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) .
52 $(hide) jar -u0f $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) resources.arsc
Yohann Roussel83efd5e2014-09-08 14:48:26 +020053
Yohann Roussel491a3ad2014-11-25 13:44:02 +010054$(jack_lib) : $(full_target) $(JILL_JAR) $(JACK_JAR)
Yohann Roussel83efd5e2014-09-08 14:48:26 +020055 $(transform-jar-to-jack)