Condensed parameters to walksources to make trimpaths easier to implement
This commit is contained in:
parent
96da8eb72c
commit
2be34e3866
@ -8,7 +8,7 @@
|
||||
_p('<?xml version="1.0" encoding="utf-8"?>')
|
||||
_p('<CodeLite_Project Name="%s">', premake.esc(prj.name))
|
||||
|
||||
premake.walksources(prj, prj.files, premake.codelite_files)
|
||||
premake.walksources(prj, premake.codelite_files)
|
||||
|
||||
local types = {
|
||||
ConsoleApp = "Executable",
|
||||
|
@ -534,7 +534,7 @@
|
||||
_p('\t</References>')
|
||||
|
||||
_p('\t<Files>')
|
||||
premake.walksources(prj, prj.files, _VS.files)
|
||||
premake.walksources(prj, _VS.files)
|
||||
_p('\t</Files>')
|
||||
|
||||
_p('\t<Globals>')
|
||||
|
@ -505,17 +505,17 @@
|
||||
-- on the directory hierarchy.
|
||||
--
|
||||
|
||||
local function walksources(prj, files, fn, group, nestlevel, finished)
|
||||
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(prj, gname, "GroupStart", nestlevel)
|
||||
fn(cfg, gname, "GroupStart", nestlevel)
|
||||
end
|
||||
|
||||
-- scan the list of files for items which belong in this group
|
||||
for _,fname in ipairs(files) do
|
||||
for _,fname in ipairs(cfg.files) do
|
||||
if (fname:startswith(group)) then
|
||||
|
||||
-- is there a subgroup within this item?
|
||||
@ -524,7 +524,7 @@
|
||||
local subgroup = fname:sub(1, split)
|
||||
if (not finished[subgroup]) then
|
||||
finished[subgroup] = true
|
||||
walksources(prj, files, fn, subgroup, nestlevel + 1, finished)
|
||||
walksources(cfg, fn, subgroup, nestlevel + 1, finished)
|
||||
end
|
||||
end
|
||||
|
||||
@ -532,19 +532,19 @@
|
||||
end
|
||||
|
||||
-- process all files that belong in this group
|
||||
for _,fname in ipairs(files) do
|
||||
for _,fname in ipairs(cfg.files) do
|
||||
if (fname:startswith(group) and not fname:find("[^\.]/", grouplen + 1)) then
|
||||
fn(prj, fname, "GroupItem", nestlevel + 1)
|
||||
fn(cfg, fname, "GroupItem", nestlevel + 1)
|
||||
end
|
||||
end
|
||||
|
||||
-- close the group
|
||||
if (nestlevel >= 0) then
|
||||
fn(prj, gname, "GroupEnd", nestlevel)
|
||||
fn(cfg, gname, "GroupEnd", nestlevel)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function premake.walksources(prj, files, fn)
|
||||
walksources(prj, files, fn, "", -1, {})
|
||||
function premake.walksources(cfg, fn)
|
||||
walksources(cfg, fn, "", -1, {})
|
||||
end
|
||||
|
@ -1,15 +1,18 @@
|
||||
--
|
||||
-- tests/test_project.lua
|
||||
-- Automated test suite for the project support functions.
|
||||
-- Copyright (c) 2008 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2008, 2009 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
|
||||
T.project = { }
|
||||
|
||||
local result
|
||||
local cfg, result
|
||||
function T.project.setup()
|
||||
_ACTION = "gmake"
|
||||
cfg = {}
|
||||
cfg.files = {}
|
||||
cfg.trimpaths = {}
|
||||
result = "\n"
|
||||
end
|
||||
|
||||
@ -31,30 +34,33 @@
|
||||
result = result .. string.rep("-", nestlevel) .. item .. "\n"
|
||||
end
|
||||
|
||||
|
||||
function T.project.walksources_OnNoFiles()
|
||||
premake.walksources({}, {}, walktest)
|
||||
premake.walksources(cfg, walktest)
|
||||
test.isequal("\n"
|
||||
.. ""
|
||||
,result)
|
||||
end
|
||||
|
||||
|
||||
function T.project.walksources_OnSingleFile()
|
||||
local files = {
|
||||
cfg.files = {
|
||||
"hello.cpp"
|
||||
}
|
||||
premake.walksources({}, files, walktest)
|
||||
premake.walksources(cfg, walktest)
|
||||
test.isequal("\n"
|
||||
.. "hello.cpp\n"
|
||||
,result)
|
||||
end
|
||||
|
||||
|
||||
function T.project.walksources_OnNestedGroups()
|
||||
local files = {
|
||||
cfg.files = {
|
||||
"rootfile.c",
|
||||
"level1/level1.c",
|
||||
"level1/level2/level2.c"
|
||||
}
|
||||
premake.walksources({}, files, walktest)
|
||||
premake.walksources(cfg, walktest)
|
||||
test.isequal("\n"
|
||||
.. "<level1>\n"
|
||||
.. "-<level1/level2>\n"
|
||||
@ -66,11 +72,12 @@
|
||||
,result)
|
||||
end
|
||||
|
||||
|
||||
function T.project.walksources_OnDottedFolders()
|
||||
local files = {
|
||||
cfg.files = {
|
||||
"src/lua-5.1.2/lapi.c"
|
||||
}
|
||||
premake.walksources({}, files, walktest)
|
||||
premake.walksources(cfg, walktest)
|
||||
test.isequal("\n"
|
||||
.. "<src>\n"
|
||||
.. "-<src/lua-5.1.2>\n"
|
||||
@ -80,15 +87,15 @@
|
||||
,result)
|
||||
end
|
||||
|
||||
|
||||
function T.project.walksources_OnDotDotLeaders()
|
||||
local files = {
|
||||
cfg.files = {
|
||||
"../src/hello.c",
|
||||
}
|
||||
premake.walksources({}, files, walktest)
|
||||
premake.walksources(cfg, walktest)
|
||||
test.isequal("\n"
|
||||
.. "<../src>\n"
|
||||
.. "-../src/hello.c\n"
|
||||
.. "</../src>\n"
|
||||
,result)
|
||||
end
|
||||
|
Reference in New Issue
Block a user