diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f30577a..d5a8742 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,10 +35,10 @@ jobs: lua-version: 5.1.0 install-luarocks: true luarocks-version: 3.9.0 + - name: install-lfs run: luarocks install luafilesystem - - + - name: compile-basalt run: lua ${{ github.workspace }}/scripts/compiler.lua - name: Upload artifact diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..84c048a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/scripts/compiler.lua b/scripts/compiler.lua index b2ac1f8..cea03b7 100644 --- a/scripts/compiler.lua +++ b/scripts/compiler.lua @@ -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 \ No newline at end of file +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() \ No newline at end of file