Remove commands optimization which breaks tokens

When a build command contains a token which references a configuration, ex. `{cfg.platform}`, the platform optimizations removed by this commit would cause a crash: "Attempt to index a nil value (global 'cfg')".

Fixes #1013
This commit is contained in:
starkos 2020-02-13 20:04:24 -05:00
parent a640f86d5b
commit ed92aba9c2
2 changed files with 5 additions and 17 deletions

View File

@ -1099,7 +1099,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -e\nls src\ncp \"a\" \"b\"";
shellScript = "set -e\nif [ \"${CONFIGURATION}\" = \"Debug\" ]; then\nls src\ncp \"a\" \"b\"\nfi\nif [ \"${CONFIGURATION}\" = \"Release\" ]; then\nls src\ncp \"a\" \"b\"\nfi";
};
/* End PBXShellScriptBuildPhase section */
]]
@ -1158,7 +1158,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -e\nls src\nif [ \"${CONFIGURATION}\" = \"Debug\" ]; then\ncp a b\nfi";
shellScript = "set -e\nif [ \"${CONFIGURATION}\" = \"Debug\" ]; then\nls src\ncp a b\nfi\nif [ \"${CONFIGURATION}\" = \"Release\" ]; then\nls src\nfi";
};
/* End PBXShellScriptBuildPhase section */
]]

View File

@ -743,16 +743,7 @@
for _, node in ipairs(tr.products.children) do
local name = tr.project.name
-- This function checks whether there are build commands of a specific
-- type to be executed; they will be generated correctly, but the project
-- commands will not contain any per-configuration commands, so the logic
-- has to be extended a bit to account for that.
local function hasBuildCommands(which)
-- standard check...this is what existed before
if #tr.project[which] > 0 then
return true
end
-- what if there are no project-level commands? check configs...
for _, cfg in ipairs(tr.configs) do
if #cfg[which] > 0 then
return true
@ -933,16 +924,13 @@
local wrapperWritten = false
local function doblock(id, name, which)
-- start with the project-level commands (most common)
local prjcmds = tr.project[which]
local commands = table.join(prjcmds, {})
-- see if there are any config-specific commands to add
local commands = {}
for _, cfg in ipairs(tr.configs) do
local cfgcmds = cfg[which]
if #cfgcmds > #prjcmds then
if #cfgcmds > 0 then
table.insert(commands, 'if [ "${CONFIGURATION}" = "' .. cfg.buildcfg .. '" ]; then')
for i = #prjcmds + 1, #cfgcmds do
for i = 1, #cfgcmds do
table.insert(commands, cfgcmds[i])
end
table.insert(commands, 'fi')