From 1e0047383eebc902ee35f715c6d31858aea2910f Mon Sep 17 00:00:00 2001 From: Cody P Schafer Date: Fri, 5 Dec 2014 14:08:50 -0500 Subject: [PATCH] refactor cargo.bbclass for easier use when we are not directly driving cargo --- classes/cargo.bbclass | 21 +++++++++++++-------- recipes/cargo/cargo.inc | 9 ++------- recipes/cargo/cargo_2014-12-04.bb | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/classes/cargo.bbclass b/classes/cargo.bbclass index 0119bc3..189f110 100644 --- a/classes/cargo.bbclass +++ b/classes/cargo.bbclass @@ -1,6 +1,6 @@ inherit rust -CARGO = "cargo" +export CARGO ?= "cargo" def cargo_base_dep(d): deps = "" @@ -23,7 +23,7 @@ export RUST_BACKTRACE = "1" EXTRA_OECARGO_PATHS ??= "" -oe_cargo_config () { +cargo_do_configure () { 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 @@ -61,16 +61,15 @@ export RUST_CFLAGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${CFLAGS}" export RUST_BUILD_CC = "${CCACHE}${BUILD_PREFIX}gcc" export RUST_BUILD_CFLAGS = "${BUILD_CC_ARCH} ${BUILD_CFLAGS}" +export CARGO_BUILD_FLAGS = "-v --target ${HOST_SYS} --release" oe_cargo_build () { which cargo which rustc - bbnote ${CARGO} build --target ${TARGET_SYS} "$@" - oe_cargo_config - "${CARGO}" build -v --target "${TARGET_SYS}" --release "$@" + bbnote ${CARGO} build ${CARGO_BUILD_FLAGS} "$@" + "${CARGO}" build ${CARGO_BUILD_FLAGS} "$@" } -cargo_do_compile () { - cd "${B}" +oe_cargo_fix_env () { export CC="${RUST_CC}" export CFLAGS="${RUST_CFLAGS}" export AR="${AR}" @@ -80,9 +79,15 @@ cargo_do_compile () { export HOST_CC="${RUST_BUILD_CC}" export HOST_CFLAGS="${RUST_BUILD_CFLAGS}" export HOST_AR="${BUILD_AR}" +} + +cargo_do_compile () { + cd "${B}" + oe_cargo_fix_env oe_cargo_build } +# All but the most simple projects will need to override this. cargo_do_install () { install -d "${D}${bindir}" for tgt in "${B}/target/${HOST_SYS}/release/"*; do @@ -92,4 +97,4 @@ cargo_do_install () { done } -EXPORT_FUNCTIONS do_compile do_install +EXPORT_FUNCTIONS do_compile do_install do_configure diff --git a/recipes/cargo/cargo.inc b/recipes/cargo/cargo.inc index e4dde16..34320a0 100644 --- a/recipes/cargo/cargo.inc +++ b/recipes/cargo/cargo.inc @@ -39,7 +39,7 @@ do_configure () { # cargo downloads a cargo snapshot to build itself using cargo, we need # to override it's arch info. - oe_cargo_config + cargo_do_configure } do_compile () { @@ -47,12 +47,7 @@ do_compile () { # HOST is set once we have this cargo, but we need to manually # set it for the bootstrap. export HOST="${BUILD_SYS}" - export TARGET_CC="${RUST_CC}" - export TARGET_CFLAGS="${RUST_CFLAGS}" - export TARGET_AR="${AR}" - export HOST_CC="${RUST_BUILD_CC}" - export HOST_CFLAGS="${RUST_BUILD_CFLAGS}" - export HOST_AR="${BUILD_AR}" + oe_cargo_fix_env oe_runmake ARGS="--verbose" } diff --git a/recipes/cargo/cargo_2014-12-04.bb b/recipes/cargo/cargo_2014-12-04.bb index 8d83729..137114a 100644 --- a/recipes/cargo/cargo_2014-12-04.bb +++ b/recipes/cargo/cargo_2014-12-04.bb @@ -2,7 +2,7 @@ SRCREV_cargo = "70f5205dba9887d8dab07f72dbc507aa74b12c1f" require cargo.inc SRC_URI += " \ - file:///0001-custom_build-build-output-goes-in-the-directory-for-.patch \ + file://0001-custom_build-build-output-goes-in-the-directory-for-.patch \ \ git://github.com/carllerche/curl-rust.git;protocol=https;name=curl-rust;destsuffix=curl-rust \ file://curl-rust/0001-curl-sys-avoid-explicitly-linking-in-openssl-If-it-.patch;patchdir=../curl-rust \