Skip to content
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

Refactor build; better options for enabling database backends #12049

Closed

Conversation

JosiahWI
Copy link
Contributor

@JosiahWI JosiahWI commented Feb 3, 2022

Fixes #12026 and fixes #12045

  • Added find scripts for LevelDB and HiRedis
  • Created find_postgresql macro to avoid duplicating PostgreSQL searching logic
  • Added options with three values: SHRUG, ON and OFF for each optional database backend

Edit: The point of the PR is to change the behavior from "ON - use if found; OFF - do not use; REQUIRED - error if not found" to "ON - error if not found; OFF - do not use; AUTO (currently SHRUG, will be changed) - enable if found"

The behavior of ON right now is not intuitive. Everyone assumes that "ON" means "ON", not "maybe ON". This leads to people not knowing whether the option worked, because they don't know they have to scroll back through the CMake log to see. If someone turns a feature on, they are generally going to assume it is required. If we want to have this kind of "use if found" behavior, it should be internal to the build, or at least named something that indicates what it does, and it should be possible for the user to disable it.

How to test

Build with the different options and observe that it works as expected.

@JosiahWI JosiahWI force-pushed the refactor/cmake-database-options branch 3 times, most recently from 614abdf to ceb4f45 Compare February 4, 2022 22:55
@JosiahWI
Copy link
Contributor Author

JosiahWI commented Feb 4, 2022

I need help. I don't have a testing environment for this and I can't think of anything else I could've messed up. I've checked documentation for get_filename_component and find_library; I've tried with and without strings around the variables; I've listed the library names explicitly with the right extensions.

@JosiahWI
Copy link
Contributor Author

JosiahWI commented Feb 6, 2022

There's a right way to do this. There are built-in variables intended for custom library directories, so the fault is with the CI build and I'll be fixing that.

EDIT: Crosscompiling complicates things. I decided to do it the convenient way that I never even realized at first, just renaming the variables correctly.

@JosiahWI JosiahWI force-pushed the refactor/cmake-database-options branch 5 times, most recently from 6099bb4 to cf9e760 Compare February 6, 2022 19:29
Added tristate options with options SHRUG, ON and OFF, and did
refactoring.
@JosiahWI JosiahWI force-pushed the refactor/cmake-database-options branch from 816791f to 74e3385 Compare February 6, 2022 19:35
@rubenwardy rubenwardy added @ Build CMake, build scripts, official builds, compiler and linker errors Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements labels Feb 23, 2022
#
# And the following imported targets:
#
# leveldb::leveldb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about making the target & file name follow the official naming (LevelDB)?

as for the options you have free choice right? because keeping them uppercase would keep old build scripts working as before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The target naming was intentional to match the targets these projects export in their master branches, so that in the long term we can switch to using those projects' configs without having to update the target names all over the place. Good point about the build scripts. The options should stay the same as before, like you said.



set(ENABLE_POSTGRESQL SHRUG CACHE STRING "Enable PostgreSQL backend")
set_property(CACHE ENABLE_POSTGRESQL PROPERTY STRINGS SHRUG ON OFF)
Copy link
Member

@sfan5 sfan5 May 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my suggestion to keep compatibility with how these options worked before:

  • REQUIRED = search and error if missing
  • ON / TRUE / 1 = search but dont error
  • OFF / FALSE / 0 = dont search

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the objectives of the PR is to change the way this works. Description has been updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see there's a potentially big problem here because it could break compatibility with people's build scripts. It would probably be almost entirely alleviated just by allowing REQUIRED and making it an alias for ON, but perhaps it's still a bit unprecedented. What are your thoughts on this? Is it worth making the build system simpler if the options no longer work the same way? Maybe it would be possible to allow setting an option to switch to the new behavior, and then deprecate the old behavior after 1 or 2 more major releases or something.

-DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
-Dleveldb_INCLUDE_DIR=$libdir/leveldb/include \
-Dleveldb_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
-Dleveldb_DLL=$libdir/leveldb/lib/libleveldb.dll
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must stay bin here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

@sfan5 sfan5 added the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Jun 5, 2022
@JosiahWI JosiahWI closed this Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Action / change needed Code still needs changes (PR) / more information requested (Issues) @ Build CMake, build scripts, official builds, compiler and linker errors Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Find scripts for LevelDB and HiRedis Throw fatal error if enabled database backends are missing
3 participants