Skip to content

Commit 08f193f

Browse files
author
Federico Fissore
committed
When compiling libraries, don't use a shared accumulator for all libraries
Fixes #36 Signed-off-by: Federico Fissore <[email protected]>
1 parent 505bb8a commit 08f193f

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

Diff for: src/arduino.cc/builder/phases/libraries_builder.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,28 @@ func (s *LibrariesBuilder) Run(context map[string]interface{}) error {
6767
}
6868

6969
func compileLibraries(libraries []*types.Library, buildPath string, buildProperties map[string]string, includes []string, verbose bool, warningsLevel string, logger i18n.Logger) ([]string, error) {
70-
var err error
71-
var objectFiles []string
70+
objectFiles := []string{}
7271
for _, library := range libraries {
73-
objectFiles, err = compileLibrary(objectFiles, library, buildPath, buildProperties, includes, verbose, warningsLevel, logger)
72+
libraryObjectFiles, err := compileLibrary(library, buildPath, buildProperties, includes, verbose, warningsLevel, logger)
7473
if err != nil {
7574
return nil, utils.WrapError(err)
7675
}
76+
objectFiles = append(objectFiles, libraryObjectFiles...)
7777
}
7878

7979
return objectFiles, nil
8080

8181
}
8282

83-
func compileLibrary(objectFiles []string, library *types.Library, buildPath string, buildProperties map[string]string, includes []string, verbose bool, warningsLevel string, logger i18n.Logger) ([]string, error) {
83+
func compileLibrary(library *types.Library, buildPath string, buildProperties map[string]string, includes []string, verbose bool, warningsLevel string, logger i18n.Logger) ([]string, error) {
8484
libraryBuildPath := filepath.Join(buildPath, library.Name)
8585

8686
err := os.MkdirAll(libraryBuildPath, os.FileMode(0755))
8787
if err != nil {
8888
return nil, utils.WrapError(err)
8989
}
9090

91+
objectFiles := []string{}
9192
if library.Layout == types.LIBRARY_RECURSIVE {
9293
objectFiles, err = builder_utils.CompileFilesRecursive(objectFiles, library.SrcFolder, libraryBuildPath, buildProperties, includes, verbose, warningsLevel, logger)
9394
if err != nil {

Diff for: src/arduino.cc/builder/test/builder_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ func TestBuilderALinkage(t *testing.T) {
296296
297297
context[constants.CTX_HARDWARE_FOLDERS] = []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware", "downloaded_board_manager_stuff"}
298298
context[constants.CTX_TOOLS_FOLDERS] = []string{"downloaded_tools", "downloaded_board_manager_stuff"}
299-
context[constants.CTX_LIBRARIES_FOLDERS] = []string{"libraries", "downloaded_libraries"}
300-
context[constants.CTX_FQBN] = "arduino:avr:leonardo"
301-
context[constants.CTX_SKETCH_LOCATION] = filepath.Join("downloaded_libraries", "HID", "examples", "NKROKeyboard", "NKROKeyboard.ino")
299+
context[constants.CTX_LIBRARIES_FOLDERS] = []string{"downloaded_libraries"}
300+
context[constants.CTX_FQBN] = "arduino:avr:robotControl"
301+
context[constants.CTX_SKETCH_LOCATION] = filepath.Join("sketch9", "sketch.ino")
302302
context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION] = "10600"
303303
context[constants.CTX_VERBOSE] = true
304304

Diff for: src/arduino.cc/builder/test/downloaded_libraries/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ A*
22
B*
33
C*
44
H*
5+
P*
56
R*

Diff for: src/arduino.cc/builder/test/helper_tools_downloader.go

-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ func DownloadCoresAndToolsAndLibraries(t *testing.T) {
130130
Library{Name: "Bridge", Version: "1.0.7"},
131131
Library{Name: "CapacitiveSensor", Version: "0.5.0"},
132132
Library{Name: "Robot IR Remote", Version: "1.0.2"},
133-
//Library{Name: "HID", Version: "0.0.0", Url: "https://github.com/NicoHood/HID/archive/dev_2_4.zip"},
134133
}
135134

136135
download(t, cores, boardsManagerCores, boardsManagerRedBearCores, tools, boardsManagerTools, boardsManagerRFduinoTools, libraries)

Diff for: src/arduino.cc/builder/test/sketch9/sketch.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
#include <IRremote.h>
33
#include <IRremoteInt.h>
44

5-
void setup {}
6-
void main {}
5+
void setup() {}
6+
void loop() {}

0 commit comments

Comments
 (0)