During the course of a different thread (Wildcard rules that ignore files with a particular prefix), the topic of using Groups with the Lua parser had come up.
Mike clarified the syntax which should work in the Lua parser: On Wednesday, June 11, 2014 11:01:02 AM UTC-4, [email protected] wrote: > > > Groups should still be the correct way to handle this. I just pushed a > simple patch to fix them with the Lua parser - they weren't handled > correctly in a few cases (notably when using '%f' and the like). Can you > pull the latest and give it a try in the Lua parser and see if it helps? Eg: > > tup.foreach_rule('*.c', 'gcc -c %f -o %o', {'%B.o', '<objs>'}) > tup.rule('<objs>', 'gcc %<objs> -o %o', 'prog') > > It's a bit crude since you still use the '<objs>' notation as in the > Tupfile parser. Perhaps a more Lua-ized version would look something like: > > tup.foreach_rule(... '%B.o', output_group='objs') > > or something. Maybe Rendaw has some thoughts there :) > I'm starting this topic to hopefully expand this conversation and address this topic in more detail. When I first started migrating my rules to the Lua parser, I made the erroneous assumption that Lua variables would be shared between the parser instances. This would be somewhat analogous to what I've done with non-recursive Makefiles -- use a variable: SHARED_LIBS = $SHARED_LIBS new_lib.so I understand now that this is not the way that the Lua parser works, but from a higher-level point of view, I can see some benefits to keeping these outputs as a Lua table (if technically possible). This is compatible with the outputs of the tup.rule / tup.frule / tup.foreach_rule functions. It is, furthermore, the native way to handle variables in Lua, which could allow for much flexibility with creating rules (over and above that which could be achieved with just groups). At this time, I am not nearly as familiar with the Tup codebase as I'd like to be, nor do I have too much knowledge of Lua -- so- my comments are really just from the point of view of a naive user. However, perhaps we can explore the possibility of serializing and deserializing table(s) to the database - so that a variable can be made accessible to any Tupfile within the directory structure. Perhaps something like this (please excuse any syntactical errors): my_table = tup.get_var('my_group1') -- Use my_table in rules... tup.save_var(my_table, 'my_group1') I guess that my underlying thought is that Groups is a *great* feature for Tup -- I use it extensively in my rules -- that dates to way before the Lua parser was written. Perhaps Lua might provide the possibility to replace this feature with an alternate construct. In other words, rather than duplicating Groups with the Lua parser, perhaps there is a more Lua-like way to do it. I hope that I'm not totally talking nonsense here -- I'm just trying to share my thoughts and suggestions for improving Tup. Thanks and regards, -Shmuel -- -- tup-users mailing list email: [email protected] unsubscribe: [email protected] options: http://groups.google.com/group/tup-users?hl=en --- You received this message because you are subscribed to the Google Groups "tup-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
