From 9e3e66d37aec942137c3fb241b1983abdbcece7e Mon Sep 17 00:00:00 2001 From: Spencer Russell Date: Tue, 9 May 2017 13:08:00 -0400 Subject: [PATCH] now reports hash of source file used to build shim --- deps/src/Makefile | 10 +++++----- deps/src/pa_shim.c | 8 ++++---- src/pa_shim.jl | 10 +++++++++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/deps/src/Makefile b/deps/src/Makefile index 27aac58..bae0abc 100644 --- a/deps/src/Makefile +++ b/deps/src/Makefile @@ -5,13 +5,17 @@ ifeq (exists, $(shell [ -e Make.user ] && echo exists )) include Make.user endif +TARGETDIR=../usr/lib +OBJS = pa_shim.o +SOURCEHASH=$(shell sha256sum pa_shim.c | awk '{print $$1}') + #check-env: #ifndef JULIA_INC # $(error Environment variable JULIA_INC is not set.) #endif #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 # LINUX_LIBS =-lrt # LINUX_LDFLAGS =-rdynamic @@ -19,10 +23,6 @@ LDFLAGS =-L../../../RingBuffers/deps/usr/lib -lpa_ringbuffer # portaudio and libsndfile # DARWIN_LDFLAGS =-L../../../Homebrew/deps/usr/lib # DARWIN_INC =-I../../../Homebrew/deps/usr/include -TARGETDIR=../usr/lib - -OBJS = pa_shim.o - # Figure out OS and architecture OS = $(shell uname) ifneq (,$(findstring MINGW,$(OS))) diff --git a/deps/src/pa_shim.c b/deps/src/pa_shim.c index 1b79708..4317568 100644 --- a/deps/src/pa_shim.c +++ b/deps/src/pa_shim.c @@ -3,7 +3,6 @@ #include #include -#define SHIM_VERSION 3 #define MIN(x, y) ((x) < (y) ? (x) : (y)) 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 -int pa_shim_getversion(void) +// return the sha256 hash of the shim source so we can make sure things are in sync +const char *pa_shim_getsourcehash(void) { - return SHIM_VERSION; + // defined on the command-line at build-time + return SOURCEHASH; } /* diff --git a/src/pa_shim.jl b/src/pa_shim.jl index 9a97065..040b896 100644 --- a/src/pa_shim.jl +++ b/src/pa_shim.jl @@ -29,5 +29,13 @@ mutable struct pa_shim_info_t errorhandle::Ptr{Void} # condition to notify on new errors 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)