scripts: Scan CWD in parameter validation script.
authorJamie Madill <jmadill@chromium.org>
Fri, 15 Dec 2017 20:54:05 +0000 (15:54 -0500)
committerTobin Ehlis <tobine@google.com>
Fri, 15 Dec 2017 23:40:00 +0000 (16:40 -0700)
This makes it more easy to locate the header in configs which have the
CWD set to something less obvious. In Chrome's case the build directory
is completely separated from the script directory.

Also reset the CWD after the header is found to keep the build intact.

scripts/parameter_validation_generator.py

index ba825e2..4a9ec4e 100644 (file)
@@ -193,6 +193,9 @@ class ParameterValidationOutputGenerator(OutputGenerator):
 
         self.vuid_file = None
         # Cover cases where file is built from scripts directory, Lin/Win, or Android build structure
+        # Set cwd to the script directory to more easily locate the header.
+        previous_dir = os.getcwd()
+        os.chdir(os.path.dirname(sys.argv[0]))
         vuid_filename_locations = [
             './vk_validation_error_messages.h',
             '../layers/vk_validation_error_messages.h',
@@ -206,6 +209,7 @@ class ParameterValidationOutputGenerator(OutputGenerator):
         if self.vuid_file == None:
             print("Error: Could not find vk_validation_error_messages.h")
             sys.exit(1)
+        os.chdir(previous_dir)
     #
     # Generate Copyright comment block for file
     def GenerateCopyright(self):