Sublime Forum

Multiple Build Commands?

#1

Hello,

I saw some posts from 2012 regarding multiple commands in the build system and I was wondering if that ever got addressed? I have a plugin I’m using (Serial Monitor), and I want to create the following workflow for my build process:

  • Close any open serial connection if it exists
  • Run a Makefile (which flashes a chip)
  • Reopen the serial connection upon success
0 Likes

#2

If you use shell_cmd in your sublime-build file, the command that you provide is passed directly to the shell on your operating system to execute as if you had typed it into a command prompt.

  • cmd1 ; cmd2 executes cmd1 followed by cmd2 (for Windows, use cmd1 & cmd2 instead)
  • cmd1 && cmd2 executes cmd1 and then cmd2 if cmd1 succeeded
  • cmd1 || cmd2 executes cmd1 and then cmd2 if cmd1 failed

Here success and failure relates to the value that the executed program returns, where success is 0 and failure is non-0. So you’d use the first case to just execute multiple commands and one of the others depending on whether you want to only proceed if previous steps succeeded.

At a guess you might want something like close ; make && reopen for this (or for windows, close & make && reopen), which would close the connection but continue executing even if there wasn’t an open connection, then build and reflash and re-open the connection if the build worked.

1 Like