Alternatives to BinaryBuilder.jl?

I’m making a wrapper for SimpleBLE in Julia and I can’t get it to build targeting windows in BinaryBuilder.jl I suspect because Mingw_jll is too old.

As a result I’ve written the package using pre-built binaries using @ccall and it works pretty well as far as I can tell. SimpleBLE.jl

But when I try to ship it with a local registry to another computer I get an access denied error because the .julia/packages directory has special permissions.

So my question is: Is there a recommended way to ship a package with pre-built binaries that is not BinaryBuilder.jl?

This post is also me begging for help with building SimpleBLE for windows (I got it working for Linux, see this post, but I don’t use Linux). I’ve opened an issue on Yggdrasil for updating MinGW but I just don’t know enough.

I’ve found something that seems to work.

Copy the dlls into a named directory inside tempdir() load it with Libc.Libdl.dlopen and then delete the copies.

This must be done inside of the __init__ function of the module to make sure that the library is loaded when the module is.

The directory must be named and made with mkdir because otherwise Julia complains at exit that it can’t delete the tempdir, probably because julia makes temporary copies of the dlls for it self and doesn’t delete them before tempdir clean up.

Even if you’re not using Yggdrasil, I’d strongly advise you to use Artifacts. Instead of putting the hand-built DLLs into the git repository itself, you can put them into a GitHub release asset akin to how BB/Yggdrasil do it. Or ArtifactUtils.jl will help you stash them into Gists.

1 Like

That would be perfect but I get an access denied error when I try to load the library while it is inside the artifacts directory.

Though I will do this to download them.

That is true about how Pkg adds packages, but it’s not the case for artifacts. They are built for this very use case and should preserve the permissions within the tarball.

Could you give an example of how to save the files? I just followed this example and did the following

using Pkg.Artifacts
using ZipArchives

artifact_toml = joinpath(@__DIR__, "..", "Artifacts.toml")

win_simplecble_hash = artifact_hash("win_simplecble", artifact_toml)

if win_simplecble_hash === nothing || !artifact_exists(win_simplecble_hash)
	win_simplecble_hash = create_artifact() do artifact_dir
		simplebleurl = "https://github.com/simpleble/simpleble/releases/download/v0.12.1/libsimplecble_windows-x64.zip"
		archive = ZipReader(read(download(simplebleurl)))
		write(joinpath(artifact_dir, "simpleble.dll"), zip_readentry(archive, "shared/bin/simpleble.dll"))
		write(joinpath(artifact_dir, "simplecble.dll"), zip_readentry(archive, "shared/bin/simplecble.dll"))
	end

	bind_artifact!(artifact_toml, "win_simplecble", win_simplecble_hash)
end

win_dll_dir = artifact_path(win_simplecble_hash)

You could take a page from some other recipes that have failed to build for Windows and fall back to an upstream-provided built product.

E.g,

3 Likes

I think it mostly works if you create the artifact on a Unix like file system, but if you use Windows to create the artifact, the permissions may be handle a bit strangely. XRef: https://github.com/JuliaLang/julia/issues/52272#issuecomment-2088920511 and Use WSL style NTFS extended attributes to store permissions of extracted artifacts on Windows · Issue #2677 · JuliaLang/Pkg.jl · GitHub

Huzza! SimpleBLE_jll build_tarbals.jl

2 Likes