aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/python/pythonbuildconfiguration.h
blob: 71d950c03414f3b88c870698f7712d55564d11d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "pythonbuildsystem.h"

#include <projectexplorer/abstractprocessstep.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildstep.h>


namespace ProjectExplorer { class Interpreter; }
namespace Python::Internal {

class PipPackageInfo;
class PySideUicExtraCompiler;

class PySideBuildStep : public ProjectExplorer::AbstractProcessStep
{
    Q_OBJECT
public:
    PySideBuildStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id);
    ~PySideBuildStep();

    void checkForPySide(const Utils::FilePath &python);

    QList<PySideUicExtraCompiler *> extraCompilers() const;

    static Utils::Id id();

private:
    void checkForPySide(const Utils::FilePath &python, const QString &pySidePackageName);
    void handlePySidePackageInfo(const PipPackageInfo &pySideInfo,
                                 const Utils::FilePath &python,
                                 const QString &requestedPackageName);

    Tasking::GroupItem runRecipe() final;
    void updateExtraCompilers();

    std::unique_ptr<QFutureWatcher<PipPackageInfo>> m_watcher;
    QMetaObject::Connection m_watcherConnection;

    Utils::FilePathAspect m_pysideProject{this};
    Utils::FilePathAspect m_pysideUic{this};
    QList<PySideUicExtraCompiler *> m_extraCompilers;
};

class PythonBuildConfiguration : public ProjectExplorer::BuildConfiguration
{
    Q_OBJECT
public:
    PythonBuildConfiguration(ProjectExplorer::Target *target, const Utils::Id &id);

    QWidget *createConfigWidget() override;
    void fromMap(const Utils::Store &map) override;
    void toMap(Utils::Store &map) const override;

    Utils::FilePath python() const;
    std::optional<Utils::FilePath> venv() const;

private:
    void initialize(const ProjectExplorer::BuildInfo &info);
    void updateInterpreter(const std::optional<ProjectExplorer::Interpreter> &python);
    void updatePython(const Utils::FilePath &python);
    void updateDocuments();
    void handlePythonUpdated(const Utils::FilePath &python);

    Utils::FilePath m_python;
    std::optional<Utils::FilePath> m_venv;
};

void setupPySideBuildStep();
void setupPythonBuildConfiguration();

} // namespace Python::Internal