@@ -23,6 +23,7 @@ import (
2323 f "github.com/arduino/arduino-cli/internal/algorithms"
2424 "github.com/arduino/go-paths-helper"
2525 "github.com/sirupsen/logrus"
26+ "golang.org/x/text/encoding/charmap"
2627 "golang.org/x/text/runes"
2728 "golang.org/x/text/transform"
2829 "golang.org/x/text/unicode/norm"
@@ -74,17 +75,32 @@ func ObjFileIsUpToDate(sourceFile, objectFile, dependencyFile *paths.Path) (bool
7475 return false , nil
7576 }
7677
77- rows , err := dependencyFile .ReadFileAsLines ()
78+ readDepFileWithEncoding := func (mapping * charmap.Charmap ) ([]string , error ) {
79+ data , err := dependencyFile .ReadFile ()
80+ if err != nil {
81+ return nil , err
82+ }
83+
84+ if mapping != nil {
85+ decoded , err := mapping .NewDecoder ().Bytes (data )
86+ if err != nil {
87+ return nil , err
88+ }
89+ data = decoded
90+ }
91+
92+ rows := strings .Split (strings .Replace (string (data ), "\r \n " , "\n " , - 1 ), "\n " )
93+ rows = f .Map (rows , removeEndingBackSlash )
94+ rows = f .Map (rows , strings .TrimSpace )
95+ rows = f .Map (rows , unescapeDep )
96+ return f .Filter (rows , f .NotEquals ("" )), nil
97+ }
98+
99+ rows , err := readDepFileWithEncoding (nil )
78100 if err != nil {
79101 logrus .Debugf ("Could not read dependency file: %s" , dependencyFile )
80102 return false , err
81103 }
82-
83- rows = f .Map (rows , removeEndingBackSlash )
84- rows = f .Map (rows , strings .TrimSpace )
85- rows = f .Map (rows , unescapeDep )
86- rows = f .Filter (rows , f .NotEquals ("" ))
87-
88104 if len (rows ) == 0 {
89105 return true , nil
90106 }
0 commit comments