mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
cmLocalGenerator: Adopt custom target 'force' output name generation
This commit is contained in:
@@ -1129,9 +1129,8 @@ cmTarget* cmLocalGenerator::AddUtilityCommand(
|
||||
|
||||
detail::AddUtilityCommand(
|
||||
*this, this->DirectoryBacktrace, cmCommandOrigin::Generator, target,
|
||||
this->Makefile->GetUtilityOutput(target), workingDir, byproducts, depends,
|
||||
commandLines, escapeOldStyle, comment, uses_terminal, command_expand_lists,
|
||||
job_pool, stdPipesUTF8);
|
||||
workingDir, byproducts, depends, commandLines, escapeOldStyle, comment,
|
||||
uses_terminal, command_expand_lists, job_pool, stdPipesUTF8);
|
||||
|
||||
return target;
|
||||
}
|
||||
@@ -4115,7 +4114,7 @@ void AppendCustomCommandToOutput(cmLocalGenerator& lg,
|
||||
|
||||
void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
|
||||
cmCommandOrigin origin, cmTarget* target,
|
||||
std::string const& force, const char* workingDir,
|
||||
const char* workingDir,
|
||||
const std::vector<std::string>& byproducts,
|
||||
const std::vector<std::string>& depends,
|
||||
const cmCustomCommandLines& commandLines,
|
||||
@@ -4128,10 +4127,13 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
|
||||
comment = "";
|
||||
}
|
||||
|
||||
// Create the generated symbolic output name of the utility target.
|
||||
std::string output = lg.CreateUtilityOutput(target->GetName());
|
||||
|
||||
std::string no_main_dependency;
|
||||
cmImplicitDependsList no_implicit_depends;
|
||||
cmSourceFile* rule = AddCustomCommand(
|
||||
lg, lfbt, origin, { force }, byproducts, depends, no_main_dependency,
|
||||
lg, lfbt, origin, { output }, byproducts, depends, no_main_dependency,
|
||||
no_implicit_depends, commandLines, comment, workingDir,
|
||||
/*replace=*/false, escapeOldStyle, uses_terminal, command_expand_lists,
|
||||
/*depfile=*/"", job_pool, stdPipesUTF8);
|
||||
@@ -4139,7 +4141,7 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
|
||||
lg.AddTargetByproducts(target, byproducts, lfbt, origin);
|
||||
}
|
||||
|
||||
target->AddSource(force);
|
||||
target->AddSource(output);
|
||||
}
|
||||
|
||||
std::vector<std::string> ComputeISPCObjectSuffixes(cmGeneratorTarget* target)
|
||||
@@ -4232,6 +4234,20 @@ cmSourceFile* cmLocalGenerator::GetSourceFileWithOutput(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string cmLocalGenerator::CreateUtilityOutput(
|
||||
std::string const& targetName)
|
||||
{
|
||||
std::string force =
|
||||
cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/", targetName);
|
||||
// The output is not actually created so mark it symbolic.
|
||||
if (cmSourceFile* sf = this->Makefile->GetOrCreateGeneratedSource(force)) {
|
||||
sf->SetProperty("SYMBOLIC", "1");
|
||||
} else {
|
||||
cmSystemTools::Error("Could not get source file entry for " + force);
|
||||
}
|
||||
return force;
|
||||
}
|
||||
|
||||
std::vector<cmCustomCommandGenerator>
|
||||
cmLocalGenerator::MakeCustomCommandGenerators(cmCustomCommand const& cc,
|
||||
std::string const& config)
|
||||
|
@@ -364,6 +364,8 @@ public:
|
||||
bool command_expand_lists = false, const std::string& job_pool = "",
|
||||
bool stdPipesUTF8 = false);
|
||||
|
||||
std::string CreateUtilityOutput(std::string const& targetName);
|
||||
|
||||
virtual std::vector<cmCustomCommandGenerator> MakeCustomCommandGenerators(
|
||||
cmCustomCommand const& cc, std::string const& config);
|
||||
|
||||
@@ -688,7 +690,7 @@ void AppendCustomCommandToOutput(cmLocalGenerator& lg,
|
||||
|
||||
void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
|
||||
cmCommandOrigin origin, cmTarget* target,
|
||||
std::string const& force, const char* workingDir,
|
||||
const char* workingDir,
|
||||
const std::vector<std::string>& byproducts,
|
||||
const std::vector<std::string>& depends,
|
||||
const cmCustomCommandLines& commandLines,
|
||||
|
@@ -1257,20 +1257,6 @@ void cmMakefile::AppendCustomCommandToOutput(
|
||||
}
|
||||
}
|
||||
|
||||
std::string cmMakefile::GetUtilityOutput(cmTarget* target)
|
||||
{
|
||||
std::string force = cmStrCat(this->GetCurrentBinaryDirectory(),
|
||||
"/CMakeFiles/", target->GetName());
|
||||
// The output is not actually created so mark it symbolic.
|
||||
if (cmSourceFile* sf = this->GetOrCreateSource(
|
||||
force, false, cmSourceFileLocationKind::Known)) {
|
||||
sf->SetProperty("SYMBOLIC", "1");
|
||||
} else {
|
||||
cmSystemTools::Error("Could not get source file entry for " + force);
|
||||
}
|
||||
return force;
|
||||
}
|
||||
|
||||
cmTarget* cmMakefile::AddUtilityCommand(
|
||||
const std::string& utilityName, bool excludeFromAll, const char* workingDir,
|
||||
const std::vector<std::string>& byproducts,
|
||||
@@ -1287,10 +1273,6 @@ cmTarget* cmMakefile::AddUtilityCommand(
|
||||
return target;
|
||||
}
|
||||
|
||||
// Get the output name of the utility target and mark it generated.
|
||||
std::string force = this->GetUtilityOutput(target);
|
||||
this->GetOrCreateGeneratedSource(force);
|
||||
|
||||
// Always create the byproduct sources and mark them generated.
|
||||
this->CreateGeneratedOutputs(byproducts);
|
||||
|
||||
@@ -1303,8 +1285,8 @@ cmTarget* cmMakefile::AddUtilityCommand(
|
||||
[=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) {
|
||||
BacktraceGuard guard(this->Backtrace, lfbt);
|
||||
detail::AddUtilityCommand(lg, lfbt, cmCommandOrigin::Project, target,
|
||||
force, GetCStrOrNull(workingStr), byproducts,
|
||||
depends, commandLines, escapeOldStyle,
|
||||
GetCStrOrNull(workingStr), byproducts, depends,
|
||||
commandLines, escapeOldStyle,
|
||||
GetCStrOrNull(commentStr), uses_terminal,
|
||||
command_expand_lists, job_pool, stdPipesUTF8);
|
||||
});
|
||||
|
@@ -242,11 +242,6 @@ public:
|
||||
const std::vector<std::string>& srcs,
|
||||
bool excludeFromAll = false);
|
||||
|
||||
/**
|
||||
* Return the utility target output source file name.
|
||||
*/
|
||||
std::string GetUtilityOutput(cmTarget* target);
|
||||
|
||||
/**
|
||||
* Dispatch adding a utility to the build. A utility target is a command
|
||||
* that is run every time the target is built.
|
||||
|
Reference in New Issue
Block a user