Skip to content

Commit

Permalink
Refactor .buckconfig common elements into .buckconfig.d
Browse files Browse the repository at this point in the history
Summary:
Move common settings, such as `prelude = bundled` and shim aliases, into a
`common.buckconfig` file inside the `.buckconfig.d` folder. The only remaining
settings inside the root `.buckconfig` should be setting specific to that
project.

This refactor also applies a new naming scheme for the root cell of Meta
projects. By deriving the root cell name from the public github repo, it makes
it easier to import external cells and avoid resolution errors due to shared
cell names. Moving forward, the expectation is that "root" shall be a cell
alias that always refers to the current cell, so each cell may always trust
that by using "root//" they are staying within their code (which was not a
guarantee before)

Reviewed By: bigfootjon

Differential Revision: D64579239

fbshipit-source-id: cb063176457d458bea4cc8891c4df323b778246b
  • Loading branch information
ckwalsh authored and facebook-github-bot committed Oct 23, 2024
1 parent 0c9750c commit ce2477d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
20 changes: 20 additions & 0 deletions .buckconfig.d/common.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[cells]
prelude = prelude
none = none

[cell_aliases]
config = prelude
ovr_config = prelude
bazel_skylib = gh_facebook_buck2_shims_meta
buck = gh_facebook_buck2_shims_meta
fbcode = gh_facebook_buck2_shims_meta
fbcode_macros = gh_facebook_buck2_shims_meta
fbsource = gh_facebook_buck2_shims_meta
shim = gh_facebook_buck2_shims_meta
toolchains = gh_facebook_buck2_shims_meta

[external_cells]
prelude = bundled

[parser]
target_platform_detector_spec = target:root//...->prelude//platforms:default target:shim//...->prelude//platforms:default
27 changes: 19 additions & 8 deletions shim/.buckconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,33 @@
# of this source tree.

[cells]
shim = .
gh_facebook_buck2_shims_meta = .

[cell_aliases]
root = gh_facebook_buck2_shims_meta

# This is a duplicate of .buckconfig.d/common.buckconfig, but due to the way
# we vendor the shim directory, common.buckconfig won't show up in the
# vendored .buckconfig.d directory.
# When the shim cell is no longer vendored in individual projects, this
# duplication cam be removed.
[cells]
prelude = prelude
toolchains = .
none = none

[cell_aliases]
config = prelude
ovr_config = prelude
fbcode = shim
fbsource = shim
fbcode_macros = shim
bazel_skylib = shim
buck = shim
bazel_skylib = gh_facebook_buck2_shims_meta
buck = gh_facebook_buck2_shims_meta
fbcode = gh_facebook_buck2_shims_meta
fbcode_macros = gh_facebook_buck2_shims_meta
fbsource = gh_facebook_buck2_shims_meta
shim = gh_facebook_buck2_shims_meta
toolchains = gh_facebook_buck2_shims_meta

[external_cells]
prelude = bundled

[parser]
target_platform_detector_spec = target:shim//...->prelude//platforms:default
target_platform_detector_spec = target:root//...->prelude//platforms:default target:shim//...->prelude//platforms:default
4 changes: 2 additions & 2 deletions shim/build_defs/lib/oss.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def _strip_third_party_rust_version(target: str) -> str:
# Cell the BUCK file being processed belongs to
ACTIVE_CELL = native.get_cell_name()

# The root cell of this project, generally "root" and does not need to be set.
# The root cell of this project, extracted from the "root" alias.
# Targets that explicitly reference this cell will not be rewritten, and
# targets that do not end up referencing a cell will be replaced with targets
# that reference this cell
ROOT_CELL = read_config("oss", "root_cell", "root")
ROOT_CELL = read_config("cell_aliases", "root", "root")

# The cell this file and the rest of the shim directory belong to, generally
# "shim" and does not need to be set.
Expand Down
4 changes: 2 additions & 2 deletions shim/shims.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ CPP_UNITTEST_DEPS = [
"shim//third-party/googletest:cpp_unittest_main",
]
CPP_FOLLY_UNITTEST_DEPS = [
"folly//folly/test/common:test_main_lib",
"folly//folly/ext/buck2:test_ext",
"gh_facebook_folly//folly/test/common:test_main_lib",
"gh_facebook_folly//folly/ext/buck2:test_ext",
]

def _get_headers_from_sources(srcs):
Expand Down

0 comments on commit ce2477d

Please sign in to comment.