Xcode: Fix custom command work-dir placeholders in "new build system"

The placeholders for `CONFIGURATION` and `EFFECTIVE_PLATFORM_NAME` need
to be handled in the `WORKING_DIRECTORY` of custom commands just as we
already do for the `COMMAND`.

Fixes: #21483
This commit is contained in:
Brad King
2020-11-23 10:09:20 -05:00
parent 4549027a09
commit 36921d2d23
6 changed files with 38 additions and 3 deletions
+11 -3
View File
@@ -1965,6 +1965,15 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateRunScriptBuildPhase(
return buildPhase;
}
namespace {
void ReplaceScriptVars(std::string& cmd)
{
cmSystemTools::ReplaceString(cmd, "$(CONFIGURATION)", "$CONFIGURATION");
cmSystemTools::ReplaceString(cmd, "$(EFFECTIVE_PLATFORM_NAME)",
"$EFFECTIVE_PLATFORM_NAME");
}
}
std::string cmGlobalXCodeGenerator::ConstructScript(
cmCustomCommandGenerator const& ccg)
{
@@ -1975,6 +1984,7 @@ std::string cmGlobalXCodeGenerator::ConstructScript(
wd = lg->GetCurrentBinaryDirectory();
}
wd = lg->ConvertToOutputFormat(wd, cmOutputConverter::SHELL);
ReplaceScriptVars(wd);
script = cmStrCat(script, " cd ", wd, "\n");
for (unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c) {
std::string cmd = ccg.GetCommand(c);
@@ -1984,9 +1994,7 @@ std::string cmGlobalXCodeGenerator::ConstructScript(
cmSystemTools::ReplaceString(cmd, "/./", "/");
cmd = lg->ConvertToOutputFormat(cmd, cmOutputConverter::SHELL);
ccg.AppendArguments(c, cmd);
cmSystemTools::ReplaceString(cmd, "$(CONFIGURATION)", "$CONFIGURATION");
cmSystemTools::ReplaceString(cmd, "$(EFFECTIVE_PLATFORM_NAME)",
"$EFFECTIVE_PLATFORM_NAME");
ReplaceScriptVars(cmd);
script = cmStrCat(script, " ", cmd, '\n');
}
return script;