Open cpsauer opened 5 years ago
Buck allows you to override each section in the .buckconfig
on a cell-by-cell basis when you call Buck. To override a setting for all cells, you can use this syntax:
FYI:
-c *//foo.bar=baz
should override config setting for all cells.
(https://github.com/facebook/buck/issues/1470#issuecomment-328140336)
The exception is repositories
. These must be defined in a proper .buckconfig
file.
If you want to override the config for one of the dependencies fetched by Buckaroo, then you can look-up the name inside the top-level .buckconfig
file.
Since all of this can get quite verbose, it is usually best to write a wrapper script or arg-file (https://github.com/facebook/buck/issues/1470#issuecomment-324059272)
I think for your use-case, the best thing is to write a flag-file (See https://buckbuild.com/command/common_parameters.html) for production that overrides cell settings as required.
Really appreciate your help, @njlr.
Those hacks work, but definitely feels less satisfying than having cells inherit the parent's configuration by default. I started reading deeper into cells and quickly discovered that you'd already asked all the questions I was about to :)
In particular, for anyone else reading, @njlr had already asked after exactly the cell configuration behaviour I'd been surprised by... (https://github.com/facebook/buck/issues/1458, https://github.com/LoopPerfect/buckaroo/issues/131). @njlr, thanks for your patience, and sorry for re-asking.
After reading, I've got a hack that gives the inheritance behavior you were asking after. I just prefixed all my buckaroo .buckconfig with <file:../../../../.buckconfig>
to make them inherit from the containing project's .buckconfig. This should really be inheritance, because buck's INI parser takes the second value if you specify something twice (at least in my tests on macOS 10.14).
@njlr, thoughts on adding this prefix by default in buckaroo, if that's the behavior you'd thought was right, too?
In Buckaroo Redux we generate a config file that goes into the .buckconfig.d
folder; there is an opportunity to create a hierarchy in that way.
However, I think that arg-files are a better approach. They allow you to override configurations for all cells and specific cells. Since they are saved as files, you can still manage them in source-control.
In this setup, you would use .buckconfig
files for a reasonable default build, but these settings would get selectively overridden by the arg-files for custom builds (release, debug, etc.)
I made a demo here: https://github.com/njlr/buck-config-demo
Perhaps that will help?
Hey @njlr,
I was setting some flags in my project's .buckconfig and I noticed that they don't seem to propagate down to the buck cells containing the buckaroo dependencies.
I first noticed with iphoneos_target_sdk_version, but it looks like optimization flags, c++ version etc. don't propagate either.
From https://github.com/facebook/buck/issues/1470#issuecomment-324059272 looks like you've been thinking recently about including .buckconfig files from one another.
What's the best way to have settings from the main project's .buckconfig also propagate into buckaroo's cells?
I think that the desired behavior is messy here--but I presume most people would like their dependencies to be optimized, at least if the main project is. And for iOS and macosx, it's problematic that iphoneos_target_sdk_version, iphonesimulator_target_sdk_version, and macosx_target_sdk_version aren't set.
Thanks so much!