adds cross-compiled multiplatform builds and infrastructure to load them
This commit is contained in:
parent
3e7c6b5c1b
commit
efd70272ab
17 changed files with 1385 additions and 47 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -5,3 +5,6 @@ deps/deps.jl
|
||||||
*.flac
|
*.flac
|
||||||
*.cov
|
*.cov
|
||||||
coverage
|
coverage
|
||||||
|
deps/usr/lib/pa_shim.so
|
||||||
|
deps/usr/lib/pa_shim.dylib
|
||||||
|
deps/usr/lib/pa_shim.dll
|
||||||
|
|
50
deps/src/Makefile
vendored
50
deps/src/Makefile
vendored
|
@ -1,4 +1,4 @@
|
||||||
# Makefile lifted from Clang.jl
|
# Makefile originally lifted from Clang.jl
|
||||||
# Copyright (c) 2012-: Isaiah Norton and [contributors](https://github.com/ihnorton/Clang.jl/graphs/contributors)
|
# Copyright (c) 2012-: Isaiah Norton and [contributors](https://github.com/ihnorton/Clang.jl/graphs/contributors)
|
||||||
|
|
||||||
ifeq (exists, $(shell [ -e Make.user ] && echo exists ))
|
ifeq (exists, $(shell [ -e Make.user ] && echo exists ))
|
||||||
|
@ -6,18 +6,33 @@ include Make.user
|
||||||
endif
|
endif
|
||||||
|
|
||||||
TARGETDIR=../usr/lib
|
TARGETDIR=../usr/lib
|
||||||
|
TARGETBASENAME=pa_shim
|
||||||
OBJS = pa_shim.o
|
OBJS = pa_shim.o
|
||||||
|
|
||||||
|
# check to see if the user passed in a HOST variable for cross-compiling
|
||||||
|
ifeq ($(HOST),)
|
||||||
# Figure out OS and architecture
|
# Figure out OS and architecture
|
||||||
OS=$(shell uname)
|
OS=$(shell uname)
|
||||||
ifneq (,$(findstring MINGW,$(OS)))
|
ifneq ($(findstring MINGW,$(OS)),)
|
||||||
OS=WINNT
|
OS=WINNT
|
||||||
endif
|
endif
|
||||||
|
else
|
||||||
|
HOSTSUFFIX=_$(HOST)
|
||||||
|
ifneq ($(findstring linux,$(HOST)),)
|
||||||
|
OS=Linux
|
||||||
|
else ifneq ($(findstring darwin,$(HOST)),)
|
||||||
|
OS=Darwin
|
||||||
|
else ifneq ($(findstring mingw,$(HOST)),)
|
||||||
|
OS=WINNT
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
CFLAGS = -Wall -Wno-strict-aliasing -fno-omit-frame-pointer -I../../../RingBuffers/deps/src
|
||||||
|
LDFLAGS +=
|
||||||
|
|
||||||
# file extensions and platform-specific libs
|
|
||||||
ifeq ($(OS), WINNT)
|
ifeq ($(OS), WINNT)
|
||||||
LIBS +=
|
LIBS +=
|
||||||
LDFLAGS += -shared -L../../../RingBuffers/deps/usr/lib -lpa_ringbuffer
|
LDFLAGS += -shared -L../../../RingBuffers/deps/usr/lib -lpa_ringbuffer$(HOSTSUFFIX)
|
||||||
INC +=
|
INC +=
|
||||||
SHACMD = sha256sum
|
SHACMD = sha256sum
|
||||||
SHLIB_EXT = dll
|
SHLIB_EXT = dll
|
||||||
|
@ -30,6 +45,7 @@ else ifeq ($(OS), Darwin)
|
||||||
SHLIB_EXT = dylib
|
SHLIB_EXT = dylib
|
||||||
SHACMD = shasum -a256
|
SHACMD = shasum -a256
|
||||||
else
|
else
|
||||||
|
CFLAGS += -fPIC
|
||||||
LIBS +=
|
LIBS +=
|
||||||
INC +=
|
INC +=
|
||||||
LDFLAGS += -shared
|
LDFLAGS += -shared
|
||||||
|
@ -38,31 +54,27 @@ else
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SOURCEHASH = $(shell $(SHACMD) pa_shim.c | awk '{print $$1}')
|
SOURCEHASH = $(shell $(SHACMD) pa_shim.c | awk '{print $$1}')
|
||||||
|
CFLAGS += -DSOURCEHASH=\"$(SOURCEHASH)\"
|
||||||
|
|
||||||
CFLAGS += -I../../../RingBuffers/deps/src -Wall -Wno-strict-aliasing -fno-omit-frame-pointer -fPIC -DSOURCEHASH=\"$(SOURCEHASH)\"
|
TARGET=$(TARGETDIR)/$(TARGETBASENAME)$(HOSTSUFFIX).$(SHLIB_EXT)
|
||||||
LDFLAGS +=
|
|
||||||
# LINUX_LIBS =-lrt
|
|
||||||
# LINUX_LDFLAGS =-rdynamic
|
|
||||||
# add the Homebrew.jl tree to the include dirs in case we used it for
|
|
||||||
# portaudio and libsndfile
|
|
||||||
# DARWIN_LDFLAGS =-L../../../Homebrew/deps/usr/lib
|
|
||||||
# DARWIN_INC =-I../../../Homebrew/deps/usr/include
|
|
||||||
|
|
||||||
TARGET = $(TARGETDIR)/pa_shim.$(SHLIB_EXT)
|
.PHONY: clean cleantemp default
|
||||||
|
|
||||||
.PHONY: clean default
|
|
||||||
|
|
||||||
default: $(TARGET)
|
default: $(TARGET)
|
||||||
|
|
||||||
%.o: %.c Makefile
|
%.o: %.c Makefile
|
||||||
$(CC) $< -fPIC -c -o $@ $(INC) $(CFLAGS)
|
$(CC) $< -c -o $@ $(INC) $(CFLAGS)
|
||||||
|
|
||||||
$(TARGETDIR):
|
$(TARGETDIR):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
$(TARGET): $(OBJS) $(TARGETDIR) Makefile
|
$(TARGET): $(OBJS) $(TARGETDIR) Makefile
|
||||||
$(CC) $(OBJS) -shared -o $@ $(LDFLAGS) $(LIBS)
|
$(CC) $(OBJS) $(LDFLAGS) -o $@ $(LIBS)
|
||||||
|
|
||||||
clean:
|
cleantemp:
|
||||||
rm -f $(OBJS)
|
rm -f $(OBJS)
|
||||||
rm -f $(TARGET)
|
|
||||||
|
clean: cleantemp
|
||||||
|
rm -f $(TARGETDIR)/$(TARGETBASENAME)*.so
|
||||||
|
rm -f $(TARGETDIR)/$(TARGETBASENAME)*.dylib
|
||||||
|
rm -f $(TARGETDIR)/$(TARGETBASENAME)*.dll
|
||||||
|
|
54
deps/src/build.sh
vendored
Executable file
54
deps/src/build.sh
vendored
Executable file
|
@ -0,0 +1,54 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# User docker to build pa_shim library for all supported platforms.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
make clean
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
# NOTE: the darwin build ends up actually being x86_64-apple-darwin14. It gets
|
||||||
|
# mapped within the docker machine
|
||||||
|
for platform in \
|
||||||
|
arm-linux-gnueabihf \
|
||||||
|
powerpc64le-linux-gnu \
|
||||||
|
x86_64-apple-darwin \
|
||||||
|
x86_64-w64-mingw32 \
|
||||||
|
i686-w64-mingw32; do
|
||||||
|
echo "================================"
|
||||||
|
echo "building for $platform..."
|
||||||
|
docker run --rm \
|
||||||
|
-v $(pwd)/../..:/workdir \
|
||||||
|
-v $(pwd)/../../../RingBuffers:/RingBuffers \
|
||||||
|
-w /workdir/deps/src \
|
||||||
|
-e CROSS_TRIPLE=$platform \
|
||||||
|
multiarch/crossbuild \
|
||||||
|
./dockerbuild_cb.sh
|
||||||
|
echo "================================"
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
|
# we use holy-build-box for the x86 linux builds because it uses an older
|
||||||
|
# glibc so it should be compatible with more user environments
|
||||||
|
echo "================================"
|
||||||
|
echo "building for x86_64-linux-gnu..."
|
||||||
|
docker run --rm \
|
||||||
|
-v $(pwd)/../..:/workdir \
|
||||||
|
-v $(pwd)/../../../RingBuffers:/RingBuffers \
|
||||||
|
-w /workdir/deps/src \
|
||||||
|
-e HOST=x86_64-linux-gnu \
|
||||||
|
phusion/holy-build-box-64 \
|
||||||
|
./dockerbuild_hbb.sh
|
||||||
|
echo "================================"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo "================================"
|
||||||
|
echo "building for i686-linux-gnu..."
|
||||||
|
docker run --rm \
|
||||||
|
-v $(pwd)/../..:/workdir \
|
||||||
|
-v $(pwd)/../../../RingBuffers:/RingBuffers \
|
||||||
|
-w /workdir/deps/src \
|
||||||
|
-e HOST=i686-linux-gnu \
|
||||||
|
phusion/holy-build-box-32 \
|
||||||
|
./dockerbuild_hbb.sh
|
||||||
|
echo "================================"
|
8
deps/src/dockerbuild_cb.sh
vendored
Executable file
8
deps/src/dockerbuild_cb.sh
vendored
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# this script is run by build.sh within each docker instance to do the build.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
make HOST=$CROSS_TRIPLE
|
||||||
|
make cleantemp
|
13
deps/src/dockerbuild_hbb.sh
vendored
Executable file
13
deps/src/dockerbuild_hbb.sh
vendored
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# this script is run by build.sh within each docker instance to do the build.
|
||||||
|
# it's meant to be run from within a "Holy Build Box" docker instance.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Activate Holy Build Box environment.
|
||||||
|
source /hbb_exe/activate
|
||||||
|
|
||||||
|
set -x
|
||||||
|
make HOST=$HOST
|
||||||
|
make cleantemp
|
2
deps/src/pa_shim.c
vendored
2
deps/src/pa_shim.c
vendored
|
@ -1,4 +1,4 @@
|
||||||
#include <portaudio.h>
|
#include "portaudio.h"
|
||||||
#include <pa_ringbuffer.h>
|
#include <pa_ringbuffer.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
1225
deps/src/portaudio.h
vendored
Normal file
1225
deps/src/portaudio.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
BIN
deps/usr/lib/pa_shim.so
vendored
BIN
deps/usr/lib/pa_shim.so
vendored
Binary file not shown.
BIN
deps/usr/lib/pa_shim_arm-linux-gnueabihf.so
vendored
Executable file
BIN
deps/usr/lib/pa_shim_arm-linux-gnueabihf.so
vendored
Executable file
Binary file not shown.
BIN
deps/usr/lib/pa_shim_i686-linux-gnu.so
vendored
Executable file
BIN
deps/usr/lib/pa_shim_i686-linux-gnu.so
vendored
Executable file
Binary file not shown.
BIN
deps/usr/lib/pa_shim_i686-w64-mingw32.dll
vendored
Executable file
BIN
deps/usr/lib/pa_shim_i686-w64-mingw32.dll
vendored
Executable file
Binary file not shown.
BIN
deps/usr/lib/pa_shim_powerpc64le-linux-gnu.so
vendored
Executable file
BIN
deps/usr/lib/pa_shim_powerpc64le-linux-gnu.so
vendored
Executable file
Binary file not shown.
Binary file not shown.
BIN
deps/usr/lib/pa_shim_x86_64-linux-gnu.so
vendored
Executable file
BIN
deps/usr/lib/pa_shim_x86_64-linux-gnu.so
vendored
Executable file
Binary file not shown.
BIN
deps/usr/lib/pa_shim_x86_64-w64-mingw32.dll
vendored
Executable file
BIN
deps/usr/lib/pa_shim_x86_64-w64-mingw32.dll
vendored
Executable file
Binary file not shown.
|
@ -1,7 +1,28 @@
|
||||||
function init_pa_shim()
|
function init_pa_shim()
|
||||||
global const libpa_shim = Libdl.find_library(
|
libdir = joinpath(dirname(@__FILE__), "..", "deps", "usr", "lib")
|
||||||
["pa_shim"],
|
libsuffix = ""
|
||||||
[joinpath(dirname(@__FILE__), "..", "deps", "usr", "lib")])
|
basename = "pa_shim"
|
||||||
|
@static if is_linux() && Sys.ARCH == :x86_64
|
||||||
|
libsuffix = "x86_64-linux-gnu"
|
||||||
|
elseif is_linux() && Sys.ARCH == :i686
|
||||||
|
libsuffix = "i686-linux-gnu"
|
||||||
|
elseif is_apple() && Sys.ARCH == :x86_64
|
||||||
|
libsuffix = "x86_64-apple-darwin14"
|
||||||
|
elseif is_windows() && Sys.ARCH == :x86_64
|
||||||
|
libsuffix = "x86_64-w64-mingw32"
|
||||||
|
elseif is_windows() && Sys.ARCH == :i686
|
||||||
|
libsuffix = "i686-w64-mingw32"
|
||||||
|
elseif !any(
|
||||||
|
(sfx) -> isfile(joinpath(libdir, "$basename.$sfx")),
|
||||||
|
("so", "dll", "dylib"))
|
||||||
|
error("Unsupported platform $(Sys.MACHINE). You can build your own library by running `make` from $(joinpath(@__FILE__, "..", "deps", "src"))")
|
||||||
|
end
|
||||||
|
# if there's a suffix-less library, it was built natively on this machine,
|
||||||
|
# so load that one first, otherwise load the pre-built one
|
||||||
|
global const libpa_shim = Base.Libdl.find_library(
|
||||||
|
[basename, "$(basename)_$libsuffix"],
|
||||||
|
[libdir])
|
||||||
|
libpa_shim == "" && error("Could not load $basename library, please file an issue at https://github.com/JuliaAudio/RingBuffers.jl/issues with your `versioninfo()` output")
|
||||||
shim_dlib = Libdl.dlopen(libpa_shim)
|
shim_dlib = Libdl.dlopen(libpa_shim)
|
||||||
# pointer to the shim's process callback
|
# pointer to the shim's process callback
|
||||||
global const shim_processcb_c = Libdl.dlsym(shim_dlib, :pa_shim_processcb)
|
global const shim_processcb_c = Libdl.dlsym(shim_dlib, :pa_shim_processcb)
|
||||||
|
|
|
@ -177,9 +177,8 @@ function test_callback_overflow(inchans, outchans, synced)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# these test are currently set up to run on OSX
|
# these default values are specific to my machines
|
||||||
|
@testset ExtendedTestSet "PortAudio Tests" begin
|
||||||
@testset DottedTestSet "PortAudio Tests" begin
|
|
||||||
if is_windows()
|
if is_windows()
|
||||||
default_indev = "Microphone Array (Realtek High "
|
default_indev = "Microphone Array (Realtek High "
|
||||||
default_outdev = "Speaker/Headphone (Realtek High"
|
default_outdev = "Speaker/Headphone (Realtek High"
|
||||||
|
@ -205,7 +204,10 @@ end
|
||||||
result = split(String(take!((io))), "\n")
|
result = split(String(take!((io))), "\n")
|
||||||
# make sure this is the same version I tested with
|
# make sure this is the same version I tested with
|
||||||
@test startswith(result[1], "PortAudio V19")
|
@test startswith(result[1], "PortAudio V19")
|
||||||
@test result[3] == "Shim Source Hash: 4ea2a8526b"
|
end
|
||||||
|
|
||||||
|
@testset "using correct shim version" begin
|
||||||
|
@test PortAudio.shimhash() == "87021557a9f999545828eb11e4ebad2cd278b734dd91a8bd3faf05c89912cf80"
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Basic callback functionality" begin
|
@testset "Basic callback functionality" begin
|
||||||
|
|
Loading…
Reference in a new issue