mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-15 12:16:40 +08:00
cmTransformDepfile: Add support for MSBuild AdditionalInputs format
This commit is contained in:
@@ -230,6 +230,9 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(
|
|||||||
case cmDepfileFormat::MakeDepfile:
|
case cmDepfileFormat::MakeDepfile:
|
||||||
argv.emplace_back("makedepfile");
|
argv.emplace_back("makedepfile");
|
||||||
break;
|
break;
|
||||||
|
case cmDepfileFormat::MSBuildAdditionalInputs:
|
||||||
|
argv.emplace_back("MSBuildAdditionalInputs");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
argv.push_back(this->LG->GetSourceDirectory());
|
argv.push_back(this->LG->GetSourceDirectory());
|
||||||
argv.push_back(this->LG->GetCurrentSourceDirectory());
|
argv.push_back(this->LG->GetCurrentSourceDirectory());
|
||||||
@@ -437,6 +440,9 @@ std::string cmCustomCommandGenerator::GetInternalDepfileName(
|
|||||||
case cmDepfileFormat::MakeDepfile:
|
case cmDepfileFormat::MakeDepfile:
|
||||||
extension = ".d";
|
extension = ".d";
|
||||||
break;
|
break;
|
||||||
|
case cmDepfileFormat::MSBuildAdditionalInputs:
|
||||||
|
extension = ".AdditionalInputs";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return cmStrCat(this->LG->GetBinaryDirectory(), "/CMakeFiles/d/",
|
return cmStrCat(this->LG->GetBinaryDirectory(), "/CMakeFiles/d/",
|
||||||
hash.HashString(depfile), extension);
|
hash.HashString(depfile), extension);
|
||||||
|
@@ -2,7 +2,9 @@
|
|||||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
#include "cmTransformDepfile.h"
|
#include "cmTransformDepfile.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#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,
|
bool cmTransformDepfile(cmDepfileFormat format, const cmLocalGenerator& lg,
|
||||||
@@ -103,6 +131,9 @@ bool cmTransformDepfile(cmDepfileFormat format, const cmLocalGenerator& lg,
|
|||||||
case cmDepfileFormat::MakeDepfile:
|
case cmDepfileFormat::MakeDepfile:
|
||||||
WriteDepfile(format, fout, lg, content);
|
WriteDepfile(format, fout, lg, content);
|
||||||
break;
|
break;
|
||||||
|
case cmDepfileFormat::MSBuildAdditionalInputs:
|
||||||
|
WriteMSBuildAdditionalInputs(fout, lg, content);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,8 @@
|
|||||||
enum class cmDepfileFormat
|
enum class cmDepfileFormat
|
||||||
{
|
{
|
||||||
GccDepfile,
|
GccDepfile,
|
||||||
MakeDepfile
|
MakeDepfile,
|
||||||
|
MSBuildAdditionalInputs,
|
||||||
};
|
};
|
||||||
|
|
||||||
class cmLocalGenerator;
|
class cmLocalGenerator;
|
||||||
|
@@ -1531,6 +1531,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
|
|||||||
format = cmDepfileFormat::GccDepfile;
|
format = cmDepfileFormat::GccDepfile;
|
||||||
} else if (args[3] == "makedepfile") {
|
} else if (args[3] == "makedepfile") {
|
||||||
format = cmDepfileFormat::MakeDepfile;
|
format = cmDepfileFormat::MakeDepfile;
|
||||||
|
} else if (args[3] == "MSBuildAdditionalInputs") {
|
||||||
|
format = cmDepfileFormat::MSBuildAdditionalInputs;
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user