Merge topic 'ninja-no-phony-sources'
93371ed5 Ninja: Skip generating empty phony rules 7243c951 Ninja: Don't limit custom cmd side-effects to build folder (#14972) a33cf6d0 Ninja: Consider only custom commands deps as side-effects (#14972)
This commit is contained in:
commit
e4767a2b6d
@ -151,11 +151,6 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
|
|||||||
++i)
|
++i)
|
||||||
{
|
{
|
||||||
arguments += " " + EncodeIdent(EncodePath(*i), os);
|
arguments += " " + EncodeIdent(EncodePath(*i), os);
|
||||||
|
|
||||||
//we need to track every dependency that comes in, since we are trying
|
|
||||||
//to find dependencies that are side effects of build commands
|
|
||||||
//
|
|
||||||
this->CombinedBuildExplicitDependencies.insert( EncodePath(*i) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write implicit dependencies.
|
// Write implicit dependencies.
|
||||||
@ -280,6 +275,13 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command,
|
|||||||
cmNinjaDeps(),
|
cmNinjaDeps(),
|
||||||
orderOnly,
|
orderOnly,
|
||||||
vars);
|
vars);
|
||||||
|
|
||||||
|
//we need to track every dependency that comes in, since we are trying
|
||||||
|
//to find dependencies that are side effects of build commands
|
||||||
|
for(cmNinjaDeps::const_iterator i = deps.begin(); i != deps.end(); ++i)
|
||||||
|
{
|
||||||
|
this->CombinedCustomCommandExplicitDependencies.insert( EncodePath(*i) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1015,43 +1017,33 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
|
|||||||
//to keep this data around
|
//to keep this data around
|
||||||
this->CombinedBuildOutputs.clear();
|
this->CombinedBuildOutputs.clear();
|
||||||
|
|
||||||
//now we difference with CombinedBuildExplicitDependencies to find
|
//now we difference with CombinedCustomCommandExplicitDependencies to find
|
||||||
//the list of items we know nothing about.
|
//the list of items we know nothing about.
|
||||||
//We have encoded all the paths in CombinedBuildExplicitDependencies
|
//We have encoded all the paths in CombinedCustomCommandExplicitDependencies
|
||||||
//and knownDependencies so no matter if unix or windows paths they
|
//and knownDependencies so no matter if unix or windows paths they
|
||||||
//should all match now.
|
//should all match now.
|
||||||
|
|
||||||
std::vector<std::string> unkownExplicitDepends;
|
std::vector<std::string> unkownExplicitDepends;
|
||||||
this->CombinedBuildExplicitDependencies.erase("all");
|
this->CombinedCustomCommandExplicitDependencies.erase("all");
|
||||||
|
|
||||||
std::set_difference(this->CombinedBuildExplicitDependencies.begin(),
|
std::set_difference(this->CombinedCustomCommandExplicitDependencies.begin(),
|
||||||
this->CombinedBuildExplicitDependencies.end(),
|
this->CombinedCustomCommandExplicitDependencies.end(),
|
||||||
knownDependencies.begin(),
|
knownDependencies.begin(),
|
||||||
knownDependencies.end(),
|
knownDependencies.end(),
|
||||||
std::back_inserter(unkownExplicitDepends));
|
std::back_inserter(unkownExplicitDepends));
|
||||||
|
|
||||||
|
|
||||||
std::string const rootBuildDirectory =
|
|
||||||
this->GetCMakeInstance()->GetHomeOutputDirectory();
|
|
||||||
for (std::vector<std::string>::const_iterator
|
for (std::vector<std::string>::const_iterator
|
||||||
i = unkownExplicitDepends.begin();
|
i = unkownExplicitDepends.begin();
|
||||||
i != unkownExplicitDepends.end();
|
i != unkownExplicitDepends.end();
|
||||||
++i)
|
++i)
|
||||||
{
|
{
|
||||||
//verify the file is in the build directory
|
|
||||||
std::string const absDepPath = cmSystemTools::CollapseFullPath(
|
|
||||||
i->c_str(), rootBuildDirectory.c_str());
|
|
||||||
bool const inBuildDir = cmSystemTools::IsSubDirectory(absDepPath.c_str(),
|
|
||||||
rootBuildDirectory.c_str());
|
|
||||||
if(inBuildDir)
|
|
||||||
{
|
|
||||||
cmNinjaDeps deps(1,*i);
|
cmNinjaDeps deps(1,*i);
|
||||||
this->WritePhonyBuild(os,
|
this->WritePhonyBuild(os,
|
||||||
"",
|
"",
|
||||||
deps,
|
deps,
|
||||||
deps);
|
deps);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os)
|
void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os)
|
||||||
|
@ -363,10 +363,11 @@ private:
|
|||||||
/// The set of custom command outputs we have seen.
|
/// The set of custom command outputs we have seen.
|
||||||
std::set<std::string> CustomCommandOutputs;
|
std::set<std::string> CustomCommandOutputs;
|
||||||
|
|
||||||
//The combined explicit dependencies of all build commands that the global
|
/// The combined explicit dependencies of custom build commands
|
||||||
//generator has issued. When combined with CombinedBuildOutputs it allows
|
std::set<std::string> CombinedCustomCommandExplicitDependencies;
|
||||||
//us to detect the set of explicit dependencies that have
|
|
||||||
std::set<std::string> CombinedBuildExplicitDependencies;
|
/// When combined with CombinedCustomCommandExplicitDependencies it allows
|
||||||
|
/// us to detect the set of explicit dependencies that have
|
||||||
std::set<std::string> CombinedBuildOutputs;
|
std::set<std::string> CombinedBuildOutputs;
|
||||||
|
|
||||||
/// The mapping from source file to assumed dependencies.
|
/// The mapping from source file to assumed dependencies.
|
||||||
|
@ -542,6 +542,8 @@ cmNinjaTargetGenerator
|
|||||||
std::back_inserter(orderOnlyDeps), MapToNinjaPath());
|
std::back_inserter(orderOnlyDeps), MapToNinjaPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!orderOnlyDeps.empty())
|
||||||
|
{
|
||||||
cmNinjaDeps orderOnlyTarget;
|
cmNinjaDeps orderOnlyTarget;
|
||||||
orderOnlyTarget.push_back(this->OrderDependsTargetForTarget());
|
orderOnlyTarget.push_back(this->OrderDependsTargetForTarget());
|
||||||
this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
|
this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
|
||||||
@ -551,13 +553,13 @@ cmNinjaTargetGenerator
|
|||||||
cmNinjaDeps(),
|
cmNinjaDeps(),
|
||||||
cmNinjaDeps(),
|
cmNinjaDeps(),
|
||||||
orderOnlyDeps);
|
orderOnlyDeps);
|
||||||
|
}
|
||||||
std::vector<cmSourceFile const*> objectSources;
|
std::vector<cmSourceFile const*> objectSources;
|
||||||
this->GeneratorTarget->GetObjectSources(objectSources, config);
|
this->GeneratorTarget->GetObjectSources(objectSources, config);
|
||||||
for(std::vector<cmSourceFile const*>::const_iterator
|
for(std::vector<cmSourceFile const*>::const_iterator
|
||||||
si = objectSources.begin(); si != objectSources.end(); ++si)
|
si = objectSources.begin(); si != objectSources.end(); ++si)
|
||||||
{
|
{
|
||||||
this->WriteObjectBuildStatement(*si);
|
this->WriteObjectBuildStatement(*si, !orderOnlyDeps.empty());
|
||||||
}
|
}
|
||||||
std::string def = this->GeneratorTarget->GetModuleDefinitionFile(config);
|
std::string def = this->GeneratorTarget->GetModuleDefinitionFile(config);
|
||||||
if(!def.empty())
|
if(!def.empty())
|
||||||
@ -570,7 +572,8 @@ cmNinjaTargetGenerator
|
|||||||
|
|
||||||
void
|
void
|
||||||
cmNinjaTargetGenerator
|
cmNinjaTargetGenerator
|
||||||
::WriteObjectBuildStatement(cmSourceFile const* source)
|
::WriteObjectBuildStatement(
|
||||||
|
cmSourceFile const* source, bool writeOrderDependsTargetForTarget)
|
||||||
{
|
{
|
||||||
std::string comment;
|
std::string comment;
|
||||||
const std::string language = source->GetLanguage();
|
const std::string language = source->GetLanguage();
|
||||||
@ -599,7 +602,10 @@ cmNinjaTargetGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmNinjaDeps orderOnlyDeps;
|
cmNinjaDeps orderOnlyDeps;
|
||||||
|
if (writeOrderDependsTargetForTarget)
|
||||||
|
{
|
||||||
orderOnlyDeps.push_back(this->OrderDependsTargetForTarget());
|
orderOnlyDeps.push_back(this->OrderDependsTargetForTarget());
|
||||||
|
}
|
||||||
|
|
||||||
// If the source file is GENERATED and does not have a custom command
|
// If the source file is GENERATED and does not have a custom command
|
||||||
// (either attached to this source file or another one), assume that one of
|
// (either attached to this source file or another one), assume that one of
|
||||||
|
@ -114,7 +114,8 @@ protected:
|
|||||||
void WriteLanguageRules(const std::string& language);
|
void WriteLanguageRules(const std::string& language);
|
||||||
void WriteCompileRule(const std::string& language);
|
void WriteCompileRule(const std::string& language);
|
||||||
void WriteObjectBuildStatements();
|
void WriteObjectBuildStatements();
|
||||||
void WriteObjectBuildStatement(cmSourceFile const* source);
|
void WriteObjectBuildStatement(cmSourceFile const* source,
|
||||||
|
bool writeOrderDependsTargetForTarget);
|
||||||
void WriteCustomCommandBuildStatement(cmCustomCommand *cc);
|
void WriteCustomCommandBuildStatement(cmCustomCommand *cc);
|
||||||
|
|
||||||
cmNinjaDeps GetObjects() const
|
cmNinjaDeps GetObjects() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user