From bdfb4b295e2152a1c9d8b1982abf59c6c5e50ebb Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 24 Mar 2023 16:57:31 +0100 Subject: [PATCH 1/2] Skip useless operations in legacy test --- legacy/builder/test/prototypes_adder_test.go | 147 ------------------- 1 file changed, 147 deletions(-) diff --git a/legacy/builder/test/prototypes_adder_test.go b/legacy/builder/test/prototypes_adder_test.go index 159beb3923e..013d05aff69 100644 --- a/legacy/builder/test/prototypes_adder_test.go +++ b/legacy/builder/test/prototypes_adder_test.go @@ -48,16 +48,9 @@ func TestPrototypesAdderBridgeExample(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -87,16 +80,9 @@ func TestPrototypesAdderSketchWithIfDef(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -126,16 +112,9 @@ func TestPrototypesAdderBaladuino(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -165,16 +144,9 @@ func TestPrototypesAdderCharWithEscapedDoubleQuote(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -204,16 +176,9 @@ func TestPrototypesAdderIncludeBetweenMultilineComment(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -243,16 +208,9 @@ func TestPrototypesAdderLineContinuations(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -282,16 +240,9 @@ func TestPrototypesAdderStringWithComment(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -321,16 +272,9 @@ func TestPrototypesAdderSketchWithStruct(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -368,16 +312,9 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -413,16 +350,9 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -455,16 +385,9 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) { quotedSketchLocation := utils.QuoteCppPath(Abs(t, sketchLocation)) commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -497,16 +420,9 @@ func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -539,16 +455,9 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -592,16 +501,9 @@ func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -634,16 +536,9 @@ func TestPrototypesAdderSketchWithUSBCON(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -675,16 +570,9 @@ func TestPrototypesAdderSketchWithTypename(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -723,16 +611,9 @@ func TestPrototypesAdderSketchWithIfDef2(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -768,16 +649,9 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -813,16 +687,9 @@ func TestPrototypesAdderSketchWithConst(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -852,16 +719,9 @@ func TestPrototypesAdderSketchWithDosEol(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } @@ -891,16 +751,9 @@ func TestPrototypesAdderSketchWithSubstringFunctionMember(t *testing.T) { defer buildPath.RemoveAll() commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - &builder.ContainerMergeCopySketchFiles{}, - &builder.ContainerFindIncludes{}, - - &builder.PrintUsedLibrariesIfVerbose{}, - &builder.WarnAboutArchIncompatibleLibraries{}, - &builder.ContainerAddPrototypes{}, } From a43aa7df7f7734ab6a4f6299523ade2e8eff8115 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 24 Mar 2023 16:52:13 +0100 Subject: [PATCH 2/2] Removed legacy 'codecomplete' implementation. --- legacy/builder/preprocess_sketch.go | 44 ++--------------------------- legacy/builder/types/context.go | 2 -- 2 files changed, 3 insertions(+), 43 deletions(-) diff --git a/legacy/builder/preprocess_sketch.go b/legacy/builder/preprocess_sketch.go index 45166146080..3a47d11587c 100644 --- a/legacy/builder/preprocess_sketch.go +++ b/legacy/builder/preprocess_sketch.go @@ -21,7 +21,6 @@ import ( "os/exec" "path/filepath" "runtime" - "strings" bldr "github.com/arduino/arduino-cli/arduino/builder" "github.com/arduino/arduino-cli/legacy/builder/constants" @@ -36,7 +35,7 @@ var ArduinoPreprocessorProperties = properties.NewFromHashmap(map[string]string{ // Ctags "tools.arduino-preprocessor.path": "{runtime.tools.arduino-preprocessor.path}", "tools.arduino-preprocessor.cmd.path": "{path}/arduino-preprocessor", - "tools.arduino-preprocessor.pattern": `"{cmd.path}" "{source_file}" "{codecomplete}" -- -std=gnu++11`, + "tools.arduino-preprocessor.pattern": `"{cmd.path}" "{source_file}" -- -std=gnu++11`, "preproc.macros.flags": "-w -x c++ -E -CC", }) @@ -63,14 +62,7 @@ func (s *PreprocessSketchArduino) Run(ctx *types.Context) error { } } - var err error - if ctx.CodeCompleteAt != "" { - err = new(OutputCodeCompletions).Run(ctx) - } else { - err = bldr.SketchSaveItemCpp(ctx.Sketch.MainFile, []byte(ctx.Source), ctx.SketchBuildPath) - } - - return err + return bldr.SketchSaveItemCpp(ctx.Sketch.MainFile, []byte(ctx.Source), ctx.SketchBuildPath) } type ArduinoPreprocessorRunner struct{} @@ -83,21 +75,6 @@ func (s *ArduinoPreprocessorRunner) Run(ctx *types.Context) error { toolProps := buildProperties.SubTree("tools").SubTree("arduino-preprocessor") preprocProperties.Merge(toolProps) preprocProperties.SetPath(constants.BUILD_PROPERTIES_SOURCE_FILE, targetFilePath) - if ctx.CodeCompleteAt != "" { - if runtime.GOOS == "windows" { - //use relative filepath to avoid ":" escaping - splt := strings.Split(ctx.CodeCompleteAt, ":") - if len(splt) == 3 { - //all right, do nothing - } else { - splt[1] = filepath.Base(splt[0] + ":" + splt[1]) - ctx.CodeCompleteAt = strings.Join(splt[1:], ":") - } - } - preprocProperties.Set("codecomplete", "-output-code-completions="+ctx.CodeCompleteAt) - } else { - preprocProperties.Set("codecomplete", "") - } pattern := preprocProperties.Get(constants.BUILD_PROPERTIES_PATTERN) if pattern == constants.EMPTY_STRING { @@ -131,21 +108,6 @@ func (s *ArduinoPreprocessorRunner) Run(ctx *types.Context) error { result := utils.NormalizeUTF8(buf) //fmt.Printf("PREPROCESSOR OUTPUT:\n%s\n", output) - if ctx.CodeCompleteAt != "" { - ctx.CodeCompletions = string(result) - } else { - ctx.Source = string(result) - } - return nil -} - -type OutputCodeCompletions struct{} - -func (s *OutputCodeCompletions) Run(ctx *types.Context) error { - if ctx.CodeCompletions == "" { - // we assume it is a json, let's make it compliant at least - ctx.CodeCompletions = "[]" - } - ctx.WriteStdout([]byte(ctx.CodeCompletions)) + ctx.Source = string(result) return nil } diff --git a/legacy/builder/types/context.go b/legacy/builder/types/context.go index 0b78872ab33..6af1fb72104 100644 --- a/legacy/builder/types/context.go +++ b/legacy/builder/types/context.go @@ -72,7 +72,6 @@ type Context struct { LibraryDirs paths.PathList // List of paths pointing to individual library root folders WatchedLocations paths.PathList FQBN *cores.FQBN - CodeCompleteAt string Clean bool // Build options are serialized here @@ -110,7 +109,6 @@ type Context struct { Sketch *sketch.Sketch Source string SourceGccMinusE string - CodeCompletions string WarningsLevel string