started new compiling platform in packager.lua
This commit is contained in:
19
scripts/compiler.lua
Normal file
19
scripts/compiler.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
lfs = require "lfs"
|
||||
sourcesPath = "source/"
|
||||
scriptsPath = "scripts/"
|
||||
|
||||
fetchFiles = function(...)
|
||||
local tbl = {}
|
||||
for _, directory in pairs{...} do
|
||||
for file in lfs.dir(directory) do
|
||||
if file ~= "." and file ~= ".." then
|
||||
table.insert(tbl, file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return tbl
|
||||
end
|
||||
|
||||
|
||||
local compiledSource = dofile(scriptsPath .. "packager.lua") -- path to packager
|
||||
3
scripts/loader.lua
Normal file
3
scripts/loader.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
local basalt = dofile(scriptsPath .. "packager.lua")
|
||||
|
||||
return (load(basalt, "t")())
|
||||
50
scripts/packager.lua
Normal file
50
scripts/packager.lua
Normal file
@@ -0,0 +1,50 @@
|
||||
local basaltFileName = "basalt.lua"
|
||||
|
||||
local requiredFiles = {
|
||||
"mainTop.lua",
|
||||
"mainBottom.lua",
|
||||
"Frame.lua",
|
||||
"Object.lua",
|
||||
"defaultTheme.lua",
|
||||
"lib/drawHelper.lua",
|
||||
"lib/eventSystem.lua",
|
||||
"lib/process.lua",
|
||||
"lib/utils.lua",
|
||||
}
|
||||
for _, value in pairs(requiredFiles)do
|
||||
assert(io.open(sourcesPath .. value), "File ".. value .." not found!")
|
||||
end
|
||||
|
||||
local lib = fetchFiles(sourcesPath .. "lib")
|
||||
local objects = fetchFiles(sourcesPath .. "objects")
|
||||
|
||||
local filesOrdered = {}
|
||||
|
||||
table.insert(filesOrdered, "mainTop.lua")
|
||||
table.insert(filesOrdered, "defaultTheme.lua")
|
||||
|
||||
for _, libFile in pairs(lib) do
|
||||
table.insert(filesOrdered, "lib/" .. libFile)
|
||||
end
|
||||
|
||||
table.insert(filesOrdered, "Object.lua")
|
||||
|
||||
for _, objectFile in pairs(objects) do
|
||||
table.insert(filesOrdered, "objects/" .. objectFile)
|
||||
end
|
||||
|
||||
table.insert(filesOrdered, "Frame.lua")
|
||||
table.insert(filesOrdered, "mainBottom.lua")
|
||||
|
||||
local basalt = io.open(sourcesPath .. basaltFileName, "w")
|
||||
local compiledSource = ""
|
||||
|
||||
for _, file in ipairs(filesOrdered) do
|
||||
print("Loading file ".. file)
|
||||
local currentSource = io.open(sourcesPath .. file, "r")
|
||||
compiledSource = compiledSource .. currentSource:read("*a") .. "\n"
|
||||
end
|
||||
|
||||
basalt:write(compiledSource)
|
||||
basalt:close()
|
||||
return compiledSource
|
||||
19
scripts/test.lua
Normal file
19
scripts/test.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
lfs = require "lfs"
|
||||
sourcesPath = "source/"
|
||||
|
||||
fetchFiles = function(...)
|
||||
local tbl = {}
|
||||
for _, directory in pairs{...} do
|
||||
for file in lfs.dir(directory) do
|
||||
if file ~= "." and file ~= ".." then
|
||||
table.insert(tbl, file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return tbl
|
||||
end
|
||||
|
||||
for _, file in pairs(fetchFiles(sourcesPath, sourcesPath .. "lib", sourcesPath .. "objects")) do
|
||||
print(file)
|
||||
end
|
||||
Reference in New Issue
Block a user