Merge pull request #30 from srwalter/update-rust-bin-bbclass
Update rust-bin.bbclass
This commit is contained in:
@@ -2,6 +2,7 @@ inherit rust
|
||||
|
||||
RUSTLIB_DEP ?= " rustlib"
|
||||
DEPENDS .= "${RUSTLIB_DEP}"
|
||||
RDEPENDS_${PN} .= "${RUSTLIB_DEP}"
|
||||
DEPENDS += "patchelf-native"
|
||||
|
||||
export rustlibdir = "${libdir}/rust"
|
||||
@@ -35,10 +36,10 @@ OVERLAP_DEPS = "${@get_overlap_deps(d)}"
|
||||
# See https://github.com/rust-lang/rust/issues/19680
|
||||
RUSTC_FLAGS += "-C prefer-dynamic"
|
||||
|
||||
rustlib="${libdir}/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}/rustlib/${HOST_SYS}/lib"
|
||||
rustlib="${libdir}/${TUNE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/rustlib/${HOST_SYS}/lib"
|
||||
CRATE_NAME ?= "${@d.getVar('BPN', True).replace('-rs', '').replace('-', '_')}"
|
||||
BINNAME ?= "${BPN}"
|
||||
LIBNAME ?= "lib${CRATE_NAME}"
|
||||
LIBNAME ?= "lib${CRATE_NAME}-rs"
|
||||
CRATE_TYPE ?= "dylib"
|
||||
BIN_SRC ?= "${S}/src/main.rs"
|
||||
LIB_SRC ?= "${S}/src/lib.rs"
|
||||
@@ -46,7 +47,7 @@ LIB_SRC ?= "${S}/src/lib.rs"
|
||||
get_overlap_externs () {
|
||||
externs=
|
||||
for dep in ${OVERLAP_DEPS}; do
|
||||
extern=$(ls ${STAGING_DIR_HOST}/${rustlibdir}/lib$dep.{so,rlib} 2>/dev/null \
|
||||
extern=$(ls ${STAGING_DIR_HOST}/${rustlibdir}/lib$dep-rs.{so,rlib} 2>/dev/null \
|
||||
| awk '{print $1}');
|
||||
if [ -n "$extern" ]; then
|
||||
externs="$externs --extern $dep=$extern"
|
||||
@@ -58,16 +59,21 @@ get_overlap_externs () {
|
||||
echo "$externs"
|
||||
}
|
||||
|
||||
do_configure () {
|
||||
}
|
||||
|
||||
oe_compile_rust_lib () {
|
||||
[ "${CRATE_TYPE}" == "dylib" ] && suffix=so || suffix=rlib
|
||||
rm -rf ${LIBNAME}.{rlib,so}
|
||||
local -a link_args
|
||||
if [ "${CRATE_TYPE}" == "dylib" ]; then
|
||||
link_args[0]="-C"
|
||||
link_args[1]="link-args=-Wl,-soname -Wl,${LIBNAME}.so"
|
||||
link_args[1]="link-args=-Wl,-soname -Wl,${LIBNAME}.$suffix"
|
||||
fi
|
||||
oe_runrustc $(get_overlap_externs) \
|
||||
"${link_args[@]}" \
|
||||
${LIB_SRC} \
|
||||
-o ${LIBNAME}.$suffix \
|
||||
--crate-name=${CRATE_NAME} --crate-type=${CRATE_TYPE} \
|
||||
"$@"
|
||||
}
|
||||
@@ -99,7 +105,7 @@ do_rust_bin_fixups() {
|
||||
|
||||
for f in `find ${PKGD}`; do
|
||||
file "$f" | grep -q ELF || continue
|
||||
readelf -d "$f" | grep RPATH | grep -q rustlib || continue
|
||||
readelf -d "$f" | grep RUNPATH | grep -q rustlib || continue
|
||||
echo "Set rpath:" "$f"
|
||||
patchelf --set-rpath '$ORIGIN:'${rustlibdir}:${rustlib} "$f"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user