diff --git a/Artifacts.toml b/Artifacts.toml new file mode 100644 index 0000000..a2830a3 --- /dev/null +++ b/Artifacts.toml @@ -0,0 +1,8 @@ +[[Git]] +arch = "i686" +git-tree-sha1 = "682b57bfc6b32066d58009a78a02c3263f993af3" +os = "windows" + + [[Git.download]] + sha256 = "9c85515690867047a57dd365e4a1ef9776036a01d1781a37d282acf9d5676bf8" + url = "https://github.com/JuliaBinaryWrappers/Git_jll.jl/releases/download/Git-v2.23.0+0/Git.v2.23.0.i686-w64-mingw32.tar.gz" diff --git a/Project.toml b/Project.toml new file mode 100644 index 0000000..187d8e7 --- /dev/null +++ b/Project.toml @@ -0,0 +1,10 @@ +name = "Git_jll" +uuid = "f8c6e375-362e-5223-8a59-34ff63f689eb" +version = "2.23.0+0" + +[deps] +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" + +[compat] +julia = "1.3" diff --git a/README.md b/README.md new file mode 100644 index 0000000..ab22e2a --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# Git_jll.jl + +This is an autogenerated package constructed using [`BinaryBuilder.jl`](https://github.com/JuliaPackaging/BinaryBuilder.jl). + +## Usage + +The code bindings within this package are autogenerated from the `Products` defined within the `build_tarballs.jl` file that generated this package. For example purposes, we will assume that the following products were defined: + +```julia +products = [ + FileProduct("src/data.txt", :data_txt), + LibraryProduct("libdataproc", :libdataproc), + ExecutableProduct("mungify", :mungify_exe) +] +``` + +With such products defined, this package will contain `data_txt`, `libdataproc` and `mungify_exe` symbols exported. For `FileProduct` variables, the exported value is a string pointing to the location of the file on-disk. For `LibraryProduct` variables, it is a string corresponding to the `SONAME` of the desired library (it will have already been `dlopen()`'ed, so typical `ccall()` usage applies), and for `ExecutableProduct` variables, the exported value is a function that can be called to set appropriate environment variables. Example: + +```julia +using Git_jll + +# For file products, you can access its file location directly: +data_lines = open(data_txt, "r") do io + readlines(io) +end + +# For library products, you can use the exported variable name in `ccall()` invocations directly +num_chars = ccall((libdataproc, :count_characters), Cint, (Cstring, Cint), data_lines[1], length(data_lines[1])) + +# For executable products, you can use the exported variable name as a function that you can call +mungify_exe() do mungify_exe_path + run(`$mungify_exe_path $num_chars`) +end +``` diff --git a/src/Git_jll.jl b/src/Git_jll.jl new file mode 100644 index 0000000..da82bd7 --- /dev/null +++ b/src/Git_jll.jl @@ -0,0 +1,31 @@ +module Git_jll +using Pkg, Pkg.BinaryPlatforms, Pkg.Artifacts, Libdl +import Base: UUID + +# 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[] +const LIBPATH_list = String[] + +# Load Artifacts.toml file +artifacts_toml = joinpath(@__DIR__, "..", "Artifacts.toml") + +# Extract all platforms +artifacts = Pkg.Artifacts.load_artifacts_toml(artifacts_toml; pkg_uuid=UUID("f8c6e375-362e-5223-8a59-34ff63f689eb")) +platforms = [Pkg.Artifacts.unpack_platform(e, "Git", artifacts_toml) for e in artifacts["Git"]] + +# Filter platforms based on what wrappers we've generated on-disk +platforms = filter(p -> isfile(joinpath(@__DIR__, "wrappers", triplet(p) * ".jl")), platforms) + +# From the available options, choose the best platform +best_platform = select_platform(Dict(p => triplet(p) for p in platforms)) + +# Silently fail if there's no binaries for this platform +if best_platform === nothing + @debug("Unable to load Git; unsupported platform $(triplet(platform_key_abi()))") +else + # Load the appropriate wrapper + include(joinpath(@__DIR__, "wrappers", "$(best_platform).jl")) +end + +end # module Git_jll diff --git a/src/wrappers/i686-w64-mingw32.jl b/src/wrappers/i686-w64-mingw32.jl new file mode 100644 index 0000000..96700e2 --- /dev/null +++ b/src/wrappers/i686-w64-mingw32.jl @@ -0,0 +1,62 @@ +# Autogenerated wrapper script for Git_jll for i686-w64-mingw32 +export git + +## Global variables +PATH = "" +LIBPATH = "" +LIBPATH_env = "PATH" + +# Relative path to `git` +const git_splitpath = ["bin", "git.exe"] + +# This will be filled out by __init__() for all products, as it must be done at runtime +git_path = "" + +# git-specific global declaration +function git(f::Function; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = true) + global PATH, LIBPATH + env_mapping = Dict{String,String}() + if adjust_PATH + if !isempty(get(ENV, "PATH", "")) + env_mapping["PATH"] = string(ENV["PATH"], ';', PATH) + else + env_mapping["PATH"] = PATH + end + end + if adjust_LIBPATH + if !isempty(get(ENV, LIBPATH_env, "")) + env_mapping[LIBPATH_env] = string(ENV[LIBPATH_env], ';', LIBPATH) + else + env_mapping[LIBPATH_env] = LIBPATH + end + end + withenv(env_mapping...) do + f(git_path) + end +end + + +""" +Open all libraries +""" +function __init__() + global prefix = abspath(joinpath(@__DIR__, "..")) + + # Initialize PATH and LIBPATH environment variable listings + global PATH_list, LIBPATH_list + global git_path = abspath(joinpath(artifact"Git", git_splitpath...)) + + push!(PATH_list, dirname(git_path)) + # Filter out duplicate and empty entries in our PATH and LIBPATH entries + filter!(!isempty, unique!(PATH_list)) + filter!(!isempty, unique!(LIBPATH_list)) + global PATH = join(PATH_list, ';') + global LIBPATH = join(LIBPATH_list, ';') + + # Add each element of LIBPATH to our DL_LOAD_PATH (necessary on platforms + # that don't honor our "already opened" trick) + #for lp in LIBPATH_list + # push!(DL_LOAD_PATH, lp) + #end +end # __init__() +