diff --git a/modules/xcode/xcode_common.lua b/modules/xcode/xcode_common.lua index 20585c9a..8896b2d1 100644 --- a/modules/xcode/xcode_common.lua +++ b/modules/xcode/xcode_common.lua @@ -812,7 +812,7 @@ _p(3,'files = (') tree.traverse(tr, { onleaf = function(node) - if xcode.getbuildcategory(node) == "Sources" then + if xcode.getbuildcategory(node) == "Sources" and node.buildid then _p(4,'%s /* %s in Sources */,', node.buildid, node.name) end end diff --git a/modules/xcode/xcode_project.lua b/modules/xcode/xcode_project.lua index 819b7723..2f98cb52 100644 --- a/modules/xcode/xcode_project.lua +++ b/modules/xcode/xcode_project.lua @@ -15,6 +15,39 @@ local fileconfig = p.fileconfig local tree = p.tree +-- +-- Checks if a node must be excluded completely from a target or not. It will +-- return true only if the node has the "ExcludeFromBuild" flag in all the +-- configurations. +-- +-- @param node +-- The node to check. +-- @param prj +-- The project being generated. +-- @returns +-- A boolean, telling whether the node must be excluded from its target or not. +-- + function xcode.mustExcludeFromTarget(node, prj) + if not node.configs then + return false + end + + local value + for cfg in premake.project.eachconfig(prj) do + local filecfg = premake.fileconfig.getconfig(node, cfg) + if filecfg then + local newValue = not not filecfg.flags.ExcludeFromBuild + if value == nil then + value = newValue + elseif value ~= newValue then + print("WARNING: " .. node.name .. " is excluded in just some configurations. Autocompletion will not work correctly on this file in Xcode.") + return false + end + end + end + return value + end + -- -- Create a tree corresponding to what is shown in the Xcode project browser -- pane, with nodes for files and folders, resources, frameworks, and products. @@ -108,7 +141,7 @@ node.isResource = xcode.isItemResource(prj, node) -- assign build IDs to buildable files - if xcode.getbuildcategory(node) and not node.excludefrombuild then + if xcode.getbuildcategory(node) and not node.excludefrombuild and not xcode.mustExcludeFromTarget(node, tr.project) then node.buildid = xcode.newid(node.name, "build", node.path) end