Skip to content

Commit

Permalink
Build dependent packages and support varargs in API.build (#91)
Browse files Browse the repository at this point in the history
* build dependent packages also

* support varags in build api

* build: use deps_graph instead of resolve_version!

* remove stray new line

* revert changes on resolve_versions!

* remove dependency on deps_graph
  • Loading branch information
vdayanand authored and KristofferC committed Jan 11, 2018
1 parent d001509 commit b4df8a2
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,40 @@ function gc(env::EnvCache=EnvCache(); period = Week(6), preview=env.preview[])
info("Deleted $(length(paths_to_delete)) package installations", byte_save_str)
end

function _get_deps!(env::EnvCache, pkgs::Vector{PackageSpec}, uuids::Vector{Base.Random.UUID})
for pkg in pkgs
info = manifest_info(env, pkg.uuid)
pkg.uuid in uuids && continue
push!(uuids, pkg.uuid)
if haskey(info, "deps")
pkgs = [PackageSpec(name, UUID(uuid)) for (name, uuid) in info["deps"]]
_get_deps!(env, pkgs, uuids)
end
end
end


build(pkg::String) = build([pkg])
build(pkgs::Vector{String}) = build([PackageSpec(pkg) for pkg in pkgs])
build(pkgs...) = build([PackageSpec(pkg) for pkg in pkgs])
build(pkg::Array{Union{}, 1}) = build(PackageSpec[])
build(pkg::PackageSpec) = build([pkg])
build(pkgs::Vector{PackageSpec}) = build(EnvCache(), pkgs)

function build(env::EnvCache, pkgs::Vector{PackageSpec})
if isempty(pkgs)
for (name, infos) in env.manifest, info in infos
uuid = UUID(info["uuid"])
push!(pkgs, PackageSpec(name, uuid))
end
end
for pkg in pkgs
pkg.mode = :manifest
end
manifest_resolve!(env, pkgs)
ensure_resolved(env, pkgs)
Pkg3.Operations.build_versions(env, [pkg.uuid for pkg in pkgs])
if isempty(pkgs)
for (name, infos) in env.manifest, info in infos
uuid = UUID(info["uuid"])
push!(pkgs, PackageSpec(name, uuid))
end
end
for pkg in pkgs
pkg.mode = :manifest
end
manifest_resolve!(env, pkgs)
ensure_resolved(env, pkgs)
uuids = Base.Random.UUID[]
_get_deps!(env, pkgs, uuids)
length(uuids) == 0 && (info("No packages to build!"); return)
Pkg3.Operations.build_versions(env, uuids)
end


Expand Down

0 comments on commit b4df8a2

Please sign in to comment.