1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2020 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and The Qt Company. For licensing terms 13 ** and conditions see https://www.qt.io/terms-conditions. For further 14 ** information use the contact form at https://www.qt.io/contact-us. 15 ** 16 ** GNU General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU 18 ** General Public License version 3 as published by the Free Software 19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 20 ** included in the packaging of this file. Please review the following 21 ** information to ensure the GNU General Public License requirements will 22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 23 ** 24 ****************************************************************************/ 25 26 #include "webassemblyconstants.h" 27 #include "webassemblyqtversion.h" 28 29 #include <projectexplorer/abi.h> 30 #include <projectexplorer/projectexplorerconstants.h> 31 #include <remotelinux/remotelinux_constants.h> 32 #include <coreplugin/featureprovider.h> 33 #include <coreplugin/icore.h> 34 #include <qtsupport/qtversionmanager.h> 35 36 #include <utils/algorithm.h> 37 #include <utils/hostosinfo.h> 38 #include <utils/qtcassert.h> 39 40 #include <QCoreApplication> 41 #include <QFileInfo> 42 #include <QVersionNumber> 43 44 using namespace QtSupport; 45 using namespace Utils; 46 47 namespace WebAssembly { 48 namespace Internal { 49 50 WebAssemblyQtVersion::WebAssemblyQtVersion() = default; 51 description() const52QString WebAssemblyQtVersion::description() const 53 { 54 return QCoreApplication::translate("WebAssemblyPlugin", "WebAssembly", 55 "Qt Version is meant for WebAssembly"); 56 } 57 targetDeviceTypes() const58QSet<Id> WebAssemblyQtVersion::targetDeviceTypes() const 59 { 60 return {Constants::WEBASSEMBLY_DEVICE_TYPE}; 61 } 62 WebAssemblyQtVersionFactory()63WebAssemblyQtVersionFactory::WebAssemblyQtVersionFactory() 64 { 65 setQtVersionCreator([] { return new WebAssemblyQtVersion; }); 66 setSupportedType(Constants::WEBASSEMBLY_QT_VERSION); 67 setPriority(1); 68 setRestrictionChecker([](const SetupData &setup) { 69 return setup.platforms.contains("wasm"); 70 }); 71 } 72 isValid() const73bool WebAssemblyQtVersion::isValid() const 74 { 75 return BaseQtVersion::isValid() && qtVersion() >= minimumSupportedQtVersion(); 76 } 77 invalidReason() const78QString WebAssemblyQtVersion::invalidReason() const 79 { 80 const QString baseReason = BaseQtVersion::invalidReason(); 81 if (!baseReason.isEmpty()) 82 return baseReason; 83 84 return tr("%1 does not support Qt for WebAssembly below version %2.") 85 .arg(Core::ICore::versionString()) 86 .arg(QVersionNumber(minimumSupportedQtVersion().majorVersion, 87 minimumSupportedQtVersion().minorVersion).toString()); 88 } 89 minimumSupportedQtVersion()90const QtVersionNumber &WebAssemblyQtVersion::minimumSupportedQtVersion() 91 { 92 const static QtVersionNumber number(5, 15); 93 return number; 94 } 95 isQtVersionInstalled()96bool WebAssemblyQtVersion::isQtVersionInstalled() 97 { 98 return anyOf(QtVersionManager::versions(), [](const BaseQtVersion *v) { 99 return v->type() == Constants::WEBASSEMBLY_QT_VERSION; 100 }); 101 } 102 isUnsupportedQtVersionInstalled()103bool WebAssemblyQtVersion::isUnsupportedQtVersionInstalled() 104 { 105 return anyOf(QtVersionManager::versions(), [](const BaseQtVersion *v) { 106 return v->type() == Constants::WEBASSEMBLY_QT_VERSION 107 && v->qtVersion() < WebAssemblyQtVersion::minimumSupportedQtVersion(); 108 }); 109 } 110 111 } // namespace Internal 112 } // namespace WebAssembly 113