-
Notifications
You must be signed in to change notification settings - Fork 125
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
Add a header with the version of xkbcommon #400
Conversation
Currently there is no easy way to universally check the version of xkbcommon. Make clear we use the semantic version schema MAJOR.MINOR.PATCH and add an auto-generated header `version.h` that provide the following macros: - `XKBCOMMON_VERSION_MAJOR`: `MAJOR` version component - `XKBCOMMON_VERSION_MINOR`: `MINOR` version component - `XKBCOMMON_VERSION_PATCH`: `PATCH` version component - `XKBCOMMON_VERSION(a, b, c)`: create a version number from its components - `XKBCOMMON_VERSION_NUMBER`: version as a number, e.g. 1.6.0 is transformed into `0x010600`. Intended use example: `#if XKBCOMMON_VERSION_NUMBER >= XKBCOMMON_VERSION(1,7,0)` - `XKBCOMMON_VERSION_STR`: version as a string
@whot had previously argued against something similar: #172 (comment) |
Thanks for the pointer. It is a bit different though: here it is meant to do checks at compile time. The use case appeared in #398: I want to check my implementation in Qt but faced the impossibility to check enum values definition with macros, in order to support older version of the lib. |
Somewhat of the same downsides though, e.g. if I backport your patch(es) to Fedora's packages, Qt would continue to assume it doesn't exist because it doesn't check if the functionality exists, just the version number.
I only know how to do this with meson, but you'd use something like:
See the meson reference manual. Other build systems have the same, just less conveniently to invoke :) |
@whot I do not think backporting a feature without changing the major/minor version is a good idea anyway, is it ?
I agree: my previous version introduced a I did not know the trick with meson, thank you! It seems a bit convoluted to me and add non negligible amount of code in already complex build code. I will have a look to see if Qt already uses something similar though. I think a good compromise could be a macro Just sharing some idea. It would be nice to adopt a recommended practice (you know better than me) and use it throughout the code base. |
lemme introduce you to long-term stable distributions :P doesn't happen that often in Fedora, more commonly in RHEL (especially in the kernel). I guess my point is more that version numbers only work reliably where you can assume fast-moving consumer stack (like npm) but not where you have a library that you may have to hack up to support multiple years/decades of different applications. Backporting a single feature can be worthwhile in larger code-bases where you don't want the risk of pulling in hundreds of patches from a new release just to get access to a new small thing.
the issue with both of these is that you're shifting the effort from the ones who need to consume the new feature to yourself. But the ones that consume the feature are the ones who know what exactly they need. You (as in libxkbcommon) don't know how they use it so those defines are basically just putting things out there in the hope they're useful. And even if they're not you're now stuck with maintaining them forever. make Qt check for features if Qt wants to use a specific feature. They'll know how. input-leap's libei support uses CMake's |
Currently there is no easy way to universally check the version of xkbcommon.
Make clear we use the semantic version schema MAJOR.MINOR.PATCH and add an auto-generated header
version.h
that provide the following macros:XKBCOMMON_VERSION_MAJOR
:MAJOR
version componentXKBCOMMON_VERSION_MINOR
:MINOR
version componentXKBCOMMON_VERSION_PATCH
:PATCH
version componentXKBCOMMON_VERSION(a, b, c)
: create a version number from its componentsXKBCOMMON_VERSION_NUMBER
: version as a number, e.g. 1.6.0 is transformed into0x010600
. Intended use example:#if XKBCOMMON_VERSION_NUMBER >= XKBCOMMON_VERSION(1,7,0)
XKBCOMMON_VERSION_STR
: version as a string