Skip to content

Commit da86fe8

Browse files
committed
Introducing types.Context structure
For now it is used in conjunction with the old map[string]string, but it will be slowly populated with all the fields currently used in the map in the next commits. When the migration will be completed the old map will be removed. Signed-off-by: Cristian Maglie <[email protected]>
1 parent 80849e7 commit da86fe8

File tree

94 files changed

+453
-264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+453
-264
lines changed

src/arduino.cc/builder/add_additional_entries_to_context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838

3939
type AddAdditionalEntriesToContext struct{}
4040

41-
func (s *AddAdditionalEntriesToContext) Run(context map[string]interface{}) error {
41+
func (s *AddAdditionalEntriesToContext) Run(context map[string]interface{}, ctx *types.Context) error {
4242
if utils.MapHas(context, constants.CTX_BUILD_PATH) {
4343
buildPath := context[constants.CTX_BUILD_PATH].(string)
4444
preprocPath, err := filepath.Abs(filepath.Join(buildPath, constants.FOLDER_PREPROC))

src/arduino.cc/builder/add_build_board_property_if_missing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939

4040
type AddBuildBoardPropertyIfMissing struct{}
4141

42-
func (s *AddBuildBoardPropertyIfMissing) Run(context map[string]interface{}) error {
42+
func (s *AddBuildBoardPropertyIfMissing) Run(context map[string]interface{}, ctx *types.Context) error {
4343
packages := context[constants.CTX_HARDWARE].(*types.Packages)
4444
logger := context[constants.CTX_LOGGER].(i18n.Logger)
4545

src/arduino.cc/builder/add_missing_build_properties_from_parent_platform_txt_files.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737

3838
type AddMissingBuildPropertiesFromParentPlatformTxtFiles struct{}
3939

40-
func (s *AddMissingBuildPropertiesFromParentPlatformTxtFiles) Run(context map[string]interface{}) error {
40+
func (s *AddMissingBuildPropertiesFromParentPlatformTxtFiles) Run(context map[string]interface{}, ctx *types.Context) error {
4141
packages := context[constants.CTX_HARDWARE].(*types.Packages)
4242
targetPackage := context[constants.CTX_TARGET_PACKAGE].(*types.Package)
4343
buildProperties := context[constants.CTX_BUILD_PROPERTIES].(props.PropertiesMap)

src/arduino.cc/builder/additional_sketch_files_copier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import (
4040

4141
type AdditionalSketchFilesCopier struct{}
4242

43-
func (s *AdditionalSketchFilesCopier) Run(context map[string]interface{}) error {
43+
func (s *AdditionalSketchFilesCopier) Run(context map[string]interface{}, ctx *types.Context) error {
4444
sketch := context[constants.CTX_SKETCH].(*types.Sketch)
4545
sketchBuildPath := context[constants.CTX_SKETCH_BUILD_PATH].(string)
4646

src/arduino.cc/builder/builder.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const DEFAULT_BUILD_CORE = "arduino"
6666

6767
type Builder struct{}
6868

69-
func (s *Builder) Run(context map[string]interface{}) error {
69+
func (s *Builder) Run(context map[string]interface{}, ctx *types.Context) error {
7070
commands := []types.Command{
7171
&SetupHumanLoggerIfMissing{},
7272

@@ -115,14 +115,14 @@ func (s *Builder) Run(context map[string]interface{}) error {
115115
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_POSTBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
116116
}
117117

118-
mainErr := runCommands(context, commands, true)
118+
mainErr := runCommands(context, ctx, commands, true)
119119

120120
commands = []types.Command{
121121
&PrintUsedAndNotUsedLibraries{},
122122

123123
&PrintUsedLibrariesIfVerbose{},
124124
}
125-
otherErr := runCommands(context, commands, false)
125+
otherErr := runCommands(context, ctx, commands, false)
126126

127127
if mainErr != nil {
128128
return mainErr
@@ -133,7 +133,7 @@ func (s *Builder) Run(context map[string]interface{}) error {
133133

134134
type Preprocess struct{}
135135

136-
func (s *Preprocess) Run(context map[string]interface{}) error {
136+
func (s *Preprocess) Run(context map[string]interface{}, ctx *types.Context) error {
137137
commands := []types.Command{
138138
&SetupHumanLoggerIfMissing{},
139139

@@ -157,12 +157,12 @@ func (s *Preprocess) Run(context map[string]interface{}) error {
157157
&PrintPreprocessedSource{},
158158
}
159159

160-
return runCommands(context, commands, true)
160+
return runCommands(context, ctx, commands, true)
161161
}
162162

163163
type ParseHardwareAndDumpBuildProperties struct{}
164164

165-
func (s *ParseHardwareAndDumpBuildProperties) Run(context map[string]interface{}) error {
165+
func (s *ParseHardwareAndDumpBuildProperties) Run(context map[string]interface{}, ctx *types.Context) error {
166166
commands := []types.Command{
167167
&SetupHumanLoggerIfMissing{},
168168

@@ -173,18 +173,18 @@ func (s *ParseHardwareAndDumpBuildProperties) Run(context map[string]interface{}
173173
&DumpBuildProperties{},
174174
}
175175

176-
return runCommands(context, commands, true)
176+
return runCommands(context, ctx, commands, true)
177177
}
178178

179-
func runCommands(context map[string]interface{}, commands []types.Command, progressEnabled bool) error {
179+
func runCommands(context map[string]interface{}, ctx *types.Context, commands []types.Command, progressEnabled bool) error {
180180
commandsLength := len(commands)
181181
progressForEachCommand := float32(100) / float32(commandsLength)
182182

183183
progress := float32(0)
184184
for _, command := range commands {
185185
PrintRingNameIfDebug(context, command)
186186
printProgressIfProgressEnabledAndMachineLogger(progressEnabled, context, progress)
187-
err := command.Run(context)
187+
err := command.Run(context, ctx)
188188
if err != nil {
189189
return utils.WrapError(err)
190190
}
@@ -213,17 +213,17 @@ func PrintRingNameIfDebug(context map[string]interface{}, command types.Command)
213213
}
214214
}
215215

216-
func RunBuilder(context map[string]interface{}) error {
216+
func RunBuilder(context map[string]interface{}, ctx *types.Context) error {
217217
command := Builder{}
218-
return command.Run(context)
218+
return command.Run(context, ctx)
219219
}
220220

221-
func RunParseHardwareAndDumpBuildProperties(context map[string]interface{}) error {
221+
func RunParseHardwareAndDumpBuildProperties(context map[string]interface{}, ctx *types.Context) error {
222222
command := ParseHardwareAndDumpBuildProperties{}
223-
return command.Run(context)
223+
return command.Run(context, ctx)
224224
}
225225

226-
func RunPreprocess(context map[string]interface{}) error {
226+
func RunPreprocess(context map[string]interface{}, ctx *types.Context) error {
227227
command := Preprocess{}
228-
return command.Run(context)
228+
return command.Run(context, ctx)
229229
}

src/arduino.cc/builder/coan_runner.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"arduino.cc/builder/constants"
3434
"arduino.cc/builder/i18n"
3535
"arduino.cc/builder/props"
36+
"arduino.cc/builder/types"
3637
"arduino.cc/builder/utils"
3738
"fmt"
3839
"path/filepath"
@@ -43,7 +44,7 @@ var ALLOWED_ARG = regexp.MustCompile("^source$|\\-E$|\\-m$|\\-P$|\\-kb$|\\-D.*")
4344

4445
type CoanRunner struct{}
4546

46-
func (s *CoanRunner) Run(context map[string]interface{}) error {
47+
func (s *CoanRunner) Run(context map[string]interface{}, ctx *types.Context) error {
4748
source := context[constants.CTX_SOURCE].(string)
4849
source += "\n"
4950
verbose := context[constants.CTX_VERBOSE].(bool)

src/arduino.cc/builder/collect_all_source_files_from_folders_with_sources.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import (
4242

4343
type CollectAllSourceFilesFromFoldersWithSources struct{}
4444

45-
func (s *CollectAllSourceFilesFromFoldersWithSources) Run(context map[string]interface{}) error {
45+
func (s *CollectAllSourceFilesFromFoldersWithSources) Run(context map[string]interface{}, ctx *types.Context) error {
4646
foldersWithSources := context[constants.CTX_FOLDERS_WITH_SOURCES_QUEUE].(*types.UniqueSourceFolderQueue)
4747
sourceFiles := context[constants.CTX_COLLECTED_SOURCE_FILES_QUEUE].(*types.UniqueStringQueue)
4848

src/arduino.cc/builder/collect_ctags_from_sketch_files.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838

3939
type CollectCTagsFromSketchFiles struct{}
4040

41-
func (s *CollectCTagsFromSketchFiles) Run(context map[string]interface{}) error {
41+
func (s *CollectCTagsFromSketchFiles) Run(context map[string]interface{}, ctx *types.Context) error {
4242
sketch := context[constants.CTX_SKETCH].(*types.Sketch)
4343
sketchFileNames := collectSketchFileNamesFrom(sketch)
4444

src/arduino.cc/builder/container_add_prototypes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838

3939
type ContainerAddPrototypes struct{}
4040

41-
func (s *ContainerAddPrototypes) Run(context map[string]interface{}) error {
41+
func (s *ContainerAddPrototypes) Run(context map[string]interface{}, ctx *types.Context) error {
4242
commands := []types.Command{
4343
&GCCPreprocRunner{TargetFileName: constants.FILE_CTAGS_TARGET_FOR_GCC_MINUS_E},
4444
&ReadFileAndStoreInContext{TargetField: constants.CTX_GCC_MINUS_E_SOURCE},
@@ -53,7 +53,7 @@ func (s *ContainerAddPrototypes) Run(context map[string]interface{}) error {
5353

5454
for _, command := range commands {
5555
PrintRingNameIfDebug(context, command)
56-
err := command.Run(context)
56+
err := command.Run(context, ctx)
5757
if err != nil {
5858
return utils.WrapError(err)
5959
}

src/arduino.cc/builder/container_build_options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636

3737
type ContainerBuildOptions struct{}
3838

39-
func (s *ContainerBuildOptions) Run(context map[string]interface{}) error {
39+
func (s *ContainerBuildOptions) Run(context map[string]interface{}, ctx *types.Context) error {
4040
commands := []types.Command{
4141
&CreateBuildOptionsMap{},
4242
&LoadPreviousBuildOptionsMap{},
@@ -46,7 +46,7 @@ func (s *ContainerBuildOptions) Run(context map[string]interface{}) error {
4646

4747
for _, command := range commands {
4848
PrintRingNameIfDebug(context, command)
49-
err := command.Run(context)
49+
err := command.Run(context, ctx)
5050
if err != nil {
5151
return utils.WrapError(err)
5252
}

0 commit comments

Comments
 (0)