From 44e9d65757640c2bbab73a7260ee1a53eefd799c Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 22 Jun 2017 11:27:04 -0700 Subject: intel/isl/format: Dedent the template in gen_format_layout.py This makes it much easier to edit the template and doesn't really dirty the python all that much. Reviewed-by: Topi Pohjolainen --- src/intel/isl/gen_format_layout.py | 115 ++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 58 deletions(-) (limited to 'src/intel') diff --git a/src/intel/isl/gen_format_layout.py b/src/intel/isl/gen_format_layout.py index f52e4549975..aa4e2d8cb9c 100644 --- a/src/intel/isl/gen_format_layout.py +++ b/src/intel/isl/gen_format_layout.py @@ -32,64 +32,63 @@ from mako import template # Load the template, ensure that __future__.division is imported, and set the # bytes encoding to be utf-8. This last bit is important to getting simple # consistent behavior for python 3 when we get there. -TEMPLATE = template.Template( - text=textwrap.dedent("""\ - /* This file is autogenerated by gen_format_layout.py. DO NOT EDIT! */ - - /* - * Copyright 2015 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - - #include "isl/isl.h" - - const struct isl_format_layout - isl_format_layouts[] = { - % for format in formats: - [ISL_FORMAT_${format.name}] = { - .format = ISL_FORMAT_${format.name}, - .name = "ISL_FORMAT_${format.name}", - .bpb = ${format.bpb}, - .bw = ${format.bw}, - .bh = ${format.bh}, - .bd = ${format.bd}, - .channels = { - % for mask in ['r', 'g', 'b', 'a', 'l', 'i', 'p']: - <% channel = getattr(format, mask, None) %>\\ - % if channel.type is not None: - .${mask} = { ISL_${channel.type}, ${channel.size} }, - % else: - .${mask} = {}, - % endif - % endfor - }, - .colorspace = ISL_COLORSPACE_${format.colorspace}, - .txc = ISL_TXC_${format.txc}, - }, - - % endfor - }; - """), - future_imports=['division'], - output_encoding='utf-8') +TEMPLATE = template.Template(future_imports=['division'], + output_encoding='utf-8', + text="""\ +/* This file is autogenerated by gen_format_layout.py. DO NOT EDIT! */ + +/* + * Copyright 2015 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "isl/isl.h" + +const struct isl_format_layout +isl_format_layouts[] = { +% for format in formats: + [ISL_FORMAT_${format.name}] = { + .format = ISL_FORMAT_${format.name}, + .name = "ISL_FORMAT_${format.name}", + .bpb = ${format.bpb}, + .bw = ${format.bw}, + .bh = ${format.bh}, + .bd = ${format.bd}, + .channels = { + % for mask in ['r', 'g', 'b', 'a', 'l', 'i', 'p']: + <% channel = getattr(format, mask, None) %>\\ + % if channel.type is not None: + .${mask} = { ISL_${channel.type}, ${channel.size} }, + % else: + .${mask} = {}, + % endif + % endfor + }, + .colorspace = ISL_COLORSPACE_${format.colorspace}, + .txc = ISL_TXC_${format.txc}, + }, + +% endfor +}; +""") class Channel(object): -- cgit v1.2.3