2017-02-06 16:59:53 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2019-08-28 18:22:45 +02:00
|
|
|
** Copyright (C) 2019 The Qt Company Ltd.
|
2017-02-06 16:59:53 +01:00
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
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"
|
2019-08-28 18:22:45 +02:00
|
|
|
#include "kitinformation.h"
|
2019-08-29 09:59:45 +02:00
|
|
|
#include "project.h"
|
2019-08-28 18:22:45 +02:00
|
|
|
#include "projectexplorerconstants.h"
|
2019-08-29 09:59:45 +02:00
|
|
|
#include "target.h"
|
2017-02-06 16:59:53 +01:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-28 13:04:16 +02:00
|
|
|
void RawProjectPart::setQtVersion(Utils::QtVersion 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
|
|
|
|
|
sysRootPath = SysRootKitAspect::sysRoot(kit).toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool KitInfo::isValid() const
|
|
|
|
|
{
|
|
|
|
|
return kit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChainInfo::ToolChainInfo(const ToolChain *toolChain,
|
|
|
|
|
const QString &sysRootPath,
|
|
|
|
|
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;
|
|
|
|
|
wordWidth = toolChain->targetAbi().wordWidth();
|
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
|
|
|
}
|
|
|
|
|
|
2019-08-28 18:22:45 +02:00
|
|
|
} // namespace ProjectExplorer
|