def main(argv): """This is the main function.""" parser = OptionParser() parser.add_option( "--output-dir", help="base directory for resulting files, under chrome/src. default is " "empty. Use this if you want the result stored under gen.") parser.add_option("-v", "--verbose", action="store_true", help="prints more output.") (options, _) = parser.parse_args(args=argv) # This script lives under gpu/command_buffer, cd to base directory. os.chdir(os.path.dirname(__file__) + "/../..") base_dir = os.getcwd() build_cmd_buffer_lib.InitializePrefix("Raster") gen = build_cmd_buffer_lib.GLGenerator(options.verbose, "2018", _FUNCTION_INFO, _NAMED_TYPE_INFO) gen.ParseGLH("gpu/command_buffer/raster_cmd_buffer_functions.txt") # Support generating files under gen/ if options.output_dir != None: os.chdir(options.output_dir) os.chdir(base_dir) gen.WriteCommandIds("gpu/command_buffer/common/raster_cmd_ids_autogen.h") gen.WriteFormat("gpu/command_buffer/common/raster_cmd_format_autogen.h") gen.WriteFormatTest( "gpu/command_buffer/common/raster_cmd_format_test_autogen.h") gen.WriteGLES2InterfaceHeader( "gpu/command_buffer/client/raster_interface_autogen.h") gen.WriteGLES2ImplementationHeader( "gpu/command_buffer/client/raster_implementation_autogen.h") gen.WriteGLES2Implementation( "gpu/command_buffer/client/raster_implementation_impl_autogen.h") gen.WriteGLES2ImplementationUnitTests( "gpu/command_buffer/client/raster_implementation_unittest_autogen.h") gen.WriteCmdHelperHeader( "gpu/command_buffer/client/raster_cmd_helper_autogen.h") gen.WriteServiceImplementation( "gpu/command_buffer/service/raster_decoder_autogen.h") gen.WriteServiceUnitTests( "gpu/command_buffer/service/raster_decoder_unittest_%d_autogen.h") gen.WriteServiceUtilsHeader( "gpu/command_buffer/service/raster_cmd_validation_autogen.h") gen.WriteServiceUtilsImplementation( "gpu/command_buffer/service/" "raster_cmd_validation_implementation_autogen.h") build_cmd_buffer_lib.Format(gen.generated_cpp_filenames) if gen.errors > 0: print "%d errors" % gen.errors return 1 return 0
def main(argv): """This is the main function.""" parser = OptionParser() parser.add_option( "--output-dir", help="Output directory for generated files. Defaults to chromium root " "directory.") parser.add_option("-v", "--verbose", action="store_true", help="Verbose logging output.") 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) # This script lives under src/gpu/command_buffer. script_dir = os.path.dirname(os.path.abspath(__file__)) assert script_dir.endswith(os.path.normpath("src/gpu/command_buffer")) # os.path.join doesn't do the right thing with relative paths. chromium_root_dir = os.path.abspath(script_dir + "/../..") # Support generating files under gen/ and for PRESUBMIT. if options.output_dir: output_dir = options.output_dir else: output_dir = chromium_root_dir os.chdir(output_dir) build_cmd_buffer_lib.InitializePrefix("Raster") gen = build_cmd_buffer_lib.GLGenerator(options.verbose, "2018", _FUNCTION_INFO, _NAMED_TYPE_INFO, chromium_root_dir) gen.ParseGLH("gpu/command_buffer/raster_cmd_buffer_functions.txt") gen.WriteCommandIds("gpu/command_buffer/common/raster_cmd_ids_autogen.h") gen.WriteFormat("gpu/command_buffer/common/raster_cmd_format_autogen.h") gen.WriteFormatTest( "gpu/command_buffer/common/raster_cmd_format_test_autogen.h") gen.WriteGLES2InterfaceHeader( "gpu/command_buffer/client/raster_interface_autogen.h") gen.WriteGLES2ImplementationHeader( "gpu/command_buffer/client/raster_implementation_autogen.h") gen.WriteGLES2Implementation( "gpu/command_buffer/client/raster_implementation_impl_autogen.h") gen.WriteGLES2ImplementationUnitTests( "gpu/command_buffer/client/raster_implementation_unittest_autogen.h") gen.WriteCmdHelperHeader( "gpu/command_buffer/client/raster_cmd_helper_autogen.h") gen.WriteServiceImplementation( "gpu/command_buffer/service/raster_decoder_autogen.h") gen.WriteServiceUnitTests( "gpu/command_buffer/service/raster_decoder_unittest_%d_autogen.h") gen.WriteServiceUtilsHeader( "gpu/command_buffer/service/raster_cmd_validation_autogen.h") gen.WriteServiceUtilsImplementation( "gpu/command_buffer/service/" "raster_cmd_validation_implementation_autogen.h") build_cmd_buffer_lib.Format(gen.generated_cpp_filenames, output_dir, chromium_root_dir) if gen.errors > 0: print "build_raster_cmd_buffer.py: Failed with %d errors" % gen.errors return 1 check_failed_filenames = [] if options.check: for filename in gen.generated_cpp_filenames: if not filecmp.cmp(os.path.join(output_dir, filename), os.path.join(chromium_root_dir, filename)): 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:' for filename in check_failed_filenames: print filename return 1 return 0