gpu/ipc/common/generate_vulkan_types.py
def main(argv):
  """This is the main function."""

  parser = optparse.OptionParser()
  parser.add_option(
      "--output-dir",
      help="Output directory for generated files. Defaults to this script's "
      "directory.")
  parser.add_option(
      "-c", "--check", action="store_true",
      help="Check if output files match generated files in chromium root "
      "directory. Use this in PRESUBMIT scripts with --output-dir.")

  (options, _) = parser.parse_args(args=argv)

  # Support generating files for PRESUBMIT.
  if options.output_dir:
    output_dir = options.output_dir
  else:
    output_dir = _SELF_LOCATION

  def ClangFormat(filename):
    formatter = "clang-format"
    if platform.system() == "Windows":
      formatter += ".bat"
    subprocess.call([formatter, "-i", "-style=chromium", filename])

  vk_xml_file_path = os.path.join(
    _SELF_LOCATION, "../../..", _VK_XML_FILE)
  ParseVkXMLFile(vk_xml_file_path)


  mojom_file_name = "vulkan_types.mojom"
  mojom_file = open(
      os.path.join(output_dir, mojom_file_name), 'wb')
  GenerateMojom(mojom_file)
  mojom_file.close()
  ClangFormat(mojom_file.name)

  traits_header_file_name = "vulkan_types_mojom_traits.h"
  traits_header_file = \
      open(os.path.join(output_dir, traits_header_file_name), 'wb')
  traits_source_file_name = "vulkan_types_mojom_traits.cc"
  traits_source_file = \
      open(os.path.join(output_dir, traits_source_file_name), 'wb')
  GenerateTraitsFile(traits_header_file, traits_source_file)
  traits_header_file.close()
  ClangFormat(traits_header_file.name)
  traits_source_file.close()
  ClangFormat(traits_source_file.name)

  typemap_file_name = "generated_vulkan_type_mappings.gni"
  typemap_file = open(
      os.path.join(output_dir, typemap_file_name), 'wb')
  GenerateTypemapFile(typemap_file)
  typemap_file.close()

  check_failed_filenames = []
  if options.check:
    for filename in [mojom_file_name, traits_header_file_name,
                     traits_source_file_name, typemap_file_name]:
      if not filecmp.cmp(os.path.join(output_dir, filename),
                         os.path.join(_SELF_LOCATION, filename)):
        check_failed_filenames.append(filename)

  if len(check_failed_filenames) > 0:
    print 'Please run gpu/ipc/common/generate_vulkan_types.py'
    print 'Failed check on generated files:'
    for filename in check_failed_filenames:
      print filename
    return 1

  return 0
