40 lines
830 B
Lua
40 lines
830 B
Lua
|
|
||
|
---@note setup code from: https://stackoverflow.com/a/30960054
|
||
|
local BinaryFormat = package.cpath:match("%p[\\|/]?%p(%a+)")
|
||
|
|
||
|
if BinaryFormat == "dll" then
|
||
|
function os.name()
|
||
|
return "Windows"
|
||
|
end
|
||
|
elseif BinaryFormat == "so" then
|
||
|
function os.name()
|
||
|
return "Linux"
|
||
|
end
|
||
|
elseif BinaryFormat == "dylib" then
|
||
|
function os.name()
|
||
|
return "MacOS"
|
||
|
end
|
||
|
end
|
||
|
|
||
|
BinaryFormat = nil
|
||
|
|
||
|
Platform = {
|
||
|
WINDOWS = "Windows",
|
||
|
LINUX = "Linux",
|
||
|
MACOS = "MacOS"
|
||
|
}
|
||
|
|
||
|
---Get OS platform lua is running on
|
||
|
function GetPlatform()
|
||
|
return os.name()
|
||
|
end
|
||
|
|
||
|
---Merge base module table with implementation table, overwriting base
|
||
|
---@param base any
|
||
|
---@param implementation any
|
||
|
function MergeModules(base, implementation)
|
||
|
for key, value in pairs(implementation) do
|
||
|
base[key] = value
|
||
|
end
|
||
|
end
|