rust-bin.bbclass: suffix rust libraries with -rs

Rust library names may have sonames that overlap with C/C++ libraries.
This causes bitbake to not be able to create the correct automatic
RDEPENDS between packages. The result is that dependencies may not get
automatically installed.

Add -rs to the file name and soname. The crate name remains the same,
and rust is not dependent on the file name to look up the crate inside
the library.
This commit is contained in:
Tyler Hall
2015-07-28 09:20:10 -04:00
committed by Steven Walter
parent 355863b528
commit 302cca7529

View File

@@ -38,7 +38,7 @@ RUSTC_FLAGS += "-C prefer-dynamic"
rustlib="${libdir}/${TUNE_PKGARCH}${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 +46,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"
@@ -59,15 +59,17 @@ get_overlap_externs () {
}
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} \
"$@"
}