Skip to content

Instantly share code, notes, and snippets.

@JeffBezanson
Created October 30, 2019 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffBezanson/a4d45bd3977ba96eb0223105e9c12e86 to your computer and use it in GitHub Desktop.
Save JeffBezanson/a4d45bd3977ba96eb0223105e9c12e86 to your computer and use it in GitHub Desktop.
function do_artifact_str(name, sfile, __module__)
local artifacts_toml = find_artifacts_toml(sfile)
if artifacts_toml === nothing
error(string(
"Cannot locate '(Julia)Artifacts.toml' file when attempting to use artifact '",
name,
"' in '",
__module__,
"'",
))
end
local pkg_uuid = nothing
if haskey(Base.module_keys, __module__)
pkg_uuid = Base.module_keys[__module__].uuid
end
# This is the resultant value at the end of all things
ensure_artifact_installed(name, artifacts_toml; pkg_uuid=pkg_uuid)
end
"""
macro artifact_str(name)
Macro that is used to automatically ensure an artifact is installed, and return its
location on-disk. Automatically looks the artifact up by name in the project's
`(Julia)Artifacts.toml` file. Throws an error on inability to install the requested artifact.
"""
macro artifact_str(name)
return quote
Base.invokelatest(do_artifact_str, $name, $(string(__source__.file)), $__module__)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment