Merge topic 'dev/custom-target-performance'
6208c285
cmMakefile: Defer dependency calculationsdc2e26df
cmMakefile: Avoid excess source filesd2803fba
cmMakefile: Add a CreateSource method
This commit is contained in:
commit
aaea11e353
|
@ -29,7 +29,7 @@ bool cmGetSourceFilePropertyCommand
|
||||||
// for the location we must create a source file first
|
// for the location we must create a source file first
|
||||||
if (!sf && args[2] == "LOCATION")
|
if (!sf && args[2] == "LOCATION")
|
||||||
{
|
{
|
||||||
sf = this->Makefile->GetOrCreateSource(file);
|
sf = this->Makefile->CreateSource(file);
|
||||||
}
|
}
|
||||||
if(sf)
|
if(sf)
|
||||||
{
|
{
|
||||||
|
|
|
@ -989,7 +989,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
|
||||||
|
|
||||||
// Choose a source file on which to store the custom command.
|
// Choose a source file on which to store the custom command.
|
||||||
cmSourceFile* file = 0;
|
cmSourceFile* file = 0;
|
||||||
if(!main_dependency.empty())
|
if(!commandLines.empty() && !main_dependency.empty())
|
||||||
{
|
{
|
||||||
// The main dependency was specified. Use it unless a different
|
// The main dependency was specified. Use it unless a different
|
||||||
// custom command already used it.
|
// custom command already used it.
|
||||||
|
@ -1010,11 +1010,9 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
|
||||||
file = 0;
|
file = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (!file)
|
||||||
{
|
{
|
||||||
// The main dependency does not have a custom command or we are
|
file = this->CreateSource(main_dependency);
|
||||||
// allowed to replace it. Use it to store the command.
|
|
||||||
file = this->GetOrCreateSource(main_dependency);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1041,9 +1039,12 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a cmSourceFile for the rule file.
|
// Create a cmSourceFile for the rule file.
|
||||||
file = this->GetOrCreateSource(outName, true);
|
if (!file)
|
||||||
|
{
|
||||||
|
file = this->CreateSource(outName, true);
|
||||||
file->SetProperty("__CMAKE_RULE", "1");
|
file->SetProperty("__CMAKE_RULE", "1");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Always create the output sources and mark them generated.
|
// Always create the output sources and mark them generated.
|
||||||
for(std::vector<std::string>::const_iterator o = outputs.begin();
|
for(std::vector<std::string>::const_iterator o = outputs.begin();
|
||||||
|
@ -1055,6 +1056,9 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attach the custom command to the file.
|
||||||
|
if(file)
|
||||||
|
{
|
||||||
// Construct a complete list of dependencies.
|
// Construct a complete list of dependencies.
|
||||||
std::vector<std::string> depends2(depends);
|
std::vector<std::string> depends2(depends);
|
||||||
if(!main_dependency.empty())
|
if(!main_dependency.empty())
|
||||||
|
@ -1062,9 +1066,6 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
|
||||||
depends2.push_back(main_dependency);
|
depends2.push_back(main_dependency);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach the custom command to the file.
|
|
||||||
if(file)
|
|
||||||
{
|
|
||||||
cmCustomCommand* cc =
|
cmCustomCommand* cc =
|
||||||
new cmCustomCommand(this, outputs, depends2, commandLines,
|
new cmCustomCommand(this, outputs, depends2, commandLines,
|
||||||
comment, workingDir);
|
comment, workingDir);
|
||||||
|
@ -1256,6 +1257,8 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the custom command in the target.
|
// Store the custom command in the target.
|
||||||
|
if (!commandLines.empty() || !depends.empty())
|
||||||
|
{
|
||||||
std::string force = this->GetStartOutputDirectory();
|
std::string force = this->GetStartOutputDirectory();
|
||||||
force += cmake::GetCMakeFilesDirectory();
|
force += cmake::GetCMakeFilesDirectory();
|
||||||
force += "/";
|
force += "/";
|
||||||
|
@ -1279,6 +1282,7 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName,
|
||||||
cmSystemTools::Error("Could not get source file entry for ",
|
cmSystemTools::Error("Could not get source file entry for ",
|
||||||
force.c_str());
|
force.c_str());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3450,6 +3454,19 @@ cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
cmSourceFile* cmMakefile::CreateSource(const std::string& sourceName,
|
||||||
|
bool generated)
|
||||||
|
{
|
||||||
|
cmSourceFile* sf = new cmSourceFile(this, sourceName);
|
||||||
|
if(generated)
|
||||||
|
{
|
||||||
|
sf->SetProperty("GENERATED", "1");
|
||||||
|
}
|
||||||
|
this->SourceFiles.push_back(sf);
|
||||||
|
return sf;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
|
cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
|
||||||
bool generated)
|
bool generated)
|
||||||
|
@ -3460,13 +3477,7 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmSourceFile* sf = new cmSourceFile(this, sourceName);
|
return this->CreateSource(sourceName, generated);
|
||||||
if(generated)
|
|
||||||
{
|
|
||||||
sf->SetProperty("GENERATED", "1");
|
|
||||||
}
|
|
||||||
this->SourceFiles.push_back(sf);
|
|
||||||
return sf;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -560,6 +560,13 @@ public:
|
||||||
*/
|
*/
|
||||||
cmSourceFile* GetSource(const std::string& sourceName) const;
|
cmSourceFile* GetSource(const std::string& sourceName) const;
|
||||||
|
|
||||||
|
/** Create the source file and return it. generated
|
||||||
|
* indicates if it is a generated file, this is used in determining
|
||||||
|
* how to create the source file instance e.g. name
|
||||||
|
*/
|
||||||
|
cmSourceFile* CreateSource(const std::string& sourceName,
|
||||||
|
bool generated = false);
|
||||||
|
|
||||||
/** Get a cmSourceFile pointer for a given source name, if the name is
|
/** Get a cmSourceFile pointer for a given source name, if the name is
|
||||||
* not found, then create the source file and return it. generated
|
* not found, then create the source file and return it. generated
|
||||||
* indicates if it is a generated file, this is used in determining
|
* indicates if it is a generated file, this is used in determining
|
||||||
|
|
Loading…
Reference in New Issue