diff --git a/README.md b/README.md index a570398d..dc3fdfe7 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,4 @@ Building binary packages is a pain. `BinaryBuilder` follows a philosophy that i All packages are cross compiled. If a package does not support cross compilation, we patch the package or, in extreme cases, rebundle prebuilt executables. -The cross-compilation environment that we use is a homegrown Linux environment with many different compilers built for it, including various versions of `gcc`, `clang`, `gfortran`, `rustc` and `go`. You can read more about this in [the `RootFS.md` file](https://github.com/JuliaPackaging/Yggdrasil/blob/master/RootFS.md) within the Yggdrasil repository. +The cross-compilation environment that we use is a homegrown Linux environment with many different compilers built for it, including various versions of `gcc`, `clang`, `gfortran`, `rustc`, `go`, and `ocaml`. You can read more about this in [the `RootFS.md` file](https://github.com/JuliaPackaging/Yggdrasil/blob/master/RootFS.md) within the Yggdrasil repository. diff --git a/docs/src/build_tips.md b/docs/src/build_tips.md index 8726886b..7f058f9d 100644 --- a/docs/src/build_tips.md +++ b/docs/src/build_tips.md @@ -127,6 +127,12 @@ Example of packages using Rust: The Rust toolchain currently used does not work with the `i686-w64-mingw32` (32-bit Windows) platform. +## OCaml builds + +The OCaml toolchain provided by BinaryBuilder can be requested by adding `:ocaml` to the `compilers` keyword argument to [`build_tarballs`](@ref): `compilers=[:c, :ocaml]`, and a specific version of the toolchain can be selected by adding the `preferred_ocaml_version` keyword argument to [`build_tarballs`](@ref). + +The OCaml toolchain provided by BinaryBuilder automatically selects the appropriate target. + ## Editing files in the wizard In the wizard, the `vim` editor is available for editing files. But, it doesn't leave any record in the build script. One generally needs to provide patch files or use something like `sed`. If a file needs patching, we suggest using `git` to add the entire worktree to a new repo, make the changes you need, then use `git diff -p` to output a patch that can be included alongside your build recipe. diff --git a/docs/src/index.md b/docs/src/index.md index ac711e9d..f16cb546 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -1,6 +1,6 @@ # BinaryBuilder.jl -The purpose of the [`BinaryBuilder.jl`](https://github.com/JuliaPackaging/BinaryBuilder.jl) Julia package is to provide a system for compiling 3rd-party binary dependencies that should work anywhere the [official Julia distribution](https://julialang.org/downloads) does. In particular, using this package you will be able to compile your large pre-existing codebases of C, C++, Fortran, Rust, Go, etc... software into binaries that can be downloaded and loaded/run on a very wide range of machines. As it is difficult (and often expensive) to natively compile software packages across the growing number of platforms that this package will need to support, we focus on providing a set of Linux-hosted cross-compilers. This package will therefore set up an environment to perform cross-compilation for all of the major platforms, and will do its best to make the compilation process as painless as possible. +The purpose of the [`BinaryBuilder.jl`](https://github.com/JuliaPackaging/BinaryBuilder.jl) Julia package is to provide a system for compiling 3rd-party binary dependencies that should work anywhere the [official Julia distribution](https://julialang.org/downloads) does. In particular, using this package you will be able to compile your large pre-existing codebases of C, C++, Fortran, Rust, Go, OCaml, etc... software into binaries that can be downloaded and loaded/run on a very wide range of machines. As it is difficult (and often expensive) to natively compile software packages across the growing number of platforms that this package will need to support, we focus on providing a set of Linux-hosted cross-compilers. This package will therefore set up an environment to perform cross-compilation for all of the major platforms, and will do its best to make the compilation process as painless as possible. Note that at this time, BinaryBuilder itself runs on Linux `x86_64` and macOS `x86_64` systems only, with Windows support under active development. On macOS and Windows, you must have `docker` installed as the backing virtualization engine. Note that Docker Desktop is the recommended version; if you have Docker Machine installed it may not work correctly or may need additional configuration. diff --git a/generate_precompile.jl b/generate_precompile.jl index 02aafca6..8e6b8649 100644 --- a/generate_precompile.jl +++ b/generate_precompile.jl @@ -9,6 +9,7 @@ using SnoopCompile ExecutableProduct("hello_world_fortran", :hello_world_fortran), ExecutableProduct("hello_world_go", :hello_world_go), ExecutableProduct("hello_world_rust", :hello_world_rust), + ExecutableProduct("hello_world_ocaml", :hello_world_ocaml), ] # First, do the build, but only output the meta json, since we definitely want that to be fast @@ -55,7 +56,7 @@ using SnoopCompile Dependency[ Dependency("Zlib_jll"), ]; - compilers=[:c, :rust, :go], + compilers=[:c, :rust, :go, :ocaml], ) rm("build"; recursive=true, force=true) diff --git a/src/AutoBuild.jl b/src/AutoBuild.jl index b8f3b625..9f3ac383 100644 --- a/src/AutoBuild.jl +++ b/src/AutoBuild.jl @@ -477,6 +477,13 @@ function get_compilers_versions(; compilers = [:c]) go version """ end + if :ocaml in compilers + output *= + """ + ocamlc -v + ocamlopt -v + """ + end if :rust in compilers output *= """ @@ -819,7 +826,15 @@ function autobuild(dir::AbstractString, build_path = joinpath(dir, "build", triplet(platform)) mkpath(build_path) - shards = choose_shards(platform; extract_kwargs(kwargs, (:preferred_gcc_version,:preferred_llvm_version,:preferred_rust_version,:preferred_go_version,:bootstrap_list,:compilers))...) + shards = choose_shards(platform; extract_kwargs(kwargs, ( + :preferred_gcc_version, + :preferred_llvm_version, + :preferred_rust_version, + :preferred_go_version, + :preferred_ocaml_version, + :bootstrap_list, + :compilers, + ))...) concrete_platform = get_concrete_platform(platform, shards) prefix = setup_workspace( diff --git a/src/wizard/obtain_source.jl b/src/wizard/obtain_source.jl index c464e747..e1e524cd 100644 --- a/src/wizard/obtain_source.jl +++ b/src/wizard/obtain_source.jl @@ -334,11 +334,11 @@ function get_name_and_version(state::WizardState) end end -@enum Compilers C=1 Go Rust +@enum Compilers C=1 Go Rust OCaml function get_compilers(state::WizardState) while state.compilers === nothing - compiler_descriptions = Dict(C => "C/C++/Fortran", Go => "Go", Rust => "Rust") - compiler_symbols = Dict(Int(C) => :c, Int(Go) => :go, Int(Rust) => :rust) + compiler_descriptions = Dict(C => "C/C++/Fortran", Go => "Go", Rust => "Rust", OCaml => "OCaml") + compiler_symbols = Dict(Int(C) => :c, Int(Go) => :go, Int(Rust) => :rust, Int(OCaml) => :ocaml) terminal = TTYTerminal("xterm", state.ins, state.outs, state.outs) result = nothing while true diff --git a/test/building.jl b/test/building.jl index 4836ba6f..f24d43ae 100644 --- a/test/building.jl +++ b/test/building.jl @@ -118,6 +118,7 @@ shards_to_test = expand_cxxstring_abis(expand_gfortran_versions(shards_to_test)) platforms_match(shard, Platform("riscv64", "linux"))) # Rust is broken on 32-bit Windows and unavailable on FreeBSD AArch64 and Linux RISC-V, let's skip it push!(products, ExecutableProduct("hello_world_rust", :hello_world_rust)) + push!(products, ExecutableProduct("hello_world_ocaml", :hello_world_ocaml)) end compilers = [:c, :go] @@ -125,6 +126,7 @@ shards_to_test = expand_cxxstring_abis(expand_gfortran_versions(shards_to_test)) if !(platforms_match(shard, Platform("aarch64", "freebsd")) || platforms_match(shard, Platform("riscv64", "linux"))) push!(compilers, :rust) + push!(compilers, :ocaml) end build_output_meta = autobuild( diff --git a/test/wizard.jl b/test/wizard.jl index 395b969e..7b05f325 100644 --- a/test/wizard.jl +++ b/test/wizard.jl @@ -180,7 +180,7 @@ end # Check that the state is modified appropriately @test state.source_urls == ["http://127.0.0.1:$(port)/a/source.tar.gz"] @test getfield.(state.source_files, :hash) == [libfoo_tarball_hash] - @test Set(state.compilers) == Set([:c, :rust, :go]) + @test Set(state.compilers) == Set([:c, :rust, :go, :ocaml]) @test state.preferred_gcc_version == getversion(available_gcc_builds[1]) # The default LLVM shard is the latest one, and above we pressed three times # arrow down in the reverse order list.