@@ -144,9 +144,6 @@ func NewCommand() *cobra.Command {
144
144
func runCompileCommand (cmd * cobra.Command , args []string ) {
145
145
logrus .Info ("Executing `arduino-cli compile`" )
146
146
147
- if dumpProfile && feedback .GetFormat () != feedback .Text {
148
- feedback .Fatal (tr ("You cannot use the %[1]s flag together with %[2]s." , "--dump-profile" , "--format json" ), feedback .ErrBadArgument )
149
- }
150
147
if profileArg .Get () != "" {
151
148
if len (libraries ) > 0 {
152
149
feedback .Fatal (tr ("You cannot use the %s flag while compiling with a profile." , "--libraries" ), feedback .ErrBadArgument )
@@ -255,7 +252,10 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
255
252
}
256
253
}
257
254
258
- if dumpProfile {
255
+ profileOut := ""
256
+ if dumpProfile && compileError == nil {
257
+ // Output profile
258
+
259
259
libs := ""
260
260
hasVendoredLibs := false
261
261
for _ , lib := range compileRes .GetUsedLibraries () {
@@ -279,43 +279,37 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
279
279
if split := strings .Split (compileRequest .GetFqbn (), ":" ); len (split ) > 2 {
280
280
newProfileName = split [2 ]
281
281
}
282
- profile := fmt .Sprintln ()
283
- profile += fmt .Sprintln ("profiles:" )
284
- profile += fmt .Sprintln (" " + newProfileName + ":" )
285
- profile += fmt .Sprintln (" fqbn: " + compileRequest .GetFqbn ())
286
- profile += fmt .Sprintln (" platforms:" )
282
+ profileOut = fmt .Sprintln ("profiles:" )
283
+ profileOut += fmt .Sprintln (" " + newProfileName + ":" )
284
+ profileOut += fmt .Sprintln (" fqbn: " + compileRequest .GetFqbn ())
285
+ profileOut += fmt .Sprintln (" platforms:" )
287
286
boardPlatform := compileRes .GetBoardPlatform ()
288
- profile += fmt .Sprintln (" - platform: " + boardPlatform .GetId () + " (" + boardPlatform .GetVersion () + ")" )
287
+ profileOut += fmt .Sprintln (" - platform: " + boardPlatform .GetId () + " (" + boardPlatform .GetVersion () + ")" )
289
288
if url := boardPlatform .GetPackageUrl (); url != "" {
290
- profile += fmt .Sprintln (" platform_index_url: " + url )
289
+ profileOut += fmt .Sprintln (" platform_index_url: " + url )
291
290
}
292
291
293
292
if buildPlatform := compileRes .GetBuildPlatform (); buildPlatform != nil &&
294
293
buildPlatform .Id != boardPlatform .Id &&
295
294
buildPlatform .Version != boardPlatform .Version {
296
- profile += fmt .Sprintln (" - platform: " + buildPlatform .GetId () + " (" + buildPlatform .GetVersion () + ")" )
295
+ profileOut += fmt .Sprintln (" - platform: " + buildPlatform .GetId () + " (" + buildPlatform .GetVersion () + ")" )
297
296
if url := buildPlatform .GetPackageUrl (); url != "" {
298
- profile += fmt .Sprintln (" platform_index_url: " + url )
297
+ profileOut += fmt .Sprintln (" platform_index_url: " + url )
299
298
}
300
299
}
301
300
if len (libs ) > 0 {
302
- profile += fmt .Sprintln (" libraries:" )
303
- profile += fmt .Sprint (libs )
301
+ profileOut += fmt .Sprintln (" libraries:" )
302
+ profileOut += fmt .Sprint (libs )
304
303
}
305
-
306
- // Output profile as a result
307
- if _ , err := stdOut .Write ([]byte (profile )); err != nil {
308
- feedback .FatalError (err , feedback .ErrGeneric )
309
- }
310
- feedback .PrintResult (stdIORes ())
311
- return
304
+ profileOut += fmt .Sprintln ()
312
305
}
313
306
314
307
stdIO := stdIORes ()
315
308
feedback .PrintResult (& compileResult {
316
309
CompilerOut : stdIO .Stdout ,
317
310
CompilerErr : stdIO .Stderr ,
318
311
BuilderResult : compileRes ,
312
+ ProfileOut : profileOut ,
319
313
Success : compileError == nil ,
320
314
})
321
315
if compileError != nil {
@@ -357,6 +351,7 @@ type compileResult struct {
357
351
CompilerErr string `json:"compiler_err"`
358
352
BuilderResult * rpc.CompileResponse `json:"builder_result"`
359
353
Success bool `json:"success"`
354
+ ProfileOut string `json:"profile_out,omitempty"`
360
355
}
361
356
362
357
func (r * compileResult ) Data () interface {} {
@@ -405,5 +400,8 @@ func (r *compileResult) String() string {
405
400
}
406
401
res += platforms .Render ()
407
402
}
403
+ if r .ProfileOut != "" {
404
+ res += "\n " + fmt .Sprintln (r .ProfileOut )
405
+ }
408
406
return res
409
407
}
0 commit comments