Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove separate source_urls wizard field #1293

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ghr_jll = "07c12ed4-43bc-5495-8a2a-d5838ef8d533"

[compat]
ArgParse = "1.1"
BinaryBuilderBase = "1.20"
BinaryBuilderBase = "1.26"
GitHub = "5.1"
HTTP = "0.8, 0.9, 1"
JLD2 = "0.1.6, 0.2, 0.3, 0.4"
Expand Down
16 changes: 7 additions & 9 deletions src/wizard/deploy.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
function print_build_tarballs(io::IO, state::WizardState)
urlfiles = zip(state.source_urls, state.source_files)

sources_strings = map(urlfiles) do x
sources_strings = map(state.source_files) do source
# Try to be smart and automatically replace version number with `$(version)`.
url_string = replace(repr(x[1]), string(state.version) => "\$(version)")
if endswith(x[1], ".git")
"GitSource($(url_string), $(repr(x[2].hash)))"
elseif any(endswith(x[1], ext) for ext in BinaryBuilderBase.archive_extensions)
"ArchiveSource($(url_string), $(repr(x[2].hash)))"
url_string = replace(repr(source.url), string(state.version) => "\$(version)")
if endswith(source.url, ".git")
"GitSource($(url_string), $(repr(source.hash)))"
elseif any(endswith(source.url, ext) for ext in BinaryBuilderBase.archive_extensions)
"ArchiveSource($(url_string), $(repr(source.hash)))"
else
"FileSource($(url_string), $(repr(x[2].hash)))"
"FileSource($(url_string), $(repr(source.hash)))"
end
end
if !isempty(state.patches)
Expand Down
15 changes: 6 additions & 9 deletions src/wizard/obtain_source.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function download_source(state::WizardState)
"""), "\n" => " ")
new_entered_url = nonempty_line_prompt("URL", msg; ins=state.ins, outs=state.outs)
if new_entered_url == "N" || new_entered_url == "n"
return new_entered_url, SetupSource(string(new_entered_url), "", "", "")
return nothing
end
# Early-exit for invalid URLs, using HTTP.URIs.parse_uri() to ensure
# it is a valid URL
Expand Down Expand Up @@ -82,8 +82,7 @@ function download_source(state::WizardState)
end

local source_hash

if endswith(url, ".git") || startswith(url, "git://")
if endswith(url, ".git") || startswith(url, "git://") || startswith(url, "ssh://")
source_path = cached_git_clone(url; progressbar=true, verbose=true)
# Clone the URL, record the current gitsha for the given branch
repo = GitRepo(source_path)
Expand Down Expand Up @@ -136,7 +135,7 @@ function download_source(state::WizardState)
end

# Spit back the url, local path and source hash
return url, SetupSource(url, source_path, source_hash, "")
return SetupSource(url, source_path, source_hash, "")
end

"""
Expand Down Expand Up @@ -272,17 +271,15 @@ function obtain_source(state::WizardState)

# These are the metadata we need to know about all the sources we'll be
# building over the course of this journey we're on together.
state.source_urls = String[]
state.source_files = SetupSource[]

while true
url, file = download_source(state)
if url != "N"
push!(state.source_urls, url)
file = download_source(state)
if file !== nothing
push!(state.source_files, file)
println(state.outs)
else
if isempty(state.source_urls)
if isempty(state.source_files)
printstyled(state.outs, "No URLs were given.\n", color=:yellow, bold=true)
continue
end
Expand Down
1 change: 0 additions & 1 deletion src/wizard/state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ necessary. It also holds all necessary metadata such as input/output streams.

# Filled in by step 2
workspace::Union{Nothing, String} = nothing
source_urls::Union{Nothing, Vector{String}} = nothing
source_files::Union{Nothing, Vector{SetupSource}} = nothing
dependencies::Union{Nothing, Vector{Dependency}} = nothing
compilers::Union{Nothing, Vector{Symbol}} = nothing
Expand Down
3 changes: 1 addition & 2 deletions test/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ end
state = Wizard.WizardState()
state.step = :step34
state.platforms = [Platform("x86_64", "linux")]
state.source_urls = ["http://127.0.0.1:14444/a/source.tar.gz"]
state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}("/tmp/source.tar.gz", bytes2hex(sha256("a")), "")]
state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}("http://127.0.0.1:14444/a/source.tar.gz", "/tmp/source.tar.gz", bytes2hex(sha256("a")), "")]
state.name = "libfoo"
state.version = v"1.0.0"
state.dependencies = [Dependency(PackageSpec(;name="Zlib_jll")),
Expand Down
10 changes: 5 additions & 5 deletions test/wizard.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ end
call_response(ins, outs, "Select the preferred LLVM version", "\e[B\e[B\e[B\r")
end
# Check that the state is modified appropriately
@test state.source_urls == ["http://127.0.0.1:$(port)/a/source.tar.gz"]
@test getfield.(state.source_files, :url) == ["http://127.0.0.1:$(port)/a/source.tar.gz"]
@test getfield.(state.source_files, :hash) == [libfoo_tarball_hash]
@test Set(state.compilers) == Set([:c, :rust, :go])
@test state.preferred_gcc_version == getversion(available_gcc_builds[1])
Expand All @@ -201,7 +201,7 @@ end
call_response(ins, outs, "Do you want to customize the set of compilers?", "N")
end
# Check that the state is modified appropriately
@test state.source_urls == [
@test getfield.(state.source_files, :url) == [
"http://127.0.0.1:$(port)/a/source.tar.gz",
"http://127.0.0.1:$(port)/b/source.tar.gz",
]
Expand Down Expand Up @@ -268,7 +268,7 @@ end
call_response(ins, outs, "Enter a version number", "1.0.0")
call_response(ins, outs, "Do you want to customize the set of compilers?", "N")
end
@test state.source_urls == ["http://127.0.0.1:$(port)/a/source.tar.gz"]
@test getfield.(state.source_files, :url) == ["http://127.0.0.1:$(port)/a/source.tar.gz"]
state = step2_state()
with_wizard_output(state, Wizard.step2) do ins, outs
call_response(ins, outs, "Please enter a URL", "N")
Expand All @@ -295,8 +295,8 @@ function step3_state()
state = Wizard.WizardState()
state.step = :step34
state.platforms = [Platform("x86_64", "linux")]
state.source_urls = ["http://127.0.0.1:$(port)/a/source.tar.gz"]
state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}(libfoo_tarball_path, libfoo_tarball_hash, "")]
state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}("http://127.0.0.1:$(port)/a/source.tar.gz",
libfoo_tarball_path, libfoo_tarball_hash, "")]
state.name = "libfoo"
state.version = v"1.0.0"
state.dependencies = Dependency[]
Expand Down