build.lua: changes

This commit is contained in:
2026-05-24 14:23:12 +02:00
parent 09ac2a17f9
commit 4fbb006072

View File

@@ -16,7 +16,7 @@ end
local function runCommand(cmd, ignore_fail) local function runCommand(cmd, ignore_fail)
print("> " .. cmd) print("> " .. cmd)
local result = os.execute(cmd) local result = os.execute(cmd)
if result ~= true and (not ignore_fail) then if (result ~= true and result ~= 0) and (not ignore_fail) then
os.exit(1) os.exit(1)
end end
end end
@@ -45,14 +45,15 @@ local needsDir = false
if separator == '\\' then if separator == '\\' then
needsDir = true needsDir = true
else else
-- My favorite coreutil is /usr/bin/[ -- TODO: maybe use exit code instead of the first return value?
local handle = io.popen('[ -d "build" ] && echo 1') local ok, _, code = os.execute('test -d build');
local result = handle:read("*a")
handle:close() local exists = (ok == 0 or (ok == true and code == 0))
needsDir = result:match("1") ~= nil
needsDir = not exists;
end end
if not needsDir then if needsDir then
if separator == '\\' then if separator == '\\' then
runCommand('mkdir build 2>nul') runCommand('mkdir build 2>nul')
else else