Skip to content

Commit

Permalink
Removing -MDD flag (if present) from preproc command line as it produ…
Browse files Browse the repository at this point in the history
…ces unwanted .d files

Signed-off-by: Federico Fissore <[email protected]>
  • Loading branch information
Federico Fissore committed Sep 11, 2015
1 parent d18cb98 commit 2361bc2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 38 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
"syscall"
)

const VERSION = "1.0.0-beta1"
const VERSION = "1.0.0-beta2"

type slice []string

Expand Down
1 change: 1 addition & 0 deletions src/arduino.cc/builder/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const BUILD_PROPERTIES_BUILD_PROJECT_NAME = "build.project_name"
const BUILD_PROPERTIES_BUILD_SYSTEM_PATH = "build.system.path"
const BUILD_PROPERTIES_BUILD_VARIANT = "build.variant"
const BUILD_PROPERTIES_BUILD_VARIANT_PATH = "build.variant.path"
const BUILD_PROPERTIES_COMPILER_CPP_FLAGS = "compiler.cpp.flags"
const BUILD_PROPERTIES_COMPILER_PATH = "compiler.path"
const BUILD_PROPERTIES_COMPILER_WARNING_FLAGS = "compiler.warning_flags"
const BUILD_PROPERTIES_INCLUDES = "includes"
Expand Down
5 changes: 5 additions & 0 deletions src/arduino.cc/builder/gcc_preproc_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (s *GCCPreprocRunner) Run(context map[string]interface{}) error {
includes := context[constants.CTX_INCLUDE_FOLDERS].([]string)
includes = utils.Map(includes, utils.WrapWithHyphenI)
properties[constants.BUILD_PROPERTIES_INCLUDES] = strings.Join(includes, constants.SPACE)
removingHyphenMDDFlagFromGCCCommandLine(properties)

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

return nil
}

func removingHyphenMDDFlagFromGCCCommandLine(properties map[string]string) {
properties[constants.BUILD_PROPERTIES_COMPILER_CPP_FLAGS] = strings.Replace(properties[constants.BUILD_PROPERTIES_COMPILER_CPP_FLAGS], "-MMD", "", -1)

This comment has been minimized.

Copy link
@cmaglie

cmaglie Sep 13, 2015

Member

The dep-files .d are needed to check if a source file must be re-compiled, if you remove them the sketch is fully recompiled at every build wasting a lot of time (unless you found a better strategy to detect when a source file must be recompiled?).

}
19 changes: 0 additions & 19 deletions src/arduino.cc/builder/test/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@ package test
import (
"arduino.cc/builder/constants"
"arduino.cc/builder/types"
"arduino.cc/builder/utils"
"fmt"
"github.com/go-errors/errors"
"github.com/stretchr/testify/assert"
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
)

Expand Down Expand Up @@ -77,19 +74,3 @@ func (s ByLibraryName) Swap(i, j int) {
func (s ByLibraryName) Less(i, j int) bool {
return s[i].Name < s[j].Name
}

func DeleteAnyDotDFile() error {
files, err := ioutil.ReadDir(".")
if err != nil {
return utils.WrapError(err)
}
for _, file := range files {
if !file.IsDir() && strings.HasSuffix(file.Name(), ".d") {
err := os.Remove(file.Name())
if err != nil {
return utils.WrapError(err)
}
}
}
return nil
}
18 changes: 0 additions & 18 deletions src/arduino.cc/builder/test/prototypes_adder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ func TestPrototypesAdderBridgeExample(t *testing.T) {

require.Equal(t, "#include <Arduino.h>\n#line 1\n", context[constants.CTX_INCLUDE_SECTION].(string))
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))

NoError(t, DeleteAnyDotDFile())
}

func TestPrototypesAdderSketchWithIfDef(t *testing.T) {
Expand Down Expand Up @@ -125,8 +123,6 @@ func TestPrototypesAdderSketchWithIfDef(t *testing.T) {
preprocessed := string(bytes)

require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))

NoError(t, DeleteAnyDotDFile())
}

func TestPrototypesAdderBaladuino(t *testing.T) {
Expand Down Expand Up @@ -171,8 +167,6 @@ func TestPrototypesAdderBaladuino(t *testing.T) {
preprocessed := string(bytes)

require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))

NoError(t, DeleteAnyDotDFile())
}

func TestPrototypesAdderCharWithEscapedDoubleQuote(t *testing.T) {
Expand Down Expand Up @@ -217,8 +211,6 @@ func TestPrototypesAdderCharWithEscapedDoubleQuote(t *testing.T) {
preprocessed := string(bytes)

require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))

NoError(t, DeleteAnyDotDFile())
}

func TestPrototypesAdderIncludeBetweenMultilineComment(t *testing.T) {
Expand Down Expand Up @@ -263,8 +255,6 @@ func TestPrototypesAdderIncludeBetweenMultilineComment(t *testing.T) {
preprocessed := string(bytes)

require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))

NoError(t, DeleteAnyDotDFile())
}

func TestPrototypesAdderLineContinuations(t *testing.T) {
Expand Down Expand Up @@ -309,8 +299,6 @@ func TestPrototypesAdderLineContinuations(t *testing.T) {
preprocessed := string(bytes)

require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))

NoError(t, DeleteAnyDotDFile())
}

func TestPrototypesAdderStringWithComment(t *testing.T) {
Expand Down Expand Up @@ -355,8 +343,6 @@ func TestPrototypesAdderStringWithComment(t *testing.T) {
preprocessed := string(bytes)

require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))

NoError(t, DeleteAnyDotDFile())
}

func TestPrototypesAdderSketchWithStruct(t *testing.T) {
Expand Down Expand Up @@ -401,8 +387,6 @@ func TestPrototypesAdderSketchWithStruct(t *testing.T) {
preprocessed := string(bytes)

require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))

NoError(t, DeleteAnyDotDFile())
}

func TestPrototypesAdderSketchWithConfig(t *testing.T) {
Expand Down Expand Up @@ -450,6 +434,4 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
preprocessed := string(bytes)

require.Equal(t, preprocessed, strings.Replace(context[constants.CTX_SOURCE].(string), "\r\n", "\n", -1))

NoError(t, DeleteAnyDotDFile())
}

0 comments on commit 2361bc2

Please sign in to comment.