-
Notifications
You must be signed in to change notification settings - Fork 913
bazel: replace -layering_check overrides with scoped private_hdrs #10489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
98b6213
af79957
210ab6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,64 @@ package( | |
| features = ["layering_check"], | ||
| ) | ||
|
|
||
| # Public API headers. Leaf target with no deps on anything inside src/rsz/, | ||
| # so :private_hdrs can depend on it without forming a cycle back through | ||
| # :rsz. The same hdrs are also listed in :rsz for layering_check. | ||
| cc_library( | ||
| name = "rsz_hdrs", | ||
| hdrs = [ | ||
| "include/rsz/OdbCallBack.hh", | ||
| "include/rsz/Resizer.hh", | ||
| ], | ||
| includes = ["include"], | ||
| deps = [ | ||
| "//src/dbSta", | ||
| "//src/dbSta:SpefWriter", | ||
| "//src/dbSta:dbNetwork", | ||
| "//src/dpl", | ||
| "//src/est", | ||
| "//src/grt", | ||
| "//src/odb/src/db", | ||
| "//src/sta:opensta_lib", | ||
| "//src/stt", | ||
| "//src/utl", | ||
| ], | ||
| ) | ||
|
|
||
| cc_library( | ||
| name = "private_hdrs", | ||
| hdrs = [ | ||
| "src/DelayEstimator.hh", | ||
| "src/MoveCommitter.hh", | ||
| "src/MoveTracker.hh", | ||
| "src/OptimizerTypes.hh", | ||
| "src/RepairSetupContext.hh", | ||
| "src/RepairTargetCollector.hh", | ||
| "src/move/MoveCandidate.hh", | ||
| "src/move/MoveGenerator.hh", | ||
| "src/move/VtSwapMtCandidate.hh", | ||
| "src/policy/OptimizationPolicy.hh", | ||
| "src/policy/SetupLegacyBase.hh", | ||
| "src/policy/SetupLegacyMtPolicy.hh", | ||
| "src/policy/SetupLegacyPolicy.hh", | ||
| "src/policy/SetupMt1Policy.hh", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How are you detecting these short of looking at all the includes?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no short, bant actually looks at all includes. |
||
| ], | ||
| includes = [ | ||
| "src", | ||
| "src/move", | ||
| "src/policy", | ||
| ], | ||
| visibility = ["//src/rsz:__subpackages__"], | ||
| deps = [ | ||
| ":rsz_hdrs", | ||
| "//src/dbSta", | ||
| "//src/dbSta:dbNetwork", | ||
| "//src/odb/src/db", | ||
| "//src/sta:opensta_lib", | ||
| "//src/utl", | ||
| ], | ||
| ) | ||
|
|
||
| cc_library( | ||
| name = "rsz", | ||
| srcs = [ | ||
|
|
@@ -20,18 +78,14 @@ cc_library( | |
| "src/ConcreteSwapArithModules.cc", | ||
| "src/ConcreteSwapArithModules.hh", | ||
| "src/DelayEstimator.cc", | ||
| "src/DelayEstimator.hh", | ||
| "src/DelayEstimatorReporter.cc", | ||
| "src/DelayEstimatorReporter.hh", | ||
| "src/MoveCommitter.cc", | ||
| "src/MoveCommitter.hh", | ||
| "src/MoveTracker.cc", | ||
| "src/MoveTracker.hh", | ||
| "src/OdbCallBack.cc", | ||
| "src/Optimizer.cc", | ||
| "src/Optimizer.hh", | ||
| "src/OptimizerTypes.cc", | ||
| "src/OptimizerTypes.hh", | ||
| "src/PreChecks.cc", | ||
| "src/PreChecks.hh", | ||
| "src/Rebuffer.cc", | ||
|
|
@@ -42,9 +96,7 @@ cc_library( | |
| "src/RepairDesign.hh", | ||
| "src/RepairHold.cc", | ||
| "src/RepairHold.hh", | ||
| "src/RepairSetupContext.hh", | ||
| "src/RepairTargetCollector.cc", | ||
| "src/RepairTargetCollector.hh", | ||
| "src/Resizer.cc", | ||
| "src/ResizerObserver.hh", | ||
| "src/SwapArithModules.hh", | ||
|
|
@@ -61,9 +113,7 @@ cc_library( | |
| "src/move/MeasuredVtSwapGenerator.cc", | ||
| "src/move/MeasuredVtSwapGenerator.hh", | ||
| "src/move/MoveCandidate.cc", | ||
| "src/move/MoveCandidate.hh", | ||
| "src/move/MoveGenerator.cc", | ||
| "src/move/MoveGenerator.hh", | ||
| "src/move/RerouteCandidate.cc", | ||
| "src/move/RerouteCandidate.hh", | ||
| "src/move/RerouteGenerator.cc", | ||
|
|
@@ -101,27 +151,21 @@ cc_library( | |
| "src/move/VtSwapGenerator.cc", | ||
| "src/move/VtSwapGenerator.hh", | ||
| "src/move/VtSwapMtCandidate.cc", | ||
| "src/move/VtSwapMtCandidate.hh", | ||
| "src/move/VtSwapMtGenerator.cc", | ||
| "src/move/VtSwapMtGenerator.hh", | ||
| "src/policy/MeasuredVtSwapPolicy.cc", | ||
| "src/policy/MeasuredVtSwapPolicy.hh", | ||
| "src/policy/OptimizationPolicy.cc", | ||
| "src/policy/OptimizationPolicy.hh", | ||
| "src/policy/SetupCritVtSwapPolicy.cc", | ||
| "src/policy/SetupCritVtSwapPolicy.hh", | ||
| "src/policy/SetupDirectionalPolicy.cc", | ||
| "src/policy/SetupDirectionalPolicy.hh", | ||
| "src/policy/SetupLastGaspPolicy.cc", | ||
| "src/policy/SetupLastGaspPolicy.hh", | ||
| "src/policy/SetupLegacyBase.cc", | ||
| "src/policy/SetupLegacyBase.hh", | ||
| "src/policy/SetupLegacyMtPolicy.cc", | ||
| "src/policy/SetupLegacyMtPolicy.hh", | ||
| "src/policy/SetupLegacyPolicy.cc", | ||
| "src/policy/SetupLegacyPolicy.hh", | ||
| "src/policy/SetupMt1Policy.cc", | ||
| "src/policy/SetupMt1Policy.hh", | ||
| "src/policy/SetupReroutePolicy.cc", | ||
| "src/policy/SetupReroutePolicy.hh", | ||
| "src/policy/SetupTnsPolicy.cc", | ||
|
|
@@ -141,6 +185,8 @@ cc_library( | |
| ], | ||
| linkopts = ["-pthread"], | ||
| deps = [ | ||
| ":private_hdrs", | ||
| ":rsz_hdrs", | ||
| "//src/dbSta", | ||
| "//src/dbSta:SpefWriter", | ||
| "//src/dbSta:dbNetwork", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WorkerConnection.husesdst/JobMessage.hso this makes it a cyclic dependency: private headers needs to depend on :dst because of that but dst already depends on private_hdrs.(this problem also exists in a bunch of other
private_hdrsalready in the project, but let's not make the problem worse).If you invoke bant with
-vvvyou see for each header that the associated sources and headers include the corresponding library that is needed for that... here the JoMessage is found to be needing
//src/dstThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the general pattern is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude said the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think in termss of private headers. That brings you on the wrong path of organizing the project.
If you formulate things in terms of public headers and private implementation, this is already leaning towards a hard to maintain project structure.
Because then, you only create targets to make it compilable, but there is still no structure that is easy to understand.
Instead, think of building small units, each providing their thing and compose the structure from there.
These can be properly named and visibility opened where needed.
That allows proper layering from the ground up.
So make small libraries that each have a meaning (and typically: a unittest). Give it a good name ('private_hdrs' does not say what it is), and structure in as directed acyclic graph that makes the project structure easy to follow and fast to compile.
It might take a bit to detangle the current project structure, but this is the only easy-to-maintain way going forward.
For an inspiration a look at e.g. verible or xls for projects structured this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pattern of putting nearly every .cc in its own cc_library feels excessively fine grained and a maintenance burden. I am Inherently skeptical of any statement that there is only one way to accomplish a goal. I'm open to discussions of how to achieve encapsulation but I don't think the granularity must be single files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is typically between 1 and 5 files indeed. It makes maintenance much easier, as it is easy to find all the related things (such as tests and the corresponding code). The automatic dependency management can be done with
bant.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the bant setup now so I can get some experience with how it works and resolves this concern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in PR #10531