mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-06 22:30:07 -05:00
Ninja: add properties for Swift partial module and doc
When building a swift object, we emit a partial swiftmodule and swiftdoc that must be merged at the end. However, in order to do that, we need to enumerate the swiftmodules and swiftdocs. As a result, the path must be known to CMake. Rather than hardcoding the rules into CMake, create a source property that we can query. This will allow us to create a final placeholder to emit the merge rule. Issue: #18800
This commit is contained in:
@@ -455,6 +455,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
|
||||
vars.SwiftAuxiliarySources = "$SWIFT_AUXILIARY_SOURCES";
|
||||
vars.SwiftModuleName = "$SWIFT_MODULE_NAME";
|
||||
vars.SwiftLibraryName = "$SWIFT_LIBRARY_NAME";
|
||||
vars.SwiftPartialModule = "$SWIFT_PARTIAL_MODULE";
|
||||
vars.SwiftPartialDoc = "$SWIFT_PARTIAL_DOC";
|
||||
}
|
||||
|
||||
// For some cases we do an explicit preprocessor invocation.
|
||||
@@ -945,6 +947,18 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
|
||||
cmGeneratorTarget::Names targetNames =
|
||||
this->GeneratorTarget->GetLibraryNames(this->GetConfigName());
|
||||
vars["SWIFT_LIBRARY_NAME"] = targetNames.Base;
|
||||
|
||||
if (const char* partial = source->GetProperty("SWIFT_PARTIAL_MODULE")) {
|
||||
vars["SWIFT_PARTIAL_MODULE"] = partial;
|
||||
} else {
|
||||
vars["SWIFT_PARTIAL_MODULE"] = objectFileName + ".swiftmodule";
|
||||
}
|
||||
|
||||
if (const char* partial = source->GetProperty("SWIFT_PARTIAL_DOC")) {
|
||||
vars["SWIFT_PARTIAL_DOC"] = partial;
|
||||
} else {
|
||||
vars["SWIFT_PARTIAL_DOC"] = objectFileName + ".swiftdoc";
|
||||
}
|
||||
}
|
||||
|
||||
if (!this->NeedDepTypeMSVC(language)) {
|
||||
|
||||
@@ -177,6 +177,16 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable(
|
||||
return replaceValues.SwiftLibraryName;
|
||||
}
|
||||
}
|
||||
if (replaceValues.SwiftPartialDoc) {
|
||||
if (variable == "SWIFT_PARTIAL_DOC") {
|
||||
return replaceValues.SwiftPartialDoc;
|
||||
}
|
||||
}
|
||||
if (replaceValues.SwiftPartialModule) {
|
||||
if (variable == "SWIFT_PARTIAL_MODULE") {
|
||||
return replaceValues.SwiftPartialModule;
|
||||
}
|
||||
}
|
||||
if (variable == "TARGET_SONAME" || variable == "SONAME_FLAG" ||
|
||||
variable == "TARGET_INSTALLNAME_DIR") {
|
||||
// All these variables depend on TargetSOName
|
||||
|
||||
@@ -61,6 +61,8 @@ public:
|
||||
const char* SwiftAuxiliarySources;
|
||||
const char* SwiftModuleName;
|
||||
const char* SwiftLibraryName;
|
||||
const char* SwiftPartialModule;
|
||||
const char* SwiftPartialDoc;
|
||||
};
|
||||
|
||||
// Expand rule variables in CMake of the type found in language rules
|
||||
|
||||
Reference in New Issue
Block a user