On Wed, Nov 20, 2019 at 10:17 AM arun.s <[email protected]>
wrote:

>
> 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 ?
>

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

-- 
-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tup-users/CA%2B6x0LW8iO_d5ssRGYkpXzJhC%2BtYVtGDhWvu83Kqd0qhe88G7A%40mail.gmail.com.

Reply via email to