@@ -35,8 +35,6 @@ import (
3535 "arduino.cc/builder/i18n"
3636 "arduino.cc/builder/utils"
3737 "os"
38- "path/filepath"
39- "strings"
4038)
4139
4240type CoreBuilder struct {}
@@ -53,17 +51,17 @@ func (s *CoreBuilder) Run(context map[string]interface{}) error {
5351 return utils .WrapError (err )
5452 }
5553
56- objectFiles , err := compileCore (coreBuildPath , buildProperties , verbose , warningsLevel , logger )
54+ archiveFile , err := compileCore (coreBuildPath , buildProperties , verbose , warningsLevel , logger )
5755 if err != nil {
5856 return utils .WrapError (err )
5957 }
6058
61- context [constants .CTX_OBJECT_FILES_CORE ] = objectFiles
59+ context [constants .CTX_ARCHIVE_FILE_PATH_CORE ] = archiveFile
6260
6361 return nil
6462}
6563
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 ) {
6765 var objectFiles []string
6866 coreFolder := buildProperties [constants .BUILD_PROPERTIES_BUILD_CORE_PATH ]
6967 variantFolder := buildProperties [constants .BUILD_PROPERTIES_BUILD_VARIANT_PATH ]
@@ -80,34 +78,19 @@ func compileCore(buildPath string, buildProperties map[string]string, verbose bo
8078 if variantFolder != constants .EMPTY_STRING {
8179 objectFiles , err = builder_utils .CompileFiles (objectFiles , variantFolder , true , buildPath , buildProperties , includes , verbose , warningsLevel , logger )
8280 if err != nil {
83- return nil , utils .WrapError (err )
81+ return "" , utils .WrapError (err )
8482 }
8583 }
8684
8785 coreObjectFiles , err := builder_utils .CompileFiles ([]string {}, coreFolder , true , buildPath , buildProperties , includes , verbose , warningsLevel , logger )
8886 if err != nil {
89- return nil , utils .WrapError (err )
87+ return "" , utils .WrapError (err )
9088 }
9189
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 )
11093 }
11194
112- return objectFiles , nil
95+ return archiveFile , nil
11396}
0 commit comments