deterministic ordered file processing
This commit is contained in:
parent
511dfe7df0
commit
251dc88f93
32
ldoc.lua
32
ldoc.lua
|
@ -447,13 +447,22 @@ local function reorder_module_file ()
|
|||
end
|
||||
end
|
||||
|
||||
-- process files, optionally in order that respects master module files
|
||||
local function process_all_files(files)
|
||||
local sortfn = reorder_module_file()
|
||||
local files = tools.expand_file_list(files,'*.*')
|
||||
if sortfn then files:sort(sortfn) end
|
||||
for f in files:iter() do
|
||||
process_file(f, file_list)
|
||||
end
|
||||
if #file_list == 0 then quit "no source files found" end
|
||||
end
|
||||
|
||||
if type(args.file) == 'table' then
|
||||
-- this can only be set from config file so we can assume it's already read
|
||||
args.file.sortfn = reorder_module_file()
|
||||
process_file_list(args.file,'*.*',process_file, file_list)
|
||||
if #file_list == 0 then quit "no source files specified" end
|
||||
-- this can only be set from config file so we can assume config is already read
|
||||
process_all_files(args.file)
|
||||
|
||||
elseif path.isdir(args.file) then
|
||||
local files = List(dir.getallfiles(args.file,'*.*'))
|
||||
-- use any configuration file we find, if not already specified
|
||||
if not config_dir then
|
||||
local config_files = files:filter(function(f)
|
||||
|
@ -466,16 +475,9 @@ elseif path.isdir(args.file) then
|
|||
end
|
||||
end
|
||||
end
|
||||
-- process files, optionally in order that respects master module files
|
||||
local sortfn = reorder_module_file()
|
||||
if sortfn then files:sort(sortfn) end
|
||||
for f in files:iter() do
|
||||
process_file(f, file_list)
|
||||
end
|
||||
|
||||
if #file_list == 0 then
|
||||
quit(quote(args.file).." contained no source files")
|
||||
end
|
||||
|
||||
process_all_files({args.file})
|
||||
|
||||
elseif path.isfile(args.file) then
|
||||
-- a single file may be accompanied by a config.ld in the same dir
|
||||
if not config_dir then
|
||||
|
|
|
@ -462,7 +462,13 @@ function M.abspath (f)
|
|||
return res
|
||||
end
|
||||
|
||||
function M.process_file_list (list, mask, operation, ...)
|
||||
function M.getallfiles(root,mask)
|
||||
local res = List(dir.getallfiles(root,mask))
|
||||
res:sort()
|
||||
return res
|
||||
end
|
||||
|
||||
function M.expand_file_list (list, mask)
|
||||
local exclude_list = list.exclude and M.files_from_list(list.exclude, mask)
|
||||
local files = List()
|
||||
local function process (f)
|
||||
|
@ -473,7 +479,7 @@ function M.process_file_list (list, mask, operation, ...)
|
|||
end
|
||||
for _,f in ipairs(list) do
|
||||
if path.isdir(f) then
|
||||
local dfiles = List(dir.getallfiles(f,mask))
|
||||
local dfiles = M.getallfiles(f,mask)
|
||||
for f in dfiles:iter() do
|
||||
process(f)
|
||||
end
|
||||
|
@ -483,11 +489,11 @@ function M.process_file_list (list, mask, operation, ...)
|
|||
quit("file or directory does not exist: "..M.quote(f))
|
||||
end
|
||||
end
|
||||
return files
|
||||
end
|
||||
|
||||
if list.sortfn then
|
||||
files:sort(list.sortfn)
|
||||
end
|
||||
|
||||
function M.process_file_list (list, mask, operation, ...)
|
||||
local files = M.expand_file_list(list,mask)
|
||||
for f in files:iter() do
|
||||
operation(f,...)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue