Skip to content

Commit e13dcc8

Browse files
committed
Added logging of failing builds
1 parent 87d8a62 commit e13dcc8

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

Diff for: ls/builder.go

+25-18
Original file line numberDiff line numberDiff line change
@@ -186,21 +186,26 @@ func (ls *INOLanguageServer) generateBuildEnvironment(ctx context.Context, logge
186186
defer conn.Close()
187187

188188
client := rpc.NewArduinoCoreServiceClient(conn)
189-
compRespStream, err := client.Compile(context.Background(),
190-
&rpc.CompileRequest{
191-
Instance: &rpc.Instance{Id: 1}, // XXX
192-
Fqbn: fqbn,
193-
SketchPath: sketchRoot.String(),
194-
SourceOverride: data.Overrides,
195-
BuildPath: buildPath.String(),
196-
CreateCompilationDatabaseOnly: true,
197-
},
198-
)
189+
compileReq := &rpc.CompileRequest{
190+
Instance: &rpc.Instance{Id: 1}, // XXX
191+
Fqbn: fqbn,
192+
SketchPath: sketchRoot.String(),
193+
SourceOverride: data.Overrides,
194+
BuildPath: buildPath.String(),
195+
CreateCompilationDatabaseOnly: true,
196+
Verbose: true,
197+
}
198+
compileReqJson, _ := json.MarshalIndent(compileReq, "", " ")
199+
logger.Logf("Running build with: %s", string(compileReqJson))
200+
201+
compRespStream, err := client.Compile(context.Background(), compileReq)
199202
if err != nil {
200203
return false, fmt.Errorf("error running compile: %w", err)
201204
}
202205

203206
// Loop and consume the server stream until all the operations are done.
207+
stdout := ""
208+
stderr := ""
204209
for {
205210
compResp, err := compRespStream.Recv()
206211
if err == io.EOF {
@@ -209,17 +214,19 @@ func (ls *INOLanguageServer) generateBuildEnvironment(ctx context.Context, logge
209214
break
210215
}
211216
if err != nil {
217+
logger.Logf("build stdout:")
218+
logger.Logf(stdout)
219+
logger.Logf("build stderr:")
220+
logger.Logf(stderr)
212221
return false, fmt.Errorf("error running compile: %w", err)
213222
}
214223

215-
// TODO: we can accumulate stdout/stderr buffer if needed
216-
_ = compResp
217-
// if resp := compResp.GetOutStream(); resp != nil {
218-
// logger.Logf("STDOUT: %s", resp)
219-
// }
220-
// if resperr := compResp.GetErrStream(); resperr != nil {
221-
// logger.Logf("STDERR: %s", resperr)
222-
// }
224+
if resp := compResp.GetOutStream(); resp != nil {
225+
stdout += string(resp)
226+
}
227+
if resperr := compResp.GetErrStream(); resperr != nil {
228+
stderr += string(resperr)
229+
}
223230
}
224231

225232
} else {

0 commit comments

Comments
 (0)