why are groups directory specific

53 views
Skip to first unread message

arun.s

unread,
Nov 20, 2019, 1:17:04 PM11/20/19
to tup-users

The tup manual says that the groups are directory specific and
I see the following example mentioned to highlight the point.


#./submodules/sm1/Tupfile
: foo.c |> gcc -c %f -o %o |> %B.o ../<submodgroup>

#./submodules/sm2/Tupfile
: bar.c |> gcc -c %f -o %o |> %B.o ../<submodgroup>

#./project/Tupfile
: baz.c | ../submodules/<submodgroup> |> gcc -c %f -o %o |> %B.o


I am trying to understand how groups being directory specific helps. Wouldn't a system based on unique group names alone have worked -like the following?

#./submodules/sm1/Tupfile
: foo.c |> gcc -c %f -o %o |> %B.o <submodgroup>

#./submodules/sm2/Tupfile
: bar.c |> gcc -c %f -o %o |> %B.o <submodgroup>

#./project/Tupfile
: baz.c | <submodgroup> |> gcc -c %f -o %o |> %B.o

Can someone explain how groups being directory specific helps ?
Thanks,
Arun

Mike Shal

unread,
Dec 1, 2019, 8:31:43 PM12/1/19
to tup-...@googlegroups.com
Hi Arun,

The reason the groups are directory-specific is so that separate projects support compositionality. In other words, you (or someone) should be able to take your project, and combine it with another separate project, and still have them both compile correctly. If groups were global, both your project and another project may have the same-named group <submodgroup>, which would then break both builds when you build them together. Suddenly your project would be including object files it did not intend to, and vice versa. By making them specific to the directory, it anchors them into the tree so that they are still unique globally.

If you prefer to have "global" groups, you can just anchor them to the root of your project. Something like this:

myproj/Tuprules.tup:
MYPROJ_ROOT = $(TUP_CWD)

Then each Tupfile in your project can reference groups as $(MYPROJ_ROOT)/<groupname>, and you have effectively made groups global for your project, but can still be combined with another project without worrying about conflicting names.

-Mike

arun.s

unread,
Dec 2, 2019, 9:14:01 AM12/2/19
to tup-users
Hi Mike,

Thanks for taking time to explain this. May I suggest making this the default way tup functions when no path is prepended to group.?  Based on the deepest included tuprules dir maybe?
It would keep the groups simpler in many tupfile projects.

Thanks,
Arun
Reply all
Reply to author
Forward
0 new messages