From: Xavier Ducrohet Date: Fri, 14 Oct 2011 23:46:45 +0000 (-0700) Subject: Improve indirect library dependency support. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;ds=sidebyside;h=def6f0d2e24d6dd96d6265fcf05fd9a1e10c789c;p=android-x86%2Fsdk.git Improve indirect library dependency support. Previously with the following setup: Main app depends on Lib1, Lib2. Lib1 and Lib2 both depends on Lib3. Lib3 would be compiled 3 times, as the main app would attempt to build it and then Libr1, and Lib2 would do it too. Of course it wasn't actually built 3 times. After the first time it would do nothing, checking dependencies and do nothing. However, for projects will a lot of libraries and a lot of indirect dependencies this could slow down a lot compilations, as the build would spend its time checking whether to build the same library many times. This ensure that only the main project attempts to build all of its library dependencies (direct and indirect), in the right order of course. When libraries are built they are told (through the "only" target) to not build their dependencies. Change-Id: Ie80f32a96e3c473d897aca5d05bf6fe9ea086884 --- diff --git a/anttasks/src/com/android/ant/AaptExecTask.java b/anttasks/src/com/android/ant/AaptExecTask.java index 87317328f..c01afe249 100644 --- a/anttasks/src/com/android/ant/AaptExecTask.java +++ b/anttasks/src/com/android/ant/AaptExecTask.java @@ -96,7 +96,7 @@ public final class AaptExecTask extends SingleDependencyTask { private boolean mNonConstantId; /** - * Input path that ignores the same file that aapt does. + * Input path that ignores the same folders/files that aapt does. */ private static class ResFolderInputPath extends InputPath { public ResFolderInputPath(File file, Set extensionsToCheck) { diff --git a/anttasks/src/com/android/ant/NewSetupTask.java b/anttasks/src/com/android/ant/NewSetupTask.java index 165ea08f6..46f5b1413 100644 --- a/anttasks/src/com/android/ant/NewSetupTask.java +++ b/anttasks/src/com/android/ant/NewSetupTask.java @@ -452,21 +452,20 @@ public class NewSetupTask extends Task { System.out.println("\n------------------\nResolving library dependencies:"); + // get the list of ordered libraries. ArrayList libraries = getProjectLibraries(antProject); if (libraries.size() > 0) { System.out.println("------------------\nOrdered libraries:"); + // use that same order to return ordered res folders, as well as jars and output. for (File library : libraries) { + // get the root path. String libRootPath = library.getAbsolutePath(); System.out.println(libRootPath); - // get the root path. - PathElement element = rootPath.createPathElement(); - element.setPath(libRootPath); - // get the res path. Always $PROJECT/res as well as the crunch cache. - element = resPath.createPathElement(); + PathElement element = resPath.createPathElement(); element.setPath(libRootPath + "/" + SdkConstants.FD_OUTPUT + "/" + SdkConstants.FD_RES); element = resPath.createPathElement(); @@ -506,6 +505,18 @@ public class NewSetupTask extends Task { throw new BuildException(e); } } + + // now use the reverse order to get the full list of library project. + // This is used to compile all the libraries, direct or indirect dependencies, + // in a single pass. + final int count = libraries.size(); + for (int i = count - 1 ; i >= 0 ; i--) { + File library = libraries.get(i); + + PathElement element = rootPath.createPathElement(); + element.setPath(library.getAbsolutePath()); + } + } else { System.out.println("No library dependencies.\n"); } diff --git a/files/ant/build.xml b/files/ant/build.xml index 91dbb1f5b..57effb22a 100644 --- a/files/ant/build.xml +++ b/files/ant/build.xml @@ -365,6 +365,11 @@ + + + + + - + + + + Building Libraries - + antfile="build.xml"> + + + ############################################ **** Back to project ${ant.project.name} **** @@ -1263,8 +1272,14 @@ (tested projects and libraries)at the same time using: 'ant all clean' debug: Builds the application and signs it with a debug key. + The 'only' target can be used to only build the + current project and ignore the libraries using: + 'ant only debug' release: Builds the application. The generated apk file must be signed before it is published. + The 'only' target can be used to only build the + current project and ignore the libraries using: + 'ant only release' instrument:Builds an instrumented package and signs it with a debug key. test: Runs the tests. Project must be a test project and