On Fri, Mar 28, 2014 at 11:33 AM, Rendaw <[email protected]> wrote:
> On Friday, March 28, 2014 12:39:59 AM UTC+9, anonym anonym wrote:
>>
>> Hi
>>
>> I wanted to try tup out. But I have a issue that I couldn't find a
>> solution for.
>>
>> I have a line in my Tupfile like this:
>>
>> : foreach .*.cpp |> gcc %f -o %o |> %B.o
>>
>> The Problem is, that it's only valid for the directory where the Tupfile
>> is located. So it doesn't compile files in subdirectories. I really don't
>> want to copy my Tupfile into every subdirectory.
>>
>> Is there anything like this, that I can also search through
>> subdirectories?
>>
>> : foreach **/*.cpp |> gcc %f -o %o |> %B.o
>>
>> Thanks for helping.
>>
>
> If you don't mind using the Lua parser instead (
> http://gittup.org/tup/lua_parser.html), I think there are two options:
> 1. Use a Tupdefault.lua file which is applied in directories with no
> Tupfile.lua, for the whole tree below the directory containing
> Tupdefault.lua
> or 2. Write a recursive function or something and use tup.glob('*') to get
> lists of files. I think I'd recommend #1 though, I'm not sure #2 will
> work... you'd have to have some pattern for distinguishing directories and
> there might be other problems (performance, etc).
>
>
The downside of using a recursive foreach as in 2) would be that any time
you change the rules file or add/remove any file in any subdirectory, tup
has to regenerate all the rules for all the directories. In contrast, using
a setup as in 1) means that adding/removing a file causes tup to only
reparse that directory and any dependent directories. For small projects
you are unlikely to notice, but recursive functions do not scale well.
Here's an example setup of how to use 3 files to compile all files in a
subdirectories and link them into a single executable in the top-level:
$ cat Tupdefault.lua
outputs = {'%B.o'}
objects = myproj_root .. '/<objects>'
outputs.extra_outputs = {objects}
tup.foreach_rule('*.c', 'gcc -c %f -o %o', outputs)
$ cat Tupfile.lua
tup.rule('<objects>', 'gcc %<objects> -o %o', 'proj')
$ cat Tuprules.lua
myproj_root = tup.getcwd()
I think the way 'outputs' is specified is a little messy - if there's not a
better way to do that in Lua, we should have a better way to do that in one
of the rule functions (any thoughts, Rendaw?)
-Mike
--
--
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.