Commits

Jason Perkins committed 7c62979

Merged file configurations and nodes in source trees

Comments (0)

Files changed (4)

src/actions/vstudio/vs200x_vcproj.lua

 			-- 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)
 		
 			-- 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

src/actions/vstudio/vs2010_vcxproj.lua

 					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)

src/project/project.lua

 -- @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)
 			node.abspath = fcfg.abspath
 			node.relpath = fcfg.relpath
 			node.vpath = fcfg.vpath
-			node.cfg = fcfg
 		end
 
 		premake.tree.trimroot(tr)
 				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

tests/project/test_vpaths.lua

 	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
 --