Skip to content

Commit a0032c4

Browse files
committed
Remove separate source_urls wizard field
Goes with JuliaPackaging/BinaryBuilderBase.jl#322. Part of the problem with the current setup is that the WizardState doesn't actually round trip properly, because the cache for archive downloads gets deleted. It could be reconstituted from source_urls of course, but it would be cleaner to just do that on-demand with the SetupSource (though this commit doesn't do that yet).
1 parent d40ec61 commit a0032c4

File tree

6 files changed

+20
-27
lines changed

6 files changed

+20
-27
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ghr_jll = "07c12ed4-43bc-5495-8a2a-d5838ef8d533"
3333

3434
[compat]
3535
ArgParse = "1.1"
36-
BinaryBuilderBase = "1.20"
36+
BinaryBuilderBase = "1.26"
3737
GitHub = "5.1"
3838
HTTP = "0.8, 0.9, 1"
3939
JLD2 = "0.1.6, 0.2, 0.3, 0.4"

src/wizard/deploy.jl

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
function print_build_tarballs(io::IO, state::WizardState)
2-
urlfiles = zip(state.source_urls, state.source_files)
3-
4-
sources_strings = map(urlfiles) do x
2+
sources_strings = map(state.source_files) do source
53
# Try to be smart and automatically replace version number with `$(version)`.
6-
url_string = replace(repr(x[1]), string(state.version) => "\$(version)")
7-
if endswith(x[1], ".git")
8-
"GitSource($(url_string), $(repr(x[2].hash)))"
9-
elseif any(endswith(x[1], ext) for ext in BinaryBuilderBase.archive_extensions)
10-
"ArchiveSource($(url_string), $(repr(x[2].hash)))"
4+
url_string = replace(repr(source.url), string(state.version) => "\$(version)")
5+
if endswith(source.url, ".git")
6+
"GitSource($(url_string), $(repr(source.hash)))"
7+
elseif any(endswith(source.url, ext) for ext in BinaryBuilderBase.archive_extensions)
8+
"ArchiveSource($(url_string), $(repr(source.hash)))"
119
else
12-
"FileSource($(url_string), $(repr(x[2].hash)))"
10+
"FileSource($(url_string), $(repr(source.hash)))"
1311
end
1412
end
1513
if !isempty(state.patches)

src/wizard/obtain_source.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function download_source(state::WizardState)
5454
"""), "\n" => " ")
5555
new_entered_url = nonempty_line_prompt("URL", msg; ins=state.ins, outs=state.outs)
5656
if new_entered_url == "N" || new_entered_url == "n"
57-
return new_entered_url, SetupSource(string(new_entered_url), "", "", "")
57+
return nothing
5858
end
5959
# Early-exit for invalid URLs, using HTTP.URIs.parse_uri() to ensure
6060
# it is a valid URL
@@ -82,8 +82,7 @@ function download_source(state::WizardState)
8282
end
8383

8484
local source_hash
85-
86-
if endswith(url, ".git") || startswith(url, "git://")
85+
if endswith(url, ".git") || startswith(url, "git://") || startswith(url, "ssh://")
8786
source_path = cached_git_clone(url; progressbar=true, verbose=true)
8887
# Clone the URL, record the current gitsha for the given branch
8988
repo = GitRepo(source_path)
@@ -136,7 +135,7 @@ function download_source(state::WizardState)
136135
end
137136

138137
# Spit back the url, local path and source hash
139-
return url, SetupSource(url, source_path, source_hash, "")
138+
return SetupSource(url, source_path, source_hash, "")
140139
end
141140

142141
"""
@@ -272,17 +271,15 @@ function obtain_source(state::WizardState)
272271

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

278276
while true
279-
url, file = download_source(state)
280-
if url != "N"
281-
push!(state.source_urls, url)
277+
file = download_source(state)
278+
if file !== nothing
282279
push!(state.source_files, file)
283280
println(state.outs)
284281
else
285-
if isempty(state.source_urls)
282+
if isempty(state.source_files)
286283
printstyled(state.outs, "No URLs were given.\n", color=:yellow, bold=true)
287284
continue
288285
end

src/wizard/state.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ necessary. It also holds all necessary metadata such as input/output streams.
3131

3232
# Filled in by step 2
3333
workspace::Union{Nothing, String} = nothing
34-
source_urls::Union{Nothing, Vector{String}} = nothing
3534
source_files::Union{Nothing, Vector{SetupSource}} = nothing
3635
dependencies::Union{Nothing, Vector{Dependency}} = nothing
3736
compilers::Union{Nothing, Vector{Symbol}} = nothing

test/basic.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ end
167167
state = Wizard.WizardState()
168168
state.step = :step34
169169
state.platforms = [Platform("x86_64", "linux")]
170-
state.source_urls = ["http://127.0.0.1:14444/a/source.tar.gz"]
171-
state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}("/tmp/source.tar.gz", bytes2hex(sha256("a")), "")]
170+
state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}("http://127.0.0.1:14444/a/source.tar.gz", "/tmp/source.tar.gz", bytes2hex(sha256("a")), "")]
172171
state.name = "libfoo"
173172
state.version = v"1.0.0"
174173
state.dependencies = [Dependency(PackageSpec(;name="Zlib_jll")),

test/wizard.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ end
178178
call_response(ins, outs, "Select the preferred LLVM version", "\e[B\e[B\e[B\r")
179179
end
180180
# Check that the state is modified appropriately
181-
@test state.source_urls == ["http://127.0.0.1:$(port)/a/source.tar.gz"]
181+
@test getfield.(state.source_files, :url) == ["http://127.0.0.1:$(port)/a/source.tar.gz"]
182182
@test getfield.(state.source_files, :hash) == [libfoo_tarball_hash]
183183
@test Set(state.compilers) == Set([:c, :rust, :go])
184184
@test state.preferred_gcc_version == getversion(available_gcc_builds[1])
@@ -201,7 +201,7 @@ end
201201
call_response(ins, outs, "Do you want to customize the set of compilers?", "N")
202202
end
203203
# Check that the state is modified appropriately
204-
@test state.source_urls == [
204+
@test getfield.(state.source_files, :url) == [
205205
"http://127.0.0.1:$(port)/a/source.tar.gz",
206206
"http://127.0.0.1:$(port)/b/source.tar.gz",
207207
]
@@ -268,7 +268,7 @@ end
268268
call_response(ins, outs, "Enter a version number", "1.0.0")
269269
call_response(ins, outs, "Do you want to customize the set of compilers?", "N")
270270
end
271-
@test state.source_urls == ["http://127.0.0.1:$(port)/a/source.tar.gz"]
271+
@test getfield.(state.source_files, :url) == ["http://127.0.0.1:$(port)/a/source.tar.gz"]
272272
state = step2_state()
273273
with_wizard_output(state, Wizard.step2) do ins, outs
274274
call_response(ins, outs, "Please enter a URL", "N")
@@ -295,8 +295,8 @@ function step3_state()
295295
state = Wizard.WizardState()
296296
state.step = :step34
297297
state.platforms = [Platform("x86_64", "linux")]
298-
state.source_urls = ["http://127.0.0.1:$(port)/a/source.tar.gz"]
299-
state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}(libfoo_tarball_path, libfoo_tarball_hash, "")]
298+
state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}("http://127.0.0.1:$(port)/a/source.tar.gz",
299+
libfoo_tarball_path, libfoo_tarball_hash, "")]
300300
state.name = "libfoo"
301301
state.version = v"1.0.0"
302302
state.dependencies = Dependency[]

0 commit comments

Comments
 (0)