Skip to content

Commit

Permalink
Fix deprecations on 0.7 (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan authored Apr 21, 2018
1 parent a042547 commit 69c3fb6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 33 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.6
URIParser
SHA
Compat 0.46.0
Compat 0.62.0
37 changes: 17 additions & 20 deletions src/BinDeps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,8 @@ __precompile__()
module BinDeps

using Compat

if VERSION >= v"0.7.0-DEV.3073"
const _HOME = Sys.BINDIR
else
const _HOME = JULIA_HOME
end

if VERSION >= v"0.7.0-DEV.3382"
using Libdl
end
using Compat.Libdl
using Compat.Pkg

export @build_steps, find_library, download_cmd, unpack_cmd,
Choice, Choices, CCompile, FileDownloader, FileRule,
Expand Down Expand Up @@ -122,7 +114,7 @@ if Sys.KERNEL == :FreeBSD
end

if Compat.Sys.iswindows()
const exe7z = joinpath(_HOME, "7z.exe")
const exe7z = joinpath(Compat.Sys.BINDIR, "7z.exe")

function unpack_cmd(file,directory,extension,secondary_extension)
if ((extension == ".Z" || extension == ".gz" || extension == ".xz" || extension == ".bz2") &&
Expand Down Expand Up @@ -226,7 +218,7 @@ push!(c::Choices, args...) = push!(c.choices, args...)

function run(c::Choices)
println()
info("There are multiple options available for installing this dependency:")
Compat.@info("There are multiple options available for installing this dependency:")
while true
for x in c.choices
println("- "*string(x.name)*": "*x.description)
Expand All @@ -239,7 +231,7 @@ function run(c::Choices)
return run(x.step)
end
end
warn("Invalid method")
Compat.@warn("Invalid method")
end
end
end
Expand Down Expand Up @@ -361,7 +353,12 @@ lower(s::CreateDirectory,collection) = @dependent_steps ( DirectoryRule(s.dest,(
lower(s::RemoveDirectory,collection) = @dependent_steps ( `rm -rf $(s.dest)` )
lower(s::BuildStep,collection) = push!(collection,s)
lower(s::Base.AbstractCmd,collection) = push!(collection,s)
lower(s::FileDownloader,collection) = @dependent_steps ( CreateDirectory(dirname(s.dest),true), ()->info("Downloading file $(s.src)"), FileRule(s.dest,download_cmd(s.src,s.dest)), ()->info("Done downloading file $(s.src)") )
lower(s::FileDownloader,collection) = @dependent_steps (
CreateDirectory(dirname(s.dest), true),
()->Compat.@info("Downloading file $(s.src)"),
FileRule(s.dest, download_cmd(s.src, s.dest)),
()->Compat.@info("Done downloading file $(s.src)")
)
lower(s::ChecksumValidator,collection) = isempty(s.sha) || @dependent_steps ()->sha_check(s.path, s.sha)
function splittarpath(path)
path,extension = splitext(path)
Expand Down Expand Up @@ -495,14 +492,14 @@ function run(s::FileRule)
end
end
function run(s::DirectoryRule)
info("Attempting to create directory $(s.dir)")
Compat.@info("Attempting to create directory $(s.dir)")
if !isdir(s.dir)
run(s.step)
if !isdir(s.dir)
error("Directory $(s.dir) was not created successfully (Tried to run $(s.step) )")
end
else
info("Directory $(s.dir) already exists")
Compat.@info("Directory $(s.dir) already exists")
end
end

Expand All @@ -513,7 +510,7 @@ function run(s::PathRule)
error("Path $(s.path) was not created successfully (Tried to run $(s.step) )")
end
else
info("Path $(s.path) already exists")
Compat.@info("Path $(s.path) already exists")
end
end

Expand All @@ -523,12 +520,12 @@ end
function run(s::SynchronousStepCollection)
for x in s.steps
if !isempty(s.cwd)
info("Changing directory to $(s.cwd)")
Compat.@info("Changing directory to $(s.cwd)")
cd(s.cwd)
end
run(x)
if !isempty(s.oldcwd)
info("Changing directory to $(s.oldcwd)")
Compat.@info("Changing directory to $(s.oldcwd)")
cd(s.oldcwd)
end
end
Expand Down Expand Up @@ -583,7 +580,7 @@ function glibc_version()
ptr = Libdl.dlsym_e(libc, :gnu_get_libc_version)
ptr == C_NULL && return # non-glibc
v = unsafe_string(ccall(ptr, Ptr{UInt8}, ()))
contains(v, Base.VERSION_REGEX) ? VersionNumber(v) : nothing
occursin(Base.VERSION_REGEX, v) ? VersionNumber(v) : nothing
end

include("dependencies.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/debug.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function show(io::IO, deps::LibraryGroup)
end

function debug_context(pkg::AbstractString)
info("Reading build script...")
Compat.@info("Reading build script...")
dir = Pkg.dir(pkg)
file = joinpath(dir, "deps", "build.jl")
context = BinDeps.PackageContext(false, dir, pkg, Any[])
Expand Down
21 changes: 10 additions & 11 deletions src/dependencies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function package_available(p::BSDPkg)
can_use(BSDPkg) || return false
rgx = Regex(string("^(", p.package, ")(\\s+.+)?\$"))
for line in eachline(`pkg search -L name $(p.package)`)
contains(line, rgx) && return true
occursin(rgx, line) && return true
end
return false
end
Expand All @@ -260,7 +260,7 @@ function available_version(p::BSDPkg)
# including the first underscore
libversion = replace(rawversion, r"_.+$" => "")
# This should be a valid version, but it's still possible that it isn't
if contains(libversion, Base.VERSION_REGEX)
if occursin(Base.VERSION_REGEX, libversion)
return VersionNumber(libversion)
else
error("\"$rawversion\" is not recognized as a version. Please report this to BinDeps.jl.")
Expand Down Expand Up @@ -399,10 +399,10 @@ elseif Compat.Sys.islinux()
if m !== nothing
desc = m[2]
if Sys.WORD_SIZE != 32 && !isempty(arch)
contains(desc, arch) || continue
occursin(arch, desc) || continue
end
for wrong in arch_wrong
contains(desc, wrong) && continue
occursin(wrong, desc) && continue
end
sonames[m[1]] = m[3]
end
Expand All @@ -414,7 +414,6 @@ else
function read_sonames()
empty!(sonames)
for line in eachline(`/sbin/ldconfig -r`)
VERSION < v"0.6" && (line = chomp(line))
m = match(r"^\s+\d+:-l([^ ]+)\.[^. ]+ => (.+)$", line)
if m !== nothing
sonames["lib" * m[1]] = m[2]
Expand Down Expand Up @@ -1041,7 +1040,7 @@ macro install(_libmaps...)
end
end
end))
if !(typeof(libmaps) <: Associative)
if !(typeof(libmaps) <: AbstractDict)
warn("Incorrect mapping in BinDeps.@install call. No dependencies will be cached.")
end
ret
Expand All @@ -1061,8 +1060,8 @@ end
# Only load that are declared whose name is listed in the Array
# E.g. @load_dependencies "file.jl" [:cairo, :tk]
#
# 2. Associative{S<:Union{Symbol,AbstractString},S<:Union{Symbol,AbstractString}}
# Only loads libraries whose name matches a key in the Associative collection, but assigns it
# 2. AbstractDict{S<:Union{Symbol,AbstractString},S<:Union{Symbol,AbstractString}}
# Only loads libraries whose name matches a key in the AbstractDict collection, but assigns it
# to the name matiching the corresponsing value
# E.g. @load_dependencies "file.jl" [:cairo=>:libcairo, :tk=>:libtk]
# will assign the result of the lookup for :cairo and :tk to the variables `libcairo` and `libtk`
Expand All @@ -1083,14 +1082,14 @@ macro load_dependencies(args...)
elseif typeof(args[1]) <: AbstractString
file = args[1]
dir = dirname(normpath(joinpath(dirname(file),"..")))
elseif typeof(args[1]) <: Associative || isa(args[1],Vector)
elseif typeof(args[1]) <: AbstractDict || isa(args[1],Vector)
arg1 = args[1]
else
error("Type $(typeof(args[1])) not recognized for argument 1. See usage instructions!")
end
elseif length(args) == 2
file = args[1]
arg1 = typeof(args[2]) <: Associative || isa(args[2],Vector) ? args[2] : eval(args[2])
arg1 = typeof(args[2]) <: AbstractDict || isa(args[2],Vector) ? args[2] : eval(args[2])
elseif length(args) != 0
error("No version of @load_dependencies takes $(length(args)) arguments. See usage instructions!")
end
Expand All @@ -1113,7 +1112,7 @@ macro load_dependencies(args...)
end
name = sym = dep.name
if arg1 !== nothing
if (typeof(arg1) <: Associative) && all(map(x->(x == Symbol || x <: AbstractString),eltype(arg1)))
if (typeof(arg1) <: AbstractDict) && all(map(x->(x == Symbol || x <: AbstractString),eltype(arg1)))
found = false
for need in keys(arg1)
found = (dep.name == string(need))
Expand Down

0 comments on commit 69c3fb6

Please sign in to comment.