librelist archives

« back to archive

Getting the yajl version numbers

Getting the yajl version numbers

From:
Hatem Nassrat
Date:
2010-05-25 @ 03:58
Is there a way of finding the version number (major, minor, micro) of
yajl programmatically when linking against the shared object. i.e is
it exported as a variable e.g. version in libyajl.so?

--
Hatem Nassrat

Re: [yajl] Getting the yajl version numbers

From:
Vitali Lovich
Date:
2010-05-25 @ 06:00
No, but should be pretty easy to add.

Lloyd, want me to submit a patch?

-Vitali

On 05/24/2010 08:58 PM, Hatem Nassrat wrote:
> Is there a way of finding the version number (major, minor, micro) of
> yajl programmatically when linking against the shared object. i.e is
> it exported as a variable e.g. version in libyajl.so?
>
> --
> Hatem Nassrat
>    

Re: [yajl] Getting the yajl version numbers

From:
Lloyd Hilaiel
Date:
2010-05-25 @ 13:44
Sure vitali, I'd pull that!

--lloyd


On May 25, 2010, at 12:00 AM, Vitali Lovich <vitali.lovich@palm.com>  
wrote:

> No, but should be pretty easy to add.
>
> Lloyd, want me to submit a patch?
>
> -Vitali
>
> On 05/24/2010 08:58 PM, Hatem Nassrat wrote:
>> Is there a way of finding the version number (major, minor, micro) of
>> yajl programmatically when linking against the shared object. i.e is
>> it exported as a variable e.g. version in libyajl.so?
>>
>> --
>> Hatem Nassrat
>>
>

Re: [yajl] Getting the yajl version numbers

From:
Vitali Lovich
Date:
2010-05-25 @ 18:10
Here's my patch.  Please let me know if there are any concerns.

-Vitali

On 05/25/2010 06:44 AM, Lloyd Hilaiel wrote:
> Sure vitali, I'd pull that!
>
> --lloyd
>
>
> On May 25, 2010, at 12:00 AM, Vitali Lovich<vitali.lovich@palm.com>
> wrote:
>
>    
>> No, but should be pretty easy to add.
>>
>> Lloyd, want me to submit a patch?
>>
>> -Vitali
>>
>> On 05/24/2010 08:58 PM, Hatem Nassrat wrote:
>>      
>>> Is there a way of finding the version number (major, minor, micro) of
>>> yajl programmatically when linking against the shared object. i.e is
>>> it exported as a variable e.g. version in libyajl.so?
>>>
>>> --
>>> Hatem Nassrat
>>>
>>>        
>>      

Re: [yajl] Getting the yajl version numbers

From:
Lloyd Hilaiel
Date:
2010-05-25 @ 18:34
On Tue, May 25, 2010 at 11:10:28AM -0700, Vitali Lovich wrote:
> Here's my patch.  Please let me know if there are any concerns.
> 
> -Vitali

applied, sir: 
http://github.com/lloyd/yajl/commit/7e43244f4a513eaa6e6fdb5680fc485da960df4e

lloyd

> On 05/25/2010 06:44 AM, Lloyd Hilaiel wrote:
> >Sure vitali, I'd pull that!
> >
> >--lloyd
> >
> >
> >On May 25, 2010, at 12:00 AM, Vitali Lovich<vitali.lovich@palm.com>
> >wrote:
> >
> >>No, but should be pretty easy to add.
> >>
> >>Lloyd, want me to submit a patch?
> >>
> >>-Vitali
> >>
> >>On 05/24/2010 08:58 PM, Hatem Nassrat wrote:
> >>>Is there a way of finding the version number (major, minor, micro) of
> >>>yajl programmatically when linking against the shared object. i.e is
> >>>it exported as a variable e.g. version in libyajl.so?
> >>>
> >>>--
> >>>Hatem Nassrat
> >>>
> 

