Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build task isn't colored in terminal #2783

Open
serfreeman1337 opened this issue Oct 8, 2022 · 5 comments
Open

Build task isn't colored in terminal #2783

serfreeman1337 opened this issue Oct 8, 2022 · 5 comments
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: tasks upstream Bugs related to issues in an upstream project
Milestone

Comments

@serfreeman1337
Copy link

serfreeman1337 commented Oct 8, 2022

Brief Issue Summary

I'm trying to get color output in terminal. Suggested workaround here #478 (comment) isn't working as expected.

Compiler errors are only colored with set(CMAKE_CXX_FLAGS -fdiagnostics-color=always) is in CMakeList.txt,
but "Building CXX Object" messages are still in white.

Switching task to shell command shows desired colored output ("Building CXX Object" messages are in green color):

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "shell",
			"label": "CMake: build and run",
			"command": "cmake --build ${workspaceFolder}/build --config Debug --target ${workspaceFolderBasename} && ${workspaceFolder}/build/${workspaceFolderBasename}",
			"group": "build"
		}
	]
}

CMake Tools Diagnostics

CMake: Log Diagnostics
{
  "os": "linux",
  "vscodeVersion": "1.72.0",
  "cmtVersion": "1.12.27",
  "configurations": [
    {
      "folder": "/home/serfreeman1337/Dev/tmp-esp32-cv-test",
      "cmakeVersion": "3.24.2",
      "configured": true,
      "generator": "Unix Makefiles",
      "usesPresets": false,
      "compilers": {
        "C": "/usr/bin/gcc",
        "CXX": "/usr/bin/g++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [
      "file:///home/serfreeman1337/Dev/tmp-esp32-cv-test/oh.cc",
      "file:///home/serfreeman1337/Dev/tmp-esp32-cv-test/tmp-esp32-cv-test.cc"
    ],
    "responses": [
      {
        "uri": "file:///home/serfreeman1337/Dev/tmp-esp32-cv-test/oh.cc",
        "configuration": {
          "includePath": [
            "/usr/include/opencv4"
          ],
          "defines": [],
          "compilerPath": "/usr/bin/g++",
          "compilerArgs": [],
          "compilerFragments": [
            "-g",
            "-std=gnu++17"
          ]
        }
      },
      {
        "uri": "file:///home/serfreeman1337/Dev/tmp-esp32-cv-test/tmp-esp32-cv-test.cc",
        "configuration": {
          "includePath": [
            "/usr/include/opencv4"
          ],
          "defines": [],
          "compilerPath": "/usr/bin/g++",
          "compilerArgs": [],
          "compilerFragments": [
            "-g",
            "-std=gnu++17"
          ]
        }
      }
    ],
    "partialMatches": [],
    "targetCount": 1,
    "executablesCount": 1,
    "librariesCount": 0,
    "targets": [
      {
        "name": "tmp-esp32-cv-test",
        "type": "EXECUTABLE"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

No response

Additional Information

Screenshots

Workaroud with set(CMAKE_CXX_FLAGS -fdiagnostics-color=always):
image

Task as shell command without fdiagnostics-color flag:
image

@serfreeman1337 serfreeman1337 changed the title build task no color in terminal Build task not colored in terminal Oct 8, 2022
@serfreeman1337 serfreeman1337 changed the title Build task not colored in terminal Build task isn't colored in terminal Oct 8, 2022
@elahehrashedi elahehrashedi added Feature: tasks enhancement an enhancement to the product that is either not present or an improvement to an existing feature labels Oct 10, 2022
@bobbrow
Copy link
Member

bobbrow commented Oct 10, 2022

It seems that the way we are doing tasks removes the colors. Right now, if we were to send the commands directly to the terminal, we could get colors, but we also wouldn't be able to tell when the build completed or whether it succeeds or not. We'll need to talk to the VS Code team to see if they can give us more information from the Terminal object.

@bobbrow bobbrow added the upstream Bugs related to issues in an upstream project label Oct 10, 2022
@piomis
Copy link
Contributor

piomis commented Oct 10, 2022

On my ArmClang, Windows 10 and VSCode Cmake Tools it looks to be working (I have it configured to useBuildTask)
.
When I add compiler setting: -fdiagnostics-color=always
it looks to be working when ArmClang called directly from shell. But not if I build with ninja and/or cmake (thus also VSCode CMake tools).

But when I add -fansi-escape-codes as compiler option it starts to be working also with ninja, cmake and in vscode termianal output.

image

Obviously these are only Clang colours. Ninja messages are still monochromatic.
As far as I managed to find out it is more ninja limitation which automatically disables colours when detecting to be called in "piped" way (and that is how cmake runs ninja).

@bobbrow
Copy link
Member

bobbrow commented Oct 11, 2022

I'm talking with the VS Code team about this issue: microsoft/vscode#145234. If we can move the implementation to run directly in the terminal, I think it will work the way you expect.

@moefear85
Copy link

for those waiting for salvation: vscode extensions->build output colorizer by steve bush.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: tasks upstream Bugs related to issues in an upstream project
Projects
Status: Pending Prioritization
Development

No branches or pull requests

7 participants