update build.lua again #2

Merged
Blendi merged 2 commits from :main into main 2026-05-23 21:00:21 +02:00
2 changed files with 33 additions and 5 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
/build /build
/.zig-cache /.zig-cache
/zig-out /zig-out
.idea
noom noom
noom.* noom.*

37
build.lua Normal file → Executable file
View File

@@ -1,5 +1,5 @@
#!/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 -- 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 isBlendi = os.getenv("USER") == "blendi" local isBlendi = os.getenv("USER") == "blendi"
local separator = package.config:sub(1,1) local separator = package.config:sub(1,1)
@@ -28,10 +28,33 @@ local function fixPath(path)
return new return new
end end
if arg[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 if separator == '\\' then
runCommand('mkdir build 2>nul') needsDir = true
else 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 end
local files = { local files = {
@@ -73,14 +96,18 @@ for i = 1,#files do
if needsRebuild(fname, out) then if needsRebuild(fname, out) then
needsLinking = true needsLinking = true
runCommand('clang -c -g -o ' .. out .. ' ' .. fname .. ' ' .. table.concat(coolArgs, ' ')) runCommand('clang -g -c -o ' .. out .. ' ' .. fname .. ' ' .. table.concat(coolArgs, ' '))
end end
objects[#objects+1] = out; objects[#objects+1] = out;
end end
local exe = separator == '\\' and "noom.exe" or "noom" local exe = separator == '\\' and ".\\noom.exe" or "./noom"
if needsLinking then if needsLinking then
runCommand('clang -g -o ' .. exe .. ' ' .. table.concat(objects, ' ') .. ' ' .. table.concat(coolArgs, ' ')) runCommand('clang -g -o ' .. exe .. ' ' .. table.concat(objects, ' ') .. ' ' .. table.concat(coolArgs, ' '))
end end
if arg[1] == "run" then
runCommand(exe)
end