diff options
author | Brad King <brad.king@kitware.com> | 2019-02-25 13:00:07 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-02-25 13:00:59 (GMT) |
commit | ac419931eed3e62cc69762a2a8b8dd76192999c0 (patch) | |
tree | 0215a41d21da06d752092b234f7a9753252f326a | |
parent | 0476d16589cf62bc631acc2f50ff2a0525b6d641 (diff) | |
parent | 001446126e71b3829855aac29048999b7a4ce6f4 (diff) | |
download | CMake-ac419931eed3e62cc69762a2a8b8dd76192999c0.zip CMake-ac419931eed3e62cc69762a2a8b8dd76192999c0.tar.gz CMake-ac419931eed3e62cc69762a2a8b8dd76192999c0.tar.bz2 |
Merge topic 'swift-partials'
001446126e Ninja: add final placeholders to merge Swift partials
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2998
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 33 | ||||
-rw-r--r-- | Source/cmRulePlaceholderExpander.cxx | 15 | ||||
-rw-r--r-- | Source/cmRulePlaceholderExpander.h | 3 |
3 files changed, 51 insertions, 0 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 3784313..9def1f4 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -283,6 +283,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()); vars.Language = this->TargetLinkLanguage.c_str(); + if (this->TargetLinkLanguage == "Swift") { + vars.SwiftPartialModules = "$SWIFT_PARTIAL_MODULES"; + vars.TargetSwiftModule = "$TARGET_SWIFT_MODULE"; + vars.TargetSwiftDoc = "$TARGET_SWIFT_DOC"; + } std::string responseFlag; if (!useResponseFile) { @@ -787,6 +792,34 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmNinjaDeps outputs; outputs.push_back(targetOutputReal); + if (this->TargetLinkLanguage == "Swift") { + if (const char* name = gt.GetProperty("SWIFT_MODULE_NAME")) { + vars["TARGET_SWIFT_DOC"] = std::string(name) + ".swiftdoc"; + vars["TARGET_SWIFT_MODULE"] = std::string(name) + ".swiftmodule"; + } else { + vars["TARGET_SWIFT_DOC"] = gt.GetName() + ".swiftdoc"; + vars["TARGET_SWIFT_MODULE"] = gt.GetName() + ".swiftmodule"; + } + outputs.push_back(vars["TARGET_SWIFT_DOC"]); + outputs.push_back(vars["TARGET_SWIFT_MODULE"]); + + cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator(); + + std::string partials; + std::vector<cmSourceFile const*> sources; + gt.GetObjectSources(sources, this->GetConfigName()); + for (cmSourceFile const* source : sources) { + partials += " "; + if (const char* partial = source->GetProperty("SWIFT_PARTIAL_MODULE")) { + partials += partial; + } else { + partials += localGen.GetTargetDirectory(>) + "/" + + gt.GetObjectName(source) + ".swiftmodule"; + } + } + vars["SWIFT_PARTIAL_MODULES"] = partials; + } + // Compute specific libraries to link with. cmNinjaDeps explicitDeps = this->GetObjects(); cmNinjaDeps implicitDeps = this->ComputeLinkDeps(this->TargetLinkLanguage); diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index 18d00b1..309ee30 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -187,6 +187,21 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable( return replaceValues.SwiftPartialModule; } } + if (replaceValues.SwiftPartialModules) { + if (variable == "SWIFT_PARTIAL_MODULES") { + return replaceValues.SwiftPartialModules; + } + } + if (replaceValues.TargetSwiftDoc) { + if (variable == "TARGET_SWIFT_DOC") { + return replaceValues.TargetSwiftDoc; + } + } + if (replaceValues.TargetSwiftModule) { + if (variable == "TARGET_SWIFT_MODULE") { + return replaceValues.TargetSwiftModule; + } + } if (variable == "TARGET_SONAME" || variable == "SONAME_FLAG" || variable == "TARGET_INSTALLNAME_DIR") { // All these variables depend on TargetSOName diff --git a/Source/cmRulePlaceholderExpander.h b/Source/cmRulePlaceholderExpander.h index 93d0577..ebd4d41 100644 --- a/Source/cmRulePlaceholderExpander.h +++ b/Source/cmRulePlaceholderExpander.h @@ -63,6 +63,9 @@ public: const char* SwiftLibraryName; const char* SwiftPartialModule; const char* SwiftPartialDoc; + const char* TargetSwiftModule; + const char* TargetSwiftDoc; + const char* SwiftPartialModules; }; // Expand rule variables in CMake of the type found in language rules |