forked from qt-creator/qt-creator
Python: Use setup function for build related factories
Change-Id: I3b1faad8a5f3ead1332941d31509c3efd3806f78 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -44,14 +44,6 @@ using namespace Utils;
|
||||
|
||||
namespace Python::Internal {
|
||||
|
||||
PySideBuildStepFactory::PySideBuildStepFactory()
|
||||
{
|
||||
registerStep<PySideBuildStep>(PySideBuildStep::id());
|
||||
setSupportedProjectType(PythonProjectId);
|
||||
setDisplayName(Tr::tr("Run PySide6 project tool"));
|
||||
setFlags(BuildStep::UniqueStep);
|
||||
}
|
||||
|
||||
PySideBuildStep::PySideBuildStep(BuildStepList *bsl, Id id)
|
||||
: AbstractProcessStep(bsl, id)
|
||||
{
|
||||
@@ -245,6 +237,25 @@ private:
|
||||
DetailsWidget *m_configureDetailsWidget;
|
||||
};
|
||||
|
||||
class PySideBuildStepFactory final : public BuildStepFactory
|
||||
{
|
||||
public:
|
||||
PySideBuildStepFactory()
|
||||
{
|
||||
registerStep<PySideBuildStep>(PySideBuildStep::id());
|
||||
setSupportedProjectType(PythonProjectId);
|
||||
setDisplayName(Tr::tr("Run PySide6 project tool"));
|
||||
setFlags(BuildStep::UniqueStep);
|
||||
}
|
||||
};
|
||||
|
||||
void setupPySideBuildStep()
|
||||
{
|
||||
static PySideBuildStepFactory thePySideBuildStepFactory;
|
||||
}
|
||||
|
||||
// PythonBuildConfiguration
|
||||
|
||||
PythonBuildConfiguration::PythonBuildConfiguration(Target *target, const Id &id)
|
||||
: BuildConfiguration(target, id)
|
||||
, m_buildSystem(std::make_unique<PythonBuildSystem>(this))
|
||||
@@ -378,38 +389,47 @@ std::optional<FilePath> PythonBuildConfiguration::venv() const
|
||||
return m_venv;
|
||||
}
|
||||
|
||||
PythonBuildConfigurationFactory::PythonBuildConfigurationFactory()
|
||||
class PythonBuildConfigurationFactory final : public BuildConfigurationFactory
|
||||
{
|
||||
registerBuildConfiguration<PythonBuildConfiguration>("Python.PySideBuildConfiguration");
|
||||
setSupportedProjectType(PythonProjectId);
|
||||
setSupportedProjectMimeTypeName(Constants::C_PY_PROJECT_MIME_TYPE);
|
||||
setBuildGenerator([](const Kit *k, const FilePath &projectPath, bool forSetup) {
|
||||
if (std::optional<Interpreter> python = PythonKitAspect::python(k)) {
|
||||
BuildInfo base;
|
||||
base.buildDirectory = projectPath.parentDir();
|
||||
base.displayName = python->name;
|
||||
base.typeName = Tr::tr("Global Python");
|
||||
base.showBuildDirConfigWidget = false;
|
||||
public:
|
||||
PythonBuildConfigurationFactory()
|
||||
{
|
||||
registerBuildConfiguration<PythonBuildConfiguration>("Python.PySideBuildConfiguration");
|
||||
setSupportedProjectType(PythonProjectId);
|
||||
setSupportedProjectMimeTypeName(Constants::C_PY_PROJECT_MIME_TYPE);
|
||||
setBuildGenerator([](const Kit *k, const FilePath &projectPath, bool forSetup) {
|
||||
if (std::optional<Interpreter> python = PythonKitAspect::python(k)) {
|
||||
BuildInfo base;
|
||||
base.buildDirectory = projectPath.parentDir();
|
||||
base.displayName = python->name;
|
||||
base.typeName = Tr::tr("Global Python");
|
||||
base.showBuildDirConfigWidget = false;
|
||||
|
||||
if (isVenvPython(python->command) || !venvIsUsable(python->command))
|
||||
return QList<BuildInfo>{base};
|
||||
if (isVenvPython(python->command) || !venvIsUsable(python->command))
|
||||
return QList<BuildInfo>{base};
|
||||
|
||||
base.enabledByDefault = false;
|
||||
base.enabledByDefault = false;
|
||||
|
||||
BuildInfo venv;
|
||||
const FilePath venvBase = projectPath.parentDir() / ".qtcreator"
|
||||
/ FileUtils::fileSystemFriendlyName(python->name + "venv");
|
||||
venv.buildDirectory = venvBase;
|
||||
int i = 2;
|
||||
while (venv.buildDirectory.exists())
|
||||
venv.buildDirectory = venvBase.stringAppended('_' + QString::number(i++));
|
||||
venv.displayName = python->name + Tr::tr(" Virtual Environment");
|
||||
venv.typeName = venvTypeName();
|
||||
venv.extraInfo = QVariantMap{{"createVenv", forSetup}};
|
||||
return QList<BuildInfo>{base, venv};
|
||||
}
|
||||
return QList<BuildInfo>{};
|
||||
});
|
||||
BuildInfo venv;
|
||||
const FilePath venvBase = projectPath.parentDir() / ".qtcreator"
|
||||
/ FileUtils::fileSystemFriendlyName(python->name + "venv");
|
||||
venv.buildDirectory = venvBase;
|
||||
int i = 2;
|
||||
while (venv.buildDirectory.exists())
|
||||
venv.buildDirectory = venvBase.stringAppended('_' + QString::number(i++));
|
||||
venv.displayName = python->name + Tr::tr(" Virtual Environment");
|
||||
venv.typeName = venvTypeName();
|
||||
venv.extraInfo = QVariantMap{{"createVenv", forSetup}};
|
||||
return QList<BuildInfo>{base, venv};
|
||||
}
|
||||
return QList<BuildInfo>{};
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
void setupPythonBuildConfiguration()
|
||||
{
|
||||
static PythonBuildConfigurationFactory thePythonBuildConfigurationFactory;
|
||||
}
|
||||
|
||||
} // Python::Internal
|
||||
|
@@ -46,12 +46,6 @@ private:
|
||||
QList<PySideUicExtraCompiler *> m_extraCompilers;
|
||||
};
|
||||
|
||||
class PySideBuildStepFactory : public ProjectExplorer::BuildStepFactory
|
||||
{
|
||||
public:
|
||||
PySideBuildStepFactory();
|
||||
};
|
||||
|
||||
class PythonBuildConfiguration : public ProjectExplorer::BuildConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -77,10 +71,7 @@ private:
|
||||
std::unique_ptr<PythonBuildSystem> m_buildSystem;
|
||||
};
|
||||
|
||||
class PythonBuildConfigurationFactory : public ProjectExplorer::BuildConfigurationFactory
|
||||
{
|
||||
public:
|
||||
PythonBuildConfigurationFactory();
|
||||
};
|
||||
void setupPySideBuildStep();
|
||||
void setupPythonBuildConfiguration();
|
||||
|
||||
} // namespace Python::Internal
|
||||
|
@@ -44,8 +44,6 @@ class PythonPluginPrivate
|
||||
{
|
||||
public:
|
||||
PythonRunConfigurationFactory runConfigFactory;
|
||||
PySideBuildStepFactory buildStepFactory;
|
||||
PythonBuildConfigurationFactory buildConfigFactory;
|
||||
SimpleTargetRunnerFactory runWorkerFactory{{runConfigFactory.runConfigurationId()}};
|
||||
SimpleDebugRunnerFactory debugRunWorkerFactory{{runConfigFactory.runConfigurationId()}, {ProjectExplorer::Constants::DAP_PY_DEBUG_RUN_MODE}};
|
||||
PythonSettings settings;
|
||||
@@ -76,6 +74,9 @@ private:
|
||||
|
||||
setupPythonEditorFactory(this);
|
||||
|
||||
setupPySideBuildStep();
|
||||
setupPythonBuildConfiguration();
|
||||
|
||||
setupPythonOutputParser();
|
||||
|
||||
KitManager::setIrrelevantAspects(KitManager::irrelevantAspects()
|
||||
|
Reference in New Issue
Block a user