BinaryBuilderBase.jl Documentation
This is the reference documentation of BinaryBuilderBase.jl
.
Index
BinaryBuilderBase.default_host_platform
BinaryBuilderBase.AbstractDependency
BinaryBuilderBase.AbstractSource
BinaryBuilderBase.AnyPlatform
BinaryBuilderBase.ArchiveSource
BinaryBuilderBase.BuildDependency
BinaryBuilderBase.Dependency
BinaryBuilderBase.DirectorySource
BinaryBuilderBase.DockerRunner
BinaryBuilderBase.ExecutableProduct
BinaryBuilderBase.FileProduct
BinaryBuilderBase.FileSource
BinaryBuilderBase.FrameworkProduct
BinaryBuilderBase.GitSource
BinaryBuilderBase.HostBuildDependency
BinaryBuilderBase.LibraryProduct
BinaryBuilderBase.Product
BinaryBuilderBase.RuntimeDependency
BinaryBuilderBase.UserNSRunner
BinaryBuilderBase.abi_agnostic
BinaryBuilderBase.accept_apple_sdk
BinaryBuilderBase.artifact_name
BinaryBuilderBase.bindir
BinaryBuilderBase.choose_shards
BinaryBuilderBase.chown_cleanup
BinaryBuilderBase.collect_jll_uuids
BinaryBuilderBase.compress_dir
BinaryBuilderBase.download_all_artifacts
BinaryBuilderBase.download_source
BinaryBuilderBase.enable_apple_file
BinaryBuilderBase.expand_cxxstring_abis
BinaryBuilderBase.expand_gfortran_versions
BinaryBuilderBase.expand_microarchitectures
BinaryBuilderBase.expand_microarchitectures
BinaryBuilderBase.filter_platforms
BinaryBuilderBase.gcc_version
BinaryBuilderBase.generate_compiler_wrappers!
BinaryBuilderBase.generate_per_uid_squashfs
BinaryBuilderBase.get_addable_spec
BinaryBuilderBase.get_commit_sha
BinaryBuilderBase.get_concrete_platform
BinaryBuilderBase.get_concrete_platform
BinaryBuilderBase.get_tree_hash
BinaryBuilderBase.getgid
BinaryBuilderBase.getuid
BinaryBuilderBase.import_docker_image
BinaryBuilderBase.includedir
BinaryBuilderBase.installed_shards
BinaryBuilderBase.is_build_dependency
BinaryBuilderBase.is_ecryptfs
BinaryBuilderBase.is_host_dependency
BinaryBuilderBase.is_mounted
BinaryBuilderBase.is_runtime_dependency
BinaryBuilderBase.is_target_dependency
BinaryBuilderBase.is_top_level_dependency
BinaryBuilderBase.libabi_agnostic
BinaryBuilderBase.libdirs
BinaryBuilderBase.locate
BinaryBuilderBase.locate
BinaryBuilderBase.locate
BinaryBuilderBase.logdir
BinaryBuilderBase.macos_sdk_already_installed
BinaryBuilderBase.manage_shards
BinaryBuilderBase.map_target
BinaryBuilderBase.mount
BinaryBuilderBase.package
BinaryBuilderBase.platform_envs
BinaryBuilderBase.platform_exeext
BinaryBuilderBase.preferred_cxxstring_abi
BinaryBuilderBase.preferred_libgfortran_version
BinaryBuilderBase.runshell
BinaryBuilderBase.satisfied
BinaryBuilderBase.setup_workspace
BinaryBuilderBase.shard_mappings
BinaryBuilderBase.shard_path
BinaryBuilderBase.supported_platforms
BinaryBuilderBase.temp_prefix
BinaryBuilderBase.uname
BinaryBuilderBase.unmount
BinaryBuilderBase.variable_name
BinaryBuilderBase.versioninfo
Types
BinaryBuilderBase.AbstractDependency
— TypeAn AbstractDependency
is a binary dependency of the JLL package. Dependencies are installed to ${prefix}
in the build environment.
Concrete subtypes of AbstractDependency
are
Dependency
: a JLL package that is necessary for to build the package and to load the generated JLL package.RuntimeDependency
: a JLL package that is necessary only at runtime. Its artifact will not be installed in the prefix during the build.BuildDependency
: a JLL package that is necessary only to build the package. This will not be a dependency of the generated JLL package.HostBuildDependency
: similar toBuildDependency
, but it will install the artifact for the host platform, instead of that for the target platform.
Subtypes of AbstractDependency
should define the following traits:
is_host_dependency
is_target_dependency
is_build_dependency
is_runtime_dependency
- [
is_top_level_dependency
][@ref]
BinaryBuilderBase.AbstractSource
— TypeAn AbstractSource
is something used as source to build the package. Sources are installed to ${WORKSPACE}/srcdir
in the build environment.
Concrete subtypes of AbstractSource
are:
ArchiveSource
: a remote archive to download from the Internet;FileSource
: a remote file to download from the Internet;GitSource
: a remote Git repository to clone;DirectorySource
: a local directory to mount.
BinaryBuilderBase.AnyPlatform
— TypeAnyPlatform()
A special platform to be used to build platform-independent tarballs, like those containing only header files. FileProduct
is the only product type allowed with this platform.
BinaryBuilderBase.ArchiveSource
— TypeArchiveSource(url::String, hash::String; unpack_target::String = "")
Specify a remote archive in one of the supported archive formats (e.g., TAR or ZIP balls) to be downloaded from the Internet from url
. hash
is the 64-character SHA256 checksum of the file.
In the builder environment, the archive will be automatically unpacked to ${WORKSPACE}/srcdir
, or in its subdirectory pointed to by the optional keyword unpack_target
, if provided.
BinaryBuilderBase.BuildDependency
— TypeBuildDependency(dep::Union{PackageSpec,String}; platforms)
Define a binary dependency that is necessary only to build the package. The dep
argument can be either a string with the name of the JLL package or a Pkg.PackageSpec
.
The optional keyword argument platforms
is a vector of AbstractPlatform
s which indicates for which platforms the dependency should be used. By default platforms=[AnyPlatform()]
, to mean that the dependency is compatible with all platforms.
BinaryBuilderBase.Dependency
— TypeDependency(dep::Union{PackageSpec,String}, build_version::VersionNumber;
compat::String, platforms::Vector{<:AbstractPlatform})
Define a binary dependency that is necessary to build the package and load the generated JLL package. The argument can be either a string with the name of the JLL package or a Pkg.PackageSpec
.
The optional positional argument build_version
can be used to specify the version of the dependency to be installed when building it. If not specified, the latest version of the package compatible with the environment will be automatically chosen by the package resolver, unless compat
is specified, see below.
The optional keyword argument compat
can be used to specify a string for use in the Project.toml
of the generated Julia package. If compat
is non-empty and build_version
is not passed, the latter defaults to the minimum version compatible with the compat
specifier.
The optional keyword argument platforms
is a vector of AbstractPlatform
s which indicates for which platforms the dependency should be used. By default platforms=[AnyPlatform()]
, to mean that the dependency is compatible with all platforms.
The optional keyword argument top_level
denotates that this dependency is platform independent. It implies that the platforms
keyword argument is set to [AnyPlatform()]
. The primary use-case is for packages that hold information about the platform selection using Preferences
. Platform selection is cached and in the case that no platform is available we need to be able to invalidate said cache. Invalidation occurs through the package that owns the Preferences
data.
BinaryBuilderBase.DirectorySource
— TypeDirectorySource(path::String; target::String = basename(path), follow_symlinks=false)
Specify a local directory to mount from path
.
The content of the directory will be mounted in ${WORKSPACE}/srcdir
, or in its subdirectory pointed to by the optional keyword target
, if provided. Symbolic links are replaced by a copy of the target when follow_symlinks
is true
.
BinaryBuilderBase.DockerRunner
— TypeDockerRunner
Use docker
as an execution engine; a reasonable backup for platforms that do not have user namespaces (e.g. MacOS, Windows).
BinaryBuilderBase.ExecutableProduct
— TypeAn ExecutableProduct
is a Product
that represents an executable file.
On all platforms, an ExecutableProduct checks for existence of the file. On non-Windows platforms, it will check for the executable bit being set. On Windows platforms, it will check that the file ends with ".exe", (adding it on automatically, if it is not already present).
ExecutableProduct(binname, varname::Symbol, dir_path="bin")
Declares an ExecutableProduct
that points to an executable located within the prefix. binname
specifies the basename of the executable, varname
is the name of the variable in the JLL package that can be used to call into the library. By default, the library is searched in the bindir
, but you can specify a different directory within the prefix with the dir_path
argument.
BinaryBuilderBase.FileProduct
— TypeFileProduct(path, varname::Symbol, dir_path = nothing)
Declares a FileProduct
that points to a file located relative to the root of a Prefix
, must simply exist to be satisfied. The first argument path
is either a single AbstractString
or a Vector{String}
to allow several paths to be checked.
BinaryBuilderBase.FileSource
— TypeFileSource(url::String, hash::String; filename::String = basename(url))
Specify a remote file to be downloaded from the Internet from url
. hash
is the 64-character SHA256 checksum of the file.
In the builder environment, the file will be saved under ${WORKSPACE}/srcdir
with the same name as the basename of the originating URL, unless the the keyword argument filename
is specified.
BinaryBuilderBase.FrameworkProduct
— TypeA FrameworkProduct
is a Product
that encapsulates a macOS Framework. It behaves mostly as a LibraryProduct
for now, but is a distinct type. This implies that for cross-platform builds where a library is provided as a Framework on macOS and as a normal library on other platforms, two calls to BinaryBuilder's build_tarballs
are needed: one with the LibraryProduct
and all non-macOS platforms, and one with the FrameworkProduct
and the MacOS
platforms.
FrameworkProduct(fwnames, varname::Symbol)
Declares a macOS FrameworkProduct
that points to a framework located within the prefix, with a name containing fwname
appended with .framework
. As an example, given that fwname
is equal to QtCore
, this would be satisfied by the following path:
lib/QtCore.framework
BinaryBuilderBase.GitSource
— TypeGitSource(url::String, hash::String; unpack_target::String = "")
Specify a remote Git repository to clone form url
. hash
is the 40-character SHA1 revision to checkout after cloning.
The repository will be cloned in ${WORKSPACE}/srcdir
, or in its subdirectory pointed to by the optional keyword unpack_target
, if provided.
BinaryBuilderBase.HostBuildDependency
— TypeHostBuildDependency(dep::Union{PackageSpec,String}; platforms)
Define a binary dependency that is necessary only to build the package. Different from the BuildDependency
, the artifact for the host platform will be installed, instead of that for the target platform.
The dep
argument can be either a string with the name of the JLL package or a Pkg.PackageSpec
.
The optional keyword argument platforms
is a vector of AbstractPlatform
s which indicates for which platforms the dependency should be used. By default platforms=[AnyPlatform()]
, to mean that the dependency is compatible with all platforms.
BinaryBuilderBase.LibraryProduct
— TypeA LibraryProduct
is a special kind of Product
that not only needs to exist, but needs to be dlopen()
'able. You must know which directory the library will be installed to, and its name, e.g. to build a LibraryProduct
that refers to "/lib/libnettle.so"
, the "directory" would be "/lib", and the "libname" would be "libnettle". Note that a LibraryProduct
can support multiple libnames, as some software projects change the libname based on the build configuration.
LibraryProduct(libname, varname::Symbol, dir_paths=String[];
dont_dlopen=false, dlopen_flags=Symbol[])
Declares a LibraryProduct
that points to a library located within the prefix. libname
specifies the basename of the library, varname
is the name of the variable in the JLL package that can be used to call into the library. By default, the library is searched in the libdir
, but you can add other directories within the prefix to the dir_paths
argument. You can specify the flags to pass to dlopen
as a vector of Symbols
with the dlopen_flags
keyword argument. If the library should not be dlopen'ed automatically by the JLL package, set dont_dlopen=true
.
For example, if the libname
is libnettle
, this would be satisfied by the following paths:
lib/libnettle.so
orlib/libnettle.so.6
on Linux and FreeBSD;lib/libnettle.6.dylib
on macOS;lib/libnettle-6.dll
on Windows.
Libraries matching the search pattern are rejected if they are not dlopen()
'able.
If you are unsure what value to use for libname
, you can use Base.BinaryPlatforms.parse_dl_name_version
:
julia> using Base.BinaryPlatforms
julia> parse_dl_name_version("sfml-audio-2.dll", "windows")[1]
"sfml-audio"
If the library would have different basenames on different operating systems (e.g., libz.so
on Linux and FreeBSD, libz.dylib
on macOS, and zlib.dll
on Windows), libname
can be also a vector of String
s with the different alternatives:
LibraryProduct(["libz", "zlib"], :libz)
BinaryBuilderBase.Product
— TypeA Product
is an expected result after building or installation of a package.
Examples of Product
s include LibraryProduct
, FrameworkProduct
, ExecutableProduct
and FileProduct
. All Product
types must define the following minimum set of functionality:
locate(::Product)
: given aProduct
, locate it within the wrappedPrefix
returning its location as a stringsatisfied(::Product)
: given aProduct
, determine whether it has been successfully satisfied (e.g. it is locateable and it passes all callbacks)variable_name(::Product)
: return the variable name assigned to aProduct
repr(::Product)
: Return a representation of thisProduct
, useful for auto-generating source code that constructsProducts
, if that's your thing.
BinaryBuilderBase.RuntimeDependency
— TypeRuntimeDependency(dep::Union{PackageSpec,String}; compat::String, platforms::Vector{<:AbstractPlatform}, top_level::Bool=false)
Define a binary dependency that is only listed as dependency of the generated JLL package, but its artifact is not installed in the prefix during the build. The dep
argument can be either a string with the name of the JLL package or a Pkg.PackageSpec
.
The optional keyword argument compat
can be used to specify a string for use in the Project.toml
of the generated Julia package.
The optional keyword argument platforms
is a vector of AbstractPlatform
s which indicates for which platforms the dependency should be used. By default platforms=[AnyPlatform()]
, to mean that the dependency is compatible with all platforms.
The optional keyword argument top_level
specifies whether the dependency should be use only at the top-level of the generated JLL package, instead of inside each platform-specific wrapper. Using top_level=true
is useful for packages needed for platform augmentation (e.g. MPIPreferences.jl
).
BinaryBuilderBase.UserNSRunner
— TypeUserNSRunner
A UserNSRunner
represents an "execution context", an object that bundles all necessary information to run commands within the container that contains our crossbuild environment. Use run()
to actually run commands within the UserNSRunner
, and runshell()
as a quick way to get an interactive shell within the crossbuild environment.
Functions
BinaryBuilderBase.abi_agnostic
— Methodabi_agnostic(p::AbstractPlatform)
Strip out any tags that are not the basic annotations like libc
and call_abi
.
BinaryBuilderBase.accept_apple_sdk
— Methodaccept_apple_sdk(ins::IO, outs::IO) -> Bool
Ask the user whether they accept the terms of the macOS SDK, and return a boolean with their choice. Write messages to outs
, read input from ins
.
BinaryBuilderBase.artifact_name
— Methodartifact_name(cs::CompilerShard)
Return the bound artifact name for a particular shard.
BinaryBuilderBase.bindir
— Methodbindir(prefix::Prefix)
Returns the binary directory for the given prefix
.
BinaryBuilderBase.choose_shards
— Methodchoose_shards(p::AbstractPlatform; rootfs_build, ps_build, GCC_builds,
LLVM_builds, archive_type)
This method chooses, given a Platform
, which shards to download, extract and mount, returning a list of CompilerShard
objects. At the moment, this always consists of four shards, but that may not always be the case.
BinaryBuilderBase.chown_cleanup
— Methodchown_cleanup(dr::DockerRunner)
On Linux, the user id inside of the docker container doesn't correspond to ours on the outside, so permissions get all kinds of screwed up. To fix this, we have to chown -R $(id -u):$(id -g) $prefix
, which really sucks, but is still better than nothing. This is why we prefer the UserNSRunner on Linux.
BinaryBuilderBase.collect_jll_uuids
— Methodcollect_jll_uuids(manifest::Pkg.Types.Manifest, dependencies::Set{Base.UUID})
Return a Set
of all JLL packages in the manifest
with dependencies
being the list of direct dependencies of the environment.
BinaryBuilderBase.compress_dir
— Methodcompress_dir(dir::AbstractString;
compressor_stream = GzipCompressorStream,
level::Int = 9,
extension::AbstractString = ".gz",
verbose::Bool = false)
Compress all files in dir
using the specified compressor_stream
with compression level equal to level
, appending extension
to the filenames. Remove the original uncompressed files at the end.
BinaryBuilderBase.download_all_artifacts
— Methoddownload_all_artifacts(; verbose::Bool=false)
Helper function to download all shards/helper binaries so that no matter what happens, you don't need an internet connection to build your precious, precious binaries.
BinaryBuilderBase.download_source
— Functiondownload_source(source::AbstractSource; verbose::Bool = false)
Download the given source
. All downloads are cached within the BinaryBuilder downloads
storage directory.
BinaryBuilderBase.enable_apple_file
— Methodenable_apple_file()
Return the path to file that, if exists, indicates that the user accepts to download macOS SDK. The file is automatically created when the package is loaded if the environment variable BINARYBUILDER_AUTOMATIC_APPLE
is set to "true"
.
BinaryBuilderBase.expand_cxxstring_abis
— Methodexpand_cxxstring_abis(p::AbstractPlatform; skip=Sys.isbsd)
Given a Platform
, returns an array of Platforms
with a spread of identical entries with the exception of the cxxstring_abi
tag within the Platform
object. This is used to take, for example, a list of supported platforms and expand them to include multiple GCC versions for the purposes of ABI matching.
If the given Platform
already specifies a cxxstring_abi
(as opposed to nothing
) only that Platform
is returned. If skip
is a function for which skip(platform)
evaluates to true
, the given platform is not expanded. By default FreeBSD and macOS platforms are skipped, due to their lack of a dependence on libstdc++
and not needing this compatibility shim.
BinaryBuilderBase.expand_gfortran_versions
— Methodexpand_gfortran_versions(p::AbstractPlatform)
Given a Platform
, returns an array of Platforms
with a spread of identical entries with the exception of the libgfortran_version
tag within the Platform
. This is used to take, for example, a list of supported platforms and expand them to include multiple GCC versions for the purposes of ABI matching. If the given Platform
already specifies a libgfortran_version
(as opposed to nothing
) only that Platform
is returned.
BinaryBuilderBase.expand_microarchitectures
— Functionexpand_microarchitectures(p::AbstractPlatform, [microarchitectures::Vector{String}])
Given a Platform
, returns a vector of Platforms
with differing march
attributes as specified by the ARCHITECTURE_FLAGS
mapping. If the given Platform
alread has a march
tag specified, only that platform is returned. If the microarchitectures
argument is given, limit the expansion to the given microarchitectures.
julia> using BinaryBuilderBase
julia> expand_microarchitectures(Platform("x86_64", "freebsd"))
4-element Vector{Platform}:
FreeBSD x86_64 {march=x86_64}
FreeBSD x86_64 {march=avx}
FreeBSD x86_64 {march=avx2}
FreeBSD x86_64 {march=avx512}
julia> expand_microarchitectures(Platform("armv7l", "linux"))
2-element Vector{Platform}:
Linux armv7l {call_abi=eabihf, libc=glibc, march=armv7l}
Linux armv7l {call_abi=eabihf, libc=glibc, march=neonvfpv4}
julia> expand_microarchitectures(Platform("aarch64", "linux"), ["armv8_0", "a64fx"])
2-element Vector{Platform}:
Linux aarch64 {libc=glibc, march=armv8_0}
Linux aarch64 {libc=glibc, march=a64fx}
julia> expand_microarchitectures(Platform("i686", "windows"))
2-element Vector{Platform}:
Windows i686 {march=pentium4}
Windows i686 {march=prescott}
BinaryBuilderBase.expand_microarchitectures
— Functionexpand_microarchitectures(ps::Vector{<:Platform}, [microarchitectures::Vector{String}];
filter=Returns(true))
Expand all platforms in the vector ps
with the supported microarchitectures.
If the microarchitectures
argument is given, limit the expansion to the given platforms. This is useful if you do not want to expand to all available microarchitectures.
The expansion is applied only to the platforms matching the filter
predicate, by default all platforms. This is useful if you want to limit the expansion to some platforms, without having to explicitly list its microarchitectures in the second argument.
julia> using BinaryBuilderBase
julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glibc", supported_platforms()))
14-element Vector{Platform}:
Linux i686 {libc=glibc, march=pentium4}
Linux i686 {libc=glibc, march=prescott}
Linux x86_64 {libc=glibc, march=x86_64}
Linux x86_64 {libc=glibc, march=avx}
Linux x86_64 {libc=glibc, march=avx2}
Linux x86_64 {libc=glibc, march=avx512}
Linux aarch64 {libc=glibc, march=armv8_0}
Linux aarch64 {libc=glibc, march=armv8_1}
Linux aarch64 {libc=glibc, march=armv8_2_crypto}
Linux aarch64 {libc=glibc, march=a64fx}
Linux armv6l {call_abi=eabihf, libc=glibc, march=arm1176jzfs}
Linux armv7l {call_abi=eabihf, libc=glibc, march=armv7l}
Linux armv7l {call_abi=eabihf, libc=glibc, march=neonvfpv4}
Linux powerpc64le {libc=glibc, march=power8}
julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glibc", supported_platforms()), ["x86_64", "avx2"])
7-element Vector{Platform}:
Linux i686 {libc=glibc}
Linux x86_64 {libc=glibc, march=x86_64}
Linux x86_64 {libc=glibc, march=avx2}
Linux aarch64 {libc=glibc}
Linux armv6l {call_abi=eabihf, libc=glibc}
Linux armv7l {call_abi=eabihf, libc=glibc}
Linux powerpc64le {libc=glibc}
julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glibc", supported_platforms()); filter=p->arch(p)=="x86_64")
9-element Vector{Platform}:
Linux i686 {libc=glibc}
Linux x86_64 {libc=glibc, march=x86_64}
Linux x86_64 {libc=glibc, march=avx}
Linux x86_64 {libc=glibc, march=avx2}
Linux x86_64 {libc=glibc, march=avx512}
Linux aarch64 {libc=glibc}
Linux armv6l {call_abi=eabihf, libc=glibc}
Linux armv7l {call_abi=eabihf, libc=glibc}
Linux powerpc64le {libc=glibc}
BinaryBuilderBase.filter_platforms
— Methodfilter_platforms(deps::AbstractVector{<:AbstractDependency}, p::AbstractPlatform)
Filter the dependencies deps
which are compatible with platform p
.
BinaryBuilderBase.gcc_version
— Functiongcc_version(p::AbstractPlatform, GCC_builds::Vector{GCCBuild},
compilers::Vector{Symbol}=[:c];
llvm_version::Union{Nothing,VersionNumber}=nothing)
Returns the closest matching GCC version number for the given particular platform, from the given set of options. The compiler ABI and the microarchitecture of the platform will be taken into account. If no match is found, returns an empty list. compilers
is the list of compilers used in the build, to choose the right version of GCC to couple with them if necessary. If the keyword argument llvm_version
is passed, it is used to filter the version of GCC for FreeBSD platforms.
This method assumes that the compiler ABI of the platform represents a platform that binaries will be run on, and thus versions are always rounded down; e.g. if the platform supports a libstdc++
version that corresponds to GCC 5.1.0
, but the only GCC versions available to be picked from are 4.8.5
and 5.2.0
, it will return 4.8.5
, as binaries compiled with that version will run on this platform, whereas binaries compiled with 5.2.0
may not.
BinaryBuilderBase.generate_compiler_wrappers!
— Methodgenerate_compiler_wrappers!(platform::AbstractPlatform; bin_path::AbstractString,
host_platform::AbstractPlatform = Platform("x86_64", "linux"; libc = "musl", cxxstring_abi = "cxx11"),
compilers::Vector{Symbol} = [:c],
allow_unsafe_flags::Bool = false,
lock_microarchitecture::Bool = true,
gcc_version::Union{Nothing,VersionNumber}=nothing,
clang_version::Union{Nothing,VersionNumber}=nothing,
clang_use_lld::Bool = false,
)
We generate a set of compiler wrapper scripts within our build environment to force all build systems to honor the necessary sets of compiler flags to build for our systems. Note that while platform_envs()
sets many environment variables, those values are intended to be optional/overridable. These values, while still overridable by directly invoking a compiler binary directly (e.g. /opt/{target}/bin/{target}-gcc), are much more difficult to override, as the flags embedded in these wrappers are absolutely necessary, and even simple programs will not compile without them.
BinaryBuilderBase.generate_per_uid_squashfs
— Functiongenerate_per_uid_squashfs(cs, new_uid = getuid())
In order for the sandbox to work well, we need to have the uids of the squashfs images match the uid of the current unprivileged user. Unfortunately there is no mount-time option to do this for us. Fortunately, squashfs is simple enough that if the ID table is uncompressed, we can just manually patch the uids to be what we need. This function performs this operation, by rewriting all UIDs and GIDs to the given new_uid
(which defaults to the current user's UID).
BinaryBuilderBase.get_addable_spec
— Methodget_addable_spec(name::AbstractString, version::VersionNumber)
Given a JLL name and registered version, return a PackageSpec
that, when passed as a Dependency
, ensures that exactly that version will be installed. Example usage:
dependencies = [
BuildDependency(get_addable_spec("LLVM_jll", v"9.0.1+0")),
]
BinaryBuilderBase.get_commit_sha
— Methodget_commit_sha(url::String, tree_hash::Base.SHA1; verbose::Bool=false)
Find the latest git commit corresponding to the given git tree SHA1 for the remote repository with the given url
. The repository is cached locally for quicker future access. If verbose
is true
, print to screen some debugging information.
The return value is the commit SHA as a String
, if the corresponding revision is found, nothing
otherwise.
BinaryBuilderBase.get_concrete_platform
— Methodget_concrete_platform(platform::AbstractPlatform;
preferred_gcc_version = nothing,
preferred_llvm_version = nothing,
compilers = nothing)
Return the concrete platform for the given platform
based on the GCC compiler ABI. The set of shards is chosen by the keyword arguments (see choose_shards
).
BinaryBuilderBase.get_concrete_platform
— Methodget_concrete_platform(platform::Platform, shards::Vector{CompilerShard})
Return the concrete platform for the given platform
based on the GCC compiler ABI in the shards
.
BinaryBuilderBase.get_tree_hash
— Methodget_tree_hash(tree::LibGit2.GitTree)
Given a GitTree
, get the GitHash
that identifies it.
BinaryBuilderBase.getgid
— Methodgetgid()
Wrapper around libc's getgid()
function
BinaryBuilderBase.getuid
— Methodgetuid()
Wrapper around libc's getuid()
function
BinaryBuilderBase.import_docker_image
— Methodimport_docker_image(rootfs::CompilerShard; verbose::Bool = false)
Checks to see if the given rootfs has been imported into docker yet; if it hasn't, then do so so that we can run things like:
docker run -ti binarybuilder_rootfs:v2018.08.27 /bin/bash
Which, after all, is the foundation upon which this whole doodad is built.
BinaryBuilderBase.includedir
— Methodincludedir(prefix::Prefix)
Returns the include directory for the given prefix
BinaryBuilderBase.installed_shards
— Methodinstalled_shards()
Return a vector of compiler shards currently downloaded on the local system
BinaryBuilderBase.is_build_dependency
— Functionis_build_dependency(dep::AbstractDependency) -> Bool
Return whether dep
is a build-time dependency or not.
BinaryBuilderBase.is_ecryptfs
— Methodis_ecryptfs(path::AbstractString; verbose::Bool=false)
Checks to see if the given path
(or any parent directory) is placed upon an ecryptfs
mount. This is known not to work on current kernels, see this bug for more details: https://bugzilla.kernel.org/show_bug.cgi?id=197603
This method returns whether it is encrypted or not, and what mountpoint it used to make that decision.
BinaryBuilderBase.is_host_dependency
— Functionis_host_dependency(dep::AbstractDependency) -> Bool
Return whether dep
is a dependency of the host platform or not.
BinaryBuilderBase.is_mounted
— Methodis_mounted(cs::CompilerShard, build_prefix::String)
Return true if the given shard is mounted. Uses run()
so will error out if something goes awry.
BinaryBuilderBase.is_runtime_dependency
— Functionis_runtime_dependency(dep::AbstractDependency) -> Bool
Return whether dep
is a runtime dependency or not.
BinaryBuilderBase.is_target_dependency
— Methodis_target_dependency(dep::AbstractDependency) -> Bool
Return whether dep
is a dependency of the target platform or not.
BinaryBuilderBase.is_top_level_dependency
— Methodis_top_level_dependency(dep::AbstractDependency) -> Bool
Return wheter dep
is a top-level dependency or not.
BinaryBuilderBase.libabi_agnostic
— Methodabi_agnostic(p::AbstractPlatform)
Like abi_agnostic
, but keep the sanitizer ABI tags.
BinaryBuilderBase.libdirs
— Functionlibdirs(prefix::Prefix, platform = HostPlatform())
Returns the library directories for the given prefix
(note that this differs between unix systems and windows systems, and between 32- and 64-bit systems).
BinaryBuilderBase.locate
— Methodlocate(ep::ExecutableProduct, prefix::Prefix;
platform::AbstractPlatform = HostPlatform(),
verbose::Bool = false,
isolate::Bool = false)
If the given executable file exists and is executable, return its path.
On all platforms, an ExecutableProduct
checks for existence of the file. On non-Windows platforms, it will check for the executable bit being set. On Windows platforms, it will check that the file ends with ".exe", (adding it on automatically, if it is not already present).
BinaryBuilderBase.locate
— Methodlocate(fp::FileProduct, prefix::Prefix;
platform::AbstractPlatform = HostPlatform(),
verbose::Bool = false,
isolate::Bool = false)
If the given file exists, return its path. The platform
and isolate
arguments are is ignored here, but included for uniformity. For ease of use, we support a limited number of custom variable expansions such as ${target}
, and ${nbits}
, so that the detection of files within target-specific folders named things like /lib32/i686-linux-musl
is simpler.
BinaryBuilderBase.locate
— Methodlocate(lp::LibraryProduct, prefix::Prefix;
verbose::Bool = false,
platform::AbstractPlatform = HostPlatform())
If the given library exists (under any reasonable name) and is dlopen()
able, (assuming it was built for the current platform) return its location. Note that the dlopen()
test is only run if the current platform matches the given platform
keyword argument, as cross-compiled libraries cannot be dlopen()
ed on foreign platforms.
BinaryBuilderBase.logdir
— Methodlogdir(prefix::Prefix; subdir::AbstractString="")
Returns the logs directory for the given prefix
. If subdir
is a non-empty string, that directory it is appended to the logdir of the given prefix
.
BinaryBuilderBase.macos_sdk_already_installed
— Methodmacos_sdk_already_installed()
Returns true
if any piece of the MacOS SDK is already installed.
BinaryBuilderBase.manage_shards
— Methodmanage_shards(; sort_by=:name, rev=false)
Open a prompt allowing a user to selectively remove downloaded compiler shards. By default, the shards are sorted by name, alternatively you can sort them by file size on disk by specifying sort_by=:size
. With rev=true
you can reverse the sort order.
BinaryBuilderBase.map_target
— Methodmap_target(cs::CompilerShard)
Return the location this compiler shard should be mounted at. We basically analyze the name and platform of this shard and return a path based on that.
BinaryBuilderBase.mount
— Methodmount(cs::CompilerShard, build_prefix::String)
Mount a compiler shard, if possible. Uses run()
so will error out if something goes awry. Note that this function only does something when using a .squashfs
shard, with a UserNS or Docker runner, on Linux. All other combinations of shard archive type, runner and platform result in a no-op from this function.
BinaryBuilderBase.package
— Methodpackage(prefix::Prefix, output_base::AbstractString,
version::VersionNumber;
platform::AbstractPlatform = HostPlatform(),
verbose::Bool = false, force::Bool = false,
filter = Returns(true))
Build a tarball of the prefix
, storing the tarball at output_base
, appending the version number version
, a platform-dependent suffix and a file extension. If platform
is not given, defaults to current platform. Returns the full path to, the SHA256 hash and the git tree SHA1 of the generated tarball.
The are additional keyword arguments:
verbose
controls whether to print information to screen,force
makes the function overwrite an existing tarball with the same namefilter
is a 2-argument function which returnstrue
if the given file or directory should be packaged, andfalse
otherwise. The arguments are(prefix, path)
, whereprefix
is the directory where the prefix is stored, andpath
is the path, within the prefix, of the file or directory. This keyword allows you to filter out from the tarball certain files or directories.
BinaryBuilderBase.platform_envs
— Methodplatform_envs(platform::AbstractPlatform, src_name::AbstractString;
host_platform = default_host_platform,
bootstrap::Bool=!isempty(bootstrap_list),
compilers::Vector{Symbol}=[:c],
rust_version::Union{Nothing,VersionNumber}=nothing,
verbose::Bool = false,
)
Given a platform
and a src_name
, generate a Dict
mapping representing all the environment variables to be set within the build environment to force compiles toward the defined target architecture. Examples of things set are PATH
, CC
, RANLIB
, as well as nonstandard things like target
.
Accepted keyword arguments are:
host_platform
: the platform of the host system,bootstraop
: iftrue
, only basic environment variables will be generated,compilers
: list of compilers, some environment variables will be generated only if the relevant compilers are used (e.g., for Go and Rust),rust_version
: version of the Rust toolchain, needed to set the environment variableRUSTUP_TOOLCHAIN
,verbose
: holds the value of theV
andVERBOSE
environment variables.
BinaryBuilderBase.platform_exeext
— Methodplatform_exeext(p::AbstractPlatform)
Get the executable extension for the given Platform. Includes the leading .
.
BinaryBuilderBase.preferred_cxxstring_abi
— Methodpreferred_cxxstring_abi(platform::AbstractPlatform, shard::CompilerShard;
gcc_builds::Vector{GCCBuild} = available_gcc_builds)
Return the C++ string ABI preferred by the given platform or GCCBootstrap shard.
BinaryBuilderBase.preferred_libgfortran_version
— Methodpreferred_libgfortran_version(platform::AbstractPlatform, shard::CompilerShard;
gcc_builds::Vector{GCCBuild} = available_gcc_builds)
Return the libgfortran version preferred by the given platform or GCCBootstrap shard.
BinaryBuilderBase.runshell
— Functionrunshell(platform::AbstractPlatform = HostPlatform())
Launch an interactive shell session within the user namespace, with environment setup to target the given platform
.
BinaryBuilderBase.satisfied
— Methodsatisfied(p::Product;
platform::AbstractPlatform = HostPlatform(),
verbose::Bool = false,
isolate::Bool = false)
Given a Product
, return true
if that Product
is satisfied, e.g. whether a file exists that matches all criteria setup for that Product
. If isolate
is set to true
, will isolate all checks from the main Julia process in the event that dlopen()
'ing a library might cause issues.
BinaryBuilderBase.setup_workspace
— Functionsetup_workspace(build_path::String, sources::Vector{SetupSource};
verbose::Bool = false)
Sets up a workspace within build_path
, creating the directory structure needed by further steps, unpacking the source within build_path
, and defining the environment variables that will be defined within the sandbox environment.
This method returns the Prefix
to install things into, and the runner that can be used to launch commands within this workspace.
BinaryBuilderBase.shard_mappings
— Methodshard_mappings(shards::Vector{CompilerShard})
Return the default mappings for a set of compiler shards
BinaryBuilderBase.shard_path
— Methodshard_path(cs::CompilerShard)
Return the path to this shard on-disk; for unpacked shards, this is a directory. For squashfs shards, this is a file. This will not cause a shard to be downloaded.
BinaryBuilderBase.supported_platforms
— Methodsupported_platforms(;exclude::Union{Vector{<:Platform},Function}=Returns(false),
experimental::Bool=false)
Return the list of supported platforms as an array of Platform
s. These are the platforms we officially support building for, if you see a mapping in get_shard_hash()
that isn't represented here, it's probably because that platform is still considered "in beta". If experimental=true
, include platforms considered experimental.
Platforms can be excluded from the list by specifying an array of platforms to exclude
i.e. supported_platforms(exclude=[Platform("i686", "windows"), Platform("x86_64", "windows")])
or a function that returns true for exclusions i.e.
supported_platforms(exclude=Sys.islinux)
BinaryBuilderBase.temp_prefix
— Methodtemp_prefix(func::Function)
Create a temporary prefix, passing the prefix into the user-defined function so that build/packaging operations can occur within the temporary prefix, which is then cleaned up after all operations are finished. If the path provided exists already, it will be deleted.
Usage example:
out_path = abspath("./libfoo")
temp_prefix() do p
# <insert build steps here>
# tarball up the built package
tarball_path, tarball_hash = package(p, out_path)
end
BinaryBuilderBase.uname
— Methoduname()
On Linux systems, return the strings returned by the uname()
function in libc
BinaryBuilderBase.unmount
— Methodunmount(cs::CompilerShard, build_prefix::String)
Unmount a compiler shard from a given build prefix, if possible. Uses run()
so will error out if something goes awry. Note that this function only does something when using a squashfs shard on Linux. All other combinations of shard archive type and platform result in a no-op.
BinaryBuilderBase.variable_name
— Methodvariable_name(p::Product)
Return the variable name associated with this Product
as a string
BinaryBuilderBase.versioninfo
— Methodversioninfo()
Helper function to print out some debugging information
Constants
BinaryBuilderBase.default_host_platform
— Constantdefault_host_platform
The default host platform in the build environment.