diff options
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 228c9fb..c959a04 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -10,6 +10,7 @@ #include <map> #include <memory> // IWYU pragma: keep #include <sstream> +#include <utility> #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" @@ -18,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" @@ -429,6 +431,10 @@ 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"; + vars.SwiftModuleName = "$SWIFT_MODULE_NAME"; + } // For some cases we do an explicit preprocessor invocation. bool const explicitPP = this->NeedExplicitPreprocessing(lang); @@ -899,6 +905,22 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( vars["FLAGS"] = this->ComputeFlagsForObject(source, language); vars["DEFINES"] = this->ComputeDefines(source, language); vars["INCLUDES"] = this->ComputeIncludes(source, language); + if (language == "Swift") { + // The swift compiler needs all the sources besides the one being compiled + // in order to do the type checking. List all these "auxiliary" sources. + 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; + + vars["SWIFT_MODULE_NAME"] = this->GeneratorTarget->GetName(); + } if (!this->NeedDepTypeMSVC(language)) { bool replaceExt(false); |