Skip to content

Commit c8b0482

Browse files
committed
Clean up some useless constants
1 parent bf4a784 commit c8b0482

File tree

3 files changed

+15
-49
lines changed

3 files changed

+15
-49
lines changed

legacy/builder/builder.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (s *Builder) Run(ctx *types.Context) error {
5555

5656
&WarnAboutPlatformRewrites{},
5757

58-
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_PREBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
58+
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.prebuild", Suffix: ".pattern"},
5959

6060
&ContainerMergeCopySketchFiles{},
6161

@@ -68,33 +68,33 @@ func (s *Builder) Run(ctx *types.Context) error {
6868
&PreprocessSketch{},
6969

7070
utils.LogIfVerbose(constants.LOG_LEVEL_INFO, tr("Compiling sketch...")),
71-
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_SKETCH_PREBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
71+
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.sketch.prebuild", Suffix: ".pattern"},
7272
&phases.SketchBuilder{},
73-
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_SKETCH_POSTBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
73+
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.sketch.postbuild", Suffix: ".pattern"},
7474

7575
utils.LogIfVerbose(constants.LOG_LEVEL_INFO, tr("Compiling libraries...")),
76-
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_LIBRARIES_PREBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
76+
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.libraries.prebuild", Suffix: ".pattern"},
7777
&UnusedCompiledLibrariesRemover{},
7878
&phases.LibrariesBuilder{},
79-
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_LIBRARIES_POSTBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
79+
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.libraries.postbuild", Suffix: ".pattern"},
8080

8181
utils.LogIfVerbose(constants.LOG_LEVEL_INFO, tr("Compiling core...")),
82-
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_CORE_PREBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
82+
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.core.prebuild", Suffix: ".pattern"},
8383
&phases.CoreBuilder{},
84-
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_CORE_POSTBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
84+
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.core.postbuild", Suffix: ".pattern"},
8585

8686
utils.LogIfVerbose(constants.LOG_LEVEL_INFO, tr("Linking everything together...")),
87-
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_LINKING_PRELINK, Suffix: constants.HOOKS_PATTERN_SUFFIX},
87+
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.linking.prelink", Suffix: ".pattern"},
8888
&phases.Linker{},
89-
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_LINKING_POSTLINK, Suffix: constants.HOOKS_PATTERN_SUFFIX},
89+
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.linking.postlink", Suffix: ".pattern"},
9090

91-
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_OBJCOPY_PREOBJCOPY, Suffix: constants.HOOKS_PATTERN_SUFFIX},
92-
&RecipeByPrefixSuffixRunner{Prefix: "recipe.objcopy.", Suffix: constants.HOOKS_PATTERN_SUFFIX},
93-
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_OBJCOPY_POSTOBJCOPY, Suffix: constants.HOOKS_PATTERN_SUFFIX},
91+
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.objcopy.preobjcopy", Suffix: ".pattern"},
92+
&RecipeByPrefixSuffixRunner{Prefix: "recipe.objcopy.", Suffix: ".pattern"},
93+
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.objcopy.postobjcopy", Suffix: ".pattern"},
9494

9595
&MergeSketchWithBootloader{},
9696

97-
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_POSTBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
97+
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.postbuild", Suffix: ".pattern"},
9898
}
9999

