diff options
Diffstat (limited to 'src/lib/msbuild')
55 files changed, 3858 insertions, 0 deletions
diff --git a/src/lib/msbuild/io/msbuildprojectwriter.cpp b/src/lib/msbuild/io/msbuildprojectwriter.cpp new file mode 100644 index 000000000..12fbe2da5 --- /dev/null +++ b/src/lib/msbuild/io/msbuildprojectwriter.cpp @@ -0,0 +1,238 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildprojectwriter.h" + +#include "../msbuild/imsbuildnodevisitor.h" +#include "../msbuild/msbuildimport.h" +#include "../msbuild/msbuildimportgroup.h" +#include "../msbuild/msbuilditem.h" +#include "../msbuild/msbuilditemdefinitiongroup.h" +#include "../msbuild/msbuilditemgroup.h" +#include "../msbuild/msbuilditemmetadata.h" +#include "../msbuild/msbuildproject.h" +#include "../msbuild/msbuildproperty.h" +#include "../msbuild/msbuildpropertygroup.h" + +#include <QtCore/qxmlstream.h> + +#include <memory> + +namespace qbs { + +static const QString kMSBuildSchemaURI = + QStringLiteral("http://schemas.microsoft.com/developer/msbuild/2003"); + +class MSBuildProjectWriterPrivate : public IMSBuildNodeVisitor +{ +public: + std::ostream *device = nullptr; + QByteArray buffer; + std::unique_ptr<QXmlStreamWriter> writer; + + void visitStart(const MSBuildImport *import) override; + void visitEnd(const MSBuildImport *import) override; + + void visitStart(const MSBuildImportGroup *importGroup) override; + void visitEnd(const MSBuildImportGroup *importGroup) override; + + void visitStart(const MSBuildItem *item) override; + void visitEnd(const MSBuildItem *item) override; + + void visitStart(const MSBuildItemDefinitionGroup *itemDefinitionGroup) override; + void visitEnd(const MSBuildItemDefinitionGroup *itemDefinitionGroup) override; + + void visitStart(const MSBuildItemGroup *itemGroup) override; + void visitEnd(const MSBuildItemGroup *itemGroup) override; + + void visitStart(const MSBuildItemMetadata *itemMetadata) override; + void visitEnd(const MSBuildItemMetadata *itemMetadata) override; + + void visitStart(const MSBuildProject *project) override; + void visitEnd(const MSBuildProject *project) override; + + void visitStart(const MSBuildProperty *property) override; + void visitEnd(const MSBuildProperty *property) override; + + void visitStart(const MSBuildPropertyGroup *propertyGroup) override; + void visitEnd(const MSBuildPropertyGroup *propertyGroup) override; +}; + +MSBuildProjectWriter::MSBuildProjectWriter(std::ostream *device) + : d(new MSBuildProjectWriterPrivate) +{ + d->device = device; + d->writer = std::make_unique<QXmlStreamWriter>(&d->buffer); + d->writer->setAutoFormatting(true); +} + +MSBuildProjectWriter::~MSBuildProjectWriter() +{ + delete d; +} + +bool MSBuildProjectWriter::write(const MSBuildProject *project) +{ + d->buffer.clear(); + d->writer->writeStartDocument(); + project->accept(d); + d->writer->writeEndDocument(); + if (d->writer->hasError()) + return false; + d->device->write(&*std::begin(d->buffer), d->buffer.size()); + return d->device->good(); +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildImport *import) +{ + writer->writeStartElement(QStringLiteral("Import")); + writer->writeAttribute(QStringLiteral("Project"), import->project()); + if (!import->condition().isEmpty()) + writer->writeAttribute(QStringLiteral("Condition"), import->condition()); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildImport *) +{ + writer->writeEndElement(); +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildImportGroup *importGroup) +{ + writer->writeStartElement(QStringLiteral("ImportGroup")); + if (!importGroup->condition().isEmpty()) + writer->writeAttribute(QStringLiteral("Condition"), importGroup->condition()); + if (!importGroup->label().isEmpty()) + writer->writeAttribute(QStringLiteral("Label"), importGroup->label()); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildImportGroup *) +{ + writer->writeEndElement(); +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildItem *item) +{ + writer->writeStartElement(item->name()); + if (!item->include().isEmpty()) + writer->writeAttribute(QStringLiteral("Include"), item->include()); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildItem *) +{ + writer->writeEndElement(); +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildItemDefinitionGroup *itemDefinitionGroup) +{ + writer->writeStartElement(QStringLiteral("ItemDefinitionGroup")); + if (!itemDefinitionGroup->condition().isEmpty()) + writer->writeAttribute(QStringLiteral("Condition"), itemDefinitionGroup->condition()); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildItemDefinitionGroup *) +{ + writer->writeEndElement(); +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildItemGroup *itemGroup) +{ + writer->writeStartElement(QStringLiteral("ItemGroup")); + if (!itemGroup->condition().isEmpty()) + writer->writeAttribute(QStringLiteral("Condition"), itemGroup->condition()); + if (!itemGroup->label().isEmpty()) + writer->writeAttribute(QStringLiteral("Label"), itemGroup->label()); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildItemGroup *) +{ + writer->writeEndElement(); +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildItemMetadata *itemMetadata) +{ + QString stringValue; + if (itemMetadata->value().type() == QVariant::Bool) { + stringValue = itemMetadata->value().toBool() + ? QStringLiteral("True") + : QStringLiteral("False"); + } else { + stringValue = itemMetadata->value().toString(); + } + writer->writeTextElement(itemMetadata->name(), stringValue); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildItemMetadata *) +{ +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildProject *project) +{ + writer->writeStartElement(QStringLiteral("Project")); + if (!project->defaultTargets().isEmpty()) + writer->writeAttribute(QStringLiteral("DefaultTargets"), project->defaultTargets()); + if (!project->toolsVersion().isEmpty()) + writer->writeAttribute(QStringLiteral("ToolsVersion"), project->toolsVersion()); + writer->writeAttribute(QStringLiteral("xmlns"), kMSBuildSchemaURI); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildProject *) +{ + writer->writeEndElement(); +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildProperty *property) +{ + QString stringValue; + if (property->value().type() == QVariant::Bool) + stringValue = property->value().toBool() ? QStringLiteral("True") : QStringLiteral("False"); + else + stringValue = property->value().toString(); + writer->writeTextElement(property->name(), stringValue); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildProperty *) +{ +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildPropertyGroup *propertyGroup) +{ + writer->writeStartElement(QStringLiteral("PropertyGroup")); + if (!propertyGroup->condition().isEmpty()) + writer->writeAttribute(QStringLiteral("Condition"), propertyGroup->condition()); + if (!propertyGroup->label().isEmpty()) + writer->writeAttribute(QStringLiteral("Label"), propertyGroup->label()); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildPropertyGroup *) +{ + writer->writeEndElement(); +} + +} // namespace qbs diff --git a/src/lib/msbuild/io/msbuildprojectwriter.h b/src/lib/msbuild/io/msbuildprojectwriter.h new file mode 100644 index 000000000..cfe6beb7b --- /dev/null +++ b/src/lib/msbuild/io/msbuildprojectwriter.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDPROJECTWRITER_H +#define MSBUILDPROJECTWRITER_H + +#include <ostream> + +#include <QtCore/qglobal.h> + +namespace qbs { + +class MSBuildProject; +class MSBuildProjectWriterPrivate; + +class MSBuildProjectWriter +{ + Q_DISABLE_COPY(MSBuildProjectWriter) +public: + explicit MSBuildProjectWriter(std::ostream *device); + ~MSBuildProjectWriter(); + + bool write(const MSBuildProject *project); + +private: + MSBuildProjectWriterPrivate *d; +}; + +} // namespace qbs + +#endif // MSBUILDPROJECTWRITER_H diff --git a/src/lib/msbuild/io/visualstudiosolutionwriter.cpp b/src/lib/msbuild/io/visualstudiosolutionwriter.cpp new file mode 100644 index 000000000..625489ac6 --- /dev/null +++ b/src/lib/msbuild/io/visualstudiosolutionwriter.cpp @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "visualstudiosolutionwriter.h" + +#include "../solution/visualstudiosolutionfileproject.h" +#include "../solution/visualstudiosolutionfolderproject.h" +#include "../solution/visualstudiosolutionglobalsection.h" +#include "../solution/visualstudiosolution.h" + +#include <tools/hostosinfo.h> +#include <tools/pathutils.h> +#include <tools/stlutils.h> +#include <tools/visualstudioversioninfo.h> + +#include <QtCore/qdir.h> +#include <QtCore/qfile.h> +#include <QtCore/qfileinfo.h> +#include <QtCore/quuid.h> + +#include <vector> + +namespace qbs { + +using namespace Internal; + +class VisualStudioSolutionWriterPrivate +{ +public: + std::ostream *device = nullptr; + std::string baseDir; +}; + +VisualStudioSolutionWriter::VisualStudioSolutionWriter(std::ostream *device) + : d(new VisualStudioSolutionWriterPrivate) +{ + d->device = device; +} + +VisualStudioSolutionWriter::~VisualStudioSolutionWriter() = default; + +std::string VisualStudioSolutionWriter::projectBaseDirectory() const +{ + return d->baseDir; +} + +void VisualStudioSolutionWriter::setProjectBaseDirectory(const std::string &dir) +{ + d->baseDir = dir; +} + +bool VisualStudioSolutionWriter::write(const VisualStudioSolution *solution) +{ + auto &out = *d->device; + out << u8"Microsoft Visual Studio Solution File, Format Version " + << solution->versionInfo().solutionVersion().toStdString() + << u8"\n# Visual Studio " + << solution->versionInfo().version().majorVersion() + << u8"\n"; + + const auto fileProjects = solution->fileProjects(); + for (const auto &project : fileProjects) { + auto projectFilePath = project->filePath().toStdString(); + + // Try to make the project file path relative to the + // solution file path if we're writing to a file device + if (!d->baseDir.empty()) { + const QDir solutionDir(QString::fromStdString(d->baseDir)); + projectFilePath = Internal::PathUtils::toNativeSeparators( + solutionDir.relativeFilePath(QString::fromStdString(projectFilePath)), + Internal::HostOsInfo::HostOsWindows).toStdString(); + } + + out << u8"Project(\"" + << project->projectTypeGuid().toString().toStdString() + << u8"\") = \"" + << QFileInfo(QString::fromStdString(projectFilePath)).baseName().toStdString() + << u8"\", \"" + << projectFilePath + << u8"\", \"" + << project->guid().toString().toStdString() + << u8"\"\n"; + + const auto dependencies = solution->dependencies(project); + if (!dependencies.empty()) { + out << u8"\tProjectSection(ProjectDependencies) = postProject\n"; + + for (const auto &dependency : dependencies) + out << u8"\t\t" + << dependency->guid().toString().toStdString() + << u8" = " + << dependency->guid().toString().toStdString() + << u8"\n"; + + out << u8"\tEndProjectSection\n"; + } + + out << u8"EndProject\n"; + } + + const auto folderProjects = solution->folderProjects(); + for (const auto &project : folderProjects) { + out << u8"Project(\"" + << project->projectTypeGuid().toString().toStdString() + << u8"\") = \"" + << project->name().toStdString() + << u8"\", \"" + << project->name().toStdString() + << u8"\", \"" + << project->guid().toString().toStdString() + << u8"\"\n"; + + out << u8"EndProject\n"; + } + + out << u8"Global\n"; + + const auto globalSections = solution->globalSections(); + for (const auto &globalSection : globalSections) { + out << u8"\tGlobalSection(" + << globalSection->name().toStdString() + << u8") = " + << (globalSection->isPost() ? u8"postSolution" : u8"preSolution") + << u8"\n"; + for (const auto &property : globalSection->properties()) + out << u8"\t\t" + << property.first.toStdString() + << u8" = " + << property.second.toStdString() + << u8"\n"; + + out << u8"\tEndGlobalSection\n"; + } + + out << u8"EndGlobal\n"; + + return out.good(); +} + +} // namespace qbs diff --git a/src/lib/msbuild/io/visualstudiosolutionwriter.h b/src/lib/msbuild/io/visualstudiosolutionwriter.h new file mode 100644 index 000000000..62ab45ead --- /dev/null +++ b/src/lib/msbuild/io/visualstudiosolutionwriter.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef VISUALSTUDIOSOLUTIONWRITER_H +#define VISUALSTUDIOSOLUTIONWRITER_H + +#include <memory> +#include <ostream> +#include <string> + +#include <QtCore/qglobal.h> + +namespace qbs { + +namespace Internal { class VisualStudioVersionInfo; } + +class VisualStudioSolution; +class VisualStudioSolutionWriterPrivate; + +class VisualStudioSolutionWriter +{ + Q_DISABLE_COPY(VisualStudioSolutionWriter) +public: + explicit VisualStudioSolutionWriter(std::ostream *device); + ~VisualStudioSolutionWriter(); + + std::string projectBaseDirectory() const; + void setProjectBaseDirectory(const std::string &dir); + + bool write(const VisualStudioSolution *solution); + +private: + void addDefaultGlobalSections(); + + std::unique_ptr<VisualStudioSolutionWriterPrivate> d; +}; + +} // namespace qbs + +#endif // VISUALSTUDIOSOLUTIONWRITER_H diff --git a/src/lib/msbuild/msbuild.pro b/src/lib/msbuild/msbuild.pro new file mode 100644 index 000000000..432169129 --- /dev/null +++ b/src/lib/msbuild/msbuild.pro @@ -0,0 +1,58 @@ +TARGET = qbsmsbuild +include(../staticlibrary.pri) +include(../corelib/use_corelib.pri) + +HEADERS += \ + io/msbuildprojectwriter.h \ + io/visualstudiosolutionwriter.h \ + msbuild/imsbuildgroup.h \ + msbuild/imsbuildnode.h \ + msbuild/imsbuildnodevisitor.h \ + msbuild/imsbuildproperty.h \ + msbuild/items/msbuildclcompile.h \ + msbuild/items/msbuildclinclude.h \ + msbuild/items/msbuildfileitem.h \ + msbuild/items/msbuildfilter.h \ + msbuild/items/msbuildlink.h \ + msbuild/items/msbuildnone.h \ + msbuild/msbuildimport.h \ + msbuild/msbuildimportgroup.h \ + msbuild/msbuilditem.h \ + msbuild/msbuilditemdefinitiongroup.h \ + msbuild/msbuilditemgroup.h \ + msbuild/msbuilditemmetadata.h \ + msbuild/msbuildproject.h \ + msbuild/msbuildproperty.h \ + msbuild/msbuildpropertygroup.h \ + solution/ivisualstudiosolutionproject.h \ + solution/visualstudiosolution.h \ + solution/visualstudiosolutionfileproject.h \ + solution/visualstudiosolutionfolderproject.h \ + solution/visualstudiosolutionglobalsection.h + +SOURCES += \ + io/msbuildprojectwriter.cpp \ + io/visualstudiosolutionwriter.cpp \ + msbuild/imsbuildgroup.cpp \ + msbuild/imsbuildnode.cpp \ + msbuild/imsbuildproperty.cpp \ + msbuild/items/msbuildclcompile.cpp \ + msbuild/items/msbuildclinclude.cpp \ + msbuild/items/msbuildfileitem.cpp \ + msbuild/items/msbuildfilter.cpp \ + msbuild/items/msbuildlink.cpp \ + msbuild/items/msbuildnone.cpp \ + msbuild/msbuildimport.cpp \ + msbuild/msbuildimportgroup.cpp \ + msbuild/msbuilditem.cpp \ + msbuild/msbuilditemdefinitiongroup.cpp \ + msbuild/msbuilditemgroup.cpp \ + msbuild/msbuilditemmetadata.cpp \ + msbuild/msbuildproject.cpp \ + msbuild/msbuildproperty.cpp \ + msbuild/msbuildpropertygroup.cpp \ + solution/ivisualstudiosolutionproject.cpp \ + solution/visualstudiosolution.cpp \ + solution/visualstudiosolutionfileproject.cpp \ + solution/visualstudiosolutionfolderproject.cpp \ + solution/visualstudiosolutionglobalsection.cpp diff --git a/src/lib/msbuild/msbuild.qbs b/src/lib/msbuild/msbuild.qbs new file mode 100644 index 000000000..5e69c28e4 --- /dev/null +++ b/src/lib/msbuild/msbuild.qbs @@ -0,0 +1,88 @@ +import qbs + +QbsStaticLibrary { + Depends { name: "cpp" } + Depends { name: "qbscore" } + name: "qbsmsbuild" + cpp.visibility: "default" + cpp.includePaths: base.concat([ + ".", + "../corelib", // for some header-only functions in tools + ]) + + Group { + name: "Solution Object Model" + prefix: "solution/" + files: [ + "ivisualstudiosolutionproject.cpp", + "ivisualstudiosolutionproject.h", + "visualstudiosolutionfileproject.cpp", + "visualstudiosolutionfileproject.h", + "visualstudiosolutionfolderproject.cpp", + "visualstudiosolutionfolderproject.h", + "visualstudiosolution.cpp", + "visualstudiosolution.h", + "visualstudiosolutionglobalsection.cpp", + "visualstudiosolutionglobalsection.h", + ] + } + Group { + name: "MSBuild Object Model" + prefix: "msbuild/" + files: [ + "imsbuildgroup.cpp", + "imsbuildgroup.h", + "imsbuildnode.cpp", + "imsbuildnode.h", + "imsbuildnodevisitor.h", + "imsbuildproperty.cpp", + "imsbuildproperty.h", + "msbuildimport.cpp", + "msbuildimport.h", + "msbuildimportgroup.cpp", + "msbuildimportgroup.h", + "msbuilditem.cpp", + "msbuilditem.h", + "msbuilditemdefinitiongroup.cpp", + "msbuilditemdefinitiongroup.h", + "msbuilditemgroup.cpp", + "msbuilditemgroup.h", + "msbuilditemmetadata.cpp", + "msbuilditemmetadata.h", + "msbuildproject.cpp", + "msbuildproject.h", + "msbuildproperty.cpp", + "msbuildproperty.h", + "msbuildpropertygroup.cpp", + "msbuildpropertygroup.h", + ] + } + Group { + name: "MSBuild Object Model Items" + prefix: "msbuild/items/" + files: [ + "msbuildclcompile.cpp", + "msbuildclcompile.h", + "msbuildclinclude.cpp", + "msbuildclinclude.h", + "msbuildfileitem.cpp", + "msbuildfileitem.h", + "msbuildfilter.cpp", + "msbuildfilter.h", + "msbuildlink.cpp", + "msbuildlink.h", + "msbuildnone.cpp", + "msbuildnone.h", + ] + } + Group { + name: "Visual Studio Object Model I/O" + prefix: "io/" + files: [ + "msbuildprojectwriter.cpp", + "msbuildprojectwriter.h", + "visualstudiosolutionwriter.cpp", + "visualstudiosolutionwriter.h", + ] + } +} diff --git a/src/lib/msbuild/msbuild/imsbuildgroup.cpp b/src/lib/msbuild/msbuild/imsbuildgroup.cpp new file mode 100644 index 000000000..81078ecb9 --- /dev/null +++ b/src/lib/msbuild/msbuild/imsbuildgroup.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "imsbuildgroup.h" +#include "msbuildproject.h" + +namespace qbs { + +class IMSBuildGroupPrivate +{ +public: + QString condition; +}; + +IMSBuildGroup::IMSBuildGroup(MSBuildProject *parent) + : QObject(parent) + , d(new IMSBuildGroupPrivate) +{ +} + +IMSBuildGroup::~IMSBuildGroup() = default; + +QString IMSBuildGroup::condition() const +{ + return d->condition; +} + +void IMSBuildGroup::setCondition(const QString &condition) +{ + d->condition = condition; +} + +IMSBuildItemGroup::IMSBuildItemGroup(MSBuildProject *parent) + : IMSBuildGroup(parent) +{ +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/imsbuildgroup.h b/src/lib/msbuild/msbuild/imsbuildgroup.h new file mode 100644 index 000000000..3d9115643 --- /dev/null +++ b/src/lib/msbuild/msbuild/imsbuildgroup.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef IMSBUILDGROUP_H +#define IMSBUILDGROUP_H + +#include <QtCore/qobject.h> + +#include <memory> + +namespace qbs { + +class MSBuildProject; +class IMSBuildGroupPrivate; + +class IMSBuildGroup : public QObject +{ + Q_OBJECT +public: + explicit IMSBuildGroup(MSBuildProject *parent = nullptr); + ~IMSBuildGroup() override; + + QString condition() const; + void setCondition(const QString &condition); + +private: + std::unique_ptr<IMSBuildGroupPrivate> d; +}; + +class IMSBuildItemGroup : public IMSBuildGroup +{ + Q_OBJECT +public: + explicit IMSBuildItemGroup(MSBuildProject *parent = nullptr); +}; + +} // namespace qbs + +#endif // IMSBUILDGROUP_H diff --git a/src/lib/msbuild/msbuild/imsbuildnode.cpp b/src/lib/msbuild/msbuild/imsbuildnode.cpp new file mode 100644 index 000000000..f563f7b07 --- /dev/null +++ b/src/lib/msbuild/msbuild/imsbuildnode.cpp @@ -0,0 +1,37 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "imsbuildnode.h" + +namespace qbs { + +IMSBuildNode::~IMSBuildNode() = default; + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/imsbuildnode.h b/src/lib/msbuild/msbuild/imsbuildnode.h new file mode 100644 index 000000000..67fb10081 --- /dev/null +++ b/src/lib/msbuild/msbuild/imsbuildnode.h @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef IMSBUILDNODE_H +#define IMSBUILDNODE_H + +namespace qbs { + +class IMSBuildNodeVisitor; + +class IMSBuildNode +{ +public: + virtual ~IMSBuildNode(); + virtual void accept(IMSBuildNodeVisitor *visitor) const = 0; +}; + +} // namespace qbs + +#endif // IMSBUILDNODE_H diff --git a/src/lib/msbuild/msbuild/imsbuildnodevisitor.h b/src/lib/msbuild/msbuild/imsbuildnodevisitor.h new file mode 100644 index 000000000..84239d648 --- /dev/null +++ b/src/lib/msbuild/msbuild/imsbuildnodevisitor.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef IMSBUILDNODEVISITOR_H +#define IMSBUILDNODEVISITOR_H + +namespace qbs { + +class MSBuildImport; +class MSBuildImportGroup; +class MSBuildItem; +class MSBuildItemDefinitionGroup; +class MSBuildItemGroup; +class MSBuildItemMetadata; +class MSBuildProject; +class MSBuildProperty; +class MSBuildPropertyGroup; + +class IMSBuildNodeVisitor +{ +public: + virtual ~IMSBuildNodeVisitor() = default; + + virtual void visitStart(const MSBuildImport *import) = 0; + virtual void visitEnd(const MSBuildImport *import) = 0; + + virtual void visitStart(const MSBuildImportGroup *importGroup) = 0; + virtual void visitEnd(const MSBuildImportGroup *importGroup) = 0; + + virtual void visitStart(const MSBuildItem *item) = 0; + virtual void visitEnd(const MSBuildItem *item) = 0; + + virtual void visitStart(const MSBuildItemDefinitionGroup *itemDefinitionGroup) = 0; + virtual void visitEnd(const MSBuildItemDefinitionGroup *itemDefinitionGroup) = 0; + + virtual void visitStart(const MSBuildItemGroup *itemGroup) = 0; + virtual void visitEnd(const MSBuildItemGroup *itemGroup) = 0; + + virtual void visitStart(const MSBuildItemMetadata *itemMetadata) = 0; + virtual void visitEnd(const MSBuildItemMetadata *itemMetadata) = 0; + + virtual void visitStart(const MSBuildProject *project) = 0; + virtual void visitEnd(const MSBuildProject *project) = 0; + + virtual void visitStart(const MSBuildProperty *property) = 0; + virtual void visitEnd(const MSBuildProperty *property) = 0; + + virtual void visitStart(const MSBuildPropertyGroup *propertyGroup) = 0; + virtual void visitEnd(const MSBuildPropertyGroup *propertyGroup) = 0; +}; + +} // namespace qbs + +#endif // IMSBUILDNODEVISITOR_H diff --git a/src/lib/msbuild/msbuild/imsbuildproperty.cpp b/src/lib/msbuild/msbuild/imsbuildproperty.cpp new file mode 100644 index 000000000..be18f1a5b --- /dev/null +++ b/src/lib/msbuild/msbuild/imsbuildproperty.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "imsbuildproperty.h" + +namespace qbs { + +class IMSBuildPropertyPrivate +{ +public: + QString condition; + QString name; + QVariant value; +}; + +IMSBuildProperty::IMSBuildProperty(QObject *parent) + : QObject(parent) + , d(new IMSBuildPropertyPrivate) +{ +} + +IMSBuildProperty::~IMSBuildProperty() = default; + +QString IMSBuildProperty::condition() const +{ + return d->condition; +} + +void IMSBuildProperty::setCondition(const QString &condition) +{ + d->condition = condition; +} + +QString IMSBuildProperty::name() const +{ + return d->name; +} + +void IMSBuildProperty::setName(const QString &name) +{ + d->name = name; +} + +QVariant IMSBuildProperty::value() const +{ + return d->value; +} + +void IMSBuildProperty::setValue(const QVariant &value) +{ + d->value = value; +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/imsbuildproperty.h b/src/lib/msbuild/msbuild/imsbuildproperty.h new file mode 100644 index 000000000..13f26f070 --- /dev/null +++ b/src/lib/msbuild/msbuild/imsbuildproperty.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef IMSBUILDPROPERTY_H +#define IMSBUILDPROPERTY_H + +#include <QtCore/qobject.h> +#include <QtCore/qvariant.h> + +#include <memory> + +namespace qbs { + +class IMSBuildPropertyPrivate; + +class IMSBuildProperty : public QObject +{ + Q_OBJECT +protected: + explicit IMSBuildProperty(QObject *parent = nullptr); + +public: + ~IMSBuildProperty() override; + + QString condition() const; + void setCondition(const QString &condition); + + QString name() const; + void setName(const QString &name); + + QVariant value() const; + void setValue(const QVariant &value); + +private: + std::unique_ptr<IMSBuildPropertyPrivate> d; +}; + +} // namespace qbs + +#endif // IMSBUILDPROPERTY_H diff --git a/src/lib/msbuild/msbuild/items/msbuildclcompile.cpp b/src/lib/msbuild/msbuild/items/msbuildclcompile.cpp new file mode 100644 index 000000000..d8a587454 --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildclcompile.cpp @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildclcompile.h" + +namespace qbs { + +static const QString MSBuildClCompileItemName = QStringLiteral("ClCompile"); + +MSBuildClCompile::MSBuildClCompile(IMSBuildItemGroup *parent) + : MSBuildFileItem(MSBuildClCompileItemName, parent) +{ +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/items/msbuildclcompile.h b/src/lib/msbuild/msbuild/items/msbuildclcompile.h new file mode 100644 index 000000000..8c326a036 --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildclcompile.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDCLCOMPILE_H +#define MSBUILDCLCOMPILE_H + +#include "msbuildfileitem.h" + +namespace qbs { + +class MSBuildClCompile : public MSBuildFileItem +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildClCompile) +public: + explicit MSBuildClCompile(IMSBuildItemGroup *parent = nullptr); +}; + +} // namespace qbs + +#endif // MSBUILDCLCOMPILE_H diff --git a/src/lib/msbuild/msbuild/items/msbuildclinclude.cpp b/src/lib/msbuild/msbuild/items/msbuildclinclude.cpp new file mode 100644 index 000000000..d9c61bece --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildclinclude.cpp @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildclinclude.h" + +namespace qbs { + +static const QString MSBuildClIncludeItemName = QStringLiteral("ClInclude"); + +MSBuildClInclude::MSBuildClInclude(IMSBuildItemGroup *parent) + : MSBuildFileItem(MSBuildClIncludeItemName, parent) +{ +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/items/msbuildclinclude.h b/src/lib/msbuild/msbuild/items/msbuildclinclude.h new file mode 100644 index 000000000..77d8e0ff2 --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildclinclude.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDCLINCLUDE_H +#define MSBUILDCLINCLUDE_H + +#include "msbuildfileitem.h" + +namespace qbs { + +class MSBuildClInclude : public MSBuildFileItem +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildClInclude) +public: + explicit MSBuildClInclude(IMSBuildItemGroup *parent = nullptr); +}; + +} // namespace qbs + +#endif // MSBUILDCLINCLUDE_H diff --git a/src/lib/msbuild/msbuild/items/msbuildfileitem.cpp b/src/lib/msbuild/msbuild/items/msbuildfileitem.cpp new file mode 100644 index 000000000..4cbb01d04 --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildfileitem.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildfileitem.h" + +#include <memory> +#include "../msbuilditemmetadata.h" + +namespace qbs { + +class MSBuildFileItemPrivate +{ +public: + std::unique_ptr<MSBuildItemMetadata> filter; +}; + +MSBuildFileItem::MSBuildFileItem(const QString &name, IMSBuildItemGroup *parent) + : MSBuildItem(name, parent) + , d(new MSBuildFileItemPrivate) +{ + d->filter = std::make_unique<MSBuildItemMetadata>(QStringLiteral("Filter"), QVariant()); +} + +MSBuildFileItem::~MSBuildFileItem() = default; + +QString MSBuildFileItem::filePath() const +{ + return include(); +} + +void MSBuildFileItem::setFilePath(const QString &filePath) +{ + setInclude(filePath); +} + +QString MSBuildFileItem::filterName() const +{ + return d->filter->value().toString(); +} + +void MSBuildFileItem::setFilterName(const QString &filterName) +{ + d->filter->setValue(filterName); + d->filter->setParent(!filterName.isEmpty() ? this : nullptr); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/items/msbuildfileitem.h b/src/lib/msbuild/msbuild/items/msbuildfileitem.h new file mode 100644 index 000000000..f34ac119a --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildfileitem.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDFILEITEM_H +#define MSBUILDFILEITEM_H + +#include "../msbuilditem.h" + +namespace qbs { + +class MSBuildFileItemPrivate; + +class MSBuildFileItem : public MSBuildItem +{ +public: + ~MSBuildFileItem() override; + + QString filePath() const; + void setFilePath(const QString &filePath); + + QString filterName() const; + void setFilterName(const QString &filterName); + +protected: + explicit MSBuildFileItem(const QString &name, IMSBuildItemGroup *parent = nullptr); + +private: + std::unique_ptr<MSBuildFileItemPrivate> d; +}; + +} // namespace qbs + +#endif // MSBUILDFILEITEM_H diff --git a/src/lib/msbuild/msbuild/items/msbuildfilter.cpp b/src/lib/msbuild/msbuild/items/msbuildfilter.cpp new file mode 100644 index 000000000..0b9c2c86a --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildfilter.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildfilter.h" +#include "../msbuilditemmetadata.h" +#include <tools/hostosinfo.h> +#include <QtCore/quuid.h> + +namespace qbs { + +static const QString MSBuildFilterItemName = QStringLiteral("Filter"); + +class MSBuildFilterPrivate +{ +public: + QUuid identifier; + QList<QString> extensions; + bool parseFiles = true; + bool sourceControlFiles = true; + MSBuildItemMetadata *identifierMetadata = nullptr; + MSBuildItemMetadata *extensionsMetadata = nullptr; +}; + +MSBuildFilter::MSBuildFilter(IMSBuildItemGroup *parent) + : MSBuildItem(MSBuildFilterItemName, parent) + , d(new MSBuildFilterPrivate) +{ + d->identifierMetadata = new MSBuildItemMetadata(QStringLiteral("UniqueIdentifier"), + QVariant(), this); + d->extensionsMetadata = new MSBuildItemMetadata(QStringLiteral("Extensions"), + QVariant(), this); + setIdentifier(QUuid::createUuid()); +} + +MSBuildFilter::MSBuildFilter(const QString &name, + const QList<QString> &extensions, + IMSBuildItemGroup *parent) + : MSBuildFilter(parent) +{ + setInclude(name); + setExtensions(extensions); +} + +MSBuildFilter::~MSBuildFilter() = default; + +QUuid MSBuildFilter::identifier() const +{ + return d->identifier; +} + +void MSBuildFilter::setIdentifier(const QUuid &identifier) +{ + d->identifier = identifier; + d->identifierMetadata->setValue(identifier.toString()); +} + +QList<QString> MSBuildFilter::extensions() const +{ + return d->extensions; +} + +void MSBuildFilter::setExtensions(const QList<QString> &extensions) +{ + d->extensions = extensions; + d->extensionsMetadata->setValue(QStringList(extensions).join( + Internal::HostOsInfo::pathListSeparator( + Internal::HostOsInfo::HostOsWindows))); +} + +bool MSBuildFilter::parseFiles() const +{ + return d->parseFiles; +} + +void MSBuildFilter::setParseFiles(bool parseFiles) +{ + d->parseFiles = parseFiles; +} + +bool MSBuildFilter::sourceControlFiles() const +{ + return d->sourceControlFiles; +} + +void MSBuildFilter::setSourceControlFiles(bool sourceControlFiles) +{ + d->sourceControlFiles = sourceControlFiles; +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/items/msbuildfilter.h b/src/lib/msbuild/msbuild/items/msbuildfilter.h new file mode 100644 index 000000000..fb977f1cc --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildfilter.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDFILTER_H +#define MSBUILDFILTER_H + +#include "../msbuilditem.h" + +namespace qbs { + +class IMSBuildItemGroup; +class MSBuildFilterPrivate; + +class MSBuildFilter : public MSBuildItem +{ + Q_OBJECT +public: + explicit MSBuildFilter(IMSBuildItemGroup *parent = nullptr); + MSBuildFilter(const QString &name, const QList<QString> &extensions, + IMSBuildItemGroup *parent = nullptr); + ~MSBuildFilter() override; + + QUuid identifier() const; + void setIdentifier(const QUuid &identifier); + + QList<QString> extensions() const; + void setExtensions(const QList<QString> &extensions); + + bool parseFiles() const; + void setParseFiles(bool parseFiles); + + bool sourceControlFiles() const; + void setSourceControlFiles(bool sourceControlFiles); + +private: + std::unique_ptr<MSBuildFilterPrivate> d; +}; + +} // namespace qbs + +#endif // MSBUILDFILTER_H diff --git a/src/lib/msbuild/msbuild/items/msbuildlink.cpp b/src/lib/msbuild/msbuild/items/msbuildlink.cpp new file mode 100644 index 000000000..cae1a63a3 --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildlink.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildlink.h" + +#include "../imsbuildgroup.h" + +namespace qbs { + +static const QString MSBuildLinkItemName = QStringLiteral("Link"); + +MSBuildLink::MSBuildLink(IMSBuildItemGroup *parent) + : MSBuildItem(MSBuildLinkItemName, parent) +{ +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/items/msbuildlink.h b/src/lib/msbuild/msbuild/items/msbuildlink.h new file mode 100644 index 000000000..3d7a3ab44 --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildlink.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDLINK_H +#define MSBUILDLINK_H + +#include "../msbuilditem.h" + +namespace qbs { + +class IMSBuildItemGroup; + +class MSBuildLink : public MSBuildItem +{ + Q_OBJECT +public: + explicit MSBuildLink(IMSBuildItemGroup *parent = nullptr); +}; + +} // namespace qbs + +#endif // MSBUILDLINK_H diff --git a/src/lib/msbuild/msbuild/items/msbuildnone.cpp b/src/lib/msbuild/msbuild/items/msbuildnone.cpp new file mode 100644 index 000000000..a590c6e9f --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildnone.cpp @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildnone.h" + +namespace qbs { + +MSBuildNone::MSBuildNone(IMSBuildItemGroup *parent) + : MSBuildFileItem(QStringLiteral("None"), parent) +{ +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/items/msbuildnone.h b/src/lib/msbuild/msbuild/items/msbuildnone.h new file mode 100644 index 000000000..3779da04f --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildnone.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDNONE_H +#define MSBUILDNONE_H + +#include "msbuildfileitem.h" + +namespace qbs { + +class MSBuildNone : public MSBuildFileItem +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildNone) +public: + explicit MSBuildNone(IMSBuildItemGroup *parent = nullptr); +}; + +} // namespace qbs + +#endif // MSBUILDNONE_H diff --git a/src/lib/msbuild/msbuild/msbuildimport.cpp b/src/lib/msbuild/msbuild/msbuildimport.cpp new file mode 100644 index 000000000..000af4496 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildimport.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildimport.h" + +#include "imsbuildnodevisitor.h" +#include "msbuildimportgroup.h" +#include "msbuildproject.h" + +namespace qbs { + +class MSBuildImportPrivate +{ +public: + QString project; + QString condition; +}; + +MSBuildImport::MSBuildImport(MSBuildProject *parent) + : QObject(parent) + , d(new MSBuildImportPrivate) +{ +} + +MSBuildImport::MSBuildImport(MSBuildImportGroup *parent) + : QObject(parent) + , d(new MSBuildImportPrivate) +{ +} + +MSBuildImport::~MSBuildImport() = default; + +QString MSBuildImport::project() const +{ + return d->project; +} + +void MSBuildImport::setProject(const QString &project) +{ + d->project = project; +} + +QString MSBuildImport::condition() const +{ + return d->condition; +} + +void MSBuildImport::setCondition(const QString &condition) +{ + d->condition = condition; +} + +void MSBuildImport::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuildimport.h b/src/lib/msbuild/msbuild/msbuildimport.h new file mode 100644 index 000000000..65f9bc056 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildimport.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#ifndef MSBUILDIMPORT_H +#define MSBUILDIMPORT_H + +#include <QtCore/qobject.h> +#include "imsbuildnode.h" + +#include <memory> + +namespace qbs { + +class MSBuildImportGroup; +class MSBuildImportPrivate; +class MSBuildProject; + +/*! + * \brief The MSBuildImport class represents an MSBuild Import element. + * + * https://msdn.microsoft.com/en-us/library/92x05xfs.aspx + */ +class MSBuildImport : public QObject, public IMSBuildNode +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildImport) +public: + explicit MSBuildImport(MSBuildProject *parent); + explicit MSBuildImport(MSBuildImportGroup *parent); + ~MSBuildImport() override; + + QString project() const; + void setProject(const QString &project); + + QString condition() const; + void setCondition(const QString &condition); + + void accept(IMSBuildNodeVisitor *visitor) const override; + +private: + std::unique_ptr<MSBuildImportPrivate> d; +}; + +} // namespace qbs + +#endif // MSBUILDIMPORT_H diff --git a/src/lib/msbuild/msbuild/msbuildimportgroup.cpp b/src/lib/msbuild/msbuild/msbuildimportgroup.cpp new file mode 100644 index 000000000..d84d81783 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildimportgroup.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildimportgroup.h" + +#include "imsbuildnodevisitor.h" +#include "msbuildimport.h" + +namespace qbs { + +class MSBuildImportGroupPrivate +{ +public: + QString label; +}; + +MSBuildImportGroup::MSBuildImportGroup(MSBuildProject *parent) + : IMSBuildGroup(parent) + , d(new MSBuildImportGroupPrivate) +{ +} + +MSBuildImportGroup::~MSBuildImportGroup() = default; + +QString MSBuildImportGroup::label() const +{ + return d->label; +} + +void MSBuildImportGroup::setLabel(const QString &label) +{ + d->label = label; +} + +void MSBuildImportGroup::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + + for (const auto &child : children()) { + if (const auto import = qobject_cast<const MSBuildImport *>(child)) + import->accept(visitor); + } + + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuildimportgroup.h b/src/lib/msbuild/msbuild/msbuildimportgroup.h new file mode 100644 index 000000000..a21cb5a54 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildimportgroup.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDIMPORTGROUP_H +#define MSBUILDIMPORTGROUP_H + +#include "imsbuildgroup.h" +#include "imsbuildnode.h" + +namespace qbs { + +class MSBuildProject; +class MSBuildImportGroupPrivate; + +/*! + * \brief The MSBuildImportGroup class represents an MSBuild ImportGroup element. + * + * https://msdn.microsoft.com/en-us/library/ff606262.aspx + */ +class MSBuildImportGroup : public IMSBuildGroup, public IMSBuildNode +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildImportGroup) +public: + explicit MSBuildImportGroup(MSBuildProject *parent = nullptr); + ~MSBuildImportGroup() override; + + QString label() const; + void setLabel(const QString &label); + + void accept(IMSBuildNodeVisitor *visitor) const override; + +private: + std::unique_ptr<MSBuildImportGroupPrivate> d; +}; + +} // namespace qbs + +#endif // MSBUILDIMPORTGROUP_H diff --git a/src/lib/msbuild/msbuild/msbuilditem.cpp b/src/lib/msbuild/msbuild/msbuilditem.cpp new file mode 100644 index 000000000..ed181a453 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditem.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuilditem.h" + +#include "imsbuildnodevisitor.h" +#include "msbuilditemdefinitiongroup.h" +#include "msbuilditemgroup.h" +#include "msbuilditemmetadata.h" + +namespace qbs { + +class MSBuildItemPrivate +{ +public: + QString name = QStringLiteral("Item"); + QString include; +}; + +MSBuildItem::MSBuildItem(const QString &name, IMSBuildItemGroup *parent) + : QObject(parent) + , d(new MSBuildItemPrivate) +{ + setName(name); +} + +MSBuildItem::~MSBuildItem() = default; + +QString MSBuildItem::name() const +{ + return d->name; +} + +void MSBuildItem::setName(const QString &name) +{ + d->name = name; +} + +QString MSBuildItem::include() const +{ + return d->include; +} + +void MSBuildItem::setInclude(const QString &include) +{ + d->include = include; +} + +void MSBuildItem::appendProperty(const QString &name, const QVariant &value) +{ + new MSBuildItemMetadata(name, value, this); +} + +void MSBuildItem::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + + for (const auto &child : children()) { + if (const auto itemMetadata = qobject_cast<const MSBuildItemMetadata *>(child)) + itemMetadata->accept(visitor); + } + + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuilditem.h b/src/lib/msbuild/msbuild/msbuilditem.h new file mode 100644 index 000000000..d01a357a2 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditem.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDITEM_H +#define MSBUILDITEM_H + +#include <QtCore/qobject.h> +#include "imsbuildnode.h" + +#include <memory> + +namespace qbs { + +class IMSBuildItemGroup; +class MSBuildItemDefinitionGroup; +class MSBuildItemGroup; +class MSBuildItemPrivate; + +/*! + * \brief The MSBuildItem class represents an MSBuild Item element. + * + * https://msdn.microsoft.com/en-us/library/ms164283.aspx + */ +class MSBuildItem : public QObject, public IMSBuildNode +{ + Q_OBJECT +public: + explicit MSBuildItem(const QString &name, IMSBuildItemGroup *parent = nullptr); + ~MSBuildItem() override; + + QString name() const; + void setName(const QString &name); + + QString include() const; + void setInclude(const QString &include); + + void appendProperty(const QString &name, const QVariant &value); + + void accept(IMSBuildNodeVisitor *visitor) const override; + +private: + std::unique_ptr<MSBuildItemPrivate> d; +}; + +} // namespace qbs + +#endif // MSBUILDITEM_H diff --git a/src/lib/msbuild/msbuild/msbuilditemdefinitiongroup.cpp b/src/lib/msbuild/msbuild/msbuilditemdefinitiongroup.cpp new file mode 100644 index 000000000..1479577c5 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditemdefinitiongroup.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuilditemdefinitiongroup.h" + +#include "imsbuildnodevisitor.h" +#include "msbuilditem.h" + +namespace qbs { + +MSBuildItemDefinitionGroup::MSBuildItemDefinitionGroup(MSBuildProject *parent) + : IMSBuildItemGroup(parent) +{ +} + +MSBuildItemDefinitionGroup::~MSBuildItemDefinitionGroup() = default; + +void MSBuildItemDefinitionGroup::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + + for (const auto &child : children()) { + if (const auto item = qobject_cast<MSBuildItem *>(child)) + item->accept(visitor); + } + + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuilditemdefinitiongroup.h b/src/lib/msbuild/msbuild/msbuilditemdefinitiongroup.h new file mode 100644 index 000000000..3c324699d --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditemdefinitiongroup.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDITEMDEFINITIONGROUP_H +#define MSBUILDITEMDEFINITIONGROUP_H + +#include "imsbuildgroup.h" +#include "imsbuildnode.h" + +namespace qbs { + +class MSBuildProject; +class MSBuildItemDefinitionGroupPrivate; + +/*! + * \brief The MSBuildItemDefinitionGroup class represents an MSBuild ItemDefinitionGroup element. + * + * https://msdn.microsoft.com/en-us/library/bb629392.aspx + */ +class MSBuildItemDefinitionGroup : public IMSBuildItemGroup, public IMSBuildNode +{ + Q_OBJECT +public: + explicit MSBuildItemDefinitionGroup(MSBuildProject *parent = nullptr); + ~MSBuildItemDefinitionGroup() override; + + void accept(IMSBuildNodeVisitor *visitor) const override; +}; + +} // namespace qbs + +#endif // MSBUILDITEMDEFINITIONGROUP_H diff --git a/src/lib/msbuild/msbuild/msbuilditemgroup.cpp b/src/lib/msbuild/msbuild/msbuilditemgroup.cpp new file mode 100644 index 000000000..48f919709 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditemgroup.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuilditemgroup.h" + +#include "imsbuildnodevisitor.h" +#include "msbuilditem.h" + +#include <memory> + +namespace qbs { + +class MSBuildItemGroupPrivate +{ +public: + QString label; +}; + +MSBuildItemGroup::MSBuildItemGroup(MSBuildProject *parent) + : IMSBuildItemGroup(parent) + , d(new MSBuildItemGroupPrivate) +{ +} + +MSBuildItemGroup::~MSBuildItemGroup() = default; + +QString MSBuildItemGroup::label() const +{ + return d->label; +} + +void MSBuildItemGroup::setLabel(const QString &label) +{ + d->label = label; +} + +void MSBuildItemGroup::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + + for (const auto &child : children()) { + if (const MSBuildItem *item = qobject_cast<MSBuildItem *>(child)) + item->accept(visitor); + } + + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuilditemgroup.h b/src/lib/msbuild/msbuild/msbuilditemgroup.h new file mode 100644 index 000000000..bbbdb0e69 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditemgroup.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDITEMGROUP_H +#define MSBUILDITEMGROUP_H + +#include "imsbuildgroup.h" +#include "imsbuildnode.h" + +#include <memory> + +namespace qbs { + +class MSBuildProject; +class MSBuildItemGroupPrivate; + +/*! + * \brief The MSBuildItemGroup class represents an MSBuild ItemGroup element. + * + * https://msdn.microsoft.com/en-us/library/646dk05y.aspx + */ +class MSBuildItemGroup : public IMSBuildItemGroup, public IMSBuildNode +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildItemGroup) +public: + explicit MSBuildItemGroup(MSBuildProject *parent = nullptr); + ~MSBuildItemGroup() override; + + QString label() const; + void setLabel(const QString &label); + + void accept(IMSBuildNodeVisitor *visitor) const override; + +private: + std::unique_ptr<MSBuildItemGroupPrivate> d; +}; + +} // namespace qbs + +#endif // MSBUILDITEMGROUP_H diff --git a/src/lib/msbuild/msbuild/msbuilditemmetadata.cpp b/src/lib/msbuild/msbuild/msbuilditemmetadata.cpp new file mode 100644 index 000000000..daaa4c6b3 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditemmetadata.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuilditemmetadata.h" + +#include "imsbuildnodevisitor.h" +#include "msbuilditem.h" + +namespace qbs { + +MSBuildItemMetadata::MSBuildItemMetadata(MSBuildItem *parent) + : IMSBuildProperty(parent) +{ +} + +MSBuildItemMetadata::MSBuildItemMetadata(const QString &name, const QVariant &value, + MSBuildItem *parent) + : MSBuildItemMetadata(parent) +{ + setName(name); + setValue(value); +} + +void MSBuildItemMetadata::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuilditemmetadata.h b/src/lib/msbuild/msbuild/msbuilditemmetadata.h new file mode 100644 index 000000000..09da2649c --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditemmetadata.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDITEMMETADATA_H +#define MSBUILDITEMMETADATA_H + +#include "imsbuildproperty.h" +#include "imsbuildnode.h" + +namespace qbs { + +class MSBuildItem; + +/*! + * \brief The MSBuildItemMetadata class represents an MSBuild ItemMetadata element. + * + * https://msdn.microsoft.com/en-us/library/ms164284.aspx + */ +class MSBuildItemMetadata : public IMSBuildProperty, public IMSBuildNode +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildItemMetadata) +public: + explicit MSBuildItemMetadata(MSBuildItem *parent = nullptr); + MSBuildItemMetadata(const QString &name, const QVariant &value = QVariant(), + MSBuildItem *parent = nullptr); + + void accept(IMSBuildNodeVisitor *visitor) const override; +}; + +} // namespace qbs + +#endif // MSBUILDITEMMETADATA_H diff --git a/src/lib/msbuild/msbuild/msbuildproject.cpp b/src/lib/msbuild/msbuild/msbuildproject.cpp new file mode 100644 index 000000000..11b5b81ea --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildproject.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildproject.h" + +#include "imsbuildnodevisitor.h" +#include "msbuildimport.h" +#include "msbuildimportgroup.h" +#include "msbuilditemdefinitiongroup.h" +#include "msbuilditemgroup.h" +#include "msbuildpropertygroup.h" + +namespace qbs { + +class MSBuildProjectPrivate +{ +public: + QString defaultTargets; + QString toolsVersion; +}; + +MSBuildProject::MSBuildProject(QObject *parent) + : QObject(parent) + , d(new MSBuildProjectPrivate) +{ +} + +MSBuildProject::~MSBuildProject() = default; + +QString MSBuildProject::defaultTargets() const +{ + return d->defaultTargets; +} + +void MSBuildProject::setDefaultTargets(const QString &defaultTargets) +{ + d->defaultTargets = defaultTargets; +} + +QString MSBuildProject::toolsVersion() const +{ + return d->toolsVersion; +} + +void MSBuildProject::setToolsVersion(const QString &toolsVersion) +{ + d->toolsVersion = toolsVersion; +} + +void MSBuildProject::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + + for (const auto &child : children()) { + if (const auto node = qobject_cast<MSBuildImport *>(child)) + node->accept(visitor); + else if (const auto node = qobject_cast<MSBuildImportGroup *>(child)) + node->accept(visitor); + else if (const auto node = qobject_cast<MSBuildItemDefinitionGroup *>(child)) + node->accept(visitor); + else if (const auto node = qobject_cast<MSBuildItemGroup *>(child)) + node->accept(visitor); + else if (const auto node = qobject_cast<MSBuildPropertyGroup *>(child)) + node->accept(visitor); + } + + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuildproject.h b/src/lib/msbuild/msbuild/msbuildproject.h new file mode 100644 index 000000000..5281f615d --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildproject.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDPROJECT_H +#define MSBUILDPROJECT_H + +#include <QtCore/qobject.h> +#include "imsbuildnode.h" + +#include <memory> + +namespace qbs { + +class MSBuildProjectPrivate; + +/*! + * \brief The MSBuildProject class represents an MSBuild Project element. + * + * https://msdn.microsoft.com/en-us/library/bcxfsh87.aspx + */ +class MSBuildProject : public QObject, public IMSBuildNode +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildProject) +public: + explicit MSBuildProject(QObject *parent = nullptr); + ~MSBuildProject() override; + + QString defaultTargets() const; + void setDefaultTargets(const QString &defaultTargets); + + QString toolsVersion() const; + void setToolsVersion(const QString &toolsVersion); + + void accept(IMSBuildNodeVisitor *visitor) const override; + +private: + std::unique_ptr<MSBuildProjectPrivate> d; +}; + +} // namespace qbs + +#endif // MSBUILDPROJECT_H diff --git a/src/lib/msbuild/msbuild/msbuildproperty.cpp b/src/lib/msbuild/msbuild/msbuildproperty.cpp new file mode 100644 index 000000000..410e2a694 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildproperty.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildproperty.h" + +#include "imsbuildnodevisitor.h" +#include "msbuildpropertygroup.h" + +namespace qbs { + +MSBuildProperty::MSBuildProperty(MSBuildPropertyGroup *parent) + : IMSBuildProperty(parent) +{ +} + +MSBuildProperty::MSBuildProperty(const QString &name, const QVariant &value, + MSBuildPropertyGroup *parent) + : MSBuildProperty(parent) +{ + setName(name); + setValue(value); +} + +void MSBuildProperty::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuildproperty.h b/src/lib/msbuild/msbuild/msbuildproperty.h new file mode 100644 index 000000000..de2c52394 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildproperty.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDPROPERTY_H +#define MSBUILDPROPERTY_H + +#include "imsbuildproperty.h" +#include "imsbuildnode.h" + +namespace qbs { + +class MSBuildPropertyGroup; + +/*! + * \brief The MSBuildProperty class represents an MSBuild Property element. + * + * https://msdn.microsoft.com/en-us/library/ms164288.aspx + */ +class MSBuildProperty : public IMSBuildProperty, public IMSBuildNode +{ + Q_OBJECT +public: + explicit MSBuildProperty(MSBuildPropertyGroup *parent = nullptr); + MSBuildProperty(const QString &name, const QVariant &value = QVariant(), + MSBuildPropertyGroup *parent = nullptr); + + void accept(IMSBuildNodeVisitor *visitor) const override; +}; + +} // namespace qbs + +#endif // MSBUILDPROPERTY_H diff --git a/src/lib/msbuild/msbuild/msbuildpropertygroup.cpp b/src/lib/msbuild/msbuild/msbuildpropertygroup.cpp new file mode 100644 index 000000000..5acb73dad --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildpropertygroup.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildpropertygroup.h" + +#include "imsbuildnodevisitor.h" +#include "msbuildproperty.h" + +namespace qbs { + +class MSBuildPropertyGroupPrivate +{ +public: + QString condition; + QString label; +}; + +MSBuildPropertyGroup::MSBuildPropertyGroup(MSBuildProject *parent) + : IMSBuildGroup(parent) + , d(new MSBuildPropertyGroupPrivate) +{ +} + +MSBuildPropertyGroup::~MSBuildPropertyGroup() = default; + +QString MSBuildPropertyGroup::label() const +{ + return d->label; +} + +void MSBuildPropertyGroup::setLabel(const QString &label) +{ + d->label = label; +} + +void MSBuildPropertyGroup::appendProperty(const QString &name, const QVariant &value) +{ + new MSBuildProperty(name, value, this); +} + +void MSBuildPropertyGroup::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + + for (const auto &child : children()) { + if (const MSBuildProperty *property = qobject_cast<MSBuildProperty *>(child)) + property->accept(visitor); + } + + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuildpropertygroup.h b/src/lib/msbuild/msbuild/msbuildpropertygroup.h new file mode 100644 index 000000000..60bdb008e --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildpropertygroup.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDPROPERTYGROUP_H +#define MSBUILDPROPERTYGROUP_H + +#include "imsbuildgroup.h" +#include "imsbuildnode.h" + +namespace qbs { + +class MSBuildProject; +class MSBuildPropertyGroupPrivate; + +/*! + * \brief The MSBuildPropertyGroup class represents an MSBuild PropertyGroup element. + * + * https://msdn.microsoft.com/en-us/library/t4w159bs.aspx + */ +class MSBuildPropertyGroup : public IMSBuildGroup, public IMSBuildNode +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildPropertyGroup) +public: + explicit MSBuildPropertyGroup(MSBuildProject *parent = nullptr); + ~MSBuildPropertyGroup() override; + + QString label() const; + void setLabel(const QString &label); + + void appendProperty(const QString &name, const QVariant &value); + + void accept(IMSBuildNodeVisitor *visitor) const override; + +private: + std::unique_ptr<MSBuildPropertyGroupPrivate> d; +}; + +} // namespace qbs + +#endif // MSBUILDPROPERTYGROUP_H diff --git a/src/lib/msbuild/solution/ivisualstudiosolutionproject.cpp b/src/lib/msbuild/solution/ivisualstudiosolutionproject.cpp new file mode 100644 index 000000000..4623b5d4d --- /dev/null +++ b/src/lib/msbuild/solution/ivisualstudiosolutionproject.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "ivisualstudiosolutionproject.h" + +namespace qbs { + +class IVisualStudioSolutionProjectPrivate +{ +public: + QUuid guid = QUuid::createUuid(); + QString name; + QString filePath; +}; + +IVisualStudioSolutionProject::IVisualStudioSolutionProject(QObject *parent) + : QObject(parent) + , d(new IVisualStudioSolutionProjectPrivate) +{ +} + +IVisualStudioSolutionProject::~IVisualStudioSolutionProject() = default; + +QUuid IVisualStudioSolutionProject::guid() const +{ + return d->guid; +} + +void IVisualStudioSolutionProject::setGuid(const QUuid &guid) +{ + d->guid = guid; +} + +QString IVisualStudioSolutionProject::name() const +{ + return d->name; +} + +void IVisualStudioSolutionProject::setName(const QString &name) +{ + d->name = name; +} + +} // namespace qbs diff --git a/src/lib/msbuild/solution/ivisualstudiosolutionproject.h b/src/lib/msbuild/solution/ivisualstudiosolutionproject.h new file mode 100644 index 000000000..6f8574aed --- /dev/null +++ b/src/lib/msbuild/solution/ivisualstudiosolutionproject.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef IVISUALSTUDIOSOLUTIONPROJECT_H +#define IVISUALSTUDIOSOLUTIONPROJECT_H + +#include <QtCore/qobject.h> +#include <QtCore/qstring.h> +#include <QtCore/quuid.h> + +#include <memory> + +namespace qbs { + +class IVisualStudioSolutionProjectPrivate; + +class IVisualStudioSolutionProject : public QObject +{ + Q_OBJECT +protected: + explicit IVisualStudioSolutionProject(QObject *parent = nullptr); + +public: + ~IVisualStudioSolutionProject() override; + + virtual QUuid projectTypeGuid() const = 0; + + QUuid guid() const; + void setGuid(const QUuid &guid); + + virtual QString name() const; + void setName(const QString &name); + +private: + std::unique_ptr<IVisualStudioSolutionProjectPrivate> d; +}; + +} // namespace qbs + +#endif // IVISUALSTUDIOSOLUTIONPROJECT_H diff --git a/src/lib/msbuild/solution/visualstudiosolution.cpp b/src/lib/msbuild/solution/visualstudiosolution.cpp new file mode 100644 index 000000000..89b266647 --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolution.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "visualstudiosolution.h" + +#include "visualstudiosolutionfileproject.h" +#include "visualstudiosolutionfolderproject.h" + +#include <tools/visualstudioversioninfo.h> + +#include <QtCore/qmap.h> + +namespace qbs { + +class VisualStudioSolutionPrivate +{ +public: + VisualStudioSolutionPrivate(const Internal::VisualStudioVersionInfo &versionInfo) + : versionInfo(versionInfo) { } + const Internal::VisualStudioVersionInfo versionInfo; + QList<IVisualStudioSolutionProject *> projects; + QMap<VisualStudioSolutionFileProject *, QList<VisualStudioSolutionFileProject *>> dependencies; + QList<VisualStudioSolutionGlobalSection *> globalSections; +}; + +VisualStudioSolution::VisualStudioSolution(const Internal::VisualStudioVersionInfo &versionInfo, + QObject *parent) + : QObject(parent) + , d(new VisualStudioSolutionPrivate(versionInfo)) +{ +} + +VisualStudioSolution::~VisualStudioSolution() = default; + +Internal::VisualStudioVersionInfo VisualStudioSolution::versionInfo() const +{ + return d->versionInfo; +} + +QList<IVisualStudioSolutionProject *> VisualStudioSolution::projects() const +{ + return d->projects; +} + +QList<VisualStudioSolutionFileProject *> VisualStudioSolution::fileProjects() const +{ + QList<VisualStudioSolutionFileProject *> list; + for (const auto &project : qAsConst(d->projects)) + if (auto fileProject = qobject_cast<VisualStudioSolutionFileProject *>(project)) + list.push_back(fileProject); + return list; +} + +QList<VisualStudioSolutionFolderProject *> VisualStudioSolution::folderProjects() const +{ + QList<VisualStudioSolutionFolderProject *> list; + for (const auto &project : qAsConst(d->projects)) + if (auto folderProject = qobject_cast<VisualStudioSolutionFolderProject *>(project)) + list.push_back(folderProject); + return list; +} + +void VisualStudioSolution::appendProject(IVisualStudioSolutionProject *project) +{ + d->projects.push_back(project); +} + +QList<VisualStudioSolutionFileProject *> VisualStudioSolution::dependencies( + VisualStudioSolutionFileProject *project) const +{ + return d->dependencies.value(project); +} + +void VisualStudioSolution::addDependency(VisualStudioSolutionFileProject *project, + VisualStudioSolutionFileProject *dependency) +{ + d->dependencies[project].push_back(dependency); +} + +QList<VisualStudioSolutionGlobalSection *> VisualStudioSolution::globalSections() const +{ + return d->globalSections; +} + +void VisualStudioSolution::appendGlobalSection(VisualStudioSolutionGlobalSection *globalSection) +{ + d->globalSections.push_back(globalSection); +} + +} // namespace qbs diff --git a/src/lib/msbuild/solution/visualstudiosolution.h b/src/lib/msbuild/solution/visualstudiosolution.h new file mode 100644 index 000000000..ba304c00c --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolution.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef VISUALSTUDIOSOLUTION_H +#define VISUALSTUDIOSOLUTION_H + +#include <QtCore/qobject.h> + +#include <memory> + +namespace qbs { + +namespace Internal { class VisualStudioVersionInfo; } + +class MSBuildProject; + +class IVisualStudioSolutionProject; +class VisualStudioSolutionFileProject; +class VisualStudioSolutionFolderProject; +class VisualStudioSolutionGlobalSection; + +class VisualStudioSolutionPrivate; + +class VisualStudioSolution : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(VisualStudioSolution) +public: + explicit VisualStudioSolution(const Internal::VisualStudioVersionInfo &versionInfo, + QObject *parent = nullptr); + ~VisualStudioSolution() override; + + Internal::VisualStudioVersionInfo versionInfo() const; + + QList<IVisualStudioSolutionProject *> projects() const; + QList<VisualStudioSolutionFileProject *> fileProjects() const; + QList<VisualStudioSolutionFolderProject *> folderProjects() const; + void appendProject(IVisualStudioSolutionProject *project); + void removeProject(const IVisualStudioSolutionProject *project); + void clearProjects(); + + QList<VisualStudioSolutionFileProject *> dependencies( + VisualStudioSolutionFileProject *project) const; + void addDependency(VisualStudioSolutionFileProject *project, + VisualStudioSolutionFileProject *dependency); + + QList<VisualStudioSolutionGlobalSection *> globalSections() const; + void appendGlobalSection(VisualStudioSolutionGlobalSection *globalSection); + +private: + void addDefaultGlobalSections(); + + std::unique_ptr<VisualStudioSolutionPrivate> d; +}; + +} // namespace qbs + +#endif // VISUALSTUDIOSOLUTION_H diff --git a/src/lib/msbuild/solution/visualstudiosolutionfileproject.cpp b/src/lib/msbuild/solution/visualstudiosolutionfileproject.cpp new file mode 100644 index 000000000..ab5db088d --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolutionfileproject.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "visualstudiosolutionfileproject.h" + +#include <QtCore/qfileinfo.h> + +namespace qbs { + +class VisualStudioSolutionFileProjectPrivate +{ +public: + QString filePath; +}; + +VisualStudioSolutionFileProject::VisualStudioSolutionFileProject(const QString &filePath, + QObject *parent) + : IVisualStudioSolutionProject(parent) + , d(new VisualStudioSolutionFileProjectPrivate) +{ + setFilePath(filePath); +} + +VisualStudioSolutionFileProject::~VisualStudioSolutionFileProject() = default; + +QString VisualStudioSolutionFileProject::name() const +{ + const auto projectName = IVisualStudioSolutionProject::name(); + if (projectName.isEmpty()) + return QFileInfo(filePath()).baseName(); + return projectName; +} + +QUuid VisualStudioSolutionFileProject::projectTypeGuid() const +{ + return QStringLiteral("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"); // C++ +} + +QString VisualStudioSolutionFileProject::filePath() const +{ + return d->filePath; +} + +void VisualStudioSolutionFileProject::setFilePath(const QString &filePath) +{ + d->filePath = filePath; +} + +} // namespace qbs diff --git a/src/lib/msbuild/solution/visualstudiosolutionfileproject.h b/src/lib/msbuild/solution/visualstudiosolutionfileproject.h new file mode 100644 index 000000000..2039146b6 --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolutionfileproject.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef VISUALSTUDIOSOLUTIONFILEPROJECT_H +#define VISUALSTUDIOSOLUTIONFILEPROJECT_H + +#include <QtCore/qobject.h> +#include "ivisualstudiosolutionproject.h" + +#include <memory> + +namespace qbs { + +class VisualStudioSolutionFileProjectPrivate; + +class VisualStudioSolutionFileProject : public IVisualStudioSolutionProject +{ + Q_OBJECT +public: + explicit VisualStudioSolutionFileProject(const QString &filePath, QObject *parent = nullptr); + ~VisualStudioSolutionFileProject() override; + + QString name() const override; + + QString filePath() const; + void setFilePath(const QString &filePath); + + QUuid projectTypeGuid() const override; + +private: + std::unique_ptr<VisualStudioSolutionFileProjectPrivate> d; +}; + +} // namespace qbs + +#endif // VISUALSTUDIOSOLUTIONFILEPROJECT_H diff --git a/src/lib/msbuild/solution/visualstudiosolutionfolderproject.cpp b/src/lib/msbuild/solution/visualstudiosolutionfolderproject.cpp new file mode 100644 index 000000000..d59d1e1ed --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolutionfolderproject.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "visualstudiosolutionfolderproject.h" + +#include <QtCore/qfileinfo.h> + +namespace qbs { + +VisualStudioSolutionFolderProject::VisualStudioSolutionFolderProject(QObject *parent) + : IVisualStudioSolutionProject(parent) +{ +} + +QUuid VisualStudioSolutionFolderProject::projectTypeGuid() const +{ + return QStringLiteral("{2150E333-8FDC-42A3-9474-1A3956D46DE8}"); +} + +} // namespace qbs diff --git a/src/lib/msbuild/solution/visualstudiosolutionfolderproject.h b/src/lib/msbuild/solution/visualstudiosolutionfolderproject.h new file mode 100644 index 000000000..a7fd180cc --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolutionfolderproject.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef VISUALSTUDIOSOLUTIONFOLDERPROJECT_H +#define VISUALSTUDIOSOLUTIONFOLDERPROJECT_H + +#include <QtCore/qobject.h> +#include "ivisualstudiosolutionproject.h" + +namespace qbs { + +class VisualStudioSolutionFolderProject : public IVisualStudioSolutionProject +{ + Q_OBJECT +public: + explicit VisualStudioSolutionFolderProject(QObject *parent); + + QUuid projectTypeGuid() const override; +}; + +} // namespace qbs + +#endif // VISUALSTUDIOSOLUTIONFOLDERPROJECT_H diff --git a/src/lib/msbuild/solution/visualstudiosolutionglobalsection.cpp b/src/lib/msbuild/solution/visualstudiosolutionglobalsection.cpp new file mode 100644 index 000000000..5cbb0cd61 --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolutionglobalsection.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "visualstudiosolutionglobalsection.h" + +#include <utility> +#include <vector> + +namespace qbs { + +class VisualStudioSolutionGlobalSectionPrivate +{ +public: + QString name; + std::vector<std::pair<QString, QString>> properties; + bool post = false; +}; + +VisualStudioSolutionGlobalSection::VisualStudioSolutionGlobalSection(const QString &name, + QObject *parent) + : QObject(parent) + , d(new VisualStudioSolutionGlobalSectionPrivate) +{ + setName(name); +} + +VisualStudioSolutionGlobalSection::~VisualStudioSolutionGlobalSection() = default; + +QString VisualStudioSolutionGlobalSection::name() const +{ + return d->name; +} + +void VisualStudioSolutionGlobalSection::setName(const QString &name) +{ + d->name = name; +} + +bool VisualStudioSolutionGlobalSection::isPost() const +{ + return d->post; +} + +void VisualStudioSolutionGlobalSection::setPost(bool post) +{ + d->post = post; +} + +std::vector<std::pair<QString, QString> > VisualStudioSolutionGlobalSection::properties() const +{ + return d->properties; +} + +void VisualStudioSolutionGlobalSection::appendProperty(const QString &key, const QString &value) +{ + d->properties.emplace_back(key, value); +} + +} // namespace qbs diff --git a/src/lib/msbuild/solution/visualstudiosolutionglobalsection.h b/src/lib/msbuild/solution/visualstudiosolutionglobalsection.h new file mode 100644 index 000000000..6d383e7d4 --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolutionglobalsection.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef VISUALSTUDIOSOLUTIONGLOBALSECTION_H +#define VISUALSTUDIOSOLUTIONGLOBALSECTION_H + +#include <QtCore/qobject.h> + +#include <memory> + +namespace qbs { + +class VisualStudioSolutionGlobalSectionPrivate; + +class VisualStudioSolutionGlobalSection : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(VisualStudioSolutionGlobalSection) +public: + explicit VisualStudioSolutionGlobalSection(const QString &name, QObject *parent = nullptr); + ~VisualStudioSolutionGlobalSection() override; + + QString name() const; + void setName(const QString &name); + + bool isPost() const; + void setPost(bool post); + + std::vector<std::pair<QString, QString> > properties() const; + void appendProperty(const QString &key, const QString &value); + +private: + std::unique_ptr<VisualStudioSolutionGlobalSectionPrivate> d; +}; + +} // namespace qbs + +#endif // VISUALSTUDIOSOLUTIONGLOBALSECTION_H diff --git a/src/lib/msbuild/use_installed_msbuild.pri b/src/lib/msbuild/use_installed_msbuild.pri new file mode 100644 index 000000000..af89b2550 --- /dev/null +++ b/src/lib/msbuild/use_installed_msbuild.pri @@ -0,0 +1,20 @@ +include(use_installed_corelib.pri) + +LIBNAME=qbsmsbuild + +unix:LIBS += -l$${LIBNAME} + +win32 { + CONFIG(debug, debug|release) { + QBSMSBUILDLIB = $${LIBNAME}d$${QBSCORELIBSUFFIX} + } + CONFIG(release, debug|release) { + QBSMSBUILDLIB = $${LIBNAME}$${QBSCORELIBSUFFIX} + } + msvc { + QBSMSBUILDLIB = $${QBSMSBUILDLIB}.lib + } else { + QBSMSBUILDLIB = lib$${QBSMSBUILDLIB} + } + LIBS += $${QBSMSBUILDLIB} +} diff --git a/src/lib/msbuild/use_msbuild.pri b/src/lib/msbuild/use_msbuild.pri new file mode 100644 index 000000000..bb69968d5 --- /dev/null +++ b/src/lib/msbuild/use_msbuild.pri @@ -0,0 +1,38 @@ +include(../../library_dirname.pri) + +isEmpty(QBSLIBDIR) { + QBSLIBDIR = $${OUT_PWD}/../../../$${QBS_LIBRARY_DIRNAME} +} + +LIBNAME=qbsmsbuild + +unix { + LIBS += -L$${QBSLIBDIR} -l$${LIBNAME} +} + +win32 { + CONFIG(debug, debug|release) { + QBSMSBUILDLIB = $${LIBNAME}d + } + CONFIG(release, debug|release) { + QBSMSBUILDLIB = $${LIBNAME} + } + msvc { + LIBS += /LIBPATH:$$QBSLIBDIR + QBSMSBUILDLIB = $${QBSMSBUILDLIB}.lib + LIBS += Shell32.lib + } else { + LIBS += -L$${QBSLIBDIR} + QBSMSBUILDLIB = lib$${QBSMSBUILDLIB} + } + LIBS += $${QBSMSBUILDLIB} +} + +INCLUDEPATH += \ + $$PWD + +CONFIG += depend_includepath + +CONFIG(static, static|shared) { + DEFINES += QBS_STATIC_LIB +} |