update build.lua again #2
1
.gitignore
vendored
1
.gitignore
vendored
@@ -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
37
build.lua
Normal file → Executable 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
|
-- 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 isBlendi = os.getenv("USER") == "blendi"
|
||||||
local separator = package.config:sub(1,1)
|
local separator = package.config:sub(1,1)
|
||||||
@@ -28,10 +30,33 @@ local function fixPath(path)
|
|||||||
return new
|
return new
|
||||||
end
|
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
|
if separator == '\\' then
|
||||||
runCommand('mkdir build 2>nul')
|
needsDir = true
|
||||||
else
|
else
|
||||||
|
-- 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')
|
runCommand('mkdir -p build')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local files = {
|
local files = {
|
||||||
@@ -73,14 +98,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 -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 -o ' .. exe .. ' ' .. table.concat(objects, ' ') .. ' ' .. table.concat(coolArgs, ' '))
|
||||||
|
end
|
||||||
|
|
||||||
|
if args[1] == "run" then
|
||||||
|
runCommand(exe)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user