This is so we can use the Rust triples in Cargo builds and other places in addition to the Rust build.
80 lines
2.5 KiB
Plaintext
80 lines
2.5 KiB
Plaintext
inherit rust-vars
|
|
inherit rust-triples
|
|
|
|
RUSTC = "rustc"
|
|
|
|
RUSTC_ARCHFLAGS += "--target=${HOST_SYS} ${RUSTFLAGS}"
|
|
|
|
def rust_base_dep(d):
|
|
# Taken from meta/classes/base.bbclass `base_dep_prepend` and modified to
|
|
# use rust instead of gcc
|
|
deps = ""
|
|
if not d.getVar('INHIBIT_DEFAULT_RUST_DEPS', True):
|
|
if (d.getVar('HOST_SYS', True) != d.getVar('BUILD_SYS', True)):
|
|
deps += " virtual/${TARGET_PREFIX}rust ${RUSTLIB_DEP}"
|
|
else:
|
|
deps += " rust-native"
|
|
return deps
|
|
|
|
DEPENDS_append = " ${@rust_base_dep(d)} patchelf-native"
|
|
|
|
# BUILD_LDFLAGS
|
|
# ${STAGING_LIBDIR_NATIVE}
|
|
# ${STAGING_BASE_LIBDIR_NATIVE}
|
|
# BUILDSDK_LDFLAGS
|
|
# ${STAGING_LIBDIR}
|
|
# #{STAGING_DIR_HOST}
|
|
# TARGET_LDFLAGS ?????
|
|
#RUSTC_BUILD_LDFLAGS = "\
|
|
# --sysroot ${STAGING_DIR_NATIVE} \
|
|
# -L${STAGING_LIBDIR_NATIVE} \
|
|
# -L${STAGING_BASE_LIBDIR_NATIVE} \
|
|
#"
|
|
|
|
RUST_PATH_NATIVE = "${STAGING_LIBDIR_NATIVE}:${STAGING_BASE_LIBDIR_NATIVE}"
|
|
|
|
## Note: the 'rustlib' element of this was a workaround rustc forgetting the
|
|
## libdir it was built with. It now remembers so this should be unneeded
|
|
#RUST_PATH_NATIVE .= ":${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/rustlib/${TARGET_SYS}/lib"
|
|
|
|
# FIXME: set based on whether we are native vs cross vs buildsdk, etc
|
|
#export RUST_PATH ??= "${RUST_PATH_NATIVE}"
|
|
|
|
## This is builtin to rustc with the value "$libdir/rust/targets"
|
|
# RUST_TARGET_PATH = "foo:bar"
|
|
|
|
oe_runrustc () {
|
|
bbnote ${RUSTC} ${RUSTC_ARCHFLAGS} ${RUSTC_FLAGS} "$@"
|
|
"${RUSTC}" ${RUSTC_ARCHFLAGS} ${RUSTC_FLAGS} "$@"
|
|
}
|
|
|
|
# XXX: for some reason bitbake sets BUILD_* & TARGET_* but uses the bare
|
|
# variables for HOST. Alias things to make it easier for us.
|
|
HOST_LDFLAGS ?= "${LDFLAGS}"
|
|
HOST_CFLAGS ?= "${CFLAGS}"
|
|
HOST_CXXFLAGS ?= "${CXXFLAGS}"
|
|
HOST_CPPFLAGS ?= "${CPPFLAGS}"
|
|
|
|
EXTRA_OECONF_remove = "--disable-static"
|
|
|
|
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 RUNPATH | grep -q rustlib || continue
|
|
echo "Set rpath:" "$f"
|
|
patchelf --set-rpath '$ORIGIN:'${rustlibdir}:${rustlib} "$f"
|
|
done
|
|
}
|
|
PACKAGE_PREPROCESS_FUNCS += "do_rust_bin_fixups"
|
|
|
|
rustlib_suffix="${TUNE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/rustlib/${HOST_SYS}/lib"
|
|
# Native sysroot standard library path
|
|
rustlib_src="${prefix}/lib/${rustlib_suffix}"
|
|
# Host sysroot standard library path
|
|
rustlib="${libdir}/${rustlib_suffix}"
|