Removed deprecated walksources() function

This commit is contained in:
Jason Perkins 2011-06-09 15:19:44 -04:00
parent 73f6ba2a6c
commit 9083e8a47e
2 changed files with 0 additions and 136 deletions

View File

@ -611,54 +611,3 @@
function premake.isdotnetproject(prj)
return (prj.language == "C#")
end
--
-- Walk the list of source code files, breaking them into "groups" based
-- on the directory hierarchy.
--
local function walksources(cfg, fn, group, nestlevel, finished)
local grouplen = group:len()
local gname = iif(group:endswith("/"), group:sub(1, -2), group)
-- open this new group
if (nestlevel >= 0) then
fn(cfg, gname, "GroupStart", nestlevel)
end
-- scan the list of files for items which belong in this group
for _,fname in ipairs(cfg.files) do
if (fname:startswith(group)) then
-- is there a subgroup within this item?
local _,split = fname:find("[^\.]/", grouplen + 1)
if (split) then
local subgroup = fname:sub(1, split)
if (not finished[subgroup]) then
finished[subgroup] = true
walksources(cfg, fn, subgroup, nestlevel + 1, finished)
end
end
end
end
-- process all files that belong in this group
for _,fname in ipairs(cfg.files) do
if (fname:startswith(group) and not fname:find("[^\.]/", grouplen + 1)) then
fn(cfg, fname, "GroupItem", nestlevel + 1)
end
end
-- close the group
if (nestlevel >= 0) then
fn(cfg, gname, "GroupEnd", nestlevel)
end
end
function premake.walksources(cfg, fn)
walksources(cfg, fn, "", -1, {})
end

View File

@ -62,88 +62,3 @@
result = premake.getlinks(cfg, "all", "fullpath")
test.isequal("user32.lib gdi32.lib", table.concat(result, " "))
end
--
-- premake.walksources() tests
--
local function walktest(prj, fname, state, nestlevel)
local item
if (state == "GroupStart") then
item = "<" .. fname .. ">"
elseif (state == "GroupEnd") then
item = "</" .. fname .. ">"
else
item = fname
end
result = result .. string.rep("-", nestlevel) .. item .. "\n"
end
function T.project.walksources_OnNoFiles()
premake.walksources(cfg, walktest)
test.isequal("\n"
.. ""
,result)
end
function T.project.walksources_OnSingleFile()
cfg.files = {
"hello.cpp"
}
premake.walksources(cfg, walktest)
test.isequal("\n"
.. "hello.cpp\n"
,result)
end
function T.project.walksources_OnNestedGroups()
cfg.files = {
"rootfile.c",
"level1/level1.c",
"level1/level2/level2.c"
}
premake.walksources(cfg, walktest)
test.isequal("\n"
.. "<level1>\n"
.. "-<level1/level2>\n"
.. "--level1/level2/level2.c\n"
.. "-</level1/level2>\n"
.. "-level1/level1.c\n"
.. "</level1>\n"
.. "rootfile.c\n"
,result)
end
function T.project.walksources_OnDottedFolders()
cfg.files = {
"src/lua-5.1.2/lapi.c"
}
premake.walksources(cfg, walktest)
test.isequal("\n"
.. "<src>\n"
.. "-<src/lua-5.1.2>\n"
.. "--src/lua-5.1.2/lapi.c\n"
.. "-</src/lua-5.1.2>\n"
.. "</src>\n"
,result)
end
function T.project.walksources_OnDotDotLeaders()
cfg.files = {
"../src/hello.c",
}
premake.walksources(cfg, walktest)
test.isequal("\n"
.. "<../src>\n"
.. "-../src/hello.c\n"
.. "</../src>\n"
,result)
end