Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 1 | |
| 2 | require rust-cross-canadian-common.inc |
| 3 | |
| 4 | RUSTLIB_TARGET_PN = "rust-cross-canadian-rustlib-target-${TRANSLATED_TARGET_ARCH}" |
| 5 | RUSTLIB_HOST_PN = "rust-cross-canadian-rustlib-host-${TRANSLATED_TARGET_ARCH}" |
| 6 | RUSTLIB_SRC_PN = "rust-cross-canadian-src" |
| 7 | RUSTLIB_PKGS = "${RUSTLIB_SRC_PN} ${RUSTLIB_TARGET_PN} ${RUSTLIB_HOST_PN}" |
| 8 | PN = "rust-cross-canadian-${TRANSLATED_TARGET_ARCH}" |
| 9 | |
| 10 | PACKAGES = "${RUSTLIB_PKGS} ${PN}" |
| 11 | RDEPENDS:${PN} += "${RUSTLIB_PKGS}" |
| 12 | |
| 13 | # The default behaviour of x.py changed in 1.47+ so now we need to |
| 14 | # explicitly ask for the stage 2 compiler to be assembled. |
| 15 | do_compile () { |
| 16 | rust_runx build --stage 2 |
| 17 | } |
| 18 | |
| 19 | do_install () { |
| 20 | # Rust requires /usr/lib to contain the libs. |
| 21 | # Similar story is with /usr/bin ruquiring `lib` to be at the same level. |
| 22 | # The required structure is retained for simplicity. |
| 23 | SYS_LIBDIR=$(dirname ${D}${libdir}) |
| 24 | SYS_BINDIR=$(dirname ${D}${bindir}) |
| 25 | RUSTLIB_DIR=${SYS_LIBDIR}/${TARGET_SYS}/rustlib |
| 26 | |
| 27 | install -d "${SYS_BINDIR}" |
| 28 | cp build/${SNAPSHOT_BUILD_SYS}/stage2/bin/* ${SYS_BINDIR} |
| 29 | for i in ${SYS_BINDIR}/*; do |
| 30 | chrpath -r "\$ORIGIN/../lib" ${i} |
| 31 | done |
| 32 | |
| 33 | install -d "${D}${libdir}" |
| 34 | cp -pRd build/${SNAPSHOT_BUILD_SYS}/stage2/lib/${TARGET_SYS}/*.so ${SYS_LIBDIR} |
| 35 | cp -pRd build/${SNAPSHOT_BUILD_SYS}/stage2/lib/${TARGET_SYS}/rustlib ${RUSTLIB_DIR} |
| 36 | |
| 37 | for i in ${SYS_LIBDIR}/*.so; do |
| 38 | chrpath -r "\$ORIGIN/../lib" ${i} |
| 39 | done |
| 40 | for i in ${RUSTLIB_DIR}/*/lib/*.so; do |
| 41 | chrpath -d ${i} |
| 42 | done |
| 43 | |
| 44 | install -m 0644 "${WORKDIR}/targets/${TARGET_SYS}.json" "${RUSTLIB_DIR}" |
| 45 | |
| 46 | SRC_DIR=${RUSTLIB_DIR}/src/rust |
| 47 | install -d ${SRC_DIR}/src/llvm-project |
| 48 | cp -R --no-dereference build/${SNAPSHOT_BUILD_SYS}/stage2/lib/rustlib/src/rust/src/llvm-project/libunwind ${SRC_DIR}/src/llvm-project |
| 49 | cp -R --no-dereference build/${SNAPSHOT_BUILD_SYS}/stage2/lib/rustlib/src/rust/library ${SRC_DIR} |
| 50 | cp --no-dereference build/${SNAPSHOT_BUILD_SYS}/stage2/lib/rustlib/src/rust/Cargo.lock ${SRC_DIR} |
| 51 | # Remove executable bit from any files so then SDK doesn't try to relocate. |
| 52 | chmod -R -x+X ${SRC_DIR} |
| 53 | |
| 54 | ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d |
| 55 | mkdir "${ENV_SETUP_DIR}" |
| 56 | ENV_SETUP_SH="${ENV_SETUP_DIR}/rust.sh" |
| 57 | |
| 58 | cat <<- EOF > "${ENV_SETUP_SH}" |
| 59 | export RUSTFLAGS="--sysroot=\$OECORE_NATIVE_SYSROOT/usr -C link-arg=--sysroot=\$OECORE_TARGET_SYSROOT -L\$OECORE_NATIVE_SYSROOT/usr/lib/${TARGET_SYS}/rustlib/${TARGET_SYS}/lib" |
| 60 | export RUST_TARGET_PATH="\$OECORE_NATIVE_SYSROOT/usr/lib/${TARGET_SYS}/rustlib" |
| 61 | EOF |
| 62 | |
| 63 | chown -R root.root ${D} |
| 64 | } |
| 65 | |
| 66 | PKG_SYS_LIBDIR = "${SDKPATHNATIVE}/usr/lib" |
| 67 | PKG_SYS_BINDIR = "${SDKPATHNATIVE}/usr/bin" |
| 68 | PKG_RUSTLIB_DIR = "${PKG_SYS_LIBDIR}/${TARGET_SYS}/rustlib" |
| 69 | FILES:${PN} = "${PKG_SYS_LIBDIR}/*.so ${PKG_SYS_BINDIR} ${base_prefix}/environment-setup.d" |
| 70 | FILES:${RUSTLIB_TARGET_PN} = "${PKG_RUSTLIB_DIR}/${TARGET_SYS} ${PKG_RUSTLIB_DIR}/${TARGET_SYS}.json" |
| 71 | FILES:${RUSTLIB_HOST_PN} = "${PKG_RUSTLIB_DIR}/${BUILD_ARCH}-unknown-linux-gnu" |
| 72 | FILES:${RUSTLIB_SRC_PN} = "${PKG_RUSTLIB_DIR}/src" |
| 73 | |
| 74 | SUMMARY:${RUSTLIB_TARGET_PN} = "Rust cross canadian libaries for ${TARGET_SYS}" |
| 75 | SUMMARY:${RUSTLIB_HOST_PN} = "Rust cross canadian libaries for ${HOST_SYS}" |
| 76 | SUMMARY:${RUSTLIB_SRC_PN} = "Rust standard library sources for cross canadian toolchain" |
| 77 | SUMMARY:${PN} = "Rust crost canadian compiler" |
| 78 | |