> >From 95529440d4ff1f3937764f4575ac73c9ff590e7a Mon Sep 17 00:00:00 2001
> From: Vitali Lovich <vitali.lovich@palm.com>
> Date: Tue, 25 May 2010 11:04:06 -0700
> Subject: [PATCH 1/1] Add version information to yajl
> 
> Add a way to retrieve both the version of the API that was built against
> as well as the run-time build that it is running on.
> ---
>  src/CMakeLists.txt           |    7 ++++++-
>  src/api/yajl_version.h.cmake |   23 +++++++++++++++++++++++
>  src/yajl_version.c           |    7 +++++++
>  3 files changed, 36 insertions(+), 1 deletions(-)
>  create mode 100644 src/api/yajl_version.h.cmake
>  create mode 100644 src/yajl_version.c
> 
> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
> index 59027cb..729a8bf 100644
> --- a/src/CMakeLists.txt
> +++ b/src/CMakeLists.txt
> @@ -29,7 +29,9 @@
>  # POSSIBILITY OF SUCH DAMAGE.
>  
>  SET (SRCS yajl.c yajl_lex.c yajl_parser.c yajl_buf.c
> -          yajl_encode.c yajl_gen.c yajl_alloc.c)
> +          yajl_encode.c yajl_gen.c yajl_alloc.c
> +          yajl_version.c
> +)
>  SET (HDRS yajl_parser.h yajl_lex.h yajl_buf.h yajl_encode.h yajl_alloc.h)
>  SET (PUB_HDRS api/yajl_parse.h api/yajl_gen.h api/yajl_common.h)
>  
> @@ -58,6 +60,9 @@ SET_TARGET_PROPERTIES(yajl PROPERTIES
>  FILE(MAKE_DIRECTORY ${libDir})
>  FILE(MAKE_DIRECTORY ${incDir})
>  
> +# generate build-time source
> +CONFIGURE_FILE(api/yajl_version.h.cmake ${incDir}/yajl_version.h)
> +
>  # copy public headers to output directory
>  FOREACH (header ${PUB_HDRS})
>    SET (header ${CMAKE_CURRENT_SOURCE_DIR}/${header})
> diff --git a/src/api/yajl_version.h.cmake b/src/api/yajl_version.h.cmake
> new file mode 100644
> index 0000000..4262ff7
> --- /dev/null
> +++ b/src/api/yajl_version.h.cmake
> @@ -0,0 +1,23 @@
> +#ifndef YAJL_VERSION_H_
> +#define YAJL_VERSION_H_
> +
> +#include <yajl/yajl_common.h>
> +
> +#define YAJL_MAJOR ${YAJL_MAJOR}
> +#define YAJL_MINOR ${YAJL_MINOR}
> +#define YAJL_MICRO ${YAJL_MICRO}
> +
> +#define YAJL_VERSION ((YAJL_MAJOR * 10000) + (YAJL_MINOR * 100) + YAJL_MICRO)
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +extern int YAJL_API yajl_version(void);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* YAJL_VERSION_H_ */
> +
> diff --git a/src/yajl_version.c b/src/yajl_version.c
> new file mode 100644
> index 0000000..0671da7
> --- /dev/null
> +++ b/src/yajl_version.c
> @@ -0,0 +1,7 @@
> +#include <yajl/yajl_version.h>
> +
> +int yajl_version(void)
> +{
> +	return YAJL_VERSION;
> +}
> +
> -- 
> 1.7.0.3
> 

Re: [yajl] Getting the yajl version numbers

From:
Hatem Nassrat
Date:
2010-05-25 @ 18:29
On Tue, May 25, 2010 at 3:10 PM, Vitali Lovich <vitali.lovich@palm.com> wrote:
> Here's my patch.  Please let me know if there are any concerns.

So YAJL_VERSION will be an int? so for the upcoming release
yajl_version() would return 10010. I am not familiar with version
numbering/standards, i usually (in python) just leave it as a string,
so in my app version is "1.0.10". Int definitely makes version number
comparison faster which is essentially what I wanted it for.

-- 
Hatem Nassrat

Re: [yajl] Getting the yajl version numbers

From:
Vitali Lovich
Date:
2010-05-25 @ 18:35
On 05/25/2010 11:29 AM, Hatem Nassrat wrote:
> On Tue, May 25, 2010 at 3:10 PM, Vitali Lovich<vitali.lovich@palm.com>  wrote:
>    
>> Here's my patch.  Please let me know if there are any concerns.
>>      
> So YAJL_VERSION will be an int?
yup
>   so for the upcoming release
> yajl_version() would return 10010.
yes
>   I am not familiar with version
> numbering/standards, i usually (in python) just leave it as a string,
> so in my app version is "1.0.10". Int definitely makes version number
> comparison faster which is essentially what I wanted it for.
>    
I wrote it for version comparison since that's typically why you want 
versions (that's the typical C macro trick for doing it that I've seen).

If you want a string it's not difficult at all to add that too.

Re: [yajl] Getting the yajl version numbers

From:
Hatem Nassrat
Date:
2010-05-25 @ 18:37
On Tue, May 25, 2010 at 3:35 PM, Vitali Lovich <vitali.lovich@palm.com> wrote:
> If you want a string it's not difficult at all to add that too.

Nope, IMHO that might clutter yajl up for no extra added benefit. I
can always create the string myself.


-- 
Hatem Nassrat

Re: [yajl] Getting the yajl version numbers

From:
Vitali Lovich
Date:
2010-05-25 @ 18:48
That's what I was thinking.

On May 25, 2010, at 11:37 AM, Hatem Nassrat wrote:

> On Tue, May 25, 2010 at 3:35 PM, Vitali Lovich <vitali.lovich@palm.com> wrote:
>> If you want a string it's not difficult at all to add that too.
> 
> Nope, IMHO that might clutter yajl up for no extra added benefit. I
> can always create the string myself.
> 
> 
> -- 
> Hatem Nassrat