瀏覽代碼

Add placeholder for Swift's library name

This allows us to set the proper link name for the Swift library
(soname).  Because this needs to be passed to the object being compiled,
we need to create a new placeholder so that it can be sent along to the
frontend.  Default to the target name unless it is explicitly provided.
Saleem Abdulrasool 6 年之前
父節點
當前提交
157570b5a2
共有 3 個文件被更改,包括 11 次插入0 次删除
  1. 5 0
      Source/cmNinjaTargetGenerator.cxx
  2. 5 0
      Source/cmRulePlaceholderExpander.cxx
  3. 1 0
      Source/cmRulePlaceholderExpander.h

+ 5 - 0
Source/cmNinjaTargetGenerator.cxx

@@ -454,6 +454,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
   if (lang == "Swift") {
   if (lang == "Swift") {
     vars.SwiftAuxiliarySources = "$SWIFT_AUXILIARY_SOURCES";
     vars.SwiftAuxiliarySources = "$SWIFT_AUXILIARY_SOURCES";
     vars.SwiftModuleName = "$SWIFT_MODULE_NAME";
     vars.SwiftModuleName = "$SWIFT_MODULE_NAME";
+    vars.SwiftLibraryName = "$SWIFT_LIBRARY_NAME";
   }
   }
 
 
   // For some cases we do an explicit preprocessor invocation.
   // For some cases we do an explicit preprocessor invocation.
@@ -940,6 +941,10 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
     } else {
     } else {
       vars["SWIFT_MODULE_NAME"] = this->GeneratorTarget->GetName();
       vars["SWIFT_MODULE_NAME"] = this->GeneratorTarget->GetName();
     }
     }
+
+    cmGeneratorTarget::Names targetNames =
+      this->GeneratorTarget->GetLibraryNames(this->GetConfigName());
+    vars["SWIFT_LIBRARY_NAME"] = targetNames.Base;
   }
   }
 
 
   if (!this->NeedDepTypeMSVC(language)) {
   if (!this->NeedDepTypeMSVC(language)) {

+ 5 - 0
Source/cmRulePlaceholderExpander.cxx

@@ -172,6 +172,11 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable(
       return replaceValues.SwiftModuleName;
       return replaceValues.SwiftModuleName;
     }
     }
   }
   }
+  if (replaceValues.SwiftLibraryName) {
+    if (variable == "SWIFT_LIBRARY_NAME") {
+      return replaceValues.SwiftLibraryName;
+    }
+  }
   if (variable == "TARGET_SONAME" || variable == "SONAME_FLAG" ||
   if (variable == "TARGET_SONAME" || variable == "SONAME_FLAG" ||
       variable == "TARGET_INSTALLNAME_DIR") {
       variable == "TARGET_INSTALLNAME_DIR") {
     // All these variables depend on TargetSOName
     // All these variables depend on TargetSOName

+ 1 - 0
Source/cmRulePlaceholderExpander.h

@@ -60,6 +60,7 @@ public:
     const char* FilterPrefix;
     const char* FilterPrefix;
     const char* SwiftAuxiliarySources;
     const char* SwiftAuxiliarySources;
     const char* SwiftModuleName;
     const char* SwiftModuleName;
+    const char* SwiftLibraryName;
   };
   };
 
 
   // Expand rule variables in CMake of the type found in language rules
   // Expand rule variables in CMake of the type found in language rules