@@ -85,7 +85,7 @@ func (handler *InoHandler) rebuildEnvironmentLoop() {
8585 }
8686}
8787
88- func (handler * InoHandler ) generateBuildEnvironment () ( * paths.Path , error ) {
88+ func (handler * InoHandler ) generateBuildEnvironment (buildPath * paths.Path ) error {
8989 sketchDir := handler .sketchRoot
9090 fqbn := handler .config .SelectedBoard .Fqbn
9191
@@ -97,15 +97,15 @@ func (handler *InoHandler) generateBuildEnvironment() (*paths.Path, error) {
9797 for uri , trackedFile := range handler .docs {
9898 rel , err := paths .New (uri ).RelFrom (handler .sketchRoot )
9999 if err != nil {
100- return nil , errors .WithMessage (err , "dumping tracked files" )
100+ return errors .WithMessage (err , "dumping tracked files" )
101101 }
102102 data .Overrides [rel .String ()] = trackedFile .Text
103103 }
104104 var overridesJSON * paths.Path
105105 if jsonBytes , err := json .MarshalIndent (data , "" , " " ); err != nil {
106- return nil , errors .WithMessage (err , "dumping tracked files" )
106+ return errors .WithMessage (err , "dumping tracked files" )
107107 } else if tmpFile , err := paths .WriteToTempFile (jsonBytes , nil , "" ); err != nil {
108- return nil , errors .WithMessage (err , "dumping tracked files" )
108+ return errors .WithMessage (err , "dumping tracked files" )
109109 } else {
110110 overridesJSON = tmpFile
111111 defer tmpFile .Remove ()
@@ -118,21 +118,23 @@ func (handler *InoHandler) generateBuildEnvironment() (*paths.Path, error) {
118118 "--only-compilation-database" ,
119119 "--clean" ,
120120 "--source-override" , overridesJSON .String (),
121+ "--build-path" , buildPath .String (),
121122 "--format" , "json" ,
122123 sketchDir .String (),
123124 }
124125 cmd , err := executils .NewProcess (args ... )
125126 if err != nil {
126- return nil , errors .Errorf ("running %s: %s" , strings .Join (args , " " ), err )
127+ return errors .Errorf ("running %s: %s" , strings .Join (args , " " ), err )
127128 }
128129 cmdOutput := & bytes.Buffer {}
129130 cmd .RedirectStdoutTo (cmdOutput )
130131 cmd .SetDirFromPath (sketchDir )
131132 log .Println ("running: " , strings .Join (args , " " ))
132133 if err := cmd .Run (); err != nil {
133- return nil , errors .Errorf ("running %s: %s" , strings .Join (args , " " ), err )
134+ return errors .Errorf ("running %s: %s" , strings .Join (args , " " ), err )
134135 }
135136
137+ // Currently those values are not used, keeping here for future improvements
136138 type cmdBuilderRes struct {
137139 BuildPath * paths.Path `json:"build_path"`
138140 UsedLibraries []* libraries.Library
@@ -145,9 +147,9 @@ func (handler *InoHandler) generateBuildEnvironment() (*paths.Path, error) {
145147 }
146148 var res cmdRes
147149 if err := json .Unmarshal (cmdOutput .Bytes (), & res ); err != nil {
148- return nil , errors .Errorf ("parsing arduino-cli output: %s" , err )
150+ return errors .Errorf ("parsing arduino-cli output: %s" , err )
149151 }
150- // Return only the build path
151152 log .Println ("arduino-cli output:" , cmdOutput )
152- return res .BuilderResult .BuildPath , nil
153+
154+ return nil
153155}
0 commit comments