70
70
clean bool // Cleanup the build folder and do not use any cached build
71
71
compilationDatabaseOnly bool // Only create compilation database without actually compiling
72
72
sourceOverrides string // Path to a .json file that contains a set of replacements of the sketch source code.
73
+ dumpProfile bool // Create and print a profile configuration from the build
73
74
// library and libraries sound similar but they're actually different.
74
75
// library expects a path to the root folder of one single library.
75
76
// libraries expects a path to a directory containing multiple libraries, similarly to the <directories.user>/libraries path.
@@ -95,6 +96,7 @@ func NewCommand() *cobra.Command {
95
96
96
97
fqbnArg .AddToCommand (compileCommand )
97
98
profileArg .AddToCommand (compileCommand )
99
+ compileCommand .Flags ().BoolVar (& dumpProfile , "dump-profile" , false , tr ("Create and print a profile configuration from the build." ))
98
100
compileCommand .Flags ().BoolVar (& showProperties , "show-properties" , false , tr ("Show all build properties used instead of compiling." ))
99
101
compileCommand .Flags ().BoolVar (& preprocess , "preprocess" , false , tr ("Print preprocessed code to stdout instead of compiling." ))
100
102
compileCommand .Flags ().StringVar (& buildCachePath , "build-cache-path" , "" , tr ("Builds of 'core.a' are saved into this path to be cached and reused." ))
@@ -270,6 +272,50 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
270
272
}
271
273
}
272
274
275
+ if dumpProfile {
276
+ libs := ""
277
+ hasVendoredLibs := false
278
+ for _ , lib := range compileRes .GetUsedLibraries () {
279
+ if lib .Location != rpc .LibraryLocation_LIBRARY_LOCATION_USER && lib .Location != rpc .LibraryLocation_LIBRARY_LOCATION_UNMANAGED {
280
+ continue
281
+ }
282
+ if lib .GetVersion () == "" {
283
+ hasVendoredLibs = true
284
+ continue
285
+ }
286
+ libs += fmt .Sprintln (" - " + lib .GetName () + " (" + lib .GetVersion () + ")" )
287
+ }
288
+ if hasVendoredLibs {
289
+ fmt .Println ()
290
+ fmt .Println (tr ("WARNING: The sketch is compiled using one or more custom libraries." ))
291
+ fmt .Println (tr ("Currently, Build Profiles only support libraries available through Arduino Library Manager." ))
292
+ }
293
+
294
+ fmt .Println ()
295
+ fmt .Println ("profile:" )
296
+ fmt .Println (" my_profile_name:" )
297
+ fmt .Println (" fqbn: " + compileRequest .GetFqbn ())
298
+ fmt .Println (" platforms:" )
299
+ boardPlatform := compileRes .GetBoardPlatform ()
300
+ fmt .Println (" - platform: " + boardPlatform .GetId () + " (" + boardPlatform .GetVersion () + ")" )
301
+ if url := boardPlatform .GetPackageUrl (); url != "" {
302
+ fmt .Println (" platform_index_url: " + url )
303
+ }
304
+
305
+ if buildPlatform := compileRes .GetBuildPlatform (); buildPlatform != nil &&
306
+ buildPlatform .Id != boardPlatform .Id &&
307
+ buildPlatform .Version != boardPlatform .Version {
308
+ fmt .Println (" - platform: " + buildPlatform .GetId () + " (" + buildPlatform .GetVersion () + ")" )
309
+ if url := buildPlatform .GetPackageUrl (); url != "" {
310
+ fmt .Println (" platform_index_url: " + url )
311
+ }
312
+ }
313
+ if len (libs ) > 0 {
314
+ fmt .Println (" libraries:" )
315
+ fmt .Print (libs )
316
+ }
317
+ }
318
+
273
319
feedback .PrintResult (& compileResult {
274
320
CompileOut : compileStdOut .String (),
275
321
CompileErr : compileStdErr .String (),
0 commit comments