Skip to content

Commit

Permalink
Fix -DARDUINO_LIB_DISCOVERY_PHASE automatic flag incompatiblity in so…
Browse files Browse the repository at this point in the history
…me rare circumstances (#838)

* Revert "Add macro -DARDUINO_LIB_DISCOVERY_PHASE during lib discovery phase (#633)"

This reverts commit 985b2c9.

* Set {build.library_discovery_phase} to 1 during lib discovery

Previously we used to add `-DARDUINO_LIB_DISCOVERY_PHASE` to the gcc
command line but this produced some incompatiblity with compilers using
non-standard `-d` flag instead of `-D`:

#633 (comment)
  • Loading branch information
cmaglie authored Jul 23, 2020
1 parent 858cda3 commit 2d7e3d1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions legacy/builder/gcc_preproc_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func GCCPreprocRunnerForDiscoveringIncludes(ctx *types.Context, sourceFilePath *

func prepareGCCPreprocRecipeProperties(ctx *types.Context, sourceFilePath *paths.Path, targetFilePath *paths.Path, includes paths.PathList) (*exec.Cmd, error) {
properties := ctx.BuildProperties.Clone()
properties.Set("build.library_discovery_phase", "1")
properties.SetPath(constants.BUILD_PROPERTIES_SOURCE_FILE, sourceFilePath)
properties.SetPath(constants.BUILD_PROPERTIES_PREPROCESSED_FILE_PATH, targetFilePath)

Expand All @@ -77,8 +78,6 @@ func prepareGCCPreprocRecipeProperties(ctx *types.Context, sourceFilePath *paths
// to create a /dev/null.d dependency file, which won't work.
cmd.Args = utils.Filter(cmd.Args, func(a string) bool { return a != "-MMD" })

cmd.Args = append(cmd.Args, "-DARDUINO_LIB_DISCOVERY_PHASE")

return cmd, nil
}

Expand Down
1 change: 1 addition & 0 deletions legacy/builder/setup_build_properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func (s *SetupBuildProperties) Run(ctx *types.Context) error {
buildProperties.Set("build.fqbn", ctx.FQBN.String())
buildProperties.Set("ide_version", ctx.ArduinoAPIVersion)
buildProperties.Set("runtime.os", properties.GetOSSuffix())
buildProperties.Set("build.library_discovery_phase", "0")

if ctx.OptimizeForDebug {
if buildProperties.ContainsKey("compiler.optimization_flags.debug") {
Expand Down

0 comments on commit 2d7e3d1

Please sign in to comment.