Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 1 | SUMMARY = "Cargo, a package manager for Rust cross canadian flavor." |
| 2 | |
| 3 | RUST_ALTERNATE_EXE_PATH = "${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config" |
| 4 | |
| 5 | HOST_SYS = "${HOST_ARCH}-unknown-linux-gnu" |
| 6 | CARGO_RUST_TARGET_CCLD = "${RUST_BUILD_CCLD}" |
| 7 | |
| 8 | require recipes-devtools/rust/rust-common.inc |
| 9 | require cargo.inc |
| 10 | |
| 11 | CARGO = "${WORKDIR}/${CARGO_SNAPSHOT}/bin/cargo" |
| 12 | BASEDEPENDS:remove = "cargo-native" |
| 13 | |
| 14 | export RUST_TARGET_PATH="${WORKDIR}/targets/" |
| 15 | |
| 16 | RUSTLIB = " \ |
| 17 | -L ${STAGING_DIR_NATIVE}/${SDKPATHNATIVE}/usr/lib/${TARGET_SYS}/rustlib/${HOST_SYS}/lib \ |
| 18 | " |
| 19 | |
| 20 | DEPENDS += "rust-native \ |
| 21 | rust-cross-canadian-${TRANSLATED_TARGET_ARCH} \ |
| 22 | virtual/nativesdk-${HOST_PREFIX}compilerlibs \ |
| 23 | nativesdk-openssl nativesdk-zlib \ |
| 24 | virtual/nativesdk-libc \ |
| 25 | " |
| 26 | |
| 27 | inherit cross-canadian |
| 28 | |
| 29 | PN = "cargo-cross-canadian-${TRANSLATED_TARGET_ARCH}" |
| 30 | |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 31 | python do_rust_gen_targets () { |
| 32 | wd = d.getVar('WORKDIR') + '/targets/' |
| 33 | |
| 34 | rust_gen_target(d, 'BUILD', wd, "", "generic", d.getVar('BUILD_ARCH')) |
| 35 | rust_gen_target(d, 'HOST', wd, "", "generic", d.getVar('HOST_ARCH')) |
| 36 | } |
| 37 | |
| 38 | do_compile:prepend () { |
| 39 | PKG_CONFIG_PATH="${RECIPE_SYSROOT_NATIVE}/usr/lib/pkgconfig:${PKG_CONFIG_PATH}" |
| 40 | } |
| 41 | |
| 42 | do_install () { |
| 43 | SYS_BINDIR=$(dirname ${D}${bindir}) |
| 44 | install -d "${SYS_BINDIR}" |
| 45 | install -m 755 "${B}/target/${CARGO_TARGET_SUBDIR}/cargo" "${SYS_BINDIR}" |
| 46 | for i in ${SYS_BINDIR}/*; do |
| 47 | chrpath -r "\$ORIGIN/../lib" ${i} |
| 48 | done |
| 49 | |
| 50 | ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d |
| 51 | mkdir "${ENV_SETUP_DIR}" |
| 52 | ENV_SETUP_SH="${ENV_SETUP_DIR}/cargo.sh" |
| 53 | cat <<- EOF > "${ENV_SETUP_SH}" |
| 54 | export CARGO_HOME="\$OECORE_TARGET_SYSROOT/home/cargo" |
| 55 | mkdir -p "\$CARGO_HOME" |
| 56 | # Init the default target once, it might be otherwise user modified. |
| 57 | if [ ! -f "\$CARGO_HOME/config" ]; then |
| 58 | touch "\$CARGO_HOME/config" |
| 59 | echo "[build]" >> "\$CARGO_HOME/config" |
| 60 | echo 'target = "'${TARGET_SYS}'"' >> "\$CARGO_HOME/config" |
| 61 | fi |
| 62 | |
| 63 | # Keep the below off as long as HTTP/2 is disabled. |
| 64 | export CARGO_HTTP_MULTIPLEXING=false |
| 65 | |
| 66 | export CARGO_HTTP_CAINFO="\$OECORE_NATIVE_SYSROOT/etc/ssl/certs/ca-certificates.crt" |
| 67 | EOF |
| 68 | } |
| 69 | |
| 70 | PKG_SYS_BINDIR = "${SDKPATHNATIVE}/usr/bin" |
| 71 | FILES:${PN} += "${base_prefix}/environment-setup.d ${PKG_SYS_BINDIR}" |
| 72 | |