run-gcmole.py 1.21 KB
Newer Older
1 2 3 4 5
#!/usr/bin/env python
# Copyright 2016 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

6 7 8
# for py2/py3 compatibility
from __future__ import print_function

9
import os
10
import os.path
11
import signal
12 13 14 15 16 17 18 19
import subprocess
import sys

GCMOLE_PATH = os.path.dirname(os.path.abspath(__file__))
CLANG_BIN = os.path.join(GCMOLE_PATH, 'gcmole-tools', 'bin')
CLANG_PLUGINS = os.path.join(GCMOLE_PATH, 'gcmole-tools')
LUA = os.path.join(GCMOLE_PATH, 'gcmole-tools', 'lua52')
DRIVER = os.path.join(GCMOLE_PATH, 'gcmole.lua')
20
BASE_PATH = os.path.dirname(os.path.dirname(GCMOLE_PATH))
21 22 23

assert len(sys.argv) == 2

24
if not os.path.isfile("out/Release/gen/torque-generated/builtin-definitions-from-dsl.h"):
25 26
  print("Expected generated headers in out/Release/gen.")
  print("Either build v8 in out/Release or change gcmole.lua:115")
27 28
  sys.exit(-1)

29
proc = subprocess.Popen(
30 31
    [LUA, DRIVER, sys.argv[1]],
    env={'CLANG_BIN': CLANG_BIN, 'CLANG_PLUGINS': CLANG_PLUGINS},
32
    cwd=BASE_PATH,
33 34 35 36 37 38 39 40 41 42 43 44
)

def handle_sigterm(*args):
  try:
    proc.kill()
  except OSError:
    pass

signal.signal(signal.SIGTERM, handle_sigterm)

proc.communicate()
sys.exit(proc.returncode)