aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2012-03-22 12:37:29 -0700
committerandroid code review <noreply-gerritcodereview@google.com>2012-03-22 12:37:30 -0700
commit36e49c5277ac346398d96d67c7ee5814bded8a5f (patch)
tree1f347a3c9a4e059ddd3331367fd818d800380021
parent7a795b5291224e2b85885f4d1f4d7ac097e96d3c (diff)
parent4987af409c704c881be83f9a90b98ce7658e1c46 (diff)
downloadsdk-36e49c5277ac346398d96d67c7ee5814bded8a5f.zip
sdk-36e49c5277ac346398d96d67c7ee5814bded8a5f.tar.gz
sdk-36e49c5277ac346398d96d67c7ee5814bded8a5f.tar.bz2
Merge "Enable passing of debug and optimization flags to slang in Ant builds."
-rw-r--r--anttasks/src/com/android/ant/RenderScriptTask.java25
-rw-r--r--files/ant/build.xml10
2 files changed, 32 insertions, 3 deletions
diff --git a/anttasks/src/com/android/ant/RenderScriptTask.java b/anttasks/src/com/android/ant/RenderScriptTask.java
index 5a71d36..d893d8e 100644
--- a/anttasks/src/com/android/ant/RenderScriptTask.java
+++ b/anttasks/src/com/android/ant/RenderScriptTask.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2010, 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,12 +28,14 @@ import java.util.List;
/**
* Task to execute renderscript.
* <p>
- * It expects 5 attributes:<br>
+ * It expects 7 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>
+ * 'optLevel' for the -O optimization level.<br>
+ * 'debug' for -g renderscript debugging.<br>
* <p>
* It also expects one or more inner elements called "source" which are identical to {@link Path}
* elements for where to find .rs files.
@@ -46,6 +48,9 @@ public class RenderScriptTask extends MultiFilesTask {
private String mResFolder;
private final List<Path> mPaths = new ArrayList<Path>();
private int mTargetApi = 0;
+ public enum OptLevel { O0, O1, O2, O3 };
+ private OptLevel mOptLevel;
+ private boolean mDebug = false;
private class RenderScriptProcessor implements SourceProcessor {
@@ -87,6 +92,13 @@ public class RenderScriptTask extends MultiFilesTask {
}
+ if (mDebug) {
+ task.createArg().setValue("-g");
+ }
+
+ task.createArg().setValue("-O");
+ task.createArg().setValue(Integer.toString(mOptLevel.ordinal()));
+
task.createArg().setValue("-target-api");
task.createArg().setValue(mTargetApiStr);
@@ -115,6 +127,7 @@ public class RenderScriptTask extends MultiFilesTask {
System.out.println(String.format(
"Compiling %1$d RenderScript files with -target-api %2$d",
count, mTargetApi));
+ System.out.println(String.format("Optimization Level: %1$d", mOptLevel.ordinal()));
} else {
System.out.println("No RenderScript files to compile.");
}
@@ -173,6 +186,14 @@ public class RenderScriptTask extends MultiFilesTask {
}
}
+ public void setOptLevel(OptLevel optLevel) {
+ mOptLevel = optLevel;
+ }
+
+ public void setDebug(boolean debug) {
+ mDebug = debug;
+ }
+
public Path createSource() {
Path p = new Path(getProject());
mPaths.add(p);
diff --git a/files/ant/build.xml b/files/ant/build.xml
index 77f9a16..c49fc5a 100644
--- a/files/ant/build.xml
+++ b/files/ant/build.xml
@@ -610,7 +610,9 @@
framework="${android.rs}"
genFolder="${gen.absolute.dir}"
resFolder="${out.res.absolute.dir}/raw"
- targetApi="${target.api}">
+ targetApi="${target.api}"
+ optLevel="${renderscript.opt.level}"
+ debug="${build.is.packaging.debug}">
<source path="${source.absolute.dir}"/>
</renderscript>
@@ -932,6 +934,9 @@
<!-- signing mode: debug -->
<property name="build.is.signing.debug" value="true" />
+ <!-- Renderscript optimization level: none -->
+ <property name="renderscript.opt.level" value="O0" />
+
</target>
<target name="-debug-obfuscation-check">
@@ -1021,6 +1026,9 @@
<!-- signing mode: release -->
<property name="build.is.signing.debug" value="false" />
+ <!-- Renderscript optimization level: aggressive -->
+ <property name="renderscript.opt.level" value="O3" />
+
<if condition="${build.is.packaging.debug}">
<then>
<echo>*************************************************</echo>