100100
mainErr := runCommands(ctx, commands)
@@ -149,7 +149,7 @@ func (s *Preprocess) Run(ctx *types.Context) error {
149149

150150
&ContainerBuildOptions{},
151151

152-
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_PREBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
152+
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.prebuild", Suffix: ".pattern"},
153153

154154
&ContainerMergeCopySketchFiles{},
155155

legacy/builder/constants/constants.go

-25
Original file line numberDiff line numberDiff line change
@@ -47,31 +47,6 @@ const FOLDER_CORE = "core"
4747
const FOLDER_PREPROC = "preproc"
4848
const FOLDER_SKETCH = "sketch"
4949
const FOLDER_TOOLS = "tools"
50-
const hooks_core = hooks + ".core"
51-
const HOOKS_CORE_POSTBUILD = hooks_core + hooks_postbuild_suffix
52-
const HOOKS_CORE_PREBUILD = hooks_core + hooks_prebuild_suffix
53-
const hooks_libraries = hooks + ".libraries"
54-
const HOOKS_LIBRARIES_POSTBUILD = hooks_libraries + hooks_postbuild_suffix
55-
const HOOKS_LIBRARIES_PREBUILD = hooks_libraries + hooks_prebuild_suffix
56-
const hooks_linking = hooks + ".linking"
57-
const HOOKS_LINKING_POSTLINK = hooks_linking + hooks_postlink_suffix
58-
const HOOKS_LINKING_PRELINK = hooks_linking + hooks_prelink_suffix
59-
const hooks_objcopy = hooks + ".objcopy"
60-
const HOOKS_OBJCOPY_POSTOBJCOPY = hooks_objcopy + hooks_postobjcopy_suffix
61-
const HOOKS_OBJCOPY_PREOBJCOPY = hooks_objcopy + hooks_preobjcopy_suffix
62-
const HOOKS_PATTERN_SUFFIX = ".pattern"
63-
const HOOKS_POSTBUILD = hooks + hooks_postbuild_suffix
64-
const hooks_postbuild_suffix = ".postbuild"
65-
const hooks_postlink_suffix = ".postlink"
66-
const hooks_postobjcopy_suffix = ".postobjcopy"
67-
const HOOKS_PREBUILD = hooks + hooks_prebuild_suffix
68-
const hooks_prebuild_suffix = ".prebuild"
69-
const hooks_prelink_suffix = ".prelink"
70-
const hooks_preobjcopy_suffix = ".preobjcopy"
71-
const hooks = "recipe.hooks"
72-
const hooks_sketch = hooks + ".sketch"
73-
const HOOKS_SKETCH_POSTBUILD = hooks_sketch + hooks_postbuild_suffix
74-
const HOOKS_SKETCH_PREBUILD = hooks_sketch + hooks_prebuild_suffix
7550
const LIBRARY_ALL_ARCHS = "*"
7651
const LIBRARY_EMAIL = "email"
7752
const LIBRARY_FOLDER_ARCH = "arch"

legacy/builder/test/recipe_runner_test.go

+1-10
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ import (
1919
"testing"
2020

2121
"github.com/arduino/arduino-cli/legacy/builder"
22-
"github.com/arduino/arduino-cli/legacy/builder/constants"
2322
"github.com/arduino/arduino-cli/legacy/builder/types"
2423
"github.com/arduino/go-properties-orderedmap"
25-
"github.com/stretchr/testify/require"
2624
)
2725

2826
// TODO
@@ -38,18 +36,11 @@ func TestRecipeRunner(t *testing.T) {
3836

3937
commands := []types.Command{
4038
&builder.AddAdditionalEntriesToContext{},
41-
&builder.RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_PREBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
39+
&builder.RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.prebuild", Suffix: ".pattern"},
4240
}
4341

4442
for _, command := range commands {
4543
err := command.Run(ctx)
4644
NoError(t, err)
4745
}
4846
}
49-
50-
func TestRecipesComposition(t *testing.T) {
51-
require.Equal(t, "recipe.hooks.core.postbuild", constants.HOOKS_CORE_POSTBUILD)
52-
require.Equal(t, "recipe.hooks.postbuild", constants.HOOKS_POSTBUILD)
53-
require.Equal(t, "recipe.hooks.linking.prelink", constants.HOOKS_LINKING_PRELINK)
54-
require.Equal(t, "recipe.hooks.objcopy.preobjcopy", constants.HOOKS_OBJCOPY_PREOBJCOPY)
55-
}

0 commit comments

Comments
 (0)