83 lines
1.7 KiB
Lua
83 lines
1.7 KiB
Lua
|
|
Import("path.lua")
|
|
Import("utils.lua")
|
|
|
|
local _systems = {
|
|
"Win32",
|
|
"Unix"
|
|
}
|
|
|
|
|
|
-- Returns a string of all supported systems
|
|
function supported_systems()
|
|
return table.concat(_systems, ', ')
|
|
end
|
|
|
|
|
|
-- Return True if 'value' is a supported system. False otherwise.
|
|
function valid_system(value)
|
|
return contains(_systems, value)
|
|
end
|
|
|
|
|
|
-- Find what host system we are on.
|
|
-- Returns nil if system could not be determined.
|
|
function host_system()
|
|
|
|
-- Check "platform" variable set by bam first.
|
|
if platform == "win32" or platform == "win64" then
|
|
return _systems[1]
|
|
end
|
|
if platform == "linux" then
|
|
return _systems[2]
|
|
end
|
|
|
|
-- next, check if we are on windows by checking
|
|
-- the 'OS' environment variable
|
|
local win = os.getenv('OS')
|
|
if win ~= nil and win:lower():match('windows') then
|
|
return _systems[1]
|
|
end
|
|
|
|
return nil
|
|
end
|
|
|
|
function SetSettingsPrefix(settings, prefix)
|
|
settings.labelprefix = string.format("[%s] ", prefix)
|
|
end
|
|
|
|
-- Copy settings with a optional label prefix.
|
|
function CopySettings(settings, prefix)
|
|
local n = TableDeepCopy(settings)
|
|
if prefix ~= nil then
|
|
SetSettingsPrefix(n, prefix)
|
|
end
|
|
return n
|
|
end
|
|
|
|
-- Defines a module
|
|
-- path: base path to source files.
|
|
-- src: table of source files.
|
|
function Module(path, src)
|
|
path = RelPath(path)
|
|
local r = {}
|
|
for k, v in pairs(src) do
|
|
r[k] = PathJoin(path, v)
|
|
end
|
|
return r
|
|
end
|
|
|
|
-- Copy a directory src to dst
|
|
-- src = "path/to/a", dest = "path/to/b" -> the whole content
|
|
-- of "a" will be copied to "path/to/b"
|
|
function CopyDir(dst, src)
|
|
local r = {}
|
|
local base = PathDir(src)
|
|
local files = CollectRecursive(Path(src) .. "/*")
|
|
|
|
for k, v in pairs(files) do
|
|
local rdir = PathDir(v:sub(base:len() + 1))
|
|
r[k] = CopyToDirectory(PathJoin(dst, rdir), v)
|
|
end
|
|
return r
|
|
end
|