aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/generators
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2017-06-02 21:11:12 -0700
committerJake Petroules <jake.petroules@qt.io>2017-06-06 16:47:39 +0000
commit406203559aae79a85e00554455e9be4fa03873a8 (patch)
tree94f285efc6761da1eca3cab5c1707afa8e6cbd59 /src/lib/corelib/generators
parente68a7a584f84ed889255341fae21a5e35fdb1132 (diff)
Add an entry for the qbs file itself in the generated vcxproj
Task-number: QBS-1128 Change-Id: I632096fd350472c7274a6cb38b4ddbdf8ec04515 Reviewed-by: Thomas Epting <thomas.epting@stryker.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/lib/corelib/generators')
-rw-r--r--src/lib/corelib/generators/generatordata.cpp16
-rw-r--r--src/lib/corelib/generators/generatordata.h1
-rw-r--r--src/lib/corelib/generators/visualstudio/msbuildqbsproductproject.cpp16
-rw-r--r--src/lib/corelib/generators/visualstudio/msbuildqbsproductproject.h3
4 files changed, 36 insertions, 0 deletions
diff --git a/src/lib/corelib/generators/generatordata.cpp b/src/lib/corelib/generators/generatordata.cpp
index e8d554d20..1ff186580 100644
--- a/src/lib/corelib/generators/generatordata.cpp
+++ b/src/lib/corelib/generators/generatordata.cpp
@@ -61,6 +61,22 @@ QString GeneratableProductData::name() const
return name;
}
+CodeLocation GeneratableProductData::location() const
+{
+ CodeLocation location;
+ QMapIterator<QString, ProductData> it(data);
+ while (it.hasNext()) {
+ it.next();
+ CodeLocation oldLocation = location;
+ location = it.value().location();
+ if (oldLocation.isValid() && oldLocation != location)
+ throw ErrorInfo(QLatin1String("Products with different code locations "
+ "per-configuration are not compatible with this "
+ "generator."));
+ }
+ return location;
+}
+
QStringList GeneratableProductData::dependencies() const
{
QStringList list;
diff --git a/src/lib/corelib/generators/generatordata.h b/src/lib/corelib/generators/generatordata.h
index d57f2f510..ae41a6295 100644
--- a/src/lib/corelib/generators/generatordata.h
+++ b/src/lib/corelib/generators/generatordata.h
@@ -55,6 +55,7 @@ typedef QMap<QString, ProductData> GeneratableProductDataMap;
struct GeneratableProductData {
GeneratableProductDataMap data;
QString name() const;
+ CodeLocation location() const;
QStringList dependencies() const;
};
diff --git a/src/lib/corelib/generators/visualstudio/msbuildqbsproductproject.cpp b/src/lib/corelib/generators/visualstudio/msbuildqbsproductproject.cpp
index 6aa9857fb..fc9187ae2 100644
--- a/src/lib/corelib/generators/visualstudio/msbuildqbsproductproject.cpp
+++ b/src/lib/corelib/generators/visualstudio/msbuildqbsproductproject.cpp
@@ -354,6 +354,8 @@ void MSBuildQbsProductProject::addFiles(const GeneratableProject &project,
{
auto itemGroup = new MSBuildItemGroup(this);
+ addQbsFile(project, product, itemGroup);
+
std::map<QString, MSBuildFileItem *> sourceFileNodes;
std::map<QString, QStringList> sourceFileEnabledConfigurations;
@@ -406,4 +408,18 @@ void MSBuildQbsProductProject::addFiles(const GeneratableProject &project,
import->setProject(QStringLiteral("$(VCTargetsPath)\\Microsoft.Cpp.targets"));
}
+void MSBuildQbsProductProject::addQbsFile(const GeneratableProject &project,
+ const GeneratableProductData &product,
+ MSBuildItemGroup *itemGroup)
+{
+ auto fileItem = new MSBuildNone(itemGroup);
+ QString path = project.baseBuildDirectory().relativeFilePath(product.location().filePath());
+ // The path still might not be relative (for example if the file item is
+ // located on a different drive)
+ if (QFileInfo(path).isRelative())
+ path = QStringLiteral("$(ProjectDir)") + path;
+ fileItem->setFilePath(path);
+}
+
+
} // namespace qbs
diff --git a/src/lib/corelib/generators/visualstudio/msbuildqbsproductproject.h b/src/lib/corelib/generators/visualstudio/msbuildqbsproductproject.h
index 131de7eb5..7fb9e2a39 100644
--- a/src/lib/corelib/generators/visualstudio/msbuildqbsproductproject.h
+++ b/src/lib/corelib/generators/visualstudio/msbuildqbsproductproject.h
@@ -40,6 +40,7 @@
namespace qbs {
class MSBuildImportGroup;
+class MSBuildItemGroup;
class MSBuildProperty;
class VisualStudioGenerator;
@@ -63,6 +64,8 @@ private:
void addItemDefGroup(const Project &project,
const ProductData &productData);
void addFiles(const GeneratableProject &project, const GeneratableProductData &product);
+ void addQbsFile(const GeneratableProject &project, const GeneratableProductData &product,
+ MSBuildItemGroup *itemGroup);
};
} // namespace qbs