From: philburk Date: Fri, 10 Apr 2015 04:00:09 +0000 (+0000) Subject: Add Pa_GetVersionInfo() X-Git-Tag: pa_stable_v190600_20161030~36 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=199e88fa6636ac9114e1f66da75fc85e03375b6e;p=portaudio Add Pa_GetVersionInfo() Add scripts to update pa_svnrevision.h --- diff --git a/clear_svnrevision.sh b/clear_svnrevision.sh new file mode 100755 index 0000000..2501630 --- /dev/null +++ b/clear_svnrevision.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# +# Clear the SVN revision in the include file. +# This should be run before checking in code to SVN. +# +revision_filename=src/common/pa_svnrevision.h + +# Update the include file with the current SVN revision. +echo "#define PA_SVN_REVISION unknown" > ${revision_filename} + +echo ${revision_filename} now contains +cat ${revision_filename} diff --git a/examples/pa_devs.c b/examples/pa_devs.c index 4d6324c..595a05d 100644 --- a/examples/pa_devs.c +++ b/examples/pa_devs.c @@ -113,11 +113,10 @@ int main(void) printf( "ERROR: Pa_Initialize returned 0x%x\n", err ); goto error; } + + printf( "PortAudio version: 0x%08X\n", Pa_GetVersion()); + printf( "Version text: '%s'\n", Pa_GetVersionInfo()->versionText ); - printf( "PortAudio version number = 0x%08X\nPortAudio version text = '%s'\n", - Pa_GetVersion(), Pa_GetVersionText() ); - - numDevices = Pa_GetDeviceCount(); if( numDevices < 0 ) { diff --git a/include/portaudio.h b/include/portaudio.h index 6485958..3bb3b31 100644 --- a/include/portaudio.h +++ b/include/portaudio.h @@ -56,8 +56,9 @@ extern "C" int Pa_GetVersion( void ); /** Retrieve a textual description of the current PortAudio build, - * eg "PortAudio V19.5.0-devel (built Mar 3 2015 09:16:35)". + * eg "PortAudio V19.5.0-devel, revision 1952M". * The format of the text may change so do not try to parse the returned string. + * @deprecated use PaVersionInfo() instead */ const char* Pa_GetVersionText( void ); @@ -66,11 +67,36 @@ const char* Pa_GetVersionText( void ); * by Pa_GetVersion(). Use this to compare a specified version number with * the currently running version. For example: * - * if (Pa_GetVersion() < paMakeVersionNumber(19.5.1)) {} + * if (Pa_GetVersion() < paMakeVersionNumber(19,5,1)) {} */ #define paMakeVersionNumber(major, minor, subminor) \ (((major)&0xFF)<<16 | ((minor)&0xFF)<<8 | ((subminor)&0xFF)) + +/** + * A structure containing the components of the version numbers. + */ +typedef struct PaVersionInfo { + int versionMajor; + int versionMinor; + int versionSubMinor; + /** + * This is currently the SVN revision but may change in the future. + * The versionControlRevision is updated by running a script before compiling code. + * If the update does not occur then this value may be less + * than the actual SVN revision number. + */ + const char *versionControlRevision; + /** Version as a string, for example "PortAudio V19.5.0-devel, revision 1952M" */ + const char *versionText; +} PaVersionInfo; + +/** + * The structure that this points to is statically allocated. + * Do not attempt to free it or modify it. + */ +const PaVersionInfo* Pa_GetVersionInfo(); + /** Error codes returned by PortAudio functions. Note that with the exception of paNoError, all PaErrorCodes are negative. */ diff --git a/src/common/pa_front.c b/src/common/pa_front.c index 197516d..0632710 100644 --- a/src/common/pa_front.c +++ b/src/common/pa_front.c @@ -65,6 +65,7 @@ #include #include #include +#include /* needed for strtol() */ #include /* needed by PA_VALIDATE_ENDIANNESS */ #include "portaudio.h" @@ -76,6 +77,10 @@ #include "pa_trace.h" /* still usefull?*/ #include "pa_debugprint.h" +#ifndef PA_SVN_REVISION +#include "pa_svnrevision.h" +#endif + /** * This is incremented if we make incompatible API changes. * This version scheme is based loosely on http://semver.org/ @@ -104,8 +109,8 @@ #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) -#define PA_VERSION_STRING_ TOSTRING(paVersionMajor) "." TOSTRING(paVersionMinor) "." TOSTRING(paVersionSubMinor) -#define PA_VERSION_TEXT_ "PortAudio V" PA_VERSION_STRING_ "-devel (built " __DATE__ " " __TIME__ ")" +#define PA_VERSION_STRING_ TOSTRING(paVersionMajor) "." TOSTRING(paVersionMinor) "." TOSTRING(paVersionSubMinor) +#define PA_VERSION_TEXT_ "PortAudio V" PA_VERSION_STRING_ "-devel, revision " TOSTRING(PA_SVN_REVISION) int Pa_GetVersion( void ) { @@ -117,6 +122,19 @@ const char* Pa_GetVersionText( void ) return PA_VERSION_TEXT_; } +static PaVersionInfo versionInfo_ = { + .versionMajor = paVersionMajor, + .versionMinor = paVersionMinor, + .versionSubMinor = paVersionSubMinor, + .versionControlRevision = TOSTRING(PA_SVN_REVISION), + .versionText = PA_VERSION_TEXT_ +}; + +const PaVersionInfo* Pa_GetVersionInfo() +{ + return &versionInfo_; +} + #define PA_LAST_HOST_ERROR_TEXT_LENGTH_ 1024 static char lastHostErrorText_[ PA_LAST_HOST_ERROR_TEXT_LENGTH_ + 1 ] = {0}; diff --git a/src/common/pa_svnrevision.h b/src/common/pa_svnrevision.h new file mode 100644 index 0000000..c3a1313 --- /dev/null +++ b/src/common/pa_svnrevision.h @@ -0,0 +1 @@ +#define PA_SVN_REVISION unknown diff --git a/update_svnrevision.sh b/update_svnrevision.sh new file mode 100755 index 0000000..7a4631a --- /dev/null +++ b/update_svnrevision.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# +# Write the SVN revision to an include file. +# This should be run before compiling code on Linux or Macintosh. +# +revision_filename=src/common/pa_svnrevision.h + +# Run svnversion first to make sure it is installed before corrupting the +# include file. +svnversion . + +# Update the include file with the current SVN revision. +echo -n "#define PA_SVN_REVISION " > ${revision_filename} +svnversion . >> ${revision_filename} + +echo ${revision_filename} now contains +cat ${revision_filename}