aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp
blob: ea522606e4cb9116a7712ca120d8c4ed63e2be86 (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
77
78
79
80
81
82
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "genericbuildconfiguration.h"

#include "genericproject.h"
#include "genericprojectconstants.h"
#include "genericprojectmanagertr.h"

#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildinfo.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorertr.h>

#include <qtsupport/qtkitaspect.h>

#include <utils/aspects.h>
#include <utils/qtcassert.h>

using namespace ProjectExplorer;
using namespace Utils;

namespace GenericProjectManager::Internal {

class GenericBuildConfiguration final : public BuildConfiguration
{
public:
    GenericBuildConfiguration(Target *target, Id id)
        : BuildConfiguration(target, id)
    {
        setConfigWidgetDisplayName(GenericProjectManager::Tr::tr("Generic Manager"));
        setBuildDirectoryHistoryCompleter("Generic.BuildDir.History");

        setInitializer([this](const BuildInfo &) {
            buildSteps()->appendStep(Constants::GENERIC_MS_ID);
            cleanSteps()->appendStep(Constants::GENERIC_MS_ID);
            updateCacheAndEmitEnvironmentChanged();
        });

        updateCacheAndEmitEnvironmentChanged();
    }

    void addToEnvironment(Environment &env) const final
    {
        QtSupport::QtKitAspect::addHostBinariesToPath(kit(), env);
    }
};

class GenericBuildConfigurationFactory final : public BuildConfigurationFactory
{
public:
    GenericBuildConfigurationFactory()
    {
        registerBuildConfiguration<GenericBuildConfiguration>
            ("GenericProjectManager.GenericBuildConfiguration");

        setSupportedProjectType(Constants::GENERICPROJECT_ID);
        setSupportedProjectMimeTypeName(Constants::GENERICMIMETYPE);

        setBuildGenerator([](const Kit *, const FilePath &projectPath, bool forSetup) {
            BuildInfo info;
            info.typeName = ProjectExplorer::Tr::tr("Build");
            info.buildDirectory = forSetup ? projectPath.absolutePath() : projectPath;

            if (forSetup)  {
                //: The name of the build configuration created by default for a generic project.
                info.displayName = ProjectExplorer::Tr::tr("Default");
            }

            return QList<BuildInfo>{info};
        });
    }
};

void setupGenericBuildConfiguration()
{
    static GenericBuildConfigurationFactory theGenericBuildConfigurationFactory;
}

} // GenericProjectManager::Internal