From 0b241993c2299c422f6bc1773756f293dc0ab330 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Tue, 27 Mar 2012 18:54:15 -0400 Subject: [PATCH] Merged file configurations and nodes in source trees --- src/actions/vstudio/vs200x_vcproj.lua | 6 +++--- src/actions/vstudio/vs2010_vcxproj.lua | 6 +++--- src/project/project.lua | 26 +++++++++----------------- tests/project/test_vpaths.lua | 21 --------------------- 4 files changed, 15 insertions(+), 44 deletions(-) diff --git a/src/actions/vstudio/vs200x_vcproj.lua b/src/actions/vstudio/vs200x_vcproj.lua index d60e7c4b..47745687 100644 --- a/src/actions/vstudio/vs200x_vcproj.lua +++ b/src/actions/vstudio/vs200x_vcproj.lua @@ -702,7 +702,7 @@ -- source files are handled at the leaves onleaf = function(node, depth) _p(depth, '') 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 diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index 9cce944f..64e63bf6 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -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) diff --git a/src/project/project.lua b/src/project/project.lua index 1fb38bbb..93b04627 100755 --- a/src/project/project.lua +++ b/src/project/project.lua @@ -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 diff --git a/tests/project/test_vpaths.lua b/tests/project/test_vpaths.lua index d1f3194d..57e8f183 100644 --- a/tests/project/test_vpaths.lua +++ b/tests/project/test_vpaths.lua @@ -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 --