浏览代码

Merge topic 'ninja-no-ranlib-windows'

ea598671 Run ranlib on archives only if the tool is available
Brad King 9 年之前
父节点
当前提交
8f3bd1f454
共有 2 个文件被更改,包括 19 次插入1 次删除
  1. 4 1
      Source/cmMakefileLibraryTargetGenerator.cxx
  2. 15 0
      Source/cmNinjaNormalTargetGenerator.cxx

+ 4 - 1
Source/cmMakefileLibraryTargetGenerator.cxx

@@ -676,7 +676,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
            i != archiveFinishCommands.end(); ++i) {
         std::string cmd = *i;
         this->LocalGenerator->ExpandRuleVariables(cmd, vars);
-        real_link_commands.push_back(cmd);
+        // If there is no ranlib the command will be ":".  Skip it.
+        if (!cmd.empty() && cmd[0] != ':') {
+          real_link_commands.push_back(cmd);
+        }
       }
     } else {
       // Get the set of commands.

+ 15 - 0
Source/cmNinjaNormalTargetGenerator.cxx

@@ -144,6 +144,14 @@ std::string cmNinjaNormalTargetGenerator::LanguageLinkerRule() const
                     this->GetGeneratorTarget()->GetName());
 }
 
+struct cmNinjaRemoveNoOpCommands
+{
+  bool operator()(std::string const& cmd)
+  {
+    return cmd.empty() || cmd[0] == ':';
+  }
+};
+
 void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
 {
   cmState::TargetType targetType = this->GetGeneratorTarget()->GetType();
@@ -231,6 +239,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
          i != linkCmds.end(); ++i) {
       this->GetLocalGenerator()->ExpandRuleVariables(*i, vars);
     }
+    {
+      // If there is no ranlib the command will be ":".  Skip it.
+      std::vector<std::string>::iterator newEnd = std::remove_if(
+        linkCmds.begin(), linkCmds.end(), cmNinjaRemoveNoOpCommands());
+      linkCmds.erase(newEnd, linkCmds.end());
+    }
+
     linkCmds.insert(linkCmds.begin(), "$PRE_LINK");
     linkCmds.push_back("$POST_BUILD");
     std::string linkCmd =