forked from JuliaInterop/ZMQ.jl
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from mcgillij/old_build_files
Old build files
- Loading branch information
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using BinaryProvider # requires BinaryProvider 0.3.0 or later | ||
include("compile.jl") | ||
|
||
# env var to force compilation from source, for testing purposes | ||
const forcecompile = get(ENV, "FORCE_COMPILE_ZMQ", "no") == "yes" | ||
|
||
# Parse some basic command-line arguments | ||
const verbose = "--verbose" in ARGS || forcecompile | ||
const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr"))) | ||
products = [ | ||
LibraryProduct(prefix, String["libzmq"], :libzmq), | ||
] | ||
|
||
# Download binaries from hosted location | ||
bin_prefix = "https://github.com/analyzere/ZMQ.jl/releases/download/v9.9.9/" | ||
#bin_prefix = "https://github.com/JuliaInterop/ZMQBuilder/releases/download/v4.2.5+6" | ||
|
||
# Listing of files generated by BinaryBuilder: | ||
download_info = Dict( | ||
Linux(:x86_64, :glibc) => ("$bin_prefix/zeromq-4.2.5.tar.gz", "781efaef87984d542a44d41979ae00eb7a657f823fa40477accd19b7f9d9024a"), | ||
) | ||
|
||
# source code tarball and hash for fallback compilation | ||
source_url = "https://github.com/zeromq/libzmq/releases/download/v4.2.5/zeromq-4.2.5.tar.gz" | ||
source_hash = "cc9090ba35713d59bb2f7d7965f877036c49c5558ea0c290b0dcc6f2a17e489f" | ||
|
||
# Install unsatisfied or updated dependencies: | ||
unsatisfied = any(!satisfied(p; verbose=verbose) for p in products) | ||
if haskey(download_info, platform_key()) && !forcecompile | ||
url, tarball_hash = download_info[platform_key()] | ||
if !isinstalled(url, tarball_hash; prefix=prefix) | ||
# Download and install binaries | ||
install(url, tarball_hash; prefix=prefix, force=true, verbose=verbose) | ||
|
||
# check again whether the dependency is satisfied, which | ||
# may not be true if dlopen fails due to a libc++ incompatibility (#176) | ||
unsatisfied = any(!satisfied(p; verbose=verbose) for p in products) | ||
end | ||
end | ||
|
||
if unsatisfied || forcecompile | ||
# Fall back to building from source, giving the library a different name | ||
# so that it is not overwritten by BinaryBuilder downloads or vice-versa. | ||
libname = "libzmq_from_source" | ||
products = [ LibraryProduct(prefix, [libname], :libzmq) ] | ||
source_path = joinpath(prefix, "downloads", "src.tar.gz") | ||
if !isfile(source_path) || !verify(source_path, source_hash; verbose=verbose) || !satisfied(products[1]; verbose=verbose) | ||
compile(libname, source_url, source_hash, prefix=prefix, verbose=verbose) | ||
end | ||
end | ||
|
||
# Write out a deps.jl file that will contain mappings for our products | ||
write_deps_file(joinpath(@__DIR__, "deps.jl"), products) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using BinaryProvider, Compat | ||
using Compat.Libdl: dlext | ||
|
||
function compile(libname, tarball_url, hash; prefix=BinaryProvider.global_prefix, verbose=false) | ||
# download to tarball_path | ||
tarball_path = joinpath(prefix, "downloads", "src.tar.gz") | ||
download_verify(tarball_url, hash, tarball_path; force=true, verbose=verbose) | ||
|
||
# unpack into source_path | ||
tarball_dir = joinpath(prefix, "downloads", split(first(list_tarball_files(tarball_path)), '/')[1]) # e.g. "zeromq-4.2.5" | ||
source_path = joinpath(prefix, "downloads", "src") | ||
verbose && Compat.@info("Unpacking $tarball_path into $source_path") | ||
rm(tarball_dir, force=true, recursive=true) | ||
rm(source_path, force=true, recursive=true) | ||
unpack(tarball_path, dirname(tarball_dir); verbose=verbose) | ||
mv(tarball_dir, source_path) | ||
|
||
install_dir = joinpath(source_path, "julia_install") | ||
verbose && Compat.@info("Compiling in $source_path...") | ||
cd(source_path) do | ||
run(`./configure --prefix=$install_dir --without-docs --disable-libunwind --disable-perf --disable-eventfd --without-gcov --disable-curve-keygen`) | ||
run(`make`) | ||
run(`make install`) | ||
mkpath(libdir(prefix)) | ||
cp("$install_dir/lib/libzmq.$dlext", joinpath(libdir(prefix), libname*"."*dlext), | ||
remove_destination=true, follow_symlinks=true) | ||
end | ||
end |