// Copyright (C) 2020 Alexis Jeandet. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "mesonrunconfiguration.h" #include "mesonpluginconstants.h" #include #include #include #include #include using namespace ProjectExplorer; using namespace Utils; namespace MesonProjectManager::Internal { class MesonRunConfiguration final : public RunConfiguration { public: MesonRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) { auto envAspect = addAspect(); envAspect->setSupportForBuildEnvironment(target); auto exeAspect = addAspect(); exeAspect->setDeviceSelector(target, ExecutableAspect::RunDevice); auto argsAspect = addAspect(); argsAspect->setMacroExpander(macroExpander()); auto workingDirAspect = addAspect(); workingDirAspect->setMacroExpander(macroExpander()); workingDirAspect->setEnvironment(envAspect); addAspect(); auto libAspect = addAspect(); connect(libAspect, &UseLibraryPathsAspect::changed, envAspect, &EnvironmentAspect::environmentChanged); if (HostOsInfo::isMacHost()) { auto dyldAspect = addAspect(); connect(dyldAspect, &UseLibraryPathsAspect::changed, envAspect, &EnvironmentAspect::environmentChanged); envAspect->addModifier([dyldAspect](Utils::Environment &env) { if (dyldAspect->value()) env.set(QLatin1String("DYLD_IMAGE_SUFFIX"), QLatin1String("_debug")); }); } envAspect->addModifier([this, libAspect](Environment &env) { BuildTargetInfo bti = buildTargetInfo(); if (bti.runEnvModifier) bti.runEnvModifier(env, libAspect->value()); }); setUpdater([this] { if (!activeBuildSystem()) return; BuildTargetInfo bti = buildTargetInfo(); aspect()->setUseTerminalHint(bti.usesTerminal); aspect()->setExecutable(bti.targetFilePath); aspect()->setDefaultWorkingDirectory(bti.workingDirectory); emit aspect()->environmentChanged(); }); connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update); } }; MesonRunConfigurationFactory::MesonRunConfigurationFactory() { registerRunConfiguration("MesonProjectManager.MesonRunConfiguration"); addSupportedProjectType(Constants::Project::ID); addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE); } } // MesonProjectManager::Internal