diff options
author | Ivan Komissarov <abbapoh@gmail.com> | 2021-04-24 02:20:06 +0300 |
---|---|---|
committer | Ivan Komissarov <abbapoh@gmail.com> | 2021-04-24 02:20:06 +0300 |
commit | a8bbaf016dc3092f6f6ad0c4a333e595da665983 (patch) | |
tree | 6b1b74bbca7850ed75da01cba5a72618f3cfa94b /share/qbs/module-providers/Qt/templates | |
parent | 001bf31623c02ba8249dd066777d014d546eb7f9 (diff) | |
parent | 2f6eecdc96fcd693cecef8011d8f9500c7872fc7 (diff) |
Merge branch '1.19' into master
Change-Id: Ic6087168a1d93c2a2b46de825f5c3b9655634e8e
Diffstat (limited to 'share/qbs/module-providers/Qt/templates')
-rw-r--r-- | share/qbs/module-providers/Qt/templates/android_support.qbs | 80 | ||||
-rw-r--r-- | share/qbs/module-providers/Qt/templates/qml.js | 25 | ||||
-rw-r--r-- | share/qbs/module-providers/Qt/templates/qml.qbs | 2 |
3 files changed, 99 insertions, 8 deletions
diff --git a/share/qbs/module-providers/Qt/templates/android_support.qbs b/share/qbs/module-providers/Qt/templates/android_support.qbs index 87c980448..68a29bb95 100644 --- a/share/qbs/module-providers/Qt/templates/android_support.qbs +++ b/share/qbs/module-providers/Qt/templates/android_support.qbs @@ -4,6 +4,7 @@ import qbs.ModUtils import qbs.TextFile import qbs.Utilities import qbs.Process +import qbs.Xml Module { version: @version@ @@ -35,6 +36,10 @@ Module { property bool _multiAbi: Utilities.versionCompare(version, "5.14") >= 0 + // QTBUG-87288: correct QtNetwork jar dependencies for 5.15.0 < Qt < 5.15.3 + property bool _correctQtNetworkDependencies: Utilities.versionCompare(version, "5.15.0") > 0 && + Utilities.versionCompare(version, "5.15.3") < 0 + Depends { name: "Android.sdk"; condition: _enableSdkSupport } Depends { name: "Android.ndk"; condition: _enableNdkSupport } Depends { name: "java"; condition: _enableSdkSupport } @@ -355,8 +360,6 @@ Module { var moveCmd = new JavaScriptCommand(); moveCmd.description = "processing androiddeployqt outout"; moveCmd.sourceCode = function() { - File.move(product.Qt.android_support._deployQtOutDir + "/AndroidManifest.xml", - outputs["android.manifest_final"][0].filePath); var libsDir = product.Qt.android_support._deployQtOutDir + "/libs"; var libDir = product.Android.sdk.packageContentsDir + "/lib"; var listFilePath = outputs["android.deployqt_list"][0].filePath; @@ -400,7 +403,78 @@ Module { File.remove(oldLibs[i]); } }; - return [copyCmd, androidDeployQtCmd, moveCmd]; + + var correctingCmd = new JavaScriptCommand(); + if (product.Qt.android_support._correctQtNetworkDependencies) { + correctingCmd.description = "correcting network jar dependency"; + correctingCmd.sourceCode = function() { + var findNetworkLib = function() { + var libsDir = product.Android.sdk.packageContentsDir + "/lib"; + var dirList = File.directoryEntries(libsDir, File.Dirs | + File.NoDotAndDotDot); + for (var i = 0; i < dirList.length; ++i) { + var archDir = FileInfo.joinPaths(libsDir, dirList[i]); + var fileList = File.directoryEntries(archDir, File.Files); + if (fileList) { + for (var j = 0; j < fileList.length; ++j) { + if (fileList[j].contains("libQt5Network")) { + return true; + } + } + } + } + return false; + } + + if (findNetworkLib()) { + var manifestData = new Xml.DomDocument(); + var manifestFilePath = product.Qt.android_support._deployQtOutDir + + "/AndroidManifest.xml" + manifestData.load(manifestFilePath); + + var rootElem = manifestData.documentElement(); + if (!rootElem || !rootElem.isElement() || rootElem.tagName() != "manifest") + throw "No manifest tag found in '" + manifestFilePath + "'."; + var appElem = rootElem.firstChild("application"); + if (!appElem || !appElem.isElement() || appElem.tagName() != "application") + throw "No application tag found in '" + manifestFilePath + "'."; + var activityElem = appElem.firstChild("activity"); + if (!activityElem || !activityElem.isElement() || + activityElem.tagName() != "activity") + throw "No activity tag found in '" + manifestFilePath + "'."; + var metaDataElem = activityElem.firstChild("meta-data"); + while (metaDataElem && metaDataElem.isElement()) { + if (metaDataElem.attribute("android:name") == + "android.app.load_local_jars" ) { + var value = metaDataElem.attribute("android:value"); + var fileName = "QtAndroidNetwork.jar"; + metaDataElem.setAttribute("android:value", value + ":jar/" + + fileName); + var jarFilePath = FileInfo.joinPaths( + product.Qt.android_support._qtInstallDir, "jar", + fileName); + var targetFilePath = FileInfo.joinPaths(product.java.classFilesDir, + fileName); + File.copy(jarFilePath, targetFilePath); + break; + } + metaDataElem = metaDataElem.nextSibling("meta-data"); + } + manifestData.save(outputs["android.manifest_final"][0].filePath, 4); + } else { + File.move(product.Qt.android_support._deployQtOutDir + "/AndroidManifest.xml", + outputs["android.manifest_final"][0].filePath); + } + }; + } else { + correctingCmd.description = "copying manifest"; + correctingCmd.sourceCode = function() { + File.move(product.Qt.android_support._deployQtOutDir + "/AndroidManifest.xml", + outputs["android.manifest_final"][0].filePath); + } + } + + return [copyCmd, androidDeployQtCmd, moveCmd, correctingCmd]; } } diff --git a/share/qbs/module-providers/Qt/templates/qml.js b/share/qbs/module-providers/Qt/templates/qml.js index df69034fe..e48c9230e 100644 --- a/share/qbs/module-providers/Qt/templates/qml.js +++ b/share/qbs/module-providers/Qt/templates/qml.js @@ -3,14 +3,31 @@ var FileInfo = require("qbs.FileInfo"); var Process = require("qbs.Process"); var TextFile = require("qbs.TextFile"); -function scannerData(scannerFilePath, qmlFiles, qmlPath) +function scannerData(scannerFilePath, qmlFiles, qmlPath, targetOS) { var p; try { p = new Process(); - p.exec(scannerFilePath, ["-qmlFiles"].concat(qmlFiles).concat(["-importPath", qmlPath]), - true); - return JSON.parse(p.readStdOut()); + if (!targetOS.contains("windows")) { + p.exec(scannerFilePath, ["-qmlFiles"].concat(qmlFiles).concat(["-importPath", qmlPath]), + true); + return JSON.parse(p.readStdOut()); + } + var data = []; + var nextFileIndex = 0; + while (nextFileIndex < qmlFiles.length) { + var currentFileList = []; + var currentFileListStringLength = 0; + while (nextFileIndex < qmlFiles.length && currentFileListStringLength < 30000) { + var currentFile = qmlFiles[nextFileIndex++]; + currentFileList.push(currentFile); + currentFileListStringLength += currentFile.length; + } + p.exec(scannerFilePath, ["-qmlFiles"].concat(currentFileList) + .concat(["-importPath", qmlPath]), true); + data = data.concat(JSON.parse(p.readStdOut())); + } + return data; } finally { if (p) p.close(); diff --git a/share/qbs/module-providers/Qt/templates/qml.qbs b/share/qbs/module-providers/Qt/templates/qml.qbs index f608ba4dd..af7b0fb5f 100644 --- a/share/qbs/module-providers/Qt/templates/qml.qbs +++ b/share/qbs/module-providers/Qt/templates/qml.qbs @@ -144,7 +144,7 @@ QtModule { qmlInputs = []; var scannerData = Qml.scannerData(product.Qt.qml.qmlImportScannerFilePath, qmlInputs.map(function(inp) { return inp.filePath; }), - product.Qt.qml.qmlPath); + product.Qt.qml.qmlPath, product.qbs.targetOS); var cppFile; var listFile; try { |