Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[fix] build&run: do not run when build fails

  • Loading branch information...
commit 2fa0f11313c5f95199b50b5c1e5f9b8c499a5f88 1 parent f3ca07c
@OpaOnWindowsNow OpaOnWindowsNow authored
Showing with 20 additions and 7 deletions.
  1. +20 −7 commands.py
View
27 commands.py
@@ -2,6 +2,7 @@
import sublime, sublime_plugin
import sys
import task, subprocess, signal
+import time
basename_exe = "opa_build"
@@ -19,6 +20,12 @@ def prog_name(prog):
else:
return prog
+def modtime(filename):
+ try:
+ return os.path.getmtime(filename)
+ except:
+ return time.min
+
def location(program):
if not (program in locations):
for path in os.environ["PATH"].split(os.pathsep):
@@ -97,14 +104,20 @@ def run(self, view):
exe = exe_name
output(panel, "Will build & run "+exe)
output(panel,"\nCompiling ...")
+ tbuild0 = modtime(os.path.join(dirname,exe)) # because we have no error code, we have to check if a new exe has been generated
self.view.window().run_command('build')
- output(panel,"done\n")
- output(panel,"\nStoping previous launch ...")
- kill(self,dirname,exe)
- output(panel,"done\n")
- output(panel,"Launching ...")
- launch(self,dirname,exe)
- #output(panel,"The application has started\n")
+ time.sleep(0.8) # for some reason the modification time is modified latter
+ tbuild1 = modtime(os.path.join(dirname,exe))
+ if tbuild0 < tbuild1:
+ output(panel,"done\n")
+ output(panel,"\nStoping previous launch ...")
+ kill(self,dirname,exe)
+ output(panel,"done\n")
+ output(panel,"Launching ...")
+ launch(self,dirname,exe)
+ #output(panel,"The application has started\n")
+ else:
+ output(panel,"Build failure\n")
class stopRunOpaBuildCommand(sublime_plugin.TextCommand):
Please sign in to comment.
Something went wrong with that request. Please try again.