summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2014-04-28 14:52:03 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-05 14:42:52 +0200
commit5d2ffacdfd718cc1cc64c76e74048854f1b59192 (patch)
tree5695d25b504b2b9335abcba35c8147fe657bc99b
parent7a4b7b8cef22ff565583ab36e7ce44029561ffd3 (diff)
downloadqttools-5d2ffacdfd718cc1cc64c76e74048854f1b59192.tar.gz
androiddeployqt: Support bundling library projects
Third party library projects can easily be added to the Android package source directory and added to the project using project.properties, but "android update" needs to be run on it to produce some local build files before it can be included in the build. We can do this for people so that they can use third party library projects without having to put build files in their source directory. [ChangeLog][Android][Deployment] Detect linked library projects in the package source directory and automatically run "android update" on these. Task-number: QTBUG-38322 Change-Id: I0bf9b8708a7ec28ed5429379215b12a65d05416a Reviewed-by: Christian Stromme <christian.stromme@digia.com>
-rw-r--r--src/androiddeployqt/main.cpp67
1 files changed, 59 insertions, 8 deletions
diff --git a/src/androiddeployqt/main.cpp b/src/androiddeployqt/main.cpp
index 385d9ce89..db8936879 100644
--- a/src/androiddeployqt/main.cpp
+++ b/src/androiddeployqt/main.cpp
@@ -1697,25 +1697,53 @@ bool copyQtFiles(Options *options)
return true;
}
+QStringList getLibraryProjectsInOutputFolder(const Options &options)
+{
+ QStringList ret;
+
+ QFile file(options.outputDirectory + QLatin1String("/project.properties"));
+ if (file.open(QIODevice::ReadOnly)) {
+ while (!file.atEnd()) {
+ QByteArray line = file.readLine().trimmed();
+ if (line.startsWith("android.library.reference")) {
+ int equalSignIndex = line.indexOf('=');
+ if (equalSignIndex >= 0) {
+ QString path = QString::fromLocal8Bit(line.mid(equalSignIndex + 1));
+
+ QFileInfo info(options.outputDirectory + QLatin1Char('/') + path);
+ if (QDir::isRelativePath(path)
+ && info.exists()
+ && info.isDir()
+ && info.canonicalFilePath().startsWith(options.outputDirectory)) {
+ ret += info.canonicalFilePath();
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+}
+
bool createAndroidProject(const Options &options)
{
if (options.verbose)
fprintf(stdout, "Running Android tool to create package definition.\n");
- QString androidTool = options.sdkPath + QLatin1String("/tools/android");
+ QString androidToolExecutable = options.sdkPath + QLatin1String("/tools/android");
#if defined(Q_OS_WIN32)
- androidTool += QLatin1String(".bat");
+ androidToolExecutable += QLatin1String(".bat");
#endif
- if (!QFile::exists(androidTool)) {
- fprintf(stderr, "Cannot find Android tool: %s\n", qPrintable(androidTool));
+ if (!QFile::exists(androidToolExecutable)) {
+ fprintf(stderr, "Cannot find Android tool: %s\n", qPrintable(androidToolExecutable));
return false;
}
- androidTool = QString::fromLatin1("%1 update project --path %2 --target %3 --name QtApp")
- .arg(shellQuote(androidTool))
- .arg(shellQuote(options.outputDirectory))
- .arg(shellQuote(options.androidPlatform));
+ QString androidTool = QString::fromLatin1("%1 update project --path %2 --target %3 --name QtApp")
+ .arg(shellQuote(androidToolExecutable))
+ .arg(shellQuote(options.outputDirectory))
+ .arg(shellQuote(options.androidPlatform));
if (options.verbose)
fprintf(stdout, " -- Command: %s\n", qPrintable(androidTool));
@@ -1728,6 +1756,29 @@ bool createAndroidProject(const Options &options)
pclose(androidToolCommand);
+ // If the project has subprojects inside the current folder, we need to also run android update on these.
+ QStringList libraryProjects = getLibraryProjectsInOutputFolder(options);
+ foreach (QString libraryProject, libraryProjects) {
+ if (options.verbose)
+ fprintf(stdout, "Updating subproject %s\n", qPrintable(libraryProject));
+
+ androidTool = QString::fromLatin1("%1 update lib-project --path %2 --target %3")
+ .arg(shellQuote(androidToolExecutable))
+ .arg(shellQuote(libraryProject))
+ .arg(shellQuote(options.androidPlatform));
+
+ if (options.verbose)
+ fprintf(stdout, " -- Command: %s\n", qPrintable(androidTool));
+
+ FILE *androidToolCommand = popen(androidTool.toLocal8Bit().constData(), "r");
+ if (androidToolCommand == 0) {
+ fprintf(stderr, "Cannot run command '%s'\n", qPrintable(androidTool));
+ return false;
+ }
+
+ pclose(androidToolCommand);
+ }
+
return true;
}