3030package builder_utils
3131
3232import (
33- "arduino.cc/builder/constants"
34- "arduino.cc/builder/i18n"
35- "arduino.cc/builder/props"
36- "arduino.cc/builder/utils"
3733 "bytes"
3834 "fmt"
3935 "os"
4036 "os/exec"
4137 "path/filepath"
4238 "strings"
39+
40+ "arduino.cc/builder/constants"
41+ "arduino.cc/builder/i18n"
42+ "arduino.cc/builder/utils"
43+ "arduino.cc/properties"
4344)
4445
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 ) {
4647 objectFiles , err := CompileFiles (objectFiles , sourcePath , false , buildPath , buildProperties , includes , verbose , warningsLevel , logger )
4748 if err != nil {
4849 return nil , i18n .WrapError (err )
@@ -63,7 +64,7 @@ func CompileFilesRecursive(objectFiles []string, sourcePath string, buildPath st
6364 return objectFiles , nil
6465}
6566
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 ) {
6768 objectFiles , err := compileFilesWithExtensionWithRecipe (objectFiles , sourcePath , recurse , buildPath , buildProperties , includes , ".S" , constants .RECIPE_S_PATTERN , verbose , warningsLevel , logger )
6869 if err != nil {
6970 return nil , i18n .WrapError (err )
@@ -79,7 +80,7 @@ func CompileFiles(objectFiles []string, sourcePath string, recurse bool, buildPa
7980 return objectFiles , nil
8081}
8182
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 ) {
8384 sources , err := findFilesInFolder (sourcePath , extension , recurse )
8485 if err != nil {
8586 return nil , i18n .WrapError (err )
@@ -115,7 +116,7 @@ func findFilesInFolder(sourcePath string, extension string, recurse bool) ([]str
115116 return sources , nil
116117}
117118
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 ) {
119120 for _ , source := range sources {
120121 objectFile , err := compileFileWithRecipe (sourcePath , source , buildPath , buildProperties , includes , recipe , verbose , warningsLevel , logger )
121122 if err != nil {
@@ -127,7 +128,7 @@ func compileFilesWithRecipe(objectFiles []string, sourcePath string, sources []s
127128 return objectFiles , nil
128129}
129130
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 ) {
131132 properties := buildProperties .Clone ()
132133 properties [constants .BUILD_PROPERTIES_COMPILER_WARNING_FLAGS ] = properties [constants .BUILD_PROPERTIES_COMPILER_WARNING_FLAGS + "." + warningsLevel ]
133134 properties [constants .BUILD_PROPERTIES_INCLUDES ] = strings .Join (includes , constants .SPACE )
@@ -257,7 +258,7 @@ func nonEmptyString(s string) bool {
257258 return s != constants .EMPTY_STRING
258259}
259260
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 ) {
261262 archiveFilePath := filepath .Join (buildPath , archiveFile )
262263 if _ , err := os .Stat (archiveFilePath ); err == nil {
263264 err = os .Remove (archiveFilePath )
@@ -281,7 +282,7 @@ func ArchiveCompiledFiles(buildPath string, archiveFile string, objectFiles []st
281282 return archiveFilePath , nil
282283}
283284
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 ) {
285286 command , err := PrepareCommandForRecipe (properties , recipe , removeUnsetProperties , echoCommandLine , echoOutput , logger )
286287 if err != nil {
287288 return nil , i18n .WrapError (err )
@@ -302,16 +303,16 @@ func ExecRecipe(properties props.PropertiesMap, recipe string, removeUnsetProper
302303 return bytes , i18n .WrapError (err )
303304}
304305
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 ]
307308 if pattern == constants .EMPTY_STRING {
308309 return nil , i18n .ErrorfWithLogger (logger , constants .MSG_PATTERN_MISSING , recipe )
309310 }
310311
311312 var err error
312- commandLine := properties .ExpandPropsInString (pattern )
313+ commandLine := buildProperties .ExpandPropsInString (pattern )
313314 if removeUnsetProperties {
314- commandLine , err = props .DeleteUnexpandedPropsFromString (commandLine )
315+ commandLine , err = properties .DeleteUnexpandedPropsFromString (commandLine )
315316 if err != nil {
316317 return nil , i18n .WrapError (err )
317318 }
@@ -329,8 +330,8 @@ func PrepareCommandForRecipe(properties props.PropertiesMap, recipe string, remo
329330 return command , nil
330331}
331332
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 )
334335 if err != nil {
335336 return "" , i18n .WrapError (err )
336337 }
@@ -341,6 +342,6 @@ func ExecRecipeCollectStdErr(properties props.PropertiesMap, recipe string, remo
341342 return string (buffer .Bytes ()), nil
342343}
343344
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 )
346347}
0 commit comments