Skip to content

Commit a9fd1c6

Browse files
committed
Moved Sketch in Context
Signed-off-by: Cristian Maglie <c.maglie@arduino.cc>
1 parent 377bebe commit a9fd1c6

16 files changed

+33
-41
lines changed

src/arduino.cc/builder/additional_sketch_files_copier.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
package builder
3131

3232
import (
33-
"arduino.cc/builder/constants"
3433
"arduino.cc/builder/i18n"
3534
"arduino.cc/builder/types"
3635
"arduino.cc/builder/utils"
@@ -42,7 +41,7 @@ import (
4241
type AdditionalSketchFilesCopier struct{}
4342

4443
func (s *AdditionalSketchFilesCopier) Run(context map[string]interface{}, ctx *types.Context) error {
45-
sketch := context[constants.CTX_SKETCH].(*types.Sketch)
44+
sketch := ctx.Sketch
4645
sketchBuildPath := ctx.SketchBuildPath
4746

4847
err := utils.EnsureFolderExists(sketchBuildPath)

src/arduino.cc/builder/collect_ctags_from_sketch_files.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
package builder
3131

3232
import (
33-
"arduino.cc/builder/constants"
3433
"arduino.cc/builder/types"
3534
"arduino.cc/builder/utils"
3635
"strings"
@@ -39,8 +38,7 @@ import (
3938
type CollectCTagsFromSketchFiles struct{}
4039

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

4543
allCtags := ctx.CTagsOfPreprocessedSource
4644
ctagsOfSketch := []*types.CTag{}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ const CTX_OBJECT_FILES_CORE = "objectFilesCore"
8888
const CTX_OBJECT_FILES_LIBRARIES = "objectFilesLibraries"
8989
const CTX_OBJECT_FILES_SKETCH = "objectFilesSketch"
9090
const CTX_PLATFORM_KEYS_REWRITE = "platformKeysRewrite"
91-
const CTX_SKETCH = "sketch"
9291
const CTX_SOURCE = "source"
9392
const CTX_TOOLS = "tools"
9493
const CTX_VIDPID = "VIDPID"

src/arduino.cc/builder/container_find_includes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (s *ContainerFindIncludes) Run(context map[string]interface{}, ctx *types.C
4646
}
4747

4848
sketchBuildPath := ctx.SketchBuildPath
49-
sketch := context[constants.CTX_SKETCH].(*types.Sketch)
49+
sketch := ctx.Sketch
5050
err = findIncludesUntilDone(context, ctx, filepath.Join(sketchBuildPath, filepath.Base(sketch.MainFile.Name)+".cpp"))
5151
if err != nil {
5252
return i18n.WrapError(err)

src/arduino.cc/builder/gcc_preproc_runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type GCCPreprocRunner struct {
4646

4747
func (s *GCCPreprocRunner) Run(context map[string]interface{}, ctx *types.Context) error {
4848
sketchBuildPath := ctx.SketchBuildPath
49-
sketch := context[constants.CTX_SKETCH].(*types.Sketch)
49+
sketch := ctx.Sketch
5050
properties, targetFilePath, err := prepareGCCPreprocRecipeProperties(context, ctx, filepath.Join(sketchBuildPath, filepath.Base(sketch.MainFile.Name)+".cpp"), s.TargetFileName)
5151
if err != nil {
5252
return i18n.WrapError(err)

src/arduino.cc/builder/merge_sketch_with_bootloader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (s *MergeSketchWithBootloader) Run(context map[string]interface{}, ctx *typ
4848
}
4949

5050
buildPath := ctx.BuildPath
51-
sketch := context[constants.CTX_SKETCH].(*types.Sketch)
51+
sketch := ctx.Sketch
5252
sketchFileName := filepath.Base(sketch.MainFile.Name)
5353
logger := ctx.GetLogger()
5454

src/arduino.cc/builder/setup_build_properties.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ func (s *SetupBuildProperties) Run(context map[string]interface{}, ctx *types.Co
5757
if ctx.BuildPath != "" {
5858
buildProperties[constants.BUILD_PROPERTIES_BUILD_PATH] = ctx.BuildPath
5959
}
60-
if utils.MapHas(context, constants.CTX_SKETCH) {
61-
buildProperties[constants.BUILD_PROPERTIES_BUILD_PROJECT_NAME] = filepath.Base(context[constants.CTX_SKETCH].(*types.Sketch).MainFile.Name)
60+
if ctx.Sketch != nil {
61+
buildProperties[constants.BUILD_PROPERTIES_BUILD_PROJECT_NAME] = filepath.Base(ctx.Sketch.MainFile.Name)
6262
}
6363
buildProperties[constants.BUILD_PROPERTIES_BUILD_ARCH] = strings.ToUpper(targetPlatform.PlatformId)
6464

src/arduino.cc/builder/sketch_loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (s *SketchLoader) Run(context map[string]interface{}, ctx *types.Context) e
8282
}
8383

8484
ctx.SketchLocation = sketchLocation
85-
context[constants.CTX_SKETCH] = sketch
85+
ctx.Sketch = sketch
8686

8787
return nil
8888
}

src/arduino.cc/builder/sketch_saver.go

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

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

src/arduino.cc/builder/sketch_source_merger.go

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

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

4545
lineOffset := 0
4646
includeSection := ""

0 commit comments

Comments
 (0)