2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2020 Alexis Jeandet.
|
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
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
#include "mesonrunconfiguration.h"
|
2020-10-29 10:20:14 +01:00
|
|
|
|
|
|
|
|
#include "mesonpluginconstants.h"
|
|
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
#include <projectexplorer/buildsystem.h>
|
|
|
|
|
#include <projectexplorer/desktoprunconfiguration.h>
|
|
|
|
|
#include <projectexplorer/environmentaspect.h>
|
2022-06-22 15:43:33 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2020-05-01 18:20:56 +02:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2022-06-22 15:43:33 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
#include <utils/environment.h>
|
|
|
|
|
#include <utils/hostosinfo.h>
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2022-05-31 18:22:07 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
namespace MesonProjectManager {
|
|
|
|
|
namespace Internal {
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2022-05-31 18:22:07 +02:00
|
|
|
MesonRunConfiguration::MesonRunConfiguration(Target *target, Utils::Id id)
|
|
|
|
|
: RunConfiguration{target, id}
|
2020-05-01 18:20:56 +02:00
|
|
|
{
|
2023-05-25 08:58:36 +02:00
|
|
|
auto envAspect = addAspect<EnvironmentAspect>();
|
|
|
|
|
envAspect->setSupportForBuildEnvironment(target);
|
2020-05-01 18:20:56 +02:00
|
|
|
|
2022-05-31 18:22:07 +02:00
|
|
|
addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
|
|
|
|
|
addAspect<ArgumentsAspect>(macroExpander());
|
|
|
|
|
addAspect<WorkingDirectoryAspect>(macroExpander(), envAspect);
|
|
|
|
|
addAspect<TerminalAspect>();
|
2020-05-01 18:20:56 +02:00
|
|
|
|
2022-05-31 18:22:07 +02:00
|
|
|
auto libAspect = addAspect<UseLibraryPathsAspect>();
|
|
|
|
|
connect(libAspect, &UseLibraryPathsAspect::changed,
|
|
|
|
|
envAspect, &EnvironmentAspect::environmentChanged);
|
2020-05-01 18:20:56 +02:00
|
|
|
|
|
|
|
|
if (Utils::HostOsInfo::isMacHost()) {
|
2022-05-31 18:22:07 +02:00
|
|
|
auto dyldAspect = addAspect<UseDyldSuffixAspect>();
|
|
|
|
|
connect(dyldAspect, &UseLibraryPathsAspect::changed,
|
|
|
|
|
envAspect, &EnvironmentAspect::environmentChanged);
|
2020-05-01 18:20:56 +02:00
|
|
|
envAspect->addModifier([dyldAspect](Utils::Environment &env) {
|
|
|
|
|
if (dyldAspect->value())
|
|
|
|
|
env.set(QLatin1String("DYLD_IMAGE_SUFFIX"), QLatin1String("_debug"));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
envAspect->addModifier([this, libAspect](Utils::Environment &env) {
|
2022-05-31 18:22:07 +02:00
|
|
|
BuildTargetInfo bti = buildTargetInfo();
|
2020-05-01 18:20:56 +02:00
|
|
|
if (bti.runEnvModifier)
|
|
|
|
|
bti.runEnvModifier(env, libAspect->value());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setUpdater([this] { updateTargetInformation(); });
|
|
|
|
|
|
2022-05-31 18:22:07 +02:00
|
|
|
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);
|
2020-05-01 18:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MesonRunConfiguration::updateTargetInformation()
|
|
|
|
|
{
|
|
|
|
|
if (!activeBuildSystem())
|
|
|
|
|
return;
|
|
|
|
|
|
2022-05-31 18:22:07 +02:00
|
|
|
BuildTargetInfo bti = buildTargetInfo();
|
|
|
|
|
aspect<TerminalAspect>()->setUseTerminalHint(bti.usesTerminal);
|
|
|
|
|
aspect<ExecutableAspect>()->setExecutable(bti.targetFilePath);
|
|
|
|
|
aspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(bti.workingDirectory);
|
2023-05-25 08:58:36 +02:00
|
|
|
emit aspect<EnvironmentAspect>()->environmentChanged();
|
2020-05-01 18:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MesonRunConfigurationFactory::MesonRunConfigurationFactory()
|
|
|
|
|
{
|
|
|
|
|
registerRunConfiguration<MesonRunConfiguration>("MesonProjectManager.MesonRunConfiguration");
|
|
|
|
|
addSupportedProjectType(Constants::Project::ID);
|
|
|
|
|
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace MesonProjectManager
|