From 9c4ba3d04f5a71359e5e0f2967943cb41e0a44f0 Mon Sep 17 00:00:00 2001 From: Rene Donner Date: Sat, 14 Mar 2015 15:37:13 +0100 Subject: [PATCH] include support for cross platform --- src/BinDeps.jl | 2 +- src/dependencies.jl | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/BinDeps.jl b/src/BinDeps.jl index 14fbc26..01ea528 100644 --- a/src/BinDeps.jl +++ b/src/BinDeps.jl @@ -4,7 +4,7 @@ module BinDeps export @make_run, @build_steps, find_library, download_cmd, unpack_cmd, Choice, Choices, CCompile, FileDownloader, FileRule, ChangeDirectory, FileDownloader, FileUnpacker, prepare_src, - autotools_install, CreateDirectory, MakeTargets, SystemLibInstall + autotools_install, CreateDirectory, MakeTargets, SystemLibInstall, include_deps const dlext = isdefined(Base.Sys, :shlib_ext) ? Base.Sys.shlib_ext : Base.Sys.dlext # Julia 0.2/0.3 compatibility const shlib_ext = dlext # compatibility with older packages (e.g. ZMQ) diff --git a/src/dependencies.jl b/src/dependencies.jl index eac1ffc..54ae237 100644 --- a/src/dependencies.jl +++ b/src/dependencies.jl @@ -767,7 +767,7 @@ end execute(dep::LibraryDependency,method) = run(lower(generate_steps(dep,method))) -macro install (_libmaps...) +macro install (pkgname, _libmaps...) if length(_libmaps) == 0 return esc(quote if bindeps_context.do_install @@ -822,8 +822,16 @@ macro install (_libmaps...) """ # Macro to load a library macro checked_lib(libname, path) - (dlopen_e(path) == C_NULL) && error("Unable to load \\n\\n\$libname (\$path)\\n\\nPlease re-run Pkg.build(package), and restart Julia.") - quote const \$(esc(libname)) = \$path end + if dlopen_e(path) == C_NULL + depsfile = joinpath(Pkg.dir(pkgname), "deps/deps.jl") + if myid() != 1 && isfile(depsfile) + path = eval(include_string(readall(depsfile))) + else + error("Unable to load \\n\\n\$libname (\$path) on $(gethostname())\\n\\nPlease re-run Pkg.build(package), and restart Julia.") + end + else + quote const \$(esc(libname)) = \$path end + end end """) println(depsfile, "# Load dependencies") @@ -978,6 +986,15 @@ function build(pkg::String, method; dep::String="", force=false) end end +function include_deps(pkg::String) + depsfile = joinpath(Pkg.dir(pkg),"deps/deps.jl") + if isfile(depsfile) + include_string(readall(depsfile)) + else + error("$pkg not properly installed. Please run Pkg.build(\"$pkg\")") + end +end + # Calculate the SHA-512 hash of a file using SHA