Initial community commit
This commit is contained in:
parent
537bcbc862
commit
fc06254474
16440 changed files with 4239995 additions and 2 deletions
9
Src/external_dependencies/openmpt-trunk/include/premake/modules/raw/README.md
vendored
Normal file
9
Src/external_dependencies/openmpt-trunk/include/premake/modules/raw/README.md
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
Premake extension to support writing the raw lua tables.
|
||||
|
||||
### Usage ###
|
||||
|
||||
Simply generate your project using the `raw` action:
|
||||
```bash
|
||||
premake5 raw
|
||||
```
|
||||
and open the generated workspace.raw file in any text editor.
|
5
Src/external_dependencies/openmpt-trunk/include/premake/modules/raw/_manifest.lua
vendored
Normal file
5
Src/external_dependencies/openmpt-trunk/include/premake/modules/raw/_manifest.lua
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
return {
|
||||
"_preload.lua",
|
||||
"raw.lua",
|
||||
"raw_action.lua",
|
||||
}
|
16
Src/external_dependencies/openmpt-trunk/include/premake/modules/raw/_preload.lua
vendored
Normal file
16
Src/external_dependencies/openmpt-trunk/include/premake/modules/raw/_preload.lua
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
newaction
|
||||
{
|
||||
trigger = "raw",
|
||||
shortname = "Raw output",
|
||||
description = "Generate raw representation of Premake structures",
|
||||
|
||||
onsolution = function(sln)
|
||||
require('raw')
|
||||
|
||||
premake.generate(sln, ".raw", premake.raw.workspace)
|
||||
end,
|
||||
}
|
||||
|
||||
return function(cfg)
|
||||
return (_ACTION == "raw")
|
||||
end
|
11
Src/external_dependencies/openmpt-trunk/include/premake/modules/raw/raw.lua
vendored
Normal file
11
Src/external_dependencies/openmpt-trunk/include/premake/modules/raw/raw.lua
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
local p = premake
|
||||
|
||||
p.modules.raw = {}
|
||||
|
||||
local m = p.modules.raw
|
||||
m.elements = {}
|
||||
|
||||
dofile("_preload.lua")
|
||||
dofile("raw_action.lua")
|
||||
|
||||
return m
|
76
Src/external_dependencies/openmpt-trunk/include/premake/modules/raw/raw_action.lua
vendored
Normal file
76
Src/external_dependencies/openmpt-trunk/include/premake/modules/raw/raw_action.lua
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
local p = premake
|
||||
p.raw = { }
|
||||
local raw = p.raw
|
||||
local gvisited = { }
|
||||
|
||||
function raw.workspace(wks)
|
||||
if not gvisited[wks.global] then
|
||||
gvisited[wks.global] = true
|
||||
raw.printTable({ global = wks.global })
|
||||
end
|
||||
end
|
||||
|
||||
function raw.printTable(t, i)
|
||||
i = i or 0
|
||||
placement = raw._createPlacement(t)
|
||||
raw._printTableRecursive(t, i, placement)
|
||||
end
|
||||
|
||||
function raw._printTableRecursive(t, i, placement)
|
||||
elements = { }
|
||||
for k, v in pairs(t) do
|
||||
table.insert(elements, { key = k, value = v })
|
||||
end
|
||||
|
||||
table.sort(elements, function(a, b)
|
||||
local n1 = type(a.key) == "number"
|
||||
local n2 = type(b.key) == "number"
|
||||
if n1 ~= n2 then
|
||||
return n1
|
||||
end
|
||||
|
||||
local k1 = n1 and a.key or raw._encode(a.key)
|
||||
local k2 = n2 and b.key or raw._encode(b.key)
|
||||
return k1 < k2
|
||||
end)
|
||||
|
||||
for _, elem in ipairs(elements) do
|
||||
p = placement[elem.value]
|
||||
if p and elem.key == p.key and t == p.parent then
|
||||
_p(i, "%s", raw._encode(elem.key) .. ': ' .. raw._encode(elem.value) .. ' {')
|
||||
raw._printTableRecursive(elem.value, i + 1, placement)
|
||||
_p(i, '} # ' .. raw._encode(elem.key))
|
||||
else
|
||||
_p(i, "%s", raw._encode(elem.key) .. ': ' .. raw._encode(elem.value))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function raw._createPlacement(tbl)
|
||||
placement = { }
|
||||
placementList = { tbl }
|
||||
while #placementList ~= 0 do
|
||||
parentList = { }
|
||||
for _, parent in ipairs(placementList) do
|
||||
for k, v in pairs(parent) do
|
||||
if type(v) == "table" and not placement[v] then
|
||||
table.insert(parentList, v)
|
||||
placement[v] = {
|
||||
parent = parent,
|
||||
key = k
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
placementList = parentList
|
||||
end
|
||||
return placement
|
||||
end
|
||||
|
||||
function raw._encode(v)
|
||||
if type(v) == "string" then
|
||||
return '"' .. v .. '"'
|
||||
else
|
||||
return tostring(v)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue