summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaTargetGenerator.cxx
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2019-01-12 00:36:49 (GMT)
committerSaleem Abdulrasool <compnerd@compnerd.org>2019-01-15 17:13:33 (GMT)
commitb90e6134a7af7d6f81a410fac52f17c7585509eb (patch)
tree4b5ee320cbfcbb59df1aff3eb177ca139d3a30a5 /Source/cmNinjaTargetGenerator.cxx
parentd4a42dd4a87c9caa222a7a40150db937258698d2 (diff)
downloadCMake-b90e6134a7af7d6f81a410fac52f17c7585509eb.zip
CMake-b90e6134a7af7d6f81a410fac52f17c7585509eb.tar.gz
CMake-b90e6134a7af7d6f81a410fac52f17c7585509eb.tar.bz2
Ninja: add new placeholder `SWIFT_AUXILIARY_SOURCES`
The swift compilation model requires all sources for the module to be listed for the compiler to type check across them. Provide a placeholder to allow enumerating the remainder of the swift sources in a target for the language compile rule. Issue: #18800
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaTargetGenerator.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 1ef12d0..5013be5 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -19,6 +19,7 @@
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalNinjaGenerator.h"
+#include "cmListFileCache.h" // for BT
#include "cmLocalGenerator.h"
#include "cmLocalNinjaGenerator.h"
#include "cmMakefile.h"
@@ -430,6 +431,9 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
vars.TargetCompilePDB = "$TARGET_COMPILE_PDB";
vars.ObjectDir = "$OBJECT_DIR";
vars.ObjectFileDir = "$OBJECT_FILE_DIR";
+ if (lang == "Swift") {
+ vars.SwiftAuxiliarySources = "$SWIFT_AUXILIARY_SOURCES";
+ }
// For some cases we do an explicit preprocessor invocation.
bool const explicitPP = this->NeedExplicitPreprocessing(lang);
@@ -900,6 +904,20 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
vars["FLAGS"] = this->ComputeFlagsForObject(source, language);
vars["DEFINES"] = this->ComputeDefines(source, language);
vars["INCLUDES"] = this->ComputeIncludes(source, language);
+ // The swift compiler needs all the sources besides the one being compiled in
+ // order to do the type checking. List all these "auxiliary" sources.
+ if (language == "Swift") {
+ std::string aux_sources;
+ cmGeneratorTarget::KindedSources const& sources =
+ this->GeneratorTarget->GetKindedSources(this->GetConfigName());
+ for (cmGeneratorTarget::SourceAndKind const& src : sources.Sources) {
+ if (src.Source.Value == source) {
+ continue;
+ }
+ aux_sources += " " + this->GetSourceFilePath(src.Source.Value);
+ }
+ vars["SWIFT_AUXILIARY_SOURCES"] = aux_sources;
+ }
if (!this->NeedDepTypeMSVC(language)) {
bool replaceExt(false);