Adding bam build system.
This commit is contained in:
parent
9835082b67
commit
f67f89715a
5 changed files with 335 additions and 0 deletions
77
.bam/functions.lua
Normal file
77
.bam/functions.lua
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
|
||||
local _systems = {
|
||||
"Win32",
|
||||
-- "Linux"
|
||||
}
|
||||
|
||||
|
||||
-- Returns a string of all supported systems
|
||||
function supported_systems()
|
||||
return table.concat(_systems, ', ')
|
||||
end
|
||||
|
||||
|
||||
-- Detect what system we currently are on.
|
||||
function system()
|
||||
|
||||
local win = os.getenv('OS')
|
||||
|
||||
if win:lower():match('windows') then
|
||||
return _systems[1]
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Defines a module
|
||||
-- path: base path to source files.
|
||||
-- src: table of source files.
|
||||
function Module(path, src)
|
||||
local r = {}
|
||||
for k, v in pairs(src) do
|
||||
r[k] = 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
|
||||
|
||||
-- Build example binary.
|
||||
-- This function Imports "examples/<name>/bam.lua"
|
||||
-- that file must define a table "src" that contains the source files.
|
||||
function BuildExample(settings, name, dependencies)
|
||||
|
||||
Import("examples/" .. name .. "/bam.lua")
|
||||
|
||||
exe = Link(settings, "examples/" .. name, Compile(settings, src))
|
||||
|
||||
if dependencies ~= nil and #dependencies > 0 then
|
||||
AddDependency(exe, dependencies)
|
||||
end
|
||||
|
||||
return exe
|
||||
end
|
||||
|
||||
-- Build examples binaries.
|
||||
-- Just a wrapper for BuildExample. taking a table of names instead.
|
||||
function BuildExamples(settings, names, dependencies)
|
||||
|
||||
local r = {}
|
||||
for i = 1, #names do
|
||||
r[i] = BuildExample(settings, names[i], dependencies)
|
||||
end
|
||||
return r
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue