android: Update build system for recent SDK versions and target ice cream sandwich.

As a result, the java parts can now be build using ant (in the android dir).
Just issue "ant debug" after "make libs". Building the java parts from eclipse
also still works.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31543 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2012-01-03 21:15:21 +00:00
parent 84f651f9b6
commit e9cb9538c7
6 changed files with 161 additions and 24 deletions

View File

@ -3,5 +3,5 @@
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -27,9 +27,6 @@ $(CPUFEAT_BUILD)/cpu-features.o: $(CPUFEAT)/cpu-features.c
.SECONDEXPANSION: # $$(OBJ) is not populated until after this
.PHONY: apk classes clean dex dirs libs jar
java2class = $(addsuffix .class,$(basename $(subst $(ANDROID_DIR),$(BUILDDIR),$(1))))
# API version
ANDROID_PLATFORM_VERSION=11
ANDROID_PLATFORM=$(ANDROID_SDK_PATH)/platforms/android-$(ANDROID_PLATFORM_VERSION)
@ -42,21 +39,27 @@ ZIPALIGN=$(ANDROID_SDK_PATH)/tools/zipalign
KEYSTORE=$(HOME)/.android/debug.keystore
ADB=$(ANDROID_SDK_PATH)/platform-tools/adb
CLASSPATH := $(BUILDDIR)/bin/classes
MANIFEST := $(BUILDDIR)/bin/AndroidManifest.xml
MANIFEST_SRC := $(ANDROID_DIR)/AndroidManifest.xml
R_JAVA := $(BUILDDIR)/gen/$(PACKAGE_PATH)/R.java
R_OBJ := $(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class
R_OBJ := $(CLASSPATH)/$(PACKAGE_PATH)/R.class
JAVA_SRC := $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/*.java)
JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/Helper/*.java)
JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/widgets/*.java)
JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/monitors/*.java)
JAVA_OBJ := $(call java2class,$(subst $(ANDROID)/src/$(PACKAGE_PATH),$(ANDROID)/bin/$(PACKAGE_PATH),$(JAVA_SRC)))
java2class = $(addsuffix .class,$(basename $(subst $(ANDROID_DIR)/src,$(CLASSPATH),$(1))))
JAVA_OBJ := $(call java2class,$(JAVA_SRC))
LIBS := $(BINLIB_DIR)/$(BINARY) $(BINLIB_DIR)/libmisc.so
LIBS += $(addprefix $(BINLIB_DIR)/lib,$(patsubst %.codec,%.so,$(notdir $(CODECS))))
TEMP_APK := $(BUILDDIR)/bin/_rockbox.apk
TEMP_APK2 := $(BUILDDIR)/bin/__rockbox.apk
DEX := $(BUILDDIR)/bin/classes.dex
@ -65,17 +68,17 @@ AP_ := $(BUILDDIR)/bin/resources.ap_
APK := $(BUILDDIR)/rockbox.apk
_DIRS := $(BUILDDIR)/___/$(PACKAGE_PATH)
DIRS := $(subst ___,bin,$(_DIRS))
DIRS += $(subst ___,gen,$(_DIRS))
DIRS += $(subst ___,data,$(_DIRS))
DIRS += $(BUILDDIR)/libs/armeabi
DIRS += $(CPUFEAT_BUILD)
DIRS += $(CLASSPATH)
RES := $(wildcard $(ANDROID_DIR)/res/*/*)
CLEANOBJS += bin gen libs data
JAVAC_OPTS += -implicit:none -classpath $(ANDROID_PLATFORM)/android.jar:$(BUILDDIR)/bin
JAVAC_OPTS += -implicit:none -classpath $(ANDROID_PLATFORM)/android.jar:$(CLASSPATH)
.PHONY:
$(MANIFEST): $(MANIFEST_SRC) $(DIRS)
@ -86,21 +89,18 @@ $(R_JAVA) $(AP_): $(MANIFEST) $(RES) | $(DIRS)
-J $(BUILDDIR)/gen -M $(MANIFEST) -S $(ANDROID_DIR)/res \
-I $(ANDROID_PLATFORM)/android.jar -F $(AP_)
$(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class: $(R_JAVA)
$(CLASSPATH)/$(PACKAGE_PATH)/R.class: $(R_JAVA)
$(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$<))javac -d $(BUILDDIR)/bin \
$(JAVAC_OPTS) \
-sourcepath $(ANDROID_DIR)/gen $<
$(JAVAC_OPTS) -sourcepath $(ANDROID_DIR)/gen $<
$(BUILDDIR)/bin/$(PACKAGE_PATH)/%.class: $(ANDROID_DIR)/src/$(PACKAGE_PATH)/%.java $(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class
$(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$<))javac -d $(BUILDDIR)/bin \
$(JAVAC_OPTS) \
-sourcepath $(ANDROID_DIR)/src $<
$(CLASSPATH)/$(PACKAGE_PATH)/%.class: $(ANDROID_DIR)/src/$(PACKAGE_PATH)/%.java $(CLASSPATH)/$(PACKAGE_PATH)/R.class
$(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$<))javac -d $(CLASSPATH) \
$(JAVAC_OPTS) -sourcepath $(ANDROID_DIR)/src $<
$(JAR): $(JAVA_SRC) $(R_JAVA)
$(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$?))javac -d $(BUILDDIR)/bin \
$(JAVAC_OPTS) \
-sourcepath $(ANDROID_DIR)/src:$(ANDROID_DIR)/gen $?
$(call PRINTS,JAR $(subst $(BUILDDIR)/,,$@))jar cf $(JAR) -C $(BUILDDIR)/bin org
$(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$?))javac -d $(CLASSPATH) \
$(JAVAC_OPTS) -sourcepath $(ANDROID_DIR)/src:$(ANDROID_DIR)/gen $?
$(call PRINTS,JAR $(subst $(BUILDDIR)/,,$@))jar cf $(JAR) -C $(CLASSPATH) org
jar: $(JAR)
@ -127,7 +127,7 @@ $(BINLIB_DIR)/libmisc.so: $(BUILDDIR)/rockbox.zip
$(BINLIB_DIR)/lib%.so: $(BUILDDIR)/apps/codecs/%.codec
$(call PRINTS,CP $(@F))cp $^ $@
libs: $(LIBS)
libs: $(DIRS) $(LIBS)
$(TEMP_APK): $(AP_) $(LIBS) $(DEX) | $(DIRS)
$(call PRINTS,APK $(subst $(BUILDDIR)/,,$@))$(APKBUILDER) $@ \

12
android/ant.properties Normal file
View File

@ -0,0 +1,12 @@
# Override some props according to android.make
# see $ANDROID_SDK_PATH/tools/ant/build.xml for what's overridable
# Once we can build signed *release* builds, we should have a different
# names for the debug builds
# the signed, unzipaligned file is bin/__rockbox.apk
out.packaged.file=bin/__${ant.project.name}.apk
# the final file is rockbox.apk, in the build dir
out.packaged.file=${ant.project.name}.apk

85
android/build.xml Normal file
View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="rockbox" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
unless="sdk.dir"
/>
<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
<!--
<target name="-pre-build">
</target>
<target name="-pre-compile">
</target>
/* This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir} */
<target name="-post-compile">
</target>
-->
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

40
android/proguard.cfg Normal file
View File

@ -0,0 +1,40 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

View File

@ -1,11 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
#
# This file must be checked in Version Control Systems.
#
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-11
target=android-15