mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-03 21:00:01 -05:00
Merge topic 'clang-tidy-xcode-generator'
09b7ac7f67strings: use single characters where possible6aa9023700string_view: use string_view literals in comparisons1b60137b98strings: combine string literalse1b70d7286cmCPackDragNDropGenerator: use a string instead of a stream for commandsf5d04b5bf0cmStrCat: use where possible in Apple-specific sources3af822cd8fcmXCode21Object: simplify streaming expressionc4f751604bcmLocalXCodeGenerator: return a default stringce549909fbcmCPackPKGGenerator: remove unnecessary `.c_str()` calls ... Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !8660
This commit is contained in:
@@ -86,24 +86,28 @@ int cmCPackBundleGenerator::ConstructBundle()
|
||||
std::string const staging = toplevel;
|
||||
|
||||
std::ostringstream contents;
|
||||
contents << staging << "/" << cpack_bundle_name << ".app/"
|
||||
<< "Contents";
|
||||
contents << staging << "/" << cpack_bundle_name
|
||||
<< ".app/"
|
||||
"Contents";
|
||||
|
||||
std::ostringstream application;
|
||||
application << contents.str() << "/"
|
||||
<< "MacOS";
|
||||
application << contents.str()
|
||||
<< "/"
|
||||
"MacOS";
|
||||
|
||||
std::ostringstream resources;
|
||||
resources << contents.str() << "/"
|
||||
<< "Resources";
|
||||
resources << contents.str()
|
||||
<< "/"
|
||||
"Resources";
|
||||
|
||||
// Install a required, user-provided bundle metadata file ...
|
||||
std::ostringstream plist_source;
|
||||
plist_source << cpack_bundle_plist;
|
||||
|
||||
std::ostringstream plist_target;
|
||||
plist_target << contents.str() << "/"
|
||||
<< "Info.plist";
|
||||
plist_target << contents.str()
|
||||
<< "/"
|
||||
"Info.plist";
|
||||
|
||||
if (!this->CopyFile(plist_source, plist_target)) {
|
||||
cmCPackLogger(
|
||||
@@ -196,15 +200,11 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
|
||||
|
||||
// sign the files supplied by the user, ie. frameworks.
|
||||
for (auto const& file : relFiles) {
|
||||
std::ostringstream temp_sign_file_cmd;
|
||||
temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
|
||||
temp_sign_file_cmd << " " << sign_parameter << " -s \""
|
||||
<< cpack_apple_cert_app;
|
||||
temp_sign_file_cmd << "\" -i ";
|
||||
temp_sign_file_cmd << this->GetOption("CPACK_APPLE_BUNDLE_ID");
|
||||
temp_sign_file_cmd << " \"";
|
||||
temp_sign_file_cmd << bundle_path;
|
||||
temp_sign_file_cmd << file << "\"";
|
||||
auto temp_sign_file_cmd =
|
||||
cmStrCat(this->GetOption("CPACK_COMMAND_CODESIGN"), ' ',
|
||||
sign_parameter, " -s \"", cpack_apple_cert_app, "\" -i ",
|
||||
this->GetOption("CPACK_APPLE_BUNDLE_ID"), " \"", bundle_path,
|
||||
file, '"');
|
||||
|
||||
if (!this->RunCommand(temp_sign_file_cmd, &output)) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
@@ -216,11 +216,9 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
|
||||
}
|
||||
|
||||
// sign main binary
|
||||
std::ostringstream temp_sign_binary_cmd;
|
||||
temp_sign_binary_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
|
||||
temp_sign_binary_cmd << " " << sign_parameter << " -s \""
|
||||
<< cpack_apple_cert_app;
|
||||
temp_sign_binary_cmd << "\" \"" << bundle_path << "\"";
|
||||
auto temp_sign_binary_cmd =
|
||||
cmStrCat(this->GetOption("CPACK_COMMAND_CODESIGN"), ' ', sign_parameter,
|
||||
" -s \"", cpack_apple_cert_app, "\" \"", bundle_path, '"');
|
||||
|
||||
if (!this->RunCommand(temp_sign_binary_cmd, &output)) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
@@ -232,15 +230,15 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
|
||||
}
|
||||
|
||||
// sign app bundle
|
||||
std::ostringstream temp_codesign_cmd;
|
||||
temp_codesign_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
|
||||
temp_codesign_cmd << " " << sign_parameter << " -s \""
|
||||
<< cpack_apple_cert_app << "\"";
|
||||
auto temp_codesign_cmd =
|
||||
cmStrCat(this->GetOption("CPACK_COMMAND_CODESIGN"), ' ', sign_parameter,
|
||||
" -s \"", cpack_apple_cert_app, "\"");
|
||||
if (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")) {
|
||||
temp_codesign_cmd << " --entitlements ";
|
||||
temp_codesign_cmd << this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS");
|
||||
temp_codesign_cmd +=
|
||||
cmStrCat(" --entitlements ",
|
||||
this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS"));
|
||||
}
|
||||
temp_codesign_cmd << " \"" << bundle_path << "\"";
|
||||
temp_codesign_cmd += cmStrCat(" \"", bundle_path, '"');
|
||||
|
||||
if (!this->RunCommand(temp_codesign_cmd, &output)) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
|
||||
#include <cm/string_view>
|
||||
#include <cmext/string_view>
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <cm3p/kwiml/abi.h>
|
||||
|
||||
@@ -136,8 +139,10 @@ int cmCPackDragNDropGenerator::InitializeInternal()
|
||||
return 0;
|
||||
}
|
||||
for (auto const& language : languages) {
|
||||
std::string license = slaDirectory + "/" + language + ".license.txt";
|
||||
std::string license_rtf = slaDirectory + "/" + language + ".license.rtf";
|
||||
std::string license =
|
||||
cmStrCat(slaDirectory, '/', language, ".license.txt");
|
||||
std::string license_rtf =
|
||||
cmStrCat(slaDirectory, '/', language, ".license.rtf");
|
||||
if (!singleLicense) {
|
||||
if (!cmSystemTools::FileExists(license) &&
|
||||
!cmSystemTools::FileExists(license_rtf)) {
|
||||
@@ -148,7 +153,7 @@ int cmCPackDragNDropGenerator::InitializeInternal()
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
std::string menu = slaDirectory + "/" + language + ".menu.txt";
|
||||
std::string menu = cmStrCat(slaDirectory, '/', language, ".menu.txt");
|
||||
if (!cmSystemTools::FileExists(menu)) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
"Missing menu file " << language << ".menu.txt"
|
||||
@@ -192,13 +197,13 @@ int cmCPackDragNDropGenerator::PackageFiles()
|
||||
// loop to create dmg files
|
||||
packageFileNames.clear();
|
||||
for (auto const& package_file : package_files) {
|
||||
std::string full_package_name = std::string(toplevel) + std::string("/");
|
||||
if (package_file == "ALL_IN_ONE") {
|
||||
std::string full_package_name = cmStrCat(toplevel, '/');
|
||||
if (package_file == "ALL_IN_ONE"_s) {
|
||||
full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME");
|
||||
} else {
|
||||
full_package_name += package_file;
|
||||
}
|
||||
full_package_name += std::string(GetOutputExtension());
|
||||
full_package_name += GetOutputExtension();
|
||||
packageFileNames.push_back(full_package_name);
|
||||
|
||||
std::string src_dir = cmStrCat(toplevel, '/', package_file);
|
||||
@@ -241,18 +246,18 @@ bool cmCPackDragNDropGenerator::CreateEmptyFile(std::ostringstream& target,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command,
|
||||
bool cmCPackDragNDropGenerator::RunCommand(std::string const& command,
|
||||
std::string* output)
|
||||
{
|
||||
int exit_code = 1;
|
||||
|
||||
bool result = cmSystemTools::RunSingleCommand(
|
||||
command.str(), output, output, &exit_code, nullptr, this->GeneratorVerbose,
|
||||
command, output, output, &exit_code, nullptr, this->GeneratorVerbose,
|
||||
cmDuration::zero());
|
||||
|
||||
if (!result || exit_code) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
"Error executing: " << command.str() << std::endl);
|
||||
"Error executing: " << command << std::endl);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -410,15 +415,21 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
|
||||
cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/temp.dmg");
|
||||
|
||||
std::string create_error;
|
||||
std::ostringstream temp_image_command;
|
||||
temp_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
|
||||
temp_image_command << " create";
|
||||
temp_image_command << " -ov";
|
||||
temp_image_command << " -srcfolder \"" << staging.str() << "\"";
|
||||
temp_image_command << " -volname \"" << cpack_dmg_volume_name << "\"";
|
||||
temp_image_command << " -fs \"" << cpack_dmg_filesystem << "\"";
|
||||
temp_image_command << " -format " << temp_image_format;
|
||||
temp_image_command << " \"" << temp_image << "\"";
|
||||
auto temp_image_command =
|
||||
cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"),
|
||||
" create"
|
||||
" -ov"
|
||||
" -srcfolder \"",
|
||||
staging.str(),
|
||||
"\""
|
||||
" -volname \"",
|
||||
cpack_dmg_volume_name,
|
||||
"\""
|
||||
" -fs \"",
|
||||
cpack_dmg_filesystem,
|
||||
"\""
|
||||
" -format ",
|
||||
temp_image_format, " \"", temp_image, '"');
|
||||
|
||||
if (!this->RunCommand(temp_image_command, &create_error)) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
@@ -434,10 +445,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
|
||||
// before we exit.
|
||||
bool had_error = false;
|
||||
|
||||
std::ostringstream attach_command;
|
||||
attach_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
|
||||
attach_command << " attach";
|
||||
attach_command << " \"" << temp_image << "\"";
|
||||
auto attach_command = cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"),
|
||||
" attach"
|
||||
" \"",
|
||||
temp_image, '"');
|
||||
|
||||
std::string attach_output;
|
||||
if (!this->RunCommand(attach_command, &attach_output)) {
|
||||
@@ -466,10 +477,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
|
||||
// Optionally set the custom icon flag for the image ...
|
||||
if (!had_error && !cpack_package_icon->empty()) {
|
||||
std::string error;
|
||||
std::ostringstream setfile_command;
|
||||
setfile_command << this->GetOption("CPACK_COMMAND_SETFILE");
|
||||
setfile_command << " -a C";
|
||||
setfile_command << " \"" << temp_mount << "\"";
|
||||
auto setfile_command = cmStrCat(this->GetOption("CPACK_COMMAND_SETFILE"),
|
||||
" -a C"
|
||||
" \"",
|
||||
temp_mount, '"');
|
||||
|
||||
if (!this->RunCommand(setfile_command, &error)) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
@@ -484,10 +495,12 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
|
||||
// Optionally we can execute a custom apple script to generate
|
||||
// the .DS_Store for the volume folder ...
|
||||
if (!had_error && !cpack_dmg_ds_store_setup_script->empty()) {
|
||||
std::ostringstream setup_script_command;
|
||||
setup_script_command << "osascript"
|
||||
<< " \"" << cpack_dmg_ds_store_setup_script << "\""
|
||||
<< " \"" << temp_mount_name << "\"";
|
||||
auto setup_script_command = cmStrCat("osascript"
|
||||
" \"",
|
||||
cpack_dmg_ds_store_setup_script,
|
||||
"\""
|
||||
" \"",
|
||||
temp_mount_name, '"');
|
||||
std::string error;
|
||||
if (!this->RunCommand(setup_script_command, &error)) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
@@ -499,10 +512,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
|
||||
}
|
||||
}
|
||||
|
||||
std::ostringstream detach_command;
|
||||
detach_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
|
||||
detach_command << " detach";
|
||||
detach_command << " \"" << temp_mount << "\"";
|
||||
auto detach_command = cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"),
|
||||
" detach"
|
||||
" \"",
|
||||
temp_mount, '\"');
|
||||
|
||||
if (!this->RunCommand(detach_command)) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
@@ -517,14 +530,15 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
|
||||
}
|
||||
|
||||
// Create the final compressed read-only disk image ...
|
||||
std::ostringstream final_image_command;
|
||||
final_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
|
||||
final_image_command << " convert \"" << temp_image << "\"";
|
||||
final_image_command << " -format ";
|
||||
final_image_command << cpack_dmg_format;
|
||||
final_image_command << " -imagekey";
|
||||
final_image_command << " zlib-level=9";
|
||||
final_image_command << " -o \"" << output_file << "\"";
|
||||
auto final_image_command = cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"),
|
||||
" convert \"", temp_image,
|
||||
"\""
|
||||
" -format ",
|
||||
cpack_dmg_format,
|
||||
" -imagekey"
|
||||
" zlib-level=9"
|
||||
" -o \"",
|
||||
output_file, '"');
|
||||
|
||||
std::string convert_error;
|
||||
|
||||
@@ -574,16 +588,18 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
|
||||
|
||||
header_data.push_back(0);
|
||||
header_data.push_back(languages.size());
|
||||
// NOLINTNEXTLINE(modernize-loop-convert): `HAVE_CoreServices` needs `i`
|
||||
for (cmList::size_type i = 0; i < languages.size(); ++i) {
|
||||
auto const& language = languages[i];
|
||||
CFStringRef language_cfstring = CFStringCreateWithCString(
|
||||
nullptr, languages[i].c_str(), kCFStringEncodingUTF8);
|
||||
nullptr, language.c_str(), kCFStringEncodingUTF8);
|
||||
CFStringRef iso_language =
|
||||
CFLocaleCreateCanonicalLanguageIdentifierFromString(
|
||||
nullptr, language_cfstring);
|
||||
if (!iso_language) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
languages[i] << " is not a recognized language"
|
||||
<< std::endl);
|
||||
language << " is not a recognized language"
|
||||
<< std::endl);
|
||||
}
|
||||
char iso_language_cstr[65];
|
||||
CFStringGetCString(iso_language, iso_language_cstr,
|
||||
@@ -663,13 +679,15 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
|
||||
this->WriteRezXML(sla_xml, rez);
|
||||
|
||||
// Create the final compressed read-only disk image ...
|
||||
std::ostringstream embed_sla_command;
|
||||
embed_sla_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
|
||||
embed_sla_command << " udifrez";
|
||||
embed_sla_command << " -xml";
|
||||
embed_sla_command << " \"" << sla_xml << "\"";
|
||||
embed_sla_command << " FIXME_WHY_IS_THIS_ARGUMENT_NEEDED";
|
||||
embed_sla_command << " \"" << output_file << "\"";
|
||||
auto embed_sla_command = cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"),
|
||||
" udifrez"
|
||||
" -xml"
|
||||
" \"",
|
||||
sla_xml,
|
||||
"\""
|
||||
" FIXME_WHY_IS_THIS_ARGUMENT_NEEDED"
|
||||
" \"",
|
||||
output_file, '"');
|
||||
std::string embed_error;
|
||||
if (!this->RunCommand(embed_sla_command, &embed_error)) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
@@ -709,8 +727,8 @@ std::string cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
|
||||
if (this->componentPackageMethod == ONE_PACKAGE_PER_GROUP) {
|
||||
// We have to find the name of the COMPONENT GROUP
|
||||
// the current COMPONENT belongs to.
|
||||
std::string groupVar =
|
||||
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
|
||||
std::string groupVar = cmStrCat(
|
||||
"CPACK_COMPONENT_", cmSystemTools::UpperCase(componentName), "_GROUP");
|
||||
cmValue _groupName = this->GetOption(groupVar);
|
||||
if (_groupName) {
|
||||
std::string groupName = _groupName;
|
||||
@@ -721,8 +739,8 @@ std::string cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
|
||||
}
|
||||
}
|
||||
|
||||
std::string componentFileName =
|
||||
"CPACK_DMG_" + cmSystemTools::UpperCase(componentName) + "_FILE_NAME";
|
||||
std::string componentFileName = cmStrCat(
|
||||
"CPACK_DMG_", cmSystemTools::UpperCase(componentName), "_FILE_NAME");
|
||||
if (this->IsSet(componentFileName)) {
|
||||
return this->GetOption(componentFileName);
|
||||
}
|
||||
@@ -806,12 +824,12 @@ bool cmCPackDragNDropGenerator::WriteLicense(RezDoc& rez, size_t licenseNumber,
|
||||
actual_license = licenseFile;
|
||||
} else {
|
||||
std::string license_wo_ext =
|
||||
slaDirectory + "/" + licenseLanguage + ".license";
|
||||
if (cmSystemTools::FileExists(license_wo_ext + ".txt")) {
|
||||
actual_license = license_wo_ext + ".txt";
|
||||
cmStrCat(slaDirectory, '/', licenseLanguage, ".license");
|
||||
if (cmSystemTools::FileExists(cmStrCat(license_wo_ext, ".txt"))) {
|
||||
actual_license = cmStrCat(license_wo_ext, ".txt");
|
||||
} else {
|
||||
licenseArray = &rez.RTF;
|
||||
actual_license = license_wo_ext + ".rtf";
|
||||
actual_license = cmStrCat(license_wo_ext, ".rtf");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -834,7 +852,7 @@ bool cmCPackDragNDropGenerator::WriteLicense(RezDoc& rez, size_t licenseNumber,
|
||||
} else {
|
||||
std::vector<std::string> lines;
|
||||
std::string actual_menu =
|
||||
slaDirectory + "/" + licenseLanguage + ".menu.txt";
|
||||
cmStrCat(slaDirectory, '/', licenseLanguage, ".menu.txt");
|
||||
if (!this->ReadFile(actual_menu, lines, error)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ protected:
|
||||
|
||||
bool CopyFile(std::ostringstream& source, std::ostringstream& target);
|
||||
bool CreateEmptyFile(std::ostringstream& target, size_t size);
|
||||
bool RunCommand(std::ostringstream& command, std::string* output = nullptr);
|
||||
bool RunCommand(std::string const& command, std::string* output = nullptr);
|
||||
|
||||
std::string GetComponentInstallDirNameSuffix(
|
||||
const std::string& componentName) override;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <cmext/string_view>
|
||||
|
||||
#include "cmCPackComponentGroup.h"
|
||||
#include "cmCPackGenerator.h"
|
||||
#include "cmCPackLog.h"
|
||||
@@ -38,13 +40,12 @@ std::string cmCPackPKGGenerator::GetPackageName(
|
||||
if (component.ArchiveFile.empty()) {
|
||||
std::string packagesDir =
|
||||
cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), ".dummy");
|
||||
std::ostringstream out;
|
||||
out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-"
|
||||
<< component.Name << ".pkg";
|
||||
return out.str();
|
||||
return cmStrCat(
|
||||
cmSystemTools::GetFilenameWithoutLastExtension(packagesDir), '-',
|
||||
component.Name, ".pkg");
|
||||
}
|
||||
|
||||
return component.ArchiveFile + ".pkg";
|
||||
return cmStrCat(component.ArchiveFile, ".pkg");
|
||||
}
|
||||
|
||||
void cmCPackPKGGenerator::CreateBackground(const char* themeName,
|
||||
@@ -160,14 +161,15 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile,
|
||||
for (auto const& comp : this->Components) {
|
||||
if (!comp.second.Group) {
|
||||
xChoiceOut.StartElement("line");
|
||||
xChoiceOut.Attribute("choice", comp.first + "Choice");
|
||||
xChoiceOut.Attribute("choice", cmStrCat(comp.first, "Choice"));
|
||||
xChoiceOut.Content(""); // Avoid self-closing tag.
|
||||
xChoiceOut.EndElement();
|
||||
}
|
||||
}
|
||||
if (!this->PostFlightComponent.Name.empty()) {
|
||||
xChoiceOut.StartElement("line");
|
||||
xChoiceOut.Attribute("choice", PostFlightComponent.Name + "Choice");
|
||||
xChoiceOut.Attribute("choice",
|
||||
cmStrCat(PostFlightComponent.Name, "Choice"));
|
||||
xChoiceOut.Content(""); // Avoid self-closing tag.
|
||||
xChoiceOut.EndElement();
|
||||
}
|
||||
@@ -207,14 +209,14 @@ void cmCPackPKGGenerator::CreateChoiceOutline(
|
||||
const cmCPackComponentGroup& group, cmXMLWriter& xout)
|
||||
{
|
||||
xout.StartElement("line");
|
||||
xout.Attribute("choice", group.Name + "Choice");
|
||||
xout.Attribute("choice", cmStrCat(group.Name, "Choice"));
|
||||
for (cmCPackComponentGroup* subgroup : group.Subgroups) {
|
||||
CreateChoiceOutline(*subgroup, xout);
|
||||
}
|
||||
|
||||
for (cmCPackComponent* comp : group.Components) {
|
||||
xout.StartElement("line");
|
||||
xout.Attribute("choice", comp->Name + "Choice");
|
||||
xout.Attribute("choice", cmStrCat(comp->Name, "Choice"));
|
||||
xout.Content(""); // Avoid self-closing tag.
|
||||
xout.EndElement();
|
||||
}
|
||||
@@ -225,7 +227,7 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponentGroup& group,
|
||||
cmXMLWriter& xout)
|
||||
{
|
||||
xout.StartElement("choice");
|
||||
xout.Attribute("id", group.Name + "Choice");
|
||||
xout.Attribute("id", cmStrCat(group.Name, "Choice"));
|
||||
xout.Attribute("title", group.DisplayName);
|
||||
xout.Attribute("start_selected", "true");
|
||||
xout.Attribute("start_enabled", "true");
|
||||
@@ -249,7 +251,7 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component,
|
||||
}
|
||||
|
||||
xout.StartElement("choice");
|
||||
xout.Attribute("id", component.Name + "Choice");
|
||||
xout.Attribute("id", cmStrCat(component.Name, "Choice"));
|
||||
xout.Attribute("title", component.DisplayName);
|
||||
xout.Attribute(
|
||||
"start_selected",
|
||||
@@ -381,15 +383,14 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name,
|
||||
const std::string& dirName)
|
||||
{
|
||||
std::string uname = cmSystemTools::UpperCase(name);
|
||||
std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
|
||||
std::string cpackVar = cmStrCat("CPACK_RESOURCE_FILE_", uname);
|
||||
cmValue inFileName = this->GetOption(cpackVar);
|
||||
if (!inFileName) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
"CPack option: " << cpackVar.c_str()
|
||||
<< " not specified. It should point to "
|
||||
<< (!name.empty() ? name : "<empty>")
|
||||
<< ".rtf, " << name << ".html, or " << name
|
||||
<< ".txt file" << std::endl);
|
||||
"CPack option: "
|
||||
<< cpackVar << " not specified. It should point to "
|
||||
<< (!name.empty() ? name : "<empty>") << ".rtf, " << name
|
||||
<< ".html, or " << name << ".txt file" << std::endl);
|
||||
return false;
|
||||
}
|
||||
if (!cmSystemTools::FileExists(inFileName)) {
|
||||
@@ -400,7 +401,8 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name,
|
||||
return false;
|
||||
}
|
||||
std::string ext = cmSystemTools::GetFilenameLastExtension(inFileName);
|
||||
if (ext != ".rtfd" && ext != ".rtf" && ext != ".html" && ext != ".txt") {
|
||||
if (ext != ".rtfd"_s && ext != ".rtf"_s && ext != ".html"_s &&
|
||||
ext != ".txt"_s) {
|
||||
cmCPackLogger(
|
||||
cmCPackLog::LOG_ERROR,
|
||||
"Bad file extension specified: "
|
||||
@@ -414,7 +416,8 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name,
|
||||
|
||||
// Set this so that distribution.dist gets the right name (without
|
||||
// the path).
|
||||
this->SetOption("CPACK_RESOURCE_FILE_" + uname + "_NOPATH", (name + ext));
|
||||
this->SetOption(cmStrCat("CPACK_RESOURCE_FILE_", uname, "_NOPATH"),
|
||||
cmStrCat(name, ext));
|
||||
|
||||
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
|
||||
"Configure file: " << (inFileName ? *inFileName : "(NULL)")
|
||||
@@ -454,7 +457,7 @@ int cmCPackPKGGenerator::CopyInstallScript(const std::string& resdir,
|
||||
{
|
||||
std::string dst = cmStrCat(resdir, '/', name);
|
||||
cmSystemTools::CopyFileAlways(script, dst);
|
||||
cmSystemTools::SetPermissions(dst.c_str(), 0777);
|
||||
cmSystemTools::SetPermissions(dst, 0777);
|
||||
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
|
||||
"copy script : " << script << "\ninto " << dst << std::endl);
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ int cmCPackProductBuildGenerator::PackageFiles()
|
||||
}
|
||||
}
|
||||
|
||||
std::string resDir = packageDirFileName + "/Contents";
|
||||
std::string resDir = cmStrCat(packageDirFileName, "/Contents");
|
||||
|
||||
if (this->IsSet("CPACK_PRODUCTBUILD_RESOURCES_DIR")) {
|
||||
std::string userResDir =
|
||||
@@ -102,15 +102,24 @@ int cmCPackProductBuildGenerator::PackageFiles()
|
||||
|
||||
pkgCmd << productbuild << " --distribution \"" << packageDirFileName
|
||||
<< "/Contents/distribution.dist\""
|
||||
<< " --package-path \"" << packageDirFileName << "/Contents/Packages"
|
||||
" --package-path \""
|
||||
<< packageDirFileName
|
||||
<< "/Contents/Packages"
|
||||
"\""
|
||||
" --resources \""
|
||||
<< resDir
|
||||
<< "\""
|
||||
<< " --resources \"" << resDir << "\""
|
||||
<< " --version \"" << version << "\""
|
||||
<< (identifier.empty() ? "" : " --identifier \"" + identifier + "\"")
|
||||
<< (identityName.empty() ? "" : " --sign \"" + identityName + "\"")
|
||||
<< (keychainPath.empty() ? ""
|
||||
: " --keychain \"" + keychainPath + "\"")
|
||||
<< " \"" << packageFileNames[0] << "\"";
|
||||
" --version \""
|
||||
<< version << "\""
|
||||
<< (identifier.empty()
|
||||
? std::string{}
|
||||
: cmStrCat(" --identifier \"", identifier, '"'))
|
||||
<< (identityName.empty() ? std::string{}
|
||||
: cmStrCat(" --sign \"", identityName, '"'))
|
||||
<< (keychainPath.empty()
|
||||
? std::string{}
|
||||
: cmStrCat(" --keychain \"", keychainPath, '"'))
|
||||
<< " \"" << packageFileNames[0] << '"';
|
||||
|
||||
// Run ProductBuild
|
||||
return RunProductBuild(pkgCmd.str());
|
||||
@@ -184,10 +193,10 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
|
||||
|
||||
std::string resDir = packageFileDir;
|
||||
if (component) {
|
||||
resDir += "/";
|
||||
resDir += '/';
|
||||
resDir += component->Name;
|
||||
}
|
||||
std::string scriptDir = resDir + "/scripts";
|
||||
std::string scriptDir = cmStrCat(resDir, "/scripts");
|
||||
|
||||
if (!cmsys::SystemTools::MakeDirectory(scriptDir.c_str())) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
@@ -232,15 +241,24 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
|
||||
keychainPath = p;
|
||||
}
|
||||
|
||||
pkgCmd << pkgbuild << " --root \"" << packageDir << "\""
|
||||
<< " --identifier \"" << pkgId << "\""
|
||||
<< " --scripts \"" << scriptDir << "\""
|
||||
<< " --version \"" << version << "\""
|
||||
<< " --install-location \"/\""
|
||||
<< (identityName.empty() ? "" : " --sign \"" + identityName + "\"")
|
||||
<< (keychainPath.empty() ? ""
|
||||
: " --keychain \"" + keychainPath + "\"")
|
||||
<< " \"" << packageFile << "\"";
|
||||
pkgCmd << pkgbuild << " --root \"" << packageDir
|
||||
<< "\""
|
||||
" --identifier \""
|
||||
<< pkgId
|
||||
<< "\""
|
||||
" --scripts \""
|
||||
<< scriptDir
|
||||
<< "\""
|
||||
" --version \""
|
||||
<< version
|
||||
<< "\""
|
||||
" --install-location \"/\""
|
||||
<< (identityName.empty() ? std::string{}
|
||||
: cmStrCat(" --sign \"", identityName, "\""))
|
||||
<< (keychainPath.empty()
|
||||
? std::string{}
|
||||
: cmStrCat(" --keychain \"", keychainPath, "\""))
|
||||
<< " \"" << packageFile << '"';
|
||||
|
||||
if (component && !component->Plist.empty()) {
|
||||
pkgCmd << " --component-plist \"" << component->Plist << "\"";
|
||||
@@ -253,10 +271,10 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
|
||||
cmValue cmCPackProductBuildGenerator::GetComponentScript(
|
||||
const char* script, const char* component_name)
|
||||
{
|
||||
std::string scriptname = std::string("CPACK_") + script + "_";
|
||||
std::string scriptname = cmStrCat("CPACK_", script, '_');
|
||||
if (component_name) {
|
||||
scriptname += cmSystemTools::UpperCase(component_name);
|
||||
scriptname += "_";
|
||||
scriptname += '_';
|
||||
}
|
||||
scriptname += "SCRIPT";
|
||||
|
||||
|
||||
+201
-198
File diff suppressed because it is too large
Load Diff
@@ -120,7 +120,7 @@ public:
|
||||
* Used to determine if this generator supports DEPFILE option.
|
||||
*/
|
||||
bool SupportsCustomCommandDepfile() const override { return true; }
|
||||
virtual cm::optional<cmDepfileFormat> DepfileFormat() const override
|
||||
cm::optional<cmDepfileFormat> DepfileFormat() const override
|
||||
{
|
||||
return this->XcodeBuildSystem == BuildSystem::One
|
||||
? cmDepfileFormat::MakeDepfile
|
||||
|
||||
@@ -31,7 +31,7 @@ std::string cmLocalXCodeGenerator::GetTargetDirectory(
|
||||
cmGeneratorTarget const*) const
|
||||
{
|
||||
// No per-target directory for this generator (yet).
|
||||
return "";
|
||||
return std::string{};
|
||||
}
|
||||
|
||||
void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags,
|
||||
|
||||
@@ -26,9 +26,7 @@ void cmXCode21Object::PrintComment(std::ostream& out)
|
||||
if (this->Comment.empty()) {
|
||||
return;
|
||||
}
|
||||
out << " /* ";
|
||||
out << this->Comment;
|
||||
out << " */";
|
||||
out << " /* " << this->Comment << " */";
|
||||
}
|
||||
|
||||
void cmXCode21Object::PrintList(
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include <cmext/string_view>
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
const char* cmXCodeObject::PBXTypeNames[] = {
|
||||
@@ -91,13 +93,13 @@ void cmXCodeObject::Print(std::ostream& out)
|
||||
out << this->Id;
|
||||
this->PrintComment(out);
|
||||
out << " = {";
|
||||
if (separator == "\n") {
|
||||
if (separator == "\n"_s) {
|
||||
out << separator;
|
||||
}
|
||||
cmXCodeObject::Indent(3 * indentFactor, out);
|
||||
out << "isa = " << PBXTypeNames[this->IsA] << ";" << separator;
|
||||
for (const auto& keyVal : this->ObjectAttributes) {
|
||||
if (keyVal.first == "isa") {
|
||||
if (keyVal.first == "isa"_s) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -142,7 +144,7 @@ void cmXCodeObject::PrintAttribute(std::ostream& out, int level,
|
||||
|
||||
case ATTRIBUTE_GROUP: {
|
||||
out << name << " = {";
|
||||
if (separator == "\n") {
|
||||
if (separator == "\n"_s) {
|
||||
out << separator;
|
||||
}
|
||||
for (const auto& keyVal : object->ObjectAttributes) {
|
||||
@@ -156,7 +158,7 @@ void cmXCodeObject::PrintAttribute(std::ostream& out, int level,
|
||||
case OBJECT_REF: {
|
||||
cmXCodeObject::PrintString(out, name);
|
||||
out << " = " << object->Object->Id;
|
||||
if (object->Object->HasComment() && name != "remoteGlobalIDString") {
|
||||
if (object->Object->HasComment() && name != "remoteGlobalIDString"_s) {
|
||||
object->Object->PrintComment(out);
|
||||
}
|
||||
out << ";" << separator;
|
||||
@@ -180,7 +182,7 @@ void cmXCodeObject::PrintList(std::vector<cmXCodeObject*> const& objs,
|
||||
{
|
||||
cmXCodeObject::Indent(1, out);
|
||||
out << "objects = {\n";
|
||||
for (auto obj : objs) {
|
||||
for (auto* obj : objs) {
|
||||
if (obj->TypeValue == OBJECT) {
|
||||
obj->Print(out);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
// search the attribute list for an object of the specified type
|
||||
cmXCodeObject* GetObject(cmXCodeObject::PBXType t) const
|
||||
{
|
||||
for (auto o : this->List) {
|
||||
for (auto* o : this->List) {
|
||||
if (o->IsA == t) {
|
||||
return o;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include <cmext/algorithm>
|
||||
#include <cmext/string_view>
|
||||
|
||||
#include "cmsys/String.h"
|
||||
|
||||
@@ -121,7 +122,7 @@ void cmXCodeScheme::WriteTestAction(cmXMLWriter& xout,
|
||||
xout.Attribute("shouldUseLaunchSchemeArgsEnv", "YES");
|
||||
|
||||
xout.StartElement("Testables");
|
||||
for (auto test : this->Tests) {
|
||||
for (auto const* test : this->Tests) {
|
||||
xout.StartElement("TestableReference");
|
||||
xout.BreakAttributes();
|
||||
xout.Attribute("skipped", "NO");
|
||||
@@ -157,7 +158,7 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout,
|
||||
cmValue launchMode =
|
||||
this->Target->GetTarget()->GetProperty("XCODE_SCHEME_LAUNCH_MODE");
|
||||
std::string value = "0"; // == 'AUTO'
|
||||
if (launchMode && *launchMode == "WAIT") {
|
||||
if (launchMode && *launchMode == "WAIT"_s) {
|
||||
value = "1";
|
||||
}
|
||||
xout.Attribute("launchStyle", value);
|
||||
@@ -447,7 +448,7 @@ void cmXCodeScheme::WriteBuildableReference(cmXMLWriter& xout,
|
||||
std::string const noConfig; // FIXME: What config to use here?
|
||||
xout.Attribute("BuildableName", xcObj->GetTarget()->GetFullName(noConfig));
|
||||
xout.Attribute("BlueprintName", xcObj->GetTarget()->GetName());
|
||||
xout.Attribute("ReferencedContainer", "container:" + container);
|
||||
xout.Attribute("ReferencedContainer", cmStrCat("container:", container));
|
||||
xout.EndElement();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <cm/string_view>
|
||||
#include <cmext/string_view>
|
||||
|
||||
#include <cm3p/json/value.h>
|
||||
@@ -43,23 +44,23 @@ bool PlistSupportedPlatformHelper(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value->asString() == "macos") {
|
||||
if (value->asString() == "macos"_s) {
|
||||
platform = cmXcFrameworkPlistSupportedPlatform::macOS;
|
||||
return true;
|
||||
}
|
||||
if (value->asString() == "ios") {
|
||||
if (value->asString() == "ios"_s) {
|
||||
platform = cmXcFrameworkPlistSupportedPlatform::iOS;
|
||||
return true;
|
||||
}
|
||||
if (value->asString() == "tvos") {
|
||||
if (value->asString() == "tvos"_s) {
|
||||
platform = cmXcFrameworkPlistSupportedPlatform::tvOS;
|
||||
return true;
|
||||
}
|
||||
if (value->asString() == "watchos") {
|
||||
if (value->asString() == "watchos"_s) {
|
||||
platform = cmXcFrameworkPlistSupportedPlatform::watchOS;
|
||||
return true;
|
||||
}
|
||||
if (value->asString() == "xros") {
|
||||
if (value->asString() == "xros"_s) {
|
||||
platform = cmXcFrameworkPlistSupportedPlatform::visionOS;
|
||||
return true;
|
||||
}
|
||||
@@ -112,8 +113,8 @@ cm::optional<cmXcFrameworkPlist> cmParseXcFrameworkPlist(
|
||||
cmStrCat("Invalid xcframework .plist file:\n ", plistPath), bt);
|
||||
return cm::nullopt;
|
||||
}
|
||||
if (metadata.CFBundlePackageType != "XFWK" ||
|
||||
metadata.XCFrameworkFormatVersion != "1.0") {
|
||||
if (metadata.CFBundlePackageType != "XFWK"_s ||
|
||||
metadata.XCFrameworkFormatVersion != "1.0"_s) {
|
||||
mf.GetCMakeInstance()->IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
cmStrCat("Expected:\n ", plistPath,
|
||||
|
||||
Reference in New Issue
Block a user