@@ -23,6 +23,7 @@ import (
23
23
f "github.com/arduino/arduino-cli/internal/algorithms"
24
24
"github.com/arduino/go-paths-helper"
25
25
"github.com/sirupsen/logrus"
26
+ "golang.org/x/text/encoding/charmap"
26
27
"golang.org/x/text/runes"
27
28
"golang.org/x/text/transform"
28
29
"golang.org/x/text/unicode/norm"
@@ -74,17 +75,32 @@ func ObjFileIsUpToDate(sourceFile, objectFile, dependencyFile *paths.Path) (bool
74
75
return false , nil
75
76
}
76
77
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 )
78
100
if err != nil {
79
101
logrus .Debugf ("Could not read dependency file: %s" , dependencyFile )
80
102
return false , err
81
103
}
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
-
88
104
if len (rows ) == 0 {
89
105
return true , nil
90
106
}
0 commit comments