| Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago | 1 | #!/bin/sh |
| 2 | # rustc out of the dist tarball buck fetched, with the sysroot stitched on. |
| 3 | # |
| 4 | # The same job scripts/rustc does, said in a way buck can ship: the wrapper and |
| 5 | # the tarball are both inputs to every action that runs it, so the compiler's |
| 6 | # identity is part of the action's cache digest and a remote worker can be |
| 7 | # handed the whole thing. |
| 8 | # |
| Cross-compile for Android, with an NDK nobody has to install 14a30c0 nandi 19d ago | 9 | # $1 is the directory the tarball unpacked into and $2 the sysroot to use; |
| 10 | # buck passes both because neither is knowable from inside the script. The |
| 11 | # sysroot is a separate argument rather than something built from a triple |
| 12 | # here: cross-compiling needs two libstds stitched into one directory, and |
| 13 | # that stitching is an artifact of its own (toolchains//dist:android-sysroot). |
| Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago | 14 | set -e |
| 15 | dist=$1 |
| Cross-compile for Android, with an NDK nobody has to install 14a30c0 nandi 19d ago | 16 | sysroot=$2 |
| Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago | 17 | shift 2 |
| 18 | |
| 19 | # The dist tarball keeps its components in sibling directories, so the |
| 20 | # compiler's own default sysroot (rustc/) holds no libstd — it lives under |
| Cross-compile for Android, with an NDK nobody has to install 14a30c0 nandi 19d ago | 21 | # rust-std-<triple>/, which is what buck names above. The codegen libraries are |
| 22 | # found by rpath relative to the binary, so only the sysroot has to be named. |
| Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago | 23 | # |
| 24 | # Callers that set their own win: buck's rustc_cfg action passes an empty |
| 25 | # --sysroot, and rustc refuses the option twice. |
| 26 | for arg do |
| 27 | case $arg in |
| 28 | --sysroot|--sysroot=*) exec "$dist/rustc/bin/rustc" "$@" ;; |
| 29 | esac |
| 30 | done |
| 31 | |
| Cross-compile for Android, with an NDK nobody has to install 14a30c0 nandi 19d ago | 32 | exec "$dist/rustc/bin/rustc" --sysroot "$sysroot" "$@" |