]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/disabled/dist-x86_64-haiku/build-toolchain.sh
Rollup merge of #44562 - eddyb:ugh-rustdoc, r=nikomatsakis
[rust.git] / src / ci / docker / disabled / dist-x86_64-haiku / build-toolchain.sh
1 #!/bin/bash
2 # Copyright 2017 The Rust Project Developers. See the COPYRIGHT
3 # file at the top-level directory of this distribution and at
4 # http://rust-lang.org/COPYRIGHT.
5 #
6 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9 # option. This file may not be copied, modified, or distributed
10 # except according to those terms.
11
12 set -ex
13
14 ARCH=$1
15
16 TOP=$(pwd)
17
18 BUILDTOOLS=$TOP/buildtools
19 HAIKU=$TOP/haiku
20 OUTPUT=/tools
21 SYSROOT=$OUTPUT/cross-tools-$ARCH/sysroot
22 PACKAGE_ROOT=/system
23
24 hide_output() {
25   set +x
26   on_err="
27 echo ERROR: An error was encountered with the build.
28 cat /tmp/build.log
29 exit 1
30 "
31   trap "$on_err" ERR
32   bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
33   PING_LOOP_PID=$!
34   $@ &> /tmp/build.log
35   trap - ERR
36   kill $PING_LOOP_PID
37   set -x
38 }
39
40 # First up, build a cross-compiler
41 git clone --depth=1 https://git.haiku-os.org/haiku
42 git clone --depth=1 https://git.haiku-os.org/buildtools
43 cd $BUILDTOOLS/jam
44 hide_output make
45 hide_output ./jam0 install
46 mkdir -p $OUTPUT
47 cd $OUTPUT
48 hide_output $HAIKU/configure --build-cross-tools $ARCH $TOP/buildtools
49
50 # Set up sysroot to redirect to /system
51 mkdir -p $SYSROOT/boot
52 mkdir -p $PACKAGE_ROOT
53 ln -s $PACKAGE_ROOT $SYSROOT/boot/system
54
55 # Build needed packages and tools for the cross-compiler
56 hide_output jam -q haiku.hpkg haiku_devel.hpkg '<build>package'
57
58 # Set up our sysroot
59 cp $OUTPUT/objects/linux/lib/*.so /lib/x86_64-linux-gnu
60 cp $OUTPUT/objects/linux/x86_64/release/tools/package/package /bin/
61 find $SYSROOT/../bin/ -type f -exec ln -s {} /bin/ \;
62
63 # Extract packages
64 package extract -C $PACKAGE_ROOT $OUTPUT/objects/haiku/$ARCH/packaging/packages/haiku.hpkg
65 package extract -C $PACKAGE_ROOT $OUTPUT/objects/haiku/$ARCH/packaging/packages/haiku_devel.hpkg
66 find $OUTPUT/download/ -name '*.hpkg' -exec package extract -C $PACKAGE_ROOT {} \;
67
68 # Fix libgcc_s so we can link to it
69 cd $PACKAGE_ROOT/develop/lib
70 ln -s ../../lib/libgcc_s.so libgcc_s.so
71
72 # Clean up
73 rm -rf $BUILDTOOLS $HAIKU $OUTPUT/Jamfile $OUTPUT/attributes $OUTPUT/build \
74   $OUTPUT/build_packages $OUTPUT/download $OUTPUT/objects