3

I'd like to know if there's any wildcard for directory structure in Tupfile, something like %B.o, which takes input filename without extension.

My Tupfile rules currently look like this:

: foreach src/*.cpp |> !cxx_c_debug |> build/d/o/%B.o

: foreach src/dir/*.cpp |> !cxx_c_debug |> build/d/o/dir/%B.o

: foreach src/dir2/subdir/*.cpp |> !cxx_c_debug |> build/d/o/dir2/subdir/%B.o

...

As you can imagine, there are many dirs and subdirs. I would like to use some kind of wildcard for bolded directory structure, instead of enumerating those one by one. Is there any way to accomplish this without creating a new Tupfile in each of those directories?

Thanks

Community
  • 1
  • 1
honza42
  • 101
  • 6

1 Answers1

3

The easiest way will be to use a Tupdefault file.

This is a feature, available in tup 0.7.4, but not yet documented. If you place a file named Tupdefault anywhere in your source tree, it will act at the Tupfile in all subdirectories, including the one where you placed it.

To get your particular example working, the Tupdefault file can look like this:

include_rules
: foreach *.cpp |> !cxx_c_debug |> %B.o

You'll probably also need to use the tup's groups feature to collect all object files in a single group placed in your project root and use that group to link them together. This is another feature that is currently being documented, but it's explained by tup's author Mike Shal here:

https://github.com/gittup/tup/issues/85#issuecomment-19423194

zah
  • 5,314
  • 1
  • 34
  • 31