Skip to content

Commit 5a1c2fe

Browse files
authored
Remove legacy "rewrite-rules" feature (#2132)
* Refactored AddMissingBuildPropertiesFromParentPlatformTxtFiles Previously the specific recipes to run CTags were added to global build properties. Now the global build properties are not altered anymore and the CTags-specific properties are created only to run CTags and dropped afterward. * Removed platform rewrite-rules functionality
1 parent 51e50e1 commit 5a1c2fe

18 files changed

+42
-562
lines changed

Diff for: arduino/cores/packagemanager/package_manager.go

+1
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ func (pme *Explorer) ResolveFQBN(fqbn *cores.FQBN) (
360360
buildProperties.Set("runtime.os", properties.GetOSSuffix())
361361
buildProperties.Set("build.library_discovery_phase", "0")
362362
// Deprecated properties
363+
buildProperties.Set("tools.avrdude.path", "{runtime.tools.avrdude.path}")
363364
buildProperties.Set("ide_version", "10607")
364365
buildProperties.Set("runtime.ide.version", "10607")
365366
if !buildProperties.ContainsKey("software") {

Diff for: legacy/builder/add_additional_entries_to_context.go

-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package builder
1717

1818
import (
19-
"github.com/arduino/arduino-cli/arduino/cores"
2019
"github.com/arduino/arduino-cli/legacy/builder/constants"
2120
"github.com/arduino/arduino-cli/legacy/builder/types"
2221
"github.com/pkg/errors"
@@ -57,7 +56,6 @@ func (*AddAdditionalEntriesToContext) Run(ctx *types.Context) error {
5756
ctx.CollectedSourceFiles = &types.UniqueSourceFileQueue{}
5857

5958
ctx.LibrariesResolutionResults = map[string]types.LibraryResolutionResult{}
60-
ctx.HardwareRewriteResults = map[*cores.PlatformRelease][]types.PlatforKeyRewrite{}
6159

6260
return nil
6361
}

Diff for: legacy/builder/add_missing_build_properties_from_parent_platform_txt_files.go

-34
This file was deleted.

Diff for: legacy/builder/builder.go

-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ func (s *Builder) Run(ctx *types.Context) error {
4444

4545
&ContainerBuildOptions{},
4646

47-
&WarnAboutPlatformRewrites{},
48-
4947
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.prebuild", Suffix: ".pattern"},
5048

5149
&ContainerMergeCopySketchFiles{},

Diff for: legacy/builder/constants/constants.go

-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const BUILD_PROPERTIES_INCLUDES = "includes"
3333
const BUILD_PROPERTIES_OBJECT_FILE = "object_file"
3434
const BUILD_PROPERTIES_RUNTIME_PLATFORM_PATH = "runtime.platform.path"
3535
const EMPTY_STRING = ""
36-
const FILE_PLATFORM_KEYS_REWRITE_TXT = "platform.keys.rewrite.txt"
3736
const FOLDER_BOOTLOADERS = "bootloaders"
3837
const FOLDER_CORE = "core"
3938
const FOLDER_PREPROC = "preproc"
@@ -52,15 +51,10 @@ const LOG_LEVEL_WARN = "warn"
5251
const PACKAGE_NAME = "name"
5352
const PACKAGE_TOOLS = "tools"
5453
const PLATFORM_ARCHITECTURE = "architecture"
55-
const PLATFORM_NAME = "name"
56-
const PLATFORM_REWRITE_NEW = "new"
57-
const PLATFORM_REWRITE_OLD = "old"
5854
const PLATFORM_URL = "url"
5955
const PLATFORM_VERSION = "version"
6056
const RECIPE_AR_PATTERN = "recipe.ar.pattern"
6157
const RECIPE_C_COMBINE_PATTERN = "recipe.c.combine.pattern"
62-
const REWRITING_DISABLED = "disabled"
63-
const REWRITING = "rewriting"
6458
const SPACE = " "
6559
const TOOL_NAME = "name"
6660
const TOOL_URL = "url"

Diff for: legacy/builder/container_setup.go

-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ func (s *ContainerSetupHardwareToolsLibsSketchAndProps) Run(ctx *types.Context)
3131
&AddAdditionalEntriesToContext{},
3232
&FailIfBuildPathEqualsSketchPath{},
3333
&HardwareLoader{},
34-
&PlatformKeysRewriteLoader{},
35-
&RewriteHardwareKeys{},
3634
&TargetBoardResolver{},
3735
&LibrariesLoader{},
3836
}
@@ -53,7 +51,6 @@ func (s *ContainerSetupHardwareToolsLibsSketchAndProps) Run(ctx *types.Context)
5351
commands = []types.Command{
5452
&SetupBuildProperties{},
5553
&SetCustomBuildProperties{},
56-
&AddMissingBuildPropertiesFromParentPlatformTxtFiles{},
5754
}
5855

5956
for _, command := range commands {

Diff for: legacy/builder/ctags/ctags_properties.go

-33
This file was deleted.

Diff for: legacy/builder/ctags_runner.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,22 @@ import (
2929
type CTagsRunner struct{}
3030

3131
func (s *CTagsRunner) Run(ctx *types.Context) error {
32-
buildProperties := ctx.BuildProperties
3332
ctagsTargetFilePath := ctx.CTagsTargetFile
3433

35-
ctagsProperties := buildProperties.Clone()
36-
ctagsProperties.Merge(buildProperties.SubTree("tools").SubTree("ctags"))
37-
ctagsProperties.SetPath("source_file", ctagsTargetFilePath)
34+
buildProperties := properties.NewMap()
35+
buildProperties.Set("tools.ctags.path", "{runtime.tools.ctags.path}")
36+
buildProperties.Set("tools.ctags.cmd.path", "{path}/ctags")
37+
buildProperties.Set("tools.ctags.pattern", `"{cmd.path}" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "{source_file}"`)
38+
buildProperties.Merge(ctx.BuildProperties)
39+
buildProperties.Merge(buildProperties.SubTree("tools").SubTree("ctags"))
40+
buildProperties.SetPath("source_file", ctagsTargetFilePath)
3841

39-
pattern := ctagsProperties.Get("pattern")
42+
pattern := buildProperties.Get("pattern")
4043
if pattern == "" {
4144
return errors.Errorf(tr("%s pattern is missing"), "ctags")
4245
}
4346

44-
commandLine := ctagsProperties.ExpandPropsInString(pattern)
47+
commandLine := buildProperties.ExpandPropsInString(pattern)
4548
parts, err := properties.SplitQuotedString(commandLine, `"'`, false)
4649
if err != nil {
4750
return errors.WithStack(err)

Diff for: legacy/builder/gcc_preproc_runner.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/arduino/arduino-cli/legacy/builder/types"
2424
"github.com/arduino/arduino-cli/legacy/builder/utils"
2525
"github.com/arduino/go-paths-helper"
26+
properties "github.com/arduino/go-properties-orderedmap"
2627
"github.com/pkg/errors"
2728
)
2829

@@ -55,20 +56,28 @@ func GCCPreprocRunnerForDiscoveringIncludes(ctx *types.Context, sourceFilePath *
5556
}
5657

5758
func prepareGCCPreprocRecipeProperties(ctx *types.Context, sourceFilePath *paths.Path, targetFilePath *paths.Path, includes paths.PathList) (*exec.Cmd, error) {
58-
properties := ctx.BuildProperties.Clone()
59-
properties.Set("build.library_discovery_phase", "1")
60-
properties.SetPath("source_file", sourceFilePath)
61-
properties.SetPath("preprocessed_file_path", targetFilePath)
59+
buildProperties := properties.NewMap()
60+
buildProperties.Set("preproc.macros.flags", "-w -x c++ -E -CC")
61+
buildProperties.Merge(ctx.BuildProperties)
62+
buildProperties.Set("build.library_discovery_phase", "1")
63+
buildProperties.SetPath("source_file", sourceFilePath)
64+
buildProperties.SetPath("preprocessed_file_path", targetFilePath)
6265

6366
includesStrings := utils.Map(includes.AsStrings(), utils.WrapWithHyphenI)
64-
properties.Set("includes", strings.Join(includesStrings, " "))
67+
buildProperties.Set("includes", strings.Join(includesStrings, " "))
6568

66-
if properties.Get("recipe.preproc.macros") == "" {
67-
//generate PREPROC_MACROS from RECIPE_CPP_PATTERN
68-
properties.Set("recipe.preproc.macros", GeneratePreprocPatternFromCompile(properties.Get("recipe.cpp.o.pattern")))
69+
if buildProperties.Get("recipe.preproc.macros") == "" {
70+
// autogenerate preprocess macros recipe from compile recipe
71+
preprocPattern := buildProperties.Get("recipe.cpp.o.pattern")
72+
// add {preproc.macros.flags} to {compiler.cpp.flags}
73+
preprocPattern = strings.Replace(preprocPattern, "{compiler.cpp.flags}", "{compiler.cpp.flags} {preproc.macros.flags}", 1)
74+
// replace "{object_file}" with "{preprocessed_file_path}"
75+
preprocPattern = strings.Replace(preprocPattern, "{object_file}", "{preprocessed_file_path}", 1)
76+
77+
buildProperties.Set("recipe.preproc.macros", preprocPattern)
6978
}
7079

71-
cmd, err := builder_utils.PrepareCommandForRecipe(properties, "recipe.preproc.macros", true, ctx.PackageManager.GetEnvVarsForSpawnedProcess())
80+
cmd, err := builder_utils.PrepareCommandForRecipe(buildProperties, "recipe.preproc.macros", true, ctx.PackageManager.GetEnvVarsForSpawnedProcess())
7281
if err != nil {
7382
return nil, errors.WithStack(err)
7483
}
@@ -79,12 +88,3 @@ func prepareGCCPreprocRecipeProperties(ctx *types.Context, sourceFilePath *paths
7988

8089
return cmd, nil
8190
}
82-
83-
func GeneratePreprocPatternFromCompile(compilePattern string) string {
84-
// add {preproc.macros.flags}
85-
// replace "{object_file}" with "{preprocessed_file_path}"
86-
returnString := compilePattern
87-
returnString = strings.Replace(returnString, "{compiler.cpp.flags}", "{compiler.cpp.flags} {preproc.macros.flags}", 1)
88-
returnString = strings.Replace(returnString, "{object_file}", "{preprocessed_file_path}", 1)
89-
return returnString
90-
}

Diff for: legacy/builder/hardware/platform.keys.rewrite.txt

-42
This file was deleted.

0 commit comments

Comments
 (0)