now reports hash of source file used to build shim

This commit is contained in:
Spencer Russell 2017-05-09 13:08:00 -04:00
parent 5c40329df6
commit 9e3e66d37a
3 changed files with 18 additions and 10 deletions

10
deps/src/Makefile vendored
View file

@ -5,13 +5,17 @@ ifeq (exists, $(shell [ -e Make.user ] && echo exists ))
include Make.user include Make.user
endif endif
TARGETDIR=../usr/lib
OBJS = pa_shim.o
SOURCEHASH=$(shell sha256sum pa_shim.c | awk '{print $$1}')
#check-env: #check-env:
#ifndef JULIA_INC #ifndef JULIA_INC
# $(error Environment variable JULIA_INC is not set.) # $(error Environment variable JULIA_INC is not set.)
#endif #endif
#INC =-I"$(JULIA_INC)" #INC =-I"$(JULIA_INC)"
CFLAGS =-Wall -Wno-strict-aliasing -fno-omit-frame-pointer -fPIC -g CFLAGS =-Wall -Wno-strict-aliasing -fno-omit-frame-pointer -fPIC -DSOURCEHASH=\"$(SOURCEHASH)\"
LDFLAGS =-L../../../RingBuffers/deps/usr/lib -lpa_ringbuffer LDFLAGS =-L../../../RingBuffers/deps/usr/lib -lpa_ringbuffer
# LINUX_LIBS =-lrt # LINUX_LIBS =-lrt
# LINUX_LDFLAGS =-rdynamic # LINUX_LDFLAGS =-rdynamic
@ -19,10 +23,6 @@ LDFLAGS =-L../../../RingBuffers/deps/usr/lib -lpa_ringbuffer
# portaudio and libsndfile # portaudio and libsndfile
# DARWIN_LDFLAGS =-L../../../Homebrew/deps/usr/lib # DARWIN_LDFLAGS =-L../../../Homebrew/deps/usr/lib
# DARWIN_INC =-I../../../Homebrew/deps/usr/include # DARWIN_INC =-I../../../Homebrew/deps/usr/include
TARGETDIR=../usr/lib
OBJS = pa_shim.o
# Figure out OS and architecture # Figure out OS and architecture
OS = $(shell uname) OS = $(shell uname)
ifneq (,$(findstring MINGW,$(OS))) ifneq (,$(findstring MINGW,$(OS)))

8
deps/src/pa_shim.c vendored
View file

@ -3,7 +3,6 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#define SHIM_VERSION 3
#define MIN(x, y) ((x) < (y) ? (x) : (y)) #define MIN(x, y) ((x) < (y) ? (x) : (y))
typedef enum { typedef enum {
@ -39,10 +38,11 @@ void senderr(pa_shim_info_t *info, pa_shim_errmsg_t msg) {
} }
} }
// return the version of the shim so we can make sure things are in sync // return the sha256 hash of the shim source so we can make sure things are in sync
int pa_shim_getversion(void) const char *pa_shim_getsourcehash(void)
{ {
return SHIM_VERSION; // defined on the command-line at build-time
return SOURCEHASH;
} }
/* /*

View file

@ -29,5 +29,13 @@ mutable struct pa_shim_info_t
errorhandle::Ptr{Void} # condition to notify on new errors errorhandle::Ptr{Void} # condition to notify on new errors
end end
shimversion() = ccall((:pa_shim_getversion, libpa_shim), Cint, ()) """
PortAudio.shimhash()
Return the sha256 hash(as a string) of the source file used to build the shim.
We may use this sometime to verify that the distributed binary stays in sync
with the rest of the package.
"""
shimhash() = unsafe_string(
ccall((:pa_shim_getsourcehash, libpa_shim), Cstring, ()))
Base.unsafe_convert(::Type{Ptr{Void}}, info::pa_shim_info_t) = pointer_from_objref(info) Base.unsafe_convert(::Type{Ptr{Void}}, info::pa_shim_info_t) = pointer_from_objref(info)