forked from qt-creator/qt-creator
Project managers: Replace various uses of ProjectConfiguration::target()
Some were wrong, others unneeded. Change-Id: I308288e75f8d1b192863171661d72d27f1e6da07 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -909,7 +909,7 @@ Tasking::GroupItem AndroidBuildApkStep::runRecipe()
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto androidAbis = applicationAbis(target());
|
||||
const auto androidAbis = applicationAbis(kit());
|
||||
const QString buildKey = buildConfiguration()->activeBuildKey();
|
||||
const FilePath buildDir = buildDirectory();
|
||||
const FilePath androidBuildDir = androidBuildDirectory(buildConfiguration());
|
||||
@@ -956,7 +956,7 @@ Tasking::GroupItem AndroidBuildApkStep::runRecipe()
|
||||
if (targets.isEmpty())
|
||||
return inputExists; // qmake does this job for us
|
||||
|
||||
QJsonObject deploySettings = deploymentSettings(target());
|
||||
QJsonObject deploySettings = deploymentSettings(kit());
|
||||
QString applicationBinary;
|
||||
if (!version->supportsMultipleQtAbis()) {
|
||||
QTC_ASSERT(androidAbis.size() == 1, return false);
|
||||
@@ -1164,7 +1164,7 @@ QVariant AndroidBuildApkStep::data(Utils::Id id) const
|
||||
return QVariant::fromValue(AndroidConfig::sdkLocation());
|
||||
|
||||
if (id == Constants::AndroidMkSpecAbis)
|
||||
return applicationAbis(target());
|
||||
return applicationAbis(kit());
|
||||
|
||||
return AbstractProcessStep::data(id);
|
||||
}
|
||||
|
@@ -176,7 +176,7 @@ bool AndroidDeployQtStep::init()
|
||||
|
||||
m_androiddeployqtArgs = {};
|
||||
|
||||
const QStringList androidABIs = applicationAbis(target());
|
||||
const QStringList androidABIs = applicationAbis(kit());
|
||||
if (androidABIs.isEmpty()) {
|
||||
reportWarningOrError(Tr::tr("No Android architecture (ABI) is set by the project."),
|
||||
Task::Error);
|
||||
@@ -189,10 +189,6 @@ bool AndroidDeployQtStep::init()
|
||||
RunConfiguration *rc = buildConfiguration()->activeRunConfiguration();
|
||||
QTC_ASSERT(rc, reportWarningOrError(Tr::tr("The kit's run configuration is invalid."), Task::Error);
|
||||
return false);
|
||||
BuildConfiguration *bc = target()->activeBuildConfiguration();
|
||||
QTC_ASSERT(bc, reportWarningOrError(Tr::tr("The kit's build configuration is invalid."),
|
||||
Task::Error);
|
||||
return false);
|
||||
|
||||
const int minTargetApi = minimumSDK(buildConfiguration());
|
||||
qCDebug(deployStepLog) << "Target architecture:" << androidABIs
|
||||
@@ -297,7 +293,7 @@ bool AndroidDeployQtStep::init()
|
||||
if (buildType() == BuildConfiguration::Release)
|
||||
m_androiddeployqtArgs.addArgs({"--release"});
|
||||
|
||||
auto androidBuildApkStep = bc->buildSteps()->firstOfType<AndroidBuildApkStep>();
|
||||
auto androidBuildApkStep = stepList()->firstOfType<AndroidBuildApkStep>();
|
||||
if (androidBuildApkStep && androidBuildApkStep->signPackage()) {
|
||||
// The androiddeployqt tool is not really written to do stand-alone installations.
|
||||
// This hack forces it to use the correct filename for the apk file when installing
|
||||
@@ -307,7 +303,7 @@ bool AndroidDeployQtStep::init()
|
||||
}
|
||||
}
|
||||
|
||||
m_environment = bc->environment();
|
||||
m_environment = buildConfiguration()->environment();
|
||||
|
||||
m_adbPath = AndroidConfig::adbToolPath();
|
||||
return true;
|
||||
@@ -537,11 +533,8 @@ QWidget *AndroidDeployQtStep::createConfigWidget()
|
||||
return;
|
||||
|
||||
// TODO: Write error messages on all the early returns below.
|
||||
Target *currentTarget = target();
|
||||
if (currentTarget == nullptr)
|
||||
return;
|
||||
|
||||
const QStringList appAbis = applicationAbis(currentTarget);
|
||||
const QStringList appAbis = applicationAbis(kit());
|
||||
if (appAbis.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -595,7 +588,7 @@ QWidget *AndroidDeployQtStep::createConfigWidget()
|
||||
};
|
||||
|
||||
TaskTreeRunner *runner = new TaskTreeRunner;
|
||||
runner->setParent(currentTarget);
|
||||
runner->setParent(target());
|
||||
runner->start(recipe);
|
||||
});
|
||||
|
||||
|
@@ -223,9 +223,9 @@ QString buildTargetSDK(const BuildConfiguration *bc)
|
||||
return fallback;
|
||||
}
|
||||
|
||||
QStringList applicationAbis(const Target *target)
|
||||
QStringList applicationAbis(const Kit *k)
|
||||
{
|
||||
auto qt = dynamic_cast<AndroidQtVersion *>(QtSupport::QtKitAspect::qtVersion(target->kit()));
|
||||
auto qt = dynamic_cast<AndroidQtVersion *>(QtSupport::QtKitAspect::qtVersion(k));
|
||||
return qt ? qt->androidAbis() : QStringList();
|
||||
}
|
||||
|
||||
@@ -241,13 +241,13 @@ QString archTriplet(const QString &abi)
|
||||
return {"arm-linux-androideabi"};
|
||||
}
|
||||
|
||||
QJsonObject deploymentSettings(const Target *target)
|
||||
QJsonObject deploymentSettings(const Kit *k)
|
||||
{
|
||||
QtSupport::QtVersion *qt = QtSupport::QtKitAspect::qtVersion(target->kit());
|
||||
QtSupport::QtVersion *qt = QtSupport::QtKitAspect::qtVersion(k);
|
||||
if (!qt)
|
||||
return {};
|
||||
|
||||
auto tc = ToolchainKitAspect::cxxToolchain(target->kit());
|
||||
auto tc = ToolchainKitAspect::cxxToolchain(k);
|
||||
if (!tc || tc->typeId() != Constants::ANDROID_TOOLCHAIN_TYPEID)
|
||||
return {};
|
||||
QJsonObject settings;
|
||||
@@ -256,7 +256,7 @@ QJsonObject deploymentSettings(const Target *target)
|
||||
settings["ndk"] = AndroidConfig::ndkLocation(qt).toFSPathString();
|
||||
settings["sdk"] = AndroidConfig::sdkLocation().toFSPathString();
|
||||
if (!qt->supportsMultipleQtAbis()) {
|
||||
const QStringList abis = applicationAbis(target);
|
||||
const QStringList abis = applicationAbis(k);
|
||||
QTC_ASSERT(abis.size() == 1, return {});
|
||||
settings["stdcpp-path"] = (AndroidConfig::toolchainPath(qt) / "sysroot/usr/lib"
|
||||
/ archTriplet(abis.first()) / "libc++_shared.so")
|
||||
|
@@ -49,7 +49,7 @@ int minimumSDK(const ProjectExplorer::BuildConfiguration *bc);
|
||||
int minimumSDK(const ProjectExplorer::Kit *kit);
|
||||
int defaultMinimumSDK(const QtSupport::QtVersion *qtVersion);
|
||||
|
||||
QStringList applicationAbis(const ProjectExplorer::Target *target);
|
||||
QStringList applicationAbis(const ProjectExplorer::Kit *k);
|
||||
QString archTriplet(const QString &abi);
|
||||
|
||||
bool isQt5CmakeProject(const ProjectExplorer::Target *target);
|
||||
@@ -64,7 +64,7 @@ bool skipInstallationAndPackageSteps(const ProjectExplorer::BuildConfiguration *
|
||||
|
||||
QString androidNameForApiLevel(int x);
|
||||
|
||||
QJsonObject deploymentSettings(const ProjectExplorer::Target *target);
|
||||
QJsonObject deploymentSettings(const ProjectExplorer::Kit *k);
|
||||
bool isQtCreatorGenerated(const Utils::FilePath &deploymentFile);
|
||||
|
||||
QStringList adbSelector(const QString &serialNumber);
|
||||
|
@@ -2139,7 +2139,7 @@ static BuildConfiguration::BuildType startupBuildType()
|
||||
{
|
||||
BuildConfiguration::BuildType buildType = BuildConfiguration::Unknown;
|
||||
if (RunConfiguration *runConfig = activeRunConfigForActiveProject()) {
|
||||
if (const BuildConfiguration *buildConfig = runConfig->target()->activeBuildConfiguration())
|
||||
if (const BuildConfiguration *buildConfig = runConfig->buildConfiguration())
|
||||
buildType = buildConfig->buildType();
|
||||
}
|
||||
return buildType;
|
||||
|
@@ -39,8 +39,7 @@ namespace Debugger::Internal {
|
||||
|
||||
static bool isLocal(RunConfiguration *runConfiguration)
|
||||
{
|
||||
Target *target = runConfiguration ? runConfiguration->target() : nullptr;
|
||||
Kit *kit = target ? target->kit() : nullptr;
|
||||
Kit *kit = runConfiguration ? runConfiguration->kit() : nullptr;
|
||||
return RunDeviceTypeKitAspect::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
|
||||
}
|
||||
|
||||
|
@@ -51,11 +51,9 @@ private:
|
||||
const FilePath projectDirectory = project()->projectDirectory();
|
||||
ProcessRunData r;
|
||||
QStringList args;
|
||||
if (BuildConfiguration *buildConfiguration = target()->activeBuildConfiguration()) {
|
||||
args << "--work-dir"
|
||||
<< QDir(projectDirectory.toUrlishString()).relativeFilePath(
|
||||
buildConfiguration->buildDirectory().toUrlishString());
|
||||
}
|
||||
args << "--work-dir"
|
||||
<< QDir(projectDirectory.toUrlishString()).relativeFilePath(
|
||||
buildConfiguration()->buildDirectory().toUrlishString());
|
||||
args << "exec" << executable();
|
||||
if (!arguments.arguments().isEmpty())
|
||||
args << "--" << arguments.arguments();
|
||||
|
@@ -127,86 +127,83 @@ FilePath IosRunConfiguration::bundleDirectory() const
|
||||
}
|
||||
FilePath res;
|
||||
bool shouldAppendBuildTypeAndPlatform = true;
|
||||
if (BuildConfiguration *bc = target()->activeBuildConfiguration()) {
|
||||
Project *project = bc->project();
|
||||
if (ProjectNode *node = project->findNodeForBuildKey(buildKey())) {
|
||||
QString pathStr = node->data(Constants::IosBuildDir).toString();
|
||||
const QString cmakeGenerator = node->data(Constants::IosCmakeGenerator).toString();
|
||||
if (ProjectNode *node = project()->findNodeForBuildKey(buildKey())) {
|
||||
QString pathStr = node->data(Constants::IosBuildDir).toString();
|
||||
const QString cmakeGenerator = node->data(Constants::IosCmakeGenerator).toString();
|
||||
|
||||
if (cmakeGenerator.isEmpty()) {
|
||||
// qmake node gives absolute IosBuildDir
|
||||
res = FilePath::fromString(pathStr);
|
||||
} else {
|
||||
// CMake node gives IosBuildDir relative to root build directory
|
||||
if (cmakeGenerator.isEmpty()) {
|
||||
// qmake node gives absolute IosBuildDir
|
||||
res = FilePath::fromString(pathStr);
|
||||
} else {
|
||||
// CMake node gives IosBuildDir relative to root build directory
|
||||
|
||||
bool useCmakePath = true;
|
||||
bool useCmakePath = true;
|
||||
|
||||
if (pathStr.isEmpty())
|
||||
if (pathStr.isEmpty())
|
||||
useCmakePath = false;
|
||||
|
||||
if (useCmakePath && cmakeGenerator == "Xcode") {
|
||||
// When generating Xcode project, CMake may put a "${EFFECTIVE_PLATFORM_NAME}" macro,
|
||||
// which is expanded by Xcode at build time.
|
||||
// To get an actual executable path at configure time, replace this macro here
|
||||
// depending on the device type.
|
||||
|
||||
const QString before = "${EFFECTIVE_PLATFORM_NAME}";
|
||||
|
||||
int idx = pathStr.indexOf(before);
|
||||
|
||||
if (idx == -1) {
|
||||
useCmakePath = false;
|
||||
|
||||
if (useCmakePath && cmakeGenerator == "Xcode") {
|
||||
// When generating Xcode project, CMake may put a "${EFFECTIVE_PLATFORM_NAME}" macro,
|
||||
// which is expanded by Xcode at build time.
|
||||
// To get an actual executable path at configure time, replace this macro here
|
||||
// depending on the device type.
|
||||
|
||||
const QString before = "${EFFECTIVE_PLATFORM_NAME}";
|
||||
|
||||
int idx = pathStr.indexOf(before);
|
||||
|
||||
if (idx == -1) {
|
||||
useCmakePath = false;
|
||||
} else {
|
||||
QString after;
|
||||
if (isDevice)
|
||||
after = "-iphoneos";
|
||||
else
|
||||
after = "-iphonesimulator";
|
||||
|
||||
pathStr.replace(idx, before.length(), after);
|
||||
}
|
||||
}
|
||||
|
||||
if (useCmakePath) {
|
||||
// With Ninja generator IosBuildDir may be just "." when executable is in the root directory,
|
||||
// so use canonical path to ensure that redundand dot is removed.
|
||||
res = bc->buildDirectory().pathAppended(pathStr).canonicalPath();
|
||||
// All done with path provided by CMake
|
||||
shouldAppendBuildTypeAndPlatform = false;
|
||||
} else {
|
||||
res = bc->buildDirectory();
|
||||
QString after;
|
||||
if (isDevice)
|
||||
after = "-iphoneos";
|
||||
else
|
||||
after = "-iphonesimulator";
|
||||
|
||||
pathStr.replace(idx, before.length(), after);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (res.isEmpty()) {
|
||||
// Fallback
|
||||
res = bc->buildDirectory();
|
||||
shouldAppendBuildTypeAndPlatform = true;
|
||||
}
|
||||
|
||||
if (shouldAppendBuildTypeAndPlatform) {
|
||||
switch (bc->buildType()) {
|
||||
case BuildConfiguration::Debug :
|
||||
case BuildConfiguration::Unknown :
|
||||
if (isDevice)
|
||||
res = res / "Debug-iphoneos";
|
||||
else
|
||||
res = res.pathAppended("Debug-iphonesimulator");
|
||||
break;
|
||||
case BuildConfiguration::Profile :
|
||||
case BuildConfiguration::Release :
|
||||
if (isDevice)
|
||||
res = res.pathAppended("Release-iphoneos");
|
||||
else
|
||||
res = res.pathAppended("Release-iphonesimulator");
|
||||
break;
|
||||
default:
|
||||
qCWarning(iosLog) << "IosBuildStep had an unknown buildType "
|
||||
<< target()->activeBuildConfiguration()->buildType();
|
||||
if (useCmakePath) {
|
||||
// With Ninja generator IosBuildDir may be just "." when executable is in the root directory,
|
||||
// so use canonical path to ensure that redundand dot is removed.
|
||||
res = buildConfiguration()->buildDirectory().pathAppended(pathStr).canonicalPath();
|
||||
// All done with path provided by CMake
|
||||
shouldAppendBuildTypeAndPlatform = false;
|
||||
} else {
|
||||
res = buildConfiguration()->buildDirectory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (res.isEmpty()) {
|
||||
// Fallback
|
||||
res = buildConfiguration()->buildDirectory();
|
||||
shouldAppendBuildTypeAndPlatform = true;
|
||||
}
|
||||
|
||||
if (shouldAppendBuildTypeAndPlatform) {
|
||||
switch (buildConfiguration()->buildType()) {
|
||||
case BuildConfiguration::Debug :
|
||||
case BuildConfiguration::Unknown :
|
||||
if (isDevice)
|
||||
res = res / "Debug-iphoneos";
|
||||
else
|
||||
res = res.pathAppended("Debug-iphonesimulator");
|
||||
break;
|
||||
case BuildConfiguration::Profile :
|
||||
case BuildConfiguration::Release :
|
||||
if (isDevice)
|
||||
res = res.pathAppended("Release-iphoneos");
|
||||
else
|
||||
res = res.pathAppended("Release-iphonesimulator");
|
||||
break;
|
||||
default:
|
||||
qCWarning(iosLog) << "IosBuildStep had an unknown buildType "
|
||||
<< buildConfiguration()->buildType();
|
||||
}
|
||||
}
|
||||
return res.pathAppended(applicationName() + ".app");
|
||||
}
|
||||
|
||||
|
@@ -22,10 +22,9 @@ using namespace Utils;
|
||||
|
||||
namespace McuSupport::Internal {
|
||||
|
||||
static FilePath cmakeFilePath(const Target *target)
|
||||
static FilePath cmakeFilePath(const Kit *k)
|
||||
{
|
||||
const CMakeProjectManager::CMakeTool *tool = CMakeProjectManager::CMakeKitAspect::cmakeTool(
|
||||
target->kit());
|
||||
const CMakeProjectManager::CMakeTool *tool = CMakeProjectManager::CMakeKitAspect::cmakeTool(k);
|
||||
return tool->filePath();
|
||||
}
|
||||
|
||||
@@ -83,7 +82,7 @@ FlashRunWorkerFactory::FlashRunWorkerFactory()
|
||||
auto worker = new ProcessRunner(runControl);
|
||||
worker->setStartModifier([worker, runControl] {
|
||||
const BuildConfiguration *bc = runControl->buildConfiguration();
|
||||
worker->setCommandLine({cmakeFilePath(bc->target()),
|
||||
worker->setCommandLine({cmakeFilePath(bc->kit()),
|
||||
runControl->aspectData<StringAspect>()->value, CommandLine::Raw});
|
||||
worker->setWorkingDirectory(bc->buildDirectory());
|
||||
worker->setEnvironment(bc->environment());
|
||||
|
@@ -569,8 +569,8 @@ BuildForRunConfigStatus BuildManager::potentiallyBuildForRunConfig(RunConfigurat
|
||||
if (!isBuilding()) {
|
||||
switch (projectExplorerSettings().buildBeforeDeploy) {
|
||||
case BuildBeforeRunMode::AppOnly:
|
||||
if (rc->target()->activeBuildConfiguration())
|
||||
rc->target()->activeBuildConfiguration()->restrictNextBuild(rc);
|
||||
if (rc->buildConfiguration())
|
||||
rc->buildConfiguration()->restrictNextBuild(rc);
|
||||
Q_FALLTHROUGH();
|
||||
case BuildBeforeRunMode::WholeProject:
|
||||
stepIds << Id(Constants::BUILDSTEPS_BUILD);
|
||||
@@ -586,8 +586,8 @@ BuildForRunConfigStatus BuildManager::potentiallyBuildForRunConfig(RunConfigurat
|
||||
Project * const pro = rc->project();
|
||||
const int queueCount = queue(projectWithDependencies(pro, stepIds),
|
||||
ConfigSelection::Active, rc);
|
||||
if (rc->target()->activeBuildConfiguration())
|
||||
rc->target()->activeBuildConfiguration()->restrictNextBuild(nullptr);
|
||||
if (rc->buildConfiguration())
|
||||
rc->buildConfiguration()->restrictNextBuild(nullptr);
|
||||
|
||||
if (queueCount < 0)
|
||||
return BuildForRunConfigStatus::BuildFailed;
|
||||
|
@@ -173,8 +173,9 @@ Environment BuildStep::buildEnvironment() const
|
||||
{
|
||||
if (const auto bc = qobject_cast<BuildConfiguration *>(projectConfiguration()))
|
||||
return bc->environment();
|
||||
if (const auto bc = target()->activeBuildConfiguration())
|
||||
return bc->environment();
|
||||
if (const auto dc = qobject_cast<DeployConfiguration *>(projectConfiguration()))
|
||||
return dc->buildConfiguration()->environment();
|
||||
QTC_CHECK(false);
|
||||
return Environment::systemEnvironment();
|
||||
}
|
||||
|
||||
|
@@ -3818,7 +3818,7 @@ void ProjectExplorerPluginPrivate::openTerminalHereWithRunEnv()
|
||||
const ProcessRunData runnable = runConfig->runnable();
|
||||
IDevice::ConstPtr device = DeviceManager::deviceForPath(runnable.command.executable());
|
||||
if (!device)
|
||||
device = RunDeviceKitAspect::device(bc->target()->kit());
|
||||
device = RunDeviceKitAspect::device(bc->kit());
|
||||
QTC_ASSERT(device && device->canOpenTerminal(), return);
|
||||
|
||||
FilePath workingDir = device->type() == Constants::DESKTOP_DEVICE_TYPE
|
||||
|
@@ -50,7 +50,7 @@ QbsInstallStep::QbsInstallStep(BuildStepList *bsl, Id id)
|
||||
|
||||
bool QbsInstallStep::init()
|
||||
{
|
||||
QTC_ASSERT(!target()->buildSystem()->isParsing(), return false);
|
||||
QTC_ASSERT(!buildSystem()->isParsing(), return false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ FilePath QbsInstallStep::installRoot() const
|
||||
|
||||
const QbsBuildConfiguration *QbsInstallStep::buildConfig() const
|
||||
{
|
||||
return static_cast<QbsBuildConfiguration *>(target()->activeBuildConfiguration());
|
||||
return static_cast<QbsBuildConfiguration *>(buildConfiguration());
|
||||
}
|
||||
|
||||
QWidget *QbsInstallStep::createConfigWidget()
|
||||
|
@@ -108,7 +108,7 @@ void QmlPreviewRunner::start()
|
||||
{
|
||||
if (m_translationUpdater)
|
||||
m_translationUpdater->start();
|
||||
m_connectionManager.setTarget(runControl()->buildConfiguration()->target());
|
||||
m_connectionManager.setTarget(runControl()->target());
|
||||
m_connectionManager.connectToServer(runControl()->qmlChannel());
|
||||
reportStarted();
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ void AppManagerDeployConfigurationAutoSwitcher::onActiveDeployConfigurationChang
|
||||
{
|
||||
if (m_deployConfiguration != deployConfiguration) {
|
||||
m_deployConfiguration = deployConfiguration;
|
||||
if (deployConfiguration && deployConfiguration->target()) {
|
||||
if (deployConfiguration) {
|
||||
if (auto runConfiguration = deployConfiguration->buildConfiguration()->activeRunConfiguration()) {
|
||||
m_deployConfigurationsUsageHistory.insert(runConfiguration, deployConfiguration);
|
||||
}
|
||||
|
Reference in New Issue
Block a user