-
Notifications
You must be signed in to change notification settings - Fork 37.7k
refactor: Split util/system into exception, shell, and fs-specific files #25152
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
Conversation
See prior discussion in #24455 /cc @dongcarl @ryanofsky |
017ee15
to
0280e82
Compare
17389de
to
44361e9
Compare
Concept ACK I think you can fix this CI failure with: diff --git a/src/Makefile.am b/src/Makefile.am
index 3d6143d1ee..d06e51852e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -923,6 +923,7 @@ libbitcoinkernel_la_SOURCES = \
util/rbf.cpp \
util/serfloat.cpp \
util/settings.cpp \
+ util/shell.cpp \
util/strencodings.cpp \
util/string.cpp \
util/syscall_sandbox.cpp \ |
8792c7a
to
1fc8ae3
Compare
Thanks @dongcarl - I've got some issues to figure out, particularly on the |
afac05c
to
60fd43c
Compare
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
e84125b
to
7ead1da
Compare
aa51c7b
to
c434603
Compare
error is a low-level function with a sole dependency on LogPrintf, which is defined in logging.h
0e2858f
to
b070db4
Compare
#ifdef ENABLE_EXTERNAL_SIGNER | ||
#if defined(__GNUC__) | ||
// Boost 1.78 requires the following workaround. | ||
// See: https://github.com/boostorg/process/issues/235 | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wnarrowing" | ||
#endif | ||
#include <boost/process.hpp> | ||
#include <memory> | ||
#include <ostream> | ||
#include <vector> | ||
#if defined(__GNUC__) | ||
#pragma GCC diagnostic pop | ||
#endif | ||
#endif // ENABLE_EXTERNAL_SIGNER |
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.
AFAICT the build failures are coming from including these lines and I don't think they are needed, so I'm guessing this was included to debug a windows problem? I'm keen on moving this PR forward,. Is there some deeper problem here with running this patch on windows, or is it a compile-time issue?
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.
in e5243d3:
and I don't think they are needed,
Yea, there is no Boost usage in this file (and is no-longer any in the util library), so the entire ENABLE_EXTERNAL_SIGNER
chunk here should be removed.
#include <typeinfo> | ||
|
||
#ifdef WIN32 | ||
#include <compat/compat.h> |
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.
In f12cd1d:
Why is compat being included here? if it's for a windows.h
include (which isn't in compat anyways), then I'd rather we just include windows.h
.
#ifdef ENABLE_EXTERNAL_SIGNER | ||
#if defined(__GNUC__) | ||
// Boost 1.78 requires the following workaround. | ||
// See: https://github.com/boostorg/process/issues/235 | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wnarrowing" | ||
#endif | ||
#include <boost/process.hpp> | ||
#include <memory> | ||
#include <ostream> | ||
#include <vector> | ||
#if defined(__GNUC__) | ||
#pragma GCC diagnostic pop | ||
#endif | ||
#endif // ENABLE_EXTERNAL_SIGNER |
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.
in e5243d3:
and I don't think they are needed,
Yea, there is no Boost usage in this file (and is no-longer any in the util library), so the entire ENABLE_EXTERNAL_SIGNER
chunk here should be removed.
#include <string> | ||
|
||
#ifdef WIN32 | ||
#include <compat/compat.h> |
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.
In e5243d3:
If this is for windows.h
, would rather just include that.
|
||
#include <string> | ||
|
||
class UniValue; |
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.
In e5243d3: Why is UniValue
in here?
@@ -37,7 +37,7 @@ def main(): | |||
|
|||
os.chdir(CODE_DIR) | |||
files = subprocess.check_output( | |||
['git', 'ls-files', '--', '*.h', '*.cpp'], | |||
["git", "ls-files", "--", "*.h", "*.cpp"], |
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.
In 9ff4bb5:
This seems unrelated to this commit, and is not mentioned in the commit message.
🐙 This pull request conflicts with the target branch and needs rebase. |
I redid this work (fixing more of the includes and splitting out a few more functions) and have a branch over here: TheCharlatan#10 @Empact I'm still keen on moving this work forward. If you don't have the time right now, I'll attribute the commits to you and try to get my branch merged instead. |
Yep, it would be good to start getting some of this merged. |
aaced56 refactor: Move error() from util/system.h to logging.h (Ben Woosley) e7333b4 refactor: Extract util/exception from util/system (Ben Woosley) Pull request description: This pull request is part of the `libbitcoinkernel` project #24303 https://github.com/bitcoin/bitcoin/projects/18 and more specifically its "Step 2: Decouple most non-consensus code from libbitcoinkernel". These commits were originally authored by empact and are taken from their parent PR #25152. #### Context There is an ongoing effort to decouple the `ArgsManager` used for command line parsing user-provided arguments from the libbitcoinkernel library (#25290, #25487, #25527, #25862, #26177, and #27125). The `ArgsManager` is defined in `system.h`. #### Changes Next to providing better code organization, this PR removes some reliance of the tree of libbitcoinkernel header includes on `system.h` (and thus the `ArgsManager` definition) by moving some logging functions out of the `system.*` files. Further commits splitting more functionality out of `system.h` are still in #25152 and will be submitted in separate PRs once this PR has been processed. ACKs for top commit: MarcoFalke: re-ACK aaced56 🐍 Tree-SHA512: cb39f4cb7a77e7dc1887b1cbf340d53decab8880fc00878a2f12dc627fe67245b4aafd4cc31a9eab0fad1e5bb5d0eb4cdb8d501323ca200fa6ab7b201ae34aea
Going to close this for now, given that it's being split out, and there's a thumbs up from the author above. |
00e9b97 refactor: Move fs.* to util/fs.* (TheCharlatan) 106b46d Add missing fs.h includes (TheCharlatan) b202b3d Add missing cstddef include in assumptions.h (TheCharlatan) 18fb363 refactor: Extract util/fs_helpers from util/system (Ben Woosley) Pull request description: This pull request is part of the `libbitcoinkernel` project #24303 https://github.com/bitcoin/bitcoin/projects/18 and more specifically its "Step 2: Decouple most non-consensus code from libbitcoinkernel". This commit was originally authored by empact and is taken from its parent PR #25152. #### Context There is an ongoing effort to decouple the `ArgsManager` used for command line parsing user-provided arguments from the libbitcoinkernel library (#25290, #25487, #25527, #25862, #26177, and #27125). The `ArgsManager` is defined in `system.h`. A similar pull request extracting functionality from `system.h` has been merged in #27238. #### Changes Next to providing better code organization, this PR removes some reliance of the tree of libbitcoinkernel header includes on `system.h` (and thus the `ArgsManager` definition) by moving filesystem related functions out of the `system.*` files. There is already a pair of `fs.h` / `fs.cpp` in the top-level `src/` directory. They were not combined with the files introduced here, to keep the patch cleaner and more importantly because they are often included without the utility functions. The new files are therefore named `fs_helpers` and the existing `fs` files are moved into the util directory. Further commits splitting more functionality out of `system.h` are still in #25152 and will be submitted in separate PRs once this PR has been processed. ACKs for top commit: hebasto: ACK 00e9b97 Tree-SHA512: 31422f148d14ba3c843b99b1550a6fd77c77f350905ca324f93d4f97b652246bc58fa9696c64d1201979cf88733e40be02d262739bb7d417cf22bf506fdb7666
This is an attempt to significantly improve code organization while making changes as simple as possible to review.
Here I split four files out of
util/system
:util/exception
, holdingPrintExceptionContinue
util/shell
, holdingShellEscape
,runCommand
util/fs
, holding various file, folder, and path-specific functions (building onfs.h
andfilesystem
)util/args
, holdingArgsManager
and related functionsThe goal was to minimize review burden, so I made an effort to minimize the diffs and only modify the code when it was easy to confirm that the change would not have negative consequences.
That said, sourcing all of the windows-related headers was not straightforward, so I expect I'll need to touch this up to correct any issues there.