blob: 8bbbd61bdc399499aa3dab577056620104cc71de [file] [log] [blame]
Andrew Geisslerd159c7f2021-09-02 21:05:58 -05001
2require rust-cross-canadian-common.inc
3
4RUSTLIB_TARGET_PN = "rust-cross-canadian-rustlib-target-${TRANSLATED_TARGET_ARCH}"
5RUSTLIB_HOST_PN = "rust-cross-canadian-rustlib-host-${TRANSLATED_TARGET_ARCH}"
6RUSTLIB_SRC_PN = "rust-cross-canadian-src"
7RUSTLIB_PKGS = "${RUSTLIB_SRC_PN} ${RUSTLIB_TARGET_PN} ${RUSTLIB_HOST_PN}"
8PN = "rust-cross-canadian-${TRANSLATED_TARGET_ARCH}"
9
10PACKAGES = "${RUSTLIB_PKGS} ${PN}"
11RDEPENDS:${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.
15do_compile () {
16 rust_runx build --stage 2
17}
18
19do_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
66PKG_SYS_LIBDIR = "${SDKPATHNATIVE}/usr/lib"
67PKG_SYS_BINDIR = "${SDKPATHNATIVE}/usr/bin"
68PKG_RUSTLIB_DIR = "${PKG_SYS_LIBDIR}/${TARGET_SYS}/rustlib"
69FILES:${PN} = "${PKG_SYS_LIBDIR}/*.so ${PKG_SYS_BINDIR} ${base_prefix}/environment-setup.d"
70FILES:${RUSTLIB_TARGET_PN} = "${PKG_RUSTLIB_DIR}/${TARGET_SYS} ${PKG_RUSTLIB_DIR}/${TARGET_SYS}.json"
71FILES:${RUSTLIB_HOST_PN} = "${PKG_RUSTLIB_DIR}/${BUILD_ARCH}-unknown-linux-gnu"
72FILES:${RUSTLIB_SRC_PN} = "${PKG_RUSTLIB_DIR}/src"
73
74SUMMARY:${RUSTLIB_TARGET_PN} = "Rust cross canadian libaries for ${TARGET_SYS}"
75SUMMARY:${RUSTLIB_HOST_PN} = "Rust cross canadian libaries for ${HOST_SYS}"
76SUMMARY:${RUSTLIB_SRC_PN} = "Rust standard library sources for cross canadian toolchain"
77SUMMARY:${PN} = "Rust crost canadian compiler"
78