It would be easier to answer if you provided more details about what exactly you are trying to do (i.e. what is the rule, what your macro is doing, and how the sources are organized).
But guessing based on your original question, it sounded to me that your macro is doing something like this:
def map_reduce(name, srcs, **kwargs):
map_target_names = []
for src in srcs:
map_target_name = "%s_%s" % (name, input)
maps.append(map_target_name)
map_rule(name = map_target_name, src = src, **kwargs)
reduce_rule(name = name, srcs = map_target_names, **kwargs)
And that you wanted srcs to come from globs from multiple packages. If that is the case, then my suggestion would be to do something like this instead:
def map_group(name, srcs, **kwargs):
map_target_names = []
for src in srcs:
map_target_name = "%s_%s" % (name, input)
maps.append(map_target_name)
map_rule(map_target_name, src = src, **kwargs)
native.filegroup(name = name, srcs = map_target_names)
Then in a/b/BUILD and a/c/BUILD:
...
map_group(
name = "mapped_group",
...
and in a/BUILD:
...
reduce_rule(
name = "reduce_everything",
srcs = [
"//a/b:mapped_group",
"//a/c:mapped_group",
]
)
...