mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 19:00:54 -06:00
cmDyndepCollation: write build database metadata
Generators will hook this up into the build graph as needed.
This commit is contained in:
@@ -194,6 +194,20 @@ TdiSourceInfo CollationInformationSources(cmGeneratorTarget const* gt,
|
||||
return info;
|
||||
}
|
||||
|
||||
Json::Value CollationInformationDatabaseInfo(cmGeneratorTarget const* gt,
|
||||
std::string const& config)
|
||||
{
|
||||
Json::Value db_info;
|
||||
|
||||
auto db_path = gt->BuildDatabasePath("CXX", config);
|
||||
if (!db_path.empty()) {
|
||||
db_info["template-path"] = cmStrCat(db_path, ".in");
|
||||
db_info["output"] = db_path;
|
||||
}
|
||||
|
||||
return db_info;
|
||||
}
|
||||
|
||||
Json::Value CollationInformationBmiInstallation(cmGeneratorTarget const* gt,
|
||||
std::string const& config)
|
||||
{
|
||||
@@ -323,6 +337,7 @@ void cmDyndepCollation::AddCollationInformation(
|
||||
auto sourcesInfo = CollationInformationSources(gt, config, cb);
|
||||
tdi["sources"] = sourcesInfo.Sources;
|
||||
tdi["cxx-modules"] = sourcesInfo.CxxModules;
|
||||
tdi["database-info"] = CollationInformationDatabaseInfo(gt, config);
|
||||
tdi["bmi-installation"] = CollationInformationBmiInstallation(gt, config);
|
||||
tdi["exports"] = CollationInformationExports(gt);
|
||||
tdi["config"] = config;
|
||||
@@ -414,6 +429,15 @@ cmDyndepCollation::ParseExportInfo(Json::Value const& tdi)
|
||||
export_info->Exports.push_back(exp);
|
||||
}
|
||||
}
|
||||
auto const& database_info = tdi["database-info"];
|
||||
if (database_info.isObject()) {
|
||||
CxxModuleDatabaseInfo db_info;
|
||||
|
||||
db_info.TemplatePath = database_info["template-path"].asString();
|
||||
db_info.Output = database_info["output"].asString();
|
||||
|
||||
export_info->DatabaseInfo = db_info;
|
||||
}
|
||||
auto const& bmi_installation = tdi["bmi-installation"];
|
||||
if (bmi_installation.isObject()) {
|
||||
CxxModuleBmiInstall bmi_install;
|
||||
|
||||
@@ -5921,6 +5921,27 @@ cmGeneratorTarget::CxxModuleSupport cmGeneratorTarget::NeedCxxDyndep(
|
||||
return policyAnswer;
|
||||
}
|
||||
|
||||
std::string cmGeneratorTarget::BuildDatabasePath(
|
||||
std::string const& lang, std::string const& config) const
|
||||
{
|
||||
// Check to see if the target wants it.
|
||||
if (!this->GetPropertyAsBool("EXPORT_BUILD_DATABASE")) {
|
||||
return {};
|
||||
}
|
||||
// Check to see if the generator supports it.
|
||||
if (!this->GetGlobalGenerator()->SupportsBuildDatabase()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (this->GetGlobalGenerator()->IsMultiConfig()) {
|
||||
return cmStrCat(this->GetSupportDirectory(), '/', config, '/', lang,
|
||||
"_build_database.json");
|
||||
}
|
||||
|
||||
return cmStrCat(this->GetSupportDirectory(), '/', lang,
|
||||
"_build_database.json");
|
||||
}
|
||||
|
||||
void cmGeneratorTarget::BuildFileSetInfoCache(std::string const& config) const
|
||||
{
|
||||
auto& per_config = this->Configs[config];
|
||||
|
||||
@@ -1502,6 +1502,9 @@ public:
|
||||
};
|
||||
CxxModuleSupport NeedCxxDyndep(std::string const& config) const;
|
||||
|
||||
std::string BuildDatabasePath(std::string const& lang,
|
||||
std::string const& config) const;
|
||||
|
||||
private:
|
||||
void BuildFileSetInfoCache(std::string const& config) const;
|
||||
struct InfoByConfig
|
||||
|
||||
@@ -171,6 +171,8 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool SupportsBuildDatabase() const { return false; }
|
||||
|
||||
virtual bool IsGNUMakeJobServerAware() const { return false; }
|
||||
|
||||
bool Compute();
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
"visibility": "PRIVATE"
|
||||
}
|
||||
},
|
||||
"database-info": null,
|
||||
"dir-cur-bld": "<BINARY_DIR>",
|
||||
"dir-cur-src": "<SOURCE_DIR>",
|
||||
"dir-top-bld": "<BINARY_DIR>",
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
"visibility": "PUBLIC"
|
||||
}
|
||||
},
|
||||
"database-info": null,
|
||||
"dir-cur-bld": "<BINARY_DIR>",
|
||||
"dir-cur-src": "<SOURCE_DIR>",
|
||||
"dir-top-bld": "<BINARY_DIR>",
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"visibility": "PRIVATE"
|
||||
}
|
||||
},
|
||||
"database-info": null,
|
||||
"dir-cur-bld": "<BINARY_DIR>",
|
||||
"dir-cur-src": "<SOURCE_DIR>",
|
||||
"dir-top-bld": "<BINARY_DIR>",
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"visibility": "PUBLIC"
|
||||
}
|
||||
},
|
||||
"database-info": null,
|
||||
"dir-cur-bld": "<BINARY_DIR>",
|
||||
"dir-cur-src": "<SOURCE_DIR>",
|
||||
"dir-top-bld": "<BINARY_DIR>",
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"visibility": "PRIVATE"
|
||||
}
|
||||
},
|
||||
"database-info": null,
|
||||
"dir-cur-bld": "<BINARY_DIR>",
|
||||
"dir-cur-src": "<SOURCE_DIR>",
|
||||
"dir-top-bld": "<BINARY_DIR>",
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"visibility": "PUBLIC"
|
||||
}
|
||||
},
|
||||
"database-info": null,
|
||||
"dir-cur-bld": "<BINARY_DIR>",
|
||||
"dir-cur-src": "<SOURCE_DIR>",
|
||||
"dir-top-bld": "<BINARY_DIR>",
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"visibility": "PRIVATE"
|
||||
}
|
||||
},
|
||||
"database-info": null,
|
||||
"dir-cur-bld": "<BINARY_DIR>",
|
||||
"dir-cur-src": "<SOURCE_DIR>",
|
||||
"dir-top-bld": "<BINARY_DIR>",
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"visibility": "PUBLIC"
|
||||
}
|
||||
},
|
||||
"database-info": null,
|
||||
"dir-cur-bld": "<BINARY_DIR>",
|
||||
"dir-cur-src": "<SOURCE_DIR>",
|
||||
"dir-top-bld": "<BINARY_DIR>",
|
||||
|
||||
Reference in New Issue
Block a user