Updated lbs to use new uniproc library
Fixed bug in fs.list_alldirs where it used directory_iterator rather that recursive_directory_iterator Fixed memory/type bugs in lua_platform.cpp Updated lbs.lua to reflect this
This commit is contained in:
70
lbs.lua
70
lbs.lua
@@ -47,22 +47,24 @@ local function get_required_objects(dirs, src_extension, obj_prefix, obj_postfix
|
||||
obj_postfix = obj_postfix or ".o"
|
||||
local objs = {}
|
||||
local new_src = {}
|
||||
for fsobj in fs.forall(dirs) do
|
||||
-- Get all files in the directory
|
||||
local src_files
|
||||
if fs.is_dir(fsobj) then src_files = fs.list_alldirs(fsobj)
|
||||
else src_files = {fsobj} end
|
||||
-- For each of the files,
|
||||
for _, src_file in pairs(src_files) do repeat
|
||||
-- Skip files that don't end in the provided extension
|
||||
if (fs.extension(src_file) ~= src_extension) then break end
|
||||
local obj_file = obj_prefix .. src_file .. obj_postfix
|
||||
-- Skip old files that do not need to be recompiled
|
||||
if not fs.is_newer(src_file) then break end
|
||||
-- Add the src and obj file to a table that will be returned
|
||||
objs[#objs+1] = obj_file
|
||||
new_src[#new_src+1] = src_file
|
||||
until true end
|
||||
for _,dir in pairs(dirs) do
|
||||
for fsobj in fs.forall(dir) do
|
||||
-- Get all files in the directory
|
||||
local src_files
|
||||
if fs.is_dir(fsobj) then src_files = fs.list_alldirs(fsobj)
|
||||
else src_files = {fsobj} end
|
||||
-- For each of the files,
|
||||
for _, src_file in pairs(src_files) do repeat
|
||||
-- Skip files that don't end in the provided extension
|
||||
if (fs.extension(src_file) ~= src_extension) then break end
|
||||
local obj_file = obj_prefix .. src_file .. obj_postfix
|
||||
-- Skip old files that do not need to be recompiled
|
||||
if not fs.is_newer(src_file, obj_file) then break end
|
||||
-- Add the src and obj file to a table that will be returned
|
||||
objs[#objs+1] = obj_file
|
||||
new_src[#new_src+1] = src_file
|
||||
until true end
|
||||
end
|
||||
end
|
||||
return objs, new_src
|
||||
end
|
||||
@@ -84,37 +86,59 @@ local function compile(CXX, src_dirs, include_dirs, defines, additional_argument
|
||||
argv[#argv+1] = args
|
||||
end
|
||||
|
||||
print("Compiling...")
|
||||
local ec, stdout, stderr = platform.exec_parallel(CXX, config.max_parallel, argv)
|
||||
for i,ec in pairs(ec) do
|
||||
if (ec ~= 0) then
|
||||
print("Command \"" .. CXX .. " " .. table.concat(argv[i], " ") .. "\" failed with exit code " .. tostring(ec) .. " and output;")
|
||||
if (#stderr ~= 0) then print(stderr[i]) else print(stdout[i]) end
|
||||
print("Command ".. tostring(i) .." \"" .. CXX .. " " .. table.concat(argv[i], " ") .. "\" failed with exit code " .. tostring(ec) .. " and output;")
|
||||
print(stderr[i])
|
||||
print(stdout[i])
|
||||
print()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function link(LNK, obj_dirs, library_dirs, linker_inputs, additional_arguments)
|
||||
local function link(LNK, obj_dirs, library_dirs, linker_inputs, additional_arguments, file_output)
|
||||
local argv = {}
|
||||
for _,v in pairs(library_dirs) do argv[#argv+1] = "-L\"" .. v .. "\"" end
|
||||
for _,v in pairs(linker_inputs) do argv[#argv+1] = "-l\"" .. v .. "\"" end
|
||||
for _,v in pairs(additional_arguments) do argv[#argv+1] = v end
|
||||
|
||||
|
||||
for _,obj_dir in pairs(obj_dirs) do
|
||||
local obj_files = fs.list_alldirs("obj")
|
||||
for _,obj_file in pairs(obj_files) do repeat
|
||||
if fs.extension(obj_file) ~= ".o" then break end
|
||||
argv[#argv+1] = obj_file
|
||||
until true end
|
||||
end
|
||||
|
||||
argv[#argv+1] = "-o " .. file_output
|
||||
|
||||
print("Linking...")
|
||||
local ec, stdout, stderr = platform.exec(LNK, argv)
|
||||
if (ec ~= 0) then
|
||||
print("Command \"" .. LNK .. " " .. table.concat(argv) .. "\" failed with exit code " .. tostring(ec) .. " and output;")
|
||||
if (#stderr ~= 0) then print(stderr[i]) else print(stdout[i]) end
|
||||
print("Command \"" .. LNK .. " " .. table.concat(argv, " ") .. "\" failed with exit code " .. tostring(ec) .. " and output;")
|
||||
print(stderr)
|
||||
print(stdout)
|
||||
print()
|
||||
end
|
||||
end
|
||||
|
||||
function build(...)
|
||||
local args = {...}
|
||||
local program_name = program_output
|
||||
for section in config.target:gmatch("[^-]+") do
|
||||
if section == "windows" then program_name = program_name .. ".exe" end
|
||||
end
|
||||
|
||||
config = load_config(config, args)
|
||||
print("Building " .. config.buildmode .. " with up to " .. tostring(config.max_parallel) .. " concurrent jobs")
|
||||
|
||||
compile(CXX, source_dirs, include_dirs, defines, additional_arguments)
|
||||
link(CXX, "obj", library_dirs, linker_inputs, {})
|
||||
|
||||
link(CXX, {"obj"}, library_dirs, linker_inputs, {}, program_name)
|
||||
end
|
||||
|
||||
function main(...) build(...) end
|
||||
|
||||
return 0
|
||||
Reference in New Issue
Block a user