-
Notifications
You must be signed in to change notification settings - Fork 544
CXX-2753 Refactor directory structure to allow for multiple ABI namespaces #1026
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
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 very much support the better alignment of the source and install directory structure.
Running ABI compliance check to verify compatibility is much appreciated.
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.
Sorry for the long delay. LGTM!
Description
Resolves CXX-2753 as part of CXX-1569. Verified by this patch.
This PR significantly changes the directory structure of CXX Driver sources files for bsoncxx and mongocxx in preparation for the addition of C++ sources and headers corresponding to additional ABI namespaces (not just
v_noabi
). Those will be introduced in subsequent PRs.The only observable changes to contents of the install directory structure pre-PR vs. post-PR should be the legacy CMake package config files (to support multiple include directories) and the uninstall script (simply due to changes in ordering of generated commands). Any other changes should be considered bugs in this PR.
Both binary and source compatibility (should be 100%) is verified by this patch, which runs abi-complance-checker comparing the proposed PR changes relative to the latest state of the target branch (note: not against the latest release of the CXX Driver, as is the case for the C Driver abi-compliance-check task).
Directory Structure
In this PR description, "source directory" refers to files tracked by the Git repository (.cpp, .hpp, .in, etc.), "binary directory" refers to files that are generated by CMake during configuration and build, and "install directory" refers to files present in the install prefix after the CXX Driver is commanded to evaluate installation rules.
The pre-PR source directory structure for the bsoncxx and mongocxx libraries is as follows (only the minimal set of files necessary to explain the directory refactor are listed):
This contrasts with the install directory structure for the bsoncxx and mongocxx libraries, where all current header files are placed within a
v_noabi
subdirectory corresponding to thev_noabi
ABI namespace:This PR proposes a source directory structure that better aligns with the install directory structure. The proposed source directory structure will also allow for the addition and maintenance of source files corresponding to additional ABI namespaces (i.e.
v1
) without conflicting with existingv_noabi
namespace files.The post-PR source directory structure is as follows:
In summary, this PR proposes bsoncxx and mongocxx follow this new directory structure:
Notes:
cmake/
rather thanlib/
as they do not directly contribute to the generated library files.include/
subdirectory contains public header files, and only public header files, such that the directory can be directly installed into the install prefix as-is. (Note: not all public headers, as some are generated.)lib/
are located in subdirectories directly corresponding to their intended location in both the binary and install directories (e.g.lib/bsoncxx/v_noabi/bsoncxx/config/config.hpp.in
-><install-prefix>/bsoncxx/v_noabi/bsoncxx/config/config.hpp
).ENABLE_TESTS
are located in a separatetest/
subdirectory. (Note:test_util/client_helpers.cpp
is a weird exception and will be dealt with properly later.)Currently, no source or header files make explicit reference to the
v_noabi
subdirectory, as the include directories are set to point toinclude/bsoncxx/v_noabi/
. However, to prepare for the addition of additional ABI namespace headers (e.g. underinclude/bsoncxx/v1/
), all files under bothinclude/
andlib/
are located under a<name>
subdirectory to facilitate inclusion of both public and private header files using the same include directive prefix. In other words, this directory structure is prepared to support all of the following include directives (where<project-dir>
refers to thesrc/<name>
source directory containing theCMakeLists.txt
file that callsproject(<name>)
):#include <bsoncxx/config/config.hpp>
(status quo: enabled by-I<project-dir>/include/bsoncxx/v_noabi
).#include <bsoncxx/private/libbson.hh>
(status quo: enabled by-I<project-dir>/lib/bsoncxx/v_noabi
).#include <bsoncxx/v_noabi/bsoncxx/config.hpp>
(future: enabled by-I<project-dir>/include
, consistent with-I<install-prefix>/include
).#include <bsoncxx/v_noabi/bsoncxx/private/libbson.hh>
(future: enabled by-I<project-dir>/lib
).#include <bsoncxx/v1/bsoncxx/config.hpp>
(future: enabled by-I<project-dir>/include
, consistent with-I<install-prefix>/include
).#include <bsoncxx/v1/bsoncxx/private/libbson.hh>
(future: enabled by-I<project-dir>/lib
).For backwards-compatibility,
-I<install-prefix>/bsoncxx/v_noabi
is expected to remain the default and have higher priority than-I<install-prefix>
. Users that want to opt intov1
ABI namespace headers (that are not already made available viav_noabi
headers) would be able to do so via thebsoncxx/v1/
prefix, and users that want to explicitly opt intov_noabi
ABI namespace headers (for clarity, forward-compatibility, etc.) would be able to do so via thebsoncxx/v_noabi/
prefix.To prepare to support the above scenario, the legacy CMake package config files were updated to support more than one path in
PACKAGE_INCLUDE_INSTALL_DIRS
(pre-PR, it assumed exactly one path only). The modern CMake package config files and pkgconfig config files are already prepared to support multiple include directories.Note: there are some files this PR currently places in the
v_noabi
subdirectory which may appear to deserve "promotion" to a multi-ABI-namespace file (i.e. files underconfig
). Such files will be individually and incrementally promoted in subsequent PRs as needed.Note: test files under
test
subdirectories have deliberately not been restructured to follow thev_noabi
subdirectory pattern. This is to preserve the location of test executables in the binary directory (as currently expected by EVG scripts). The updating of test files to align with the ABI namespace structure is considered low-priority and less-motivated than updates to the library files themselves. As such, refactoring of test files will be deferred to when they are demanded by the addition of tests for new ABI namespace entities.