Skip to content

Commit 36b6b23

Browse files
committed
Added the DIAGNOSTICS_COLOR_WHEN var for controlling diagnostics-color.
Some IDEs do not work nicely with the recently added diagnostics-color compiler switch. This patch adds the DIAGNOSTICS_COLOR_WHEN variable, for controlling diagnostics-color switch. The default was chosen to be 'always', which makes the Arduino.mk file backwards compatible with everything up to commit fa82c3a (Sat Sep 2 15:32:52 2017 +0100). The supported values for DIAGNOSTICS_COLOR_WHEN are: `always`, `never` and `auto`, and as with all Arduino.mk variables, it can easily be overridden. For more details on the diagnostics-color compiler switch, see: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Language-Independent-Options.html#Language-Independent-Options
1 parent a7b8084 commit 36b6b23

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

Arduino.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,10 +1108,11 @@ endif
11081108
CFLAGS += $(CFLAGS_STD)
11091109
CXXFLAGS += -fpermissive -fno-exceptions $(CXXFLAGS_STD)
11101110
ASFLAGS += -x assembler-with-cpp
1111+
DIAGNOSTICS_COLOR_WHEN ?= always
11111112
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
11121113
ASFLAGS += -flto
1113-
CXXFLAGS += -fno-threadsafe-statics -flto -fno-devirtualize -fdiagnostics-color
1114-
CFLAGS += -flto -fno-fat-lto-objects -fdiagnostics-color
1114+
CXXFLAGS += -fno-threadsafe-statics -flto -fno-devirtualize -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN)
1115+
CFLAGS += -flto -fno-fat-lto-objects -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN)
11151116
endif
11161117
LDFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -Wl,--gc-sections -O$(OPTIMIZATION_LEVEL)
11171118
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
1515
- Tweak: Update Windows usage documentation and allow non-relative paths (issue #519) (https://github.com/tuna-f1sh)
1616
- Tweak: Support Cygwin Unix Python and Windows installation on Windows to pass correct port binding. (https://github.com/tuna-f1sh)
1717
- New: Added -fdiagnostics-color to \*STD flags (https://github.com/sej7278)
18+
- New: Made -fdiagnostics-color take a variiable DIAGNOSTICS_COLOR_WHEN: never, always, auto. (https://github.com/wingunder)
1819
- New: Add generation of tags file using ctags, which automatically includes project libs and Arduino core. (https://github.com/tuna-f1sh)
1920
- New: Add template Makefile and project boilerplate initialise script, `ardmk-init`. (https://github.com/tuna-f1sh)
2021
- New: Support atmelice_isp JTAG tool as ISP programmer. (https://github.com/tuna-f1sh)

arduino-mk-vars.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ CXXFLAGS_STD = -std=gnu++98
10471047
Flags passed to compiler for files compiled as C. Add more flags to this
10481048
variable using `+=`.
10491049

1050-
Defaults to `undefined` on 1.0 or `-flto -fno-fat-lto-objects -fdiagnostics-color` on AVR toolchain > 4.9.0 (e.g. IDE 1.6.10+)
1050+
Defaults to `undefined` on 1.0 or `-flto -fno-fat-lto-objects -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN)` on AVR toolchain > 4.9.0 (e.g. IDE 1.6.10+)
10511051

10521052
**Example:**
10531053

@@ -1080,6 +1080,30 @@ CXXFLAGS += -my-c++-onlyflag
10801080

10811081
----
10821082

1083+
### DIAGNOSTICS_COLOR_WHEN
1084+
1085+
**Description:**
1086+
1087+
This variable controls the compiler's diagnostics-color setting, as defined
1088+
in CFLAGS or CXXFLAGS, on AVR toolchain > 4.9.0.
1089+
Supported values are: `always`, `never` and `auto`.
1090+
For more details, see: [Options to Control Diagnostic Messages Formatting]
1091+
(https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Language-Independent-Options.html#Language-Independent-Options)
1092+
1093+
Defaults to `always`.
1094+
1095+
**Example:**
1096+
1097+
```Makefile
1098+
DIAGNOSTICS_COLOR_WHEN = never
1099+
# or
1100+
DIAGNOSTICS_COLOR_WHEN = auto
1101+
```
1102+
1103+
**Requirement:** *Optional*
1104+
1105+
----
1106+
10831107
### ASFLAGS
10841108

10851109
**Description:**

0 commit comments

Comments
 (0)