-
Notifications
You must be signed in to change notification settings - Fork 60
ref: little step forward to separate lib aktualizr headers #1688
Conversation
12486d5
to
cb57f4e
Compare
Codecov Report
@@ Coverage Diff @@
## master #1688 +/- ##
==========================================
- Coverage 76.54% 69.62% -6.92%
==========================================
Files 195 188 -7
Lines 13353 14674 +1321
==========================================
- Hits 10221 10217 -4
- Misses 3132 4457 +1325
Continue to review full report at Codecov.
|
Looks good so far, thanks! CI is complaining about some header ordering issues. I hope we can still keep C/C++, Boost/external, and internal headers grouped separately as the styleguide recommends. It might just be an issue of spacing. I also saw that |
cb57f4e
to
02a62c7
Compare
It looks like the only problem here is with the formatting because of header include ordering issues. This is a bit unfortunate. I would need to look into this a bit to decide what the right way to do this is. @kbushgit or @eu-smirnov do either of you have strong opinions on how we should order these headers and if the stipulations of the Google style guide (and clang-tidy) are appropriate? |
02a62c7
to
bade364
Compare
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.
Wow, that's a lot of boilerplate. But looks pretty good so far!
Why prefer including the public API headers with angle brackets instead of quotes? I know that might be preferable for other users of the library, but internally, shouldn't we be searching locally for the headers before searching system paths?
|
||
namespace api { | ||
class CommandQueue; | ||
} |
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.
I forget, does class api::CommandQueue
work? I thought it did and it's a little cleaner.
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.
yes we use it, the disadvantage he is that we have to use smart ptr, the reason is that we cant simple uses forward declaration with member objects defined by the value
aktualizr/include/libaktualizr/aktualizr.h
Line 250 in 39f58c5
std::shared_ptr<api::CommandQueue> api_queue_; |
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.
Yeah, that's fine, I just meant if we could put this forward declaration on one line by using the scope resolution operator (::
) instead of this three-line variant.
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.
Why not a unique_ptr, though?
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.
Why not a unique_ptr, though?
It will cause a compilation error:
Invalid application of ‘sizeof’ to incomplete type ‘api::CommandQueue’
static_assert(sizeof(_Tp)>0,
It can be fixed by adding an empty dtor for Aktualizr.
Here is an answer with a good explanation
https://stackoverflow.com/a/9954553
include/libaktualizr/config.h
Outdated
#include <libaktualizr/logging_config.h> | ||
#include <libaktualizr/packagemanagerconfig.h> | ||
#include <libaktualizr/storage_config.h> | ||
#include <libaktualizr/telemetryconfig.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.
If we end up having to move all these config files into a common directory, then it no longer makes sense for them to be separate files. We originally separated them out into their respective modules to keep them tied to their relevant code. But if that doesn't work, it's just unnecessary complexity to have them scattered across multiple tiny files.
@@ -1,4 +1,4 @@ | |||
set(HEADERS config.h) | |||
#set(HEADERS config.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.
This (and the other commented-out line below) should be removed if they really aren't needed anymore.
@@ -28,7 +30,8 @@ Aktualizr::Aktualizr(Config config, std::shared_ptr<INvStorage> storage_in, | |||
|
|||
void Aktualizr::Initialize() { | |||
uptane_client_->initialize(); | |||
api_queue_.run(); | |||
api_queue_ = std::make_shared<api::CommandQueue>(); |
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 we move the object creation to the constructor?
This is a good point and it makes sense but only for the default paths, which are system paths plus current project 's directory. The compiler organizes include paths in the queue and then looking for include files from left to right in that queue, so if we explicitly specify the path using -I (include_directories) option this path will be appended to the left in that queue, so the compiler will be treated user-added path first before look into the system path. In general, I agree that in our nonpublic headers it may be preferred to use quotes instead of angle brackets but not in the public headers. Since I do not see any disadvantages I would prefer to leave that as is and keep using the same approach for both public and private headers. |
Did you mean to close this? :) I assume not.
I don't think this is completely accurate. At least gcc is explicit that brackets should be used for system headers and quotes for "header files of your own program". My interpretation is that users of libaktualizr will want to include with brackets, but within the project, when referring to our own headers, we should use quotes. |
While there is indeed no difference between |
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
f941134
to
b19559e
Compare
This was the github CI failure:
|
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
I don't know if you're still unable to see the failures, but here's what I'm seeing:
and
And it needs a rebase now. If you have clang-tidy-8 on your local machine, I suspect there are going to be more complaints from that, so I encourage running it locally. |
* The intent is to avoid unintentional use of the "naked" relative path by | ||
* mandating a base directory for each instantiation. | ||
* | ||
* @todo has to be moved into Utils namespace |
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.
Is this todo
still accurate? If so, I'd prefer it were TODO
to match all the others in the code. If not, please remove the line.
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.
this syntax is a doxygen
compliant, I know we use TODO
but what the reason to keep this approach in our public headers!
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.
But is that "todo" more meaningful for the API users reading the documentation or for us, the developers that maintain it and whose burden it would be to actually put it in the Utils
namespace?
More importantly, is it actually important for BasedPath
to live in the Utils
namespace? I'm not convinced it "has to be moved".
@@ -12,6 +12,8 @@ | |||
#include <sys/socket.h> | |||
#include <sys/types.h> | |||
|
|||
#include "utilities/utils.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.
The ordering here is mixed up. Seems like it's split into two sections.
@@ -13,4 +12,5 @@ add_aktualizr_test(NAME config SOURCES config_test.cc ARGS ${PROJECT_BINARY_DIR} | |||
# config file test for collisions between import and FS->SQL migration paths | |||
add_test(NAME config-import COMMAND ${PROJECT_SOURCE_DIR}/tests/run_import_clash_test.sh ${PROJECT_SOURCE_DIR}/config) | |||
|
|||
aktualizr_source_file_checks(${SOURCES} ${HEADERS} config_test.cc) | |||
#aktualizr_source_file_checks(${SOURCES} ${HEADERS} config_test.cc) |
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.
This commented-out line can be removed.
|
||
#include "utilities/utils.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.
?
dequeue_buffer.h | ||
exceptions.h | ||
fault_injection.h | ||
sig_handler.h | ||
timer.h | ||
types.h | ||
utils.h | ||
utils.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.
Indenting is off in these two changed lines.
@@ -4,12 +4,16 @@ | |||
#include <string> | |||
#include <vector> | |||
|
|||
#include <string> | |||
#include <vector> |
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.
Duplicated.
on my machine installed clang-tidy-8 I don't see such error... We cant use default destructor in the combination of forwarding declaration and unique_ptr because of this compilation error:
|
refactoring regarding separating
libaktualizr
headers "internal/external"Signed-off-by: Kostiantyn Bushko kbushko@intellias.com