From fe3e094a8f57ef8fdbaa6341c046409bd96071d0 Mon Sep 17 00:00:00 2001 From: Roger-luo Date: Thu, 27 Dec 2018 16:01:57 -0500 Subject: [PATCH 1/2] add test case --- test/test_packages/CUDA/Project.toml | 6 ++++++ test/test_packages/CUDA/src/CUDA.jl | 5 +++++ .../ConditionalDependency/Project.toml | 18 ++++++++++++++++++ .../src/ConditionalDependency.jl | 5 +++++ 4 files changed, 34 insertions(+) create mode 100644 test/test_packages/CUDA/Project.toml create mode 100644 test/test_packages/CUDA/src/CUDA.jl create mode 100644 test/test_packages/ConditionalDependency/Project.toml create mode 100644 test/test_packages/ConditionalDependency/src/ConditionalDependency.jl diff --git a/test/test_packages/CUDA/Project.toml b/test/test_packages/CUDA/Project.toml new file mode 100644 index 0000000000..3e5b081fa1 --- /dev/null +++ b/test/test_packages/CUDA/Project.toml @@ -0,0 +1,6 @@ +authors = ["Roger-luo "] +name = "CUDA" +uuid = "11d27378-0a18-11e9-0a59-4ba122bf6828" +version = "0.1.0" + +[deps] diff --git a/test/test_packages/CUDA/src/CUDA.jl b/test/test_packages/CUDA/src/CUDA.jl new file mode 100644 index 0000000000..1f3281185b --- /dev/null +++ b/test/test_packages/CUDA/src/CUDA.jl @@ -0,0 +1,5 @@ +module CUDA + +greet() = print("Hello World!") + +end # module diff --git a/test/test_packages/ConditionalDependency/Project.toml b/test/test_packages/ConditionalDependency/Project.toml new file mode 100644 index 0000000000..c9fb4054e2 --- /dev/null +++ b/test/test_packages/ConditionalDependency/Project.toml @@ -0,0 +1,18 @@ +authors = ["Roger-luo "] +name = "ConditionalDependency" +uuid = "09c64820-0a14-11e9-376f-03eff1a9e926" +version = "0.1.0" + +[extras] +x2 = "52baf49e-96b1-11e8-23dd-2d073a3a6758" + +[extras.CUDA] +uuid = "11d27378-0a18-11e9-0a59-4ba122bf6828" +features = ["cuda"] +version = "0.2.0" + +[features] +cuda = ["CUDA"] + +[targets] +test = ["x2"] diff --git a/test/test_packages/ConditionalDependency/src/ConditionalDependency.jl b/test/test_packages/ConditionalDependency/src/ConditionalDependency.jl new file mode 100644 index 0000000000..124b347620 --- /dev/null +++ b/test/test_packages/ConditionalDependency/src/ConditionalDependency.jl @@ -0,0 +1,5 @@ +module ConditionalDependency + +greet() = print("Hello World!") + +end # module From 58f84066f4558066b0307d812376163bea249cd2 Mon Sep 17 00:00:00 2001 From: Roger-luo Date: Thu, 27 Dec 2018 17:08:42 -0500 Subject: [PATCH 2/2] add member features to PackageSpec --- Project.toml | 1 - src/API.jl | 8 +++++++- src/Types.jl | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index b93b1698aa..ef19e26fc6 100644 --- a/Project.toml +++ b/Project.toml @@ -3,7 +3,6 @@ keywords = ["package", "management"] license = "MIT" name = "Pkg" version = "1.1.0" -uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/API.jl b/src/API.jl index e51886260e..dbb650ffd8 100644 --- a/src/API.jl +++ b/src/API.jl @@ -546,6 +546,7 @@ setprotocol!(proto::Union{Nothing, AbstractString}=nothing) = GitTools.setprotoc function Package(;name::Union{Nothing,AbstractString} = nothing, uuid::Union{Nothing,String,UUID} = nothing, version::Union{VersionNumber, String, VersionSpec, Nothing} = nothing, + features::Union{Nothing, String, Vector{String}} = String[], url = nothing, rev = nothing, path=nothing, mode::PackageMode = PKGMODE_PROJECT) path !== nothing && url !== nothing && pkgerror("cannot specify both a path and url") @@ -555,8 +556,13 @@ function Package(;name::Union{Nothing,AbstractString} = nothing, nothing : Types.GitRepo(rev = rev, url = url !== nothing ? url : path) version = version === nothing ? VersionSpec() : VersionSpec(version) + + features = features === nothing ? String[] : + features isa String ? [features] : + features + uuid isa String && (uuid = UUID(uuid)) - PackageSpec(name, uuid, version, mode, nothing, PKGSPEC_NOTHING, repo) + PackageSpec(name, uuid, version, features, mode, nothing, PKGSPEC_NOTHING, repo) end Package(name::AbstractString) = PackageSpec(name) Package(name::AbstractString, uuid::UUID) = PackageSpec(name, uuid) diff --git a/src/Types.jl b/src/Types.jl index 4b699fe361..4b232e7542 100644 --- a/src/Types.jl +++ b/src/Types.jl @@ -145,6 +145,7 @@ Base.@kwdef mutable struct PackageSpec name::Union{Nothing,String} = nothing uuid::Union{Nothing,UUID} = nothing version::VersionTypes = VersionSpec() + features::Vector{String} = String[] mode::PackageMode = PKGMODE_PROJECT path::Union{Nothing,String} = nothing special_action::PackageSpecialAction = PKGSPEC_NOTHING # If the package is currently being pinned, freed etc @@ -160,7 +161,9 @@ has_uuid(pkg::PackageSpec) = pkg.uuid !== nothing function Base.show(io::IO, pkg::PackageSpec) vstr = repr(pkg.version) - f = ["name" => pkg.name, "uuid" => has_uuid(pkg) ? pkg.uuid : "", "v" => (vstr == "VersionSpec(\"*\")" ? "" : vstr)] + f = ["name" => pkg.name, "uuid" => has_uuid(pkg) ? pkg.uuid : "", + "v" => (vstr == "VersionSpec(\"*\")" ? "" : vstr), + "features" => pkg.features] if pkg.repo !== nothing if pkg.repo.url !== nothing push!(f, "url/path" => string("\"", pkg.repo.url, "\""))