update build.lua again

This commit is contained in:
tema5002
2026-05-23 21:47:49 +03:00
parent 9acff5f893
commit cdb90d236d
2 changed files with 35 additions and 5 deletions

39
build.lua Normal file → Executable file
View File

@@ -1,4 +1,6 @@
#!/usr/bin/env lua
-- 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
local args = {...}
local isBlendi = os.getenv("USER") == "blendi"
local separator = package.config:sub(1,1)
@@ -28,10 +30,33 @@ local function fixPath(path)
return new
end
if args[1] == "clean" then
if separator == '\\' then
runCommand("rmdir /s /q build 2>nul")
else
runCommand("rm -r build")
end
return
end
local needsDir = false
if separator == '\\' then
runCommand('mkdir build 2>nul')
needsDir = true
else
runCommand('mkdir -p build')
-- My favorite coreutil is /usr/bin/[
local handle = io.popen('[ -d "build" ] && echo 1')
local result = handle:read("*a")
handle:close()
needsDir = result:match("1") ~= nil
end
if not needsDir then
if separator == '\\' then
runCommand('mkdir build 2>nul')
else
runCommand('mkdir -p build')
end
end
local files = {
@@ -73,14 +98,18 @@ for i = 1,#files do
if needsRebuild(fname, out) then
needsLinking = true
runCommand('clang -c -g -o ' .. out .. ' ' .. fname .. ' ' .. table.concat(coolArgs, ' '))
runCommand('clang -c -o ' .. out .. ' ' .. fname .. ' ' .. table.concat(coolArgs, ' '))
end
objects[#objects+1] = out;
end
local exe = separator == '\\' and "noom.exe" or "noom"
local exe = separator == '\\' and ".\\noom.exe" or "./noom"
if needsLinking then
runCommand('clang -g -o ' .. exe .. ' ' .. table.concat(objects, ' ') .. ' ' .. table.concat(coolArgs, ' '))
runCommand('clang -o ' .. exe .. ' ' .. table.concat(objects, ' ') .. ' ' .. table.concat(coolArgs, ' '))
end
if args[1] == "run" then
runCommand(exe)
end