Commit 5695a5b2 by Geoff Lang Committed by Commit Bot

Allow the run_code_generation.py script to be run from any directory.

BUG=angleproject:2695 Change-Id: I9a083bf67b17ca0dc1ee213b75caa4ecece62f00 Reviewed-on: https://chromium-review.googlesource.com/1127354 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent be7e455c
...@@ -18,13 +18,17 @@ root_dir = os.path.abspath(os.path.join(script_dir, '..')) ...@@ -18,13 +18,17 @@ root_dir = os.path.abspath(os.path.join(script_dir, '..'))
# auto_script is a standard way for scripts to return their inputs and outputs. # auto_script is a standard way for scripts to return their inputs and outputs.
def get_child_script_dirname(script):
# All script names are relative to ANGLE's root
return os.path.dirname(os.path.abspath(os.path.join(root_dir, script)))
def grab_from_script(script, param): def grab_from_script(script, param):
res = subprocess.check_output(['python', script, param]).strip() res = subprocess.check_output(['python', script, param]).strip()
return [os.path.abspath(os.path.join(os.path.dirname(script), name)) for name in res.split(',')] return [os.path.abspath(os.path.join(os.path.dirname(script), name)) for name in res.split(',')]
def auto_script(script): def auto_script(script):
# Set the CWD to the script directory. # Set the CWD to the script directory.
os.chdir(os.path.dirname(os.path.abspath(script))) os.chdir(get_child_script_dirname(script))
base_script = os.path.basename(script) base_script = os.path.basename(script)
return { return {
'script': script, 'script': script,
...@@ -177,7 +181,7 @@ for name, info in sorted(generators.iteritems()): ...@@ -177,7 +181,7 @@ for name, info in sorted(generators.iteritems()):
any_dirty = True any_dirty = True
# Set the CWD to the script directory. # Set the CWD to the script directory.
os.chdir(os.path.dirname(os.path.abspath(script))) os.chdir(get_child_script_dirname(script))
print('Running ' + name + ' code generator') print('Running ' + name + ' code generator')
if subprocess.call(['python', os.path.basename(script)]) != 0: if subprocess.call(['python', os.path.basename(script)]) != 0:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment