|
| 1 | +### Instructions for adding a new version of the OCaml toolchain |
| 2 | +# |
| 3 | +# * update the `version` variable and `sources` |
| 4 | +# * To deploy the shard and automatically update your BinaryBuilderBase's |
| 5 | +# `Artifacts.toml`, use the `--deploy` flag to the `build_tarballs.jl` script. |
| 6 | +# You can build & deploy by running: |
| 7 | +# |
| 8 | +# julia build_tarballs.jl --debug --verbose --deploy |
| 9 | +# |
| 10 | + |
| 11 | +using BinaryBuilderBase, BinaryBuilder, Pkg.Artifacts |
| 12 | + |
| 13 | +include("../common.jl") |
| 14 | + |
| 15 | +name = "OCamlBase" |
| 16 | +version = v"5.4.0" |
| 17 | + |
| 18 | +sources = [ |
| 19 | + # This is a pre-release version of OCaml 5.4.0, because the latest |
| 20 | + # release (5.3.0) does not have cross-compilation support. |
| 21 | + GitSource("https://github.com/ocaml/ocaml.git", |
| 22 | + "411679d2e21e44f148deb1b3ff12355266fe26a0"), |
| 23 | + DirectorySource("./bundled"), |
| 24 | +] |
| 25 | + |
| 26 | +# Check if deploy flag is set |
| 27 | +deploy = "--deploy" in ARGS |
| 28 | + |
| 29 | +# These are the targets we support right now: |
| 30 | +# x86_64-w64-mingw32 |
| 31 | +# x86_64-apple-darwin |
| 32 | +# aarch64-apple-darwin |
| 33 | +# x86_64-linux-gnu |
| 34 | +# x86_64-linux-musl |
| 35 | +# aarch64-linux-gnu |
| 36 | +# aarch64-linux-musl |
| 37 | + |
| 38 | +# The first thing we're going to do is to install Rust for all targets into a single prefix |
| 39 | +script = "version=$(version)\n" * raw""" |
| 40 | +cd ${WORKSPACE}/srcdir |
| 41 | +
|
| 42 | +# Apply patches |
| 43 | +cd ocaml |
| 44 | +for f in ${WORKSPACE}/srcdir/patches/*.patch; do |
| 45 | + atomic_patch -p1 ${f} |
| 46 | +done |
| 47 | +
|
| 48 | +# Do a native build of OCaml |
| 49 | +./configure --build=${MACHTYPE} --host=${MACHTYPE} CC="$HOSTCC" CXX="$HOSTCXX" LD="$HOSTLD" STRIP="$HOSTSTRIP" AS="$HOSTAS" |
| 50 | +make -j${nproc} |
| 51 | +make install |
| 52 | +git clean -fxd |
| 53 | +
|
| 54 | +# Build the cross-compiler |
| 55 | +unset CC |
| 56 | +./configure --prefix=${prefix} --host=${MACHTYPE} --build=${MACHTYPE} --target=${target} |
| 57 | +make crossopt -j${nproc} |
| 58 | +make installcross |
| 59 | +
|
| 60 | +# Fix shebang of ocamlrun scripts to not hardcode a path of the build environment |
| 61 | +for bin in $(file ${bindir}/* | grep "a \S*/ocamlrun script" | cut -d: -f1); do |
| 62 | + abspath=$(file ${bin} | grep -oh "a \S*/ocamlrun script" | cut -d' ' -f2) |
| 63 | + sed -i "s?${abspath}?/usr/bin/env ocamlrun?" "${bin}" |
| 64 | +done |
| 65 | +""" |
| 66 | + |
| 67 | +# We assemble this giant tarball, then will split it up immediately after this: |
| 68 | +platforms = Platform[ host_platform ] |
| 69 | +products = Product[ |
| 70 | + # build with no products since all of our products are for the host, not the target |
| 71 | + |
| 72 | + # ExecutableProduct("ocamlopt.opt", :ocamlopt), |
| 73 | + # ExecutableProduct("ocamlc.opt", :ocamlc), |
| 74 | + # ExecutableProduct("ocamlrun", :ocamlrun), |
| 75 | +] |
| 76 | +dependencies = Dependency[] |
| 77 | + |
| 78 | +name = "OCamlBase" |
| 79 | +compiler_target = try |
| 80 | + parse(Platform, ARGS[end]) |
| 81 | +catch |
| 82 | + error("This is not a typical build_tarballs.jl! Must provide exactly one platform as the last argument!") |
| 83 | +end |
| 84 | +deleteat!(ARGS, length(ARGS)) |
| 85 | + |
| 86 | +# Build the tarballs |
| 87 | +ndARGS, deploy_target = find_deploy_arg(ARGS) |
| 88 | +build_info = build_tarballs(ndARGS, name, version, sources, script, Platform[compiler_target], products, dependencies; |
| 89 | + skip_audit=true, julia_compat="1.6", preferred_gcc_version=v"5") |
| 90 | + |
| 91 | +build_info = Dict(host_platform => first(values(build_info))) |
| 92 | + |
| 93 | +# Upload the artifacts (if requested) |
| 94 | +if deploy_target !== nothing |
| 95 | + upload_and_insert_shards(deploy_target, name, version, build_info; target=compiler_target) |
| 96 | +end |
0 commit comments