Skip to content

Commit d9b4541

Browse files
committed
Removed a bunch of unused functions/identifiers
1 parent d203490 commit d9b4541

12 files changed

+9
-164
lines changed

add_additional_entries_to_context.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import (
4040

4141
type AddAdditionalEntriesToContext struct{}
4242

43-
func (s *AddAdditionalEntriesToContext) Run(ctx *types.Context) error {
43+
func (*AddAdditionalEntriesToContext) Run(ctx *types.Context) error {
4444
if ctx.BuildPath != "" {
4545
buildPath := ctx.BuildPath
4646
preprocPath, err := filepath.Abs(filepath.Join(buildPath, constants.FOLDER_PREPROC))

add_build_board_property_if_missing.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939

4040
type AddBuildBoardPropertyIfMissing struct{}
4141

42-
func (s *AddBuildBoardPropertyIfMissing) Run(ctx *types.Context) error {
42+
func (*AddBuildBoardPropertyIfMissing) Run(ctx *types.Context) error {
4343
packages := ctx.Hardware
4444
logger := ctx.GetLogger()
4545

arduino-builder/main.go

-8
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,6 @@ func toSliceOfUnquoted(value []string) ([]string, error) {
375375
return values, nil
376376
}
377377

378-
func printError(err error, printStackTrace bool) {
379-
if printStackTrace {
380-
printCompleteError(err)
381-
} else {
382-
printErrorMessageAndFlagUsage(err)
383-
}
384-
}
385-
386378
func printCompleteError(err error) {
387379
err = i18n.WrapError(err)
388380
fmt.Fprintln(os.Stderr, err.(*errors.Error).ErrorStack())

builder_utils/utils.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func ArchiveCompiledFiles(buildPath string, archiveFile string, objectFiles []st
355355
}
356356

357357
func ExecRecipe(properties properties.Map, recipe string, removeUnsetProperties bool, echoCommandLine bool, echoOutput bool, logger i18n.Logger) ([]byte, error) {
358-
command, err := PrepareCommandForRecipe(properties, recipe, removeUnsetProperties, echoCommandLine, echoOutput, logger)
358+
command, err := PrepareCommandForRecipe(properties, recipe, removeUnsetProperties, echoCommandLine, logger)
359359
if err != nil {
360360
return nil, i18n.WrapError(err)
361361
}
@@ -375,7 +375,7 @@ func ExecRecipe(properties properties.Map, recipe string, removeUnsetProperties
375375
return bytes, i18n.WrapError(err)
376376
}
377377

378-
func PrepareCommandForRecipe(buildProperties properties.Map, recipe string, removeUnsetProperties bool, echoCommandLine bool, echoOutput bool, logger i18n.Logger) (*exec.Cmd, error) {
378+
func PrepareCommandForRecipe(buildProperties properties.Map, recipe string, removeUnsetProperties bool, echoCommandLine bool, logger i18n.Logger) (*exec.Cmd, error) {
379379
pattern := buildProperties[recipe]
380380
if pattern == constants.EMPTY_STRING {
381381
return nil, i18n.ErrorfWithLogger(logger, constants.MSG_PATTERN_MISSING, recipe)
@@ -399,8 +399,8 @@ func PrepareCommandForRecipe(buildProperties properties.Map, recipe string, remo
399399
return command, nil
400400
}
401401

402-
func ExecRecipeCollectStdErr(buildProperties properties.Map, recipe string, removeUnsetProperties bool, echoCommandLine bool, echoOutput bool, logger i18n.Logger) (string, error) {
403-
command, err := PrepareCommandForRecipe(buildProperties, recipe, removeUnsetProperties, echoCommandLine, echoOutput, logger)
402+
func ExecRecipeCollectStdErr(buildProperties properties.Map, recipe string, removeUnsetProperties bool, echoCommandLine bool, logger i18n.Logger) (string, error) {
403+
command, err := PrepareCommandForRecipe(buildProperties, recipe, removeUnsetProperties, echoCommandLine, logger)
404404
if err != nil {
405405
return "", i18n.WrapError(err)
406406
}

constants/constants.go

-14
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ const BUILD_PROPERTIES_TOOLS_KEY = "tools"
5959
const BUILD_PROPERTIES_VID = "vid"
6060
const CTAGS = "ctags"
6161
const EMPTY_STRING = ""
62-
const FILE_BUILTIN_TOOLS_VERSIONS_TXT = "builtin_tools_versions.txt"
6362
const FILE_CTAGS_TARGET_FOR_GCC_MINUS_E = "ctags_target_for_gcc_minus_e.cpp"
64-
const FILE_GCC_PREPROC_TARGET = "gcc_preproc_target.cpp"
6563
const FILE_PLATFORM_KEYS_REWRITE_TXT = "platform.keys.rewrite.txt"
6664
const FILE_INCLUDES_CACHE = "includes.cache"
6765
const FOLDER_BOOTLOADERS = "bootloaders"
@@ -128,7 +126,6 @@ const MSG_BUILD_OPTIONS_CHANGED = "Build options changed, rebuilding all"
128126
const MSG_CANT_FIND_SKETCH_IN_PATH = "Unable to find {0} in {1}"
129127
const MSG_FQBN_INVALID = "{0} is not a valid fully qualified board name. Required format is targetPackageName:targetPlatformName:targetBoardName."
130128
const MSG_INVALID_QUOTING = "Invalid quoting: no closing [{0}] char found."
131-
const MSG_IGNORED_BUILTIN_TOOLS_TXT = "Skipping {0}; please consider removing that file since it may hurt older Arduino installations"
132129
const MSG_LIB_LEGACY = "(legacy)"
133130
const MSG_LIBRARIES_MULTIPLE_LIBS_FOUND_FOR = "Multiple libraries were found for \"{0}\""
134131
const MSG_LIBRARIES_NOT_USED = " Not used: {0}"
@@ -138,7 +135,6 @@ const MSG_LIBRARY_INCOMPATIBLE_ARCH = "WARNING: library {0} claims to run on {1}
138135
const MSG_LOOKING_FOR_RECIPES = "Looking for recipes like {0}*{1}"
139136
const MSG_MISSING_BUILD_BOARD = "Warning: Board {0}:{1}:{2} doesn''t define a ''build.board'' preference. Auto-set to: {3}"
140137
const MSG_MISSING_CORE_FOR_BOARD = "Selected board depends on '{0}' core (not installed)."
141-
const MSG_MUST_BE_A_FOLDER = "{0} must be a folder"
142138
const MSG_PACKAGE_UNKNOWN = "{0}: Unknown package"
143139
const MSG_PATTERN_MISSING = "{0} pattern is missing"
144140
const MSG_PLATFORM_UNKNOWN = "Platform {0} (package {1}) is unknown"
@@ -155,10 +151,6 @@ const MSG_SIZER_DATA_TOO_BIG = "Not enough memory; see http://www.arduino.cc/en/
155151
const MSG_SIZER_LOW_MEMORY = "Low memory available, stability problems may occur."
156152
const MSG_SIZER_ERROR_NO_RULE = "Couldn't determine program size"
157153
const MSG_SKETCH_CANT_BE_IN_BUILDPATH = "Sketch cannot be located in build path. Please specify a different build path"
158-
const MSG_SKIPPING_TAG_ALREADY_DEFINED = "Skipping tag {0} because prototype is already defined"
159-
const MSG_SKIPPING_TAG_BECAUSE_HAS_FIELD = "Skipping tag {0} because it has field {0}"
160-
const MSG_SKIPPING_TAG_WITH_REASON = "Skipping tag {0}. Reason: {1}"
161-
const MSG_UNHANDLED_TYPE_IN_CONTEXT = "Unhandled type {0} in context key {1}"
162154
const MSG_UNKNOWN_SKETCH_EXT = "Unknown sketch file extension: {0}"
163155
const MSG_USING_LIBRARY_AT_VERSION = "Using library {0} at version {1} in folder: {2} {3}"
164156
const MSG_USING_LIBRARY = "Using library {0} in folder: {1} {2}"
@@ -167,30 +159,24 @@ const MSG_USING_CORE = "Using core '{0}' from platform in folder: {1}"
167159
const MSG_USING_PREVIOUS_COMPILED_FILE = "Using previously compiled file: {0}"
168160
const MSG_USING_CACHED_INCLUDES = "Using cached library dependencies for file: {0}"
169161
const MSG_WARNING_LIB_INVALID_CATEGORY = "WARNING: Category '{0}' in library {1} is not valid. Setting to '{2}'"
170-
const MSG_WARNING_PLATFORM_MISSING_VALUE = "Warning: platform.txt from core '{0}' misses property '{1}', using default value '{2}'. Consider upgrading this core."
171162
const MSG_WARNING_PLATFORM_OLD_VALUES = "Warning: platform.txt from core '{0}' contains deprecated {1}, automatically converted to {2}. Consider upgrading this core."
172163
const MSG_WARNING_SPURIOUS_FILE_IN_LIB = "WARNING: Spurious {0} folder in '{1}' library"
173-
const MSG_WRONG_PROPERTIES_FILE = "Property line '{0}' in file {1} is invalid"
174-
const MSG_WRONG_PROPERTIES = "Property line '{0}' is invalid"
175164
const PACKAGE_NAME = "name"
176165
const PACKAGE_TOOLS = "tools"
177166
const PLATFORM_ARCHITECTURE = "architecture"
178167
const PLATFORM_NAME = "name"
179-
const PLATFORM_REWRITE_ADDED = "added"
180168
const PLATFORM_REWRITE_NEW = "new"
181169
const PLATFORM_REWRITE_OLD = "old"
182170
const PLATFORM_URL = "url"
183171
const PLATFORM_VERSION = "version"
184172
const PROPERTY_WARN_DATA_PERCENT = "build.warn_data_percentage"
185173
const PROPERTY_UPLOAD_MAX_SIZE = "upload.maximum_size"
186174
const PROPERTY_UPLOAD_MAX_DATA_SIZE = "upload.maximum_data_size"
187-
const PROGRAMMER_NAME = "name"
188175
const RECIPE_AR_PATTERN = "recipe.ar.pattern"
189176
const RECIPE_C_COMBINE_PATTERN = "recipe.c.combine.pattern"
190177
const RECIPE_C_PATTERN = "recipe.c.o.pattern"
191178
const RECIPE_CPP_PATTERN = "recipe.cpp.o.pattern"
192179
const RECIPE_SIZE_PATTERN = "recipe.size.pattern"
193-
const RECIPE_PREPROC_INCLUDES = "recipe.preproc.includes"
194180
const RECIPE_PREPROC_MACROS = "recipe.preproc.macros"
195181
const RECIPE_S_PATTERN = "recipe.S.o.pattern"
196182
const RECIPE_SIZE_REGEXP = "recipe.size.regex"

gcc_preproc_runner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (s *GCCPreprocRunnerForDiscoveringIncludes) Run(ctx *types.Context) error {
9090
properties[constants.RECIPE_PREPROC_MACROS] = GeneratePreprocPatternFromCompile(properties[constants.RECIPE_CPP_PATTERN])
9191
}
9292

93-
stderr, err := builder_utils.ExecRecipeCollectStdErr(properties, constants.RECIPE_PREPROC_MACROS, true, verbose, false, logger)
93+
stderr, err := builder_utils.ExecRecipeCollectStdErr(properties, constants.RECIPE_PREPROC_MACROS, true, verbose, logger)
9494
if err != nil {
9595
return i18n.WrapError(err)
9696
}

gcc_preproc_source_saver.go

-53
This file was deleted.

print_used_libraries_if_verbose.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
package builder
3131

3232
import (
33+
"time"
34+
3335
"github.com/arduino/arduino-builder/constants"
3436
"github.com/arduino/arduino-builder/types"
35-
"time"
3637
)
3738

3839
type PrintUsedLibrariesIfVerbose struct{}

resolve_library.go

-23
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,6 @@ func filterOutLibraryFrom(libraries []*types.Library, libraryToRemove *types.Lib
130130
return filteredOutLibraries
131131
}
132132

133-
func findLibraryIn(libraries []*types.Library, library *types.Library) *types.Library {
134-
for _, lib := range libraries {
135-
if lib == library {
136-
return lib
137-
}
138-
}
139-
return nil
140-
}
141-
142133
func libraryCompatibleWithPlatform(library *types.Library, platform *cores.PlatformRelease) (bool, bool) {
143134
if len(library.Archs) == 0 {
144135
return true, true
@@ -173,20 +164,6 @@ func librariesCompatibleWithPlatform(libraries []*types.Library, platform *cores
173164
return compatibleLibraries
174165
}
175166

176-
func librariesWithinPlatform(libraries []*types.Library, platform *cores.PlatformRelease) []*types.Library {
177-
librariesWithinSpecifiedPlatform := []*types.Library{}
178-
for _, library := range libraries {
179-
cleanPlatformFolder := filepath.Clean(platform.Folder)
180-
cleanLibraryFolder := filepath.Clean(library.SrcFolder)
181-
if strings.Contains(cleanLibraryFolder, cleanPlatformFolder) {
182-
librariesWithinSpecifiedPlatform = append(librariesWithinSpecifiedPlatform, library)
183-
}
184-
}
185-
186-
return librariesWithinSpecifiedPlatform
187-
188-
}
189-
190167
func findBestLibraryWithHeader(header string, libraries []*types.Library) *types.Library {
191168
headerName := strings.Replace(header, filepath.Ext(header), constants.EMPTY_STRING, -1)
192169

types/context.go

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ type Context struct {
6969
LibrariesResolutionResults map[string]LibraryResolutionResult
7070
IncludeJustFound string
7171
IncludeFolders []string
72-
OutputGccMinusM string
7372

7473
// C++ Parsing
7574
CTagsOutput string

types/types.go

-6
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,6 @@ type PlatforKeyRewrite struct {
185185
NewValue string
186186
}
187187

188-
type KeyValuePair struct {
189-
Key string
190-
Value string
191-
}
192-
193188
type Prototype struct {
194189
FunctionName string
195190
File string
@@ -226,7 +221,6 @@ type CTag struct {
226221
Signature string
227222

228223
Prototype string
229-
Function string
230224
PrototypeModifiers string
231225
}
232226

utils/utils.go

-51
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ import (
4646
"github.com/arduino/arduino-builder/types"
4747
)
4848

49-
func KeysOfMapOfStringInterface(input map[string]interface{}) []string {
50-
var keys []string
51-
for key, _ := range input {
52-
keys = append(keys, key)
53-
}
54-
return keys
55-
}
56-
5749
func KeysOfMapOfString(input map[string]string) []string {
5850
var keys []string
5951
for key, _ := range input {
@@ -254,24 +246,11 @@ func PrepareCommand(pattern string, logger i18n.Logger) (*exec.Cmd, error) {
254246
return PrepareCommandFilteredArgs(pattern, filterEmptyArg, logger)
255247
}
256248

257-
func MapHas(aMap map[string]interface{}, key string) bool {
258-
_, ok := aMap[key]
259-
return ok
260-
}
261-
262249
func MapStringStringHas(aMap map[string]string, key string) bool {
263250
_, ok := aMap[key]
264251
return ok
265252
}
266253

267-
func SliceToMapStringBool(keys []string, value bool) map[string]bool {
268-
aMap := make(map[string]bool)
269-
for _, key := range keys {
270-
aMap[key] = value
271-
}
272-
return aMap
273-
}
274-
275254
func AbsolutizePaths(files []string) ([]string, error) {
276255
for idx, file := range files {
277256
absFile, err := filepath.Abs(file)
@@ -295,32 +274,6 @@ func ReadFileToRows(file string) ([]string, error) {
295274
return strings.Split(txt, "\n"), nil
296275
}
297276

298-
func TheOnlySubfolderOf(folder string) (string, error) {
299-
subfolders, err := ReadDirFiltered(folder, FilterDirs)
300-
if err != nil {
301-
return constants.EMPTY_STRING, i18n.WrapError(err)
302-
}
303-
304-
if len(subfolders) != 1 {
305-
return constants.EMPTY_STRING, nil
306-
}
307-
308-
return subfolders[0].Name(), nil
309-
}
310-
311-
func FilterOutFoldersByNames(folders []os.FileInfo, names ...string) []os.FileInfo {
312-
filterNames := SliceToMapStringBool(names, true)
313-
314-
var filtered []os.FileInfo
315-
for _, folder := range folders {
316-
if !filterNames[folder.Name()] {
317-
filtered = append(filtered, folder)
318-
}
319-
}
320-
321-
return filtered
322-
}
323-
324277
type CheckExtensionFunc func(ext string) bool
325278

326279
func FindFilesInFolder(files *[]string, folder string, extensions CheckExtensionFunc, recurse bool) error {
@@ -430,10 +383,6 @@ func LogIfVerbose(level string, format string, args ...interface{}) types.Comman
430383
return &loggerAction{true, level, format, args}
431384
}
432385

433-
func LogThis(level string, format string, args ...interface{}) types.Command {
434-
return &loggerAction{false, level, format, args}
435-
}
436-
437386
// Returns the given string as a quoted string for use with the C
438387
// preprocessor. This adds double quotes around it and escapes any
439388
// double quotes and backslashes in the string.

0 commit comments

Comments
 (0)