aboutsummaryrefslogtreecommitdiffstats
path: root/anttasks
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-09-15 18:10:59 -0700
committerXavier Ducrohet <xav@android.com>2011-09-15 18:10:59 -0700
commit91308ed41e99d6d6ffb6117740c3debdd4e08764 (patch)
tree5175a8ca7413f885b6a447491d3a043df652f20c /anttasks
parent6e214496edc57aab166d845e6f2b44a8febf5a77 (diff)
downloadsdk-91308ed41e99d6d6ffb6117740c3debdd4e08764.zip
sdk-91308ed41e99d6d6ffb6117740c3debdd4e08764.tar.gz
sdk-91308ed41e99d6d6ffb6117740c3debdd4e08764.tar.bz2
Pass -target-api to the renderscript compiler.
This allows to use a single llvm executable to target all API versions. Change-Id: Ib27f7fc9e54c548d31fc98fc323f439cb99218d5
Diffstat (limited to 'anttasks')
-rw-r--r--anttasks/src/com/android/ant/NewSetupTask.java20
-rw-r--r--anttasks/src/com/android/ant/RenderScriptTask.java34
2 files changed, 45 insertions, 9 deletions
diff --git a/anttasks/src/com/android/ant/NewSetupTask.java b/anttasks/src/com/android/ant/NewSetupTask.java
index c0e8d2a..45a18c3 100644
--- a/anttasks/src/com/android/ant/NewSetupTask.java
+++ b/anttasks/src/com/android/ant/NewSetupTask.java
@@ -82,6 +82,7 @@ public class NewSetupTask extends Task {
private String mProjectLibrariesPackageOut;
private String mProjectLibrariesJarsOut;
private String mProjectLibrariesLibsOut;
+ private String mTargetApiOut;
public void setProjectTypeOut(String projectTypeOut) {
mProjectTypeOut = projectTypeOut;
@@ -127,6 +128,10 @@ public class NewSetupTask extends Task {
mProjectLibrariesLibsOut = projectLibrariesLibsOut;
}
+ public void setTargetApiOut(String targetApiOut) {
+ mTargetApiOut = targetApiOut;
+ }
+
@Override
public void execute() throws BuildException {
if (mProjectTypeOut == null) {
@@ -162,6 +167,9 @@ public class NewSetupTask extends Task {
if (mProjectLibrariesLibsOut == null) {
throw new BuildException("Missing attribute projectLibrariesLibsOut");
}
+ if (mTargetApiOut == null) {
+ throw new BuildException("Missing attribute targetApiOut");
+ }
Project antProject = getProject();
@@ -377,6 +385,12 @@ public class NewSetupTask extends Task {
"For '%1$s' SDK Preview, attribute minSdkVersion in AndroidManifest.xml must be '%1$s'",
codeName));
}
+
+ // set the API level to the previous API level (which is actually the value in
+ // androidVersion.)
+ antProject.setProperty(mTargetApiOut,
+ Integer.toString(androidVersion.getApiLevel()));
+
} else if (value.length() > 0) {
// for normal platform, we'll only display warnings if the value is lower or higher
// than the target api level.
@@ -391,6 +405,9 @@ public class NewSetupTask extends Task {
AndroidManifest.ATTRIBUTE_MIN_SDK_VERSION));
}
+ // set the target api to the value
+ antProject.setProperty(mTargetApiOut, value);
+
int projectApiLevel = androidVersion.getApiLevel();
if (minSdkValue < projectApiLevel) {
System.out.println(String.format(
@@ -407,6 +424,9 @@ public class NewSetupTask extends Task {
// no minSdkVersion? display a warning
System.out.println(
"WARNING: No minSdkVersion value set. Application will install on all Android versions.");
+
+ // set the target api to 1
+ antProject.setProperty(mTargetApiOut, "1");
}
} catch (XPathExpressionException e) {
diff --git a/anttasks/src/com/android/ant/RenderScriptTask.java b/anttasks/src/com/android/ant/RenderScriptTask.java
index 08eeeed..50284fd 100644
--- a/anttasks/src/com/android/ant/RenderScriptTask.java
+++ b/anttasks/src/com/android/ant/RenderScriptTask.java
@@ -31,16 +31,17 @@ import java.util.Iterator;
import java.util.List;
/**
- * Task to execute aidl.
+ * Task to execute renderscript.
+ * <p>
+ * It expects 5 attributes:<br>
+ * 'executable' ({@link Path} with a single path) for the location of the llvm executable<br>
+ * 'framework' ({@link Path} with 1 or more paths) for the include paths.<br>
+ * 'genFolder' ({@link Path} with a single path) for the location of the gen folder.<br>
+ * 'resFolder' ({@link Path} with a single path) for the location of the res folder.<br>
+ * 'targetApi' for the -target-api value.<br>
* <p>
- * It expects 3 attributes:<br>
- * 'executable' ({@link Path} with a single path) for the location of the aidl executable<br>
- * 'framework' ({@link Path} with a single path) for the "preprocessed" file containing all the
- * parcelables exported by the framework<br>
- * 'genFolder' ({@link Path} with a single path) for the location of the gen folder.
- *
* It also expects one or more inner elements called "source" which are identical to {@link Path}
- * elements.
+ * elements for where to find .rs files.
*/
public class RenderScriptTask extends Task {
@@ -49,6 +50,7 @@ public class RenderScriptTask extends Task {
private String mGenFolder;
private String mResFolder;
private final List<Path> mPaths = new ArrayList<Path>();
+ private String mTargetApi;
/**
* Sets the value of the "executable" attribute.
@@ -70,6 +72,10 @@ public class RenderScriptTask extends Task {
mResFolder = TaskHelper.checkSinglePath("resFolder", value);
}
+ public void setTargetApi(String targetApi) {
+ mTargetApi = targetApi;
+ }
+
public Path createSource() {
Path p = new Path(getProject());
mPaths.add(p);
@@ -90,6 +96,9 @@ public class RenderScriptTask extends Task {
if (mResFolder == null) {
throw new BuildException("RenderScriptTask's 'resFolder' is required.");
}
+ if (mTargetApi == null) {
+ throw new BuildException("RenderScriptTask's 'targetApi' is required.");
+ }
Project taskProject = getProject();
@@ -137,6 +146,9 @@ public class RenderScriptTask extends Task {
}
}
+ task.createArg().setValue("-target-api");
+ task.createArg().setValue(mTargetApi);
+
task.createArg().setValue("-p");
task.createArg().setValue(mGenFolder);
task.createArg().setValue("-o");
@@ -145,11 +157,15 @@ public class RenderScriptTask extends Task {
// execute it.
task.execute();
+
+ count++;
}
}
if (count > 0) {
- System.out.println(String.format("Compiled %d renderscript files.", count));
+ System.out.println(String.format(
+ "Compiled %d renderscript files (with -target-api set to %s)",
+ count, mTargetApi));
} else {
System.out.println("No renderscript files to compile.");
}