From c8e2b6166e3e77649947f019c521dc58f9ee14b3 Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Wed, 31 Aug 2016 16:32:21 -0400 Subject: [PATCH 01/12] cargo-snapshot.inc: use a date-specific downloadfilename This allows the snapshot to be cached in a local mirror with a unique name --- recipes-devtools/cargo/cargo-snapshot.inc | 2 +- recipes-devtools/cargo/cargo.inc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes-devtools/cargo/cargo-snapshot.inc b/recipes-devtools/cargo/cargo-snapshot.inc index 0ea10ee..5403ec0 100644 --- a/recipes-devtools/cargo/cargo-snapshot.inc +++ b/recipes-devtools/cargo/cargo-snapshot.inc @@ -1,4 +1,4 @@ -CARGO_SNAPSHOT = "2016-01-31/cargo-nightly-x86_64-unknown-linux-gnu.tar.gz" +CARGO_SNAPSHOT = "2016-01-31/cargo-nightly-x86_64-unknown-linux-gnu.tar.gz;downloadfilename=cargo-nightly-x86_64-unknown-linux-gnu-2016-01-31.tar.gz" SRC_URI[md5sum] = "52f48780b7cfadc88813766048d4d402" SRC_URI[sha256sum] = "1920e661bab536eba763ff6704a1d62fb20bb0f67d8c5a119e41c49510ea5fa6" diff --git a/recipes-devtools/cargo/cargo.inc b/recipes-devtools/cargo/cargo.inc index ca6a31f..df0f603 100644 --- a/recipes-devtools/cargo/cargo.inc +++ b/recipes-devtools/cargo/cargo.inc @@ -54,7 +54,7 @@ do_compile () { rm -rf target/snapshot mkdir -p target - cp -R ${WORKDIR}/$(basename ${CARGO_SNAPSHOT} .tar.gz)/cargo target/snapshot + cp -R ${WORKDIR}/cargo-nightly-x86_64-unknown-linux-gnu/cargo target/snapshot oe_runmake ARGS="--verbose" } From c6ea2fe28572e33eac4520abe0c1fcf8bac8de73 Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Thu, 1 Sep 2016 09:45:34 -0400 Subject: [PATCH 02/12] cargo_util.bbclass: support EXTRA_OECARGO_PATHS With this we can convert the cargo-native recipe over to using cargo_util instead of cargo.bbclass --- classes/cargo_util.bbclass | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/classes/cargo_util.bbclass b/classes/cargo_util.bbclass index f38a519..83ebaaa 100644 --- a/classes/cargo_util.bbclass +++ b/classes/cargo_util.bbclass @@ -62,6 +62,21 @@ oe_cargo_fix_env () { export HOST_AR="${BUILD_AR}" } +EXTRA_OECARGO_PATHS ??= "" + +cargo_util_do_configure () { + mkdir -p ${CARGO_HOME} + # 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_HOME}/config + + for p in ${EXTRA_OECARGO_PATHS}; do + printf "\"%s\"\n" "$p" + done | sed -e 's/$/,/' >> ${CARGO_HOME}/config + echo "]" >> ${CARGO_HOME}/config +} + cargo_util_do_compile () { cd "${B}" @@ -91,4 +106,4 @@ cargo_util_do_install () { fi } -EXPORT_FUNCTIONS do_compile do_install +EXPORT_FUNCTIONS do_configure do_compile do_install From 11f0c95763b1d4c68349bb60c43e09967ceaa69f Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Thu, 1 Sep 2016 11:35:36 -0400 Subject: [PATCH 03/12] cargo_util.bbclass: fix for native users Building native packages with cargo means with need a native rust compiler --- classes/cargo_util.bbclass | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/cargo_util.bbclass b/classes/cargo_util.bbclass index 83ebaaa..55d3924 100644 --- a/classes/cargo_util.bbclass +++ b/classes/cargo_util.bbclass @@ -13,6 +13,7 @@ BASEDEPENDS_append = " cargo-native" # Ensure we get the right rust variant DEPENDS_append_class-target = " virtual/${TARGET_PREFIX}rust ${RUSTLIB_DEP}" +DEPENDS_append_class-native = " rust-native" # Cargo only supports in-tree builds at the moment B = "${S}" From 0c54b5727f9b4e1a623bdd90ae9c62769ec11fd3 Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Thu, 1 Sep 2016 14:31:13 -0400 Subject: [PATCH 04/12] cargo-snapshot.inc: update to a newer nightly build Switch to a nightly that supports the source-replacement feature. This allows us to swap in our locally-fetched crates for upstream crates.io --- recipes-devtools/cargo/cargo-snapshot.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes-devtools/cargo/cargo-snapshot.inc b/recipes-devtools/cargo/cargo-snapshot.inc index 5403ec0..8f3c28a 100644 --- a/recipes-devtools/cargo/cargo-snapshot.inc +++ b/recipes-devtools/cargo/cargo-snapshot.inc @@ -1,4 +1,4 @@ -CARGO_SNAPSHOT = "2016-01-31/cargo-nightly-x86_64-unknown-linux-gnu.tar.gz;downloadfilename=cargo-nightly-x86_64-unknown-linux-gnu-2016-01-31.tar.gz" -SRC_URI[md5sum] = "52f48780b7cfadc88813766048d4d402" -SRC_URI[sha256sum] = "1920e661bab536eba763ff6704a1d62fb20bb0f67d8c5a119e41c49510ea5fa6" +CARGO_SNAPSHOT = "2016-09-01/cargo-nightly-x86_64-unknown-linux-gnu.tar.gz;downloadfilename=cargo-nightly-x86_64-unknown-linux-gnu-2016-09-01.tar.gz" +SRC_URI[md5sum] = "d41ebf79290a7c9c9e5df87cb27e5091" +SRC_URI[sha256sum] = "365e5cad79512d244b8ced32f8e5b86a710fc6c17f0d0f5f744b8058ef6dc756" From f89057c0afe2909a0b562310d09e179e26bc9669 Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Fri, 2 Sep 2016 14:20:03 -0400 Subject: [PATCH 05/12] lib/crate.py: additionally populate a local registry The local registry is a more future-proof way to prevent cargo from accessing the network during the build. Unfortunately, this is only used during the build of cargo-native for now. The snapshot used while building cargo-native supports using a local registry ("source replacement") however the version of cargo supported by rust 1.10 does not. Until we can build a new-enough version of cargo that supports source-replacement, we'll have to patch cargo directly to prevent it from accessing the network. Once we do have a new-enough cargo, we can stop populating cargo_home/registry and only create cargo_registry. --- classes/cargo_util.bbclass | 9 +++++++++ lib/crate.py | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/classes/cargo_util.bbclass b/classes/cargo_util.bbclass index 55d3924..81d4c85 100644 --- a/classes/cargo_util.bbclass +++ b/classes/cargo_util.bbclass @@ -76,6 +76,15 @@ cargo_util_do_configure () { printf "\"%s\"\n" "$p" done | sed -e 's/$/,/' >> ${CARGO_HOME}/config echo "]" >> ${CARGO_HOME}/config + + # Point cargo at our local mirror of the registry + cat >> ${CARGO_HOME}/config < Date: Fri, 2 Sep 2016 20:14:02 -0400 Subject: [PATCH 06/12] lib/crate.py: update magic hash for new cargo --- classes/cargo_util.bbclass | 4 ++-- lib/crate.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/classes/cargo_util.bbclass b/classes/cargo_util.bbclass index 81d4c85..29bd695 100644 --- a/classes/cargo_util.bbclass +++ b/classes/cargo_util.bbclass @@ -91,8 +91,8 @@ cargo_util_do_compile () { cd "${B}" # prevent cargo from trying to fetch down new data - mkdir -p "${WORKDIR}/cargo_home/registry/index/" - touch "${WORKDIR}/cargo_home/registry/index/.cargo-index-lock" + mkdir -p "${WORKDIR}/cargo_home/registry/index/github.com-1ecc6299db9ec823" + touch "${WORKDIR}/cargo_home/registry/index/github.com-1ecc6299db9ec823/.cargo-index-lock" oe_cargo_fix_env oe_cargo_build diff --git a/lib/crate.py b/lib/crate.py index be626fc..3197037 100644 --- a/lib/crate.py +++ b/lib/crate.py @@ -35,7 +35,8 @@ class Crate(Wget): def _cargo_path(self, rootdir, component): # TODO: make this less brittle - repo = "github.com-88ac128001ac3a9a" + # This can go away entirely once we can build a cargo that supports source-replacement + repo = "github.com-1ecc6299db9ec823" return os.path.join(rootdir, "cargo_home", "registry", component, repo) def _cargo_src_path(self, rootdir): From cb753fc536561b14f7e95ee7b390cb53a85bc664 Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Thu, 1 Sep 2016 09:46:10 -0400 Subject: [PATCH 07/12] cargo.inc: switch to cargo_util.bbclass This does all the fetching through bitbake which allows it to be built correctly in firewalled environments. --- recipes-devtools/cargo/cargo.inc | 60 ++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/recipes-devtools/cargo/cargo.inc b/recipes-devtools/cargo/cargo.inc index df0f603..6303f83 100644 --- a/recipes-devtools/cargo/cargo.inc +++ b/recipes-devtools/cargo/cargo.inc @@ -1,6 +1,4 @@ -INHIBIT_CARGO_DEP = "1" - -inherit cargo +inherit cargo_util inherit patch inherit rust-installer @@ -11,8 +9,60 @@ LICENSE = "MIT | Apache-2.0" DEPENDS = "openssl zlib libgit2 curl ca-certificates libssh2" +CARGO_INDEX_COMMIT = "6127fc24b0b6fe73fe4d339817fbf000b9a798a2" + SRC_URI = "\ http://static-rust-lang-org.s3.amazonaws.com/cargo-dist/${CARGO_SNAPSHOT} \ + crate://crates.io/advapi32-sys/0.1.2 \ + crate://crates.io/bufstream/0.1.1 \ + crate://crates.io/crossbeam/0.2.8 \ + crate://crates.io/docopt/0.6.78 \ + crate://crates.io/env_logger/0.3.2 \ + crate://crates.io/filetime/0.1.10 \ + crate://crates.io/flate2/0.2.13 \ + crate://crates.io/fs2/0.2.3 \ + crate://crates.io/glob/0.2.11 \ + crate://crates.io/hamcrest/0.1.0 \ + crate://crates.io/kernel32-sys/0.2.1 \ + crate://crates.io/libc/0.2.8 \ + crate://crates.io/log/0.3.5 \ + crate://crates.io/num_cpus/0.2.11 \ + crate://crates.io/regex/0.1.58 \ + crate://crates.io/rustc-serialize/0.3.18 \ + crate://crates.io/tar/0.4.5 \ + crate://crates.io/tempdir/0.3.4 \ + crate://crates.io/term/0.4.4 \ + crate://crates.io/toml/0.1.28 \ + crate://crates.io/url/1.1.0 \ + crate://crates.io/winapi/0.2.6 \ + crate://crates.io/semver/0.2.3 \ + crate://crates.io/regex-syntax/0.3.0 \ + crate://crates.io/utf8-ranges/0.1.3 \ + crate://crates.io/gcc/0.3.26 \ + crate://crates.io/unicode-normalization/0.1.2 \ + crate://crates.io/libz-sys/1.0.2 \ + crate://crates.io/rand/0.3.14 \ + crate://crates.io/user32-sys/0.1.2 \ + crate://crates.io/idna/0.1.0 \ + crate://crates.io/strsim/0.3.0 \ + crate://crates.io/matches/0.1.2 \ + crate://crates.io/cmake/0.1.16 \ + crate://crates.io/gdi32-sys/0.1.1 \ + crate://crates.io/bitflags/0.1.1 \ + crate://crates.io/unicode-bidi/0.2.3 \ + crate://crates.io/pkg-config/0.3.8 \ + crate://crates.io/winapi-build/0.1.1 \ + crate://crates.io/memchr/0.1.10 \ + crate://crates.io/pnacl-build-helper/1.4.10 \ + crate://crates.io/nom/1.2.2 \ + crate://crates.io/num/0.1.31 \ + crate://crates.io/uuid/0.2.3 \ + crate://crates.io/aho-corasick/0.5.1 \ + crate://crates.io/libressl-pnacl-sys/2.1.6 \ + crate://crates.io/miniz-sys/0.1.7 \ + crate://crates.io/openssl-sys/0.7.8 \ + crate://crates.io/url/0.5.10 \ + crate-index://crates.io/${CARGO_INDEX_COMMIT} \ " B = "${S}" @@ -44,9 +94,7 @@ do_configure () { ${EXTRA_OECONF} \ || die "Could not configure cargo" - # cargo downloads a cargo snapshot to build itself using cargo, we need - # to override it's arch info. - cargo_do_configure + cargo_util_do_configure } do_compile () { From 1059968d25625b298da0ebaafd0966ab2db449d3 Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Fri, 2 Sep 2016 15:11:06 -0400 Subject: [PATCH 08/12] cargo: never contact the registry It's forbidden to access the network during the build phase in bitbake. Since this version of cargo does not yet support source-replacement, we must patch out the behavior instead. --- recipes-devtools/cargo/cargo_0.11.0.bb | 1 + ...0001-Never-update-the-registry-index.patch | 88 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 recipes-devtools/cargo/files/0001-Never-update-the-registry-index.patch diff --git a/recipes-devtools/cargo/cargo_0.11.0.bb b/recipes-devtools/cargo/cargo_0.11.0.bb index f977673..c70d049 100644 --- a/recipes-devtools/cargo/cargo_0.11.0.bb +++ b/recipes-devtools/cargo/cargo_0.11.0.bb @@ -4,6 +4,7 @@ require cargo.inc SRC_URI += " \ git://github.com/rust-lang/cargo.git;protocol=https;name=cargo \ file://0001-disable-cargo-snapshot-fetch.patch \ + file://0001-Never-update-the-registry-index.patch \ git://github.com/rust-lang/rust-installer.git;protocol=https;name=rust-installer;destsuffix=${S}/src/rust-installer \ " # Compatible with Rust 1.10.0 diff --git a/recipes-devtools/cargo/files/0001-Never-update-the-registry-index.patch b/recipes-devtools/cargo/files/0001-Never-update-the-registry-index.patch new file mode 100644 index 0000000..ac33a06 --- /dev/null +++ b/recipes-devtools/cargo/files/0001-Never-update-the-registry-index.patch @@ -0,0 +1,88 @@ +From 27df8ab04275dfd715d1756fc517bb0323f1b210 Mon Sep 17 00:00:00 2001 +From: Steven Walter +Date: Fri, 2 Sep 2016 14:02:03 -0400 +Subject: [PATCH] Never update the registry index + +Bitbake will fetch the index for us so that we needn't do network IO +during a build +--- + src/cargo/ops/cargo_run.rs | 2 +- + src/cargo/sources/registry.rs | 34 +--------------------------------- + 2 files changed, 2 insertions(+), 34 deletions(-) + +diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs +index 6764118..379b98b 100644 +--- a/src/cargo/ops/cargo_run.rs ++++ b/src/cargo/ops/cargo_run.rs +@@ -1,7 +1,7 @@ + use std::path::Path; + + use ops::{self, CompileFilter}; +-use util::{self, CargoResult, process, ProcessError}; ++use util::{self, CargoResult, ProcessError}; + use core::Package; + + pub fn run(manifest_path: &Path, +diff --git a/src/cargo/sources/registry.rs b/src/cargo/sources/registry.rs +index 614d654..a0c7fe6 100644 +--- a/src/cargo/sources/registry.rs ++++ b/src/cargo/sources/registry.rs +@@ -166,7 +166,6 @@ use std::path::{PathBuf, Path}; + + use curl::http; + use flate2::read::GzDecoder; +-use git2; + use rustc_serialize::hex::ToHex; + use rustc_serialize::json; + use tar::Archive; +@@ -174,7 +173,7 @@ use url::Url; + + use core::{Source, SourceId, PackageId, Package, Summary, Registry}; + use core::dependency::{Dependency, DependencyInner, Kind}; +-use sources::{PathSource, git}; ++use sources::PathSource; + use util::{CargoResult, Config, internal, ChainError, ToUrl, human}; + use util::{hex, Sha256, paths, Filesystem, FileLock}; + use ops; +@@ -464,38 +463,7 @@ impl<'cfg> RegistrySource<'cfg> { + + /// Actually perform network operations to update the registry + fn do_update(&mut self) -> CargoResult<()> { +- if self.updated { +- return Ok(()) +- } +- try!(self.checkout_path.create_dir()); +- let lock = try!(self.checkout_path.open_rw(Path::new(INDEX_LOCK), +- self.config, +- "the registry index")); +- let path = lock.path().parent().unwrap(); +- +- try!(self.config.shell().status("Updating", +- format!("registry `{}`", self.source_id.url()))); +- let repo = try!(git2::Repository::open(path).or_else(|_| { +- let _ = lock.remove_siblings(); +- git2::Repository::init(path) +- })); +- +- // git fetch origin +- let url = self.source_id.url().to_string(); +- let refspec = "refs/heads/*:refs/remotes/origin/*"; +- +- try!(git::fetch(&repo, &url, refspec, &self.config).chain_error(|| { +- internal(format!("failed to fetch `{}`", url)) +- })); +- +- // git reset --hard origin/master +- let reference = "refs/remotes/origin/master"; +- let oid = try!(repo.refname_to_id(reference)); +- trace!("[{}] updating to rev {}", self.source_id, oid); +- let object = try!(repo.find_object(oid, None)); +- try!(repo.reset(&object, git2::ResetType::Hard, None)); + self.updated = true; +- self.cache.clear(); + Ok(()) + } + } +-- +2.7.4 + From f31f0c22572075b6622b3b0a8d9e3a3f4e2bbe9e Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Fri, 2 Sep 2016 12:15:33 -0400 Subject: [PATCH 09/12] libstd-rs: download dependent crates Cargo was trying to download these itself before, which isn't allowed. Use the crate fetcher to get our dependencies --- recipes-devtools/rust/libstd-rs.bb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/recipes-devtools/rust/libstd-rs.bb b/recipes-devtools/rust/libstd-rs.bb index d8e72a5..f458b2c 100644 --- a/recipes-devtools/rust/libstd-rs.bb +++ b/recipes-devtools/rust/libstd-rs.bb @@ -6,6 +6,13 @@ LICENSE = "MIT | Apache-2.0" LIC_FILES_CHKSUM ="file://COPYRIGHT;md5=43e1f1fb9c0ee3af66693d8c4fecafa8" require rust-shared-source.inc +CARGO_INDEX_COMMIT = "6127fc24b0b6fe73fe4d339817fbf000b9a798a2" + +SRC_URI += "\ + crate://crates.io/gcc/0.3.26 \ + crate-index://crates.io/${CARGO_INDEX_COMMIT} \ +" + DEPENDS += "compiler-rt" RUSTLIB_DEP = "" From e87b2d43b0b261e8a8e8364eb8fad79300347ea6 Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Fri, 2 Sep 2016 20:14:20 -0400 Subject: [PATCH 10/12] libstd-rs: use cargo_util_do_compile --- classes/cargo_util.bbclass | 2 -- recipes-devtools/rust/libstd-rs.bb | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/classes/cargo_util.bbclass b/classes/cargo_util.bbclass index 29bd695..98af9ee 100644 --- a/classes/cargo_util.bbclass +++ b/classes/cargo_util.bbclass @@ -88,8 +88,6 @@ EOF } cargo_util_do_compile () { - cd "${B}" - # prevent cargo from trying to fetch down new data mkdir -p "${WORKDIR}/cargo_home/registry/index/github.com-1ecc6299db9ec823" touch "${WORKDIR}/cargo_home/registry/index/github.com-1ecc6299db9ec823/.cargo-index-lock" diff --git a/recipes-devtools/rust/libstd-rs.bb b/recipes-devtools/rust/libstd-rs.bb index f458b2c..f785c0d 100644 --- a/recipes-devtools/rust/libstd-rs.bb +++ b/recipes-devtools/rust/libstd-rs.bb @@ -23,12 +23,10 @@ RUSTFLAGS += "-L ${STAGING_LIBDIR}" B = "${WORKDIR}/build" -do_compile () { +do_compile_prepend () { cd ${S}/src/rustc/std_shim export CARGO_TARGET_DIR="${B}" export RUSTC_BOOTSTRAP_KEY="e8edd0fd" - oe_cargo_fix_env - oe_cargo_build } do_install () { From fbf59ed6a04e02280751a69bdb1974c0b5a21708 Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Mon, 5 Sep 2016 15:01:12 -0400 Subject: [PATCH 11/12] cargo.bbclass: replace with what was cargo_util.bbclass The old cargo.bbclass had no users in meta-rust and had lots of problems (not least of which was lots of duplicated lines with cargo_util.bbclass). Delete the old cargo.bbclass and replace it entirely wiht cargo_util --- classes/cargo.bbclass | 68 ++++++---- classes/cargo_util.bbclass | 117 ------------------ recipes-devtools/cargo/cargo.inc | 4 +- recipes-devtools/rust/libstd-rs.bb | 2 +- .../rust-hello-world/rust-hello-world_git.bb | 2 +- recipes-example/rustfmt/rustfmt_0.4.0.bb | 2 +- 6 files changed, 47 insertions(+), 148 deletions(-) delete mode 100644 classes/cargo_util.bbclass diff --git a/classes/cargo.bbclass b/classes/cargo.bbclass index 3d1605c..ded9894 100644 --- a/classes/cargo.bbclass +++ b/classes/cargo.bbclass @@ -1,20 +1,23 @@ -inherit rust +inherit rust-vars +# add crate fetch support +inherit crate-fetch -CARGO ?= "cargo" +# the binary we will use +CARGO = "cargo" + +# Where we download our registry and dependencies to export CARGO_HOME = "${WORKDIR}/cargo_home" -def cargo_base_dep(d): - deps = "" - if not d.getVar('INHIBIT_DEFAULT_DEPS', True) and not d.getVar('INHIBIT_CARGO_DEP', True): - deps += " cargo-native" - return deps +# We need cargo to compile for the target +BASEDEPENDS_append = " cargo-native" -BASEDEPENDS_append = " ${@cargo_base_dep(d)}" +# Ensure we get the right rust variant +DEPENDS_append_class-target = " virtual/${TARGET_PREFIX}rust ${RUSTLIB_DEP}" +DEPENDS_append_class-native = " rust-native" # Cargo only supports in-tree builds at the moment B = "${S}" - # In case something fails in the build process, give a bit more feedback on # where the issue occured export RUST_BACKTRACE = "1" @@ -24,22 +27,26 @@ export RUST_BACKTRACE = "1" # for cross compilation, so tell it we know better than it. export PKG_CONFIG_ALLOW_CROSS = "1" -EXTRA_OECARGO_PATHS ??= "" - cargo_do_configure () { - # FIXME: we currently make a mess in the directory above us - # (${WORKDIR}), which may not be ideal. Look into whether this is - # allowed - mkdir -p ../.cargo + mkdir -p ${CARGO_HOME} # 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 + echo "paths = [" > ${CARGO_HOME}/config for p in ${EXTRA_OECARGO_PATHS}; do printf "\"%s\"\n" "$p" - done | sed -e 's/$/,/' >>../.cargo/config - echo "]" >>../.cargo/config + done | sed -e 's/$/,/' >> ${CARGO_HOME}/config + echo "]" >> ${CARGO_HOME}/config + + # Point cargo at our local mirror of the registry + cat >> ${CARGO_HOME}/config < ${CARGO_HOME}/config - - for p in ${EXTRA_OECARGO_PATHS}; do - printf "\"%s\"\n" "$p" - done | sed -e 's/$/,/' >> ${CARGO_HOME}/config - echo "]" >> ${CARGO_HOME}/config - - # Point cargo at our local mirror of the registry - cat >> ${CARGO_HOME}/config < Date: Mon, 5 Sep 2016 15:14:19 -0400 Subject: [PATCH 12/12] README.md: link to cargo-bitbake helper program cargo-bitbake can be used to generate recipes for cargo-based rust packages. --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index c2d1cc6..a93bae4 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,19 @@ This openembedded layer provides the rust compiler, tools for building packages - rust (built for target) +## Building a rust package + +When building a rust package in bitbake, it's usually easiest to build with +cargo using cargo.bbclass. If the package already has a Cargo.toml file (most +rust packages do), then it's especially easy. Otherwise you should probably +get the code building in cargo first. + +Once your package builds in cargo, you can use +[cargo-bitbake](https://github.com/cardoe/cargo-bitbake) to generate a bitbake +recipe for it. This allows bitbake to fetch all the necessary dependent +crates, as well as a pegged version of the crates.io index, to ensure maximum +reproducibility. + ## Common issues when packaging things using cargo You may run into errors similar to: