diff --git a/REQUIRE b/REQUIRE index 1421fb6..ac75b1b 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,3 +1,4 @@ julia 0.6 +BinaryProvider 0.2 Compat 0.62 TranscodingStreams 0.3 diff --git a/deps/build.jl b/deps/build.jl new file mode 100644 index 0000000..7ac2df2 --- /dev/null +++ b/deps/build.jl @@ -0,0 +1,47 @@ +using BinaryProvider + +# Parse some basic command-line arguments +const verbose = "--verbose" in ARGS +const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr"))) +products = [ + LibraryProduct(prefix, String["liblzma"], :liblzma), +] + +# Download binaries from hosted location +bin_prefix = "https://github.com/bicycle1885/XzBuilder/releases/download/v1.0.0" + +# Listing of files generated by BinaryBuilder: +download_info = Dict( + #BinaryProvider.Linux(:aarch64, :glibc, :blank_abi) => ("$bin_prefix/XzBuilder.aarch64-linux-gnu.tar.gz", "36cb5f30ef212ae889850336121b97bebe8805b77190e5b2bb5e9f30da3e471a"), + #BinaryProvider.UnknownPlatform() => ("$bin_prefix/XzBuilder.arm-linux-gnueabihf.tar.gz", "52a0d759997d722099078338271fb1278bab66c12f268932b94b7a8ce5feaf84"), + #BinaryProvider.Linux(:i686, :glibc, :blank_abi) => ("$bin_prefix/XzBuilder.i686-linux-gnu.tar.gz", "caae08967ae86557dab4d1fc9c607b131aec7390bdeb04bf201d855f88747cf6"), + #BinaryProvider.Windows(:i686, :blank_libc, :blank_abi) => ("$bin_prefix/XzBuilder.i686-w64-mingw32.tar.gz", "ef2f862f760e6a9b095b2182d351a826f4a192f2afbd8a4c9302d89174101cda"), + #BinaryProvider.Linux(:powerpc64le, :glibc, :blank_abi) => ("$bin_prefix/XzBuilder.powerpc64le-linux-gnu.tar.gz", "6f6be8b5a3670e181f3b7823559a2bb74198ed9fe680a80cb26cc42d041cd378"), + #BinaryProvider.MacOS(:x86_64, :blank_libc, :blank_abi) => ("$bin_prefix/XzBuilder.x86_64-apple-darwin14.tar.gz", "8aed74a3a44123d15d4fc76659bd7cf4d336fb2e200a9c897624b19bdfb5ba81"), + #BinaryProvider.Linux(:x86_64, :glibc, :blank_abi) => ("$bin_prefix/XzBuilder.x86_64-linux-gnu.tar.gz", "786d2c2a86452c11b31a2af8db5f80db1237e967efad2661887cbb6140214b1e"), + #BinaryProvider.Windows(:x86_64, :blank_libc, :blank_abi) => ("$bin_prefix/XzBuilder.x86_64-w64-mingw32.tar.gz", "239333adb161f0e3ad1971fe43b2ccb7741f4f0657d131fe1354c343261f93ce"), + BinaryProvider.Linux(:aarch64, :glibc) => ("$bin_prefix/XzBuilder.aarch64-linux-gnu.tar.gz", "36cb5f30ef212ae889850336121b97bebe8805b77190e5b2bb5e9f30da3e471a"), + BinaryProvider.Linux(:i686, :glibc) => ("$bin_prefix/XzBuilder.i686-linux-gnu.tar.gz", "caae08967ae86557dab4d1fc9c607b131aec7390bdeb04bf201d855f88747cf6"), + BinaryProvider.Windows(:i686) => ("$bin_prefix/XzBuilder.i686-w64-mingw32.tar.gz", "ef2f862f760e6a9b095b2182d351a826f4a192f2afbd8a4c9302d89174101cda"), + BinaryProvider.Linux(:powerpc64le, :glibc) => ("$bin_prefix/XzBuilder.powerpc64le-linux-gnu.tar.gz", "6f6be8b5a3670e181f3b7823559a2bb74198ed9fe680a80cb26cc42d041cd378"), + BinaryProvider.MacOS(:x86_64) => ("$bin_prefix/XzBuilder.x86_64-apple-darwin14.tar.gz", "8aed74a3a44123d15d4fc76659bd7cf4d336fb2e200a9c897624b19bdfb5ba81"), + BinaryProvider.Linux(:x86_64, :glibc) => ("$bin_prefix/XzBuilder.x86_64-linux-gnu.tar.gz", "786d2c2a86452c11b31a2af8db5f80db1237e967efad2661887cbb6140214b1e"), + BinaryProvider.Windows(:x86_64) => ("$bin_prefix/XzBuilder.x86_64-w64-mingw32.tar.gz", "239333adb161f0e3ad1971fe43b2ccb7741f4f0657d131fe1354c343261f93ce"), +) + +# First, check to see if we're all satisfied +if any(!satisfied(p; verbose=verbose) for p in products) + if haskey(download_info, platform_key()) + # Download and install binaries + url, tarball_hash = download_info[platform_key()] + install(url, tarball_hash; prefix=prefix, force=true, verbose=verbose) + else + # If we don't have a BinaryProvider-compatible .tar.gz to download, complain. + # Alternatively, you could attempt to install from a separate provider, + # build from source or something more even more ambitious here. + error("Your platform $(triplet(platform_key())) is not supported by this package!") + end +end + +# Write out a deps.jl file that will contain mappings for our products +write_deps_file(joinpath(@__DIR__, "deps.jl"), products) diff --git a/src/CodecXz.jl b/src/CodecXz.jl index ace1698..1bb75b6 100644 --- a/src/CodecXz.jl +++ b/src/CodecXz.jl @@ -9,6 +9,7 @@ export XzDecompressorStream using Compat: Cvoid +using Compat.Libdl import TranscodingStreams: TranscodingStreams, TranscodingStream, @@ -17,6 +18,13 @@ import TranscodingStreams: initialize, finalize +const liblzmapath = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl") +if !isfile(liblzmapath) + error("CodecXz.jl is not installed properly, run Pkg.build(\"CodecXz\") and restart Julia.") +end +include(liblzmapath) +check_deps() + # TODO: This method will be added in the next version of TranscodingStreams.jl. function splitkwargs(kwargs, keys) hits = [] diff --git a/src/liblzma.jl b/src/liblzma.jl index c1b636d..01b3f51 100644 --- a/src/liblzma.jl +++ b/src/liblzma.jl @@ -1,8 +1,6 @@ # The liblzma Interfaces # ====================== -const liblzma = "liblzma" - # Return code const LZMA_OK = Cint(0) const LZMA_STREAM_END = Cint(1)