Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use BinaryProvider.jl #13

Merged
merged 20 commits into from
Dec 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ os:
- linux
- osx
julia:
- 0.5
- 0.6
- nightly
matrix:
allow_failures:
- julia: nightly
notifications:
email: false
# uncomment the following lines to override the default test script
#script:
# script:
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
# - julia -e 'Pkg.clone(pwd()); Pkg.build("Accumulo"); Pkg.test("Accumulo"; coverage=true)'
# - julia -e 'Pkg.clone(pwd()); Pkg.build("Snappy"); Pkg.test("Snappy"; coverage=true)'
5 changes: 2 additions & 3 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
julia 0.5
BinDeps
@osx Homebrew
julia 0.6
BinaryProvider 0.1.1
5 changes: 5 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ branches:
- master
- /release-.*/

matrix:
allow_failures:
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

notifications:
- provider: Email
on_build_success: false
Expand Down
50 changes: 35 additions & 15 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
using BinDeps
@BinDeps.setup
using BinaryProvider

snappy = library_dependency("libsnappy")
# This is where all binaries will get installed
const prefix = Prefix(!isempty(ARGS) ? ARGS[1] : joinpath(@__DIR__,"usr"))

# BinDeps issue: fails on sudo prompt
#provides(AptGet, {
# "libsnappy-dev" => snappy
#})
libsnappy = LibraryProduct(prefix, "libsnappy")

version = "1.1.4"
provides(Sources, URI("https://github.com/google/snappy/releases/download/$(version)/snappy-$(version).tar.gz"), snappy, unpacked_dir="snappy-$(version)")
provides(BuildProcess, Autotools(libtarget=dirname(@__FILE__) * "/builds/libsnappy/.libs/libsnappy." * Libdl.dlext), snappy, os=:Unix)
# Assign products to `products`:
products = [libsnappy]

@static if is_apple()
using Homebrew
provides(Homebrew.HB, "snappy", snappy, os=:Darwin)
end
# Download binaries from hosted location
bin_prefix = "https://github.com/davidanthoff/SnappyBuilder/releases/download/v1.1.7%2Bbuild.1"

# Listing of files generated by BinaryBuilder:
download_info = Dict(
Linux(:aarch64) => ("$bin_prefix/SnappyBuilder.aarch64-linux-gnu.tar.gz", "8cb4b9af85da7efa20bc4787ea16af4b76123d790590bfd447cbe092f123f2f8"),
Linux(:armv7l) => ("$bin_prefix/SnappyBuilder.arm-linux-gnueabihf.tar.gz", "67469c1ce2391e65c3d9f5f8162f0e14f69ce0e19af0389ad8d77226bf79a922"),
Linux(:i686) => ("$bin_prefix/SnappyBuilder.i686-linux-gnu.tar.gz", "f34512ca97f500cdaeeea19aeb3e3075b3aa2b4342cf3a5a3788c77eb634f0bd"),
Windows(:i686) => ("$bin_prefix/SnappyBuilder.i686-w64-mingw32.tar.gz", "53a28428e5c3d75bef1b2ce90b8af8905177b7dae313c8a859afe24c7c9571dd"),
Linux(:powerpc64le) => ("$bin_prefix/SnappyBuilder.powerpc64le-linux-gnu.tar.gz", "32ecdd9185c2f39e2c95db9e8adb2adf8f251d65c0a8e43c0ee6ec46778045cb"),
MacOS() => ("$bin_prefix/SnappyBuilder.x86_64-apple-darwin14.tar.gz", "8fe643e462799ce141b4d306427f73b2a373651282cdfabcaeb976e705069b7c"),
Linux(:x86_64) => ("$bin_prefix/SnappyBuilder.x86_64-linux-gnu.tar.gz", "9a45685503de0db44068126d67f49e241f9013970ddc560cfd7ba17b411dac8c"),
Windows(:x86_64) => ("$bin_prefix/SnappyBuilder.x86_64-w64-mingw32.tar.gz", "1c13a31c23225b812ee477dffa1fc77d6f501c0a3b65a9920edf5aa4a76f4475"),
)

@BinDeps.install Dict(:libsnappy => :libsnappy)
if platform_key() in keys(download_info)
# First, check to see if we're all satisfied
if any(!satisfied(p; verbose=true) for p in products)
# Download and install binaries
url, tarball_hash = download_info[platform_key()]
install(url, tarball_hash; prefix=prefix, force=true, verbose=true)
end

# Finally, write out a deps.jl file that will contain mappings for each
# named product here: (there will be a "libfoo" variable and a "fooifier"
# variable, etc...)
@write_deps_file libsnappy
else
error("Your platform $(Sys.MACHINE) is not supported by this package!")
end
13 changes: 9 additions & 4 deletions src/Snappy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ __precompile__()

module Snappy

if isfile(joinpath(dirname(dirname(@__FILE__)),"deps","deps.jl"))
include("../deps/deps.jl")
else
error("Snappy not properly installed. Please run Pkg.build(\"Snappy\")")
# Load libsnappy from our deps.jl
const depsjl_path = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl")
if !isfile(depsjl_path)
error("Snappy not installed properly, run Pkg.build(\"Snappy\"), restart Julia and try again")
end
include(depsjl_path)

export compress, uncompress

Expand All @@ -15,6 +16,10 @@ const SnappyOK = Cint(0)
const SnappyInvalidInput = Cint(1)
const SnappyBufferTooSmall = Cint(2)

function __init__()
check_deps()
end

# High-level Interfaces

function compress(input::Vector{UInt8})
Expand Down