forked from qt-creator/qt-creator
CMakeProjectManager: Replace FilePath::toString
Replace occurrences of FilePath::toString with more sensible alternatives. Use FilePath instead of QString where it makes sense. Change-Id: I3569b39fa6042d26deeb1dc46e63e4a19efcdb58 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -246,9 +246,12 @@ bool CMakeBuildSystem::supportsAction(Node *context, ProjectAction action, const
|
||||
|
||||
static QString relativeFilePaths(const FilePaths &filePaths, const FilePath &projectDir)
|
||||
{
|
||||
return Utils::transform(filePaths, [projectDir](const FilePath &path) {
|
||||
return path.canonicalPath().relativePathFrom(projectDir).cleanPath().toString();
|
||||
}).join(' ');
|
||||
return Utils::transform(
|
||||
filePaths,
|
||||
[projectDir](const FilePath &path) {
|
||||
return path.canonicalPath().relativePathFrom(projectDir).cleanPath().path();
|
||||
})
|
||||
.join(' ');
|
||||
};
|
||||
|
||||
static QString newFilesForFunction(const std::string &cmakeFunction,
|
||||
@@ -735,7 +738,7 @@ bool CMakeBuildSystem::addFiles(Node *context, const FilePaths &filePaths, FileP
|
||||
{
|
||||
FilePaths tsFiles, srcFiles;
|
||||
std::tie(tsFiles, srcFiles) = Utils::partition(filePaths, [](const FilePath &fp) {
|
||||
return Utils::mimeTypeForFile(fp.toString()).name() == Utils::Constants::LINGUIST_MIMETYPE;
|
||||
return Utils::mimeTypeForFile(fp).name() == Utils::Constants::LINGUIST_MIMETYPE;
|
||||
});
|
||||
bool success = true;
|
||||
if (!srcFiles.isEmpty())
|
||||
@@ -862,7 +865,7 @@ RemovedFilesFromProject CMakeBuildSystem::removeFiles(Node *context,
|
||||
bool haveGlobbing = false;
|
||||
for (const auto &file : filePaths) {
|
||||
const QString fileName
|
||||
= file.canonicalPath().relativePathFrom(projDir).cleanPath().toString();
|
||||
= file.canonicalPath().relativePathFrom(projDir).cleanPath().path();
|
||||
|
||||
auto filePos = projectFileArgumentPosition(targetName, fileName);
|
||||
if (filePos) {
|
||||
@@ -944,7 +947,7 @@ bool CMakeBuildSystem::canRenameFile(Node *context,
|
||||
if (auto n = dynamic_cast<CMakeTargetNode *>(context)) {
|
||||
const FilePath projDir = n->filePath().canonicalPath();
|
||||
const QString oldRelPathName
|
||||
= oldFilePath.canonicalPath().relativePathFrom(projDir).cleanPath().toString();
|
||||
= oldFilePath.canonicalPath().relativePathFrom(projDir).cleanPath().path();
|
||||
|
||||
const QString targetName = n->buildKey();
|
||||
|
||||
@@ -1366,7 +1369,7 @@ void CMakeBuildSystem::updateProjectData()
|
||||
QStringList apps;
|
||||
for (const auto &target : std::as_const(m_buildTargets)) {
|
||||
if (target.targetType == DynamicLibraryType) {
|
||||
res.insert(target.executable.parentDir().toString());
|
||||
res.insert(target.executable.parentDir().path());
|
||||
apps.push_back(target.executable.toUserOutput());
|
||||
}
|
||||
// ### shall we add also the ExecutableType ?
|
||||
@@ -2192,8 +2195,9 @@ DeploymentData CMakeBuildSystem::deploymentDataFromFile() const
|
||||
if (ct.targetType == ExecutableType || ct.targetType == DynamicLibraryType) {
|
||||
if (!ct.executable.isEmpty()
|
||||
&& result.deployableForLocalFile(ct.executable).localFilePath() != ct.executable) {
|
||||
result.addFile(ct.executable,
|
||||
deploymentPrefix + buildDir.relativeChildPath(ct.executable).toString(),
|
||||
result.addFile(
|
||||
ct.executable,
|
||||
deploymentPrefix + buildDir.relativeChildPath(ct.executable).path(),
|
||||
DeployableFile::TypeExecutable);
|
||||
}
|
||||
}
|
||||
|
@@ -346,7 +346,7 @@ CMakeConfig CMakeConfig::fromArguments(const QStringList &list, QStringList &unk
|
||||
CMakeConfig CMakeConfig::fromFile(const Utils::FilePath &cacheFile, QString *errorMessage)
|
||||
{
|
||||
CMakeConfig result;
|
||||
QFile cache(cacheFile.toString());
|
||||
QFile cache(cacheFile.toFSPathString());
|
||||
if (!cache.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
if (errorMessage)
|
||||
*errorMessage = Tr::tr("Failed to open %1 for reading.").arg(cacheFile.toUserOutput());
|
||||
|
@@ -277,8 +277,8 @@ static QVariant findOrRegisterDebugger(
|
||||
QString errorMessage;
|
||||
debugger.reinitializeFromFile(&errorMessage, &env);
|
||||
if (!errorMessage.isEmpty())
|
||||
qCWarning(cmInputLog()) << "Error reinitializing debugger" << debuggerPath.toString()
|
||||
<< "Error:" << errorMessage;
|
||||
qCWarning(cmInputLog()) << "Error reinitializing debugger"
|
||||
<< debuggerPath.toUserOutput() << "Error:" << errorMessage;
|
||||
|
||||
return DebuggerItemManager::registerDebugger(debugger);
|
||||
} else {
|
||||
@@ -572,11 +572,11 @@ static QMakeAndCMakePrefixPath qtInfoFromCMakeCache(const CMakeConfig &config,
|
||||
}
|
||||
|
||||
if (!cmakeMakeProgram.isEmpty()) {
|
||||
args.push_back(QStringLiteral("-DCMAKE_MAKE_PROGRAM=%1").arg(cmakeMakeProgram.toString()));
|
||||
args.push_back(QStringLiteral("-DCMAKE_MAKE_PROGRAM=%1").arg(cmakeMakeProgram.path()));
|
||||
}
|
||||
|
||||
if (!toolchainFile.isEmpty()) {
|
||||
args.push_back(QStringLiteral("-DCMAKE_TOOLCHAIN_FILE=%1").arg(toolchainFile.toString()));
|
||||
args.push_back(QStringLiteral("-DCMAKE_TOOLCHAIN_FILE=%1").arg(toolchainFile.path()));
|
||||
}
|
||||
if (!prefixPath.isEmpty()) {
|
||||
args.push_back(QStringLiteral("-DCMAKE_PREFIX_PATH=%1").arg(prefixPath));
|
||||
@@ -585,7 +585,7 @@ static QMakeAndCMakePrefixPath qtInfoFromCMakeCache(const CMakeConfig &config,
|
||||
args.push_back(QStringLiteral("-DCMAKE_FIND_ROOT_PATH=%1").arg(findRootPath));
|
||||
}
|
||||
if (!hostPath.isEmpty()) {
|
||||
args.push_back(QStringLiteral("-DQT_HOST_PATH=%1").arg(hostPath.toString()));
|
||||
args.push_back(QStringLiteral("-DQT_HOST_PATH=%1").arg(hostPath.path()));
|
||||
}
|
||||
|
||||
qCDebug(cmInputLog) << "CMake probing for qmake path: " << cmakeExecutable.toUserOutput() << args;
|
||||
@@ -717,20 +717,20 @@ void updateConfigWithDirectoryData(CMakeConfig &config, const std::unique_ptr<Di
|
||||
});
|
||||
|
||||
if (it != config.end() && it->value.isEmpty())
|
||||
it->value = tcd.compilerPath.toString().toUtf8();
|
||||
it->value = tcd.compilerPath.path().toUtf8();
|
||||
else
|
||||
config << CMakeConfigItem(key,
|
||||
CMakeConfigItem::FILEPATH,
|
||||
tcd.compilerPath.toString().toUtf8());
|
||||
config << CMakeConfigItem(
|
||||
key, CMakeConfigItem::FILEPATH, tcd.compilerPath.path().toUtf8());
|
||||
};
|
||||
|
||||
updateCompilerValue("CMAKE_C_COMPILER", ProjectExplorer::Constants::C_LANGUAGE_ID);
|
||||
updateCompilerValue("CMAKE_CXX_COMPILER", ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
||||
|
||||
if (data->qt.qt)
|
||||
config << CMakeConfigItem("QT_QMAKE_EXECUTABLE",
|
||||
config << CMakeConfigItem(
|
||||
"QT_QMAKE_EXECUTABLE",
|
||||
CMakeConfigItem::FILEPATH,
|
||||
data->qt.qt->qmakeFilePath().toString().toUtf8());
|
||||
data->qt.qt->qmakeFilePath().path().toUtf8());
|
||||
}
|
||||
|
||||
Toolchain *findExternalToolchain(const QString &presetArchitecture, const QString &presetToolset)
|
||||
@@ -811,7 +811,7 @@ Toolchain *findExternalToolchain(const QString &presetArchitecture, const QStrin
|
||||
qCDebug(cmInputLog) << "For external architecture" << presetArchitecture
|
||||
<< "and toolset" << presetToolset
|
||||
<< "the following toolchain was selected:\n"
|
||||
<< compilerPath.toString();
|
||||
<< compilerPath.toUserOutput();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@@ -616,7 +616,7 @@ void CMakeManager::buildFile(Node *node)
|
||||
Target *target = project->activeTarget();
|
||||
QTC_ASSERT(target, return);
|
||||
const QString generator = CMakeGeneratorKitAspect::generator(target->kit());
|
||||
const QString relativeSource = filePath.relativeChildPath(targetNode->filePath()).toString();
|
||||
const FilePath relativeSource = filePath.relativeChildPath(targetNode->filePath());
|
||||
Utils::FilePath targetBase;
|
||||
BuildConfiguration *bc = target->activeBuildConfiguration();
|
||||
QTC_ASSERT(bc, return);
|
||||
@@ -631,7 +631,7 @@ void CMakeManager::buildFile(Node *node)
|
||||
}
|
||||
|
||||
auto cbc = static_cast<CMakeBuildSystem *>(bc->buildSystem());
|
||||
const QString sourceFile = targetBase.pathAppended(relativeSource).toString();
|
||||
const QString sourceFile = targetBase.resolvePath(relativeSource).path();
|
||||
const QString objExtension = [&]() -> QString {
|
||||
const auto sourceKind = ProjectFile::classify(relativeSource);
|
||||
const QByteArray cmakeLangExtension = ProjectFile::isCxx(sourceKind)
|
||||
|
@@ -247,7 +247,7 @@ QVariant CMakeTargetNode::data(Id role) const
|
||||
// or "-iphonesimulator" depending on the device type (which is unavailable here).
|
||||
|
||||
// dir/target.app/target -> dir
|
||||
return m_artifact.parentDir().parentDir().toString();
|
||||
return m_artifact.parentDir().parentDir().path();
|
||||
}
|
||||
|
||||
if (role == Ios::Constants::IosCmakeGenerator)
|
||||
|
@@ -120,7 +120,7 @@ CMakeTool::CMakeTool(const Store &map, bool fromSdk) :
|
||||
m_isAutoDetected = map.value(CMAKE_INFORMATION_AUTODETECTED, false).toBool();
|
||||
m_detectionSource = map.value(CMAKE_INFORMATION_DETECTIONSOURCE).toString();
|
||||
|
||||
setFilePath(FilePath::fromUserInput(map.value(CMAKE_INFORMATION_COMMAND).toString()));
|
||||
setFilePath(FilePath::fromSettings(map.value(CMAKE_INFORMATION_COMMAND)));
|
||||
|
||||
m_qchFilePath = FilePath::fromSettings(map.value(CMAKE_INFORMATION_QCH_FILE_PATH));
|
||||
|
||||
@@ -178,8 +178,8 @@ Store CMakeTool::toMap() const
|
||||
Store data;
|
||||
data.insert(CMAKE_INFORMATION_DISPLAYNAME, m_displayName);
|
||||
data.insert(CMAKE_INFORMATION_ID, m_id.toSetting());
|
||||
data.insert(CMAKE_INFORMATION_COMMAND, m_executable.toString());
|
||||
data.insert(CMAKE_INFORMATION_QCH_FILE_PATH, m_qchFilePath.toString());
|
||||
data.insert(CMAKE_INFORMATION_COMMAND, m_executable.toSettings());
|
||||
data.insert(CMAKE_INFORMATION_QCH_FILE_PATH, m_qchFilePath.toSettings());
|
||||
data.insert(CMAKE_INFORMATION_AUTO_CREATE_BUILD_DIRECTORY, m_autoCreateBuildDirectory);
|
||||
if (m_readerType)
|
||||
data.insert(CMAKE_INFORMATION_READERTYPE,
|
||||
@@ -384,16 +384,16 @@ FilePath CMakeTool::searchQchFile(const FilePath &executable)
|
||||
return {};
|
||||
|
||||
FilePath prefixDir = executable.parentDir().parentDir();
|
||||
QDir docDir{prefixDir.pathAppended("doc/cmake").toString()};
|
||||
FilePath docDir = prefixDir.pathAppended("doc/cmake");
|
||||
if (!docDir.exists())
|
||||
docDir.setPath(prefixDir.pathAppended("share/doc/cmake").toString());
|
||||
docDir = prefixDir.pathAppended("share/doc/cmake");
|
||||
if (!docDir.exists())
|
||||
return {};
|
||||
|
||||
const QStringList files = docDir.entryList(QStringList("*.qch"));
|
||||
for (const QString &docFile : files) {
|
||||
if (docFile.startsWith("cmake", Qt::CaseInsensitive)) {
|
||||
return FilePath::fromString(docDir.absoluteFilePath(docFile));
|
||||
const FilePaths files = docDir.dirEntries(QStringList("*.qch"));
|
||||
for (const FilePath &docFile : files) {
|
||||
if (docFile.startsWith("cmake")) {
|
||||
return docDir.resolvePath(docFile).absolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -350,7 +350,7 @@ void CMakeToolManager::updateDocumentation()
|
||||
QStringList docs;
|
||||
for (const auto tool : tools) {
|
||||
if (!tool->qchFilePath().isEmpty())
|
||||
docs.append(tool->qchFilePath().toString());
|
||||
docs.append(tool->qchFilePath().path());
|
||||
}
|
||||
Core::HelpManager::registerDocumentation(docs);
|
||||
}
|
||||
|
@@ -94,8 +94,9 @@ void ConfigModelItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *
|
||||
ConfigModel::DataItem data = ConfigModel::dataItemFromIndex(index);
|
||||
if (data.type == ConfigModel::DataItem::FILE || data.type == ConfigModel::DataItem::DIRECTORY) {
|
||||
auto edit = static_cast<PathChooser *>(editor);
|
||||
if (edit->unexpandedFilePath().toString() != data.value)
|
||||
model->setData(index, edit->unexpandedFilePath().toString(), Qt::EditRole);
|
||||
const QString unexpandedFilePath = edit->unexpandedFilePath().path();
|
||||
if (unexpandedFilePath != data.value)
|
||||
model->setData(index, unexpandedFilePath, Qt::EditRole);
|
||||
return;
|
||||
} else if (!data.values.isEmpty()) {
|
||||
auto edit = static_cast<QComboBox *>(editor);
|
||||
|
@@ -315,7 +315,7 @@ void FileApiReader::makeBackupConfiguration(bool store)
|
||||
if (!reply.renameFile(replyPrev))
|
||||
Core::MessageManager::writeFlashing(
|
||||
addCMakePrefix(Tr::tr("Failed to rename \"%1\" to \"%2\".")
|
||||
.arg(reply.toString(), replyPrev.toString())));
|
||||
.arg(reply.toUserOutput(), replyPrev.toUserOutput())));
|
||||
}
|
||||
|
||||
FilePath cmakeCacheTxt = m_parameters.buildDirectory.pathAppended(Constants::CMAKE_CACHE_TXT);
|
||||
@@ -325,9 +325,9 @@ void FileApiReader::makeBackupConfiguration(bool store)
|
||||
|
||||
if (cmakeCacheTxt.exists())
|
||||
if (!FileUtils::copyIfDifferent(cmakeCacheTxt, cmakeCacheTxtPrev))
|
||||
Core::MessageManager::writeFlashing(
|
||||
addCMakePrefix(Tr::tr("Failed to copy \"%1\" to \"%2\".")
|
||||
.arg(cmakeCacheTxt.toString(), cmakeCacheTxtPrev.toString())));
|
||||
Core::MessageManager::writeFlashing(addCMakePrefix(
|
||||
Tr::tr("Failed to copy \"%1\" to \"%2\".")
|
||||
.arg(cmakeCacheTxt.toUserOutput(), cmakeCacheTxtPrev.toUserOutput())));
|
||||
}
|
||||
|
||||
void FileApiReader::writeConfigurationIntoBuildDirectory(const QStringList &configurationArguments)
|
||||
|
@@ -37,8 +37,8 @@ static void expandAllButEnv(const PresetsDetails::ConfigurePreset &preset,
|
||||
{
|
||||
value.replace("${dollar}", "$");
|
||||
|
||||
value.replace("${sourceDir}", sourceDirectory.toString());
|
||||
value.replace("${sourceParentDir}", sourceDirectory.parentDir().toString());
|
||||
value.replace("${sourceDir}", sourceDirectory.path());
|
||||
value.replace("${sourceParentDir}", sourceDirectory.parentDir().path());
|
||||
value.replace("${sourceDirName}", sourceDirectory.fileName());
|
||||
|
||||
value.replace("${presetName}", preset.name);
|
||||
@@ -57,9 +57,9 @@ static void expandAllButEnv(const PresetsDetails::BuildPreset &preset,
|
||||
{
|
||||
value.replace("${dollar}", "$");
|
||||
|
||||
value.replace("${sourceDir}", sourceDirectory.toString());
|
||||
value.replace("${sourceDir}", sourceDirectory.path());
|
||||
value.replace("${fileDir}", preset.fileDir.path());
|
||||
value.replace("${sourceParentDir}", sourceDirectory.parentDir().toString());
|
||||
value.replace("${sourceParentDir}", sourceDirectory.parentDir().path());
|
||||
value.replace("${sourceDirName}", sourceDirectory.fileName());
|
||||
|
||||
value.replace("${presetName}", preset.name);
|
||||
@@ -233,7 +233,7 @@ void updateToolchainFile(
|
||||
if (!toolchainFile.exists())
|
||||
return;
|
||||
|
||||
const QString toolchainFileString = toolchainFile.cleanPath().toString();
|
||||
const QString toolchainFileString = toolchainFile.cleanPath().path();
|
||||
|
||||
// toolchainFile takes precedence to CMAKE_TOOLCHAIN_FILE
|
||||
CMakeConfig cache = configurePreset.cacheVariables ? configurePreset.cacheVariables.value()
|
||||
@@ -270,7 +270,7 @@ void updateInstallDir(PresetsDetails::ConfigurePreset &configurePreset,
|
||||
installDir = probePath;
|
||||
}
|
||||
}
|
||||
installDirString = installDir.cleanPath().toString();
|
||||
installDirString = installDir.cleanPath().path();
|
||||
|
||||
// installDir takes precedence to CMAKE_INSTALL_PREFIX
|
||||
CMakeConfig cache = configurePreset.cacheVariables ? configurePreset.cacheVariables.value()
|
||||
|
Reference in New Issue
Block a user