diff options
author | Xavier Ducrohet <xav@android.com> | 2012-11-30 10:54:05 -0800 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2012-11-30 11:04:30 -0800 |
commit | 466d084bf64a41bbcac4145795628d182286b6ba (patch) | |
tree | 449bfcd300e57a1db2f032707fcad8391cdf0be4 /eclipse | |
parent | fbf28acf3eb01515e94444de8a916a3c2d779211 (diff) | |
download | sdk-466d084bf64a41bbcac4145795628d182286b6ba.zip sdk-466d084bf64a41bbcac4145795628d182286b6ba.tar.gz sdk-466d084bf64a41bbcac4145795628d182286b6ba.tar.bz2 |
Add renderscript specific compilation target.
The property name is "renderscript.target" and is to
be located in project.properties.
If not present, the minSdkVersion (or 11 if lower)
is used.
Change-Id: Ic243474ce1d5ce2235cbfdfc45092ed8a5ffbbf7
Diffstat (limited to 'eclipse')
4 files changed, 35 insertions, 15 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AidlProcessor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AidlProcessor.java index e399b69..fa878cf 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AidlProcessor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AidlProcessor.java @@ -98,7 +98,7 @@ public class AidlProcessor extends SourceProcessor { @SuppressWarnings("deprecation") @Override protected void doCompileFiles(List<IFile> sources, BaseBuilder builder, - IProject project, IAndroidTarget projectTarget, int targetApi, + IProject project, IAndroidTarget projectTarget, List<IPath> sourceFolders, List<IFile> notCompiledOut, List<File> libraryProjectsOut, IProgressMonitor monitor) throws CoreException { // create the command line diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/RenderScriptProcessor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/RenderScriptProcessor.java index 2ec781f..2652866 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/RenderScriptProcessor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/RenderScriptProcessor.java @@ -143,10 +143,17 @@ public class RenderScriptProcessor extends SourceProcessor { } } + private int mTargetApi = 11; + public RenderScriptProcessor(IJavaProject javaProject, IFolder genFolder) { super(javaProject, genFolder, new RsChangeHandler()); } + public void setTargetApi(int targetApi) { + // make sure the target api value is good. Must be 11+ or llvm-rs-cc complains. + mTargetApi = targetApi < 11 ? 11 : targetApi; + } + @Override protected Set<String> getExtensions() { return EXTENSIONS; @@ -160,7 +167,7 @@ public class RenderScriptProcessor extends SourceProcessor { @SuppressWarnings("deprecation") @Override protected void doCompileFiles(List<IFile> sources, BaseBuilder builder, - IProject project, IAndroidTarget projectTarget, int targetApi, + IProject project, IAndroidTarget projectTarget, List<IPath> sourceFolders, List<IFile> notCompiledOut, List<File> libraryProjectsOut, IProgressMonitor monitor) throws CoreException { @@ -173,11 +180,6 @@ public class RenderScriptProcessor extends SourceProcessor { int depIndex; - // make sure the target api value is good. Must be 11+ or llvm-rs-cc complains. - if (targetApi < 11) { - targetApi = 11; - } - // create the command line String[] command = new String[15]; int index = 0; @@ -193,7 +195,7 @@ public class RenderScriptProcessor extends SourceProcessor { command[index++] = quote(rawFolder.getLocation().toOSString()); command[index++] = "-target-api"; //$NON-NLS-1$ - command[index++] = Integer.toString(targetApi); + command[index++] = Integer.toString(mTargetApi); command[index++] = "-d"; //$NON-NLS-1$ command[depIndex = index++] = null; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/SourceProcessor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/SourceProcessor.java index 794ed52..7932a70 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/SourceProcessor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/SourceProcessor.java @@ -220,7 +220,7 @@ public abstract class SourceProcessor { * */ public final int compileFiles(BaseBuilder builder, - IProject project, IAndroidTarget projectTarget, int minSdkVersion, + IProject project, IAndroidTarget projectTarget, List<IPath> sourceFolders, List<File> libraryProjectsOut, IProgressMonitor monitor) throws CoreException { @@ -242,7 +242,7 @@ public abstract class SourceProcessor { // list of files that have failed compilation. List<IFile> stillNeedCompilation = new ArrayList<IFile>(); - doCompileFiles(mToCompile, builder, project, projectTarget, minSdkVersion, sourceFolders, + doCompileFiles(mToCompile, builder, project, projectTarget, sourceFolders, stillNeedCompilation, libraryProjectsOut, monitor); mToCompile.clear(); @@ -274,7 +274,7 @@ public abstract class SourceProcessor { protected abstract void doCompileFiles( List<IFile> filesToCompile, BaseBuilder builder, - IProject project, IAndroidTarget projectTarget, int targetApi, + IProject project, IAndroidTarget projectTarget, List<IPath> sourceFolders, List<IFile> notCompiledOut, List<File> libraryProjectsOut, IProgressMonitor monitor) throws CoreException; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java index 73d183c..25b16e4 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java @@ -139,6 +139,8 @@ public class PreCompilerBuilder extends BaseBuilder { */ private DerivedProgressMonitor mDerivedProgressMonitor; + private RenderScriptProcessor mRenderScriptProcessor; + /** * Progress monitor waiting the end of the process to set a persistent value * in a file. This is typically used in conjunction with <code>IResource.refresh()</code>, @@ -650,10 +652,27 @@ public class PreCompilerBuilder extends BaseBuilder { // run the source processors int processorStatus = SourceProcessor.COMPILE_STATUS_NONE; + + // get the renderscript target + int rsTarget = minSdkValue == -1 ? 11 : minSdkValue; + String rsTargetStr = projectState.getProperty(ProjectProperties.PROPERTY_RS_TARGET); + if (rsTargetStr != null) { + try { + rsTarget = Integer.parseInt(rsTargetStr); + } catch (NumberFormatException e) { + handleException(e, String.format( + "Property %s is not an integer.", + ProjectProperties.PROPERTY_RS_TARGET)); + return result; + } + } + + mRenderScriptProcessor.setTargetApi(rsTarget); + for (SourceProcessor processor : mProcessors) { try { processorStatus |= processor.compileFiles(this, - project, projectTarget, minSdkValue, sourceFolderPathList, + project, projectTarget, sourceFolderPathList, libProjectsOut, monitor); } catch (Throwable t) { handleException(t, String.format( @@ -776,10 +795,9 @@ public class PreCompilerBuilder extends BaseBuilder { // load the source processors SourceProcessor aidlProcessor = new AidlProcessor(javaProject, mGenFolder); - SourceProcessor renderScriptProcessor = new RenderScriptProcessor(javaProject, - mGenFolder); + mRenderScriptProcessor = new RenderScriptProcessor(javaProject, mGenFolder); mProcessors.add(aidlProcessor); - mProcessors.add(renderScriptProcessor); + mProcessors.add(mRenderScriptProcessor); } catch (Throwable throwable) { AdtPlugin.log(throwable, "Failed to finish PrecompilerBuilder#startupOnInitialize()"); } |