ENH: Added source file property OBJECT_DEPENDS to support generated header files included in non-generated sources.

This commit is contained in:
Brad King 2002-12-13 16:16:48 -05:00
parent 7e824e83a9
commit 3348131819
5 changed files with 114 additions and 11 deletions

View File

@ -2351,6 +2351,23 @@ OutputBuildObjectFromSource(std::ostream& fout,
objectFile.c_str(), objectFile.c_str(),
flags.c_str()); flags.c_str());
} }
std::vector<std::string> sourceAndDeps;
sourceAndDeps.push_back(sourceFile);
// Check for extra object-file dependencies.
const char* additionalDeps = source.GetProperty("OBJECT_DEPENDS");
if(additionalDeps)
{
std::vector<std::string> depends;
cmSystemTools::ExpandListArgument(additionalDeps, depends);
for(std::vector<std::string>::iterator i = depends.begin();
i != depends.end(); ++i)
{
sourceAndDeps.push_back(cmSystemTools::ConvertToOutputPath(i->c_str()));
}
}
this->OutputMakeRule(fout, this->OutputMakeRule(fout,
comment.c_str(), comment.c_str(),
objectFile.c_str(), objectFile.c_str(),
@ -2477,6 +2494,20 @@ void cmLocalUnixMakefileGenerator::OutputMakeRule(std::ostream& fout,
const char* target, const char* target,
const char* depends, const char* depends,
const std::vector<std::string>& commands) const std::vector<std::string>& commands)
{
std::vector<std::string> depend;
if(depends)
{
depend.push_back(depends);
}
this->OutputMakeRule(fout, comment, target, depend, commands);
}
void cmLocalUnixMakefileGenerator::OutputMakeRule(std::ostream& fout,
const char* comment,
const char* target,
const std::vector<std::string>& depends,
const std::vector<std::string>& commands)
{ {
if(!target) if(!target)
{ {
@ -2497,13 +2528,14 @@ void cmLocalUnixMakefileGenerator::OutputMakeRule(std::ostream& fout,
replace = target; replace = target;
m_Makefile->ExpandVariablesInString(replace); m_Makefile->ExpandVariablesInString(replace);
fout << cmSystemTools::ConvertToOutputPath(replace.c_str()) << ": "; fout << cmSystemTools::ConvertToOutputPath(replace.c_str()) << ":";
if(depends) for(std::vector<std::string>::const_iterator dep = depends.begin();
dep != depends.end(); ++dep)
{ {
replace = depends; replace = *dep;
m_Makefile->ExpandVariablesInString(replace); m_Makefile->ExpandVariablesInString(replace);
fout << replace.c_str(); fout << " " << replace.c_str();
} }
fout << "\n"; fout << "\n";
int count = 0; int count = 0;

View File

@ -160,6 +160,12 @@ protected:
const char* depends, const char* depends,
const std::vector<std::string>& commands); const std::vector<std::string>& commands);
virtual void OutputMakeRule(std::ostream&,
const char* comment,
const char* target,
const std::vector<std::string>& depends,
const std::vector<std::string>& commands);
virtual void OutputMakeRule(std::ostream&, virtual void OutputMakeRule(std::ostream&,
const char* comment, const char* comment,
const char* target, const char* target,

View File

@ -280,10 +280,20 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
{ {
std::string source = cc->first; std::string source = cc->first;
const cmSourceGroup::Commands& commands = cc->second.m_Commands; const cmSourceGroup::Commands& commands = cc->second.m_Commands;
std::vector<std::string> depends;
const char* compileFlags = 0; const char* compileFlags = 0;
if(cc->second.m_SourceFile) if(cc->second.m_SourceFile)
{ {
// Check for extra compiler flags.
compileFlags = cc->second.m_SourceFile->GetProperty("COMPILE_FLAGS"); compileFlags = cc->second.m_SourceFile->GetProperty("COMPILE_FLAGS");
// Check for extra object-file dependencies.
const char* dependsValue =
cc->second.m_SourceFile->GetProperty("OBJECT_DEPENDS");
if(dependsValue)
{
cmSystemTools::ExpandListArgument(dependsValue, depends);
}
} }
if (source != libName || target.GetType() == cmTarget::UTILITY) if (source != libName || target.GetType() == cmTarget::UTILITY)
{ {
@ -293,6 +303,18 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
// build it, then it will. // build it, then it will.
fout << "SOURCE=" << fout << "SOURCE=" <<
cmSystemTools::ConvertToOutputPath(source.c_str()) << "\n\n"; cmSystemTools::ConvertToOutputPath(source.c_str()) << "\n\n";
if(!depends.empty())
{
// Write out the dependencies for the rule.
fout << "USERDEP__HACK=";
for(std::vector<std::string>::const_iterator d = depends.begin();
d != depends.end(); ++d)
{
fout << "\\\n\t" <<
cmSystemTools::ConvertToOutputPath(d->c_str());
}
fout << "\n";
}
if (!commands.empty()) if (!commands.empty())
{ {
cmSourceGroup::CommandFiles totalCommand; cmSourceGroup::CommandFiles totalCommand;
@ -385,7 +407,7 @@ void cmLocalVisualStudio6Generator::WriteCustomRule(std::ostream& fout,
for(std::set<std::string>::const_iterator output = outputs.begin(); for(std::set<std::string>::const_iterator output = outputs.begin();
output != outputs.end(); ++output) output != outputs.end(); ++output)
{ {
fout << "\"" << output->c_str() fout << "\"" << cmSystemTools::ConvertToOutputPath(output->c_str())
<< "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\""; << "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"";
fout << command << "\n\n"; fout << command << "\n\n";
} }

View File

@ -664,14 +664,35 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
std::string source = cc->first; std::string source = cc->first;
const cmSourceGroup::Commands& commands = cc->second.m_Commands; const cmSourceGroup::Commands& commands = cc->second.m_Commands;
const char* compileFlags = 0; const char* compileFlags = 0;
std::string additionalDeps;
if(cc->second.m_SourceFile) if(cc->second.m_SourceFile)
{ {
// Check for extra compiler flags.
compileFlags = cc->second.m_SourceFile->GetProperty("COMPILE_FLAGS"); compileFlags = cc->second.m_SourceFile->GetProperty("COMPILE_FLAGS");
// Check for extra object-file dependencies.
const char* deps =
cc->second.m_SourceFile->GetProperty("OBJECT_DEPENDS");
if(deps)
{
std::vector<std::string> depends;
cmSystemTools::ExpandListArgument(deps, depends);
if(!depends.empty())
{
std::vector<std::string>::iterator i = depends.begin();
additionalDeps = this->ConvertToXMLOutputPath(i->c_str());
for(++i;i != depends.end(); ++i)
{
additionalDeps += ";";
additionalDeps += this->ConvertToXMLOutputPath(i->c_str());
}
}
}
} }
if (source != libName || target.GetType() == cmTarget::UTILITY) if (source != libName || target.GetType() == cmTarget::UTILITY)
{ {
fout << "\t\t\t<File\n"; fout << "\t\t\t<File\n";
std::string d = cmSystemTools::ConvertToOutputPath(source.c_str()); std::string d = this->ConvertToXMLOutputPath(source.c_str());
// remove double quotes from the string // remove double quotes from the string
cmSystemTools::ReplaceString(d, "\"", ""); cmSystemTools::ReplaceString(d, "\"", "");
// Tell MS-Dev what the source is. If the compiler knows how to // Tell MS-Dev what the source is. If the compiler knows how to
@ -689,7 +710,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
totalCommand.m_Depends, totalCommand.m_Depends,
totalCommand.m_Outputs, compileFlags); totalCommand.m_Outputs, compileFlags);
} }
else if(compileFlags) else if(compileFlags || additionalDeps.length())
{ {
for(std::vector<std::string>::iterator i = configs->begin(); for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i) i != configs->end(); ++i)
@ -697,9 +718,18 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
fout << "\t\t\t\t<FileConfiguration\n" fout << "\t\t\t\t<FileConfiguration\n"
<< "\t\t\t\t\tName=\"" << *i << "|Win32\">\n" << "\t\t\t\t\tName=\"" << *i << "|Win32\">\n"
<< "\t\t\t\t\t<Tool\n" << "\t\t\t\t\t<Tool\n"
<< "\t\t\t\t\tName=\"VCCLCompilerTool\"\n" << "\t\t\t\t\tName=\"VCCLCompilerTool\"\n";
<< "\t\t\t\t\tAdditionalOptions=\"" if(compileFlags)
<< compileFlags << "\"/>\n" {
fout << "\t\t\t\t\tAdditionalOptions=\""
<< compileFlags << "\"\n";
}
if(additionalDeps.length())
{
fout << "\t\t\t\t\tAdditionalDependencies=\""
<< additionalDeps.c_str() << "\"\n";
}
fout << "\t\t\t\t\t/>\n"
<< "\t\t\t\t</FileConfiguration>\n"; << "\t\t\t\t</FileConfiguration>\n";
} }
} }
@ -783,7 +813,7 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(std::ostream& fout,
{ {
first = false; first = false;
} }
fout << output->c_str(); fout << this->ConvertToXMLOutputPath(output->c_str());
} }
fout << "\"/>\n"; fout << "\"/>\n";
fout << "\t\t\t\t</FileConfiguration>\n"; fout << "\t\t\t\t</FileConfiguration>\n";

View File

@ -64,6 +64,19 @@ bool cmSetSourceFilesPropertiesCommand::InitialPass(
} }
propertyPairs.push_back(*j); propertyPairs.push_back(*j);
} }
else if(*j == "OBJECT_DEPENDS")
{
doingFiles = false;
propertyPairs.push_back("OBJECT_DEPENDS");
++j;
if(j == args.end())
{
this->SetError("called with incorrect number of arguments "
"OBJECT_DEPENDS with no dependencies");
return false;
}
propertyPairs.push_back(*j);
}
else if(*j == "PROPERTIES") else if(*j == "PROPERTIES")
{ {
doingFiles = false; doingFiles = false;