Skip to content

Commit

Permalink
输出到stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
actboy168 committed Mar 18, 2024
1 parent ddffb21 commit 649e762
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions scripts/action.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ local writer = require "writer"
local arguments = require "arguments"

local function execute(option)
local redirect = option.stdout ~= nil
option.stdout = option.stdout or true
assert(option.stdout ~= nil)
option.stderr = "stdout"
option.searchPath = true
if globals.compiler == "msvc" then
Expand All @@ -19,13 +18,6 @@ local function execute(option)
option[1] = { "cmd", "/c", option[1] }
end
local process = assert(sp.spawn(option))
if not redirect then
for line in process.stdout:lines() do
io.write(line, "\n")
io.flush()
end
process.stdout:close()
end
return process:wait()
end

Expand All @@ -46,9 +38,8 @@ local function compdb()
})
local f <close> = assert(io.open(compile_commands.."/compile_commands.json", "wb"))
ninja {
"-t", "compdb",
"-x",
stdout = f
"-t", "compdb", "-x",
stdout = f,
}
end
end
Expand All @@ -68,14 +59,20 @@ local function build()
})
end
end
local code = ninja { arguments.targets, options }
local code = ninja {
arguments.targets, options,
stdout = io.stdout,
}
if code ~= 0 then
os.exit(code)
end
end

local function clean()
local code = ninja { "-t", "clean" }
local code = ninja {
"-t", "clean",
stdout = io.stdout,
}
if code ~= 0 then
os.exit(code)
end
Expand Down

0 comments on commit 649e762

Please sign in to comment.