30
30
package builder_utils
31
31
32
32
import (
33
- "arduino.cc/builder/constants"
34
- "arduino.cc/builder/i18n"
35
- "arduino.cc/builder/props"
36
- "arduino.cc/builder/utils"
37
33
"bytes"
38
34
"fmt"
39
35
"os"
40
36
"os/exec"
41
37
"path/filepath"
42
38
"strings"
39
+
40
+ "arduino.cc/builder/constants"
41
+ "arduino.cc/builder/i18n"
42
+ "arduino.cc/builder/utils"
43
+ "arduino.cc/properties"
43
44
)
44
45
45
- func CompileFilesRecursive (objectFiles []string , sourcePath string , buildPath string , buildProperties props. PropertiesMap , includes []string , verbose bool , warningsLevel string , logger i18n.Logger ) ([]string , error ) {
46
+ func CompileFilesRecursive (objectFiles []string , sourcePath string , buildPath string , buildProperties properties. Map , includes []string , verbose bool , warningsLevel string , logger i18n.Logger ) ([]string , error ) {
46
47
objectFiles , err := CompileFiles (objectFiles , sourcePath , false , buildPath , buildProperties , includes , verbose , warningsLevel , logger )
47
48
if err != nil {
48
49
return nil , i18n .WrapError (err )
@@ -63,7 +64,7 @@ func CompileFilesRecursive(objectFiles []string, sourcePath string, buildPath st
63
64
return objectFiles , nil
64
65
}
65
66
66
- func CompileFiles (objectFiles []string , sourcePath string , recurse bool , buildPath string , buildProperties props. PropertiesMap , includes []string , verbose bool , warningsLevel string , logger i18n.Logger ) ([]string , error ) {
67
+ func CompileFiles (objectFiles []string , sourcePath string , recurse bool , buildPath string , buildProperties properties. Map , includes []string , verbose bool , warningsLevel string , logger i18n.Logger ) ([]string , error ) {
67
68
objectFiles , err := compileFilesWithExtensionWithRecipe (objectFiles , sourcePath , recurse , buildPath , buildProperties , includes , ".S" , constants .RECIPE_S_PATTERN , verbose , warningsLevel , logger )
68
69
if err != nil {
69
70
return nil , i18n .WrapError (err )
@@ -79,7 +80,7 @@ func CompileFiles(objectFiles []string, sourcePath string, recurse bool, buildPa
79
80
return objectFiles , nil
80
81
}
81
82
82
- func compileFilesWithExtensionWithRecipe (objectFiles []string , sourcePath string , recurse bool , buildPath string , buildProperties props. PropertiesMap , includes []string , extension string , recipe string , verbose bool , warningsLevel string , logger i18n.Logger ) ([]string , error ) {
83
+ func compileFilesWithExtensionWithRecipe (objectFiles []string , sourcePath string , recurse bool , buildPath string , buildProperties properties. Map , includes []string , extension string , recipe string , verbose bool , warningsLevel string , logger i18n.Logger ) ([]string , error ) {
83
84
sources , err := findFilesInFolder (sourcePath , extension , recurse )
84
85
if err != nil {
85
86
return nil , i18n .WrapError (err )
@@ -115,7 +116,7 @@ func findFilesInFolder(sourcePath string, extension string, recurse bool) ([]str
115
116
return sources , nil
116
117
}
117
118
118
- func compileFilesWithRecipe (objectFiles []string , sourcePath string , sources []string , buildPath string , buildProperties props. PropertiesMap , includes []string , recipe string , verbose bool , warningsLevel string , logger i18n.Logger ) ([]string , error ) {
119
+ func compileFilesWithRecipe (objectFiles []string , sourcePath string , sources []string , buildPath string , buildProperties properties. Map , includes []string , recipe string , verbose bool , warningsLevel string , logger i18n.Logger ) ([]string , error ) {
119
120
for _ , source := range sources {
120
121
objectFile , err := compileFileWithRecipe (sourcePath , source , buildPath , buildProperties , includes , recipe , verbose , warningsLevel , logger )
121
122
if err != nil {
@@ -127,7 +128,7 @@ func compileFilesWithRecipe(objectFiles []string, sourcePath string, sources []s
127
128
return objectFiles , nil
128
129
}
129
130
130
- func compileFileWithRecipe (sourcePath string , source string , buildPath string , buildProperties props. PropertiesMap , includes []string , recipe string , verbose bool , warningsLevel string , logger i18n.Logger ) (string , error ) {
131
+ func compileFileWithRecipe (sourcePath string , source string , buildPath string , buildProperties properties. Map , includes []string , recipe string , verbose bool , warningsLevel string , logger i18n.Logger ) (string , error ) {
131
132
properties := buildProperties .Clone ()
132
133
properties [constants .BUILD_PROPERTIES_COMPILER_WARNING_FLAGS ] = properties [constants .BUILD_PROPERTIES_COMPILER_WARNING_FLAGS + "." + warningsLevel ]
133
134
properties [constants .BUILD_PROPERTIES_INCLUDES ] = strings .Join (includes , constants .SPACE )
@@ -257,7 +258,7 @@ func nonEmptyString(s string) bool {
257
258
return s != constants .EMPTY_STRING
258
259
}
259
260
260
- func ArchiveCompiledFiles (buildPath string , archiveFile string , objectFiles []string , buildProperties props. PropertiesMap , verbose bool , logger i18n.Logger ) (string , error ) {
261
+ func ArchiveCompiledFiles (buildPath string , archiveFile string , objectFiles []string , buildProperties properties. Map , verbose bool , logger i18n.Logger ) (string , error ) {
261
262
archiveFilePath := filepath .Join (buildPath , archiveFile )
262
263
if _ , err := os .Stat (archiveFilePath ); err == nil {
263
264
err = os .Remove (archiveFilePath )
@@ -281,7 +282,7 @@ func ArchiveCompiledFiles(buildPath string, archiveFile string, objectFiles []st
281
282
return archiveFilePath , nil
282
283
}
283
284
284
- func ExecRecipe (properties props. PropertiesMap , recipe string , removeUnsetProperties bool , echoCommandLine bool , echoOutput bool , logger i18n.Logger ) ([]byte , error ) {
285
+ func ExecRecipe (properties properties. Map , recipe string , removeUnsetProperties bool , echoCommandLine bool , echoOutput bool , logger i18n.Logger ) ([]byte , error ) {
285
286
command , err := PrepareCommandForRecipe (properties , recipe , removeUnsetProperties , echoCommandLine , echoOutput , logger )
286
287
if err != nil {
287
288
return nil , i18n .WrapError (err )
@@ -302,16 +303,16 @@ func ExecRecipe(properties props.PropertiesMap, recipe string, removeUnsetProper
302
303
return bytes , i18n .WrapError (err )
303
304
}
304
305
305
- func PrepareCommandForRecipe (properties props. PropertiesMap , recipe string , removeUnsetProperties bool , echoCommandLine bool , echoOutput bool , logger i18n.Logger ) (* exec.Cmd , error ) {
306
- pattern := properties [recipe ]
306
+ func PrepareCommandForRecipe (buildProperties properties. Map , recipe string , removeUnsetProperties bool , echoCommandLine bool , echoOutput bool , logger i18n.Logger ) (* exec.Cmd , error ) {
307
+ pattern := buildProperties [recipe ]
307
308
if pattern == constants .EMPTY_STRING {
308
309
return nil , i18n .ErrorfWithLogger (logger , constants .MSG_PATTERN_MISSING , recipe )
309
310
}
310
311
311
312
var err error
312
- commandLine := properties .ExpandPropsInString (pattern )
313
+ commandLine := buildProperties .ExpandPropsInString (pattern )
313
314
if removeUnsetProperties {
314
- commandLine , err = props .DeleteUnexpandedPropsFromString (commandLine )
315
+ commandLine , err = properties .DeleteUnexpandedPropsFromString (commandLine )
315
316
if err != nil {
316
317
return nil , i18n .WrapError (err )
317
318
}
@@ -329,8 +330,8 @@ func PrepareCommandForRecipe(properties props.PropertiesMap, recipe string, remo
329
330
return command , nil
330
331
}
331
332
332
- func ExecRecipeCollectStdErr (properties props. PropertiesMap , recipe string , removeUnsetProperties bool , echoCommandLine bool , echoOutput bool , logger i18n.Logger ) (string , error ) {
333
- command , err := PrepareCommandForRecipe (properties , recipe , removeUnsetProperties , echoCommandLine , echoOutput , logger )
333
+ func ExecRecipeCollectStdErr (buildProperties properties. Map , recipe string , removeUnsetProperties bool , echoCommandLine bool , echoOutput bool , logger i18n.Logger ) (string , error ) {
334
+ command , err := PrepareCommandForRecipe (buildProperties , recipe , removeUnsetProperties , echoCommandLine , echoOutput , logger )
334
335
if err != nil {
335
336
return "" , i18n .WrapError (err )
336
337
}
@@ -341,6 +342,6 @@ func ExecRecipeCollectStdErr(properties props.PropertiesMap, recipe string, remo
341
342
return string (buffer .Bytes ()), nil
342
343
}
343
344
344
- func RemoveHyphenMDDFlagFromGCCCommandLine (properties props. PropertiesMap ) {
345
- properties [constants .BUILD_PROPERTIES_COMPILER_CPP_FLAGS ] = strings .Replace (properties [constants .BUILD_PROPERTIES_COMPILER_CPP_FLAGS ], "-MMD" , "" , - 1 )
345
+ func RemoveHyphenMDDFlagFromGCCCommandLine (buildProperties properties. Map ) {
346
+ buildProperties [constants .BUILD_PROPERTIES_COMPILER_CPP_FLAGS ] = strings .Replace (buildProperties [constants .BUILD_PROPERTIES_COMPILER_CPP_FLAGS ], "-MMD" , "" , - 1 )
346
347
}
0 commit comments