This is the main function.
This is the main function.
This is the main function .
def main(argv):
  parser = optparse.OptionParser()
  parser.add_option(
      "--output-dir",
      help="Output directory for generated files. Defaults to this script's "
      "directory.")
  parser.add_option(
      "-c", "--check", action="store_true",
      help="Check if output files match generated files in chromium root "
      "directory. Use this in PRESUBMIT scripts with --output-dir.")
  (options, _) = parser.parse_args(args=argv)
  if options.output_dir:
    output_dir = options.output_dir
  else:
    output_dir = _SELF_LOCATION
  def ClangFormat(filename):
    formatter = "clang-format"
    if platform.system() == "Windows":
      formatter += ".bat"
    subprocess.call([formatter, "-i", "-style=chromium", filename])
  vk_xml_file_path = os.path.join(
    _SELF_LOCATION, "../../..", _VK_XML_FILE)
  ParseVkXMLFile(vk_xml_file_path)
  mojom_file_name = "vulkan_types.mojom"
  mojom_file = open(
      os.path.join(output_dir, mojom_file_name), 'wb')
  GenerateMojom(mojom_file)
  mojom_file.close()
  ClangFormat(mojom_file.name)
  traits_header_file_name = "vulkan_types_mojom_traits.h"
  traits_header_file = \
      open(os.path.join(output_dir, traits_header_file_name), 'wb')
  traits_source_file_name = "vulkan_types_mojom_traits.cc"
  traits_source_file = \
      open(os.path.join(output_dir, traits_source_file_name), 'wb')
  GenerateTraitsFile(traits_header_file, traits_source_file)
  traits_header_file.close()
  ClangFormat(traits_header_file.name)
  traits_source_file.close()
  ClangFormat(traits_source_file.name)
  typemap_file_name = "generated_vulkan_type_mappings.gni"
  typemap_file = open(
      os.path.join(output_dir, typemap_file_name), 'wb')
  GenerateTypemapFile(typemap_file)
  typemap_file.close()
  check_failed_filenames = []
  if options.check:
    for filename in [mojom_file_name, traits_header_file_name,
                     traits_source_file_name, typemap_file_name]:
      if not filecmp.cmp(os.path.join(output_dir, filename),
                         os.path.join(_SELF_LOCATION, filename)):
        check_failed_filenames.append(filename)
  if len(check_failed_filenames) > 0:
    print 'Please run gpu/ipc/common/generate_vulkan_types.py'
    print 'Failed check on generated files:'
    for filename in check_failed_filenames:
      print filename
    return 1
  return 0
def main ( argv ) : parser = optparse . OptionParser ( ) parser . add_option ( "--output-dir" , help = "Output directory for generated files. Defaults to this script's " "directory." ) parser . add_option ( "-c" , "--check" , action = "store_true" , help = "Check if output files match generated files in chromium root " "directory. Use this in PRESUBMIT scripts with --output-dir." ) ( options , _ ) = parser . parse_args ( args = argv ) if options . output_dir : output_dir = options . output_dir else : output_dir = _SELF_LOCATION def ClangFormat ( filename ) : formatter = "clang-format" if platform . system ( ) == "Windows" : formatter += ".bat" subprocess . call ( [ formatter , "-i" , "-style=chromium" , filename ] ) vk_xml_file_path = os . path . join ( _SELF_LOCATION , "../../.." , _VK_XML_FILE ) ParseVkXMLFile ( vk_xml_file_path ) mojom_file_name = "vulkan_types.mojom" mojom_file = open ( os . path . join ( output_dir , mojom_file_name ) , 'wb' ) GenerateMojom ( mojom_file ) mojom_file . close ( ) ClangFormat ( mojom_file . name ) traits_header_file_name = "vulkan_types_mojom_traits.h" traits_header_file = open ( os . path . join ( output_dir , traits_header_file_name ) , 'wb' ) traits_source_file_name = "vulkan_types_mojom_traits.cc" traits_source_file = open ( os . path . join ( output_dir , traits_source_file_name ) , 'wb' ) GenerateTraitsFile ( traits_header_file , traits_source_file ) traits_header_file . close ( ) ClangFormat ( traits_header_file . name ) traits_source_file . close ( ) ClangFormat ( traits_source_file . name ) typemap_file_name = "generated_vulkan_type_mappings.gni" typemap_file = open ( os . path . join ( output_dir , typemap_file_name ) , 'wb' ) GenerateTypemapFile ( typemap_file ) typemap_file . close ( ) check_failed_filenames = [ ] if options . check : for filename in [ mojom_file_name , traits_header_file_name , traits_source_file_name , typemap_file_name ] : if not filecmp . cmp ( os . path . join ( output_dir , filename ) , os . path . join ( _SELF_LOCATION , filename ) ) : check_failed_filenames . append ( filename ) if len ( check_failed_filenames ) > 0 : print 'Please run gpu/ipc/common/generate_vulkan_types.py' print 'Failed check on generated files:' for filename in check_failed_filenames : print filename return 1 return 0
This is the main function.
This is the main function .
"""This is the main function.""" # Support generating files for PRESUBMIT.
argv