Skip to content

Commit c7a18f8

Browse files
author
Federico Fissore
committed
Sketch sources files were recursively copied BUT not compiled. See
arduino/Arduino#1004 (comment) Signed-off-by: Federico Fissore <[email protected]>
1 parent 278b13e commit c7a18f8

File tree

6 files changed

+56
-2
lines changed

6 files changed

+56
-2
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (s *SketchBuilder) Run(context map[string]interface{}) error {
5454
}
5555

5656
var objectFiles []string
57-
objectFiles, err = builder_utils.CompileFiles(objectFiles, sketchBuildPath, false, sketchBuildPath, buildProperties, includes, verbose, warningsLevel, logger)
57+
objectFiles, err = builder_utils.CompileFiles(objectFiles, sketchBuildPath, true, sketchBuildPath, buildProperties, includes, verbose, warningsLevel, logger)
5858
if err != nil {
5959
return utils.WrapError(err)
6060
}

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

+21
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,24 @@ func TestBuilderSketchWithOldLib(t *testing.T) {
313313
err := command.Run(context)
314314
NoError(t, err)
315315
}
316+
317+
func TestBuilderSketchWithSubfolders(t *testing.T) {
318+
DownloadCoresAndToolsAndLibraries(t)
319+
320+
context := make(map[string]interface{})
321+
322+
buildPath := SetupBuildPath(t, context)
323+
defer os.RemoveAll(buildPath)
324+
325+
context[constants.CTX_HARDWARE_FOLDERS] = []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"}
326+
context[constants.CTX_TOOLS_FOLDERS] = []string{"downloaded_tools"}
327+
context[constants.CTX_FQBN] = "arduino:avr:uno"
328+
context[constants.CTX_SKETCH_LOCATION] = filepath.Join("sketch_with_subfolders", "sketch_with_subfolders.ino")
329+
context[constants.CTX_BUILT_IN_LIBRARIES_FOLDERS] = []string{"downloaded_libraries"}
330+
context[constants.CTX_OTHER_LIBRARIES_FOLDERS] = []string{"libraries"}
331+
context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION] = "10600"
332+
333+
command := builder.Builder{}
334+
err := command.Run(context)
335+
NoError(t, err)
336+
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ func TestLoadSketchFromFolder(t *testing.T) {
136136

137137
require.True(t, strings.Index(sketch.MainFile.Name, "sketch_with_subfolders.ino") != -1)
138138

139-
require.Equal(t, 1, len(sketch.AdditionalFiles))
139+
require.Equal(t, 2, len(sketch.AdditionalFiles))
140140
require.True(t, strings.Index(sketch.AdditionalFiles[0].Name, "other.cpp") != -1)
141+
require.True(t, strings.Index(sketch.AdditionalFiles[1].Name, "other.h") != -1)
141142
}
142143

143144
func TestLoadSketchWithBackup(t *testing.T) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "subfolder/other.h"
2+
3+
MyClass myClass;
4+
5+
void setup() {
6+
myClass.init ( &Serial );
7+
}
8+
9+
void loop() {
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <Arduino.h> // Arduino 1.0
2+
3+
#include "other.h"
4+
5+
MyClass::MyClass() {
6+
}
7+
8+
void MyClass::init ( Stream *stream ) {
9+
controllerStream = stream;
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef other__h
2+
#define other__h
3+
4+
class MyClass {
5+
public:
6+
MyClass();
7+
void init ( Stream *controllerStream );
8+
9+
private:
10+
Stream *controllerStream;
11+
};
12+
#endif

0 commit comments

Comments
 (0)