build.lua: maybe windows support
This commit is contained in:
29
build.lua
29
build.lua
@@ -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
|
-- 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 isBlendi = os.getenv("USER") == "blendi"
|
||||||
|
local seperator = package.config:sub(1,1)
|
||||||
|
|
||||||
local function filename(path)
|
local function filename(path)
|
||||||
local s,e = 1, #path
|
local s,e = 1, #path
|
||||||
@@ -19,7 +18,22 @@ local function runCommand(cmd)
|
|||||||
return os.execute(cmd)
|
return os.execute(cmd)
|
||||||
end
|
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')
|
runCommand('mkdir build')
|
||||||
|
|
||||||
local files = {
|
local files = {
|
||||||
@@ -31,7 +45,7 @@ local files = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local objects = {}
|
local objects = {}
|
||||||
|
|
||||||
local coolArgs = {}
|
local coolArgs = {}
|
||||||
if not isBlendi then table.insert(coolArgs, '-fsanitize=undefined,address') end
|
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 fname = files[i]
|
||||||
local out = "build/" .. filename(fname) .. '.o'
|
local out = "build/" .. filename(fname) .. '.o'
|
||||||
|
|
||||||
|
fname = fixPath(fname)
|
||||||
|
out = fixPath(out)
|
||||||
|
|
||||||
runCommand('clang -c -o ' .. out .. ' ' .. fname .. ' ' .. table.concat(coolArgs, ' '))
|
runCommand('clang -c -o ' .. out .. ' ' .. fname .. ' ' .. table.concat(coolArgs, ' '))
|
||||||
|
|
||||||
objects[#objects+1] = out;
|
objects[#objects+1] = out;
|
||||||
end
|
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, ' '))
|
||||||
|
|||||||
Reference in New Issue
Block a user