split rust.bbclass into rust & cargo classes

This commit is contained in:
Cody P Schafer
2014-11-21 12:11:28 -05:00
parent fd26b2e1bb
commit 4b75f09945
3 changed files with 62 additions and 56 deletions
+60
View File
@@ -0,0 +1,60 @@
inherit rust
CARGO = "cargo"
# Cargo only supports in-tree builds at the moment
B = "${S}"
OECARGO_PATH ??= ""
oe_cargo_config () {
mkdir -p .cargo
# FIXME: we currently blow away the entire config because duplicate
# sections are treated as a parse error by cargo (causing the entire
# config to be silently ignored.
# NOTE: we cannot pass more flags via this interface, the 'linker' is
# assumed to be a path to a binary. If flags are needed, a wrapper must
# be used.
echo "paths = [" >.cargo/config
for p in ${OECARGO_PATH}; do
printf "\"%s\" " "$p"
done | sed -e 's/[ \n]+/,/g' -e 's/,$//' >>.cargo/config
echo "]" >>.cargo/config
}
rust_cargo_patch () {
cd "${S}"
cat >>Cargo.toml <<EOF
[profile.dev]
rpath = true
[profile.release]
rpath = true
EOF
}
oe_cargo_build () {
# FIXME: if there is already an entry for this target, in an existing
# cargo/config, this won't work.
which cargo
which rustc
bbnote ${CARGO} build --target ${TARGET_SYS} "$@"
oe_cargo_config
"${CARGO}" build -v --target "${TARGET_SYS}" --release "$@"
}
cargo_do_compile () {
cd "${B}"
oe_cargo_build
}
cargo_do_install () {
install -d "${D}${bindir}"
for tgt in "${B}/target/${HOST_SYS}/release/"*; do
if [ -f "$tgt" ] && [ -x "$tgt" ]; then
install -m755 "$tgt" "${D}${bindir}"
fi
done
}
EXPORT_FUNCTIONS do_compile do_install
-40
View File
@@ -68,47 +68,7 @@ RUST_PATH_NATIVE = "${STAGING_LIBDIR_NATIVE}:${STAGING_BASE_LIBDIR_NATIVE}"
## This is builtin to rustc with the value "$libdir/rust/targets"
# RUST_TARGET_PATH = "foo:bar"
CARGO = "cargo"
OECARGO_PATH ??= ""
oe_runrustc () {
bbnote ${RUSTC} ${RUSTC_ARCHFLAGS} ${RUSTC_FLAGS} "$@"
"${RUSTC}" ${RUSTC_ARCHFLAGS} ${RUSTC_FLAGS} "$@"
}
oe_cargo_config () {
mkdir -p .cargo
# FIXME: we currently blow away the entire config because duplicate
# sections are treated as a parse error by cargo (causing the entire
# config to be silently ignored.
# NOTE: we cannot pass more flags via this interface, the 'linker' is
# assumed to be a path to a binary. If flags are needed, a wrapper must
# be used.
echo "paths = [" >.cargo/config
for p in ${OECARGO_PATH}; do
printf "\"%s\" " "$p"
done | sed -e 's/[ \n]+/,/g' -e 's/,$//' >>.cargo/config
echo "]" >>.cargo/config
}
rust_cargo_patch () {
cd "${S}"
cat >>Cargo.toml <<EOF
[profile.dev]
rpath = true
[profile.release]
rpath = true
EOF
}
oe_cargo_build () {
# FIXME: if there is already an entry for this target, in an existing
# cargo/config, this won't work.
which cargo
which rustc
bbnote ${CARGO} build --target ${TARGET_SYS} "$@"
oe_cargo_config
"${CARGO}" build -v --target "${TARGET_SYS}" --release "$@"
}
@@ -1,4 +1,4 @@
inherit rust
inherit cargo
SRC_URI = "git://github.com/jmesmon/rust-hello-world.git;protocol=https"
SRCREV="e0fa23f1a3cb1eb1407165bd2fc36d2f6e6ad728"
@@ -10,20 +10,6 @@ LICENSE = "MIT | Apache-2.0"
# FIXME: we really depend on cargo-native, but avoid it for now as building it
# is more painful than it should be
DEPENDS = "cargo-native"
#DEPENDS = "cargo-native"
S = "${WORKDIR}/git"
B = "${S}"
do_compile () {
oe_cargo_build
}
do_install () {
install -d "${D}${bindir}"
for tgt in "${B}/target/${HOST_SYS}/release/"*; do
if [ -f "$tgt" ] && [ -x "$tgt" ]; then
install -m755 "$tgt" "${D}${bindir}"
fi
done
}