<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 3, 2014 at 8:14 AM, Samuel Iglesias Gonsálvez <span dir="ltr"><<a href="mailto:siglesias@igalia.com" target="_blank">siglesias@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wednesday, December 03, 2014 03:44:19 PM Samuel Iglesias Gonsálvez wrote:<br>
> On Wednesday, December 03, 2014 03:29:46 PM Samuel Iglesias Gonsálvez wrote:<br>
> > On Wednesday, December 03, 2014 11:34:10 AM Emil Velikov wrote:<br>
> > > On 03/12/14 11:30, Emil Velikov wrote:<br>
> > > > Hi Iago,<br>
> > > ><br>
> > > > On 01/12/14 11:04, Iago Toral Quiroga wrote:<br>
> > > >> From: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>><br>
> > > >><br>
> > > >> We were auto-generating it before. The problem was that the<br>
> > > >> autogeneration<br>
> > > >> tool we were using was called "copy, paste, and edit". Let's use a<br>
> > > >> more<br>
> > > >> sensible solution.<br>
> > > >><br>
> > > >> Signed-off-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>><br>
> > > >><br>
> > > >> v2 by Samuel Iglesias <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
> > > >> - Remove format_pack.c as it is now autogenerated<br>
> > > >> - Add usage of INDENT_FLAGS in Makefile.am<br>
> > > >> - Remove trailing blank line<br>
> > > >><br>
> > > >> v3 by Samuel Iglesias <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
> > > >> - Merge format_convert.py into format_parser.py<br>
> > > >><br>
> > > >> - Adapt pack_*_* function generations<br>
> > > >><br>
> > > >> - Fix out-of-tree build<br>
> > > >><br>
> > > >> Signed-off-by: Samuel Iglesias Gonsalvez <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
> > > >> ---<br>
> > > >><br>
> > > >> src/mesa/Makefile.am | 14 +<br>
> > > >> src/mesa/Makefile.sources | 2 +-<br>
> > > >> src/mesa/main/format_pack.c | 2982<br>
> > > >> --------------------------------------<br>
> > > >> src/mesa/main/format_pack.c.mako<br>
> > > >><br>
> > > >> | 897 ++++++++++++<br>
> > > >><br>
> > > >> src/mesa/main/format_parser.py | 71 +<br>
> > > >> src/mesa/main/run_mako.py | 7 +<br>
> > > >> 6 files changed, 990 insertions(+), 2983 deletions(-)<br>
> > > >> delete mode 100644 src/mesa/main/format_pack.c<br>
> > > >> create mode 100644 src/mesa/main/format_pack.c.mako<br>
> > > >> create mode 100644 src/mesa/main/run_mako.py<br>
> > > >><br>
> > > >> diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am<br>
> > > >> index 932db4f..849c9da 100644<br>
> > > >> --- a/src/mesa/Makefile.am<br>
> > > >> +++ b/src/mesa/Makefile.am<br>
> > > >> @@ -19,6 +19,8 @@<br>
> > > >><br>
> > > >> # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> > > >> OTHER<br>
> > > >> DEALINGS # IN THE SOFTWARE.<br>
> > > >><br>
> > > >> +BUILDDIR_ABSOLUTE_PATH = $(PWD)<br>
> > > >> +<br>
> > > ><br>
> > > > You should not need this new variable. Additionally I'm suspecting<br>
> > > > this<br>
> > > > is the reason between the build hickups you/Jason are seeing.<br>
> > > ><br>
> > > >> SUBDIRS = . main/tests<br>
> > > >><br>
> > > >> if HAVE_X11_DRIVER<br>
> > > >><br>
> > > >> @@ -66,6 +68,7 @@ BUILT_SOURCES = \<br>
> > > >><br>
> > > >> main/get_hash.h \<br>
> > > >><br>
> > > >> main/format_info.c \<br>
> > > >><br>
> > > >> $(BUILDDIR)main/git_sha1.h \<br>
> > > >><br>
> > > >> + $(BUILDDIR)main/format_pack.c \<br>
> > > >><br>
> > > >> $(BUILDDIR)program/program_parse.tab.c \<br>
> > > >> $(BUILDDIR)program/lex.yy.c<br>
> > > >><br>
> > > >> CLEANFILES = \<br>
> > > >><br>
> > > >> @@ -89,6 +92,17 @@ main/format_info.c: main/formats.csv<br>
> > > >><br>
> > > >> \>><br>
> > > >><br>
> > > >> $< > $@.tmp;<br>
> > > >> \<br>
> > > >><br>
> > > >> mv $@.tmp $@;<br>
> > > >><br>
> > > >> +$(BUILDDIR)main/format_pack.c: main/format_pack.c.mako<br>
> > > >> main/formats.csv<br>
> > > >> \<br>
> > > >> + main/run_mako.py<br>
> > > >> main/format_parser.py<br>
> > > >> + $(AM_V_GEN)set -e; \<br>
> > > >> + cd $(srcdir); \<br>
> > > >> + $(PYTHON2) $(PYTHON_FLAGS) main/run_mako.py \<br>
> > > >> + main/format_pack.c.mako main/formats.csv > \<br>
> > > >> + $(BUILDDIR_ABSOLUTE_PATH)/$@.tmp; \<br>
> > > >> + cd $(BUILDDIR_ABSOLUTE_PATH); \<br>
> > > >> + cat $@.tmp | $(INDENT) $(INDENT_FLAGS) > $@; \<br>
> > > >> + rm $@.tmp;<br>
> > > >> +<br>
> > > ><br>
> > > > Can you prefix the files in the srcdir, and drop the tmp file (pipe<br>
> > > > directly into indent). It will make the above ~1/2 the size and a bit<br>
> > > > easier to follow :)<br>
> > ><br>
> > > Completely forgot, please add a couple of mines into the scons build<br>
> > > while you're here. src/mapi/shared-glapi/SConscript could serve as an<br>
> > > example.<br>
> ><br>
> > This is my first time modifying a SConscript file. Looking at what was<br>
> > done<br>
> > for format_info.c, I think that the following modification is enough to<br>
> > have format_pack.c autogenerated:<br>
> ><br>
> > format_pack = env.CodeGenerate(<br>
> ><br>
> > target = 'main/format_pack.c',<br>
> > script = 'main/run_mako.py',<br>
> > template = 'main/format_pack.c.mako',<br>
> > source = 'main/formats.csv',<br>
> > command = python_cmd + ' $SCRIPT ' + ' $TEMPLATE $SOURCE | ' +<br>
> ><br>
> > '$INDENT $INDENT_FLAGS > $TARGET'<br>
> ><br>
> > )<br>
> ><br>
> > I did a 80-char line wrap (it was not my email client), I suppose this is<br>
> > valid in SConscript, right? scons -f SConscript did not complain about it.<br>
><br>
> Comparing with the SConscript you told me, I did a couple of small<br>
> modifications to my previous code:<br>
><br>
> format_pack = env.CodeGenerate(<br>
> target = 'main/format_pack.c',<br>
> script = 'main/run_mako.py',<br>
> source = 'main/format_pack.c.mako main/formats.csv',<br>
> command = python_cmd + ' $SCRIPT ' + ' $SOURCE | ' + \<br>
> '$INDENT $INDENT_FLAGS > $TARGET'<br>
> )<br>
><br>
> I think this is more or less what we need but, if someone with more<br>
> experience on SConscript files sees a better way, it would be great to<br>
> learn how to do it.<br>
><br>
> I'm going to do some tests to check that this is building properly.<br>
><br>
<br>
</div></div>I finally found a way of generating format_pack.c and format_unpack.c with<br>
scons using env.CodeGenerate().<br>
<br>
As env.CodeGenerate() only uses one 'source' argument (it fails if you run<br>
what I wrote above), I ended up renaming format_pack.c.mako and<br>
format_unpack.c.mako to be python scripts with the template content inline.<br>
<br>
Now, they auto-generate format_{pack,unpack}.c files by themselves using the<br>
python mako module. Thanks to that, run_mako.py can be removed and both<br>
SConscript and Makefile.am modifications are simpler.<br></blockquote><div> <br></div><div>That works. I kind of liked having the run_mako wrapper, but that works too.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Any other idea/suggestion would be helpful.<br>
<br>
Sam<br>
<br>_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
<br></blockquote></div><br></div></div>