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

Introduce symbol to get version of library #914

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
AC_PREREQ([2.60])
AC_INIT([libsecp256k1],[0.1])
AC_PREREQ([2.69])
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this necessary?

Copy link
Author

Choose a reason for hiding this comment

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

This was to do what bitcoin core was doing for version and release management, I think I can improve it though

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we shouldn't increase it to 2.69 without a good reason. I'm not sure if it really works with 2.60 but it's not a disaster if it fails.


define(_LIBSECP256K1_VERSION_MAJOR, 0)
define(_LIBSECP256K1_VERSION_MINOR, 8)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be 99 according to the preliminary plan (#856). I didn't have a particular reason for this besides matching Bitcoin Core's approach. But if I understand this PR correctly , secp256k1_version doesn't include _LIBSECP256K1_VERSION_IS_RELEASE. If minor version was 99 for non-releases, secp256k1_version can be used to distinguish between releases and non-releases.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah - I picked 0.8 to provide additional headroom for breaking API changes before stabilization.

0.8 could be cut as a branch now-ish

0.9 would represent a nearly complete API and allow for stabilization from 0.9 -> 0.9.9

and 1.0 would reflect final API / ABI

define(_LIBSECP256K1_VERSION_BUILD, 0)
define(_LIBSECP256K1_VERSION_RC, 0)
define(_LIBSECP256K1_VERSION_IS_RELEASE, false)
define(_LIBSECP256K1_VERSION, m4_join([.], _LIBSECP256K1_VERSION_MAJOR, _LIBSECP256K1_VERSION_MINOR, _LIBSECP256K1_VERSION_BUILD)m4_if(_LIBSECP256K1_VERSION_RC, [0], [], [rc]_LIBSECP256K1_VERSION_RC))

AC_INIT([libsecp256k1],_LIBSECP256K1_VERSION)
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([build-aux/m4])
AC_CANONICAL_HOST
Expand Down Expand Up @@ -493,6 +501,18 @@ AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG], [test x"$enable_module_schnorrsig" =
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$use_external_asm" = x"yes"])
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm"])

AC_DEFINE(LIBSECP256K1_VERSION_MAJOR, _LIBSECP256K1_VERSION_MAJOR, [Major version])
AC_DEFINE(LIBSECP256K1_VERSION_MINOR, _LIBSECP256K1_VERSION_MINOR, [Minor version])
AC_DEFINE(LIBSECP256K1_VERSION_BUILD, _LIBSECP256K1_VERSION_BUILD, [Version Build])
AC_DEFINE(LIBSECP256K1_VERSION_IS_RELEASE, _LIBSECP256K1_VERSION_IS_RELEASE, [Version is release])
AC_DEFINE(LIBSECP256K1_VERSION, _LIBSECP256K1_VERSION, [Version string])

AC_SUBST(LIBSECP256K1_VERSION_MAJOR, _LIBSECP256K1_VERSION_MAJOR)
AC_SUBST(LIBSECP256K1_VERSION_MINOR, _LIBSECP256K1_VERSION_MINOR)
AC_SUBST(LIBSECP256K1_VERSION_BUILD, _LIBSECP256K1_VERSION_BUILD)
AC_SUBST(LIBSECP256K1_VERSION_IS_RELEASE, _LIBSECP256K1_VERSION_IS_RELEASE)
AC_SUBST(LIBSECP256K1_VERSION, _LIBSECP256K1_VERSION)

# Make sure nothing new is exported so that we don't break the cache.
PKGCONFIG_PATH_TEMP="$PKG_CONFIG_PATH"
unset PKG_CONFIG_PATH
Expand Down
2 changes: 2 additions & 0 deletions include/secp256k1.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ typedef int (*secp256k1_nonce_function)(
#define SECP256K1_TAG_PUBKEY_HYBRID_EVEN 0x06
#define SECP256K1_TAG_PUBKEY_HYBRID_ODD 0x07

SECP256K1_API extern const char* secp256k1_version;

/** A simple secp256k1 context object with no precomputed tables. These are useful for
* type serialization/parsing functions which require a context object to maintain
* API consistency, but currently do not require expensive precomputations or dynamic
Expand Down
2 changes: 2 additions & 0 deletions src/secp256k1.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ void secp256k1_default_illegal_callback_fn(const char* str, void* data);
void secp256k1_default_error_callback_fn(const char* str, void* data);
#endif

const char* secp256k1_version = PACKAGE_VERSION;

static const secp256k1_callback default_illegal_callback = {
secp256k1_default_illegal_callback_fn,
NULL
Expand Down