From b40745c925eb931d4044596018cd5079b8456ab7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Feb 2005 12:19:20 -0500 Subject: BUG: Using a better technique to produce the rule file name for a custom command when the output is not in the current directory or lower. --- Source/cmLocalUnixMakefileGenerator2.cxx | 43 +++++++++----------------------- Source/cmLocalUnixMakefileGenerator2.h | 1 - 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/Source/cmLocalUnixMakefileGenerator2.cxx b/Source/cmLocalUnixMakefileGenerator2.cxx index a8023e5..5eec9f7 100644 --- a/Source/cmLocalUnixMakefileGenerator2.cxx +++ b/Source/cmLocalUnixMakefileGenerator2.cxx @@ -659,8 +659,15 @@ cmLocalUnixMakefileGenerator2 std::string dir = "CMakeCustomRules.dir"; cmSystemTools::MakeDirectory(this->ConvertToFullPath(dir).c_str()); - // Construct the name of the rule file. - std::string customName = this->GetCustomBaseName(cc); + // Convert the output name to a relative path if possible. + std::string output = this->ConvertToRelativePath(cc.GetOutput()); + + // Construct the name of the rule file by transforming the output + // name to a valid file name. Since the output is already a file + // everything but the path characters is valid. + std::string customName = output; + cmSystemTools::ReplaceString(customName, "../", "___"); + cmSystemTools::ReplaceString(customName, "/", "_"); std::string ruleFileName = dir; ruleFileName += "/"; ruleFileName += customName; @@ -689,7 +696,7 @@ cmLocalUnixMakefileGenerator2 } this->WriteDisclaimer(ruleFileStream); ruleFileStream - << "# Custom command rule file for " << customName.c_str() << ".\n\n"; + << "# Custom command rule file for " << output.c_str() << ".\n\n"; // Collect the commands. std::vector commands; @@ -709,13 +716,13 @@ cmLocalUnixMakefileGenerator2 comment = cc.GetComment(); } std::string preEcho = "Generating "; - preEcho += customName; + preEcho += output; preEcho += "..."; this->WriteMakeRule(ruleFileStream, comment, preEcho.c_str(), cc.GetOutput(), depends, commands); // Write the clean rule for this custom command. - std::string cleanTarget = customName; + std::string cleanTarget = output; cleanTarget += ".clean"; commands.clear(); depends.clear(); @@ -2281,32 +2288,6 @@ cmLocalUnixMakefileGenerator2 } //---------------------------------------------------------------------------- -std::string -cmLocalUnixMakefileGenerator2 -::GetCustomBaseName(const cmCustomCommand& cc) -{ - // If the full path to the output file includes this build - // directory, we want to use the relative path for the filename of - // the custom file. Otherwise, we will use just the filename - // portion. - std::string customName; - if(cmSystemTools::FileIsFullPath(cc.GetOutput()) && - (std::string(cc.GetOutput()).find(m_Makefile->GetStartOutputDirectory()) == 0)) - { - // Use the relative path but convert it to a valid file name. - customName = - cmSystemTools::RelativePath(m_Makefile->GetStartOutputDirectory(), - cc.GetOutput()); - cmSystemTools::ReplaceString(customName, "/", "_"); - } - else - { - customName = cmSystemTools::GetFilenameName(cc.GetOutput()); - } - return customName; -} - -//---------------------------------------------------------------------------- const char* cmLocalUnixMakefileGenerator2 ::GetSourceFileLanguage(const cmSourceFile& source) diff --git a/Source/cmLocalUnixMakefileGenerator2.h b/Source/cmLocalUnixMakefileGenerator2.h index ed83081..efa03cd 100644 --- a/Source/cmLocalUnixMakefileGenerator2.h +++ b/Source/cmLocalUnixMakefileGenerator2.h @@ -196,7 +196,6 @@ protected: std::string GetSubdirTargetName(const char* pass, const char* subdir); std::string GetObjectFileName(const cmTarget& target, const cmSourceFile& source); - std::string GetCustomBaseName(const cmCustomCommand& cc); const char* GetSourceFileLanguage(const cmSourceFile& source); std::string ConvertToFullPath(const std::string& localPath); std::string ConvertToRelativePath(const char* p); -- cgit v0.12