|
|
@@ -2,7 +2,9 @@
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
|
#include "cmTransformDepfile.h"
|
|
|
|
|
|
+#include <algorithm>
|
|
|
#include <functional>
|
|
|
+#include <memory>
|
|
|
#include <string>
|
|
|
#include <type_traits>
|
|
|
#include <utility>
|
|
|
@@ -78,6 +80,32 @@ void WriteDepfile(cmDepfileFormat format, cmsys::ofstream& fout,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+void WriteMSBuildAdditionalInputs(cmsys::ofstream& fout,
|
|
|
+ cmLocalGenerator const& lg,
|
|
|
+ cmGccDepfileContent const& content)
|
|
|
+{
|
|
|
+ if (content.empty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Write a UTF-8 BOM so MSBuild knows the encoding when reading the file.
|
|
|
+ static const char utf8bom[] = { char(0xEF), char(0xBB), char(0xBF) };
|
|
|
+ fout.write(utf8bom, sizeof(utf8bom));
|
|
|
+
|
|
|
+ // Write the format expected by MSBuild CustomBuild AdditionalInputs.
|
|
|
+ const char* sep = "";
|
|
|
+ for (std::string path : content.front().paths) {
|
|
|
+ if (!cmSystemTools::FileIsFullPath(path)) {
|
|
|
+ path =
|
|
|
+ cmSystemTools::CollapseFullPath(path, lg.GetCurrentBinaryDirectory());
|
|
|
+ }
|
|
|
+ std::replace(path.begin(), path.end(), '/', '\\');
|
|
|
+ fout << sep << path;
|
|
|
+ sep = ";";
|
|
|
+ }
|
|
|
+ fout << "\n";
|
|
|
+}
|
|
|
}
|
|
|
|
|
|
bool cmTransformDepfile(cmDepfileFormat format, const cmLocalGenerator& lg,
|
|
|
@@ -103,6 +131,9 @@ bool cmTransformDepfile(cmDepfileFormat format, const cmLocalGenerator& lg,
|
|
|
case cmDepfileFormat::MakeDepfile:
|
|
|
WriteDepfile(format, fout, lg, content);
|
|
|
break;
|
|
|
+ case cmDepfileFormat::MSBuildAdditionalInputs:
|
|
|
+ WriteMSBuildAdditionalInputs(fout, lg, content);
|
|
|
+ break;
|
|
|
}
|
|
|
return true;
|
|
|
}
|