]> git.proxmox.com Git - rustc.git/blob - src/ci/docker/cross2/build-fuchsia-toolchain.sh
New upstream version 1.23.0+dfsg1
[rustc.git] / src / ci / docker / cross2 / build-fuchsia-toolchain.sh
1 #!/usr/bin/env 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 # ignore-tidy-linelength
13
14 set -ex
15 source shared.sh
16
17 ZIRCON=e9a26dbc70d631029f8ee9763103910b7e3a2fe1
18
19 mkdir -p zircon
20 pushd zircon > /dev/null
21
22 # Download sources
23 git init
24 git remote add origin https://fuchsia.googlesource.com/zircon
25 git fetch --depth=1 origin $ZIRCON
26 git reset --hard FETCH_HEAD
27
28 # Download toolchain
29 ./scripts/download-toolchain
30 chmod -R a+rx prebuilt/downloads/clang+llvm-x86_64-linux
31 cp -a prebuilt/downloads/clang+llvm-x86_64-linux/. /usr/local
32
33 build() {
34 local arch="$1"
35
36 case "${arch}" in
37 x86_64) tgt="zircon-pc-x86-64" ;;
38 aarch64) tgt="zircon-qemu-arm64" ;;
39 esac
40
41 hide_output make -j$(getconf _NPROCESSORS_ONLN) $tgt
42 dst=/usr/local/${arch}-unknown-fuchsia
43 mkdir -p $dst
44 cp -a build-${tgt}/sysroot/include $dst/
45 cp -a build-${tgt}/sysroot/lib $dst/
46 }
47
48 # Build sysroot
49 for arch in x86_64 aarch64; do
50 build ${arch}
51 done
52
53 popd > /dev/null
54 rm -rf zircon
55
56 for arch in x86_64 aarch64; do
57 for tool in clang clang++; do
58 cat >/usr/local/bin/${arch}-unknown-fuchsia-${tool} <<EOF
59 #!/bin/sh
60 ${tool} --target=${arch}-unknown-fuchsia --sysroot=/usr/local/${arch}-unknown-fuchsia "\$@"
61 EOF
62 chmod +x /usr/local/bin/${arch}-unknown-fuchsia-${tool}
63 done
64 ln -s /usr/local/bin/llvm-ar /usr/local/bin/${arch}-unknown-fuchsia-ar
65 done