Skip to content

Commit

Permalink
Convert command buffer autogen to python3
Browse files Browse the repository at this point in the history
The python scripts to generate GLES2/raster/WebGPU command buffer was
still running with vpython which is 2.7. Update the PRESUBMIT to run
with python3 and fix python3 compatibility issues.

Bug: none
Change-Id: Ibe11208afb11bfe9870dc261865a7c909f76bde2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3577186
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: Derek Schuff <dschuff@chromium.org>
Commit-Queue: Kyle Charbonneau <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#991501}
  • Loading branch information
kylechar authored and Chromium LUCI CQ committed Apr 12, 2022
1 parent 2784ff0 commit 9bf3083
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 39 deletions.
6 changes: 3 additions & 3 deletions gpu/command_buffer/PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def CommonChecks(input_api, output_api):
input_api.Command(
name='build_gles2_cmd_buffer',
cmd=[
input_api.python_executable, 'build_gles2_cmd_buffer.py',
input_api.python3_executable, 'build_gles2_cmd_buffer.py',
'--check', '--output-dir=' + temp_dir
],
kwargs={},
Expand All @@ -75,7 +75,7 @@ def CommonChecks(input_api, output_api):
input_api.Command(
name='build_raster_cmd_buffer',
cmd=[
input_api.python_executable, 'build_raster_cmd_buffer.py',
input_api.python3_executable, 'build_raster_cmd_buffer.py',
'--check', '--output-dir=' + temp_dir
],
kwargs={},
Expand All @@ -85,7 +85,7 @@ def CommonChecks(input_api, output_api):
input_api.Command(
name='build_webgpu_cmd_buffer',
cmd=[
input_api.python_executable, 'build_webgpu_cmd_buffer.py',
input_api.python3_executable, 'build_webgpu_cmd_buffer.py',
'--check', '--output-dir=' + temp_dir
],
kwargs={},
Expand Down
22 changes: 11 additions & 11 deletions gpu/command_buffer/build_cmd_buffer_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ def _Namespace():
def Grouper(n, iterable, fillvalue=None):
"""Collect data into fixed-length chunks or blocks"""
args = [iter(iterable)] * n
return itertools.izip_longest(fillvalue=fillvalue, *args)
return itertools.zip_longest(fillvalue=fillvalue, *args)


def SplitWords(input_string):
Expand Down Expand Up @@ -831,7 +831,7 @@ def __init__(self, filename, year):
except OSError as e:
if e.errno == errno.EEXIST:
pass
self._file = open(filename, 'wb')
self._file = open(filename, 'w')

def __enter__(self):
self._file.write(self._ENTER_MSG)
Expand Down Expand Up @@ -1477,7 +1477,7 @@ def WriteGLES2ImplementationUnitTest(self, func, f):
"""
for invalid_arg in constants:
gl_arg_strings = []
invalid = invalid_arg.GetInvalidArg(func)
invalid = invalid_arg.GetInvalidArg(0)
for arg in func.GetOriginalArgs():
if arg is invalid_arg:
gl_arg_strings.append(invalid[0])
Expand Down Expand Up @@ -5923,7 +5923,7 @@ def WriteCmdFlag(self, f):
"""Writes the cmd cmd_flags constant."""
# By default trace only at the highest level 3.
trace_level = int(self.GetInfo('trace_level', default = 3))
if trace_level not in xrange(0, 4):
if trace_level not in range(0, 4):
raise KeyError("Unhandled trace_level: %d" % trace_level)

cmd_flags = ('CMD_FLAG_SET_TRACE_LEVEL(%d)' % trace_level)
Expand Down Expand Up @@ -6351,11 +6351,11 @@ def GetFunctionInfo(self, name):
def Log(self, msg):
"""Prints something if verbose is true."""
if self.verbose:
print msg
print(msg)

def Error(self, msg):
"""Prints an error."""
print "Error: %s" % msg
print("Error: %s" % msg)
self.errors += 1

def ParseGLH(self, filename):
Expand Down Expand Up @@ -6703,7 +6703,7 @@ def WriteStates(test_prev):
continue
if state['type'] == 'FrontBack':
num_states = len(state['states'])
for ndx, group in enumerate(Grouper(num_states / 2,
for ndx, group in enumerate(Grouper(num_states // 2,
state['states'])):
if test_prev:
f.write(" if (")
Expand Down Expand Up @@ -6992,7 +6992,7 @@ def WriteServiceContextStateTestHelpers(self, filename):
state = _STATE_INFO[state_name]
if state['type'] == 'FrontBack':
num_states = len(state['states'])
for ndx, group in enumerate(Grouper(num_states / 2,
for ndx, group in enumerate(Grouper(num_states // 2,
state['states'])):
args = []
for item in group:
Expand Down Expand Up @@ -7424,13 +7424,13 @@ def WritePepperGLES2Interface(self, filename, dev):
f.write("#include \"ppapi/c/ppb_opengles2.h\"\n\n")
else:
f.write("\n#ifndef __gl2_h_\n")
for (k, v) in _GL_TYPES.iteritems():
for (k, v) in _GL_TYPES.items():
f.write("typedef %s %s;\n" % (v, k))
f.write("#ifdef _WIN64\n")
for (k, v) in _GL_TYPES_64.iteritems():
for (k, v) in _GL_TYPES_64.items():
f.write("typedef %s %s;\n" % (v, k))
f.write("#else\n")
for (k, v) in _GL_TYPES_32.iteritems():
for (k, v) in _GL_TYPES_32.items():
f.write("typedef %s %s;\n" % (v, k))
f.write("#endif // _WIN64\n")
f.write("#endif // __gl2_h_\n\n")
Expand Down
10 changes: 5 additions & 5 deletions gpu/command_buffer/build_gles2_cmd_buffer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down Expand Up @@ -4318,7 +4318,7 @@ def main(argv):
chromium_root_dir)

if gen.errors > 0:
print "build_gles2_cmd_buffer.py: Failed with %d errors" % gen.errors
print("build_gles2_cmd_buffer.py: Failed with %d errors" % gen.errors)
return 1

check_failed_filenames = []
Expand All @@ -4329,10 +4329,10 @@ def main(argv):
check_failed_filenames.append(filename)

if len(check_failed_filenames) > 0:
print 'Please run gpu/command_buffer/build_gles2_cmd_buffer.py'
print 'Failed check on autogenerated command buffer files:'
print('Please run gpu/command_buffer/build_gles2_cmd_buffer.py')
print('Failed check on autogenerated command buffer files:')
for filename in check_failed_filenames:
print filename
print(filename)
return 1

return 0
Expand Down
10 changes: 5 additions & 5 deletions gpu/command_buffer/build_raster_cmd_buffer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down Expand Up @@ -468,7 +468,7 @@ def main(argv):
chromium_root_dir)

if gen.errors > 0:
print "build_raster_cmd_buffer.py: Failed with %d errors" % gen.errors
print("build_raster_cmd_buffer.py: Failed with %d errors" % gen.errors)
return 1

check_failed_filenames = []
Expand All @@ -479,10 +479,10 @@ def main(argv):
check_failed_filenames.append(filename)

if len(check_failed_filenames) > 0:
print 'Please run gpu/command_buffer/build_raster_cmd_buffer.py'
print 'Failed check on autogenerated command buffer files:'
print('Please run gpu/command_buffer/build_raster_cmd_buffer.py')
print('Failed check on autogenerated command buffer files:')
for filename in check_failed_filenames:
print filename
print(filename)
return 1

return 0
Expand Down
10 changes: 5 additions & 5 deletions gpu/command_buffer/build_webgpu_cmd_buffer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down Expand Up @@ -168,7 +168,7 @@ def main(argv):
chromium_root_dir)

if gen.errors > 0:
print "build_webgpu_cmd_buffer.py: Failed with %d errors" % gen.errors
print("build_webgpu_cmd_buffer.py: Failed with %d errors" % gen.errors)
return 1

check_failed_filenames = []
Expand All @@ -179,10 +179,10 @@ def main(argv):
check_failed_filenames.append(filename)

if len(check_failed_filenames) > 0:
print 'Please run gpu/command_buffer/build_webgpu_cmd_buffer.py'
print 'Failed check on autogenerated command buffer files:'
print('Please run gpu/command_buffer/build_webgpu_cmd_buffer.py')
print('Failed check on autogenerated command buffer files:')
for filename in check_failed_filenames:
print filename
print(filename)
return 1

return 0
Expand Down
4 changes: 2 additions & 2 deletions gpu/command_buffer/common/gles2_cmd_format_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_AUTOGEN_H_
#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_AUTOGEN_H_

#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
#define GL_SCANOUT_CHROMIUM 0x6000
#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001

struct ActiveTexture {
typedef ActiveTexture ValueType;
Expand Down
16 changes: 8 additions & 8 deletions ppapi/api/ppb_opengles2.idl
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ describe {
#include "ppapi/c/pp_resource.h"

#ifndef __gl2_h_
typedef void GLvoid;
typedef int GLsizei;
typedef unsigned short GLushort;
typedef short GLshort;
typedef unsigned char GLubyte;
typedef unsigned int GLenum;
typedef int GLint;
typedef unsigned char GLboolean;
typedef unsigned int GLbitfield;
typedef float GLfloat;
typedef float GLclampf;
typedef signed char GLbyte;
typedef short GLshort;
typedef int GLint;
typedef int GLsizei;
typedef unsigned char GLubyte;
typedef unsigned short GLushort;
typedef unsigned int GLuint;
typedef float GLfloat;
typedef float GLclampf;
typedef void GLvoid;
typedef int GLfixed;
typedef int GLclampx;
#ifdef _WIN64
Expand Down

0 comments on commit 9bf3083

Please sign in to comment.