summaryrefslogtreecommitdiffstats
path: root/src/ci/docker/host-x86_64/dist-various-2/build-fuchsia-toolchain.sh
blob: 73acdf5be6356733909ae059d71837f5c64be18d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash

set -ex
source shared.sh

ZIRCON=e9a26dbc70d631029f8ee9763103910b7e3a2fe1

mkdir -p zircon
pushd zircon > /dev/null

# Download sources
git init
git remote add origin https://github.com/rust-lang-nursery/mirror-google-fuchsia-zircon
git fetch --depth=1 origin $ZIRCON
git reset --hard FETCH_HEAD

# Download toolchain
./scripts/download-toolchain
chmod -R a+rx prebuilt/downloads/clang+llvm-x86_64-linux
cp -a prebuilt/downloads/clang+llvm-x86_64-linux/. /usr/local

build() {
  local arch="$1"

  case "${arch}" in
    x86_64) tgt="zircon-pc-x86-64" ;;
    aarch64) tgt="zircon-qemu-arm64" ;;
  esac

  hide_output make -j$(getconf _NPROCESSORS_ONLN) $tgt
  dst=/usr/local/${arch}-fuchsia
  mkdir -p $dst
  cp -a build-${tgt}/sysroot/include $dst/
  cp -a build-${tgt}/sysroot/lib $dst/
}

# Build sysroot
for arch in x86_64 aarch64; do
  build ${arch}
done

popd > /dev/null
rm -rf zircon

for arch in x86_64 aarch64; do
  for tool in clang clang++; do
    cat >/usr/local/bin/${arch}-fuchsia-${tool} <<EOF
#!/bin/sh
${tool} --target=${arch}-fuchsia --sysroot=/usr/local/${arch}-fuchsia "\$@"
EOF
    chmod +x /usr/local/bin/${arch}-fuchsia-${tool}
  done
  ln -s /usr/local/bin/llvm-ar /usr/local/bin/${arch}-fuchsia-ar
done