1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 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 "iosqtversion.h"
27 #include "iosconstants.h"
28 #include "iosconfigurations.h"
29 
30 #include <utils/environment.h>
31 #include <utils/hostosinfo.h>
32 
33 #include <qtsupport/qtkitinformation.h>
34 #include <qtsupport/qtsupportconstants.h>
35 #include <qtsupport/qtversionmanager.h>
36 
37 #include <projectexplorer/kit.h>
38 #include <projectexplorer/projectexplorer.h>
39 
40 using namespace Ios::Internal;
41 using namespace ProjectExplorer;
42 
43 IosQtVersion::IosQtVersion() = default;
44 
isValid() const45 bool IosQtVersion::isValid() const
46 {
47     if (!BaseQtVersion::isValid())
48         return false;
49     if (qtAbis().isEmpty())
50         return false;
51     return true;
52 }
53 
invalidReason() const54 QString IosQtVersion::invalidReason() const
55 {
56     QString tmp = BaseQtVersion::invalidReason();
57     if (tmp.isEmpty() && qtAbis().isEmpty())
58         return tr("Failed to detect the ABIs used by the Qt version.");
59     return tmp;
60 }
61 
detectQtAbis() const62 Abis IosQtVersion::detectQtAbis() const
63 {
64     Abis abis = BaseQtVersion::detectQtAbis();
65     for (int i = 0; i < abis.count(); ++i) {
66         abis[i] = Abi(abis.at(i).architecture(),
67                       abis.at(i).os(),
68                       Abi::GenericFlavor,
69                       abis.at(i).binaryFormat(),
70                       abis.at(i).wordWidth());
71     }
72     return abis;
73 }
74 
description() const75 QString IosQtVersion::description() const
76 {
77     //: Qt Version is meant for Ios
78     return tr("iOS");
79 }
80 
availableFeatures() const81 QSet<Utils::Id> IosQtVersion::availableFeatures() const
82 {
83     QSet<Utils::Id> features = QtSupport::BaseQtVersion::availableFeatures();
84     features.insert(QtSupport::Constants::FEATURE_MOBILE);
85     features.remove(QtSupport::Constants::FEATURE_QT_CONSOLE);
86     features.remove(QtSupport::Constants::FEATURE_QT_WEBKIT);
87     return features;
88 }
89 
targetDeviceTypes() const90 QSet<Utils::Id> IosQtVersion::targetDeviceTypes() const
91 {
92     // iOS Qt version supports ios devices as well as simulator.
93     return {Constants::IOS_DEVICE_TYPE, Constants::IOS_SIMULATOR_TYPE};
94 }
95 
96 
97 // Factory
98 
IosQtVersionFactory()99 IosQtVersionFactory::IosQtVersionFactory()
100 {
101     setQtVersionCreator([] { return new IosQtVersion; });
102     setSupportedType(Constants::IOSQT);
103     setPriority(90);
104     setRestrictionChecker([](const SetupData &setup) {
105         return setup.platforms.contains("ios");
106     });
107 }
108