arduino-cli icon indicating copy to clipboard operation
arduino-cli copied to clipboard

implement file_regex to pull errors and line numbers

Open jacobrosenthal opened this issue 9 years ago • 6 comments

file_regex only allows you to give a regex to capture filename, line number, column number, and error message for display and navigation after compile.

I broke the version.h include for the following error

b'Bootstrap.ino:17:22: fatal error: versi on.h: No such file or directory\ncompilation terminated.\nError compiling.\n'

Then with this regex

b'(\w*.\w*):(\d*):(\d*):(.*)

Can get 4 groups

  1. Bootstrap.ino
  2. 17
  3. 22
  4. fatal error: versi on.h: No such file or directory\ncompilation terminated.\nError compiling.\n' wanted group one to have a path added to it, again I cant alter code only regex

The biggest problem is arduino strips the full file path. Maybe we could add it back in but Im not sure how to add static text to my regex?

jacobrosenthal avatar Jun 10 '15 01:06 jacobrosenthal

I tried using "result_file_regex" and "result_line_regex" as referenced here to get the outputs.

Using

    "file_regex": "^(?'filename'..*): .*:$",
    "line_regex": "^(..[^:]*):(?'line number'[0-9]+): (?'error message'.*)$",

in the build system I can get some error messages, but it's flaky, sometimes it grabs a whole bunch of lines.

The problem I noticed though is that because the arduino ide first preprocesses the ino files, the line numbers don't correspond to the line numbers of the sketches

lfdebrux avatar May 23 '16 12:05 lfdebrux

The current version of the Arduino IDE does provide full path. The following regexp should work: "file_regex": "(\\w*.\\w*):(\\d*):(\\d*):(.*)", It captures this:

Verifying...


C:\Users\P\Documents\GitHub\MySensors\examples\DimmableLEDActuator\DimmableLEDActuator.ino: In function 'void presentation()':

C:\Users\P\Documents\GitHub\MySensors\examples\DimmableLEDActuator\DimmableLEDActuator.ino:68:7: warning: unused variable 'i' [-Wunused-variable]

   int i;

       ^

image

fallberg avatar Oct 09 '16 21:10 fallberg

@fallberg I don't see the same thing on osx 10.12, sublimetext 3126. Can you PR and confirm your versions? Also can anyone else report in?

jacobrosenthal avatar Oct 13 '16 07:10 jacobrosenthal

Also of note, Im not sure how you enabled -wall or -wunused-variable, and you seem to get column numbers, and I dont on osx


void setup()  
{
asdf
}

void loop()
{
asdfaffs
}

Jacobs-MacBook-Air-3:Downloads jacobrosenthal$ /Applications/Arduino.app/Contents/MacOS/Arduino --board  arduino:avr:uno --verify /Users/jacobrosenthal/Desktop/NullStreamExample/NullStreamExample.ino
WARNING: Category '' in library EEPROM is not valid. Setting to 'Uncategorized'
WARNING: Category '' in library SPI is not valid. Setting to 'Uncategorized'
WARNING: Category '' in library SoftwareSerial is not valid. Setting to 'Uncategorized'
WARNING: Category '' in library Wire is not valid. Setting to 'Uncategorized'
Warning: platform.txt from core 'Arduino AVR Boards' contains deprecated recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}", automatically converted to recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}". Consider upgrading this core.
/Users/jacobrosenthal/Desktop/NullStreamExample/NullStreamExample.ino: In function 'void setup()':
NullStreamExample:4: error: 'asdf' was not declared in this scope
 asdf
 ^
NullStreamExample:5: error: expected ';' before '}' token
 }
 ^
exit status 1
'asdf' was not declared in this scope
Jacobs-MacBook-Air-3:Downloads jacobrosenthal$ 

jacobrosenthal avatar Oct 13 '16 08:10 jacobrosenthal

Hm, it appears the crappy arduino env. only formats the warnings properly, but not errors. You can enable move verbose warning reporting by setting compiler warnings to 'all' and show verbose output during compilation in the IDE configuration.

fallberg avatar Oct 14 '16 04:10 fallberg

I have tried a few options but I can't seem to get it to grab warnings and errors at the same time. I suspect the ST engine is not clever enough to use named grabs and just uses indexes so it is tricky to have one regex rule to match two different cases with the data in the same index for some reason. I am no regex wizard so perhaps someone know how to fuse these two cases together:

For warnings:

"file_regex": "^(?'filename'.*.ino):(?'line number'[0-9]+):(?'column number'[0-9]+):(?'error message'.*)|.*$",
// line_regex not really needed here
"line_regex": "^.*:(?'line number'[0-9]+)(: )(?'error message'.*)$",

image

For errors:

"file_regex": "^(?'filename'.*.ino).*$",
"line_regex": "^.*:(?'line number'[0-9]+)(: )(?'error message'.*)$",

image

By the way, is there a way to specify project specific file and line regex:s for the arduino-cli build system? Without re-defineing the other build system settings/commands?

Environment: ST3 build 3126 (stable) on Windows 10 Arduino IDE 1.6.12

fallberg avatar Oct 16 '16 16:10 fallberg