Skip to content

Commit

Permalink
Use new BinDeps 0.2.2 build
Browse files Browse the repository at this point in the history
Fix #5
A step towards addressing #3
  • Loading branch information
carlobaldassi committed Aug 20, 2013
1 parent ea5d847 commit 6875d9d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 40 deletions.
3 changes: 0 additions & 3 deletions .gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
julia 0.2-
BinDeps 0.0.1-
BinDeps 0.2.2-
4 changes: 4 additions & 0 deletions deps/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
usr
builds
downloads
src
37 changes: 9 additions & 28 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
using BinDeps

@BinDeps.setup

glpkvers = "4.48"
glpkname = "glpk-$glpkvers"
@unix_only glpkarchive = "$glpkname.tar.gz"
@windows_only glpkarghive = "win$(glpkname).zip"
glpkprefix = Pkg.dir("GLPK", "deps", "usr")

tagfile = "installed_vers"
glpkdep = library_dependency("libglpk", validate = ((name,handle)->(bytestring(ccall(dlsym(handle, :glp_version), Ptr{Uint8}, ())) == glpkvers)))

if !isfile(tagfile) || readchomp(tagfile) != glpkvers
@unix_only begin
if !isfile("$glpkarchive")
run(download_cmd("http://ftp.gnu.org/gnu/glpk/$glpkarchive", glpkarchive))
end
run(unpack_cmd(glpkarchive, "."))
cd("$glpkname") do
run(`./configure --prefix=$glpkprefix --with-gmp --enable-dl`)
run(`make`)
run(`make check`)
run(`make install`)
end
end
provides(Sources, {URI("http://ftp.gnu.org/gnu/glpk/$glpkname.tar.gz") => glpkdep}, os = :Unix)
provides(Sources, {URI("http://downloads.sourceforge.net/project/winglpk/winglpk/GLPK-$glpkvers/win$glpkname.zip") => glpkdep}, os = :Windows)

@windows_only begin
error("sorry, Windows is currently unsupported by the GLPK module")
if !isfile("$glpkarchive")
run(download_cmd("http://ftp.gnu.org/gnu/glpk/$glpkarchive", glpkarchive))
run(download_cmd("http://downloads.sourceforge.net/project/winglpk/winglpk/GLPK-$glpkvers/$glpkarchive", glpkarchive))
end
run(`7z x $glpkarchive -y`)
# TODO move binaries to usr directory
end
provides(BuildProcess, {
Autotools(libtarget = joinpath("src", ".libs", "libglpk.la"), configure_options = String["--with-gmp", "--enable-dl"]) => glpkdep
}, os = :Unix)

run(`echo $glpkvers` > tagfile)
end
@BinDeps.install
1 change: 0 additions & 1 deletion deps/ext.jl

This file was deleted.

15 changes: 8 additions & 7 deletions src/GLPK.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ import Base.pointer, Base.setindex!, Base.getindex

## Shared library interface setup
#{{{
include("GLPK_constants.jl")
using BinDeps
@BinDeps.load_dependencies

include(Pkg.dir("GLPK","deps","ext.jl"))
include("GLPK_constants.jl")

# General recoverable exception: all GLPK functions
# throw this in case of recoverable errors
Expand All @@ -205,17 +206,17 @@ end
# Error hook, used to catch internal errors when calling
# GLPK functions
function _err_hook(info::Ptr{Void})
ccall((:glp_error_hook, _jl_libGLPK), Void, (Ptr{Void}, Ptr{Void}), C_NULL, C_NULL)
ccall((:glp_free_env, _jl_libGLPK), Void, ())
ccall((:glp_error_hook, libglpk), Void, (Ptr{Void}, Ptr{Void}), C_NULL, C_NULL)
ccall((:glp_free_env, libglpk), Void, ())
_del_all_objs()
throw(GLPKFatalError("GLPK call failed. All GLPK objects you defined so far are now invalidated."))
end

macro glpk_ccall(f, args...)
quote
ccall((:glp_error_hook, _jl_libGLPK), Void, (Ptr{Void}, Ptr{Void}), cfunction(_err_hook, Void, (Ptr{Void},)), C_NULL)
ret = ccall(($"glp_$(f)", _jl_libGLPK), $(args...))
ccall((:glp_error_hook, _jl_libGLPK), Void, (Ptr{Void}, Ptr{Void}), C_NULL, C_NULL)
ccall((:glp_error_hook, libglpk), Void, (Ptr{Void}, Ptr{Void}), cfunction(_err_hook, Void, (Ptr{Void},)), C_NULL)
ret = ccall(($"glp_$(f)", libglpk), $(args...))
ccall((:glp_error_hook, libglpk), Void, (Ptr{Void}, Ptr{Void}), C_NULL, C_NULL)
ret
end
end
Expand Down

0 comments on commit 6875d9d

Please sign in to comment.