@@ -33,6 +33,7 @@ import (
3333 "github.com/arduino/arduino-cli/i18n"
3434 "github.com/arduino/arduino-cli/internal/cli/arguments"
3535 "github.com/arduino/arduino-cli/internal/cli/feedback"
36+ "github.com/arduino/arduino-cli/internal/cli/feedback/result"
3637 "github.com/arduino/arduino-cli/internal/cli/instance"
3738 rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
3839 "github.com/arduino/arduino-cli/table"
@@ -340,10 +341,14 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
340341
341342 stdIO := stdIORes ()
342343 res := & compileResult {
343- CompilerOut : stdIO .Stdout ,
344- CompilerErr : stdIO .Stderr ,
345- BuilderResult : compileRes ,
346- UploadResult : uploadRes ,
344+ CompilerOut : stdIO .Stdout ,
345+ CompilerErr : stdIO .Stderr ,
346+ BuilderResult : result .NewCompileResponse (compileRes ),
347+ UploadResult : struct {
348+ UpdatedUploadPort * result.Port `json:"updated_upload_port,omitempty"`
349+ }{
350+ UpdatedUploadPort : result .NewPort (uploadRes .GetUpdatedUploadPort ()),
351+ },
347352 ProfileOut : profileOut ,
348353 Success : compileError == nil ,
349354 showPropertiesMode : showProperties ,
@@ -385,13 +390,15 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
385390}
386391
387392type compileResult struct {
388- CompilerOut string `json:"compiler_out"`
389- CompilerErr string `json:"compiler_err"`
390- BuilderResult * rpc.CompileResponse `json:"builder_result"`
391- UploadResult * rpc.UploadResult `json:"upload_result"`
392- Success bool `json:"success"`
393- ProfileOut string `json:"profile_out,omitempty"`
394- Error string `json:"error,omitempty"`
393+ CompilerOut string `json:"compiler_out"`
394+ CompilerErr string `json:"compiler_err"`
395+ BuilderResult * result.CompileResponse `json:"builder_result"`
396+ UploadResult struct {
397+ UpdatedUploadPort * result.Port `json:"updated_upload_port,omitempty"`
398+ } `json:"upload_result"`
399+ Success bool `json:"success"`
400+ ProfileOut string `json:"profile_out,omitempty"`
401+ Error string `json:"error,omitempty"`
395402
396403 showPropertiesMode arguments.ShowPropertiesMode
397404 hideStats bool
@@ -402,8 +409,8 @@ func (r *compileResult) Data() interface{} {
402409}
403410
404411func (r * compileResult ) String () string {
405- if r .showPropertiesMode != arguments .ShowPropertiesDisabled {
406- return strings .Join (r .BuilderResult .GetBuildProperties () , fmt .Sprintln ())
412+ if r .BuilderResult != nil && r . showPropertiesMode != arguments .ShowPropertiesDisabled {
413+ return strings .Join (r .BuilderResult .BuildProperties , fmt .Sprintln ())
407414 }
408415
409416 if r .hideStats {
@@ -419,38 +426,41 @@ func (r *compileResult) String() string {
419426 if r .CompilerOut != "" || r .CompilerErr != "" {
420427 res += fmt .Sprintln ()
421428 }
422- if len (build .GetUsedLibraries () ) > 0 {
429+ if build != nil && len (build .UsedLibraries ) > 0 {
423430 libraries := table .New ()
424431 libraries .SetHeader (
425432 table .NewCell (tr ("Used library" ), titleColor ),
426433 table .NewCell (tr ("Version" ), titleColor ),
427434 table .NewCell (tr ("Path" ), pathColor ))
428- for _ , l := range build .GetUsedLibraries () {
435+ for _ , l := range build .UsedLibraries {
436+ if l == nil {
437+ continue
438+ }
429439 libraries .AddRow (
430- table .NewCell (l .GetName () , nameColor ),
431- l .GetVersion () ,
432- table .NewCell (l .GetInstallDir () , pathColor ))
440+ table .NewCell (l .Name , nameColor ),
441+ l .Version ,
442+ table .NewCell (l .InstallDir , pathColor ))
433443 }
434444 res += fmt .Sprintln (libraries .Render ())
435445 }
436-
437- if boardPlatform := build .GetBoardPlatform (); boardPlatform != nil {
446+ if build != nil && build . BoardPlatform != nil {
447+ boardPlatform := build .BoardPlatform
438448 platforms := table .New ()
439449 platforms .SetHeader (
440450 table .NewCell (tr ("Used platform" ), titleColor ),
441451 table .NewCell (tr ("Version" ), titleColor ),
442452 table .NewCell (tr ("Path" ), pathColor ))
443453 platforms .AddRow (
444- table .NewCell (boardPlatform .GetId () , nameColor ),
445- boardPlatform .GetVersion () ,
446- table .NewCell (boardPlatform .GetInstallDir () , pathColor ))
447- if buildPlatform := build .GetBuildPlatform () ; buildPlatform != nil &&
454+ table .NewCell (boardPlatform .Id , nameColor ),
455+ boardPlatform .Version ,
456+ table .NewCell (boardPlatform .InstallDir , pathColor ))
457+ if buildPlatform := build .BuildPlatform ; buildPlatform != nil &&
448458 buildPlatform .Id != boardPlatform .Id &&
449459 buildPlatform .Version != boardPlatform .Version {
450460 platforms .AddRow (
451- table .NewCell (buildPlatform .GetId () , nameColor ),
452- buildPlatform .GetVersion () ,
453- table .NewCell (buildPlatform .GetInstallDir () , pathColor ))
461+ table .NewCell (buildPlatform .Id , nameColor ),
462+ buildPlatform .Version ,
463+ table .NewCell (buildPlatform .InstallDir , pathColor ))
454464 }
455465 res += fmt .Sprintln (platforms .Render ())
456466 }
0 commit comments