Merged file configurations and nodes in source trees

This commit is contained in:
Jason Perkins 2012-03-27 18:54:15 -04:00
parent 07f000ecda
commit 0b241993c2
4 changed files with 15 additions and 44 deletions

View File

@ -702,7 +702,7 @@
-- source files are handled at the leaves
onleaf = function(node, depth)
_p(depth, '<File')
_p(depth, '\tRelativePath="%s"', path.translate(node.cfg.relpath))
_p(depth, '\tRelativePath="%s"', path.translate(node.relpath))
_p(depth, '\t>')
vc200x.fileConfiguration(prj, node, depth + 1)
@ -732,14 +732,14 @@
-- get any settings specific to this file for this configuration;
-- if nil this file is excluded from the configuration entirely
local filecfg = config.getfileconfig(cfg, node.cfg.abspath)
local filecfg = config.getfileconfig(cfg, node.abspath)
-- if there is a file configuration, see if it contains any values
-- (will be empty if it matches the project config)
local hasSettings = (filecfg ~= nil and filecfg.terms ~= nil)
-- check to see if this is the PCH source file
local isPchSource = (prj.pchsource == node.cfg.abspath and not cfg.flags.NoPCH)
local isPchSource = (prj.pchsource == node.abspath and not cfg.flags.NoPCH)
-- only write the element if we have something to say
if compileAs or isPchSource or not filecfg or hasSettings then

View File

@ -459,11 +459,11 @@
local filecfg = config.getfileconfig(cfg, node.abspath)
if filecfg and filecfg.buildrule then
table.insert(groups.CustomBuild, node)
elseif path.iscppfile(node.relpath) then
elseif path.iscppfile(node.name) then
table.insert(groups.ClCompile, node)
elseif path.iscppheader(node.relpath) then
elseif path.iscppheader(node.name) then
table.insert(groups.ClInclude, node)
elseif path.isresourcefile(node.relpath) then
elseif path.isresourcefile(node.name) then
table.insert(groups.ResourceCompile, node)
else
table.insert(groups.None, node)

View File

@ -293,9 +293,15 @@
-- @param prj
-- The project to query.
-- @return
-- A tree object containing the source file hierarchy. Each leaf
-- node contains a file configuration object at node.cfg; see
-- project.eachfile() for a description of this object.
-- A tree object containing the source file hierarchy. Leaf nodes
-- representing the individual files contain the fields:
-- abspath - the absolute path of the file
-- relpath - the relative path from the project to the file
-- vpath - the file's virtual path
-- All nodes contain the fields:
-- path - the node's path within the tree
-- realpath - the node's file system path (nil for virtual paths)
-- name - the directory or file name represented by the node
--
function project.getsourcetree(prj)
@ -322,7 +328,6 @@
node.abspath = fcfg.abspath
node.relpath = fcfg.relpath
node.vpath = fcfg.vpath
node.cfg = fcfg
end
premake.tree.trimroot(tr)
@ -376,19 +381,6 @@
end
end
end
-- remove any dot ("./", "../") patterns from the start of the path
local changed
repeat
changed = true
if vpath:startswith("./") then
vpath = vpath:sub(3)
elseif vpath:startswith("../") then
vpath = vpath:sub(4)
else
changed = false
end
until not changed
return vpath
end

View File

@ -104,27 +104,6 @@
end
--
-- Test directory dot patterns
--
function suite.RemovesLeadingDotFolder()
prepare()
test.isequal("hello.c", project.getvpath(prj, "./hello.c"))
end
function suite.RemovesLeadingDotDotFolder()
prepare()
test.isequal("hello.c", project.getvpath(prj, "../hello.c"))
end
function suite.RemovesMultipleLeadingDotDotFolders()
prepare()
test.isequal("src/hello.c", project.getvpath(prj, "../../src/hello.c"))
end
--
-- Test with project locations
--