ENH: first step to only rebuuilding on flag changes
This commit is contained in:
parent
12ed2c85d9
commit
40cd76ab03
@ -304,6 +304,19 @@ cmLocalUnixMakefileGenerator3
|
|||||||
|
|
||||||
this->WriteMakeVariables(ruleFileStream, HOME_OUTPUT);
|
this->WriteMakeVariables(ruleFileStream, HOME_OUTPUT);
|
||||||
|
|
||||||
|
// Open the flags file. This should be copy-if-different because the
|
||||||
|
// rules may depend on this file itself.
|
||||||
|
std::string flagFileName = dir;
|
||||||
|
flagFileName += "/flags.make";
|
||||||
|
std::string flagFileNameFull = this->ConvertToFullPath(flagFileName);
|
||||||
|
cmGeneratedFileStream flagFileStream(flagFileNameFull.c_str());
|
||||||
|
flagFileStream.SetCopyIfDifferent(true);
|
||||||
|
if(!flagFileStream)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this->WriteDisclaimer(flagFileStream);
|
||||||
|
|
||||||
// Include the dependencies for the target.
|
// Include the dependencies for the target.
|
||||||
std::string depPath = dir;
|
std::string depPath = dir;
|
||||||
depPath += "/depend.make";
|
depPath += "/depend.make";
|
||||||
@ -340,7 +353,7 @@ cmLocalUnixMakefileGenerator3
|
|||||||
{
|
{
|
||||||
// Generate this object file's rule file.
|
// Generate this object file's rule file.
|
||||||
this->WriteObjectRuleFiles(target, *(*source), objects,
|
this->WriteObjectRuleFiles(target, *(*source), objects,
|
||||||
ruleFileStream);
|
ruleFileStream, flagFileStream);
|
||||||
}
|
}
|
||||||
else if((*source)->GetPropertyAsBool("EXTERNAL_OBJECT"))
|
else if((*source)->GetPropertyAsBool("EXTERNAL_OBJECT"))
|
||||||
{
|
{
|
||||||
@ -350,6 +363,46 @@ cmLocalUnixMakefileGenerator3
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// write language flags for target
|
||||||
|
std::map<cmStdString,cmLocalUnixMakefileGenerator3::IntegrityCheckSet>&
|
||||||
|
checkSet = this->GetIntegrityCheckSet()[target.GetName()];
|
||||||
|
for(std::map<cmStdString,
|
||||||
|
cmLocalUnixMakefileGenerator3::IntegrityCheckSet>::const_iterator
|
||||||
|
l = checkSet.begin(); l != checkSet.end(); ++l)
|
||||||
|
{
|
||||||
|
const char *lang = l->first.c_str();
|
||||||
|
std::string flags;
|
||||||
|
// Add the export symbol definition for shared library objects.
|
||||||
|
bool shared = ((target.GetType() == cmTarget::SHARED_LIBRARY) ||
|
||||||
|
(target.GetType() == cmTarget::MODULE_LIBRARY));
|
||||||
|
if(shared)
|
||||||
|
{
|
||||||
|
flags += "-D";
|
||||||
|
if(const char* custom_export_name = target.GetProperty("DEFINE_SYMBOL"))
|
||||||
|
{
|
||||||
|
flags += custom_export_name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string in = target.GetName();
|
||||||
|
in += "_EXPORTS";
|
||||||
|
flags += cmSystemTools::MakeCindentifier(in.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add language-specific flags.
|
||||||
|
this->AddLanguageFlags(flags, lang);
|
||||||
|
|
||||||
|
// Add shared-library flags if needed.
|
||||||
|
this->AddSharedFlags(flags, lang, shared);
|
||||||
|
|
||||||
|
// Add include directory flags.
|
||||||
|
this->AppendFlags(flags, this->GetIncludeFlags(lang));
|
||||||
|
flagFileStream << lang << "_FLAGS = " << flags
|
||||||
|
<< "\n"
|
||||||
|
<< "\n";
|
||||||
|
}
|
||||||
|
|
||||||
// write the custom commands for this target
|
// write the custom commands for this target
|
||||||
std::vector<std::string> cleanFiles;
|
std::vector<std::string> cleanFiles;
|
||||||
// Look for files registered for cleaning in this directory.
|
// Look for files registered for cleaning in this directory.
|
||||||
@ -428,7 +481,8 @@ cmLocalUnixMakefileGenerator3
|
|||||||
cmTarget& target,
|
cmTarget& target,
|
||||||
cmSourceFile& source,
|
cmSourceFile& source,
|
||||||
std::vector<std::string>& depends,
|
std::vector<std::string>& depends,
|
||||||
std::ostream &ruleFileStream)
|
std::ostream &ruleFileStream,
|
||||||
|
std::ostream &flagFileStream)
|
||||||
{
|
{
|
||||||
// Open the rule file for writing. This should be copy-if-different
|
// Open the rule file for writing. This should be copy-if-different
|
||||||
// because the rules may depend on this file itself.
|
// because the rules may depend on this file itself.
|
||||||
@ -436,15 +490,32 @@ cmLocalUnixMakefileGenerator3
|
|||||||
ruleFileName += "/build.make";
|
ruleFileName += "/build.make";
|
||||||
std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
|
std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
|
||||||
|
|
||||||
|
std::string flagFileName = this->GetTargetDirectory(target);
|
||||||
|
flagFileName += "/flags.make";
|
||||||
|
std::string flagFileNameFull = this->ConvertToFullPath(flagFileName);
|
||||||
|
this->AppendRuleDepend(depends, flagFileNameFull.c_str());
|
||||||
|
|
||||||
// generate the depend scanning rule
|
// generate the depend scanning rule
|
||||||
this->WriteObjectDependRules(source, depends);
|
this->WriteObjectDependRules(source, depends);
|
||||||
|
|
||||||
this->AppendRuleDepend(depends, ruleFileNameFull.c_str());
|
std::string relativeObj = this->GetHomeRelativeOutputPath();
|
||||||
|
relativeObj += obj;
|
||||||
|
|
||||||
// Write the build rule.
|
// Write the build rule.
|
||||||
// Build the set of compiler flags.
|
// Build the set of compiler flags.
|
||||||
std::string flags;
|
std::string flags;
|
||||||
|
|
||||||
|
// Add flags from source file properties.
|
||||||
|
if (source.GetProperty("COMPILE_FLAGS"))
|
||||||
|
{
|
||||||
|
this->AppendFlags(flags, source.GetProperty("COMPILE_FLAGS"));
|
||||||
|
flagFileStream << "# Custom flags.\n"
|
||||||
|
<< relativeObj << "_FLAGS = "
|
||||||
|
<< source.GetProperty("COMPILE_FLAGS")
|
||||||
|
<< "\n"
|
||||||
|
<< "\n";
|
||||||
|
}
|
||||||
|
|
||||||
// Add the export symbol definition for shared library objects.
|
// Add the export symbol definition for shared library objects.
|
||||||
bool shared = ((target.GetType() == cmTarget::SHARED_LIBRARY) ||
|
bool shared = ((target.GetType() == cmTarget::SHARED_LIBRARY) ||
|
||||||
(target.GetType() == cmTarget::MODULE_LIBRARY));
|
(target.GetType() == cmTarget::MODULE_LIBRARY));
|
||||||
@ -463,9 +534,6 @@ cmLocalUnixMakefileGenerator3
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add flags from source file properties.
|
|
||||||
this->AppendFlags(flags, source.GetProperty("COMPILE_FLAGS"));
|
|
||||||
|
|
||||||
// Add language-specific flags.
|
// Add language-specific flags.
|
||||||
this->AddLanguageFlags(flags, lang);
|
this->AddLanguageFlags(flags, lang);
|
||||||
|
|
||||||
@ -474,6 +542,8 @@ cmLocalUnixMakefileGenerator3
|
|||||||
|
|
||||||
// Add include directory flags.
|
// Add include directory flags.
|
||||||
this->AppendFlags(flags, this->GetIncludeFlags(lang));
|
this->AppendFlags(flags, this->GetIncludeFlags(lang));
|
||||||
|
|
||||||
|
std::cerr << "Have total flags: " << flags << std::endl;
|
||||||
|
|
||||||
// Get the output paths for source and object files.
|
// Get the output paths for source and object files.
|
||||||
std::string sourceFile = source.GetFullPath();
|
std::string sourceFile = source.GetFullPath();
|
||||||
@ -485,8 +555,6 @@ cmLocalUnixMakefileGenerator3
|
|||||||
std::string objectFile = this->Convert(obj.c_str(),START_OUTPUT,SHELL);
|
std::string objectFile = this->Convert(obj.c_str(),START_OUTPUT,SHELL);
|
||||||
|
|
||||||
// Construct the build message.
|
// Construct the build message.
|
||||||
std::string relativeObj = this->GetHomeRelativeOutputPath();
|
|
||||||
relativeObj += obj;
|
|
||||||
std::vector<std::string> commands;
|
std::vector<std::string> commands;
|
||||||
std::string buildEcho = "Building ";
|
std::string buildEcho = "Building ";
|
||||||
buildEcho += lang;
|
buildEcho += lang;
|
||||||
@ -557,7 +625,8 @@ void
|
|||||||
cmLocalUnixMakefileGenerator3
|
cmLocalUnixMakefileGenerator3
|
||||||
::WriteObjectRuleFiles(cmTarget& target, cmSourceFile& source,
|
::WriteObjectRuleFiles(cmTarget& target, cmSourceFile& source,
|
||||||
std::vector<std::string>& objects,
|
std::vector<std::string>& objects,
|
||||||
std::ostream &ruleFileStream)
|
std::ostream &ruleFileStream,
|
||||||
|
std::ostream &flagFileStream)
|
||||||
{
|
{
|
||||||
// Identify the language of the source file.
|
// Identify the language of the source file.
|
||||||
const char* lang = this->GetSourceFileLanguage(source);
|
const char* lang = this->GetSourceFileLanguage(source);
|
||||||
@ -606,7 +675,7 @@ cmLocalUnixMakefileGenerator3
|
|||||||
|
|
||||||
// generate the build rule file
|
// generate the build rule file
|
||||||
this->WriteObjectBuildFile(obj, lang, target, source, depends,
|
this->WriteObjectBuildFile(obj, lang, target, source, depends,
|
||||||
ruleFileStream);
|
ruleFileStream, flagFileStream);
|
||||||
|
|
||||||
// The object file should be checked for dependency integrity.
|
// The object file should be checked for dependency integrity.
|
||||||
m_CheckDependFiles[target.GetName()][lang].insert(&source);
|
m_CheckDependFiles[target.GetName()][lang].insert(&source);
|
||||||
@ -3006,7 +3075,7 @@ void cmLocalUnixMakefileGenerator3
|
|||||||
{
|
{
|
||||||
// now write all the language stuff
|
// now write all the language stuff
|
||||||
// Set the set of files to check for dependency integrity.
|
// Set the set of files to check for dependency integrity.
|
||||||
std::set<cmStdString> checkSetLangs;
|
std::set<cmStdString> checkSetLangs;
|
||||||
std::map<cmStdString,cmLocalUnixMakefileGenerator3::IntegrityCheckSet>&
|
std::map<cmStdString,cmLocalUnixMakefileGenerator3::IntegrityCheckSet>&
|
||||||
checkSet = this->GetIntegrityCheckSet()[target.GetName()];
|
checkSet = this->GetIntegrityCheckSet()[target.GetName()];
|
||||||
for(std::map<cmStdString,
|
for(std::map<cmStdString,
|
||||||
|
@ -201,7 +201,8 @@ protected:
|
|||||||
void WriteObjectRuleFiles(cmTarget& target,
|
void WriteObjectRuleFiles(cmTarget& target,
|
||||||
cmSourceFile& source,
|
cmSourceFile& source,
|
||||||
std::vector<std::string>& objects,
|
std::vector<std::string>& objects,
|
||||||
std::ostream &filestr);
|
std::ostream &filestr,
|
||||||
|
std::ostream &flagstr);
|
||||||
|
|
||||||
// write the build rule for an object
|
// write the build rule for an object
|
||||||
void WriteObjectBuildFile(std::string &obj,
|
void WriteObjectBuildFile(std::string &obj,
|
||||||
@ -209,7 +210,8 @@ protected:
|
|||||||
cmTarget& target,
|
cmTarget& target,
|
||||||
cmSourceFile& source,
|
cmSourceFile& source,
|
||||||
std::vector<std::string>& depends,
|
std::vector<std::string>& depends,
|
||||||
std::ostream &filestr);
|
std::ostream &filestr,
|
||||||
|
std::ostream &flagstr);
|
||||||
|
|
||||||
// write the depend.make file for an object
|
// write the depend.make file for an object
|
||||||
void WriteObjectDependRules(cmSourceFile& source,
|
void WriteObjectDependRules(cmSourceFile& source,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user