[native] how can I get compile warnings printed in the console window?

I want to see compiler and linker warnings in the output that is printed to the console, just like compiler and linker errors. Is there a way to configure that?

At the moment, there’s not a way to configure the native tools to always display output. We only show the output when something fails.

You can see the warnings with --info, but you’ll get other output too.

The reason I want this, is to populate the “Error List” window in Visual Studio with warnings and errors, not just errors. How can I create the Visual Studio projects such that they include --info when calling Gradle? I know I could add that by hand, but I would have to touch quite a few projects, and the change would be overwritten, the next time I let Gradle create the Visual Studio files again.

You can try:

tasks.withType(GenerateProjectFileTask) {
    gradleArgs = "--info"
}

I think we’ll still limit the output to the first 10 files compiled.

That worked, thanks! :slight_smile:

Hi, I noticed this hasn’t received any updates since, but as of gradle 3.1 this behaviour still exists. Are there any plans to implement this? I’ve submitted a bug on github: https://github.com/gradle/gradle/issues/810

I’m also interested in the compiler warnings and errors printed at the console window.
The following worked for me, but there is too much output I don’t want to see.

So I tried the following with the intention to only set the log level for compiling tasks.

tasks.whenTaskAdded { task ->
   if (task instanceof CCompile || task instanceof CppCompile) {
      logging.setLevel(LogLevel.INFO)
   }
}

But it has no effect!
Any help will be appreciated.

To output the compiler warnings and options I do the following which I also posted on StackOverflow, see here. It is not while the compiler is doing his actions but afterwards.

To add a task after the compile and link task I add the following (this task will be executed if the build failed or succeeded).

tasks.withType(InstallExecutable) {
   finalizedBy showCompilerOutput
}

If you just want to execute showCompilerOutput if the build was successful you can use this:

build.finalizedBy showCompilerOutput

The task showCompilerOutput is for displaying the output of the files I mentioned in my question. Therefore it builds a file tree which points to the files that I mentioned: output.txt.

task showCompilerOutput {
   dependsOn showCompilerOptions
   doLast {
      println '\n-----------------------------------------------------\n'
      println 'Compiler output:'
      FileTree tree = fileTree('build').include('**/output.txt')
      // Iterate over the contents of a tree
      tree.each {File file ->
          println 'Content of file ' + file + ':\n'
          println file.text
          println '------\n'
      }
   }
}

This task is also dependend of another task which is called showCompilerOptions, which is doing the same but for the files with the compiler options: options.txt.

task showCompilerOptions {
   doLast {
      println '\n-----------------------------------------------------\n'
      println 'Compiler options:'
      FileTree tree = fileTree('build').include('**/options.txt')
      // Iterate over the contents of a tree
      tree.each {File file ->
          println 'Content of file ' + file + ':\n'
          println file.text
          println '------\n'
      }
   }
}
1 Like

I’m guessing this stopped working, as I see no such txt files under the “build” tree. Where do the compilation result outputs being thrown to now?
Thanks.