diff --git a/src/arduino.cc/builder/compare_prototypes_from_source_and_preproc_source.go b/src/arduino.cc/builder/compare_prototypes_from_source_and_preproc_source.go deleted file mode 100644 index 0f19b7f1..00000000 --- a/src/arduino.cc/builder/compare_prototypes_from_source_and_preproc_source.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of Arduino Builder. - * - * Arduino Builder is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - * - * Copyright 2015 Arduino LLC (http://www.arduino.cc/) - */ - -package builder - -// XXX: Obsolete? - -import "arduino.cc/builder/types" - -type ComparePrototypesFromSourceAndPreprocSource struct{} - -func (s *ComparePrototypesFromSourceAndPreprocSource) Run(ctx *types.Context) error { - ctagsOfSource := ctx.CTagsOfSource - ctagsOfPreprocSource := ctx.CTagsOfPreprocessedSource - - actualCTags := []*types.CTag{} - for _, ctagOfPreprocSource := range ctagsOfPreprocSource { - if sliceContainsCTag(ctagsOfSource, ctagOfPreprocSource) { - actualCTags = append(actualCTags, ctagOfPreprocSource) - } - } - - ctx.CTagsCollected = actualCTags - - return nil -} - -func sliceContainsCTag(slice []*types.CTag, target *types.CTag) bool { - for _, value := range slice { - if value.FunctionName == target.FunctionName { - return true - } - } - return false -} diff --git a/src/arduino.cc/builder/external_include_replacer.go b/src/arduino.cc/builder/external_include_replacer.go deleted file mode 100644 index fc3dcb43..00000000 --- a/src/arduino.cc/builder/external_include_replacer.go +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file is part of Arduino Builder. - * - * Arduino Builder is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - * - * Copyright 2015 Arduino LLC (http://www.arduino.cc/) - */ - -package builder - -import ( - "arduino.cc/builder/types" - "path/filepath" - "strings" -) - -type ExternalIncludeReplacer struct { - Source *string - Target *string - From string - To string -} - -func (s *ExternalIncludeReplacer) Run(ctx *types.Context) error { - source := *s.Source - nonAbsoluteIncludes := findNonAbsoluteIncludes(ctx.Includes) - - for _, include := range nonAbsoluteIncludes { - source = strings.Replace(source, s.From+"<"+include+">", s.To+"<"+include+">", -1) - source = strings.Replace(source, s.From+"\""+include+"\"", s.To+"\""+include+"\"", -1) - } - - *s.Target = source - - return nil -} - -func findNonAbsoluteIncludes(includes []string) []string { - var nonAbsoluteIncludes []string - for _, include := range includes { - if !filepath.IsAbs(include) { - nonAbsoluteIncludes = append(nonAbsoluteIncludes, include) - } - } - return nonAbsoluteIncludes -} diff --git a/src/arduino.cc/builder/gcc_minus_m_output_parser.go b/src/arduino.cc/builder/gcc_minus_m_output_parser.go deleted file mode 100644 index 458d58de..00000000 --- a/src/arduino.cc/builder/gcc_minus_m_output_parser.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of Arduino Builder. - * - * Arduino Builder is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - * - * Copyright 2015 Arduino LLC (http://www.arduino.cc/) - */ - -package builder - -import ( - "arduino.cc/builder/types" - "arduino.cc/builder/utils" - "strings" -) - -type GCCMinusMOutputParser struct{} - -func (s *GCCMinusMOutputParser) Run(ctx *types.Context) error { - output := ctx.OutputGccMinusM - - rows := strings.Split(output, "\n") - includes := make([]string, 0) - if len(rows) > 2 { - for _, row := range rows[2:] { - if !strings.HasPrefix(row, " ") { - row = strings.TrimSpace(row) - if row != "" { - row = strings.TrimSuffix(row, ":") - row = strings.Replace(row, "\\ ", " ", -1) - includes = append(includes, row) - } - } - } - } - - ctx.Includes = utils.AppendIfNotPresent(ctx.Includes, includes...) - - return nil -} diff --git a/src/arduino.cc/builder/hardware/platform.txt b/src/arduino.cc/builder/hardware/platform.txt index 87d8b64a..ca8df1f7 100644 --- a/src/arduino.cc/builder/hardware/platform.txt +++ b/src/arduino.cc/builder/hardware/platform.txt @@ -7,10 +7,6 @@ tools.ctags.pattern="{cmd.path}" -u --language-force=c++ -f - --c++-kinds=svpf - # additional entries tools.avrdude.path={runtime.tools.avrdude.path} -preproc.includes.flags=-w -x c++ -M -MG -MP -#preproc.includes.compatibility_flags={build.mbed_api_include} {build.nRF51822_api_include} {build.ble_api_include} {compiler.libsam.c.flags} {compiler.arm.cmsis.path} {build.variant_system_include} -#recipe.preproc.includes="{compiler.path}{compiler.cpp.cmd}" {preproc.includes.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {preproc.includes.compatibility_flags} {includes} "{source_file}" - preproc.macros.flags=-w -x c++ -E -CC #preproc.macros.compatibility_flags={build.mbed_api_include} {build.nRF51822_api_include} {build.ble_api_include} {compiler.libsam.c.flags} {compiler.arm.cmsis.path} {build.variant_system_include} #recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" {compiler.cpreprocessor.flags} {compiler.cpp.flags} {preproc.macros.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {preproc.macros.compatibility_flags} {includes} "{source_file}" -o "{preprocessed_file_path}" diff --git a/src/arduino.cc/builder/includes_finder_with_gcc.go b/src/arduino.cc/builder/includes_finder_with_gcc.go deleted file mode 100644 index 847cabbc..00000000 --- a/src/arduino.cc/builder/includes_finder_with_gcc.go +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of Arduino Builder. - * - * Arduino Builder is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - * - * Copyright 2015 Arduino LLC (http://www.arduino.cc/) - */ - -package builder - -// XXX: Obsolete? - -import ( - "arduino.cc/builder/builder_utils" - "arduino.cc/builder/constants" - "arduino.cc/builder/i18n" - "arduino.cc/builder/types" - "arduino.cc/builder/utils" - "strings" -) - -type IncludesFinderWithGCC struct { - SourceFile string -} - -func (s *IncludesFinderWithGCC) Run(ctx *types.Context) error { - buildProperties := ctx.BuildProperties.Clone() - verbose := ctx.Verbose - logger := ctx.GetLogger() - - includes := utils.Map(ctx.IncludeFolders, utils.WrapWithHyphenI) - includesParams := strings.Join(includes, " ") - - properties := buildProperties.Clone() - properties[constants.BUILD_PROPERTIES_SOURCE_FILE] = s.SourceFile - properties[constants.BUILD_PROPERTIES_INCLUDES] = includesParams - builder_utils.RemoveHyphenMDDFlagFromGCCCommandLine(properties) - - if properties[constants.RECIPE_PREPROC_INCLUDES] == "" { - //generate RECIPE_PREPROC_INCLUDES from RECIPE_CPP_PATTERN - properties[constants.RECIPE_PREPROC_INCLUDES] = GeneratePreprocIncludePatternFromCompile(properties[constants.RECIPE_CPP_PATTERN]) - } - - output, err := builder_utils.ExecRecipe(properties, constants.RECIPE_PREPROC_INCLUDES, true, verbose, false, logger) - if err != nil { - return i18n.WrapError(err) - } - - ctx.OutputGccMinusM = string(output) - - return nil -} - -func GeneratePreprocIncludePatternFromCompile(compilePattern string) string { - // add {preproc.includes.flags} - // remove -o "{object_file}" - returnString := compilePattern - returnString = strings.Replace(returnString, "{compiler.cpp.flags}", "{compiler.cpp.flags} {preproc.includes.flags}", 1) - returnString = strings.Replace(returnString, "-o {object_file}", "", 1) - return returnString -} diff --git a/src/arduino.cc/builder/test/external_include_replacer_test.go b/src/arduino.cc/builder/test/external_include_replacer_test.go deleted file mode 100644 index e75b6597..00000000 --- a/src/arduino.cc/builder/test/external_include_replacer_test.go +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This file is part of Arduino Builder. - * - * Arduino Builder is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - * - * Copyright 2015 Arduino LLC (http://www.arduino.cc/) - */ - -package test - -import ( - "arduino.cc/builder" - "arduino.cc/builder/types" - "github.com/stretchr/testify/require" - "testing" -) - -var sourceWithIncludes = "#line 1 \"sketch_with_config.ino\"\n" + - "#include \"config.h\"\n" + - "\n" + - "#ifdef DEBUG\n" + - "#include \"includes/de bug.h\"\n" + - "#endif\n" + - "\n" + - "#include \n" + - "\n" + - "void setup() {\n" + - "\n" + - "}\n" + - "\n" + - "void loop() {\n" + - "\n" + - "}\n" - -var sourceWithPragmas = "#line 1 \"sketch_with_config.ino\"\n" + - "#include \"config.h\"\n" + - "\n" + - "#ifdef DEBUG\n" + - "#include \"includes/de bug.h\"\n" + - "#endif\n" + - "\n" + - "#pragma ___MY_INCLUDE___ \n" + - "\n" + - "void setup() {\n" + - "\n" + - "}\n" + - "\n" + - "void loop() {\n" + - "\n" + - "}\n" - -func TestExternalIncludeReplacerIncludeToPragma(t *testing.T) { - ctx := &types.Context{} - ctx.Source = sourceWithIncludes - ctx.Includes = []string{"/tmp/test184599776/sketch/config.h", "/tmp/test184599776/sketch/includes/de bug.h", "Bridge.h"} - - replacer := builder.ExternalIncludeReplacer{Source: &ctx.Source, Target: &ctx.SourceGccMinusE, From: "#include ", To: "#pragma ___MY_INCLUDE___ "} - err := replacer.Run(ctx) - NoError(t, err) - - require.Equal(t, sourceWithIncludes, ctx.Source) - require.Equal(t, sourceWithPragmas, ctx.SourceGccMinusE) -} - -func TestExternalIncludeReplacerPragmaToInclude(t *testing.T) { - ctx := &types.Context{} - ctx.SourceGccMinusE = sourceWithPragmas - ctx.Includes = []string{"/tmp/test184599776/sketch/config.h", "/tmp/test184599776/sketch/includes/de bug.h", "Bridge.h"} - - replacer := builder.ExternalIncludeReplacer{Source: &ctx.SourceGccMinusE, Target: &ctx.SourceGccMinusE, From: "#pragma ___MY_INCLUDE___ ", To: "#include "} - err := replacer.Run(ctx) - NoError(t, err) - - require.Empty(t, ctx.Source) - require.Equal(t, sourceWithIncludes, ctx.SourceGccMinusE) -} diff --git a/src/arduino.cc/builder/test/gcc_minus_m_output_parser_test.go b/src/arduino.cc/builder/test/gcc_minus_m_output_parser_test.go deleted file mode 100644 index df848fcc..00000000 --- a/src/arduino.cc/builder/test/gcc_minus_m_output_parser_test.go +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file is part of Arduino Builder. - * - * Arduino Builder is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - * - * Copyright 2015 Arduino LLC (http://www.arduino.cc/) - */ - -package test - -import ( - "arduino.cc/builder" - "arduino.cc/builder/types" - "github.com/stretchr/testify/require" - "testing" -) - -func TestGCCMinusMOutputParser(t *testing.T) { - ctx := &types.Context{} - - output := "sketch_with_config.o: sketch_with_config.ino config.h de\\ bug.h Bridge.h\n" + - "\n" + - "config.h:\n" + - "\n" + - "de\\ bug.h:\n" + - "\n" + - "Bridge.h:\n" - - ctx.OutputGccMinusM = output - - parser := builder.GCCMinusMOutputParser{} - err := parser.Run(ctx) - NoError(t, err) - - includes := ctx.Includes - require.Equal(t, 3, len(includes)) - require.Equal(t, "config.h", includes[0]) - require.Equal(t, "de bug.h", includes[1]) - require.Equal(t, "Bridge.h", includes[2]) -} - -func TestGCCMinusMOutputParserEmptyOutput(t *testing.T) { - ctx := &types.Context{} - - output := "sketch.ino.o: /tmp/test699709208/sketch/sketch.ino.cpp" - - ctx.OutputGccMinusM = output - - parser := builder.GCCMinusMOutputParser{} - err := parser.Run(ctx) - NoError(t, err) - - includes := ctx.Includes - require.Equal(t, 0, len(includes)) -} - -func TestGCCMinusMOutputParserFirstLineOnMultipleLines(t *testing.T) { - ctx := &types.Context{} - - output := "sketch_with_config.ino.o: \\\n" + - " /tmp/test097286304/sketch/sketch_with_config.ino.cpp \\\n" + - " /tmp/test097286304/sketch/config.h \\\n" + - " /tmp/test097286304/sketch/includes/de\\ bug.h Bridge.h\n" + - "\n" + - "/tmp/test097286304/sketch/config.h:\n" + - "\n" + - "/tmp/test097286304/sketch/includes/de\\ bug.h:\n" + - "\n" + - "Bridge.h:\n" - - ctx.OutputGccMinusM = output - - parser := builder.GCCMinusMOutputParser{} - err := parser.Run(ctx) - NoError(t, err) - - includes := ctx.Includes - require.Equal(t, 3, len(includes)) - require.Equal(t, "/tmp/test097286304/sketch/config.h", includes[0]) - require.Equal(t, "/tmp/test097286304/sketch/includes/de bug.h", includes[1]) - require.Equal(t, "Bridge.h", includes[2]) -} diff --git a/src/arduino.cc/builder/test/includes_finder_with_gcc_test.go b/src/arduino.cc/builder/test/includes_finder_with_gcc_test.go deleted file mode 100644 index 903161f1..00000000 --- a/src/arduino.cc/builder/test/includes_finder_with_gcc_test.go +++ /dev/null @@ -1,244 +0,0 @@ -/* - * This file is part of Arduino Builder. - * - * Arduino Builder is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - * - * Copyright 2015 Arduino LLC (http://www.arduino.cc/) - */ - -package test - -import ( - "arduino.cc/builder" - "arduino.cc/builder/types" - "arduino.cc/builder/utils" - "github.com/stretchr/testify/require" - "os" - "path/filepath" - "sort" - "testing" -) - -func TestIncludesFinderWithGCC(t *testing.T) { - DownloadCoresAndToolsAndLibraries(t) - - ctx := &types.Context{ - HardwareFolders: []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"}, - ToolsFolders: []string{"downloaded_tools"}, - SketchLocation: filepath.Join("sketch2", "SketchWithIfDef.ino"), - FQBN: "arduino:avr:leonardo", - ArduinoAPIVersion: "10600", - Verbose: true, - } - - buildPath := SetupBuildPath(t, ctx) - defer os.RemoveAll(buildPath) - - commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - - &builder.ContainerMergeCopySketchFiles{}, - - &builder.ContainerFindIncludes{}, - } - - for _, command := range commands { - err := command.Run(ctx) - NoError(t, err) - } - require.Nil(t, ctx.Includes) -} - -func TestIncludesFinderWithGCCSketchWithConfig(t *testing.T) { - DownloadCoresAndToolsAndLibraries(t) - - ctx := &types.Context{ - HardwareFolders: []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"}, - ToolsFolders: []string{"downloaded_tools"}, - BuiltInLibrariesFolders: []string{"downloaded_libraries"}, - OtherLibrariesFolders: []string{"dependent_libraries", "libraries"}, - SketchLocation: filepath.Join("sketch_with_config", "sketch_with_config.ino"), - FQBN: "arduino:avr:leonardo", - ArduinoAPIVersion: "10600", - Verbose: true, - } - - buildPath := SetupBuildPath(t, ctx) - defer os.RemoveAll(buildPath) - - commands := []types.Command{ - - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - - &builder.ContainerMergeCopySketchFiles{}, - - &builder.ContainerFindIncludes{}, - } - - for _, command := range commands { - err := command.Run(ctx) - NoError(t, err) - } - - includes := ctx.Includes - require.Equal(t, 1, len(includes)) - require.True(t, utils.SliceContains(includes, "Bridge.h")) - - importedLibraries := ctx.ImportedLibraries - require.Equal(t, 1, len(importedLibraries)) - require.Equal(t, "Bridge", importedLibraries[0].Name) -} - -func TestIncludesFinderWithGCCSketchWithDependendLibraries(t *testing.T) { - DownloadCoresAndToolsAndLibraries(t) - - ctx := &types.Context{ - HardwareFolders: []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"}, - ToolsFolders: []string{"downloaded_tools"}, - OtherLibrariesFolders: []string{"dependent_libraries"}, - SketchLocation: filepath.Join("sketch_with_dependend_libraries", "sketch.ino"), - FQBN: "arduino:avr:leonardo", - ArduinoAPIVersion: "10600", - Verbose: true, - } - - buildPath := SetupBuildPath(t, ctx) - defer os.RemoveAll(buildPath) - - commands := []types.Command{ - - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - - &builder.ContainerMergeCopySketchFiles{}, - - &builder.ContainerFindIncludes{}, - } - - for _, command := range commands { - err := command.Run(ctx) - NoError(t, err) - } - - includes := ctx.Includes - require.Equal(t, 4, len(includes)) - - sort.Strings(includes) - require.Equal(t, "library1.h", includes[0]) - require.Equal(t, "library2.h", includes[1]) - require.Equal(t, "library3.h", includes[2]) - require.Equal(t, "library4.h", includes[3]) - - importedLibraries := ctx.ImportedLibraries - require.Equal(t, 4, len(importedLibraries)) - - sort.Sort(ByLibraryName(importedLibraries)) - require.Equal(t, "library1", importedLibraries[0].Name) - require.Equal(t, "library2", importedLibraries[1].Name) - require.Equal(t, "library3", importedLibraries[2].Name) - require.Equal(t, "library4", importedLibraries[3].Name) -} - -func TestIncludesFinderWithGCCSketchWithThatChecksIfSPIHasTransactions(t *testing.T) { - DownloadCoresAndToolsAndLibraries(t) - - ctx := &types.Context{ - HardwareFolders: []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"}, - ToolsFolders: []string{"downloaded_tools"}, - BuiltInLibrariesFolders: []string{"downloaded_libraries"}, - OtherLibrariesFolders: []string{"dependent_libraries", "libraries"}, - SketchLocation: filepath.Join("sketch_that_checks_if_SPI_has_transactions", "sketch.ino"), - FQBN: "arduino:avr:leonardo", - ArduinoAPIVersion: "10600", - Verbose: true, - } - - buildPath := SetupBuildPath(t, ctx) - defer os.RemoveAll(buildPath) - - commands := []types.Command{ - - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - - &builder.ContainerMergeCopySketchFiles{}, - - &builder.ContainerFindIncludes{}, - } - - for _, command := range commands { - err := command.Run(ctx) - NoError(t, err) - } - - includes := ctx.Includes - require.Equal(t, 1, len(includes)) - require.Equal(t, "SPI.h", includes[0]) - - importedLibraries := ctx.ImportedLibraries - require.Equal(t, 1, len(importedLibraries)) - require.Equal(t, "SPI", importedLibraries[0].Name) -} - -func TestIncludesFinderWithGCCSketchWithThatChecksIfSPIHasTransactionsAndIncludesMissingLib(t *testing.T) { - DownloadCoresAndToolsAndLibraries(t) - - ctx := &types.Context{ - HardwareFolders: []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"}, - ToolsFolders: []string{"downloaded_tools"}, - BuiltInLibrariesFolders: []string{"downloaded_libraries"}, - OtherLibrariesFolders: []string{"dependent_libraries", "libraries"}, - SketchLocation: filepath.Join("sketch_that_checks_if_SPI_has_transactions_and_includes_missing_Ethernet", "sketch.ino"), - FQBN: "arduino:avr:leonardo", - ArduinoAPIVersion: "10600", - Verbose: true, - } - - buildPath := SetupBuildPath(t, ctx) - defer os.RemoveAll(buildPath) - - commands := []types.Command{ - - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - - &builder.ContainerMergeCopySketchFiles{}, - } - - for _, command := range commands { - err := command.Run(ctx) - NoError(t, err) - } - - command := &builder.ContainerFindIncludes{} - err := command.Run(ctx) - require.Error(t, err) - - includes := ctx.Includes - require.Equal(t, 2, len(includes)) - sort.Strings(includes) - require.Equal(t, "Inexistent.h", includes[0]) - require.Equal(t, "SPI.h", includes[1]) - - importedLibraries := ctx.ImportedLibraries - require.Equal(t, 1, len(importedLibraries)) - require.Equal(t, "SPI", importedLibraries[0].Name) -} diff --git a/src/arduino.cc/builder/types/context.go b/src/arduino.cc/builder/types/context.go index 09546536..1b04e1aa 100644 --- a/src/arduino.cc/builder/types/context.go +++ b/src/arduino.cc/builder/types/context.go @@ -65,7 +65,6 @@ type Context struct { // C++ Parsing CTagsOutput string CTagsTargetFile string - CTagsOfSource []*CTag CTagsOfPreprocessedSource []*CTag CTagsCollected []*CTag IncludeSection string