Re: [Mesa-dev] [PATCH] isl: Replace bash generator with python generator
Quoting Dylan Baker (2016-06-09 15:06:42) > Quoting Emil Velikov (2016-06-09 14:12:46) > > On 9 June 2016 at 21:56, Dylan Bakerwrote: > > > Emil, should this take an argument, or is it fine as is? I was going to > > > ask Matt, but he's on vacation... > > > > > As Jason, suggested - it's better if the build provides the output > > filename. Can we please do that ? > > IIRC some of the existing python scripts (the src/gallium/drivers/swr > > ones come to mind) in mesa already do so, thus one can borrow/share > > code and ideas. > > > > I'll be having dinner in a moment but I'll send you and piece to > > squash for the Android side of things. > > Ah, thanks! I meant to ask about that. I'll update to take the filenames > via command line arguments. > > Lets assume that I'll use --csv and --out as the options. > > Dylan And that's what I've coded up. I've also fixed the Makefile.am which worked for some reason the other day but is totally busted on list... > > > > > Thanks > > Emil > > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev signature.asc Description: signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] isl: Replace bash generator with python generator
Quoting Emil Velikov (2016-06-09 14:12:46) > On 9 June 2016 at 21:56, Dylan Bakerwrote: > > Emil, should this take an argument, or is it fine as is? I was going to > > ask Matt, but he's on vacation... > > > As Jason, suggested - it's better if the build provides the output > filename. Can we please do that ? > IIRC some of the existing python scripts (the src/gallium/drivers/swr > ones come to mind) in mesa already do so, thus one can borrow/share > code and ideas. > > I'll be having dinner in a moment but I'll send you and piece to > squash for the Android side of things. Ah, thanks! I meant to ask about that. I'll update to take the filenames via command line arguments. Lets assume that I'll use --csv and --out as the options. Dylan > > Thanks > Emil signature.asc Description: signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] isl: Replace bash generator with python generator
On 9 June 2016 at 21:56, Dylan Bakerwrote: > Emil, should this take an argument, or is it fine as is? I was going to > ask Matt, but he's on vacation... > As Jason, suggested - it's better if the build provides the output filename. Can we please do that ? IIRC some of the existing python scripts (the src/gallium/drivers/swr ones come to mind) in mesa already do so, thus one can borrow/share code and ideas. I'll be having dinner in a moment but I'll send you and piece to squash for the Android side of things. Thanks Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] isl: Replace bash generator with python generator
Emil, should this take an argument, or is it fine as is? I was going to ask Matt, but he's on vacation... Dylan signature.asc Description: signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] isl: Replace bash generator with python generator
[snip] Quoting Jason Ekstrand (2016-06-08 16:20:33) > gen_format_layout.c.mako > > I made this comment in the office today but I think the mako here is simple > enough that we might be better off just putting it all in one file. > I know you're not a fan of separate templates, and if the consensus is to put the template in the python file I'll do that, but my experience working with mako makes me wary of doing that for templates over a few lines. I think they're very hard to read (remember that the copyright header is part of the template), and you don't get syntax highlighting which makes them much harder to work with. [snip] > > +def reader(): > > + """Wrapper around csv.reader that skips comments and blanks.""" > > + # csv.reader actually reads the file one line at a time (it was > > designed > to > > + # open excel generated sheets), so hold the file until all of the lines > are > > + # read. > > + with open('isl_format_layout.csv', 'r') as f: > > I'm not so sure this works. It's probably better to pass the file name in. > Maybe this is safe but I'm skeptical. I don't know, I can change it, it just seemed kinda silly to add command parsing to a generator that reads exactly one file. Maybe someone with more autotools experience could say whether this is a good idea or not? > > Other than those two comments, this seems perfectly reasonable. > Okay, I'll wait for some more feedback and send out a v2. [snip] Dylan signature.asc Description: signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] isl: Replace bash generator with python generator
On Jun 7, 2016 5:32 PM, "Dylan Baker"wrote: > > This replaces the current bash generator with a python based generator > using mako. It's quite fast and works with both python 2.7 and python > 3.5, and should work with 3.3+ and maybe even 3.2. > > It produces an almost identical file except for a minor layout changes, > and the addition of a "generated file, do not edit" warning. > > Signed-off-by: Dylan Baker > --- > src/intel/isl/Makefile.am| 7 +- > src/intel/isl/gen_format_layout.c.mako | 77 + > src/intel/isl/gen_format_layout.py | 143 +++ > src/intel/isl/isl_format_layout_gen.bash | 129 > 4 files changed, 224 insertions(+), 132 deletions(-) > create mode 100644 src/intel/isl/gen_format_layout.c.mako > create mode 100644 src/intel/isl/gen_format_layout.py > delete mode 100755 src/intel/isl/isl_format_layout_gen.bash > > diff --git a/src/intel/isl/Makefile.am b/src/intel/isl/Makefile.am > index 74f863a..ee75bbd 100644 > --- a/src/intel/isl/Makefile.am > +++ b/src/intel/isl/Makefile.am > @@ -66,10 +66,11 @@ libisl_gen9_la_CFLAGS = $(libisl_la_CFLAGS) -DGEN_VERSIONx10=90 > > BUILT_SOURCES = $(ISL_GENERATED_FILES) > > -isl_format_layout.c: isl_format_layout_gen.bash \ > +isl_format_layout.c: gen_format_layout.py \ > + gen_format_layout.c.mako \ > isl_format_layout.csv > - $(AM_V_GEN)$(srcdir)/isl_format_layout_gen.bash \ > - <$(srcdir)/isl_format_layout.csv >$@ > + $(PYTHON_GEN) $(AM_V_GEN)$(srcdir)/gen_format_layout.py \ > + <$(srcdir)/isl_format_layout.csv > > # > # Tests > diff --git a/src/intel/isl/gen_format_layout.c.mako b/src/intel/isl/gen_format_layout.c.mako I made this comment in the office today but I think the mako here is simple enough that we might be better off just putting it all in one file. > new file mode 100644 > index 000..241a923 > --- /dev/null > +++ b/src/intel/isl/gen_format_layout.c.mako > @@ -0,0 +1,77 @@ > +## encoding=utf-8 > +## Copyright © 2016 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 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. > +## > +## This is the mako template companion to gen_format_layout.py > +## > +/* This file is autogenerated by gen_format_layout.{c.mako,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.h" > + > +const struct isl_format_layout > +isl_format_layouts[] = { > +% for format in formats: > + [ISL_FORMAT_${format.name}] = { > +.format = ISL_FORMAT_${format.name}, > +.name =
[Mesa-dev] [PATCH] isl: Replace bash generator with python generator
This replaces the current bash generator with a python based generator using mako. It's quite fast and works with both python 2.7 and python 3.5, and should work with 3.3+ and maybe even 3.2. It produces an almost identical file except for a minor layout changes, and the addition of a "generated file, do not edit" warning. Signed-off-by: Dylan Baker--- src/intel/isl/Makefile.am| 7 +- src/intel/isl/gen_format_layout.c.mako | 77 + src/intel/isl/gen_format_layout.py | 143 +++ src/intel/isl/isl_format_layout_gen.bash | 129 4 files changed, 224 insertions(+), 132 deletions(-) create mode 100644 src/intel/isl/gen_format_layout.c.mako create mode 100644 src/intel/isl/gen_format_layout.py delete mode 100755 src/intel/isl/isl_format_layout_gen.bash diff --git a/src/intel/isl/Makefile.am b/src/intel/isl/Makefile.am index 74f863a..ee75bbd 100644 --- a/src/intel/isl/Makefile.am +++ b/src/intel/isl/Makefile.am @@ -66,10 +66,11 @@ libisl_gen9_la_CFLAGS = $(libisl_la_CFLAGS) -DGEN_VERSIONx10=90 BUILT_SOURCES = $(ISL_GENERATED_FILES) -isl_format_layout.c: isl_format_layout_gen.bash \ +isl_format_layout.c: gen_format_layout.py \ + gen_format_layout.c.mako \ isl_format_layout.csv - $(AM_V_GEN)$(srcdir)/isl_format_layout_gen.bash \ - <$(srcdir)/isl_format_layout.csv >$@ + $(PYTHON_GEN) $(AM_V_GEN)$(srcdir)/gen_format_layout.py \ + <$(srcdir)/isl_format_layout.csv # # Tests diff --git a/src/intel/isl/gen_format_layout.c.mako b/src/intel/isl/gen_format_layout.c.mako new file mode 100644 index 000..241a923 --- /dev/null +++ b/src/intel/isl/gen_format_layout.c.mako @@ -0,0 +1,77 @@ +## encoding=utf-8 +## Copyright ?? 2016 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 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. +## +## This is the mako template companion to gen_format_layout.py +## +/* This file is autogenerated by gen_format_layout.{c.mako,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.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}", +.bs = ${format.bs}, +.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} = {}, + %