batch-filesublimetext3build-script

Sublime Text 3, Build system - How to stop when there is an error


I wrote a custom build system for cc65 compiler. When there is no error it works correctly but the batch script doesn't stop when there is an error.

Even though compiler stopped working and sublime text catches error messages batch script continues to line %VICE_PATH%\x64 index which is running previous version of the output file. How can I make it stop on error?

My build script:

{
    "cmd": "build.bat",
    "file_regex": "^ *([A-z0-9.]*)\\(([0-9]+)\\)",
    "working_dir": "$project_path",
    "shell": true,
    "syntax": "",
}

Batch file:

@ECHO off

SET CPP_PATH=C:\Users\gokhan\Documents\C64CrossDev\tools\cc65\bin
SET VICE_PATH=C:\Users\gokhan\Documents\C64CrossDev\tools\WinVICE-2.4-x64


%CPP_PATH%\cl65 index.c text.s
%VICE_PATH%\x64 index

p.s.: I'm working on Windows 10


Solution

  • After doing some search about %errorlevel% I've reached the folowing solution:

    @ECHO off
    
    SET CPP_PATH=C:\Users\gokhan\Documents\C64CrossDev\tools\cc65\bin
    SET VICE_PATH=C:\Users\gokhan\Documents\C64CrossDev\tools\WinVICE-2.4-x64
    
    
    %CPP_PATH%\cl65 main.c text.s -o main.prg
    
    IF %ERRORLEVEL%==0 %VICE_PATH%\x64 main.prg