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