From a91af9bbaec5151723a259a0941f58dac6cdb3ce Mon Sep 17 00:00:00 2001 From: Tyler Hall Date: Fri, 12 Jun 2015 12:52:19 -0400 Subject: [PATCH] Add rust-bin class This provides more defaults that aren't required for compiling with rustc, but standardize the output for inclusion in a distro. Things like - Where to install libraries - Stripping rustc note sections - Optimization by default --- classes/rust-bin.bbclass | 31 +++++++++++++++++++++++++++++++ recipes/rust/rustlib.bb | 4 +--- 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 classes/rust-bin.bbclass diff --git a/classes/rust-bin.bbclass b/classes/rust-bin.bbclass new file mode 100644 index 0000000..22335bb --- /dev/null +++ b/classes/rust-bin.bbclass @@ -0,0 +1,31 @@ +inherit rust + +RUSTLIB_DEP ?= " rustlib" +DEPENDS .= "${RUSTLIB_DEP}" +DEPENDS += "patchelf-native" + +export rustlibdir = "${libdir}/rust" +FILES_${PN} += "${rustlibdir}/*.so" +FILES_${PN}-dev += "${rustlibdir}/*.rlib" +FILES_${PN}-dbg += "${rustlibdir}/.debug" + +RUSTC_ARCHFLAGS += "-C opt-level=3 -L ${STAGING_DIR_HOST}/${rustlibdir}" +EXTRA_OEMAKE += 'RUSTC_ARCHFLAGS="${RUSTC_ARCHFLAGS}"' + +rustlib="${libdir}/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}/rustlib/${HOST_SYS}/lib" + +do_rust_bin_fixups() { + for f in `find ${PKGD} -name '*.so*'`; do + echo "Strip rust note: $f" + ${OBJCOPY} -R .note.rustc $f $f + done + + for f in `find ${PKGD}`; do + file "$f" | grep -q ELF || continue + readelf -d "$f" | grep RPATH | grep -q rustlib || continue + echo "Set rpath:" "$f" + patchelf --set-rpath '$ORIGIN:'${rustlibdir}:${rustlib} "$f" + done +} + +PACKAGE_PREPROCESS_FUNCS += "do_rust_bin_fixups" diff --git a/recipes/rust/rustlib.bb b/recipes/rust/rustlib.bb index 9d767a3..c13be30 100644 --- a/recipes/rust/rustlib.bb +++ b/recipes/rust/rustlib.bb @@ -3,13 +3,11 @@ HOMEPAGE = "http://www.rust-lang.org" SECTION = "devel" LICENSE = "MIT | Apache-2.0" -inherit rust +inherit rust-bin DEPENDS += "virtual/${TARGET_PREFIX}rust" RUSTLIB_DEP = "" -rustlib="${libdir}/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}/rustlib/${HOST_SYS}/lib" - do_install () { mkdir -p ${D}/${rustlib} cp ${STAGING_DIR_NATIVE}/${rustlib}/*.so ${D}/${rustlib}