summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaNormalTargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmNinjaNormalTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx105
1 files changed, 77 insertions, 28 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index f8a13ce..1221a3f 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -282,10 +282,13 @@ 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";
+ vars.SwiftLibraryName = "$SWIFT_LIBRARY_NAME";
+ vars.SwiftModule = "$SWIFT_MODULE";
+ vars.SwiftModuleName = "$SWIFT_MODULE_NAME";
+ vars.SwiftOutputFileMap = "$SWIFT_OUTPUT_FILE_MAP";
+ vars.SwiftSources = "$SWIFT_SOURCES";
}
std::string responseFlag;
@@ -583,7 +586,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
// First and very important step is to make sure while inside this
// step our link language is set to CUDA
std::string cudaLinkLanguage = "CUDA";
- std::string const objExt =
+ std::string const& objExt =
this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION");
std::string const cfgName = this->GetConfigName();
@@ -783,35 +786,79 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
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"]);
+ vars["SWIFT_LIBRARY_NAME"] = [this]() -> std::string {
+ cmGeneratorTarget::Names targetNames =
+ this->GetGeneratorTarget()->GetLibraryNames(this->GetConfigName());
+ return targetNames.Base;
+ }();
+
+ vars["SWIFT_MODULE_NAME"] = [this]() -> std::string {
+ if (const char* name =
+ this->GetGeneratorTarget()->GetProperty("Swift_MODULE_NAME")) {
+ return name;
+ }
+ return this->GetGeneratorTarget()->GetName();
+ }();
+
+ vars["SWIFT_MODULE"] = [this](const std::string& module) -> std::string {
+ std::string directory =
+ this->GetLocalGenerator()->GetCurrentBinaryDirectory();
+ if (const char* prop = this->GetGeneratorTarget()->GetProperty(
+ "Swift_MODULE_DIRECTORY")) {
+ directory = prop;
+ }
- cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator();
+ std::string name = module + ".swiftmodule";
+ if (const char* prop =
+ this->GetGeneratorTarget()->GetProperty("Swift_MODULE")) {
+ name = prop;
+ }
- 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) + "/" +
- gt.GetObjectName(source) + ".swiftmodule";
+ return this->GetLocalGenerator()->ConvertToOutputFormat(
+ this->ConvertToNinjaPath(directory + "/" + name),
+ cmOutputConverter::SHELL);
+ }(vars["SWIFT_MODULE_NAME"]);
+
+ vars["SWIFT_OUTPUT_FILE_MAP"] =
+ this->GetLocalGenerator()->ConvertToOutputFormat(
+ this->ConvertToNinjaPath(gt.GetSupportDirectory() +
+ "/output-file-map.json"),
+ cmOutputConverter::SHELL);
+
+ vars["SWIFT_SOURCES"] = [this]() -> std::string {
+ std::vector<cmSourceFile const*> sources;
+ std::stringstream oss;
+
+ this->GetGeneratorTarget()->GetObjectSources(sources,
+ this->GetConfigName());
+ cmLocalGenerator const* LocalGen = this->GetLocalGenerator();
+ for (const auto& source : sources) {
+ oss << " "
+ << LocalGen->ConvertToOutputFormat(
+ this->ConvertToNinjaPath(this->GetSourceFilePath(source)),
+ cmOutputConverter::SHELL);
}
- }
- vars["SWIFT_PARTIAL_MODULES"] = partials;
+ return oss.str();
+ }();
}
// Compute specific libraries to link with.
- cmNinjaDeps explicitDeps = this->GetObjects();
+ cmNinjaDeps explicitDeps;
+ if (this->TargetLinkLanguage == "Swift") {
+ std::vector<cmSourceFile const*> sources;
+ this->GetGeneratorTarget()->GetObjectSources(sources,
+ this->GetConfigName());
+ for (const auto& source : sources) {
+ outputs.push_back(
+ this->ConvertToNinjaPath(this->GetObjectFilePath(source)));
+ explicitDeps.push_back(
+ this->ConvertToNinjaPath(this->GetSourceFilePath(source)));
+ }
+
+ outputs.push_back(vars["SWIFT_MODULE"]);
+ } else {
+ explicitDeps = this->GetObjects();
+ }
cmNinjaDeps implicitDeps = this->ComputeLinkDeps(this->TargetLinkLanguage);
if (!this->DeviceLinkObject.empty()) {
@@ -1060,7 +1107,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
this->GetTargetFilePath(this->TargetNames.SharedObject));
// If one link has to be created.
if (targetOutputReal == soName || targetOutput == soName) {
- symlinkVars["SONAME"] = soName;
+ symlinkVars["SONAME"] =
+ this->GetLocalGenerator()->ConvertToOutputFormat(
+ soName, cmOutputConverter::SHELL);
} else {
symlinkVars["SONAME"].clear();
symlinks.push_back(soName);