Sublime Forum

Sublime-build file_regex Arduino sketches

#1

A few members over on the PJRC forum have setup some windows command files and some sublime text build setup scripts to allow us to do Arduino builds for most/all of the Teensy boards using the Arduino build system. Which is great. I much prefer working within sublime text instead of the Arduino IDE, and the default stuff works pretty well for showing the errors within the source file.

Which is great. The one main issue I run into with this, is that Arduino will copy your sketch and any other source files within your sketch folder to a temporary directory, which is where it compiles from.

The issue in these cases, is the error messages reported show up looking something like:

"C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_LSS_Phoenix.ino\\sketch\\LSS_Phoenix.ino.cpp.o"
In file included from C:\arduino-1.8.12\hardware\teensy\avr\cores\teensy4/WProgram.h:41:0,
                 from C:\Users\kurte\AppData\Local\Temp\arduino_build_LSS_Phoenix.ino\pch\Arduino.h:6:
C:\Users\kurte\AppData\Local\Temp\arduino_build_LSS_Phoenix.ino\sketch\_Phoenix_Driver_lss.h: In function 'void FindServoOffsets()':
C:\Users\kurte\AppData\Local\Temp\arduino_build_LSS_Phoenix.ino\sketch\_Phoenix_Driver_lss.h:658:61: error: 'cCoxaPin' was not declared in this scope
     abSSCServoNum[sSN*NUMSERVOSPERLEG + 0] = pgm_read_byte(&cCoxaPin[sSN]);
                                                             ^

And when I hit F4 it brings up that line in the temp file, where many times I will fix the error there, do a compile again and get the same error… As again the real source file is copied back to the temporary folder overwriting my changes.

So was wondering if there is a way to setup the file_regex to allow the normal finding of files, except when it finds files tat are coming out of the temporary directory such as this and redirect back to the real source file?

Thanks

0 Likes

#2

The file_regex is used to parse the build system’s output. It doesn’t know about the details of copying a file to a temporary location.

You’d need to create a custom build system, which translates the temporary paths of compiler output back to the original ones. The default build system is implemented in exec.py. What you’d need is to derive the default ExecCommand and override the write() method.

from Default.exec import ExecCommand


class ArudinoExecCommand(ExecCommand):

    def write(self, characters):
        characters = characters.replace(temppath, realpath)
        return super().write(characters)

This command can then be assigned to your build system.

0 Likes

#3

Maybe https://packagecontrol.io/packages/Deviot%20(Arduino%20IDE) already contains custom build systems?

0 Likes

#4

Thanks for the information, I will take a look.

Will take a look at the exec.py stuff and see how bad it looks, especially for someone like me who python is not my native language.

The Deviot system looks interesting - But it looks like it is using PlatfrormIO, which I have nothing against, but I mostly try to help out making sure all of my code changes work with the Official Arduino build system (with a Teensy processor), so will need to experiment and see how close they are.

Thanks again!

0 Likes