cargo_1.85.1.bb 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. SUMMARY = "Cargo, a package manager for Rust."
  2. HOMEPAGE = "https://crates.io"
  3. LICENSE = "MIT | Apache-2.0"
  4. SECTION = "devel"
  5. DEPENDS = "openssl zlib curl ca-certificates libssh2"
  6. LIC_FILES_CHKSUM = " \
  7. file://LICENSE-MIT;md5=b377b220f43d747efdec40d69fcaa69d \
  8. file://LICENSE-APACHE;md5=71b224ca933f0676e26d5c2e2271331c \
  9. file://LICENSE-THIRD-PARTY;md5=f257ad009884cb88a3a87d6920e7180a \
  10. "
  11. require rust-source.inc
  12. require rust-snapshot.inc
  13. S = "${RUSTSRC}/src/tools/cargo"
  14. CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor"
  15. inherit cargo pkgconfig
  16. DEBUG_PREFIX_MAP += "-fdebug-prefix-map=${RUSTSRC}/vendor=${TARGET_DBGSRC_DIR}"
  17. do_cargo_setup_snapshot () {
  18. ${UNPACKDIR}/rust-snapshot-components/${CARGO_SNAPSHOT}/install.sh --prefix="${WORKDIR}/${CARGO_SNAPSHOT}" --disable-ldconfig
  19. # Need to use uninative's loader if enabled/present since the library paths
  20. # are used internally by rust and result in symbol mismatches if we don't
  21. if [ ! -z "${UNINATIVE_LOADER}" -a -e "${UNINATIVE_LOADER}" ]; then
  22. patchelf-uninative ${WORKDIR}/${CARGO_SNAPSHOT}/bin/cargo --set-interpreter ${UNINATIVE_LOADER}
  23. fi
  24. }
  25. addtask cargo_setup_snapshot after do_unpack before do_configure
  26. do_cargo_setup_snapshot[dirs] += "${WORKDIR}/${CARGO_SNAPSHOT}"
  27. do_cargo_setup_snapshot[vardepsexclude] += "UNINATIVE_LOADER"
  28. do_compile:prepend () {
  29. export RUSTC_BOOTSTRAP="1"
  30. }
  31. do_install () {
  32. install -d "${D}${bindir}"
  33. install -m 755 "${B}/target/${CARGO_TARGET_SUBDIR}/cargo" "${D}${bindir}"
  34. }
  35. do_install:append:class-nativesdk() {
  36. # To quote the cargo docs, "Cargo also sets the dynamic library path when compiling
  37. # and running binaries with commands like `cargo run` and `cargo test`". Sadly it
  38. # sets to libdir but not base_libdir leading to symbol mismatches depending on the
  39. # host OS. Fully set LD_LIBRARY_PATH to contain both to avoid this.
  40. create_wrapper ${D}/${bindir}/cargo LD_LIBRARY_PATH=${libdir}:${base_libdir}
  41. ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d
  42. mkdir "${ENV_SETUP_DIR}"
  43. CARGO_ENV_SETUP_SH="${ENV_SETUP_DIR}/cargo.sh"
  44. cat <<- EOF > "${CARGO_ENV_SETUP_SH}"
  45. # Keep the below off as long as HTTP/2 is disabled.
  46. export CARGO_HTTP_MULTIPLEXING=false
  47. export CARGO_HTTP_CAINFO="\$OECORE_NATIVE_SYSROOT/etc/ssl/certs/ca-certificates.crt"
  48. EOF
  49. }
  50. FILES:${PN} += "${base_prefix}/environment-setup.d"
  51. # Disabled due to incompatibility with libgit2 0.28.x (https://github.com/rust-lang/git2-rs/issues/458, https://bugs.gentoo.org/707746#c1)
  52. # as shipped by Yocto Dunfell.
  53. # According to https://github.com/rust-lang/git2-rs/issues/458#issuecomment-522567539, there are no compatibility guarantees between
  54. # libgit2-sys and arbitrary system libgit2 versions, so better keep this turned off.
  55. #export LIBGIT2_SYS_USE_PKG_CONFIG = "1"
  56. # Needed for pkg-config to be used
  57. export LIBSSH2_SYS_USE_PKG_CONFIG = "1"
  58. # When building cargo-native we don't have cargo-native to use and depend on,
  59. # so we must use the locally set up snapshot to bootstrap the build.
  60. BASEDEPENDS:remove:class-native = "cargo-native"
  61. CARGO:class-native = "${WORKDIR}/${CARGO_SNAPSHOT}/bin/cargo"
  62. DEPENDS:append:class-nativesdk = " nativesdk-rust"
  63. RUSTLIB:append:class-nativesdk = " -L ${STAGING_DIR_HOST}/${SDKPATHNATIVE}/usr/lib/rustlib/${RUST_HOST_SYS}/lib"
  64. RUSTLIB_DEP:class-nativesdk = ""
  65. BBCLASSEXTEND = "native nativesdk"