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 <topi.pohjolainen@intel.com>
This commit is contained in:
Jason Ekstrand 2017-06-22 11:27:04 -07:00
parent dd75edb429
commit 44e9d65757

View file

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