BUG: Added object language to list of object files in a local generator's directory. Fixed generation of preprocessing and assembly rules to be done only for C and C++ objects.

This commit is contained in:
Brad King 2006-08-15 12:00:27 -04:00
parent 7169980b59
commit c6f1a11480
4 changed files with 40 additions and 13 deletions

View File

@ -1231,9 +1231,10 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule
}
}
}
std::map<cmStdString,std::vector<cmTarget *> > const& objs =
typedef cmLocalUnixMakefileGenerator3::LocalObjectInfo LocalObjectInfo;
std::map<cmStdString, LocalObjectInfo> const& objs =
lg->GetLocalObjectFiles();
for(std::map<cmStdString,std::vector<cmTarget *> >::const_iterator o =
for(std::map<cmStdString, LocalObjectInfo>::const_iterator o =
objs.begin(); o != objs.end(); ++o)
{
path = "... ";

View File

@ -288,7 +288,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
// now write out the object rules
// for each object file name
for (std::map<cmStdString,std::vector<cmTarget *> >::iterator lo =
for (std::map<cmStdString, LocalObjectInfo>::iterator lo =
this->LocalObjectFiles.begin();
lo != this->LocalObjectFiles.end(); ++lo)
{
@ -297,8 +297,20 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
"target to build an object file",
lo->first.c_str(), lo->second);
// Check whether preprocessing and assembly rules make sense.
// They make sense only for C and C++ sources.
bool lang_is_c_or_cxx = false;
for(std::vector<LocalObjectEntry>::const_iterator ei =
lo->second.begin(); ei != lo->second.end(); ++ei)
{
if(ei->Language == "C" || ei->Language == "CXX")
{
lang_is_c_or_cxx = true;
}
}
// Add convenience rules for preprocessed and assembly files.
if(do_preprocess_rules || do_assembly_rules)
if(lang_is_c_or_cxx && (do_preprocess_rules || do_assembly_rules))
{
std::string::size_type dot_pos = lo->first.rfind(".");
std::string base = lo->first.substr(0, dot_pos);
@ -333,14 +345,15 @@ void
cmLocalUnixMakefileGenerator3
::WriteObjectConvenienceRule(std::ostream& ruleFileStream,
const char* comment, const char* output,
std::vector<cmTarget*>& targets)
LocalObjectInfo const& targets)
{
// Recursively make the rule for each target using the object file.
std::vector<std::string> commands;
for(std::vector<cmTarget*>::iterator t = targets.begin();
for(std::vector<LocalObjectEntry>::const_iterator t = targets.begin();
t != targets.end(); ++t)
{
std::string tgtMakefileName = this->GetRelativeTargetDirectory(**t);
std::string tgtMakefileName =
this->GetRelativeTargetDirectory(*(t->Target));
std::string targetName = tgtMakefileName;
tgtMakefileName += "/build.make";
targetName += "/";

View File

@ -202,7 +202,16 @@ public:
// write the target rules for the local Makefile into the stream
void WriteLocalAllRules(std::ostream& ruleFileStream);
std::map<cmStdString,std::vector<cmTarget *> > GetLocalObjectFiles()
struct LocalObjectEntry
{
cmTarget* Target;
std::string Language;
LocalObjectEntry(): Target(0), Language() {}
LocalObjectEntry(cmTarget* t, const char* lang):
Target(t), Language(lang) {}
};
class LocalObjectInfo: public std::vector<LocalObjectEntry> {};
std::map<cmStdString, LocalObjectInfo> const& GetLocalObjectFiles()
{ return this->LocalObjectFiles;}
// return info about progress actions
@ -276,7 +285,7 @@ protected:
const std::vector<std::string>& objects);
void WriteObjectConvenienceRule(std::ostream& ruleFileStream,
const char* comment, const char* output,
std::vector<cmTarget*>& targets);
LocalObjectInfo const& targets);
std::string GetObjectFileName(cmTarget& target,
const cmSourceFile& source,
@ -336,7 +345,7 @@ private:
bool SkipPreprocessedSourceRules;
bool SkipAssemblySourceRules;
std::map<cmStdString,std::vector<cmTarget *> > LocalObjectFiles;
std::map<cmStdString, LocalObjectInfo> LocalObjectFiles;
/* does the work for each target */
std::vector<cmMakefileTargetGenerator *> TargetGenerators;

View File

@ -350,7 +350,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
objNoTargetDir = cmSystemTools::GetFilenameName(objNoTargetDir);
}
this->LocalGenerator->LocalObjectFiles[objNoTargetDir].
push_back(this->Target);
push_back(
cmLocalUnixMakefileGenerator3::LocalObjectEntry(this->Target, lang)
);
}
//----------------------------------------------------------------------------
@ -495,9 +497,11 @@ cmMakefileTargetGenerator
relativeObj.c_str(),
depends, commands, false);
bool do_preprocess_rules =
bool lang_is_c_or_cxx = ((strcmp(lang, "C") == 0) ||
(strcmp(lang, "CXX") == 0));
bool do_preprocess_rules = lang_is_c_or_cxx &&
this->LocalGenerator->GetCreatePreprocessedSourceRules();
bool do_assembly_rules =
bool do_assembly_rules = lang_is_c_or_cxx &&
this->LocalGenerator->GetCreateAssemblySourceRules();
if(do_preprocess_rules || do_assembly_rules)
{