diff --git a/build.lua b/build.lua index c7da02a..2a091cc 100644 --- a/build.lua +++ b/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 --- TODO: script the build - local isBlendi = os.getenv("USER") == "blendi" +local seperator = package.config:sub(1,1) local function filename(path) local s,e = 1, #path @@ -19,7 +18,22 @@ local function runCommand(cmd) return os.execute(cmd) 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') local files = { @@ -31,7 +45,7 @@ local files = { } local objects = {} - + local coolArgs = {} 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 out = "build/" .. filename(fname) .. '.o' + fname = fixPath(fname) + out = fixPath(out) + runCommand('clang -c -o ' .. out .. ' ' .. fname .. ' ' .. table.concat(coolArgs, ' ')) objects[#objects+1] = out; 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, ' '))