Sublime Forum

Build system regex with relative path

#1

I have a regex that I have been using with Android gradle builds which is as follows…

{
“file_regex”: “^(…[^:]):([0-9]+):?([0-9]+)?:? (.)$”,
“cmd”: [“gradlew.bat” , “assembleDebug” ],
“working_dir”: “${project_path}/SomDir1/SomeDir2/SomeDir3”
}

When I use this same regex, to build a flutter android app, the jump to error feature doesn’t work.

This is because the java compiler was returning absolute paths to files. The dart compiler is returning a relative path.

Is there a way I can instruct sublime to open the file path returned by the regex, based on a relative root directory?

0 Likes

#2

Relative filenames are assumed to be relative to the value of the working_dir path, so generally speaking what you want to do should work.

That said, some external commands may alter the current directory as they’re carrying out the build, which makes the error messages they generate be relative to a path other than the working_dir path. An example of that is using the Makefile build system for a project that recurses into subdirectories as it builds; it does that by changing the current directory as far as the tools are concerned, which makes them generate error output that you can’t navigate.

Short of having the tools in question always generate an absolute path in error output (such as was asked recently in this SO question) I think the only way to pull something like that off is to have a custom build target command that watches for output being sent to the output panel and rewrites it to change the paths. I’m not aware of any packages that do that, though.

0 Likes