2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2019 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2017-02-06 16:59:53 +01:00
|
|
|
|
2019-08-28 18:22:45 +02:00
|
|
|
#include "rawprojectpart.h"
|
2017-02-06 16:59:53 +01:00
|
|
|
|
2019-08-28 18:22:45 +02:00
|
|
|
#include "abi.h"
|
2021-05-07 16:10:07 +02:00
|
|
|
#include "buildconfiguration.h"
|
2022-10-11 16:22:15 +02:00
|
|
|
#include "buildsystem.h"
|
2019-08-28 18:22:45 +02:00
|
|
|
#include "kitinformation.h"
|
2019-08-29 09:59:45 +02:00
|
|
|
#include "project.h"
|
|
|
|
|
#include "target.h"
|
2017-02-06 16:59:53 +01:00
|
|
|
|
2022-10-11 16:22:15 +02:00
|
|
|
#include <ios/iosconstants.h>
|
2019-06-12 12:48:07 +02:00
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
|
2019-08-28 18:22:45 +02:00
|
|
|
namespace ProjectExplorer {
|
2017-02-06 16:59:53 +01:00
|
|
|
|
2019-08-28 18:22:45 +02:00
|
|
|
RawProjectPartFlags::RawProjectPartFlags(const ToolChain *toolChain,
|
2018-06-11 12:52:04 +02:00
|
|
|
const QStringList &commandLineFlags,
|
|
|
|
|
const QString &includeFileBaseDir)
|
2017-02-06 16:59:53 +01:00
|
|
|
{
|
|
|
|
|
// Keep the following cheap/non-blocking for the ui thread. Expensive
|
|
|
|
|
// operations are encapsulated in ToolChainInfo as "runners".
|
2019-01-08 16:22:39 +01:00
|
|
|
this->commandLineFlags = commandLineFlags;
|
2017-02-06 16:59:53 +01:00
|
|
|
if (toolChain) {
|
|
|
|
|
warningFlags = toolChain->warningFlags(commandLineFlags);
|
2018-10-08 09:49:02 +02:00
|
|
|
languageExtensions = toolChain->languageExtensions(commandLineFlags);
|
2018-06-11 12:52:04 +02:00
|
|
|
includedFiles = toolChain->includedFiles(commandLineFlags, includeFileBaseDir);
|
2017-02-06 16:59:53 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RawProjectPart::setDisplayName(const QString &displayName)
|
|
|
|
|
{
|
|
|
|
|
this->displayName = displayName;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-28 12:23:37 +02:00
|
|
|
void RawProjectPart::setFiles(const QStringList &files,
|
|
|
|
|
const FileIsActive &fileIsActive,
|
|
|
|
|
const GetMimeType &getMimeType)
|
2017-02-06 16:59:53 +01:00
|
|
|
{
|
|
|
|
|
this->files = files;
|
2019-08-28 12:23:37 +02:00
|
|
|
this->fileIsActive = fileIsActive;
|
|
|
|
|
this->getMimeType = getMimeType;
|
2017-02-06 16:59:53 +01:00
|
|
|
}
|
|
|
|
|
|
2019-06-12 12:48:07 +02:00
|
|
|
static QString trimTrailingSlashes(const QString &path) {
|
|
|
|
|
QString p = path;
|
|
|
|
|
while (p.endsWith('/') && p.count() > 1) {
|
|
|
|
|
p.chop(1);
|
|
|
|
|
}
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-28 18:22:45 +02:00
|
|
|
HeaderPath RawProjectPart::frameworkDetectionHeuristic(const HeaderPath &header)
|
2019-06-12 12:48:07 +02:00
|
|
|
{
|
|
|
|
|
QString path = trimTrailingSlashes(header.path);
|
|
|
|
|
|
2021-08-24 15:30:04 +02:00
|
|
|
if (path.endsWith(".framework"))
|
|
|
|
|
return HeaderPath::makeFramework(path.left(path.lastIndexOf('/')));
|
2019-06-12 12:48:07 +02:00
|
|
|
return header;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-09 14:13:22 +01:00
|
|
|
void RawProjectPart::setProjectFileLocation(const QString &projectFile, int line, int column)
|
2017-02-06 16:59:53 +01:00
|
|
|
{
|
|
|
|
|
this->projectFile = projectFile;
|
2017-02-27 14:02:38 +01:00
|
|
|
projectFileLine = line;
|
|
|
|
|
projectFileColumn = column;
|
2017-02-06 16:59:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RawProjectPart::setConfigFileName(const QString &configFileName)
|
|
|
|
|
{
|
|
|
|
|
this->projectConfigFile = configFileName;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-27 14:46:45 +01:00
|
|
|
void RawProjectPart::setBuildSystemTarget(const QString &target)
|
|
|
|
|
{
|
|
|
|
|
buildSystemTarget = target;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-27 14:37:41 +01:00
|
|
|
void RawProjectPart::setCallGroupId(const QString &id)
|
|
|
|
|
{
|
|
|
|
|
callGroupId = id;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-21 16:06:36 +01:00
|
|
|
void RawProjectPart::setQtVersion(Utils::QtMajorVersion qtVersion)
|
2017-02-06 16:59:53 +01:00
|
|
|
{
|
|
|
|
|
this->qtVersion = qtVersion;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-28 18:22:45 +02:00
|
|
|
void RawProjectPart::setMacros(const Macros ¯os)
|
2017-02-06 16:59:53 +01:00
|
|
|
{
|
2017-02-07 15:00:38 +01:00
|
|
|
this->projectMacros = macros;
|
2017-02-06 16:59:53 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-28 18:22:45 +02:00
|
|
|
void RawProjectPart::setHeaderPaths(const HeaderPaths &headerPaths)
|
2017-02-06 16:59:53 +01:00
|
|
|
{
|
|
|
|
|
this->headerPaths = headerPaths;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RawProjectPart::setIncludePaths(const QStringList &includePaths)
|
|
|
|
|
{
|
2019-06-12 12:48:07 +02:00
|
|
|
this->headerPaths = Utils::transform<QVector>(includePaths, [](const QString &path) {
|
2021-08-24 15:30:04 +02:00
|
|
|
return RawProjectPart::frameworkDetectionHeuristic(HeaderPath::makeUser(path));
|
2019-06-12 12:48:07 +02:00
|
|
|
});
|
2017-02-06 16:59:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RawProjectPart::setPreCompiledHeaders(const QStringList &preCompiledHeaders)
|
|
|
|
|
{
|
|
|
|
|
this->precompiledHeaders = preCompiledHeaders;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-11 12:52:04 +02:00
|
|
|
void RawProjectPart::setIncludedFiles(const QStringList &files)
|
|
|
|
|
{
|
|
|
|
|
includedFiles = files;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-06 16:59:53 +01:00
|
|
|
void RawProjectPart::setSelectedForBuilding(bool yesno)
|
|
|
|
|
{
|
|
|
|
|
this->selectedForBuilding = yesno;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RawProjectPart::setFlagsForC(const RawProjectPartFlags &flags)
|
|
|
|
|
{
|
|
|
|
|
flagsForC = flags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RawProjectPart::setFlagsForCxx(const RawProjectPartFlags &flags)
|
|
|
|
|
{
|
|
|
|
|
flagsForCxx = flags;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-28 18:22:45 +02:00
|
|
|
void RawProjectPart::setBuildTargetType(BuildTargetType type)
|
2017-08-29 12:11:27 +02:00
|
|
|
{
|
|
|
|
|
buildTargetType = type;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-20 12:12:53 +01:00
|
|
|
KitInfo::KitInfo(Kit *kit)
|
|
|
|
|
: kit(kit)
|
2019-08-29 09:59:45 +02:00
|
|
|
{
|
|
|
|
|
// Toolchains
|
|
|
|
|
if (kit) {
|
2020-02-18 18:25:26 +01:00
|
|
|
cToolChain = ToolChainKitAspect::cToolChain(kit);
|
|
|
|
|
cxxToolChain = ToolChainKitAspect::cxxToolChain(kit);
|
2019-08-29 09:59:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sysroot
|
2022-06-30 09:08:47 +02:00
|
|
|
sysRootPath = SysRootKitAspect::sysRoot(kit);
|
2019-08-29 09:59:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool KitInfo::isValid() const
|
|
|
|
|
{
|
|
|
|
|
return kit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChainInfo::ToolChainInfo(const ToolChain *toolChain,
|
2022-06-30 09:08:47 +02:00
|
|
|
const Utils::FilePath &sysRootPath,
|
2019-08-29 09:59:45 +02:00
|
|
|
const Utils::Environment &env)
|
|
|
|
|
{
|
|
|
|
|
if (toolChain) {
|
|
|
|
|
// Keep the following cheap/non-blocking for the ui thread...
|
|
|
|
|
type = toolChain->typeId();
|
|
|
|
|
isMsvc2015ToolChain = toolChain->targetAbi().osFlavor() == Abi::WindowsMsvc2015Flavor;
|
2022-10-07 18:00:36 +02:00
|
|
|
abi = toolChain->targetAbi();
|
2022-01-20 16:53:55 +01:00
|
|
|
targetTriple = toolChain->effectiveCodeModelTargetTriple();
|
|
|
|
|
targetTripleIsAuthoritative = !toolChain->explicitCodeModelTargetTriple().isEmpty();
|
2019-08-29 09:59:45 +02:00
|
|
|
extraCodeModelFlags = toolChain->extraCodeModelFlags();
|
2019-10-10 11:04:01 +02:00
|
|
|
installDir = toolChain->installDir();
|
2021-05-07 16:10:07 +02:00
|
|
|
compilerFilePath = toolChain->compilerCommand();
|
2019-08-29 09:59:45 +02:00
|
|
|
|
|
|
|
|
// ...and save the potentially expensive operations for later so that
|
|
|
|
|
// they can be run from a worker thread.
|
|
|
|
|
this->sysRootPath = sysRootPath;
|
|
|
|
|
headerPathsRunner = toolChain->createBuiltInHeaderPathsRunner(env);
|
|
|
|
|
macroInspectionRunner = toolChain->createMacroInspectionRunner();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectUpdateInfo::ProjectUpdateInfo(Project *project,
|
|
|
|
|
const KitInfo &kitInfo,
|
|
|
|
|
const Utils::Environment &env,
|
2020-02-04 12:27:58 +01:00
|
|
|
const RawProjectParts &rawProjectParts,
|
|
|
|
|
const RppGenerator &rppGenerator)
|
2021-05-07 16:10:07 +02:00
|
|
|
: rawProjectParts(rawProjectParts)
|
2020-02-04 12:27:58 +01:00
|
|
|
, rppGenerator(rppGenerator)
|
2021-05-07 16:10:07 +02:00
|
|
|
, cToolChainInfo(ToolChainInfo(kitInfo.cToolChain, kitInfo.sysRootPath, env))
|
|
|
|
|
, cxxToolChainInfo(ToolChainInfo(kitInfo.cxxToolChain, kitInfo.sysRootPath, env))
|
|
|
|
|
{
|
|
|
|
|
if (project) {
|
|
|
|
|
projectName = project->displayName();
|
|
|
|
|
projectFilePath = project->projectFilePath();
|
|
|
|
|
if (project->activeTarget() && project->activeTarget()->activeBuildConfiguration())
|
|
|
|
|
buildRoot = project->activeTarget()->activeBuildConfiguration()->buildDirectory();
|
|
|
|
|
}
|
2019-08-29 09:59:45 +02:00
|
|
|
}
|
|
|
|
|
|
2022-10-11 16:22:15 +02:00
|
|
|
// We do not get the -target flag from qmake or cmake on macOS; see QTCREATORBUG-28278.
|
|
|
|
|
void addTargetFlagForIos(QStringList &cFlags, QStringList &cxxFlags, const BuildSystem *bs,
|
|
|
|
|
const std::function<QString ()> &getDeploymentTarget)
|
|
|
|
|
{
|
|
|
|
|
const Utils::Id deviceType = DeviceTypeKitAspect::deviceTypeId(bs->target()->kit());
|
|
|
|
|
if (deviceType != Ios::Constants::IOS_DEVICE_TYPE
|
|
|
|
|
&& deviceType != Ios::Constants::IOS_SIMULATOR_TYPE) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const bool isSim = deviceType == Ios::Constants::IOS_SIMULATOR_TYPE;
|
|
|
|
|
QString targetTriple(QLatin1String(isSim ? "x86_64" : "arm64"));
|
|
|
|
|
targetTriple.append("-apple-ios").append(getDeploymentTarget());
|
|
|
|
|
if (isSim)
|
|
|
|
|
targetTriple.append("-simulator");
|
|
|
|
|
const auto addTargetFlag = [&targetTriple](QStringList &flags) {
|
|
|
|
|
if (!flags.contains("-target") && !Utils::contains(flags,
|
|
|
|
|
[](const QString &flag) { return flag.startsWith("--target="); })) {
|
|
|
|
|
flags << "-target" << targetTriple;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
addTargetFlag(cxxFlags);
|
|
|
|
|
addTargetFlag(cFlags);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-28 18:22:45 +02:00
|
|
|
} // namespace ProjectExplorer
|