|
@@ -26,6 +26,7 @@
|
|
|
#include "cmGeneratorExpression.h"
|
|
#include "cmGeneratorExpression.h"
|
|
|
#include "cmGeneratorTarget.h"
|
|
#include "cmGeneratorTarget.h"
|
|
|
#include "cmGlobalNinjaGenerator.h"
|
|
#include "cmGlobalNinjaGenerator.h"
|
|
|
|
|
+#include "cmInstallFileSetGenerator.h"
|
|
|
#include "cmLocalGenerator.h"
|
|
#include "cmLocalGenerator.h"
|
|
|
#include "cmLocalNinjaGenerator.h"
|
|
#include "cmLocalNinjaGenerator.h"
|
|
|
#include "cmMakefile.h"
|
|
#include "cmMakefile.h"
|
|
@@ -1653,6 +1654,104 @@ void cmNinjaTargetGenerator::WriteTargetDependInfo(std::string const& lang,
|
|
|
tdi_linked_target_dirs.append(l);
|
|
tdi_linked_target_dirs.append(l);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ cmTarget* tgt = this->GeneratorTarget->Target;
|
|
|
|
|
+ auto all_file_sets = tgt->GetAllFileSetNames();
|
|
|
|
|
+ Json::Value& tdi_cxx_module_info = tdi["cxx-modules"] = Json::objectValue;
|
|
|
|
|
+ for (auto const& file_set_name : all_file_sets) {
|
|
|
|
|
+ auto* file_set = tgt->GetFileSet(file_set_name);
|
|
|
|
|
+ if (!file_set) {
|
|
|
|
|
+ this->GetMakefile()->IssueMessage(
|
|
|
|
|
+ MessageType::INTERNAL_ERROR,
|
|
|
|
|
+ cmStrCat("Target \"", tgt->GetName(),
|
|
|
|
|
+ "\" is tracked to have file set \"", file_set_name,
|
|
|
|
|
+ "\", but it was not found."));
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ auto fs_type = file_set->GetType();
|
|
|
|
|
+ // We only care about C++ module sources here.
|
|
|
|
|
+ if (fs_type != "CXX_MODULES"_s) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ auto fileEntries = file_set->CompileFileEntries();
|
|
|
|
|
+ auto directoryEntries = file_set->CompileDirectoryEntries();
|
|
|
|
|
+
|
|
|
|
|
+ auto directories = file_set->EvaluateDirectoryEntries(
|
|
|
|
|
+ directoryEntries, this->GeneratorTarget->LocalGenerator, config,
|
|
|
|
|
+ this->GeneratorTarget);
|
|
|
|
|
+ std::map<std::string, std::vector<std::string>> files_per_dirs;
|
|
|
|
|
+ for (auto const& entry : fileEntries) {
|
|
|
|
|
+ file_set->EvaluateFileEntry(directories, files_per_dirs, entry,
|
|
|
|
|
+ this->GeneratorTarget->LocalGenerator,
|
|
|
|
|
+ config, this->GeneratorTarget);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ std::map<std::string, cmSourceFile const*> sf_map;
|
|
|
|
|
+ {
|
|
|
|
|
+ std::vector<cmSourceFile const*> objectSources;
|
|
|
|
|
+ this->GeneratorTarget->GetObjectSources(objectSources, config);
|
|
|
|
|
+ for (auto const* sf : objectSources) {
|
|
|
|
|
+ auto full_path = sf->GetFullPath();
|
|
|
|
|
+ if (full_path.empty()) {
|
|
|
|
|
+ this->GetMakefile()->IssueMessage(
|
|
|
|
|
+ MessageType::INTERNAL_ERROR,
|
|
|
|
|
+ cmStrCat("Target \"", tgt->GetName(),
|
|
|
|
|
+ "\" has a full path-less source file."));
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ sf_map[full_path] = sf;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Json::Value fs_dest = Json::nullValue;
|
|
|
|
|
+ for (auto const& ig : this->GetMakefile()->GetInstallGenerators()) {
|
|
|
|
|
+ if (auto const* fsg =
|
|
|
|
|
+ dynamic_cast<cmInstallFileSetGenerator const*>(ig.get())) {
|
|
|
|
|
+ if (fsg->GetTarget() == this->GeneratorTarget &&
|
|
|
|
|
+ fsg->GetFileSet() == file_set) {
|
|
|
|
|
+ fs_dest = fsg->GetDestination(config);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (auto const& files_per_dir : files_per_dirs) {
|
|
|
|
|
+ for (auto const& file : files_per_dir.second) {
|
|
|
|
|
+ auto lookup = sf_map.find(file);
|
|
|
|
|
+ if (lookup == sf_map.end()) {
|
|
|
|
|
+ this->GetMakefile()->IssueMessage(
|
|
|
|
|
+ MessageType::INTERNAL_ERROR,
|
|
|
|
|
+ cmStrCat("Target \"", tgt->GetName(), "\" has source file \"",
|
|
|
|
|
+ file,
|
|
|
|
|
+ R"(" which is not in any of its "FILE_SET BASE_DIRS".)"));
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ auto const* sf = lookup->second;
|
|
|
|
|
+
|
|
|
|
|
+ if (!sf) {
|
|
|
|
|
+ this->GetMakefile()->IssueMessage(
|
|
|
|
|
+ MessageType::INTERNAL_ERROR,
|
|
|
|
|
+ cmStrCat("Target \"", tgt->GetName(), "\" has source file \"",
|
|
|
|
|
+ file, "\" which has not been tracked properly."));
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ auto obj_path = this->GetObjectFilePath(sf, config);
|
|
|
|
|
+ Json::Value& tdi_module_info = tdi_cxx_module_info[obj_path] =
|
|
|
|
|
+ Json::objectValue;
|
|
|
|
|
+
|
|
|
|
|
+ tdi_module_info["source"] = file;
|
|
|
|
|
+ tdi_module_info["relative-directory"] = files_per_dir.first;
|
|
|
|
|
+ tdi_module_info["name"] = file_set->GetName();
|
|
|
|
|
+ tdi_module_info["type"] = file_set->GetType();
|
|
|
|
|
+ tdi_module_info["visibility"] =
|
|
|
|
|
+ std::string(cmFileSetVisibilityToName(file_set->GetVisibility()));
|
|
|
|
|
+ tdi_module_info["destination"] = fs_dest;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
std::string const tdin = this->GetTargetDependInfoPath(lang, config);
|
|
std::string const tdin = this->GetTargetDependInfoPath(lang, config);
|
|
|
cmGeneratedFileStream tdif(tdin);
|
|
cmGeneratedFileStream tdif(tdin);
|
|
|
tdif << tdi;
|
|
tdif << tdi;
|