Created
October 30, 2019 22:17
-
-
Save JeffBezanson/a4d45bd3977ba96eb0223105e9c12e86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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