Skip to content

Remove legacy "rewrite-rules" feature #2132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arduino/cores/packagemanager/package_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ func (pme *Explorer) ResolveFQBN(fqbn *cores.FQBN) (
buildProperties.Set("runtime.os", properties.GetOSSuffix())
buildProperties.Set("build.library_discovery_phase", "0")
// Deprecated properties
buildProperties.Set("tools.avrdude.path", "{runtime.tools.avrdude.path}")
buildProperties.Set("ide_version", "10607")
buildProperties.Set("runtime.ide.version", "10607")
if !buildProperties.ContainsKey("software") {
Expand Down
2 changes: 0 additions & 2 deletions legacy/builder/add_additional_entries_to_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package builder

import (
"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/legacy/builder/constants"
"github.com/arduino/arduino-cli/legacy/builder/types"
"github.com/pkg/errors"
Expand Down Expand Up @@ -57,7 +56,6 @@ func (*AddAdditionalEntriesToContext) Run(ctx *types.Context) error {
ctx.CollectedSourceFiles = &types.UniqueSourceFileQueue{}

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

return nil
}

This file was deleted.

2 changes: 0 additions & 2 deletions legacy/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ func (s *Builder) Run(ctx *types.Context) error {

&ContainerBuildOptions{},

&WarnAboutPlatformRewrites{},

&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.prebuild", Suffix: ".pattern"},

&ContainerMergeCopySketchFiles{},
Expand Down
6 changes: 0 additions & 6 deletions legacy/builder/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const BUILD_PROPERTIES_INCLUDES = "includes"
const BUILD_PROPERTIES_OBJECT_FILE = "object_file"
const BUILD_PROPERTIES_RUNTIME_PLATFORM_PATH = "runtime.platform.path"
const EMPTY_STRING = ""
const FILE_PLATFORM_KEYS_REWRITE_TXT = "platform.keys.rewrite.txt"
const FOLDER_BOOTLOADERS = "bootloaders"
const FOLDER_CORE = "core"
const FOLDER_PREPROC = "preproc"
Expand All @@ -52,15 +51,10 @@ const LOG_LEVEL_WARN = "warn"
const PACKAGE_NAME = "name"
const PACKAGE_TOOLS = "tools"
const PLATFORM_ARCHITECTURE = "architecture"
const PLATFORM_NAME = "name"
const PLATFORM_REWRITE_NEW = "new"
const PLATFORM_REWRITE_OLD = "old"
const PLATFORM_URL = "url"
const PLATFORM_VERSION = "version"
const RECIPE_AR_PATTERN = "recipe.ar.pattern"
const RECIPE_C_COMBINE_PATTERN = "recipe.c.combine.pattern"
const REWRITING_DISABLED = "disabled"
const REWRITING = "rewriting"
const SPACE = " "
const TOOL_NAME = "name"
const TOOL_URL = "url"
Expand Down
3 changes: 0 additions & 3 deletions legacy/builder/container_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ func (s *ContainerSetupHardwareToolsLibsSketchAndProps) Run(ctx *types.Context)
&AddAdditionalEntriesToContext{},
&FailIfBuildPathEqualsSketchPath{},
&HardwareLoader{},
&PlatformKeysRewriteLoader{},
&RewriteHardwareKeys{},
&TargetBoardResolver{},
&LibrariesLoader{},
}
Expand All @@ -53,7 +51,6 @@ func (s *ContainerSetupHardwareToolsLibsSketchAndProps) Run(ctx *types.Context)
commands = []types.Command{
&SetupBuildProperties{},
&SetCustomBuildProperties{},
&AddMissingBuildPropertiesFromParentPlatformTxtFiles{},
}

for _, command := range commands {
Expand Down
33 changes: 0 additions & 33 deletions legacy/builder/ctags/ctags_properties.go

This file was deleted.

15 changes: 9 additions & 6 deletions legacy/builder/ctags_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,22 @@ import (
type CTagsRunner struct{}

func (s *CTagsRunner) Run(ctx *types.Context) error {
buildProperties := ctx.BuildProperties
ctagsTargetFilePath := ctx.CTagsTargetFile

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

pattern := ctagsProperties.Get("pattern")
pattern := buildProperties.Get("pattern")
if pattern == "" {
return errors.Errorf(tr("%s pattern is missing"), "ctags")
}

commandLine := ctagsProperties.ExpandPropsInString(pattern)
commandLine := buildProperties.ExpandPropsInString(pattern)
parts, err := properties.SplitQuotedString(commandLine, `"'`, false)
if err != nil {
return errors.WithStack(err)
Expand Down
36 changes: 18 additions & 18 deletions legacy/builder/gcc_preproc_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/arduino/arduino-cli/legacy/builder/types"
"github.com/arduino/arduino-cli/legacy/builder/utils"
"github.com/arduino/go-paths-helper"
properties "github.com/arduino/go-properties-orderedmap"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -55,20 +56,28 @@ func GCCPreprocRunnerForDiscoveringIncludes(ctx *types.Context, sourceFilePath *
}

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

includesStrings := utils.Map(includes.AsStrings(), utils.WrapWithHyphenI)
properties.Set("includes", strings.Join(includesStrings, " "))
buildProperties.Set("includes", strings.Join(includesStrings, " "))

if properties.Get("recipe.preproc.macros") == "" {
//generate PREPROC_MACROS from RECIPE_CPP_PATTERN
properties.Set("recipe.preproc.macros", GeneratePreprocPatternFromCompile(properties.Get("recipe.cpp.o.pattern")))
if buildProperties.Get("recipe.preproc.macros") == "" {
// autogenerate preprocess macros recipe from compile recipe
preprocPattern := buildProperties.Get("recipe.cpp.o.pattern")
// add {preproc.macros.flags} to {compiler.cpp.flags}
preprocPattern = strings.Replace(preprocPattern, "{compiler.cpp.flags}", "{compiler.cpp.flags} {preproc.macros.flags}", 1)
// replace "{object_file}" with "{preprocessed_file_path}"
preprocPattern = strings.Replace(preprocPattern, "{object_file}", "{preprocessed_file_path}", 1)

buildProperties.Set("recipe.preproc.macros", preprocPattern)
}

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

return cmd, nil
}

func GeneratePreprocPatternFromCompile(compilePattern string) string {
// add {preproc.macros.flags}
// replace "{object_file}" with "{preprocessed_file_path}"
returnString := compilePattern
returnString = strings.Replace(returnString, "{compiler.cpp.flags}", "{compiler.cpp.flags} {preproc.macros.flags}", 1)
returnString = strings.Replace(returnString, "{object_file}", "{preprocessed_file_path}", 1)
return returnString
}
42 changes: 0 additions & 42 deletions legacy/builder/hardware/platform.keys.rewrite.txt

This file was deleted.

Loading