• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
6import os
7import os.path
8import signal
9import subprocess
10import sys
11
12GCMOLE_PATH = os.path.dirname(os.path.abspath(__file__))
13CLANG_BIN = os.path.join(GCMOLE_PATH, 'gcmole-tools', 'bin')
14CLANG_PLUGINS = os.path.join(GCMOLE_PATH, 'gcmole-tools')
15LUA = os.path.join(GCMOLE_PATH, 'gcmole-tools', 'lua52')
16DRIVER = os.path.join(GCMOLE_PATH, 'gcmole.lua')
17BASE_PATH = os.path.dirname(os.path.dirname(GCMOLE_PATH))
18
19assert len(sys.argv) == 2
20
21if 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
26proc = subprocess.Popen(
27    [LUA, DRIVER, sys.argv[1]],
28    env={'CLANG_BIN': CLANG_BIN, 'CLANG_PLUGINS': CLANG_PLUGINS},
29    cwd=BASE_PATH,
30)
31
32def handle_sigterm(*args):
33  try:
34    proc.kill()
35  except OSError:
36    pass
37
38signal.signal(signal.SIGTERM, handle_sigterm)
39
40proc.communicate()
41sys.exit(proc.returncode)
42