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: Jamie Madill <jmadill@chromium.org>
diff --git a/scripts/run_code_generation.py b/scripts/run_code_generation.py
index 041e84c..bf0f6a5 100755
--- a/scripts/run_code_generation.py
+++ b/scripts/run_code_generation.py
@@ -18,13 +18,17 @@
 
 # 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):
     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(',')]
 
 def auto_script(script):
     # 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)
     return {
         'script': script,
@@ -177,7 +181,7 @@
         any_dirty = True
 
         # 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')
         if subprocess.call(['python', os.path.basename(script)]) != 0: