Skip to content

Commit

Permalink
Removed useless buildPath from buildOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Sep 26, 2023
1 parent b0a091c commit c0fe7a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions arduino/builder/build_options_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type buildOptions struct {
builtInToolsDirs paths.PathList
otherLibrariesDirs paths.PathList
builtInLibrariesDirs *paths.Path
buildPath *paths.Path
runtimePlatformPath *paths.Path
buildCorePath *paths.Path
sketch *sketch.Sketch
Expand All @@ -48,7 +47,7 @@ type buildOptions struct {
// newBuildOptions fixdoc
func newBuildOptions(
hardwareDirs, builtInToolsDirs, otherLibrariesDirs paths.PathList,
builtInLibrariesDirs, buildPath *paths.Path,
builtInLibrariesDirs *paths.Path,
sketch *sketch.Sketch,
customBuildProperties []string,
fqbn *cores.FQBN,
Expand Down Expand Up @@ -87,7 +86,6 @@ func newBuildOptions(
builtInToolsDirs: builtInToolsDirs,
otherLibrariesDirs: otherLibrariesDirs,
builtInLibrariesDirs: builtInLibrariesDirs,
buildPath: buildPath,
runtimePlatformPath: runtimePlatformPath,
buildCorePath: buildCorePath,
sketch: sketch,
Expand All @@ -102,17 +100,17 @@ func (b *Builder) createBuildOptionsJSON() error {
if err != nil {
return err
}
return b.buildOptions.buildPath.Join("build.options.json").WriteFile(buildOptionsJSON)
return b.buildPath.Join("build.options.json").WriteFile(buildOptionsJSON)
}

func (b *Builder) wipeBuildPath() error {
// FIXME: this should go outside legacy and behind a `logrus` call so users can
// control when this should be printed.
// logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_BUILD_OPTIONS_CHANGED + constants.MSG_REBUILD_ALL)
if err := b.buildOptions.buildPath.RemoveAll(); err != nil {
if err := b.buildPath.RemoveAll(); err != nil {
return fmt.Errorf("%s: %w", tr("cleaning build path"), err)
}
if err := b.buildOptions.buildPath.MkdirAll(); err != nil {
if err := b.buildPath.MkdirAll(); err != nil {
return fmt.Errorf("%s: %w", tr("cleaning build path"), err)
}
return nil
Expand All @@ -125,7 +123,7 @@ func (b *Builder) wipeBuildPathIfBuildOptionsChanged() error {

// Load previous build options map
var buildOptionsJSONPrevious []byte
if buildOptionsFile := b.buildOptions.buildPath.Join("build.options.json"); buildOptionsFile.Exist() {
if buildOptionsFile := b.buildPath.Join("build.options.json"); buildOptionsFile.Exist() {
var err error
buildOptionsJSONPrevious, err = buildOptionsFile.ReadFile()
if err != nil {
Expand Down Expand Up @@ -157,9 +155,8 @@ func (b *Builder) wipeBuildPathIfBuildOptionsChanged() error {
// since the json was generated - like platform.txt or similar
// if so, trigger a "safety" wipe
targetCoreFolder := b.buildOptions.runtimePlatformPath
coreFolder := b.buildOptions.buildCorePath
realCoreFolder := coreFolder.Parent().Parent()
jsonPath := b.buildOptions.buildPath.Join("build.options.json")
realCoreFolder := b.buildOptions.buildCorePath.Parent().Parent()
jsonPath := b.buildPath.Join("build.options.json")
coreUnchanged, _ := utils.DirContentIsOlderThan(realCoreFolder, jsonPath, ".txt")
if coreUnchanged && targetCoreFolder != nil && !realCoreFolder.EqualsTo(targetCoreFolder) {
coreUnchanged, _ = utils.DirContentIsOlderThan(targetCoreFolder, jsonPath, ".txt")
Expand Down
2 changes: 1 addition & 1 deletion arduino/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func NewBuilder(
),
buildOptions: newBuildOptions(
hardwareDirs, builtInToolsDirs, otherLibrariesDirs,
builtInLibrariesDirs, buildPath,
builtInLibrariesDirs,
sk,
customBuildPropertiesArgs,
fqbn,
Expand Down

0 comments on commit c0fe7a3

Please sign in to comment.