Skip to content

Commit 48c0180

Browse files
committed
Migrated verbosity parameters into Context
Signed-off-by: Cristian Maglie <[email protected]>
1 parent 559454c commit 48c0180

26 files changed

+63
-109
lines changed

src/arduino.cc/builder/add_additional_entries_to_context.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ func (s *AddAdditionalEntriesToContext) Run(context map[string]interface{}, ctx
6969
context[constants.CTX_WARNINGS_LEVEL] = DEFAULT_WARNINGS_LEVEL
7070
}
7171

72-
if !utils.MapHas(context, constants.CTX_VERBOSE) {
73-
context[constants.CTX_VERBOSE] = false
74-
}
75-
7672
sourceFiles := &types.UniqueStringQueue{}
7773
context[constants.CTX_COLLECTED_SOURCE_FILES_QUEUE] = sourceFiles
7874
foldersWithSources := &types.UniqueSourceFolderQueue{}

src/arduino.cc/builder/coan_runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type CoanRunner struct{}
4747
func (s *CoanRunner) Run(context map[string]interface{}, ctx *types.Context) error {
4848
source := context[constants.CTX_SOURCE].(string)
4949
source += "\n"
50-
verbose := context[constants.CTX_VERBOSE].(bool)
50+
verbose := ctx.Verbose
5151

5252
preprocPath := context[constants.CTX_PREPROC_PATH].(string)
5353
err := utils.EnsureFolderExists(preprocPath)

src/arduino.cc/builder/constants/constants.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ const CTX_CTAGS_OF_PREPROC_SOURCE = "ctagsOfPreprocSource"
8989
const CTX_CTAGS_OF_SOURCE = "ctagsOfSource"
9090
const CTX_CTAGS_OUTPUT = "ctagsOutput"
9191
const CTX_CTAGS_TEMP_FILE_PATH = "ctagsTempFilePath"
92-
const CTX_DEBUG_PREPROCESSOR = "debugPreprocessor"
9392
const CTX_FILE_PATH_TO_READ = "filePathToRead"
9493
const CTX_FOLDERS_WITH_SOURCES_QUEUE = "foldersWithSourcesQueue"
9594
const CTX_GCC_MINUS_E_SOURCE = "gccMinusESource"
@@ -121,7 +120,6 @@ const CTX_TARGET_BOARD = "targetBoard"
121120
const CTX_TARGET_PACKAGE = "targetPackage"
122121
const CTX_TARGET_PLATFORM = "targetPlatform"
123122
const CTX_TOOLS = "tools"
124-
const CTX_VERBOSE = "verbose"
125123
const CTX_VIDPID = "VIDPID"
126124
const CTX_WARNINGS_LEVEL = "warningLevel"
127125
const EMPTY_STRING = ""

src/arduino.cc/builder/ctags/ctags_runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (s *CTagsRunner) Run(context map[string]interface{}, ctx *types.Context) er
6060
return i18n.WrapError(err)
6161
}
6262

63-
verbose := context[constants.CTX_VERBOSE].(bool)
63+
verbose := ctx.Verbose
6464
if verbose {
6565
fmt.Println(commandLine)
6666
}

src/arduino.cc/builder/gcc_preproc_runner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (s *GCCPreprocRunner) Run(context map[string]interface{}, ctx *types.Contex
5757
properties[constants.RECIPE_PREPROC_MACROS] = GeneratePreprocPatternFromCompile(properties[constants.RECIPE_CPP_PATTERN])
5858
}
5959

