forked from qt-creator/qt-creator
Utils: Introduce FilePath::operator/(const QString &)
Including some random uses. This mimics std::filesystem::operator/(std::filesystem::path). Change-Id: I0b0f5cf0d962fd33d4cbb9be96645a0b4a21ee03 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -376,9 +376,7 @@ void AndroidBuildApkStep::doRun()
|
||||
auto setup = [this] {
|
||||
const auto androidAbis = AndroidManager::applicationAbis(target());
|
||||
for (const auto &abi : androidAbis) {
|
||||
Utils::FilePath androidLibsDir = buildDirectory()
|
||||
.pathAppended("android-build/libs")
|
||||
.pathAppended(abi);
|
||||
FilePath androidLibsDir = buildDirectory() / "android-build/libs" / abi;
|
||||
if (!androidLibsDir.exists() && !QDir{buildDirectory().toString()}.mkpath(androidLibsDir.toString()))
|
||||
return false;
|
||||
}
|
||||
@@ -404,7 +402,7 @@ void AndroidBuildApkStep::doRun()
|
||||
if (version->qtVersion() < QtSupport::QtVersionNumber(5, 14, 0)) {
|
||||
QTC_ASSERT(androidAbis.size() == 1, return false);
|
||||
applicationBinary = buildSystem()->buildTarget(buildKey).targetFilePath.toString();
|
||||
Utils::FilePath androidLibsDir = buildDirectory().pathAppended("android-build/libs").pathAppended(androidAbis.first());
|
||||
FilePath androidLibsDir = buildDirectory() / "android-build/libs" / androidAbis.first();
|
||||
for (const auto &target : targets) {
|
||||
if (!copyFileIfNewer(target, androidLibsDir.pathAppended(QFileInfo{target}.fileName()).toString()))
|
||||
return false;
|
||||
@@ -422,9 +420,7 @@ void AndroidBuildApkStep::doRun()
|
||||
applicationBinary.remove(0, 3).chop(targetSuffix.size());
|
||||
}
|
||||
|
||||
Utils::FilePath androidLibsDir = buildDirectory()
|
||||
.pathAppended("android-build/libs")
|
||||
.pathAppended(abi);
|
||||
FilePath androidLibsDir = buildDirectory() / "android-build/libs" / abi;
|
||||
for (const auto &target : targets) {
|
||||
if (target.endsWith(targetSuffix)) {
|
||||
if (!copyFileIfNewer(target, androidLibsDir.pathAppended(QFileInfo{target}.fileName()).toString()))
|
||||
|
||||
@@ -430,7 +430,7 @@ QString AndroidConfig::apiLevelNameFor(const SdkPlatform *platform)
|
||||
|
||||
FilePath AndroidConfig::adbToolPath() const
|
||||
{
|
||||
return m_sdkLocation.pathAppended("platform-tools/adb" QTC_HOST_EXE_SUFFIX);
|
||||
return m_sdkLocation / "platform-tools/adb" QTC_HOST_EXE_SUFFIX;
|
||||
}
|
||||
|
||||
FilePath AndroidConfig::androidToolPath() const
|
||||
@@ -438,12 +438,12 @@ FilePath AndroidConfig::androidToolPath() const
|
||||
if (HostOsInfo::isWindowsHost()) {
|
||||
// I want to switch from using android.bat to using an executable. All it really does is call
|
||||
// Java and I've made some progress on it. So if android.exe exists, return that instead.
|
||||
const FilePath path = m_sdkLocation.pathAppended("tools/android" QTC_HOST_EXE_SUFFIX);
|
||||
const FilePath path = m_sdkLocation / "tools/android" QTC_HOST_EXE_SUFFIX;
|
||||
if (path.exists())
|
||||
return path;
|
||||
return m_sdkLocation.pathAppended("tools/android" ANDROID_BAT_SUFFIX);
|
||||
return m_sdkLocation / "tools/android" ANDROID_BAT_SUFFIX;
|
||||
}
|
||||
return m_sdkLocation.pathAppended("tools/android");
|
||||
return m_sdkLocation / "tools/android";
|
||||
}
|
||||
|
||||
FilePath AndroidConfig::emulatorToolPath() const
|
||||
@@ -451,7 +451,7 @@ FilePath AndroidConfig::emulatorToolPath() const
|
||||
QString relativePath = "emulator/emulator";
|
||||
if (sdkToolsVersion() < QVersionNumber(25, 3, 0))
|
||||
relativePath = "tools/emulator";
|
||||
return m_sdkLocation.pathAppended(relativePath + QTC_HOST_EXE_SUFFIX);
|
||||
return m_sdkLocation / (relativePath + QTC_HOST_EXE_SUFFIX);
|
||||
}
|
||||
|
||||
FilePath AndroidConfig::sdkManagerToolPath() const
|
||||
@@ -459,7 +459,7 @@ FilePath AndroidConfig::sdkManagerToolPath() const
|
||||
QString toolPath = "tools/bin/sdkmanager";
|
||||
if (HostOsInfo::isWindowsHost())
|
||||
toolPath += ANDROID_BAT_SUFFIX;
|
||||
return m_sdkLocation.pathAppended(toolPath);
|
||||
return m_sdkLocation / toolPath;
|
||||
}
|
||||
|
||||
FilePath AndroidConfig::avdManagerToolPath() const
|
||||
@@ -467,21 +467,21 @@ FilePath AndroidConfig::avdManagerToolPath() const
|
||||
QString toolPath = "tools/bin/avdmanager";
|
||||
if (HostOsInfo::isWindowsHost())
|
||||
toolPath += ANDROID_BAT_SUFFIX;
|
||||
return m_sdkLocation.pathAppended(toolPath);
|
||||
return m_sdkLocation / toolPath;
|
||||
}
|
||||
|
||||
FilePath AndroidConfig::aaptToolPath() const
|
||||
{
|
||||
const Utils::FilePath aaptToolPath = m_sdkLocation.pathAppended("build-tools");
|
||||
const FilePath aaptToolPath = m_sdkLocation / "build-tools";
|
||||
QString toolPath = QString("%1/aapt").arg(buildToolsVersion().toString());
|
||||
if (HostOsInfo::isWindowsHost())
|
||||
toolPath += QTC_HOST_EXE_SUFFIX;
|
||||
return aaptToolPath.pathAppended(toolPath);
|
||||
return aaptToolPath / toolPath;
|
||||
}
|
||||
|
||||
FilePath AndroidConfig::toolchainPathFromNdk(const Utils::FilePath &ndkLocation) const
|
||||
{
|
||||
const FilePath toolchainPath = ndkLocation.pathAppended("toolchains/llvm/prebuilt/");
|
||||
const FilePath toolchainPath = ndkLocation / "toolchains/llvm/prebuilt/";
|
||||
|
||||
// detect toolchain host
|
||||
QStringList hostPatterns;
|
||||
@@ -501,7 +501,7 @@ FilePath AndroidConfig::toolchainPathFromNdk(const Utils::FilePath &ndkLocation)
|
||||
QDirIterator iter(toolchainPath.toString(), hostPatterns, QDir::Dirs);
|
||||
if (iter.hasNext()) {
|
||||
iter.next();
|
||||
return toolchainPath.pathAppended(iter.fileName());
|
||||
return toolchainPath / iter.fileName();
|
||||
}
|
||||
|
||||
return {};
|
||||
@@ -517,7 +517,7 @@ FilePath AndroidConfig::clangPathFromNdk(const Utils::FilePath &ndkLocation) con
|
||||
const FilePath path = toolchainPathFromNdk(ndkLocation);
|
||||
if (path.isEmpty())
|
||||
return {};
|
||||
return path.pathAppended(HostOsInfo::withExecutableSuffix("bin/clang"));
|
||||
return path / HostOsInfo::withExecutableSuffix("bin/clang");
|
||||
}
|
||||
|
||||
FilePath AndroidConfig::clangPath(const BaseQtVersion *qtVersion) const
|
||||
@@ -849,8 +849,7 @@ QVersionNumber AndroidConfig::sdkToolsVersion() const
|
||||
{
|
||||
QVersionNumber version;
|
||||
if (m_sdkLocation.exists()) {
|
||||
const Utils::FilePath sdkToolsPropertiesPath
|
||||
= m_sdkLocation.pathAppended("tools/source.properties");
|
||||
const FilePath sdkToolsPropertiesPath = m_sdkLocation / "tools/source.properties";
|
||||
QSettings settings(sdkToolsPropertiesPath.toString(), QSettings::IniFormat);
|
||||
auto versionStr = settings.value(sdkToolsVersionKey).toString();
|
||||
version = QVersionNumber::fromString(versionStr);
|
||||
|
||||
@@ -161,11 +161,10 @@ void AndroidDebugSupport::start()
|
||||
// instead ~/android/ndk-bundle/platforms/android-29/arch-arm64
|
||||
// use ~/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot
|
||||
if (qtVersion) {
|
||||
Utils::FilePath sysRoot = AndroidConfigurations::currentConfig()
|
||||
.ndkLocation(qtVersion)
|
||||
.pathAppended("platforms")
|
||||
.pathAppended(QString("android-%1").arg(sdkVersion))
|
||||
.pathAppended(devicePreferredAbi);
|
||||
Utils::FilePath sysRoot = AndroidConfigurations::currentConfig().ndkLocation(qtVersion)
|
||||
/ "platforms"
|
||||
/ QString("android-%1").arg(sdkVersion)
|
||||
/ devicePreferredAbi;
|
||||
setSysRoot(sysRoot);
|
||||
qCDebug(androidDebugSupportLog) << "Sysroot: " << sysRoot;
|
||||
}
|
||||
|
||||
@@ -293,10 +293,10 @@ QJsonObject AndroidManager::deploymentSettings(const Target *target)
|
||||
if (qt->qtVersion() < QtSupport::QtVersionNumber(5, 14, 0)) {
|
||||
const QStringList abis = applicationAbis(target);
|
||||
QTC_ASSERT(abis.size() == 1, return {});
|
||||
settings["stdcpp-path"] = AndroidConfigurations::currentConfig().toolchainPath(qt)
|
||||
.pathAppended("sysroot/usr/lib/")
|
||||
.pathAppended(archTriplet(abis.first()))
|
||||
.pathAppended("libc++_shared.so").toString();
|
||||
settings["stdcpp-path"] = (AndroidConfigurations::currentConfig().toolchainPath(qt)
|
||||
/ "sysroot/usr/lib/"
|
||||
/ archTriplet(abis.first())
|
||||
/ "libc++_shared.so").toString();
|
||||
} else {
|
||||
settings["stdcpp-path"] = AndroidConfigurations::currentConfig()
|
||||
.toolchainPath(qt)
|
||||
@@ -321,7 +321,7 @@ bool AndroidManager::isQtCreatorGenerated(const FilePath &deploymentFile)
|
||||
Utils::FilePath AndroidManager::dirPath(const ProjectExplorer::Target *target)
|
||||
{
|
||||
if (auto *bc = target->activeBuildConfiguration())
|
||||
return bc->buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY);
|
||||
return bc->buildDirectory() / Constants::ANDROID_BUILDDIRECTORY;
|
||||
return Utils::FilePath();
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ Utils::FilePath AndroidManager::apkPath(const ProjectExplorer::Target *target)
|
||||
else
|
||||
apkPath += QLatin1String("debug.apk");
|
||||
|
||||
return dirPath(target).pathAppended(apkPath);
|
||||
return dirPath(target) / apkPath;
|
||||
}
|
||||
|
||||
bool AndroidManager::matchedAbis(const QStringList &deviceAbis, const QStringList &appAbis)
|
||||
@@ -738,7 +738,7 @@ bool AndroidManager::updateGradleProperties(ProjectExplorer::Target *target, con
|
||||
if (!packageSourceDir.exists())
|
||||
return false;
|
||||
|
||||
const FilePath wrapperProps = packageSourceDir.pathAppended("gradle/wrapper/gradle-wrapper.properties");
|
||||
const FilePath wrapperProps = packageSourceDir / "gradle/wrapper/gradle-wrapper.properties";
|
||||
if (wrapperProps.exists()) {
|
||||
GradleProperties wrapperProperties = readGradleProperties(wrapperProps.toString());
|
||||
QString distributionUrl = QString::fromLocal8Bit(wrapperProperties["distributionUrl"]);
|
||||
@@ -751,7 +751,7 @@ bool AndroidManager::updateGradleProperties(ProjectExplorer::Target *target, con
|
||||
|
||||
GradleProperties localProperties;
|
||||
localProperties["sdk.dir"] = AndroidConfigurations::currentConfig().sdkLocation().toString().toLocal8Bit();
|
||||
const FilePath localPropertiesFile = packageSourceDir.pathAppended("local.properties");
|
||||
const FilePath localPropertiesFile = packageSourceDir / "local.properties";
|
||||
if (!mergeGradleProperties(localPropertiesFile.toString(), localProperties))
|
||||
return false;
|
||||
|
||||
@@ -773,7 +773,7 @@ bool AndroidManager::updateGradleProperties(ProjectExplorer::Target *target, con
|
||||
int AndroidManager::findApiLevel(const Utils::FilePath &platformPath)
|
||||
{
|
||||
int apiLevel = -1;
|
||||
const Utils::FilePath propertiesPath = platformPath.pathAppended("/source.properties");
|
||||
const Utils::FilePath propertiesPath = platformPath / "/source.properties";
|
||||
if (propertiesPath.exists()) {
|
||||
QSettings sdkProperties(propertiesPath.toString(), QSettings::IniFormat);
|
||||
bool validInt = false;
|
||||
|
||||
Reference in New Issue
Block a user