@@ -10,6 +10,7 @@ import (
10
10
"path/filepath"
11
11
"strings"
12
12
13
+ "github.com/arduino/go-properties-orderedmap"
13
14
"github.com/pkg/errors"
14
15
)
15
16
@@ -142,7 +143,7 @@ func generateCompileFlags(tempDir, inoPath, sourcePath, fqbn string) (string, er
142
143
err = logCommandErr (globalCliPath , output , err , errMsgFilter (tempDir ))
143
144
return "" , err
144
145
}
145
- properties , err := readProperties ( bytes . NewReader (output ) )
146
+ buildProps , err := properties . LoadFromBytes (output )
146
147
if err != nil {
147
148
return "" , errors .Wrap (err , "Error while reading build properties." )
148
149
}
@@ -154,7 +155,7 @@ func generateCompileFlags(tempDir, inoPath, sourcePath, fqbn string) (string, er
154
155
defer outFile .Close ()
155
156
156
157
printer := Printer {Writer : bufio .NewWriter (outFile )}
157
- printCompileFlags (properties , & printer , fqbn )
158
+ printCompileFlags (buildProps , & printer , fqbn )
158
159
printLibraryPaths (sourcePath , & printer )
159
160
printer .Flush ()
160
161
return flagsPath , printer .Err
@@ -214,40 +215,40 @@ func copyIno2Cpp(inoCode string, cppPath string) (cppCode []byte, err error) {
214
215
return
215
216
}
216
217
217
- func printCompileFlags (properties map [ string ] string , printer * Printer , fqbn string ) {
218
+ func printCompileFlags (buildProps * properties. Map , printer * Printer , fqbn string ) {
218
219
if strings .Contains (fqbn , ":avr:" ) {
219
220
printer .Println ("--target=avr" )
220
221
} else if strings .Contains (fqbn , ":sam:" ) {
221
222
printer .Println ("--target=arm-none-eabi" )
222
223
}
223
- cppFlags := expandProperty ( properties , "compiler.cpp.flags" )
224
+ cppFlags := buildProps . ExpandPropsInString ( buildProps . Get ( "compiler.cpp.flags" ) )
224
225
printer .Println (splitFlags (cppFlags ))
225
- mcu := expandProperty ( properties , "build.mcu" )
226
+ mcu := buildProps . ExpandPropsInString ( buildProps . Get ( "build.mcu" ) )
226
227
if strings .Contains (fqbn , ":avr:" ) {
227
228
printer .Println ("-mmcu=" , mcu )
228
229
} else if strings .Contains (fqbn , ":sam:" ) {
229
230
printer .Println ("-mcpu=" , mcu )
230
231
}
231
- fcpu := expandProperty ( properties , "build.f_cpu" )
232
+ fcpu := buildProps . ExpandPropsInString ( buildProps . Get ( "build.f_cpu" ) )
232
233
printer .Println ("-DF_CPU=" , fcpu )
233
- ideVersion := expandProperty ( properties , "runtime.ide.version" )
234
+ ideVersion := buildProps . ExpandPropsInString ( buildProps . Get ( "runtime.ide.version" ) )
234
235
printer .Println ("-DARDUINO=" , ideVersion )
235
- board := expandProperty ( properties , "build.board" )
236
+ board := buildProps . ExpandPropsInString ( buildProps . Get ( "build.board" ) )
236
237
printer .Println ("-DARDUINO_" , board )
237
- arch := expandProperty ( properties , "build.arch" )
238
+ arch := buildProps . ExpandPropsInString ( buildProps . Get ( "build.arch" ) )
238
239
printer .Println ("-DARDUINO_ARCH_" , arch )
239
240
if strings .Contains (fqbn , ":sam:" ) {
240
- libSamFlags := expandProperty ( properties , "compiler.libsam.c.flags" )
241
+ libSamFlags := buildProps . ExpandPropsInString ( buildProps . Get ( "compiler.libsam.c.flags" ) )
241
242
printer .Println (splitFlags (libSamFlags ))
242
243
}
243
- extraFlags := expandProperty ( properties , "build.extra_flags" )
244
+ extraFlags := buildProps . ExpandPropsInString ( buildProps . Get ( "build.extra_flags" ) )
244
245
printer .Println (splitFlags (extraFlags ))
245
- corePath := expandProperty ( properties , "build.core.path" )
246
+ corePath := buildProps . ExpandPropsInString ( buildProps . Get ( "build.core.path" ) )
246
247
printer .Println ("-I" , corePath )
247
- variantPath := expandProperty ( properties , "build.variant.path" )
248
+ variantPath := buildProps . ExpandPropsInString ( buildProps . Get ( "build.variant.path" ) )
248
249
printer .Println ("-I" , variantPath )
249
250
if strings .Contains (fqbn , ":avr:" ) {
250
- avrgccPath := expandProperty ( properties , "runtime.tools.avr-gcc.path" )
251
+ avrgccPath := buildProps . ExpandPropsInString ( buildProps . Get ( "runtime.tools.avr-gcc.path" ) )
251
252
printer .Println ("-I" , filepath .Join (avrgccPath , "avr" , "include" ))
252
253
}
253
254
0 commit comments