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

add a few global -> Ref #12

Merged
merged 1 commit into from
Sep 21, 2020
Merged
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
19 changes: 9 additions & 10 deletions src/products/executable_generators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ function declare_old_executable_product(product_name)
return Base.invokelatest(
JLLWrappers.withenv_executable_wrapper,
f,
$(Symbol("$(product_name)_path")),
PATH,
LIBPATH,
$(Symbol("$(product_name)_path"))[],
PATH[],
LIBPATH[],
adjust_PATH,
adjust_LIBPATH,
)
end

# This will eventually be replaced with a `Ref{String}`
$(path_name) = ""
$(path_name) = Ref{String}()
function $(Symbol(string("get_", product_name, "_path")))()
return $(path_name)::String
return $(path_name)[]
end
end
end
Expand All @@ -34,12 +33,12 @@ function declare_new_executable_product(product_name)
env = Base.invokelatest(
JLLWrappers.adjust_ENV!,
copy(ENV),
PATH,
LIBPATH,
PATH[],
LIBPATH[],
adjust_PATH,
adjust_LIBPATH,
)
return Cmd(Cmd([$(path_name)]); env)
return Cmd(Cmd([$(path_name)[]]); env)
end

# Signal to concerned parties that they should use the new version, eventually.
Expand All @@ -61,7 +60,7 @@ macro init_executable_product(product_name, product_path)
path_name = Symbol(string(product_name, "_path"))
return esc(quote
# Locate the executable on-disk, store into $(path_name)
global $(path_name) = joinpath(artifact_dir, $(product_path))
$(path_name)[] = joinpath(artifact_dir, $(product_path))

# Add this executable's directory onto the list of PATH's that we'll need to expose to dependents
push!(PATH_list, joinpath(artifact_dir, $(dirname(product_path))))
Expand Down
4 changes: 2 additions & 2 deletions src/toplevel_generators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ function generate_toplevel_definitions(src_name, __source__)
"""
function is_available end

PATH = ""
LIBPATH = ""
const PATH = Ref{String}("")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if these were supposed to be initialized or not but if they are not I run into #11.

const LIBPATH = Ref{String}("")
# We put these inter-JLL-package API values here so that they are always defined, even if there
# is no underlying wrapper held within this JLL package.
const PATH_list = String[]
Expand Down
4 changes: 2 additions & 2 deletions src/wrapper_generators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ macro generate_init_footer()
# Filter out duplicate and empty entries in our PATH and LIBPATH entries
unique!(PATH_list)
unique!(LIBPATH_list)
global PATH = join(PATH_list, $(pathsep))
global LIBPATH = join(vcat(LIBPATH_list, Base.invokelatest(JLLWrappers.get_julia_libpaths)), $(pathsep))
PATH[] = join(PATH_list, $(pathsep))
LIBPATH[] = join(vcat(LIBPATH_list, Base.invokelatest(JLLWrappers.get_julia_libpaths)), $(pathsep))
end)
end
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module TestJLL end
else
@test @eval TestJLL HelloWorldC_jll.is_available()
@test "Hello, World!" == @eval TestJLL hello_world(h->readchomp(`$h`))
@test isfile(@eval TestJLL HelloWorldC_jll.hello_world_path)
@test isfile(@eval TestJLL HelloWorldC_jll.hello_world_path[])
@test isfile(@eval TestJLL HelloWorldC_jll.get_hello_world_path())
@test isdir(@eval TestJLL HelloWorldC_jll.artifact_dir)
end
Expand Down