@@ -10,6 +10,7 @@ import (
1010 "path/filepath"
1111 "strings"
1212
13+ "github.com/arduino/go-properties-orderedmap"
1314 "github.com/pkg/errors"
1415)
1516
@@ -142,7 +143,7 @@ func generateCompileFlags(tempDir, inoPath, sourcePath, fqbn string) (string, er
142143 err = logCommandErr (globalCliPath , output , err , errMsgFilter (tempDir ))
143144 return "" , err
144145 }
145- properties , err := readProperties ( bytes . NewReader (output ) )
146+ buildProps , err := properties . LoadFromBytes (output )
146147 if err != nil {
147148 return "" , errors .Wrap (err , "Error while reading build properties." )
148149 }
@@ -154,7 +155,7 @@ func generateCompileFlags(tempDir, inoPath, sourcePath, fqbn string) (string, er
154155 defer outFile .Close ()
155156
156157 printer := Printer {Writer : bufio .NewWriter (outFile )}
157- printCompileFlags (properties , & printer , fqbn )
158+ printCompileFlags (buildProps , & printer , fqbn )
158159 printLibraryPaths (sourcePath , & printer )
159160 printer .Flush ()
160161 return flagsPath , printer .Err
@@ -214,40 +215,40 @@ func copyIno2Cpp(inoCode string, cppPath string) (cppCode []byte, err error) {
214215 return
215216}
216217
217- func printCompileFlags (properties map [ string ] string , printer * Printer , fqbn string ) {
218+ func printCompileFlags (buildProps * properties. Map , printer * Printer , fqbn string ) {
218219 if strings .Contains (fqbn , ":avr:" ) {
219220 printer .Println ("--target=avr" )
220221 } else if strings .Contains (fqbn , ":sam:" ) {
221222 printer .Println ("--target=arm-none-eabi" )
222223 }
223- cppFlags := expandProperty ( properties , "compiler.cpp.flags" )
224+ cppFlags := buildProps . ExpandPropsInString ( buildProps . Get ( "compiler.cpp.flags" ) )
224225 printer .Println (splitFlags (cppFlags ))
225- mcu := expandProperty ( properties , "build.mcu" )
226+ mcu := buildProps . ExpandPropsInString ( buildProps . Get ( "build.mcu" ) )
226227 if strings .Contains (fqbn , ":avr:" ) {
227228 printer .Println ("-mmcu=" , mcu )
228229 } else if strings .Contains (fqbn , ":sam:" ) {
229230 printer .Println ("-mcpu=" , mcu )
230231 }
231- fcpu := expandProperty ( properties , "build.f_cpu" )
232+ fcpu := buildProps . ExpandPropsInString ( buildProps . Get ( "build.f_cpu" ) )
232233 printer .Println ("-DF_CPU=" , fcpu )
233- ideVersion := expandProperty ( properties , "runtime.ide.version" )
234+ ideVersion := buildProps . ExpandPropsInString ( buildProps . Get ( "runtime.ide.version" ) )
234235 printer .Println ("-DARDUINO=" , ideVersion )
235- board := expandProperty ( properties , "build.board" )
236+ board := buildProps . ExpandPropsInString ( buildProps . Get ( "build.board" ) )
236237 printer .Println ("-DARDUINO_" , board )
237- arch := expandProperty ( properties , "build.arch" )
238+ arch := buildProps . ExpandPropsInString ( buildProps . Get ( "build.arch" ) )
238239 printer .Println ("-DARDUINO_ARCH_" , arch )
239240 if strings .Contains (fqbn , ":sam:" ) {
240- libSamFlags := expandProperty ( properties , "compiler.libsam.c.flags" )
241+ libSamFlags := buildProps . ExpandPropsInString ( buildProps . Get ( "compiler.libsam.c.flags" ) )
241242 printer .Println (splitFlags (libSamFlags ))
242243 }
243- extraFlags := expandProperty ( properties , "build.extra_flags" )
244+ extraFlags := buildProps . ExpandPropsInString ( buildProps . Get ( "build.extra_flags" ) )
244245 printer .Println (splitFlags (extraFlags ))
245- corePath := expandProperty ( properties , "build.core.path" )
246+ corePath := buildProps . ExpandPropsInString ( buildProps . Get ( "build.core.path" ) )
246247 printer .Println ("-I" , corePath )
247- variantPath := expandProperty ( properties , "build.variant.path" )
248+ variantPath := buildProps . ExpandPropsInString ( buildProps . Get ( "build.variant.path" ) )
248249 printer .Println ("-I" , variantPath )
249250 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" ) )
251252 printer .Println ("-I" , filepath .Join (avrgccPath , "avr" , "include" ))
252253 }
253254
0 commit comments