From 8c8965a2c17afa68852cef528a7af02f2730b65d Mon Sep 17 00:00:00 2001 From: rsora Date: Fri, 21 Feb 2020 12:16:25 +0100 Subject: [PATCH 1/3] add debug symbols option in CLI and gRPC insterface --- cli/compile/compile.go | 31 ++++++----- commands/compile/compile.go | 3 ++ legacy/builder/create_build_options_map.go | 2 - legacy/builder/setup_build_properties.go | 11 ++++ legacy/builder/types/context.go | 6 +++ rpc/commands/compile.pb.go | 63 ++++++++++++---------- rpc/commands/compile.proto | 1 + rpc/debug/debug.pb.go | 3 +- 8 files changed, 75 insertions(+), 45 deletions(-) diff --git a/cli/compile/compile.go b/cli/compile/compile.go index 6f62f5f5267..8f1ab072a46 100644 --- a/cli/compile/compile.go +++ b/cli/compile/compile.go @@ -48,6 +48,7 @@ var ( verify bool // Upload, verify uploaded binary after the upload. exportFile string // The compiled binary is written to this file libraries []string // List of custom libraries paths separated by commas. Or can be used multiple times for multiple libraries paths. + optimizeForDebug bool // Optimize compile output for debug, not for release ) // NewCommand created a new `compile` command @@ -80,6 +81,7 @@ func NewCommand() *cobra.Command { command.Flags().StringVar(&vidPid, "vid-pid", "", "When specified, VID/PID specific build properties are used, if boards supports them.") command.Flags().StringSliceVar(&libraries, "libraries", []string{}, "List of custom libraries paths separated by commas. Or can be used multiple times for multiple libraries paths.") + command.Flags().BoolVar(&optimizeForDebug, "optimize-for-debug", false, "Optional, optimize compile output for debug, not for release.") return command } @@ -99,20 +101,21 @@ func run(cmd *cobra.Command, args []string) { sketchPath := initSketchPath(path) _, err = compile.Compile(context.Background(), &rpc.CompileReq{ - Instance: inst, - Fqbn: fqbn, - SketchPath: sketchPath.String(), - ShowProperties: showProperties, - Preprocess: preprocess, - BuildCachePath: buildCachePath, - BuildPath: buildPath, - BuildProperties: buildProperties, - Warnings: warnings, - Verbose: verbose, - Quiet: quiet, - VidPid: vidPid, - ExportFile: exportFile, - Libraries: libraries, + Instance: inst, + Fqbn: fqbn, + SketchPath: sketchPath.String(), + ShowProperties: showProperties, + Preprocess: preprocess, + BuildCachePath: buildCachePath, + BuildPath: buildPath, + BuildProperties: buildProperties, + Warnings: warnings, + Verbose: verbose, + Quiet: quiet, + VidPid: vidPid, + ExportFile: exportFile, + Libraries: libraries, + OptimizeForDebug: optimizeForDebug, }, os.Stdout, os.Stderr, viper.GetString("logging.level") == "debug") if err != nil { diff --git a/commands/compile/compile.go b/commands/compile/compile.go index a03a0b01c5d..e00398abed0 100644 --- a/commands/compile/compile.go +++ b/commands/compile/compile.go @@ -103,6 +103,9 @@ func Compile(ctx context.Context, req *rpc.CompileReq, outStream, errStream io.W builderCtx.Verbose = req.GetVerbose() + // Optimize for debug + builderCtx.OptimizeForDebug = req.GetOptimizeForDebug() + builderCtx.CoreBuildCachePath = paths.TempDir().Join("arduino-core-cache") builderCtx.Jobs = int(req.GetJobs()) diff --git a/legacy/builder/create_build_options_map.go b/legacy/builder/create_build_options_map.go index 8583d374a05..b9de9b0cc45 100644 --- a/legacy/builder/create_build_options_map.go +++ b/legacy/builder/create_build_options_map.go @@ -17,7 +17,6 @@ package builder import ( "encoding/json" - "github.com/arduino/arduino-cli/legacy/builder/i18n" "github.com/arduino/arduino-cli/legacy/builder/types" ) @@ -30,7 +29,6 @@ func (s *CreateBuildOptionsMap) Run(ctx *types.Context) error { if err != nil { return i18n.WrapError(err) } - ctx.BuildOptionsJson = string(bytes) return nil diff --git a/legacy/builder/setup_build_properties.go b/legacy/builder/setup_build_properties.go index e23a697363e..a69ae5099a5 100644 --- a/legacy/builder/setup_build_properties.go +++ b/legacy/builder/setup_build_properties.go @@ -69,6 +69,17 @@ func (s *SetupBuildProperties) Run(ctx *types.Context) error { buildProperties.Set("ide_version", ctx.ArduinoAPIVersion) buildProperties.Set("runtime.os", utils.PrettyOSName()) + if ctx.OptimizeForDebug { + if buildProperties.ContainsKey("compiler.optimization_flags.debug") { + buildProperties.Set("compiler.optimization_flags", buildProperties.Get("compiler.optimization_flags.debug")) + } + } else { + if buildProperties.ContainsKey("compiler.optimization_flags.release") { + buildProperties.Set("compiler.optimization_flags", buildProperties.Get("compiler.optimization_flags.release")) + } + } + ctx.OptimizationFlags = buildProperties.Get("compiler.optimization_flags") + variant := buildProperties.Get("build.variant") if variant == "" { buildProperties.Set("build.variant.path", "") diff --git a/legacy/builder/types/context.go b/legacy/builder/types/context.go index 8238ed98c3f..50b3935ef79 100644 --- a/legacy/builder/types/context.go +++ b/legacy/builder/types/context.go @@ -94,6 +94,10 @@ type Context struct { Verbose bool DebugPreprocessor bool + // Compile optimization settings + OptimizeForDebug bool + OptimizationFlags string + // Dry run, only create progress map Progress ProgressStruct @@ -140,6 +144,7 @@ func (ctx *Context) ExtractBuildOptions() *properties.Map { opts.Set("runtime.ide.version", ctx.ArduinoAPIVersion) opts.Set("customBuildProperties", strings.Join(ctx.CustomBuildProperties, ",")) opts.Set("additionalFiles", strings.Join(additionalFilesRelative, ",")) + opts.Set("compiler.optimization_flags", ctx.OptimizationFlags) return opts } @@ -156,6 +161,7 @@ func (ctx *Context) InjectBuildOptions(opts *properties.Map) { ctx.FQBN = fqbn ctx.ArduinoAPIVersion = opts.Get("runtime.ide.version") ctx.CustomBuildProperties = strings.Split(opts.Get("customBuildProperties"), ",") + ctx.OptimizationFlags = opts.Get("compiler.optimization_flags") } func (ctx *Context) GetLogger() i18n.Logger { diff --git a/rpc/commands/compile.pb.go b/rpc/commands/compile.pb.go index ca07e31f157..096bb38ff83 100644 --- a/rpc/commands/compile.pb.go +++ b/rpc/commands/compile.pb.go @@ -36,6 +36,7 @@ type CompileReq struct { ExportFile string `protobuf:"bytes,13,opt,name=exportFile,proto3" json:"exportFile,omitempty"` Jobs int32 `protobuf:"varint,14,opt,name=jobs,proto3" json:"jobs,omitempty"` Libraries []string `protobuf:"bytes,15,rep,name=libraries,proto3" json:"libraries,omitempty"` + OptimizeForDebug bool `protobuf:"varint,16,opt,name=optimizeForDebug,proto3" json:"optimizeForDebug,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -171,6 +172,13 @@ func (m *CompileReq) GetLibraries() []string { return nil } +func (m *CompileReq) GetOptimizeForDebug() bool { + if m != nil { + return m.OptimizeForDebug + } + return false +} + type CompileResp struct { OutStream []byte `protobuf:"bytes,1,opt,name=out_stream,json=outStream,proto3" json:"out_stream,omitempty"` ErrStream []byte `protobuf:"bytes,2,opt,name=err_stream,json=errStream,proto3" json:"err_stream,omitempty"` @@ -226,31 +234,32 @@ func init() { func init() { proto.RegisterFile("commands/compile.proto", fileDescriptor_86bc582849c76c3d) } var fileDescriptor_86bc582849c76c3d = []byte{ - // 405 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x41, 0x6f, 0xd4, 0x30, - 0x10, 0x85, 0x95, 0x6e, 0x77, 0xbb, 0x99, 0x2d, 0xad, 0x64, 0x41, 0xb1, 0x2a, 0x40, 0xa1, 0x07, - 0x14, 0x09, 0x35, 0x2b, 0xc1, 0x99, 0x0b, 0x95, 0x90, 0x10, 0x97, 0x55, 0xb8, 0x71, 0x41, 0x89, - 0x33, 0x34, 0x86, 0x24, 0xf6, 0x8e, 0x9d, 0x96, 0x3f, 0xcd, 0x7f, 0x40, 0x9e, 0x6c, 0x36, 0xab, - 0x95, 0x7a, 0x4a, 0xe6, 0x7b, 0xcf, 0xcf, 0x63, 0x7b, 0xe0, 0x4a, 0x99, 0xb6, 0x2d, 0xba, 0xca, - 0xad, 0x95, 0x69, 0xad, 0x6e, 0x30, 0xb3, 0x64, 0xbc, 0x11, 0x2f, 0x95, 0xca, 0x0a, 0xaa, 0x7a, - 0xdd, 0x99, 0x4c, 0x35, 0x3a, 0x1b, 0x6d, 0xd7, 0x2f, 0x0e, 0x17, 0xb4, 0xa6, 0x1b, 0xfc, 0x37, - 0xff, 0x66, 0x00, 0x77, 0x43, 0x42, 0x8e, 0x5b, 0xf1, 0x09, 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xfb, 0xb7, 0x29, 0x9d, 0xbc, 0x48, 0xa2, 0x74, 0x9e, 0xf3, 0x7f, 0x38, 0x5f, 0xa3, 0x4b, 0x2a, - 0x28, 0xf4, 0x7e, 0xc9, 0xbd, 0x4f, 0xe0, 0xe6, 0x1b, 0xac, 0xf6, 0xcf, 0xed, 0xac, 0x78, 0x0d, - 0x60, 0x7a, 0xff, 0xd3, 0x79, 0xc2, 0xa2, 0xe5, 0x17, 0x3f, 0xcf, 0x63, 0xd3, 0xfb, 0xef, 0x0c, - 0x82, 0x8c, 0x44, 0xa3, 0x7c, 0x32, 0xc8, 0x48, 0x34, 0xc8, 0x9f, 0x6f, 0x7f, 0xbc, 0xbf, 0xd7, - 0xbe, 0xee, 0xcb, 0x30, 0x14, 0xeb, 0xdd, 0x90, 0x8c, 0xdf, 0x5b, 0xd5, 0xe8, 0x35, 0x59, 0xb5, - 0x1e, 0x07, 0xa6, 0x5c, 0xf0, 0xc8, 0x7d, 0xfc, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x89, 0x00, 0xe4, - 0x1f, 0xbc, 0x02, 0x00, 0x00, + // 426 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xc1, 0x6f, 0xd3, 0x30, + 0x14, 0xc6, 0x95, 0xad, 0xed, 0x9a, 0xd7, 0xb1, 0x4d, 0x16, 0x0c, 0x6b, 0x02, 0x14, 0x76, 0x40, + 0x11, 0x68, 0xa9, 0x04, 0x67, 0x2e, 0x0c, 0x4d, 0x42, 0x5c, 0xaa, 0x70, 0xe3, 0x82, 0x12, 0xe7, + 0xd1, 0x18, 0x92, 0xd8, 0x7d, 0x76, 0x36, 0xc4, 0x7f, 0xc2, 0x7f, 0x8b, 0xf2, 0xd2, 0x34, 0x55, + 0x11, 0x27, 0xfb, 0xfd, 0xde, 0xe7, 0xcf, 0xcf, 0xd6, 0x07, 0x97, 0xca, 0xd4,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0xa4, 0xdc, 0x38, 0x94, 0xc0, 0x83, 0x0e, 0xa5, 0x78, 0x0c, 0xd3, 0x4d, 0xab, 0xd1, + 0xcb, 0x05, 0xf3, 0xbe, 0x10, 0x97, 0x30, 0xbb, 0xd7, 0xc5, 0x4a, 0x17, 0xf2, 0x94, 0x9d, 0xb6, + 0x55, 0xf7, 0x66, 0xfc, 0x65, 0x0d, 0xf9, 0x3b, 0x5d, 0xa1, 0x7c, 0xd4, 0xff, 0xdd, 0x48, 0xba, + 0xff, 0xfe, 0x61, 0x72, 0x27, 0xcf, 0xa2, 0x20, 0x9e, 0xa6, 0xbc, 0xef, 0xde, 0x57, 0xe9, 0x9c, + 0x32, 0xea, 0x66, 0x3f, 0xe7, 0xd9, 0x47, 0x20, 0x5e, 0xc3, 0x85, 0xb1, 0x5e, 0xd7, 0xfa, 0x37, + 0xde, 0x19, 0xfa, 0x88, 0x79, 0xbb, 0x96, 0x17, 0x3c, 0xca, 0x3f, 0xfc, 0xfa, 0x33, 0x2c, 0x76, + 0xd1, 0x70, 0x56, 0x3c, 0x07, 0x30, 0xad, 0xff, 0xe6, 0x3c, 0x61, 0x56, 0x73, 0x3a, 0x4e, 0xd3, + 0xd0, 0xb4, 0xfe, 0x0b, 0x83, 0xae, 0x8d, 0x44, 0x43, 0xfb, 0xa8, 0x6f, 0x23, 0x51, 0xdf, 0xfe, + 0x70, 0xf3, 0xf5, 0xcd, 0x5a, 0xfb, 0xb2, 0xcd, 0xbb, 0x00, 0x2d, 0xb7, 0x81, 0x1a, 0xd6, 0x1b, + 0x55, 0xe9, 0x25, 0x59, 0xb5, 0x1c, 0xc2, 0x95, 0xcf, 0x38, 0x9e, 0xef, 0xfe, 0x06, 0x00, 0x00, + 0xff, 0xff, 0x89, 0xd3, 0x60, 0xf6, 0xe8, 0x02, 0x00, 0x00, } diff --git a/rpc/commands/compile.proto b/rpc/commands/compile.proto index cabd9985047..30bde5f5e41 100644 --- a/rpc/commands/compile.proto +++ b/rpc/commands/compile.proto @@ -37,6 +37,7 @@ message CompileReq { string exportFile = 13; // The compiled binary is written to this file int32 jobs = 14; // The max number of concurrent compiler instances to run (as make -jx) repeated string libraries = 15; // List of custom libraries paths separated by commas. Or can be used multiple times for multiple libraries paths. + bool optimizeForDebug = 16; // Optimize compile output for debug, not for release } message CompileResp { diff --git a/rpc/debug/debug.pb.go b/rpc/debug/debug.pb.go index fad8b92d951..f1118002282 100644 --- a/rpc/debug/debug.pb.go +++ b/rpc/debug/debug.pb.go @@ -205,8 +205,7 @@ func (m *DebugResp) GetError() string { return "" } -// duplicate from commands/common.proto -// as module imports seems not to work +// TODO remove this in next proto refactoring because is a duplicate from commands/common.proto type Instance struct { Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` From deee04902786eedfdb2a552574e9be8deb2ff510 Mon Sep 17 00:00:00 2001 From: rsora Date: Fri, 21 Feb 2020 12:23:02 +0100 Subject: [PATCH 2/3] Calculate precompiled core path usign also build optimization flags --- legacy/builder/builder_utils/utils.go | 17 ----------------- legacy/builder/phases/core_builder.go | 21 ++++++++++++++++++++- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/legacy/builder/builder_utils/utils.go b/legacy/builder/builder_utils/utils.go index 7ebc86f2d21..c8f0ffefd89 100644 --- a/legacy/builder/builder_utils/utils.go +++ b/legacy/builder/builder_utils/utils.go @@ -519,20 +519,3 @@ func PrepareCommandForRecipe(ctx *types.Context, buildProperties *properties.Map return command, nil } - -// GetCachedCoreArchiveFileName returns the filename to be used to store -// the global cached core.a. -func GetCachedCoreArchiveFileName(fqbn string, coreFolder *paths.Path) string { - fqbnToUnderscore := strings.Replace(fqbn, ":", "_", -1) - fqbnToUnderscore = strings.Replace(fqbnToUnderscore, "=", "_", -1) - if absCoreFolder, err := coreFolder.Abs(); err == nil { - coreFolder = absCoreFolder - } // silently continue if absolute path can't be detected - hash := utils.MD5Sum([]byte(coreFolder.String())) - realName := "core_" + fqbnToUnderscore + "_" + hash + ".a" - if len(realName) > 100 { - // avoid really long names, simply hash the final part - realName = "core_" + utils.MD5Sum([]byte(fqbnToUnderscore+"_"+hash)) + ".a" - } - return realName -} diff --git a/legacy/builder/phases/core_builder.go b/legacy/builder/phases/core_builder.go index bf178652e37..edd199ad928 100644 --- a/legacy/builder/phases/core_builder.go +++ b/legacy/builder/phases/core_builder.go @@ -17,6 +17,7 @@ package phases import ( "os" + "strings" "github.com/arduino/arduino-cli/legacy/builder/builder_utils" "github.com/arduino/arduino-cli/legacy/builder/constants" @@ -90,7 +91,8 @@ func compileCore(ctx *types.Context, buildPath *paths.Path, buildCachePath *path var targetArchivedCore *paths.Path if buildCachePath != nil { - archivedCoreName := builder_utils.GetCachedCoreArchiveFileName(buildProperties.Get(constants.BUILD_PROPERTIES_FQBN), realCoreFolder) + archivedCoreName := getCachedCoreArchiveFileName(buildProperties.Get(constants.BUILD_PROPERTIES_FQBN), + buildProperties.Get("compiler.optimization_flags"), realCoreFolder) targetArchivedCore = buildCachePath.Join(archivedCoreName) canUseArchivedCore := !builder_utils.CoreOrReferencedCoreHasChanged(realCoreFolder, targetCoreFolder, targetArchivedCore) @@ -129,3 +131,20 @@ func compileCore(ctx *types.Context, buildPath *paths.Path, buildCachePath *path return archiveFile, variantObjectFiles, nil } + +// GetCachedCoreArchiveFileName returns the filename to be used to store +// the global cached core.a. +func getCachedCoreArchiveFileName(fqbn string, optimizationFlags string, coreFolder *paths.Path) string { + fqbnToUnderscore := strings.Replace(fqbn, ":", "_", -1) + fqbnToUnderscore = strings.Replace(fqbnToUnderscore, "=", "_", -1) + if absCoreFolder, err := coreFolder.Abs(); err == nil { + coreFolder = absCoreFolder + } // silently continue if absolute path can't be detected + hash := utils.MD5Sum([]byte(coreFolder.String() + optimizationFlags)) + realName := "core_" + fqbnToUnderscore + "_" + hash + ".a" + if len(realName) > 100 { + // avoid really long names, simply hash the final part + realName = "core_" + utils.MD5Sum([]byte(fqbnToUnderscore+"_"+hash)) + ".a" + } + return realName +} From 46837068d89c783a62f41f50f024859bfdcb2c74 Mon Sep 17 00:00:00 2001 From: rsora Date: Fri, 21 Feb 2020 12:49:11 +0100 Subject: [PATCH 3/3] Align failing lecacy tests with new hashing behaviour --- legacy/builder/phases/core_builder.go | 4 ++-- legacy/builder/test/builder_test.go | 4 ++-- legacy/builder/test/create_build_options_map_test.go | 2 ++ legacy/builder/test/store_build_options_map_test.go | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/legacy/builder/phases/core_builder.go b/legacy/builder/phases/core_builder.go index edd199ad928..846fd30dbb6 100644 --- a/legacy/builder/phases/core_builder.go +++ b/legacy/builder/phases/core_builder.go @@ -91,7 +91,7 @@ func compileCore(ctx *types.Context, buildPath *paths.Path, buildCachePath *path var targetArchivedCore *paths.Path if buildCachePath != nil { - archivedCoreName := getCachedCoreArchiveFileName(buildProperties.Get(constants.BUILD_PROPERTIES_FQBN), + archivedCoreName := GetCachedCoreArchiveFileName(buildProperties.Get(constants.BUILD_PROPERTIES_FQBN), buildProperties.Get("compiler.optimization_flags"), realCoreFolder) targetArchivedCore = buildCachePath.Join(archivedCoreName) canUseArchivedCore := !builder_utils.CoreOrReferencedCoreHasChanged(realCoreFolder, targetCoreFolder, targetArchivedCore) @@ -134,7 +134,7 @@ func compileCore(ctx *types.Context, buildPath *paths.Path, buildCachePath *path // GetCachedCoreArchiveFileName returns the filename to be used to store // the global cached core.a. -func getCachedCoreArchiveFileName(fqbn string, optimizationFlags string, coreFolder *paths.Path) string { +func GetCachedCoreArchiveFileName(fqbn string, optimizationFlags string, coreFolder *paths.Path) string { fqbnToUnderscore := strings.Replace(fqbn, ":", "_", -1) fqbnToUnderscore = strings.Replace(fqbnToUnderscore, "=", "_", -1) if absCoreFolder, err := coreFolder.Abs(); err == nil { diff --git a/legacy/builder/test/builder_test.go b/legacy/builder/test/builder_test.go index a8c8f078d39..351b3a6c8d6 100644 --- a/legacy/builder/test/builder_test.go +++ b/legacy/builder/test/builder_test.go @@ -24,8 +24,8 @@ import ( "github.com/arduino/go-paths-helper" "github.com/arduino/arduino-cli/legacy/builder" - "github.com/arduino/arduino-cli/legacy/builder/builder_utils" "github.com/arduino/arduino-cli/legacy/builder/constants" + "github.com/arduino/arduino-cli/legacy/builder/phases" "github.com/arduino/arduino-cli/legacy/builder/types" "github.com/stretchr/testify/require" ) @@ -379,7 +379,7 @@ func TestBuilderCacheCoreAFile(t *testing.T) { // Pick timestamp of cached core coreFolder := paths.New("downloaded_hardware", "arduino", "avr") - coreFileName := builder_utils.GetCachedCoreArchiveFileName(ctx.FQBN.String(), coreFolder) + coreFileName := phases.GetCachedCoreArchiveFileName(ctx.FQBN.String(), ctx.OptimizationFlags, coreFolder) cachedCoreFile := ctx.CoreBuildCachePath.Join(coreFileName) coreStatBefore, err := cachedCoreFile.Stat() require.NoError(t, err) diff --git a/legacy/builder/test/create_build_options_map_test.go b/legacy/builder/test/create_build_options_map_test.go index d7024d47689..3abb60eca0a 100644 --- a/legacy/builder/test/create_build_options_map_test.go +++ b/legacy/builder/test/create_build_options_map_test.go @@ -35,6 +35,7 @@ func TestCreateBuildOptionsMap(t *testing.T) { Verbose: true, BuildPath: paths.New("buildPath"), DebugLevel: 5, + OptimizationFlags: "-Os", } create := builder.CreateBuildOptionsMap{} @@ -45,6 +46,7 @@ func TestCreateBuildOptionsMap(t *testing.T) { "additionalFiles": "", "builtInLibrariesFolders": "", "builtInToolsFolders": "tools", + "compiler.optimization_flags": "-Os", "customBuildProperties": "", "fqbn": "my:nice:fqbn", "hardwareFolders": "hardware,hardware2", diff --git a/legacy/builder/test/store_build_options_map_test.go b/legacy/builder/test/store_build_options_map_test.go index 82b555c403f..f3aa0b7ba79 100644 --- a/legacy/builder/test/store_build_options_map_test.go +++ b/legacy/builder/test/store_build_options_map_test.go @@ -37,6 +37,7 @@ func TestStoreBuildOptionsMap(t *testing.T) { CustomBuildProperties: []string{"custom=prop"}, Verbose: true, DebugLevel: 5, + OptimizationFlags: "-Os", } buildPath := SetupBuildPath(t, ctx) @@ -63,6 +64,7 @@ func TestStoreBuildOptionsMap(t *testing.T) { "additionalFiles": "", "builtInLibrariesFolders": "built-in libraries", "builtInToolsFolders": "tools", + "compiler.optimization_flags": "-Os", "customBuildProperties": "custom=prop", "fqbn": "my:nice:fqbn", "hardwareFolders": "hardware", pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy