Build wrapper with command-line options from file

eclipse
build-wrapper
sonarcfamily
sonarlint
sonarqube

(SHa) #1

Hello,

I’m trying to use build wrapper with IAR.
My build command uses a file to pass command-line options:

iccarm.exe -f file

Build wrapper output seems good but it seems that SonarLint doesn’t manage command-line options passed throug file (-f option for IAR).

So, build wrapper doesn’t work on my side.

Please can you tell me weither it’s normal or not ?

Versions:

  • Build wrapper: version 5.1 (win-x86-64)
  • SonarLint: SonarLint for Eclipse 3.6.0.201806071228

(Loïc Joly) #2

Hello, I suggest you read my answer to your other related question, I think it will explain why you are not supposed to do what you are trying to do. :slight_smile:


(SHa) #3

Unfortunately, I’m not sure that it will make the trick.

I have two use cases:

  • Analysis with SonarLint in Eclipse
  • Build on a continuous integration tool

Analysis with SonarLint in Eclipse:
I don’t use Eclipse to build.
I have a target (in Eclipse) that call a command line to build my code with an external tool.
This is the reason why I would use the build wrapper in Eclipse.

Build on a continuous integration tool
I also build directly on a continuous integration tool and I would use the build wrapper.
However it fails due to options passed by file.

Is the build wrapper compatible with options passed by file ?


(Loïc Joly) #4

For your first use case, you need the project in Eclipse to be configured well enough so that it could actually be built from within Eclipse.

For your second use case, using the build wrapper is the way to go. It does supports the -f compiler option to get extra options from a file. So if you want us to look into your issue, we would need a full example that reproduces it:

  • The source code
  • The different command lines that you used
  • The outputs that you got, and where they differ from what you expected. The most important outputs being, of course, the log files (from the build wrapper as well as from the analysis).

(SHa) #5

Ok.

Find a zip here https://ufile.io/erpy4 with the following data:

  • the source code
  • sonar scanner log: see sonar.logs file
  • wrapper output: see bw_output directory
  • tmp directory: contains file with compilation options

Excpected behavior: Sonarqube should analyse my source files
Actual behavior: Sources are not analysed. In sonarqube log, there is: 0 compilation units analyzed

If I don’t use file for compilation options, everything is fine.


(Loïc Joly) #6

Hello,

We had a quick look at your files, and found one point that may be the reason of the issue. You are using command lines like:

iccarm.exe -ftmp\tmpvpxrgu.lnk

While we expect command lines with a space after the -f switch, like:

iccarm.exe -f tmp\tmpvpxrgu.lnk

Could you try to add a space, and confirm us if this solves your issue?
Thank you


(SHa) #7

I tried with a space. It works great!

Thank you very much for your support.

Can you tell me if we can expect Sonarqube to accept -f option wihout space in future versions ?


(Loïc Joly) #8

I’m glad this could unblock you.
I created a ticket to allow the build wraper to understand this command line option even if the space is not there: https://jira.sonarsource.com/browse/CPP-2034