buck2
                                
                                
                                
                                    buck2 copied to clipboard
                            
                            
                            
                        Giving an alias for multiple target patterns
I have a bunch of top level cells called root//, third-party//, and cellar//, and I'd like to build everything across all of them when doing things like CI integration.
Currently, I have to do that with a very verbose command:
buck2 build root//... third-party//... cellar//...
There is an [alias] stanza in .buckconfig which lets you alias targets, but not target patterns. This does not work:
[alias]
world = root//... third-party//... cellar//...
$ buck2 build world
File changed: root//.buckconfig
Parsing target pattern `world`
Caused by:
    0: Error resolving alias `world`
    1: [alias] section produced a dangling chain: `world -> root//... third-party//... cellar//...`
Workarounds
I think you could use @ syntax on the command line to include a file, so something like buck2 build @world, but that requires an actual file existing which is pretty messy, and I don't see why [alias] should not work.
Having such a target would also be useful for bxl scripts where I want to hardcode a name referring to every target pattern, without needing to repeat all the cell names everywhere constantly. The @ workaround would not work for this case.
Couldn’t you do this with a dummy target that has a dep on each of your patterns?
I don’t remember if deps attribute allows expressions, but perhaps it allows query functions
Couldn’t you do this with a dummy target that has a dep on each of your patterns?
That's not really the same thing, those targets will end up in the wrong configurations.
I think the "I want to build the world" problem is definitely a legit ask. You could imagine supporting syntax like ...//... for it. I don't know if we want to extend alias to support this though, I think I'd want to see some use examples of use cases outside of this particular one
You could imagine supporting syntax like
...//...for it.
I'd be perfectly happy with that, in this case; the syntax is perhaps a little less nice than buck2 build world (imo a little more intuitive), but I'm perfectly happy to compromise on that.
Really, this is the only thing I can think of for this, off the top of my head. I just asked for the generalized version since I figured it was a pretty natural extension of the existing feature, is all.
@stepancheg had suggested that instead we should treat cells as being more like aliases, and so root//... should actually work to build the whole world. If that's the direction that we want to go then having support for the ...// thing would be a little bit weird, so I'm going to ask around internally after the holidays what kind of timeline we'd be looking at for getting cross-cell references working, and then we can go from there