build.lua: maybe windows support

This commit is contained in:
2026-05-09 10:54:48 +02:00
parent 8e8642d7d6
commit c95df11c88

View File

@@ -1,8 +1,7 @@
-- i love build scripts i love build scripts i love build scripts scripts build love i script build love me i love script build i script love build
-- TODO: script the build
local isBlendi = os.getenv("USER") == "blendi"
local seperator = package.config:sub(1,1)
local function filename(path)
local s,e = 1, #path
@@ -19,7 +18,22 @@ local function runCommand(cmd)
return os.execute(cmd)
end
runCommand('rm -r build')
local function fixPath(path)
local new = ""
for i = 1,#path do
local ch = path:sub(i,i)
if ch == '/' then new = new .. seperator
else new = new .. ch end
end
return new
end
if seperator == '\\' then
runCommand('rmdir /S /Q build')
else
runCommand('rm -rf build')
end
runCommand('mkdir build')
local files = {
@@ -31,7 +45,7 @@ local files = {
}
local objects = {}
local coolArgs = {}
if not isBlendi then table.insert(coolArgs, '-fsanitize=undefined,address') end
@@ -39,9 +53,14 @@ for i = 1,#files do
local fname = files[i]
local out = "build/" .. filename(fname) .. '.o'
fname = fixPath(fname)
out = fixPath(out)
runCommand('clang -c -o ' .. out .. ' ' .. fname .. ' ' .. table.concat(coolArgs, ' '))
objects[#objects+1] = out;
end
runCommand('clang -o noom ' .. table.concat(objects, ' ') .. ' ' .. table.concat(coolArgs, ' '))
local exe = seperator == '\\' and "noom.exe" or "noom"
runCommand('clang -o ' .. exe .. ' ' .. table.concat(objects, ' ') .. ' ' .. table.concat(coolArgs, ' '))