mirror of
https://github.com/reactos/CMake.git
synced 2025-03-03 09:27:12 +00:00
cmExportLibraryDependenciesCommand: Port away from FinalPass
This commit is contained in:
parent
a74dad3bd3
commit
20169f0b8d
@ -19,57 +19,31 @@
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
||||
bool cmExportLibraryDependenciesCommand::InitialPass(
|
||||
std::vector<std::string> const& args, cmExecutionStatus&)
|
||||
{
|
||||
if (args.empty()) {
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
// store the arguments for the final pass
|
||||
this->Filename = args[0];
|
||||
this->Append = false;
|
||||
if (args.size() > 1) {
|
||||
if (args[1] == "APPEND") {
|
||||
this->Append = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void cmExportLibraryDependenciesCommand::FinalPass()
|
||||
{
|
||||
// export_library_dependencies() shouldn't modify anything
|
||||
// ensure this by calling a const method
|
||||
this->ConstFinalPass();
|
||||
}
|
||||
|
||||
void cmExportLibraryDependenciesCommand::ConstFinalPass() const
|
||||
static void FinalAction(cmMakefile& makefile, std::string const& filename,
|
||||
bool append)
|
||||
{
|
||||
// Use copy-if-different if not appending.
|
||||
std::unique_ptr<cmsys::ofstream> foutPtr;
|
||||
if (this->Append) {
|
||||
if (append) {
|
||||
const auto openmodeApp = std::ios::app;
|
||||
foutPtr =
|
||||
cm::make_unique<cmsys::ofstream>(this->Filename.c_str(), openmodeApp);
|
||||
foutPtr = cm::make_unique<cmsys::ofstream>(filename.c_str(), openmodeApp);
|
||||
} else {
|
||||
std::unique_ptr<cmGeneratedFileStream> ap(
|
||||
new cmGeneratedFileStream(this->Filename, true));
|
||||
new cmGeneratedFileStream(filename, true));
|
||||
ap->SetCopyIfDifferent(true);
|
||||
foutPtr = std::move(ap);
|
||||
}
|
||||
std::ostream& fout = *foutPtr;
|
||||
|
||||
if (!fout) {
|
||||
cmSystemTools::Error("Error Writing " + this->Filename);
|
||||
cmSystemTools::Error("Error Writing " + filename);
|
||||
cmSystemTools::ReportLastSystemError("");
|
||||
return;
|
||||
}
|
||||
|
||||
// Collect dependency information about all library targets built in
|
||||
// the project.
|
||||
cmake* cm = this->Makefile->GetCMakeInstance();
|
||||
cmake* cm = makefile.GetCMakeInstance();
|
||||
cmGlobalGenerator* global = cm->GetGlobalGenerator();
|
||||
const std::vector<cmMakefile*>& locals = global->GetMakefiles();
|
||||
std::map<std::string, std::string> libDepsOld;
|
||||
@ -166,3 +140,20 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
|
||||
}
|
||||
fout << "endif()\n";
|
||||
}
|
||||
|
||||
bool cmExportLibraryDependenciesCommand::InitialPass(
|
||||
std::vector<std::string> const& args, cmExecutionStatus&)
|
||||
{
|
||||
if (args.empty()) {
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string const& filename = args[0];
|
||||
bool const append = args.size() > 1 && args[1] == "APPEND";
|
||||
this->Makefile->AddFinalAction([filename, append](cmMakefile& makefile) {
|
||||
FinalAction(makefile, filename, append);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -23,14 +23,6 @@ public:
|
||||
}
|
||||
bool InitialPass(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status) override;
|
||||
|
||||
void FinalPass() override;
|
||||
bool HasFinalPass() const override { return true; }
|
||||
|
||||
private:
|
||||
std::string Filename;
|
||||
bool Append = false;
|
||||
void ConstFinalPass() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user