diff options
author | Andrew Knight <andrew.knight@intopalo.com> | 2015-07-28 14:19:25 +0300 |
---|---|---|
committer | Andrew Knight <andrew.knight@intopalo.com> | 2015-07-28 15:58:40 +0000 |
commit | b5bc5748321de0ed903cac91c249515d148d99dc (patch) | |
tree | f03f010b5f114ebad550692f2401869a5d304663 | |
parent | b0cd7407eab6a12b347652ae44c4abcedfd0b65c (diff) | |
download | qttools-b5bc5748321de0ed903cac91c249515d148d99dc.tar.gz qttools-b5bc5748321de0ed903cac91c249515d148d99dc.tar.bz2 qttools-b5bc5748321de0ed903cac91c249515d148d99dc.zip |
androiddeployqt: Make it QT_NO_CAST_*_ASCII clean
This makes the codebase more consistent. Where appropriate, const was also
added to local variables.
Found by compiling Qt with QT_NO_CAST_FROM_ASCII/QT_NO_CAST_TO_ASCII.
Change-Id: If36859b74c2320265702bb8b357248e8777f0ae9
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
-rw-r--r-- | src/androiddeployqt/androiddeployqt.pro | 2 | ||||
-rw-r--r-- | src/androiddeployqt/main.cpp | 64 |
2 files changed, 34 insertions, 32 deletions
diff --git a/src/androiddeployqt/androiddeployqt.pro b/src/androiddeployqt/androiddeployqt.pro index 31bc5fa0..7b003a77 100644 --- a/src/androiddeployqt/androiddeployqt.pro +++ b/src/androiddeployqt/androiddeployqt.pro @@ -7,5 +7,7 @@ SOURCES += \ # Required for declarations of popen/pclose on Windows windows: QMAKE_CXXFLAGS += -U__STRICT_ANSI__ +DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII + load(qt_app) diff --git a/src/androiddeployqt/main.cpp b/src/androiddeployqt/main.cpp index 07a34714..1f8f274d 100644 --- a/src/androiddeployqt/main.cpp +++ b/src/androiddeployqt/main.cpp @@ -722,13 +722,13 @@ bool readInputFile(Options *options) { - QJsonValue value = jsonObject.value("sdkBuildToolsRevision"); + const QJsonValue value = jsonObject.value(QStringLiteral("sdkBuildToolsRevision")); if (!value.isUndefined()) options->sdkBuildToolsVersion = value.toString(); } { - QJsonValue qtInstallDirectory = jsonObject.value("qt"); + const QJsonValue qtInstallDirectory = jsonObject.value(QStringLiteral("qt")); if (qtInstallDirectory.isUndefined()) { fprintf(stderr, "No Qt directory in json file %s\n", qPrintable(options->inputFileName)); return false; @@ -737,13 +737,13 @@ bool readInputFile(Options *options) } { - QJsonValue androidSourcesDirectory = jsonObject.value("android-package-source-directory"); + const QJsonValue androidSourcesDirectory = jsonObject.value(QStringLiteral("android-package-source-directory")); if (!androidSourcesDirectory.isUndefined()) options->androidSourceDirectory = androidSourcesDirectory.toString(); } { - QJsonValue applicationBinary = jsonObject.value("application-binary"); + const QJsonValue applicationBinary = jsonObject.value(QStringLiteral("application-binary")); if (applicationBinary.isUndefined()) { fprintf(stderr, "No application binary defined in json file.\n"); return false; @@ -757,7 +757,7 @@ bool readInputFile(Options *options) } { - QJsonValue deploymentDependencies = jsonObject.value("deployment-dependencies"); + const QJsonValue deploymentDependencies = jsonObject.value(QStringLiteral("deployment-dependencies")); if (!deploymentDependencies.isUndefined()) { QStringList dependencies = deploymentDependencies.toString().split(QLatin1Char(',')); foreach (QString dependency, dependencies) { @@ -782,7 +782,7 @@ bool readInputFile(Options *options) { - QJsonValue targetArchitecture = jsonObject.value("target-architecture"); + const QJsonValue targetArchitecture = jsonObject.value(QStringLiteral("target-architecture")); if (targetArchitecture.isUndefined()) { fprintf(stderr, "No target architecture defined in json file.\n"); return false; @@ -791,7 +791,7 @@ bool readInputFile(Options *options) } { - QJsonValue ndk = jsonObject.value("ndk"); + const QJsonValue ndk = jsonObject.value(QStringLiteral("ndk")); if (ndk.isUndefined()) { fprintf(stderr, "No NDK path defined in json file.\n"); return false; @@ -800,7 +800,7 @@ bool readInputFile(Options *options) } { - QJsonValue toolchainPrefix = jsonObject.value("toolchain-prefix"); + const QJsonValue toolchainPrefix = jsonObject.value(QStringLiteral("toolchain-prefix")); if (toolchainPrefix.isUndefined()) { fprintf(stderr, "No toolchain prefix defined in json file.\n"); return false; @@ -809,7 +809,7 @@ bool readInputFile(Options *options) } { - QJsonValue toolPrefix = jsonObject.value("tool-prefix"); + const QJsonValue toolPrefix = jsonObject.value(QStringLiteral("tool-prefix")); if (toolPrefix.isUndefined()) { fprintf(stderr, "Warning: No tool prefix defined in json file.\n"); options->toolPrefix = options->toolchainPrefix; @@ -819,7 +819,7 @@ bool readInputFile(Options *options) } { - QJsonValue toolchainVersion = jsonObject.value("toolchain-version"); + const QJsonValue toolchainVersion = jsonObject.value(QStringLiteral("toolchain-version")); if (toolchainVersion.isUndefined()) { fprintf(stderr, "No toolchain version defined in json file.\n"); return false; @@ -828,7 +828,7 @@ bool readInputFile(Options *options) } { - QJsonValue ndkHost = jsonObject.value("ndk-host"); + const QJsonValue ndkHost = jsonObject.value(QStringLiteral("ndk-host")); if (ndkHost.isUndefined()) { fprintf(stderr, "No NDK host defined in json file.\n"); return false; @@ -841,25 +841,25 @@ bool readInputFile(Options *options) options->packageName = cleanPackageName(QString::fromLatin1("org.qtproject.example.%1").arg(QFileInfo(options->applicationBinary).baseName().mid(sizeof("lib") - 1))); { - QJsonValue extraLibs = jsonObject.value("android-extra-libs"); + const QJsonValue extraLibs = jsonObject.value(QStringLiteral("android-extra-libs")); if (!extraLibs.isUndefined()) options->extraLibs = extraLibs.toString().split(QLatin1Char(','), QString::SkipEmptyParts); } { - QJsonValue extraPlugins = jsonObject.value("android-extra-plugins"); + const QJsonValue extraPlugins = jsonObject.value(QStringLiteral("android-extra-plugins")); if (!extraPlugins.isUndefined()) options->extraPlugins = extraPlugins.toString().split(QLatin1Char(',')); } { - QJsonValue qmlRootPath = jsonObject.value("qml-root-path"); + const QJsonValue qmlRootPath = jsonObject.value(QStringLiteral("qml-root-path")); if (!qmlRootPath.isUndefined()) options->rootPath = qmlRootPath.toString(); } { - QJsonValue qmlImportPaths = jsonObject.value("qml-import-paths"); + const QJsonValue qmlImportPaths = jsonObject.value(QStringLiteral("qml-import-paths")); if (!qmlImportPaths.isUndefined()) options->qmlImportPaths = qmlImportPaths.toString().split(QLatin1Char(',')); } @@ -903,7 +903,7 @@ void cleanAndroidFiles(const Options &options) cleanTopFolders(options, options.androidSourceDirectory, options.outputDirectory); cleanTopFolders(options, options.qtInstallDirectory + QLatin1String("/src/android/templates"), options.outputDirectory); - cleanTopFolders(options, options.qtInstallDirectory + QLatin1String("/src/android/java"), options.outputDirectory + "__qt5__android__files__"); + cleanTopFolders(options, options.qtInstallDirectory + QLatin1String("/src/android/java"), options.outputDirectory + QLatin1String("__qt5__android__files__")); } bool copyAndroidTemplate(const Options &options, const QString &androidTemplate, const QString &outDirPrefix = QString()) @@ -926,7 +926,7 @@ bool copyAndroidTemplate(const Options &options, const QString &androidTemplate, bool copyGradleTemplate(const Options &options) { - QDir sourceDirectory(options.sdkPath + "/tools/templates/gradle/wrapper"); + QDir sourceDirectory(options.sdkPath + QLatin1String("/tools/templates/gradle/wrapper")); if (!sourceDirectory.exists()) { fprintf(stderr, "Cannot find template directory %s\n", qPrintable(sourceDirectory.absolutePath())); return false; @@ -1042,7 +1042,7 @@ bool copyAndroidExtraResources(const Options &options) foreach (const QString &resourceFile, files) { QString originFile(resourceDir.filePath(resourceFile)); QString destinationFile; - if (!resourceFile.endsWith(".so")) { + if (!resourceFile.endsWith(QLatin1String(".so"))) { destinationFile = assetsDir + resourceFile; } else { destinationFile = libsDir + QStringLiteral("/lib") + QString(resourceDir.dirName() + QLatin1Char('/') + resourceFile).replace(QLatin1Char('/'), QLatin1Char('_')); @@ -1137,13 +1137,13 @@ bool updateLibsXml(const Options &options) QDir resourceDir(extraRes); QStringList files = allFilesInside(resourceDir, resourceDir); foreach (const QString &file, files) { - QString destinationPath = resourceDir.dirName()+'/'+file; - if (!file.endsWith(".so")) { + QString destinationPath = resourceDir.dirName() + QLatin1Char('/') + file; + if (!file.endsWith(QLatin1String(".so"))) { bundledInAssets += QStringLiteral("<item>%1:%1</item>\n") .arg(destinationPath); } else { bundledInLibs += QStringLiteral("<item>lib%1:%2</item>\n") - .arg(QString(destinationPath).replace('/', '_')) + .arg(QString(destinationPath).replace(QLatin1Char('/'), QLatin1Char('_'))) .arg(destinationPath); } } @@ -1182,7 +1182,7 @@ bool updateStringsXml(const Options &options) fprintf(stdout, " -- res/values/strings.xml\n"); QHash<QString, QString> replacements; - replacements["<!-- %%INSERT_APP_NAME%% -->"] = QFileInfo(options.applicationBinary).baseName().mid(sizeof("lib") - 1); + replacements[QStringLiteral("<!-- %%INSERT_APP_NAME%% -->")] = QFileInfo(options.applicationBinary).baseName().mid(sizeof("lib") - 1); QString fileName = options.outputDirectory + QLatin1String("/res/values/strings.xml"); if (!QFile::exists(fileName)) { @@ -1226,7 +1226,7 @@ bool updateStringsXml(const Options &options) } replacements.clear(); - replacements["<!-- %%INSERT_STRINGS -->"] = QString(QLatin1String("<string name=\"app_name\">%1</string>\n")) + replacements[QStringLiteral("<!-- %%INSERT_STRINGS -->")] = QString::fromLatin1("<string name=\"app_name\">%1</string>\n") .arg(QFileInfo(options.applicationBinary).baseName().mid(sizeof("lib") - 1)); if (!updateFile(fileName, replacements)) @@ -1780,7 +1780,7 @@ bool scanImports(Options *options, QSet<QString> *usedDependencies) fprintf(stdout, " -- Appending dependency found by qmlimportscanner: %s\n", qPrintable(fileName.absolutePath)); // Put all imports in default import path in assets - fileName.relativePath.prepend("qml/"); + fileName.relativePath.prepend(QLatin1String("qml/")); options->qtDependencies.append(fileName); if (fileName.absolutePath.endsWith(QLatin1String(".so"))) { @@ -1904,7 +1904,7 @@ bool stripLibraries(const Options &options) + options.architecture; QStringList libraries = QDir(libraryPath).entryList(QDir::Files); foreach (QString library, libraries) { - if (library.endsWith(".so")) { + if (library.endsWith(QLatin1String(".so"))) { if (!stripFile(options, libraryPath + QLatin1Char('/') + library)) return false; } @@ -2109,11 +2109,11 @@ bool copyQtFiles(Options *options) QString relativePath = info.absoluteFilePath().mid(options->qtInstallDirectory.length()); if (relativePath.startsWith(QLatin1Char('/'))) relativePath.remove(0, 1); - if ((relativePath.startsWith("lib/") && relativePath.endsWith(".so")) - || relativePath.startsWith("jar/") - || relativePath.startsWith("imports/") - || relativePath.startsWith("qml/") - || relativePath.startsWith("plugins/")) { + if ((relativePath.startsWith(QLatin1String("lib/")) && relativePath.endsWith(QLatin1String(".so"))) + || relativePath.startsWith(QLatin1String("jar/")) + || relativePath.startsWith(QLatin1String("imports/")) + || relativePath.startsWith(QLatin1String("qml/")) + || relativePath.startsWith(QLatin1String("plugins/"))) { if (!deployToLocalTmp(options, relativePath)) return false; } @@ -2268,7 +2268,7 @@ bool createAndroidProject(const Options &options) QString findInPath(const QString &fileName) { - QString path = qgetenv("PATH"); + const QString path = QString::fromLocal8Bit(qgetenv("PATH")); #if defined(Q_OS_WIN32) QLatin1Char separator(';'); #else @@ -2620,7 +2620,7 @@ bool signPackage(const Options &options) QString jdkPath = options.jdkPath; if (jdkPath.isEmpty()) - jdkPath = qgetenv("JAVA_HOME"); + jdkPath = QString::fromLocal8Bit(qgetenv("JAVA_HOME")); #if defined(Q_OS_WIN32) QString jarSignerTool = QString::fromLatin1("jarsigner.exe"); |