60-
verbose := context[constants.CTX_VERBOSE].(bool)
60+
verbose := ctx.Verbose
6161
logger := ctx.GetLogger()
6262
_, err = builder_utils.ExecRecipe(properties, constants.RECIPE_PREPROC_MACROS, true, verbose, false, logger)
6363
if err != nil {
@@ -80,7 +80,7 @@ func (s *GCCPreprocRunnerForDiscoveringIncludes) Run(context map[string]interfac
8080
return i18n.WrapError(err)
8181
}
8282

83-
verbose := context[constants.CTX_VERBOSE].(bool)
83+
verbose := ctx.Verbose
8484
logger := ctx.GetLogger()
8585

8686
if properties[constants.RECIPE_PREPROC_MACROS] == constants.EMPTY_STRING {

src/arduino.cc/builder/includes_finder_with_gcc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (s *IncludesFinderWithGCC) Run(context map[string]interface{}, ctx *types.C
4848
if p, ok := context[constants.CTX_BUILD_PROPERTIES]; ok {
4949
buildProperties = p.(props.PropertiesMap).Clone()
5050
}
51-
verbose := context[constants.CTX_VERBOSE].(bool)
51+
verbose := ctx.Verbose
5252
logger := ctx.GetLogger()
5353

5454
includesParams := constants.EMPTY_STRING

src/arduino.cc/builder/includes_to_include_folders.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (s *IncludesToIncludeFolders) Run(context map[string]interface{}, ctx *type
7979
context[constants.CTX_IMPORTED_LIBRARIES] = importedLibraries
8080

8181
buildProperties := context[constants.CTX_BUILD_PROPERTIES].(props.PropertiesMap)
82-
verbose := context[constants.CTX_VERBOSE].(bool)
82+
verbose := ctx.Verbose
8383
includeFolders := resolveIncludeFolders(newlyImportedLibraries, buildProperties, verbose)
8484
context[constants.CTX_INCLUDE_FOLDERS] = includeFolders
8585

src/arduino.cc/builder/phases/core_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type CoreBuilder struct{}
4343
func (s *CoreBuilder) Run(context map[string]interface{}, ctx *types.Context) error {
4444
coreBuildPath := context[constants.CTX_CORE_BUILD_PATH].(string)
4545
buildProperties := context[constants.CTX_BUILD_PROPERTIES].(props.PropertiesMap)
46-
verbose := context[constants.CTX_VERBOSE].(bool)
46+
verbose := ctx.Verbose
4747
warningsLevel := context[constants.CTX_WARNINGS_LEVEL].(string)
4848
logger := ctx.GetLogger()
4949

src/arduino.cc/builder/phases/libraries_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (s *LibrariesBuilder) Run(context map[string]interface{}, ctx *types.Contex
4848
includes := context[constants.CTX_INCLUDE_FOLDERS].([]string)
4949
includes = utils.Map(includes, utils.WrapWithHyphenI)
5050
libraries := context[constants.CTX_IMPORTED_LIBRARIES].([]*types.Library)
51-
verbose := context[constants.CTX_VERBOSE].(bool)
51+
verbose := ctx.Verbose
5252
warningsLevel := context[constants.CTX_WARNINGS_LEVEL].(string)
5353
logger := ctx.GetLogger()
5454

src/arduino.cc/builder/phases/linker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (s *Linker) Run(context map[string]interface{}, ctx *types.Context) error {
6060
}
6161

6262
buildProperties := context[constants.CTX_BUILD_PROPERTIES].(props.PropertiesMap)
63-
verbose := context[constants.CTX_VERBOSE].(bool)
63+
verbose := ctx.Verbose
6464
warningsLevel := context[constants.CTX_WARNINGS_LEVEL].(string)
6565
logger := ctx.GetLogger()
6666

src/arduino.cc/builder/phases/sketch_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (s *SketchBuilder) Run(context map[string]interface{}, ctx *types.Context)
4545
buildProperties := context[constants.CTX_BUILD_PROPERTIES].(props.PropertiesMap)
4646
includes := context[constants.CTX_INCLUDE_FOLDERS].([]string)
4747
includes = utils.Map(includes, utils.WrapWithHyphenI)
48-
verbose := context[constants.CTX_VERBOSE].(bool)
48+
verbose := ctx.Verbose
4949
warningsLevel := context[constants.CTX_WARNINGS_LEVEL].(string)
5050
logger := ctx.GetLogger()
5151

src/arduino.cc/builder/print_used_libraries_if_verbose.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
type PrintUsedLibrariesIfVerbose struct{}
4040

4141
func (s *PrintUsedLibrariesIfVerbose) Run(context map[string]interface{}, ctx *types.Context) error {
42-
verbose := context[constants.CTX_VERBOSE].(bool)
42+
verbose := ctx.Verbose
4343
logger := ctx.GetLogger()
4444

4545
if !verbose || !utils.MapHas(context, constants.CTX_IMPORTED_LIBRARIES) {

src/arduino.cc/builder/prototypes_adder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import (
4141
type PrototypesAdder struct{}
4242

4343
func (s *PrototypesAdder) Run(context map[string]interface{}, ctx *types.Context) error {
44-
debugOutput := context[constants.CTX_DEBUG_PREPROCESSOR] != nil
44+
debugOutput := ctx.DebugPreprocessor
4545
source := context[constants.CTX_SOURCE].(string)
4646

4747
source = strings.Replace(source, "\r\n", "\n", -1)

src/arduino.cc/builder/recipe_runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (s *RecipeByPrefixSuffixRunner) Run(context map[string]interface{}, ctx *ty
5555
if p, ok := context[constants.CTX_BUILD_PROPERTIES]; ok {
5656
buildProperties = p.(props.PropertiesMap).Clone()
5757
}
58-
verbose := context[constants.CTX_VERBOSE].(bool)
58+
verbose := ctx.Verbose
5959

6060
recipes := findRecipes(buildProperties, s.Prefix, s.Suffix)
6161

src/arduino.cc/builder/test/add_additional_entries_to_context_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ func TestAddAdditionalEntriesToContextNoBuildPath(t *testing.T) {
5151
require.Nil(t, context[constants.CTX_CORE_BUILD_PATH])
5252

5353
require.NotNil(t, context[constants.CTX_WARNINGS_LEVEL])
54-
require.NotNil(t, context[constants.CTX_VERBOSE])
5554

5655
require.True(t, context[constants.CTX_COLLECTED_SOURCE_FILES_QUEUE].(*types.UniqueStringQueue).Empty())
5756
require.True(t, context[constants.CTX_FOLDERS_WITH_SOURCES_QUEUE].(*types.UniqueSourceFolderQueue).Empty())
@@ -74,7 +73,6 @@ func TestAddAdditionalEntriesToContextWithBuildPath(t *testing.T) {
7473
require.Equal(t, Abs(t, filepath.Join("folder", constants.FOLDER_CORE)), context[constants.CTX_CORE_BUILD_PATH])
7574

7675
require.NotNil(t, context[constants.CTX_WARNINGS_LEVEL])
77-
require.NotNil(t, context[constants.CTX_VERBOSE])
7876

7977
require.True(t, context[constants.CTX_COLLECTED_SOURCE_FILES_QUEUE].(*types.UniqueStringQueue).Empty())
8078
require.True(t, context[constants.CTX_FOLDERS_WITH_SOURCES_QUEUE].(*types.UniqueSourceFolderQueue).Empty())

src/arduino.cc/builder/test/builder_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ func TestBuilderEmptySketch(t *testing.T) {
5252
SketchLocation: filepath.Join("sketch1", "sketch.ino"),
5353
FQBN: "arduino:avr:uno",
5454
ArduinoAPIVersion: "10600",
55+
Verbose: true,
5556
}
5657

5758
buildPath := SetupBuildPath(t, context)
5859
defer os.RemoveAll(buildPath)
5960

60-
context[constants.CTX_VERBOSE] = true
6161
ctx.DebugLevel = 10
6262

6363
command := builder.Builder{}
@@ -88,13 +88,12 @@ func TestBuilderBridge(t *testing.T) {
8888
SketchLocation: filepath.Join("downloaded_libraries", "Bridge", "examples", "Bridge", "Bridge.ino"),
8989
FQBN: "arduino:avr:leonardo",
9090
ArduinoAPIVersion: "10600",
91+
Verbose: true,
9192
}
9293

9394
buildPath := SetupBuildPath(t, context)
9495
defer os.RemoveAll(buildPath)
9596

96-
context[constants.CTX_VERBOSE] = true
97-
9897
command := builder.Builder{}
9998
err := command.Run(context, ctx)
10099
NoError(t, err)

src/arduino.cc/builder/test/coan_runner_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ func TestCoanRunner(t *testing.T) {
5151
SketchLocation: filepath.Join("sketch2", "SketchWithIfDef.ino"),
5252
FQBN: "arduino:avr:leonardo",
5353
ArduinoAPIVersion: "10600",
54+
Verbose: true,
5455
}
5556

5657
buildPath := SetupBuildPath(t, context)
5758
defer os.RemoveAll(buildPath)
5859

59-
context[constants.CTX_VERBOSE] = true
60-
6160
commands := []types.Command{
6261
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
6362
&builder.SketchSourceMerger{},

src/arduino.cc/builder/test/create_build_options_map_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ func TestCreateBuildOptionsMap(t *testing.T) {
4848
SketchLocation: "sketchLocation",
4949
FQBN: "fqbn",
5050
ArduinoAPIVersion: "ideVersion",
51+
Verbose: true,
5152
}
5253

5354
context[constants.CTX_BUILD_PATH] = "buildPath"
54-
context[constants.CTX_VERBOSE] = true
5555
ctx.DebugLevel = 5
5656

5757
create := builder.CreateBuildOptionsMap{}

src/arduino.cc/builder/test/ctags_runner_test.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,12 @@ func TestCTagsRunner(t *testing.T) {
5555
SketchLocation: sketchLocation,
5656
FQBN: "arduino:avr:leonardo",
5757
ArduinoAPIVersion: "10600",
58+
Verbose: true,
5859
}
5960

6061
buildPath := SetupBuildPath(t, context)
6162
defer os.RemoveAll(buildPath)
6263

63-
context[constants.CTX_VERBOSE] = true
64-
6564
commands := []types.Command{
6665

6766
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
@@ -107,13 +106,12 @@ func TestCTagsRunnerSketchWithClass(t *testing.T) {
107106
SketchLocation: sketchLocation,
108107
FQBN: "arduino:avr:leonardo",
109108
ArduinoAPIVersion: "10600",
109+
Verbose: true,
110110
}
111111

112112
buildPath := SetupBuildPath(t, context)
113113
defer os.RemoveAll(buildPath)
114114

115-
context[constants.CTX_VERBOSE] = true
116-
117115
commands := []types.Command{
118116

119117
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
@@ -157,13 +155,12 @@ func TestCTagsRunnerSketchWithTypename(t *testing.T) {
157155
SketchLocation: sketchLocation,
158156
FQBN: "arduino:avr:leonardo",
159157
ArduinoAPIVersion: "10600",
158+
Verbose: true,
160159
}
161160

162161
buildPath := SetupBuildPath(t, context)
163162
defer os.RemoveAll(buildPath)
164163

165-
context[constants.CTX_VERBOSE] = true
166-
167164
commands := []types.Command{
168165

169166
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
@@ -206,13 +203,12 @@ func TestCTagsRunnerSketchWithNamespace(t *testing.T) {
206203
SketchLocation: sketchLocation,
207204
FQBN: "arduino:avr:leonardo",
208205
ArduinoAPIVersion: "10600",
206+
Verbose: true,
209207
}
210208

211209
buildPath := SetupBuildPath(t, context)
212210
defer os.RemoveAll(buildPath)
213211

214-
context[constants.CTX_VERBOSE] = true
215-
216212
commands := []types.Command{
217213

218214
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
@@ -254,13 +250,12 @@ func TestCTagsRunnerSketchWithTemplates(t *testing.T) {
254250
SketchLocation: sketchLocation,
255251
FQBN: "arduino:avr:leonardo",
256252
ArduinoAPIVersion: "10600",
253+
Verbose: true,
257254
}
258255

259256
buildPath := SetupBuildPath(t, context)
260257
defer os.RemoveAll(buildPath)
261258

262-
context[constants.CTX_VERBOSE] = true
263-
264259
commands := []types.Command{
265260

266261
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},

src/arduino.cc/builder/test/includes_finder_with_gcc_test.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ func TestIncludesFinderWithGCC(t *testing.T) {
5151
SketchLocation: filepath.Join("sketch2", "SketchWithIfDef.ino"),
5252
FQBN: "arduino:avr:leonardo",
5353
ArduinoAPIVersion: "10600",
54+
Verbose: true,
5455
}
5556

5657
buildPath := SetupBuildPath(t, context)
5758
defer os.RemoveAll(buildPath)
5859

59-
context[constants.CTX_VERBOSE] = true
60-
6160
commands := []types.Command{
6261

6362
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
@@ -87,13 +86,12 @@ func TestIncludesFinderWithGCCSketchWithConfig(t *testing.T) {
8786
SketchLocation: filepath.Join("sketch_with_config", "sketch_with_config.ino"),
8887
FQBN: "arduino:avr:leonardo",
8988
ArduinoAPIVersion: "10600",
89+
Verbose: true,
9090
}
9191

9292
buildPath := SetupBuildPath(t, context)
9393
defer os.RemoveAll(buildPath)
9494

95-
context[constants.CTX_VERBOSE] = true
96-
9795
commands := []types.Command{
9896

9997
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
@@ -129,13 +127,12 @@ func TestIncludesFinderWithGCCSketchWithDependendLibraries(t *testing.T) {
129127
SketchLocation: filepath.Join("sketch_with_dependend_libraries", "sketch.ino"),
130128
FQBN: "arduino:avr:leonardo",
131129
ArduinoAPIVersion: "10600",
130+
Verbose: true,
132131
}
133132

134133
buildPath := SetupBuildPath(t, context)
135134
defer os.RemoveAll(buildPath)
136135

137-
context[constants.CTX_VERBOSE] = true
138-
139136
commands := []types.Command{
140137

141138
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
@@ -182,13 +179,12 @@ func TestIncludesFinderWithGCCSketchWithThatChecksIfSPIHasTransactions(t *testin
182179
SketchLocation: filepath.Join("sketch_that_checks_if_SPI_has_transactions", "sketch.ino"),
183180
FQBN: "arduino:avr:leonardo",
184181
ArduinoAPIVersion: "10600",
182+
Verbose: true,
185183
}
186184

187185
buildPath := SetupBuildPath(t, context)
188186
defer os.RemoveAll(buildPath)
189187

190-
context[constants.CTX_VERBOSE] = true
191-
192188
commands := []types.Command{
193189

194190
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
@@ -225,13 +221,12 @@ func TestIncludesFinderWithGCCSketchWithThatChecksIfSPIHasTransactionsAndInclude
225221
SketchLocation: filepath.Join("sketch_that_checks_if_SPI_has_transactions_and_includes_missing_Ethernet", "sketch.ino"),
226222
FQBN: "arduino:avr:leonardo",
227223
ArduinoAPIVersion: "10600",
224+
Verbose: true,
228225
}
229226

230227
buildPath := SetupBuildPath(t, context)
231228
defer os.RemoveAll(buildPath)
232229

233-
context[constants.CTX_VERBOSE] = true
234-
235230
commands := []types.Command{
236231

237232
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},

src/arduino.cc/builder/test/includes_finder_with_regexp_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@ func TestIncludesFinderWithRegExpCoanOutput(t *testing.T) {
5050
SketchLocation: filepath.Join("sketch2", "SketchWithIfDef.ino"),
5151
FQBN: "arduino:avr:leonardo",
5252
ArduinoAPIVersion: "10600",
53+
Verbose: true,
5354
}
5455

5556
buildPath := SetupBuildPath(t, context)
5657
defer os.RemoveAll(buildPath)
5758

58-
context[constants.CTX_VERBOSE] = true
59-
6059
commands := []types.Command{
6160

6261
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},

0 commit comments

Comments
 (0)