]> Repos - portaudio/commitdiff
Add Pa_GetVersionInfo()
authorphilburk <philburk@0f58301d-fd10-0410-b4af-bbb618454e57>
Fri, 10 Apr 2015 04:00:09 +0000 (04:00 +0000)
committerphilburk <philburk@0f58301d-fd10-0410-b4af-bbb618454e57>
Fri, 10 Apr 2015 04:00:09 +0000 (04:00 +0000)
Add scripts to update pa_svnrevision.h

clear_svnrevision.sh [new file with mode: 0755]
examples/pa_devs.c
include/portaudio.h
src/common/pa_front.c
src/common/pa_svnrevision.h [new file with mode: 0644]
update_svnrevision.sh [new file with mode: 0755]

diff --git a/clear_svnrevision.sh b/clear_svnrevision.sh
new file mode 100755 (executable)
index 0000000..2501630
--- /dev/null
@@ -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}
index 4d6324c35a30ba442899ee51fd6d19b4e9b151d2..595a05dbe7a94dfe0a1c2238e8959c4208fd29d7 100644 (file)
@@ -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 )
     {
index 64859587c655af658119876d1491494504bc6927..3bb3b3197a77efe9a8b03092f13c31bd4a18ba9c 100644 (file)
@@ -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.
 */
index 197516d814d6f70c4a85d48790b1c9137315c193..06327109efc4435e31c8f6b3d220da9115870101 100644 (file)
@@ -65,6 +65,7 @@
 #include <stdio.h>
 #include <memory.h>
 #include <string.h>
+#include <stdlib.h> /* needed for strtol() */
 #include <assert.h> /* needed by PA_VALIDATE_ENDIANNESS */
 
 #include "portaudio.h"
 #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/
 #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 (file)
index 0000000..c3a1313
--- /dev/null
@@ -0,0 +1 @@
+#define PA_SVN_REVISION unknown
diff --git a/update_svnrevision.sh b/update_svnrevision.sh
new file mode 100755 (executable)
index 0000000..7a4631a
--- /dev/null
@@ -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}