Skip to content

Commit 2361bc2

Browse files
author
Federico Fissore
committed
Removing -MDD flag (if present) from preproc command line as it produces unwanted .d files
Signed-off-by: Federico Fissore <[email protected]>
1 parent d18cb98 commit 2361bc2

File tree

5 files changed

+7
-38
lines changed

5 files changed

+7
-38
lines changed

Diff for: main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import (
4444
"syscall"
4545
)
4646

47-
const VERSION = "1.0.0-beta1"
47+
const VERSION = "1.0.0-beta2"
4848

4949
type slice []string
5050

Diff for: src/arduino.cc/builder/constants/constants.go

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const BUILD_PROPERTIES_BUILD_PROJECT_NAME = "build.project_name"
4545
const BUILD_PROPERTIES_BUILD_SYSTEM_PATH = "build.system.path"
4646
const BUILD_PROPERTIES_BUILD_VARIANT = "build.variant"
4747
const BUILD_PROPERTIES_BUILD_VARIANT_PATH = "build.variant.path"
48+
const BUILD_PROPERTIES_COMPILER_CPP_FLAGS = "compiler.cpp.flags"
4849
const BUILD_PROPERTIES_COMPILER_PATH = "compiler.path"
4950
const BUILD_PROPERTIES_COMPILER_WARNING_FLAGS = "compiler.warning_flags"
5051
const BUILD_PROPERTIES_INCLUDES = "includes"

Diff for: src/arduino.cc/builder/gcc_preproc_runner.go

+5
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func (s *GCCPreprocRunner) Run(context map[string]interface{}) error {
5252
includes := context[constants.CTX_INCLUDE_FOLDERS].([]string)
5353
includes = utils.Map(includes, utils.WrapWithHyphenI)
5454
properties[constants.BUILD_PROPERTIES_INCLUDES] = strings.Join(includes, constants.SPACE)
55+
removingHyphenMDDFlagFromGCCCommandLine(properties)
5556

5657
verbose := context[constants.CTX_VERBOSE].(bool)
5758
logger := context[constants.CTX_LOGGER].(i18n.Logger)
@@ -64,3 +65,7 @@ func (s *GCCPreprocRunner) Run(context map[string]interface{}) error {
6465

6566
return nil
6667
}
68+
69+
func removingHyphenMDDFlagFromGCCCommandLine(properties map[string]string) {
70+
properties[constants.BUILD_PROPERTIES_COMPILER_CPP_FLAGS] = strings.Replace(properties[constants.BUILD_PROPERTIES_COMPILER_CPP_FLAGS], "-MMD", "", -1)
71+
}

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

-19
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,11 @@ package test
3232
import (
3333
"arduino.cc/builder/constants"
3434
"arduino.cc/builder/types"
35-
"arduino.cc/builder/utils"
3635
"fmt"
3736
"github.com/go-errors/errors"
3837
"github.com/stretchr/testify/assert"
3938
"io/ioutil"
40-
"os"
4139
"path/filepath"
42-
"strings"
4340
"testing"
4441
)
4542

@@ -77,19 +74,3 @@ func (s ByLibraryName) Swap(i, j int) {
7774
func (s ByLibraryName) Less(i, j int) bool {
7875
return s[i].Name < s[j].Name
7976
}
80-
81-
func DeleteAnyDotDFile() error {
82-
files, err := ioutil.ReadDir(".")
83-
if err != nil {
84-
return utils.WrapError(err)
85-
}
86-
for _, file := range files {
87-
if !file.IsDir() && strings.HasSuffix(file.Name(), ".d") {
88-
err := os.Remove(file.Name())
89-
if err != nil {
90-
return utils.WrapError(err)
91-
}
92-
}
93-
}
94-
return nil
95-
}

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

-18
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ func TestPrototypesAdderBridgeExample(t *testing.T) {
7979

8080
require.Equal(t, "#include <Arduino.h>\n#line 1\n", context[constants.CTX_INCLUDE_SECTION].(string))
8181
require.Equal(t, "void setup();\nvoid loop();\nvoid process(YunClient client);\nvoid digitalCommand(YunClient client);\nvoid analogCommand(YunClient client);\nvoid modeCommand(YunClient client);\n#line 33\n", context[constants.CTX_PROTOTYPE_SECTION].(string))
82-
83-
NoError(t, DeleteAnyDotDFile())
8482
}
8583

8684
func TestPrototypesAdderSketchWithIfDef(t *testing.T) {
@@ -125,8 +123,6 @@ func TestPrototypesAdderSketchWithIfDef(t *testing.T) {
125123
preprocessed := string(bytes)
126124

127125
require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))
128-
129-
NoError(t, DeleteAnyDotDFile())
130126
}
131127

132128
func TestPrototypesAdderBaladuino(t *testing.T) {
@@ -171,8 +167,6 @@ func TestPrototypesAdderBaladuino(t *testing.T) {
171167
preprocessed := string(bytes)
172168

173169
require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))
174-
175-
NoError(t, DeleteAnyDotDFile())
176170
}
177171

178172
func TestPrototypesAdderCharWithEscapedDoubleQuote(t *testing.T) {
@@ -217,8 +211,6 @@ func TestPrototypesAdderCharWithEscapedDoubleQuote(t *testing.T) {
217211
preprocessed := string(bytes)
218212

219213
require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))
220-
221-
NoError(t, DeleteAnyDotDFile())
222214
}
223215

224216
func TestPrototypesAdderIncludeBetweenMultilineComment(t *testing.T) {
@@ -263,8 +255,6 @@ func TestPrototypesAdderIncludeBetweenMultilineComment(t *testing.T) {
263255
preprocessed := string(bytes)
264256

265257
require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))
266-
267-
NoError(t, DeleteAnyDotDFile())
268258
}
269259

270260
func TestPrototypesAdderLineContinuations(t *testing.T) {
@@ -309,8 +299,6 @@ func TestPrototypesAdderLineContinuations(t *testing.T) {
309299
preprocessed := string(bytes)
310300

311301
require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))
312-
313-
NoError(t, DeleteAnyDotDFile())
314302
}
315303

316304
func TestPrototypesAdderStringWithComment(t *testing.T) {
@@ -355,8 +343,6 @@ func TestPrototypesAdderStringWithComment(t *testing.T) {
355343
preprocessed := string(bytes)
356344

357345
require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))
358-
359-
NoError(t, DeleteAnyDotDFile())
360346
}
361347

362348
func TestPrototypesAdderSketchWithStruct(t *testing.T) {
@@ -401,8 +387,6 @@ func TestPrototypesAdderSketchWithStruct(t *testing.T) {
401387
preprocessed := string(bytes)
402388

403389
require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))
404-
405-
NoError(t, DeleteAnyDotDFile())
406390
}
407391

408392
func TestPrototypesAdderSketchWithConfig(t *testing.T) {
@@ -450,6 +434,4 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
450434
preprocessed := string(bytes)
451435

452436
require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))
453-
454-
NoError(t, DeleteAnyDotDFile())
455437
}

0 commit comments

Comments
 (0)