From c6f1a11480f478b430fcb798ddeac972ec17ae6a Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Aug 2006 12:00:27 -0400 Subject: [PATCH] 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. --- Source/cmGlobalUnixMakefileGenerator3.cxx | 5 +++-- Source/cmLocalUnixMakefileGenerator3.cxx | 23 ++++++++++++++++++----- Source/cmLocalUnixMakefileGenerator3.h | 15 ++++++++++++--- Source/cmMakefileTargetGenerator.cxx | 10 +++++++--- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 4be5cd58a..255b1a3f6 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -1231,9 +1231,10 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule } } } - std::map > const& objs = + typedef cmLocalUnixMakefileGenerator3::LocalObjectInfo LocalObjectInfo; + std::map const& objs = lg->GetLocalObjectFiles(); - for(std::map >::const_iterator o = + for(std::map::const_iterator o = objs.begin(); o != objs.end(); ++o) { path = "... "; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 4c5347046..525b7912b 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -288,7 +288,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() // now write out the object rules // for each object file name - for (std::map >::iterator lo = + for (std::map::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::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& targets) + LocalObjectInfo const& targets) { // Recursively make the rule for each target using the object file. std::vector commands; - for(std::vector::iterator t = targets.begin(); + for(std::vector::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 += "/"; diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 89bb6421b..9bb2ab76d 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -202,7 +202,16 @@ public: // write the target rules for the local Makefile into the stream void WriteLocalAllRules(std::ostream& ruleFileStream); - std::map > 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 {}; + std::map const& GetLocalObjectFiles() { return this->LocalObjectFiles;} // return info about progress actions @@ -276,7 +285,7 @@ protected: const std::vector& objects); void WriteObjectConvenienceRule(std::ostream& ruleFileStream, const char* comment, const char* output, - std::vector& targets); + LocalObjectInfo const& targets); std::string GetObjectFileName(cmTarget& target, const cmSourceFile& source, @@ -336,7 +345,7 @@ private: bool SkipPreprocessedSourceRules; bool SkipAssemblySourceRules; - std::map > LocalObjectFiles; + std::map LocalObjectFiles; /* does the work for each target */ std::vector TargetGenerators; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 098aa427f..558a78f18 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -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) {