Skip to content

Commit

Permalink
Fully redirecting stdout/err from Compile command
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Apr 12, 2019
1 parent f895ae5 commit c591d4d
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 66 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func run(cmd *cobra.Command, args []string) {
Quiet: flags.quiet,
VidPid: flags.vidPid,
ExportFile: flags.exportFile,
}, os.Stdout, output.NewTaskProgressCB(), output.DownloadProgressBar())
}, os.Stdout, os.Stderr, output.NewTaskProgressCB(), output.DownloadProgressBar())
if err == nil {
outputCompileResp(compRes)
} else {
Expand Down
6 changes: 4 additions & 2 deletions commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

func Compile(ctx context.Context, req *rpc.CompileReq,
outStream io.Writer,
outStream io.Writer, errStream io.Writer,
taskCB commands.TaskProgressCB, downloadCB commands.DownloadProgressCB) (*rpc.CompileResp, error) {

pm := commands.GetPackageManager(req)
Expand Down Expand Up @@ -158,7 +158,9 @@ func Compile(ctx context.Context, req *rpc.CompileReq,
builderCtx.BuiltInLibrariesDirs = paths.NewPathList(ideLibrariesPath)
}

builderCtx.SetLogger(i18n.LoggerToIoWriter{Writer: outStream})
builderCtx.ExecStdout = outStream
builderCtx.ExecStderr = errStream
builderCtx.SetLogger(i18n.LoggerToCustomStreams{Stdout: outStream, Stderr: errStream})
if req.GetShowProperties() {
err = builder.RunParseHardwareAndDumpBuildProperties(builderCtx)
} else if req.GetPreprocess() {
Expand Down
11 changes: 7 additions & 4 deletions daemon/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ func main() {
fmt.Printf("Compile error: %s\n", err)
os.Exit(1)
}
if compResp.GetOutput() != nil {
fmt.Printf("%s", compResp.GetOutput())
if resp := compResp.GetOutStream(); resp != nil {
fmt.Printf(">> STDOUT: %s", resp)
}
if resperr := compResp.GetErrStream(); resperr != nil {
fmt.Printf(">> STDERR: %s", resperr)
}
if compResp.GetDownloadProgress() != nil {
fmt.Printf(">> DOWNLOAD: %s\n", compResp.GetDownloadProgress())
Expand Down Expand Up @@ -156,10 +159,10 @@ func main() {
os.Exit(1)
}
if resp := uplResp.GetOutStream(); resp != nil {
fmt.Printf("output %s", resp)
fmt.Printf(">> STDOUT: %s", resp)
}
if resperr := uplResp.GetErrStream(); resperr != nil {
fmt.Printf("error %s", resperr)
fmt.Printf(">> STDERR: %s", resperr)
}
}

Expand Down
3 changes: 2 additions & 1 deletion daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ func (s *ArduinoCoreServerImpl) Init(ctx context.Context, req *rpc.InitReq) (*rp
func (s *ArduinoCoreServerImpl) Compile(req *rpc.CompileReq, stream rpc.ArduinoCore_CompileServer) error {
resp, err := compile.Compile(
stream.Context(), req,
feedStream(func(data []byte) { stream.Send(&rpc.CompileResp{Output: data}) }),
feedStream(func(data []byte) { stream.Send(&rpc.CompileResp{OutStream: data}) }),
feedStream(func(data []byte) { stream.Send(&rpc.CompileResp{ErrStream: data}) }),
func(p *rpc.TaskProgress) { stream.Send(&rpc.CompileResp{TaskProgress: p}) },
func(p *rpc.DownloadProgress) { stream.Send(&rpc.CompileResp{DownloadProgress: p}) },
)
Expand Down
81 changes: 45 additions & 36 deletions rpc/compile.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions rpc/compile.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ message CompileReq {
}

message CompileResp {
bytes output = 1;
DownloadProgress download_progress = 2;
TaskProgress task_progress = 3;
bytes out_stream = 1;
bytes err_stream = 2;
DownloadProgress download_progress = 3;
TaskProgress task_progress = 4;
}
37 changes: 25 additions & 12 deletions vendor/github.com/arduino/arduino-builder/i18n/i18n.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions vendor/github.com/arduino/arduino-builder/types/context.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions vendor/github.com/arduino/arduino-builder/utils/utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c591d4d

Please sign in to comment.