mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-06 14:48:38 -06:00
cmGlobalNinjaGenerator: generate install rules for BMI files
This commit is contained in:
@@ -2494,6 +2494,17 @@ struct CxxModuleFileSet
|
|||||||
cm::optional<std::string> Destination;
|
cm::optional<std::string> Destination;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct CxxModuleBmiInstall
|
||||||
|
{
|
||||||
|
std::string Component;
|
||||||
|
std::string Destination;
|
||||||
|
bool ExcludeFromAll;
|
||||||
|
bool Optional;
|
||||||
|
std::string Permissions;
|
||||||
|
std::string MessageLevel;
|
||||||
|
std::string ScriptLocation;
|
||||||
|
};
|
||||||
|
|
||||||
struct CxxModuleExport
|
struct CxxModuleExport
|
||||||
{
|
{
|
||||||
std::string Name;
|
std::string Name;
|
||||||
@@ -2507,6 +2518,7 @@ struct CxxModuleExport
|
|||||||
struct cmGlobalNinjaGenerator::CxxModuleExportInfo
|
struct cmGlobalNinjaGenerator::CxxModuleExportInfo
|
||||||
{
|
{
|
||||||
std::map<std::string, CxxModuleFileSet> ObjectToFileSet;
|
std::map<std::string, CxxModuleFileSet> ObjectToFileSet;
|
||||||
|
cm::optional<CxxModuleBmiInstall> BmiInstallation;
|
||||||
std::vector<CxxModuleExport> Exports;
|
std::vector<CxxModuleExport> Exports;
|
||||||
std::string Config;
|
std::string Config;
|
||||||
};
|
};
|
||||||
@@ -2695,6 +2707,12 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
|
|||||||
exports.emplace_back(std::move(properties), &exp);
|
exports.emplace_back(std::move(properties), &exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<cmGeneratedFileStream> bmi_install_script;
|
||||||
|
if (export_info.BmiInstallation) {
|
||||||
|
bmi_install_script = cm::make_unique<cmGeneratedFileStream>(
|
||||||
|
export_info.BmiInstallation->ScriptLocation);
|
||||||
|
}
|
||||||
|
|
||||||
auto cmEscape = [](cm::string_view str) {
|
auto cmEscape = [](cm::string_view str) {
|
||||||
return cmOutputConverter::EscapeForCMake(
|
return cmOutputConverter::EscapeForCMake(
|
||||||
str, cmOutputConverter::WrapQuotes::NoWrap);
|
str, cmOutputConverter::WrapQuotes::NoWrap);
|
||||||
@@ -2796,11 +2814,24 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write out properties for any exports.
|
// Write out properties and install rules for any exports.
|
||||||
for (auto const& p : object.Provides) {
|
for (auto const& p : object.Provides) {
|
||||||
|
bool bmi_dest_is_abs = false;
|
||||||
|
std::string bmi_destination;
|
||||||
|
if (export_info.BmiInstallation) {
|
||||||
|
auto dest =
|
||||||
|
install_destination(export_info.BmiInstallation->Destination);
|
||||||
|
bmi_dest_is_abs = dest.first;
|
||||||
|
bmi_destination = cmStrCat(dest.second, '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string install_bmi_path;
|
||||||
std::string build_bmi_path;
|
std::string build_bmi_path;
|
||||||
auto m = mod_files.find(p.LogicalName);
|
auto m = mod_files.find(p.LogicalName);
|
||||||
if (m != mod_files.end()) {
|
if (m != mod_files.end()) {
|
||||||
|
install_bmi_path =
|
||||||
|
cmStrCat(bmi_destination,
|
||||||
|
cmEscape(cmSystemTools::GetFilenameName(m->second)));
|
||||||
build_bmi_path = cmEscape(m->second);
|
build_bmi_path = cmEscape(m->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2816,7 +2847,9 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string bmi_path;
|
std::string bmi_path;
|
||||||
if (!exp.second->Install) {
|
if (exp.second->Install && export_info.BmiInstallation) {
|
||||||
|
bmi_path = install_bmi_path;
|
||||||
|
} else if (!exp.second->Install) {
|
||||||
bmi_path = build_bmi_path;
|
bmi_path = build_bmi_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2833,6 +2866,54 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
|
|||||||
}
|
}
|
||||||
*exp.first << "\"\n";
|
*exp.first << "\"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bmi_install_script) {
|
||||||
|
auto const& bmi_install = *export_info.BmiInstallation;
|
||||||
|
|
||||||
|
*bmi_install_script << "if (CMAKE_INSTALL_COMPONENT STREQUAL \""
|
||||||
|
<< cmEscape(bmi_install.Component) << '\"';
|
||||||
|
if (!bmi_install.ExcludeFromAll) {
|
||||||
|
*bmi_install_script << " OR NOT CMAKE_INSTALL_COMPONENT";
|
||||||
|
}
|
||||||
|
*bmi_install_script << ")\n";
|
||||||
|
*bmi_install_script << " file(INSTALL\n"
|
||||||
|
" DESTINATION \"";
|
||||||
|
if (!bmi_dest_is_abs) {
|
||||||
|
*bmi_install_script << "${CMAKE_INSTALL_PREFIX}/";
|
||||||
|
}
|
||||||
|
*bmi_install_script << cmEscape(bmi_install.Destination)
|
||||||
|
<< "\"\n"
|
||||||
|
" TYPE FILE\n";
|
||||||
|
if (bmi_install.Optional) {
|
||||||
|
*bmi_install_script << " OPTIONAL\n";
|
||||||
|
}
|
||||||
|
if (!bmi_install.MessageLevel.empty()) {
|
||||||
|
*bmi_install_script << " " << bmi_install.MessageLevel << "\n";
|
||||||
|
}
|
||||||
|
if (!bmi_install.Permissions.empty()) {
|
||||||
|
*bmi_install_script << " PERMISSIONS" << bmi_install.Permissions
|
||||||
|
<< "\n";
|
||||||
|
}
|
||||||
|
*bmi_install_script << " FILES \"" << m->second << "\")\n";
|
||||||
|
if (bmi_dest_is_abs) {
|
||||||
|
*bmi_install_script
|
||||||
|
<< " list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES\n"
|
||||||
|
" \""
|
||||||
|
<< cmEscape(cmSystemTools::GetFilenameName(m->second))
|
||||||
|
<< "\")\n"
|
||||||
|
" if (CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)\n"
|
||||||
|
" message(WARNING\n"
|
||||||
|
" \"ABSOLUTE path INSTALL DESTINATION : "
|
||||||
|
"${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n"
|
||||||
|
" endif ()\n"
|
||||||
|
" if (CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)\n"
|
||||||
|
" message(FATAL_ERROR\n"
|
||||||
|
" \"ABSOLUTE path INSTALL DESTINATION forbidden (by "
|
||||||
|
"caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n"
|
||||||
|
" endif ()\n";
|
||||||
|
}
|
||||||
|
*bmi_install_script << "endif ()\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2935,6 +3016,21 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
|
|||||||
export_info.Exports.push_back(exp);
|
export_info.Exports.push_back(exp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
auto const& bmi_installation = tdi["bmi-installation"];
|
||||||
|
if (bmi_installation.isObject()) {
|
||||||
|
CxxModuleBmiInstall bmi_install;
|
||||||
|
|
||||||
|
bmi_install.Component = bmi_installation["component"].asString();
|
||||||
|
bmi_install.Destination = bmi_installation["destination"].asString();
|
||||||
|
bmi_install.ExcludeFromAll = bmi_installation["exclude-from-all"].asBool();
|
||||||
|
bmi_install.Optional = bmi_installation["optional"].asBool();
|
||||||
|
bmi_install.Permissions = bmi_installation["permissions"].asString();
|
||||||
|
bmi_install.MessageLevel = bmi_installation["message-level"].asString();
|
||||||
|
bmi_install.ScriptLocation =
|
||||||
|
bmi_installation["script-location"].asString();
|
||||||
|
|
||||||
|
export_info.BmiInstallation = bmi_install;
|
||||||
|
}
|
||||||
Json::Value const& tdi_cxx_modules = tdi["cxx-modules"];
|
Json::Value const& tdi_cxx_modules = tdi["cxx-modules"];
|
||||||
if (tdi_cxx_modules.isObject()) {
|
if (tdi_cxx_modules.isObject()) {
|
||||||
for (auto i = tdi_cxx_modules.begin(); i != tdi_cxx_modules.end(); ++i) {
|
for (auto i = tdi_cxx_modules.begin(); i != tdi_cxx_modules.end(); ++i) {
|
||||||
|
|||||||
Reference in New Issue
Block a user