diff --git a/classes/rust-cross.bbclass b/classes/internal-rust-cross.bbclass similarity index 99% rename from classes/rust-cross.bbclass rename to classes/internal-rust-cross.bbclass index f4133cd..dc53921 100644 --- a/classes/rust-cross.bbclass +++ b/classes/internal-rust-cross.bbclass @@ -13,6 +13,5 @@ PN = "rust-cross-${TARGET_ARCH}" # INHIBIT_PACKAGE_STRIP = "1" # ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_NATIVE}${target_includedir}" - # TODO: use rust-native instead of a snapshot EXTRA_OECONF += "" diff --git a/classes/internal-rust-native.bbclass b/classes/internal-rust-native.bbclass new file mode 100644 index 0000000..1a45a4d --- /dev/null +++ b/classes/internal-rust-native.bbclass @@ -0,0 +1,5 @@ +inherit native +PN = "rust-native" + +USE_LOCAL_NATIVE_RUST ??= "0" +USE_LOCAL_RUST = "${base_conditional('USE_LOCAL_NATIVE_RUST', '0', '0', '1')}" diff --git a/recipes/rust-hello-world/rust-hello-world_git.bb b/recipes/rust-hello-world/rust-hello-world_git.bb index f11d7a8..6ffa074 100644 --- a/recipes/rust-hello-world/rust-hello-world_git.bb +++ b/recipes/rust-hello-world/rust-hello-world_git.bb @@ -6,7 +6,7 @@ SUMMARY = "Hello World by Cargo for Rust" HOMEPAGE = "https://github.com/jmesmon/rust-hello-world" LICENSE = "MIT | Apache-2.0" -DEPENDS = "rust cargo" +DEPENDS = "cargo-native" inherit rust S = "${WORKDIR}/git" diff --git a/recipes/rust/files/0001-platform.mk-avoid-choking-on-i586.patch b/recipes/rust/files/0001-platform.mk-avoid-choking-on-i586.patch new file mode 100644 index 0000000..edfc5b5 --- /dev/null +++ b/recipes/rust/files/0001-platform.mk-avoid-choking-on-i586.patch @@ -0,0 +1,27 @@ +From fead6879b81ca4a15116a572ae286a6cb0b071c0 Mon Sep 17 00:00:00 2001 +From: Cody P Schafer +Date: Sat, 15 Nov 2014 20:12:48 -0500 +Subject: [PATCH] platform.mk: avoid choking on i586 + +--- + mk/platform.mk | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/mk/platform.mk b/mk/platform.mk +index 6da01ef..ee83f66 100644 +--- a/mk/platform.mk ++++ b/mk/platform.mk +@@ -14,7 +14,9 @@ + # would create a variable HOST_i686-darwin-macos with the value + # i386. + define DEF_HOST_VAR +- HOST_$(1) = $(subst i686,i386,$(word 1,$(subst -, ,$(1)))) ++ HOST_$(1) = $(subst i686,i386,\ ++ $(subst i586,i386,\ ++ $(word 1,$(subst -, ,$(1))))) + endef + $(foreach t,$(CFG_TARGET),$(eval $(call DEF_HOST_VAR,$(t)))) + $(foreach t,$(CFG_TARGET),$(info cfg: host for $(t) is $(HOST_$(t)))) +-- +2.0.4 + diff --git a/recipes/rust/rust.inc b/recipes/rust/rust.inc index 44ddc7b..a2b4527 100644 --- a/recipes/rust/rust.inc +++ b/recipes/rust/rust.inc @@ -11,6 +11,10 @@ LIC_FILES_CHKSUM ="\ file://COPYRIGHT;md5=0e8e4a3b5d8e1c90eb243d406369763a \ " +# Controls whether we use the local rust. +# For -native, we set this to "0" by default. +USE_LOCAL_RUST = "1" + export RUST_TARGET_PATH="${WORKDIR}/targets/" ## arm-unknown-linux-gnueabihf @@ -232,19 +236,23 @@ do_configure () { # rpath is required otherwise rustc fails to resolve symbols - ${S}/configure \ - "--enable-rpath" \ - "--disable-verify-install" \ - "--prefix=${prefix}" \ - "--target=${TARGET_SYS}" \ - "--host=${HOST_SYS}" \ - "--build=${BUILD_SYS}" \ - "--localstatedir=${localstatedir}" \ - "--sysconfdir=${sysconfdir}" \ - "--datadir=${datadir}" \ - "--infodir=${infodir}" \ - "--mandir=${mandir}" \ - "--libdir=${libdir}" + # TODO: consider setting --local-rust-root for -cross and -target + # builds. + ${S}/configure \ + "--enable-rpath" \ + "--disable-verify-install" \ + "--prefix=${prefix}" \ + "--target=${TARGET_SYS}" \ + "--host=${HOST_SYS}" \ + "--build=${BUILD_SYS}" \ + "--localstatedir=${localstatedir}" \ + "--sysconfdir=${sysconfdir}" \ + "--datadir=${datadir}" \ + "--infodir=${infodir}" \ + "--mandir=${mandir}" \ + "--libdir=${libdir}" \ + ${@base_conditional('USE_LOCAL_RUST', '1', '--enable-local-rust', '', d)} \ + ${EXTRA_OECONF} } rust_runmake () { @@ -281,9 +289,16 @@ do_install () { # Need to copy the *.so files to the appropriate target path # cp $prefix/lib/rustlib/`rust_triple "${TARGET_ARCH}" "${TARGET_VENDOR}" "${TARGET_OS}"`/lib/*.so ${target_libdir}/ -# cross-canadian: llvm configure fails for host while attempting to build host-only llvm -BBCLASSEXTEND = "rust-cross native" +## We abuse the BBCLASSEXTEND system to avoid creating multiple .bb for every +## rust version (which is what gcc does). +## +## Right now 'target' doesn't need any special settings, but at some point we may need to: +## - add an internal-rust-target +## - set the PN of this package to something like "rust-internal" or otherwise +## make the base unbuildable. +BBCLASSEXTEND = "internal-rust-cross internal-rust-native" +## This is a hack to have -cross provide -native, which doesn't quite work #python cross_virtclass_provides_native_handler () { # classextend = e.data.getVar('BBCLASSEXTEND', True) or "" # if "cross" not in classextend: diff --git a/recipes/rust/rust_0.12.0+2014-11-14.bb b/recipes/rust/rust_0.12.0+2014-11-14.bb index 89b933f..7c94acb 100644 --- a/recipes/rust/rust_0.12.0+2014-11-14.bb +++ b/recipes/rust/rust_0.12.0+2014-11-14.bb @@ -4,4 +4,5 @@ require rust-git.inc SRC_URI_append = "\ file://0001-src-etc-snapshot-support-triples-lacking-a-vendor.patch \ file://0001-get-snapshot-debug.patch \ + file://0001-platform.mk-avoid-choking-on-i586.patch \ "