2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2022 The Qt Company Ltd.
|
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
|
2022-03-30 14:42:33 +02:00
|
|
|
|
|
|
|
|
#include "pysidebuildconfiguration.h"
|
|
|
|
|
|
|
|
|
|
#include "pythonconstants.h"
|
|
|
|
|
#include "pythonproject.h"
|
2022-07-15 11:49:34 +02:00
|
|
|
#include "pythontr.h"
|
2022-03-30 14:42:33 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/buildinfo.h>
|
|
|
|
|
#include <projectexplorer/buildsteplist.h>
|
|
|
|
|
#include <projectexplorer/environmentaspect.h>
|
|
|
|
|
#include <projectexplorer/processparameters.h>
|
|
|
|
|
#include <projectexplorer/runconfiguration.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
2022-07-15 11:49:34 +02:00
|
|
|
|
2022-03-30 14:42:33 +02:00
|
|
|
#include <utils/commandline.h>
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
2022-07-15 11:49:34 +02:00
|
|
|
namespace Python::Internal {
|
2022-03-30 14:42:33 +02:00
|
|
|
|
2022-07-15 11:49:34 +02:00
|
|
|
const char pySideBuildStep[] = "Python.PysideBuildStep";
|
2022-03-30 14:42:33 +02:00
|
|
|
|
|
|
|
|
PySideBuildStepFactory::PySideBuildStepFactory()
|
|
|
|
|
{
|
|
|
|
|
registerStep<PySideBuildStep>(pySideBuildStep);
|
|
|
|
|
setSupportedProjectType(PythonProjectId);
|
2022-07-15 11:49:34 +02:00
|
|
|
setDisplayName(Tr::tr("Run PySide6 project tool"));
|
2023-03-28 09:37:02 +02:00
|
|
|
setFlags(BuildStep::UniqueStep);
|
2022-03-30 14:42:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PySideBuildStep::PySideBuildStep(BuildStepList *bsl, Id id)
|
|
|
|
|
: AbstractProcessStep(bsl, id)
|
|
|
|
|
{
|
2023-05-23 16:54:11 +02:00
|
|
|
m_pysideProject.setSettingsKey("Python.PySideProjectTool");
|
|
|
|
|
m_pysideProject.setLabelText(Tr::tr("PySide project tool:"));
|
|
|
|
|
m_pysideProject.setToolTip(Tr::tr("Enter location of PySide project tool."));
|
|
|
|
|
m_pysideProject.setExpectedKind(PathChooser::Command);
|
|
|
|
|
m_pysideProject.setHistoryCompleter("Python.PySideProjectTool.History");
|
|
|
|
|
|
|
|
|
|
const FilePath pySideProjectPath = FilePath("pyside6-project").searchInPath();
|
2022-03-30 14:42:33 +02:00
|
|
|
if (pySideProjectPath.isExecutableFile())
|
2023-06-29 17:18:26 +02:00
|
|
|
m_pysideProject.setValue(pySideProjectPath);
|
2022-03-30 14:42:33 +02:00
|
|
|
|
2023-05-23 16:54:11 +02:00
|
|
|
setCommandLineProvider([this] { return CommandLine(m_pysideProject(), {"build"}); });
|
2022-10-18 13:55:39 +02:00
|
|
|
setWorkingDirectoryProvider([this] {
|
2023-05-23 16:54:11 +02:00
|
|
|
return m_pysideProject().withNewMappedPath(project()->projectDirectory()); // FIXME: new path needed?
|
2022-10-18 13:55:39 +02:00
|
|
|
});
|
2022-07-07 08:40:05 +02:00
|
|
|
setEnvironmentModifier([this](Environment &env) {
|
2023-05-23 16:54:11 +02:00
|
|
|
env.prependOrSetPath(m_pysideProject().parentDir());
|
2022-07-07 08:40:05 +02:00
|
|
|
});
|
2022-03-30 14:42:33 +02:00
|
|
|
}
|
|
|
|
|
|
2023-05-23 16:54:11 +02:00
|
|
|
void PySideBuildStep::updatePySideProjectPath(const FilePath &pySideProjectPath)
|
2022-03-30 14:42:33 +02:00
|
|
|
{
|
2023-06-29 17:18:26 +02:00
|
|
|
m_pysideProject.setValue(pySideProjectPath);
|
2022-03-30 14:42:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PySideBuildStep::doRun()
|
|
|
|
|
{
|
|
|
|
|
if (processParameters()->effectiveCommand().isExecutableFile())
|
|
|
|
|
AbstractProcessStep::doRun();
|
|
|
|
|
else
|
|
|
|
|
emit finished(true);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-23 16:47:28 +02:00
|
|
|
|
|
|
|
|
// PySideBuildConfiguration
|
|
|
|
|
|
|
|
|
|
class PySideBuildConfiguration : public BuildConfiguration
|
2022-03-30 14:42:33 +02:00
|
|
|
{
|
2023-05-23 16:47:28 +02:00
|
|
|
public:
|
|
|
|
|
PySideBuildConfiguration(Target *target, Id id)
|
|
|
|
|
: BuildConfiguration(target, id)
|
|
|
|
|
{
|
|
|
|
|
setConfigWidgetDisplayName(Tr::tr("General"));
|
|
|
|
|
|
|
|
|
|
setInitializer([this](const BuildInfo &) {
|
|
|
|
|
buildSteps()->appendStep(pySideBuildStep);
|
|
|
|
|
updateCacheAndEmitEnvironmentChanged();
|
|
|
|
|
});
|
2022-03-30 14:42:33 +02:00
|
|
|
|
|
|
|
|
updateCacheAndEmitEnvironmentChanged();
|
2023-05-23 16:47:28 +02:00
|
|
|
}
|
|
|
|
|
};
|
2022-03-30 14:42:33 +02:00
|
|
|
|
2023-05-23 16:47:28 +02:00
|
|
|
PySideBuildConfigurationFactory::PySideBuildConfigurationFactory()
|
|
|
|
|
{
|
|
|
|
|
registerBuildConfiguration<PySideBuildConfiguration>("Python.PySideBuildConfiguration");
|
|
|
|
|
setSupportedProjectType(PythonProjectId);
|
|
|
|
|
setSupportedProjectMimeTypeName(Constants::C_PY_MIMETYPE);
|
|
|
|
|
setBuildGenerator([](const Kit *, const FilePath &projectPath, bool) {
|
|
|
|
|
BuildInfo info;
|
|
|
|
|
info.displayName = "build";
|
|
|
|
|
info.typeName = "build";
|
|
|
|
|
info.buildDirectory = projectPath.parentDir();
|
|
|
|
|
return QList<BuildInfo>{info};
|
|
|
|
|
});
|
2022-03-30 14:42:33 +02:00
|
|
|
}
|
|
|
|
|
|
2022-07-15 11:49:34 +02:00
|
|
|
} // Python::Internal
|