bluekitchen / btstack

Dual-mode Bluetooth stack, with small memory footprint.
http://bluekitchen-gmbh.com
Other
1.73k stars 611 forks source link

have a way to detect BTstack version at compile time #640

Open ricardoquesada opened 1 week ago

ricardoquesada commented 1 week ago

Is your feature request related to a problem? Please describe. Recently the API to use the btstack_hid_parser_t changed in a way that is not backward compatible. In added usage_iterator.

Libraries that depend on BTstack (like Bluepad32) might use latest BTstack version (when bundled with Bluepad32), or might use the BTstack bundled with PicoSDK (which uses the old API).

For example, Bluepad32 (and other libraries) could use something like:

#if defined __has_include
#  if __has_include (<btstack_version.h>)
#    include <btstack_version.h>
#    ... compare-version
#    ... define use_new_api..
#  else
#   ... define use_old_api...
#endif

And btstack_version.h could have something like:

#define BTSTACK_VERSION_MAJOR 1
#define BTSTACK_VERSION_MINOR 6
#define BTSTACK_VERSION_PATCH 1

// optional: but useful to print in the logs
#define BTSTACK_VERSION_STRING "1.6.1"

Describe the solution you'd like Before releasing a new stable version, it would be great to have a header file that has the BTstack version defined. Based on that I can either use one API, or the other.

Describe alternatives you've considered

Additional context Add any other context or screenshots about the feature request here.

mringwal commented 1 week ago

Hi @ricardoquesada Fair request. There's already another feature request on the issue tracker.

Ideally, it would use the version and git hash, however, that's not possible across any all platforms.

However, updating a version file manually per release sounds doable.