mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 13:20:47 -06:00
cmGlobalXCodeGenerator: Migrate legacy makefile path escaping to local helper
Also clarify the name. It does not do any relative path conversion.
This commit is contained in:
@@ -264,6 +264,13 @@ cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(const std::string& name,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
std::string ConvertToMakefilePath(std::string const& path)
|
||||||
|
{
|
||||||
|
return cmSystemTools::ConvertToOutputPath(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool cmGlobalXCodeGenerator::FindMakeProgram(cmMakefile* mf)
|
bool cmGlobalXCodeGenerator::FindMakeProgram(cmMakefile* mf)
|
||||||
{
|
{
|
||||||
// The Xcode generator knows how to lookup its build tool
|
// The Xcode generator knows how to lookup its build tool
|
||||||
@@ -652,8 +659,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
|
|||||||
bool isGenerateProject = isTopLevel || !generateTopLevelProjectOnly;
|
bool isGenerateProject = isTopLevel || !generateTopLevelProjectOnly;
|
||||||
if (regenerate && isGenerateProject) {
|
if (regenerate && isGenerateProject) {
|
||||||
this->CreateReRunCMakeFile(root, gens);
|
this->CreateReRunCMakeFile(root, gens);
|
||||||
std::string file =
|
std::string file = ConvertToMakefilePath(this->CurrentReRunCMakeMakefile);
|
||||||
this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile);
|
|
||||||
cmSystemTools::ReplaceString(file, "\\ ", " ");
|
cmSystemTools::ReplaceString(file, "\\ ", " ");
|
||||||
cc = cm::make_unique<cmCustomCommand>();
|
cc = cm::make_unique<cmCustomCommand>();
|
||||||
cc->SetCommandLines(cmMakeSingleCommandLine({ "make", "-f", file }));
|
cc->SetCommandLines(cmMakeSingleCommandLine({ "make", "-f", file }));
|
||||||
@@ -732,7 +738,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
|
|||||||
|
|
||||||
for (const auto& lfile : lfiles) {
|
for (const auto& lfile : lfiles) {
|
||||||
makefileStream << "TARGETS += $(subst $(space),$(spaceplus),$(wildcard "
|
makefileStream << "TARGETS += $(subst $(space),$(spaceplus),$(wildcard "
|
||||||
<< this->ConvertToRelativeForMake(lfile) << "))\n";
|
<< ConvertToMakefilePath(lfile) << "))\n";
|
||||||
}
|
}
|
||||||
makefileStream << '\n';
|
makefileStream << '\n';
|
||||||
|
|
||||||
@@ -743,25 +749,25 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
|
|||||||
makefileStream << ".NOTPARALLEL:\n\n"
|
makefileStream << ".NOTPARALLEL:\n\n"
|
||||||
".PHONY: all VERIFY_GLOBS\n\n"
|
".PHONY: all VERIFY_GLOBS\n\n"
|
||||||
"all: VERIFY_GLOBS "
|
"all: VERIFY_GLOBS "
|
||||||
<< this->ConvertToRelativeForMake(checkCache)
|
<< ConvertToMakefilePath(checkCache)
|
||||||
<< "\n\n"
|
<< "\n\n"
|
||||||
"VERIFY_GLOBS:\n"
|
"VERIFY_GLOBS:\n"
|
||||||
"\t"
|
"\t"
|
||||||
<< this->ConvertToRelativeForMake(
|
<< ConvertToMakefilePath(cmSystemTools::GetCMakeCommand())
|
||||||
cmSystemTools::GetCMakeCommand())
|
|
||||||
<< " -P "
|
<< " -P "
|
||||||
<< this->ConvertToRelativeForMake(cm->GetGlobVerifyScript())
|
<< ConvertToMakefilePath(cm->GetGlobVerifyScript())
|
||||||
<< "\n\n";
|
<< "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
makefileStream << this->ConvertToRelativeForMake(checkCache)
|
makefileStream << ConvertToMakefilePath(checkCache) << ": $(TARGETS)\n";
|
||||||
<< ": $(TARGETS)\n";
|
makefileStream << '\t'
|
||||||
makefileStream
|
<< ConvertToMakefilePath(cmSystemTools::GetCMakeCommand())
|
||||||
<< '\t' << this->ConvertToRelativeForMake(cmSystemTools::GetCMakeCommand())
|
<< " -S" << ConvertToMakefilePath(root->GetSourceDirectory())
|
||||||
<< " -S" << this->ConvertToRelativeForMake(root->GetSourceDirectory())
|
<< " -B" << ConvertToMakefilePath(root->GetBinaryDirectory())
|
||||||
<< " -B" << this->ConvertToRelativeForMake(root->GetBinaryDirectory())
|
<< (cm->GetIgnoreWarningAsError()
|
||||||
<< (cm->GetIgnoreWarningAsError() ? " --compile-no-warning-as-error" : "")
|
? " --compile-no-warning-as-error"
|
||||||
<< '\n';
|
: "")
|
||||||
|
<< '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool objectIdLessThan(const std::unique_ptr<cmXCodeObject>& l,
|
static bool objectIdLessThan(const std::unique_ptr<cmXCodeObject>& l,
|
||||||
@@ -2199,11 +2205,11 @@ void cmGlobalXCodeGenerator::AddCommandsToBuildPhase(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string cdir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory();
|
std::string cdir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory();
|
||||||
cdir = this->ConvertToRelativeForMake(cdir);
|
cdir = ConvertToMakefilePath(cdir);
|
||||||
std::string makecmd = cmStrCat(
|
std::string makecmd =
|
||||||
"make -C ", cdir, " -f ",
|
cmStrCat("make -C ", cdir, " -f ",
|
||||||
this->ConvertToRelativeForMake(cmStrCat(makefile, "$CONFIGURATION")),
|
ConvertToMakefilePath(cmStrCat(makefile, "$CONFIGURATION")),
|
||||||
" OBJDIR=$(basename \"$OBJECT_FILE_DIR_normal\") all");
|
" OBJDIR=$(basename \"$OBJECT_FILE_DIR_normal\") all");
|
||||||
buildphase->AddAttribute("shellScript", this->CreateString(makecmd));
|
buildphase->AddAttribute("shellScript", this->CreateString(makecmd));
|
||||||
buildphase->AddAttribute("showEnvVarsInLog", this->CreateString("0"));
|
buildphase->AddAttribute("showEnvVarsInLog", this->CreateString("0"));
|
||||||
}
|
}
|
||||||
@@ -2237,7 +2243,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
|
|||||||
const std::vector<std::string>& outputs = ccg.GetOutputs();
|
const std::vector<std::string>& outputs = ccg.GetOutputs();
|
||||||
if (!outputs.empty()) {
|
if (!outputs.empty()) {
|
||||||
for (auto const& output : outputs) {
|
for (auto const& output : outputs) {
|
||||||
makefileStream << "\\\n\t" << this->ConvertToRelativeForMake(output);
|
makefileStream << "\\\n\t" << ConvertToMakefilePath(output);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
@@ -2291,7 +2297,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
|
|||||||
// There is at least one output, start the rule for it
|
// There is at least one output, start the rule for it
|
||||||
const char* sep = "";
|
const char* sep = "";
|
||||||
for (auto const& output : outputs) {
|
for (auto const& output : outputs) {
|
||||||
makefileStream << sep << this->ConvertToRelativeForMake(output);
|
makefileStream << sep << ConvertToMakefilePath(output);
|
||||||
sep = " ";
|
sep = " ";
|
||||||
}
|
}
|
||||||
makefileStream << ": ";
|
makefileStream << ": ";
|
||||||
@@ -2300,7 +2306,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
|
|||||||
makefileStream << tname[&ccg.GetCC()] << ": ";
|
makefileStream << tname[&ccg.GetCC()] << ": ";
|
||||||
}
|
}
|
||||||
for (auto const& dep : realDepends) {
|
for (auto const& dep : realDepends) {
|
||||||
makefileStream << "\\\n" << this->ConvertToRelativeForMake(dep);
|
makefileStream << "\\\n" << ConvertToMakefilePath(dep);
|
||||||
}
|
}
|
||||||
makefileStream << '\n';
|
makefileStream << '\n';
|
||||||
|
|
||||||
@@ -2317,12 +2323,12 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
|
|||||||
// Build the command line in a single string.
|
// Build the command line in a single string.
|
||||||
std::string cmd2 = ccg.GetCommand(c);
|
std::string cmd2 = ccg.GetCommand(c);
|
||||||
cmSystemTools::ReplaceString(cmd2, "/./", "/");
|
cmSystemTools::ReplaceString(cmd2, "/./", "/");
|
||||||
cmd2 = this->ConvertToRelativeForMake(cmd2);
|
cmd2 = ConvertToMakefilePath(cmd2);
|
||||||
std::string cmd;
|
std::string cmd;
|
||||||
std::string wd = ccg.GetWorkingDirectory();
|
std::string wd = ccg.GetWorkingDirectory();
|
||||||
if (!wd.empty()) {
|
if (!wd.empty()) {
|
||||||
cmd += "cd ";
|
cmd += "cd ";
|
||||||
cmd += this->ConvertToRelativeForMake(wd);
|
cmd += ConvertToMakefilePath(wd);
|
||||||
cmd += " && ";
|
cmd += " && ";
|
||||||
}
|
}
|
||||||
cmd += cmd2;
|
cmd += cmd2;
|
||||||
@@ -2336,7 +2342,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
|
|||||||
target->GetLocalGenerator()->GetMakefile()->GetSource(
|
target->GetLocalGenerator()->GetMakefile()->GetSource(
|
||||||
dep, cmSourceFileLocationKind::Known)) {
|
dep, cmSourceFileLocationKind::Known)) {
|
||||||
if (dsf->GetPropertyAsBool("SYMBOLIC")) {
|
if (dsf->GetPropertyAsBool("SYMBOLIC")) {
|
||||||
makefileStream << this->ConvertToRelativeForMake(dep) << ":\n";
|
makefileStream << ConvertToMakefilePath(dep) << ":\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4865,7 +4871,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile(
|
|||||||
gt->GetType() == cmStateEnums::SHARED_LIBRARY ||
|
gt->GetType() == cmStateEnums::SHARED_LIBRARY ||
|
||||||
gt->GetType() == cmStateEnums::MODULE_LIBRARY) {
|
gt->GetType() == cmStateEnums::MODULE_LIBRARY) {
|
||||||
std::string tfull = gt->GetFullPath(configName);
|
std::string tfull = gt->GetFullPath(configName);
|
||||||
std::string trel = this->ConvertToRelativeForMake(tfull);
|
std::string trel = ConvertToMakefilePath(tfull);
|
||||||
|
|
||||||
// Add this target to the post-build phases of its dependencies.
|
// Add this target to the post-build phases of its dependencies.
|
||||||
auto const y = target->GetDependTargets().find(configName);
|
auto const y = target->GetDependTargets().find(configName);
|
||||||
@@ -4891,7 +4897,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile(
|
|||||||
auto const x = target->GetDependLibraries().find(configName);
|
auto const x = target->GetDependLibraries().find(configName);
|
||||||
if (x != target->GetDependLibraries().end()) {
|
if (x != target->GetDependLibraries().end()) {
|
||||||
for (auto const& deplib : x->second) {
|
for (auto const& deplib : x->second) {
|
||||||
std::string file = this->ConvertToRelativeForMake(deplib);
|
std::string file = ConvertToMakefilePath(deplib);
|
||||||
makefileStream << "\\\n\t" << file;
|
makefileStream << "\\\n\t" << file;
|
||||||
dummyRules.insert(file);
|
dummyRules.insert(file);
|
||||||
}
|
}
|
||||||
@@ -4903,7 +4909,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile(
|
|||||||
std::string d = cmStrCat(this->GetTargetTempDir(gt, configName),
|
std::string d = cmStrCat(this->GetTargetTempDir(gt, configName),
|
||||||
"/lib", objLibName, ".a");
|
"/lib", objLibName, ".a");
|
||||||
|
|
||||||
std::string dependency = this->ConvertToRelativeForMake(d);
|
std::string dependency = ConvertToMakefilePath(d);
|
||||||
makefileStream << "\\\n\t" << dependency;
|
makefileStream << "\\\n\t" << dependency;
|
||||||
dummyRules.insert(dependency);
|
dummyRules.insert(dependency);
|
||||||
}
|
}
|
||||||
@@ -4911,7 +4917,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile(
|
|||||||
// Write the action to remove the target if it is out of date.
|
// Write the action to remove the target if it is out of date.
|
||||||
makefileStream << "\n"
|
makefileStream << "\n"
|
||||||
"\t/bin/rm -f "
|
"\t/bin/rm -f "
|
||||||
<< this->ConvertToRelativeForMake(tfull) << '\n';
|
<< ConvertToMakefilePath(tfull) << '\n';
|
||||||
// if building for more than one architecture
|
// if building for more than one architecture
|
||||||
// then remove those executables as well
|
// then remove those executables as well
|
||||||
if (this->Architectures.size() > 1) {
|
if (this->Architectures.size() > 1) {
|
||||||
@@ -4921,8 +4927,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile(
|
|||||||
std::string universalFile = cmStrCat(universal, architecture, '/',
|
std::string universalFile = cmStrCat(universal, architecture, '/',
|
||||||
gt->GetFullName(configName));
|
gt->GetFullName(configName));
|
||||||
makefileStream << "\t/bin/rm -f "
|
makefileStream << "\t/bin/rm -f "
|
||||||
<< this->ConvertToRelativeForMake(universalFile)
|
<< ConvertToMakefilePath(universalFile) << '\n';
|
||||||
<< '\n';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
makefileStream << "\n\n";
|
makefileStream << "\n\n";
|
||||||
@@ -5123,12 +5128,6 @@ cmDocumentationEntry cmGlobalXCodeGenerator::GetDocumentation()
|
|||||||
"Generate Xcode project files." };
|
"Generate Xcode project files." };
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmGlobalXCodeGenerator::ConvertToRelativeForMake(
|
|
||||||
std::string const& p)
|
|
||||||
{
|
|
||||||
return cmSystemTools::ConvertToOutputPath(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string cmGlobalXCodeGenerator::RelativeToSource(const std::string& p)
|
std::string cmGlobalXCodeGenerator::RelativeToSource(const std::string& p)
|
||||||
{
|
{
|
||||||
std::string const& rootSrc =
|
std::string const& rootSrc =
|
||||||
|
|||||||
@@ -163,7 +163,6 @@ private:
|
|||||||
std::string RelativeToSource(const std::string& p);
|
std::string RelativeToSource(const std::string& p);
|
||||||
std::string RelativeToRootBinary(const std::string& p);
|
std::string RelativeToRootBinary(const std::string& p);
|
||||||
std::string RelativeToBinary(const std::string& p);
|
std::string RelativeToBinary(const std::string& p);
|
||||||
std::string ConvertToRelativeForMake(std::string const& p);
|
|
||||||
void CreateCustomCommands(
|
void CreateCustomCommands(
|
||||||
cmXCodeObject* buildPhases, cmXCodeObject* sourceBuildPhase,
|
cmXCodeObject* buildPhases, cmXCodeObject* sourceBuildPhase,
|
||||||
cmXCodeObject* headerBuildPhase, cmXCodeObject* resourceBuildPhase,
|
cmXCodeObject* headerBuildPhase, cmXCodeObject* resourceBuildPhase,
|
||||||
|
|||||||
Reference in New Issue
Block a user