diff options
author | Xavier Ducrohet <xav@android.com> | 2011-10-14 16:46:45 -0700 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2011-10-14 16:46:45 -0700 |
commit | def6f0d2e24d6dd96d6265fcf05fd9a1e10c789c (patch) | |
tree | 4228ac22d8fbd9a342b024805d3980aef1d71261 /anttasks/src/com/android/ant/NewSetupTask.java | |
parent | e162064a7b5db1eecec34271bc7e2a4296181ea6 (diff) | |
download | sdk-def6f0d2e24d6dd96d6265fcf05fd9a1e10c789c.zip sdk-def6f0d2e24d6dd96d6265fcf05fd9a1e10c789c.tar.gz sdk-def6f0d2e24d6dd96d6265fcf05fd9a1e10c789c.tar.bz2 |
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
Diffstat (limited to 'anttasks/src/com/android/ant/NewSetupTask.java')
-rw-r--r-- | anttasks/src/com/android/ant/NewSetupTask.java | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/anttasks/src/com/android/ant/NewSetupTask.java b/anttasks/src/com/android/ant/NewSetupTask.java index 165ea08..46f5b14 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<File> 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"); } |