compiler update

This commit is contained in:
Samkist
2022-06-03 02:12:36 -04:00
parent 17c7aedff3
commit 9303397680
3 changed files with 27 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
lfs = require "lfs"
sourcesPath = "source/"
scriptsPath = "scripts/"
buildPath = "build/"
fetchFiles = function(...)
local tbl = {}
@@ -15,5 +16,27 @@ fetchFiles = function(...)
return tbl
end
dirExists = function(path)
local _, endIndex = string.find(path, "/")
if(endIndex == #path) then
path = string.sub(path, 1, #path - 1)
end
if(lfs.attributes(path, "mode") == "directory") then
return true
end
return false
end
local compiledSource = dofile(scriptsPath .. "packager.lua") -- path to packager
local compiledSource = dofile(scriptsPath .. "packager.lua") -- path to packager
if not dirExists(buildPath) then
lfs.mkdir(buildPath)
assert(dirExists(buildPath), "Failed to make build directory, exiting...")
return
end
local sourceFileName = "basalt.lua"
local sourceFile = io.open(buildPath .. sourceFileName, "w")
sourceFile:write(compiledSource)
sourceFile:close()