Home | History | Annotate | Download | only in gcmole
      1 #!/usr/bin/env python
      2 # Copyright 2016 the V8 project authors. All rights reserved.
      3 # Use of this source code is governed by a BSD-style license that can be
      4 # found in the LICENSE file.
      5 
      6 import os
      7 import os.path
      8 import signal
      9 import subprocess
     10 import sys
     11 
     12 GCMOLE_PATH = os.path.dirname(os.path.abspath(__file__))
     13 CLANG_BIN = os.path.join(GCMOLE_PATH, 'gcmole-tools', 'bin')
     14 CLANG_PLUGINS = os.path.join(GCMOLE_PATH, 'gcmole-tools')
     15 LUA = os.path.join(GCMOLE_PATH, 'gcmole-tools', 'lua52')
     16 DRIVER = os.path.join(GCMOLE_PATH, 'gcmole.lua')
     17 BASE_PATH = os.path.dirname(os.path.dirname(GCMOLE_PATH))
     18 
     19 assert len(sys.argv) == 2
     20 
     21 if not os.path.isfile("out/Release/gen/torque-generated/builtin-definitions-from-dsl.h"):
     22   print "Expected generated headers in out/Release/gen."
     23   print "Either build v8 in out/Release or change gcmole.lua:115"
     24   sys.exit(-1)
     25 
     26 proc = subprocess.Popen(
     27     [LUA, DRIVER, sys.argv[1]],
     28     env={'CLANG_BIN': CLANG_BIN, 'CLANG_PLUGINS': CLANG_PLUGINS},
     29     cwd=BASE_PATH,
     30 )
     31 
     32 def handle_sigterm(*args):
     33   try:
     34     proc.kill()
     35   except OSError:
     36     pass
     37 
     38 signal.signal(signal.SIGTERM, handle_sigterm)
     39 
     40 proc.communicate()
     41 sys.exit(proc.returncode)
     42