@@ -42,7 +42,7 @@ import (
42
42
"github.com/arduino/arduino-builder/types"
43
43
"github.com/arduino/arduino-builder/utils"
44
44
"github.com/arduino/go-paths-helper"
45
- "github.com/arduino/go-properties-map "
45
+ "github.com/arduino/go-properties-orderedmap "
46
46
)
47
47
48
48
func PrintProgressIfProgressEnabledAndMachineLogger (ctx * types.Context ) {
@@ -58,7 +58,7 @@ func PrintProgressIfProgressEnabledAndMachineLogger(ctx *types.Context) {
58
58
}
59
59
}
60
60
61
- func CompileFilesRecursive (ctx * types.Context , sourcePath * paths.Path , buildPath * paths.Path , buildProperties properties.Map , includes []string ) (paths.PathList , error ) {
61
+ func CompileFilesRecursive (ctx * types.Context , sourcePath * paths.Path , buildPath * paths.Path , buildProperties * properties.Map , includes []string ) (paths.PathList , error ) {
62
62
objectFiles , err := CompileFiles (ctx , sourcePath , false , buildPath , buildProperties , includes )
63
63
if err != nil {
64
64
return nil , i18n .WrapError (err )
@@ -80,7 +80,7 @@ func CompileFilesRecursive(ctx *types.Context, sourcePath *paths.Path, buildPath
80
80
return objectFiles , nil
81
81
}
82
82
83
- func CompileFiles (ctx * types.Context , sourcePath * paths.Path , recurse bool , buildPath * paths.Path , buildProperties properties.Map , includes []string ) (paths.PathList , error ) {
83
+ func CompileFiles (ctx * types.Context , sourcePath * paths.Path , recurse bool , buildPath * paths.Path , buildProperties * properties.Map , includes []string ) (paths.PathList , error ) {
84
84
sObjectFiles , err := compileFilesWithExtensionWithRecipe (ctx , sourcePath , recurse , buildPath , buildProperties , includes , ".S" , constants .RECIPE_S_PATTERN )
85
85
if err != nil {
86
86
return nil , i18n .WrapError (err )
@@ -100,7 +100,7 @@ func CompileFiles(ctx *types.Context, sourcePath *paths.Path, recurse bool, buil
100
100
return objectFiles , nil
101
101
}
102
102
103
- func compileFilesWithExtensionWithRecipe (ctx * types.Context , sourcePath * paths.Path , recurse bool , buildPath * paths.Path , buildProperties properties.Map , includes []string , extension string , recipe string ) (paths.PathList , error ) {
103
+ func compileFilesWithExtensionWithRecipe (ctx * types.Context , sourcePath * paths.Path , recurse bool , buildPath * paths.Path , buildProperties * properties.Map , includes []string , extension string , recipe string ) (paths.PathList , error ) {
104
104
sources , err := findFilesInFolder (sourcePath , extension , recurse )
105
105
if err != nil {
106
106
return nil , i18n .WrapError (err )
@@ -164,7 +164,7 @@ func findAllFilesInFolder(sourcePath string, recurse bool) ([]string, error) {
164
164
return sources , nil
165
165
}
166
166
167
- func compileFilesWithRecipe (ctx * types.Context , sourcePath * paths.Path , sources paths.PathList , buildPath * paths.Path , buildProperties properties.Map , includes []string , recipe string ) (paths.PathList , error ) {
167
+ func compileFilesWithRecipe (ctx * types.Context , sourcePath * paths.Path , sources paths.PathList , buildPath * paths.Path , buildProperties * properties.Map , includes []string , recipe string ) (paths.PathList , error ) {
168
168
objectFiles := paths .NewPathList ()
169
169
if len (sources ) == 0 {
170
170
return objectFiles , nil
@@ -212,19 +212,19 @@ func compileFilesWithRecipe(ctx *types.Context, sourcePath *paths.Path, sources
212
212
}
213
213
}
214
214
215
- func compileFileWithRecipe (ctx * types.Context , sourcePath * paths.Path , source * paths.Path , buildPath * paths.Path , buildProperties properties.Map , includes []string , recipe string ) (* paths.Path , error ) {
215
+ func compileFileWithRecipe (ctx * types.Context , sourcePath * paths.Path , source * paths.Path , buildPath * paths.Path , buildProperties * properties.Map , includes []string , recipe string ) (* paths.Path , error ) {
216
216
logger := ctx .GetLogger ()
217
217
properties := buildProperties .Clone ()
218
- properties [ constants .BUILD_PROPERTIES_COMPILER_WARNING_FLAGS ] = properties [ constants .BUILD_PROPERTIES_COMPILER_WARNING_FLAGS + "." + ctx .WarningsLevel ]
219
- properties [ constants .BUILD_PROPERTIES_INCLUDES ] = strings .Join (includes , constants .SPACE )
220
- properties [ constants .BUILD_PROPERTIES_SOURCE_FILE ] = source . String ( )
218
+ properties . Set ( constants .BUILD_PROPERTIES_COMPILER_WARNING_FLAGS , properties . Get ( constants .BUILD_PROPERTIES_COMPILER_WARNING_FLAGS + "." + ctx .WarningsLevel ))
219
+ properties . Set ( constants .BUILD_PROPERTIES_INCLUDES , strings .Join (includes , constants .SPACE ) )
220
+ properties . SetPath ( constants .BUILD_PROPERTIES_SOURCE_FILE , source )
221
221
relativeSource , err := sourcePath .RelTo (source )
222
222
if err != nil {
223
223
return nil , i18n .WrapError (err )
224
224
}
225
- properties [ constants .BUILD_PROPERTIES_OBJECT_FILE ] = buildPath .JoinPath (relativeSource ).String () + ".o"
225
+ properties . Set ( constants .BUILD_PROPERTIES_OBJECT_FILE , buildPath .JoinPath (relativeSource ).String ()+ ".o" )
226
226
227
- err = paths . New ( properties [ constants .BUILD_PROPERTIES_OBJECT_FILE ] ).Parent ().MkdirAll ()
227
+ err = properties . GetPath ( constants .BUILD_PROPERTIES_OBJECT_FILE ).Parent ().MkdirAll ()
228
228
if err != nil {
229
229
return nil , i18n .WrapError (err )
230
230
}
@@ -240,10 +240,10 @@ func compileFileWithRecipe(ctx *types.Context, sourcePath *paths.Path, source *p
240
240
return nil , i18n .WrapError (err )
241
241
}
242
242
} else if ctx .Verbose {
243
- logger .Println (constants .LOG_LEVEL_INFO , constants .MSG_USING_PREVIOUS_COMPILED_FILE , properties [ constants .BUILD_PROPERTIES_OBJECT_FILE ] )
243
+ logger .Println (constants .LOG_LEVEL_INFO , constants .MSG_USING_PREVIOUS_COMPILED_FILE , properties . Get ( constants .BUILD_PROPERTIES_OBJECT_FILE ) )
244
244
}
245
245
246
- return paths . New ( properties [ constants .BUILD_PROPERTIES_OBJECT_FILE ] ), nil
246
+ return properties . GetPath ( constants .BUILD_PROPERTIES_OBJECT_FILE ), nil
247
247
}
248
248
249
249
func ObjFileIsUpToDate (ctx * types.Context , sourceFile , objectFile , dependencyFile * paths.Path ) (bool , error ) {
@@ -430,7 +430,7 @@ func TXTBuildRulesHaveChanged(corePath, targetCorePath, targetFile *paths.Path)
430
430
return true
431
431
}
432
432
433
- func ArchiveCompiledFiles (ctx * types.Context , buildPath * paths.Path , archiveFile * paths.Path , objectFilesToArchive paths.PathList , buildProperties properties.Map ) (* paths.Path , error ) {
433
+ func ArchiveCompiledFiles (ctx * types.Context , buildPath * paths.Path , archiveFile * paths.Path , objectFilesToArchive paths.PathList , buildProperties * properties.Map ) (* paths.Path , error ) {
434
434
logger := ctx .GetLogger ()
435
435
archiveFilePath := buildPath .JoinPath (archiveFile )
436
436
@@ -463,9 +463,9 @@ func ArchiveCompiledFiles(ctx *types.Context, buildPath *paths.Path, archiveFile
463
463
464
464
for _ , objectFile := range objectFilesToArchive {
465
465
properties := buildProperties .Clone ()
466
- properties [ constants .BUILD_PROPERTIES_ARCHIVE_FILE ] = archiveFilePath .Base ()
467
- properties [ constants .BUILD_PROPERTIES_ARCHIVE_FILE_PATH ] = archiveFilePath . String ( )
468
- properties [ constants .BUILD_PROPERTIES_OBJECT_FILE ] = objectFile . String ( )
466
+ properties . Set ( constants .BUILD_PROPERTIES_ARCHIVE_FILE , archiveFilePath .Base () )
467
+ properties . SetPath ( constants .BUILD_PROPERTIES_ARCHIVE_FILE_PATH , archiveFilePath )
468
+ properties . SetPath ( constants .BUILD_PROPERTIES_OBJECT_FILE , objectFile )
469
469
470
470
_ , _ , err := ExecRecipe (ctx , properties , constants .RECIPE_AR_PATTERN , false /* stdout */ , utils .ShowIfVerbose /* stderr */ , utils .Show )
471
471
if err != nil {
@@ -476,7 +476,7 @@ func ArchiveCompiledFiles(ctx *types.Context, buildPath *paths.Path, archiveFile
476
476
return archiveFilePath , nil
477
477
}
478
478
479
- func ExecRecipe (ctx * types.Context , buildProperties properties.Map , recipe string , removeUnsetProperties bool , stdout int , stderr int ) ([]byte , []byte , error ) {
479
+ func ExecRecipe (ctx * types.Context , buildProperties * properties.Map , recipe string , removeUnsetProperties bool , stdout int , stderr int ) ([]byte , []byte , error ) {
480
480
// See util.ExecCommand for stdout/stderr arguments
481
481
command , err := PrepareCommandForRecipe (ctx , buildProperties , recipe , removeUnsetProperties )
482
482
if err != nil {
@@ -488,9 +488,9 @@ func ExecRecipe(ctx *types.Context, buildProperties properties.Map, recipe strin
488
488
489
489
const COMMANDLINE_LIMIT = 30000
490
490
491
- func PrepareCommandForRecipe (ctx * types.Context , buildProperties properties.Map , recipe string , removeUnsetProperties bool ) (* exec.Cmd , error ) {
491
+ func PrepareCommandForRecipe (ctx * types.Context , buildProperties * properties.Map , recipe string , removeUnsetProperties bool ) (* exec.Cmd , error ) {
492
492
logger := ctx .GetLogger ()
493
- pattern := buildProperties [ recipe ]
493
+ pattern := buildProperties . Get ( recipe )
494
494
if pattern == "" {
495
495
return nil , i18n .ErrorfWithLogger (logger , constants .MSG_PATTERN_MISSING , recipe )
496
496
}
@@ -504,7 +504,7 @@ func PrepareCommandForRecipe(ctx *types.Context, buildProperties properties.Map,
504
504
relativePath := ""
505
505
506
506
if len (commandLine ) > COMMANDLINE_LIMIT {
507
- relativePath = buildProperties [ "build.path" ]
507
+ relativePath = buildProperties . Get ( "build.path" )
508
508
}
509
509
510
510
command , err := utils .PrepareCommand (commandLine , logger , relativePath )
0 commit comments