Files
qt-creator/src/plugins/python/pythonproject.cpp
David Schulz c0a3565362 Python: Create a default BuildSystem for Python targets
This makes sure the project can be parsed even if we do not have a valid
build configuration for that target.

Amends 09e94ae4ac

Change-Id: I92214474f581af228bd5c2aaf2f3e4b620ffc9d5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-12-01 07:01:10 +00:00

61 lines
1.6 KiB
C++

// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "pythonproject.h"
#include "pythonbuildsystem.h"
#include "pythonconstants.h"
#include <coreplugin/icontext.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
using namespace Core;
using namespace ProjectExplorer;
using namespace Utils;
namespace Python::Internal {
PythonProject::PythonProject(const FilePath &fileName)
: Project(Constants::C_PY_PROJECT_MIME_TYPE, fileName)
{
setId(PythonProjectId);
setProjectLanguages(Context(ProjectExplorer::Constants::PYTHON_LANGUAGE_ID));
setDisplayName(fileName.completeBaseName());
setBuildSystemCreator([](Target *t) { return new PythonBuildSystem(t); });
}
Project::RestoreResult PythonProject::fromMap(const Store &map, QString *errorMessage)
{
Project::RestoreResult res = Project::fromMap(map, errorMessage);
if (res == RestoreResult::Ok) {
if (!activeTarget())
addTargetForDefaultKit();
}
return res;
}
PythonProjectNode::PythonProjectNode(const FilePath &path)
: ProjectNode(path)
{
setDisplayName(path.completeBaseName());
setAddFileFilter("*.py");
}
PythonFileNode::PythonFileNode(const FilePath &filePath,
const QString &nodeDisplayName,
FileType fileType)
: FileNode(filePath, fileType)
, m_displayName(nodeDisplayName)
{}
QString PythonFileNode::displayName() const
{
return m_displayName;
}
} // Python::Internal