Have run_code_generation only call vpython when needed

gen_builtin_symbols.py uses a vpython module to generate
a perfect hash function
Also seeded the perfect hash function to make it deterministic

Bug: angleproject:3747
Change-Id: I660fe71bd6b2213be9d4ccc2f68641637a49a047
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1738747
Commit-Queue: Clemen Deng <clemendeng@google.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Clemen Deng
2019-08-06 13:31:01 -04:00
committed by Commit Bot
parent 483ee3fa23
commit 44f518b584
4 changed files with 147 additions and 162 deletions

View File

@@ -38,12 +38,18 @@ def rebase_script_path(script_path, relative_path):
return os.path.relpath(os.path.join(os.path.dirname(script_path), relative_path), root_dir)
def get_executable_name():
return 'vpython.bat' if platform.system() == 'Windows' else 'vpython'
# Check if we need a module from vpython
def get_executable_name(first_line):
if 'vpython' in first_line:
return 'vpython.bat' if platform.system() == 'Windows' else 'vpython'
return 'python'
def grab_from_script(script, param):
res = subprocess.check_output([get_executable_name(), script, param]).strip()
res = ''
f = open(os.path.basename(script), "r")
res = subprocess.check_output([get_executable_name(f.readline()), script, param]).strip()
f.close()
if res == '':
return []
return [clean_path_slashes(rebase_script_path(script, name)) for name in res.split(',')]
@@ -190,8 +196,12 @@ def main():
os.chdir(get_child_script_dirname(script))
print('Running ' + name + ' code generator')
if subprocess.call([get_executable_name(), os.path.basename(script)]) != 0:
f = open(os.path.basename(script), "r")
if subprocess.call([get_executable_name(f.readline()),
os.path.basename(script)]) != 0:
sys.exit(1)
f.close()
# Update the hash dictionary.
all_new_hashes[fname] = new_hashes