@@ -35,8 +35,6 @@ import (
35
35
"arduino.cc/builder/i18n"
36
36
"arduino.cc/builder/utils"
37
37
"os"
38
- "path/filepath"
39
- "strings"
40
38
)
41
39
42
40
type CoreBuilder struct {}
@@ -53,17 +51,17 @@ func (s *CoreBuilder) Run(context map[string]interface{}) error {
53
51
return utils .WrapError (err )
54
52
}
55
53
56
- objectFiles , err := compileCore (coreBuildPath , buildProperties , verbose , warningsLevel , logger )
54
+ archiveFile , err := compileCore (coreBuildPath , buildProperties , verbose , warningsLevel , logger )
57
55
if err != nil {
58
56
return utils .WrapError (err )
59
57
}
60
58
61
- context [constants .CTX_OBJECT_FILES_CORE ] = objectFiles
59
+ context [constants .CTX_ARCHIVE_FILE_PATH_CORE ] = archiveFile
62
60
63
61
return nil
64
62
}
65
63
66
- func compileCore (buildPath string , buildProperties map [string ]string , verbose bool , warningsLevel string , logger i18n.Logger ) ([] string , error ) {
64
+ func compileCore (buildPath string , buildProperties map [string ]string , verbose bool , warningsLevel string , logger i18n.Logger ) (string , error ) {
67
65
var objectFiles []string
68
66
coreFolder := buildProperties [constants .BUILD_PROPERTIES_BUILD_CORE_PATH ]
69
67
variantFolder := buildProperties [constants .BUILD_PROPERTIES_BUILD_VARIANT_PATH ]
@@ -80,34 +78,19 @@ func compileCore(buildPath string, buildProperties map[string]string, verbose bo
80
78
if variantFolder != constants .EMPTY_STRING {
81
79
objectFiles , err = builder_utils .CompileFiles (objectFiles , variantFolder , true , buildPath , buildProperties , includes , verbose , warningsLevel , logger )
82
80
if err != nil {
83
- return nil , utils .WrapError (err )
81
+ return "" , utils .WrapError (err )
84
82
}
85
83
}
86
84
87
85
coreObjectFiles , err := builder_utils .CompileFiles ([]string {}, coreFolder , true , buildPath , buildProperties , includes , verbose , warningsLevel , logger )
88
86
if err != nil {
89
- return nil , utils .WrapError (err )
87
+ return "" , utils .WrapError (err )
90
88
}
91
89
92
- coreArchiveFilePath := filepath .Join (buildPath , "core.a" )
93
- if _ , err := os .Stat (coreArchiveFilePath ); err == nil {
94
- err = os .Remove (coreArchiveFilePath )
95
- if err != nil {
96
- return nil , utils .WrapError (err )
97
- }
98
- }
99
-
100
- for _ , coreObjectFile := range coreObjectFiles {
101
- properties := utils .MergeMapsOfStrings (make (map [string ]string ), buildProperties )
102
- properties [constants .BUILD_PROPERTIES_INCLUDES ] = strings .Join (includes , constants .SPACE )
103
- properties [constants .BUILD_PROPERTIES_ARCHIVE_FILE ] = filepath .Base (coreArchiveFilePath )
104
- properties [constants .BUILD_PROPERTIES_OBJECT_FILE ] = coreObjectFile
105
-
106
- _ , err := builder_utils .ExecRecipe (properties , "recipe.ar.pattern" , false , verbose , verbose , logger )
107
- if err != nil {
108
- return nil , utils .WrapError (err )
109
- }
90
+ archiveFile , err := builder_utils .ArchiveCompiledFiles (buildPath , "core.a" , coreObjectFiles , buildProperties , verbose , logger )
91
+ if err != nil {
92
+ return "" , utils .WrapError (err )
110
93
}
111
94
112
- return objectFiles , nil
95
+ return archiveFile , nil
113
96
}
0 commit comments