From a3b9cb683f219c57bec3c51542261708b9458380 Mon Sep 17 00:00:00 2001 From: Alessio Perugini Date: Tue, 12 Sep 2023 16:24:02 +0200 Subject: [PATCH] remove clean from Context --- arduino/builder/builder.go | 8 +------- arduino/builder/core.go | 8 ++++---- commands/compile/compile.go | 3 +-- legacy/builder/builder.go | 2 +- legacy/builder/test/builder_test.go | 4 ++-- legacy/builder/types/context.go | 1 - 6 files changed, 9 insertions(+), 17 deletions(-) diff --git a/arduino/builder/builder.go b/arduino/builder/builder.go index 169d729e33a..845657452db 100644 --- a/arduino/builder/builder.go +++ b/arduino/builder/builder.go @@ -49,15 +49,9 @@ type Builder struct { coreBuildCachePath *paths.Path logger *logger.BuilderLogger + clean bool *BuildOptionsManager - - hardwareDirs, builtInToolsDirs, otherLibrariesDirs paths.PathList - builtInLibrariesDirs *paths.Path - clean bool - - compilerOptimizationFlags string - runtimePlatformPath, buildCorePath *paths.Path } // NewBuilder creates a sketch Builder. diff --git a/arduino/builder/core.go b/arduino/builder/core.go index 9d3fa053eaa..4fc411235a0 100644 --- a/arduino/builder/core.go +++ b/arduino/builder/core.go @@ -37,7 +37,7 @@ import ( // BuildCore fixdoc func (b *Builder) BuildCore( actualPlatform *cores.PlatformRelease, - onlyUpdateCompilationDatabase, clean bool, + onlyUpdateCompilationDatabase bool, compilationDatabase *compilation.Database, progress *progress.Struct, progressCB rpc.TaskProgressCB, ) (paths.PathList, *paths.Path, error) { @@ -58,7 +58,7 @@ func (b *Builder) BuildCore( } archiveFile, objectFiles, err := b.compileCore( - onlyUpdateCompilationDatabase, clean, + onlyUpdateCompilationDatabase, actualPlatform, compilationDatabase, progress, progressCB, @@ -71,7 +71,7 @@ func (b *Builder) BuildCore( } func (b *Builder) compileCore( - onlyUpdateCompilationDatabase, clean bool, + onlyUpdateCompilationDatabase bool, actualPlatform *cores.PlatformRelease, compilationDatabase *compilation.Database, progress *progress.Struct, progressCB rpc.TaskProgressCB, @@ -117,7 +117,7 @@ func (b *Builder) compileCore( } var canUseArchivedCore bool - if onlyUpdateCompilationDatabase || clean { + if onlyUpdateCompilationDatabase || b.clean { canUseArchivedCore = false } else if isOlder, err := utils.DirContentIsOlderThan(realCoreFolder, targetArchivedCore); err != nil || !isOlder { // Recreate the archive if ANY of the core files (including platform.txt) has changed diff --git a/commands/compile/compile.go b/commands/compile/compile.go index 46d4870875a..6d5e293614d 100644 --- a/commands/compile/compile.go +++ b/commands/compile/compile.go @@ -192,7 +192,6 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream builderCtx.BuiltInLibrariesDirs = configuration.IDEBuiltinLibrariesDir(configuration.Settings) - builderCtx.Clean = req.GetClean() builderCtx.OnlyUpdateCompilationDatabase = req.GetCreateCompilationDatabaseOnly() builderCtx.SourceOverride = req.GetSourceOverride() @@ -212,7 +211,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream builderCtx.OtherLibrariesDirs, builderCtx.BuiltInLibrariesDirs, fqbn, - builderCtx.Clean, + req.GetClean(), builderLogger, ) if err != nil { diff --git a/legacy/builder/builder.go b/legacy/builder/builder.go index be668d8a21c..6feb0e4ce5f 100644 --- a/legacy/builder/builder.go +++ b/legacy/builder/builder.go @@ -134,7 +134,7 @@ func (s *Builder) Run(ctx *types.Context) error { types.BareCommand(func(ctx *types.Context) error { objectFiles, archiveFile, err := ctx.Builder.BuildCore( ctx.ActualPlatform, - ctx.OnlyUpdateCompilationDatabase, ctx.Clean, + ctx.OnlyUpdateCompilationDatabase, ctx.CompilationDatabase, &ctx.Progress, ctx.ProgressCB, ) diff --git a/legacy/builder/test/builder_test.go b/legacy/builder/test/builder_test.go index 4a33b8b6920..7af31de9a53 100644 --- a/legacy/builder/test/builder_test.go +++ b/legacy/builder/test/builder_test.go @@ -106,7 +106,7 @@ func prepareBuilderTestContext(t *testing.T, ctx *types.Context, sketchPath *pat ctx.Builder, err = bldr.NewBuilder( sk, nil, buildPath, false, nil, 0, nil, ctx.HardwareDirs, ctx.BuiltInToolsDirs, ctx.OtherLibrariesDirs, - ctx.BuiltInLibrariesDirs, parseFQBN(t, "a:b:c"), ctx.Clean, builderLogger, + ctx.BuiltInLibrariesDirs, parseFQBN(t, "a:b:c"), false, builderLogger, ) require.NoError(t, err) if fqbnString != "" { @@ -119,7 +119,7 @@ func prepareBuilderTestContext(t *testing.T, ctx *types.Context, sketchPath *pat ctx.Builder, err = bldr.NewBuilder( sk, boardBuildProperties, buildPath, false, nil, 0, nil, ctx.HardwareDirs, ctx.BuiltInToolsDirs, ctx.OtherLibrariesDirs, - ctx.BuiltInLibrariesDirs, fqbn, ctx.Clean, builderLogger) + ctx.BuiltInLibrariesDirs, fqbn, false, builderLogger) require.NoError(t, err) ctx.PackageManager = pme diff --git a/legacy/builder/types/context.go b/legacy/builder/types/context.go index 31e3d941749..ed23bea3970 100644 --- a/legacy/builder/types/context.go +++ b/legacy/builder/types/context.go @@ -39,7 +39,6 @@ type Context struct { BuiltInToolsDirs paths.PathList BuiltInLibrariesDirs *paths.Path OtherLibrariesDirs paths.PathList - Clean bool PackageManager *packagemanager.Explorer RequiredTools []*cores.ToolRelease