Merge pull request #286 from janderholm/buildseparation
Build separation
This commit is contained in:
@@ -15,16 +15,19 @@ BASEDEPENDS_append = " cargo-native"
|
|||||||
DEPENDS_append_class-target = " virtual/${TARGET_PREFIX}rust ${RUSTLIB_DEP}"
|
DEPENDS_append_class-target = " virtual/${TARGET_PREFIX}rust ${RUSTLIB_DEP}"
|
||||||
DEPENDS_append_class-native = " rust-native"
|
DEPENDS_append_class-native = " rust-native"
|
||||||
|
|
||||||
# Cargo only supports in-tree builds at the moment
|
# Enable build separation
|
||||||
B = "${S}"
|
B = "${WORKDIR}/build"
|
||||||
|
|
||||||
# In case something fails in the build process, give a bit more feedback on
|
# In case something fails in the build process, give a bit more feedback on
|
||||||
# where the issue occured
|
# where the issue occured
|
||||||
export RUST_BACKTRACE = "1"
|
export RUST_BACKTRACE = "1"
|
||||||
|
|
||||||
|
# Assume there's a Cargo.toml directly in the source directory
|
||||||
|
MANIFEST_PATH ??= "${S}/Cargo.toml"
|
||||||
|
|
||||||
RUSTFLAGS ??= ""
|
RUSTFLAGS ??= ""
|
||||||
BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}"
|
BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}"
|
||||||
CARGO_BUILD_FLAGS = "-v --target ${HOST_SYS} ${BUILD_MODE}"
|
CARGO_BUILD_FLAGS = "-v --target ${HOST_SYS} ${BUILD_MODE} --manifest-path=${MANIFEST_PATH}"
|
||||||
|
|
||||||
# This is based on the content of CARGO_BUILD_FLAGS and generally will need to
|
# This is based on the content of CARGO_BUILD_FLAGS and generally will need to
|
||||||
# change if CARGO_BUILD_FLAGS changes.
|
# change if CARGO_BUILD_FLAGS changes.
|
||||||
|
|||||||
@@ -30,48 +30,71 @@ CARGO_VENDORING_DIRECTORY ?= "${CARGO_HOME}/bitbake"
|
|||||||
|
|
||||||
cargo_common_do_configure () {
|
cargo_common_do_configure () {
|
||||||
mkdir -p ${CARGO_HOME}/bitbake
|
mkdir -p ${CARGO_HOME}/bitbake
|
||||||
echo "paths = [" > ${CARGO_HOME}/config
|
|
||||||
|
|
||||||
for p in ${EXTRA_OECARGO_PATHS}; do
|
cat <<- EOF > ${CARGO_HOME}/config
|
||||||
printf "\"%s\"\n" "$p"
|
# EXTRA_OECARGO_PATHS
|
||||||
done | sed -e 's/$/,/' >> ${CARGO_HOME}/config
|
paths = [
|
||||||
echo "]" >> ${CARGO_HOME}/config
|
$(for p in ${EXTRA_OECARGO_PATHS}; do echo \"$p\",; done)
|
||||||
|
]
|
||||||
|
EOF
|
||||||
|
|
||||||
# Point cargo at our local mirror of the registry
|
|
||||||
cat <<- EOF >> ${CARGO_HOME}/config
|
cat <<- EOF >> ${CARGO_HOME}/config
|
||||||
|
|
||||||
|
# Local mirror vendored by bitbake
|
||||||
[source.bitbake]
|
[source.bitbake]
|
||||||
directory = "${CARGO_VENDORING_DIRECTORY}"
|
directory = "${CARGO_VENDORING_DIRECTORY}"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [ -z "${EXTERNALSRC}" ] && [ ${CARGO_DISABLE_BITBAKE_VENDORING} = "0" ]; then
|
if [ -z "${EXTERNALSRC}" ] && [ ${CARGO_DISABLE_BITBAKE_VENDORING} = "0" ]; then
|
||||||
cat <<- EOF >> ${CARGO_HOME}/config
|
cat <<- EOF >> ${CARGO_HOME}/config
|
||||||
|
|
||||||
[source.crates-io]
|
[source.crates-io]
|
||||||
replace-with = "bitbake"
|
replace-with = "bitbake"
|
||||||
local-registry = "/nonexistant"
|
local-registry = "/nonexistant"
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Disable multiplexing in order to keep cargo from using http2, which we
|
cat <<- EOF >> ${CARGO_HOME}/config
|
||||||
# can't currently enable because of dependency loops
|
|
||||||
cat <<- EOF >> ${CARGO_HOME}/config
|
|
||||||
[http]
|
|
||||||
multiplexing = false
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# When a sstate-cache is used sometimes the certificates are not available
|
[http]
|
||||||
# at the compile time path anymore. Set it explicitly instead.
|
# Multiplexing can't be enabled because http2 can't be enabled
|
||||||
echo "cainfo = \"${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt\"" \
|
# in curl-native without dependency loops
|
||||||
>> ${CARGO_HOME}/config
|
multiplexing = false
|
||||||
|
|
||||||
|
# Ignore the hard coded and incorrect path to certificates
|
||||||
|
cainfo = "${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt"
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
if [ -n "${http_proxy}" ]; then
|
if [ -n "${http_proxy}" ]; then
|
||||||
echo "proxy = \"${http_proxy}\"" >> ${CARGO_HOME}/config
|
echo "proxy = \"${http_proxy}\"" >> ${CARGO_HOME}/config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[target.${HOST_SYS}]" >> ${CARGO_HOME}/config
|
cat <<- EOF >> ${CARGO_HOME}/config
|
||||||
echo "linker = '${RUST_TARGET_CCLD}'" >> ${CARGO_HOME}/config
|
|
||||||
|
# HOST_SYS
|
||||||
|
[target.${HOST_SYS}]
|
||||||
|
linker = "${RUST_TARGET_CCLD}"
|
||||||
|
EOF
|
||||||
|
|
||||||
if [ "${HOST_SYS}" != "${BUILD_SYS}" ]; then
|
if [ "${HOST_SYS}" != "${BUILD_SYS}" ]; then
|
||||||
echo "[target.${BUILD_SYS}]" >> ${CARGO_HOME}/config
|
cat <<- EOF >> ${CARGO_HOME}/config
|
||||||
echo "linker = '${RUST_BUILD_CCLD}'" >> ${CARGO_HOME}/config
|
|
||||||
|
# BUILD_SYS
|
||||||
|
[target.${BUILD_SYS}]
|
||||||
|
linker = "${RUST_BUILD_CCLD}"
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Put build output in build directory preferred by bitbake instead of
|
||||||
|
# inside source directory unless they are the same
|
||||||
|
if [ "${B}" != "${S}" ]; then
|
||||||
|
cat <<- EOF >> ${CARGO_HOME}/config
|
||||||
|
|
||||||
|
[build]
|
||||||
|
# Use out of tree build destination to avoid poluting the source tree
|
||||||
|
target-dir = "${B}/target"
|
||||||
|
EOF
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ do_compile_prepend () {
|
|||||||
|
|
||||||
do_install () {
|
do_install () {
|
||||||
install -d "${D}${bindir}"
|
install -d "${D}${bindir}"
|
||||||
install -m 755 "${RUSTSRC}/target/${CARGO_TARGET_SUBDIR}/cargo" "${D}${bindir}"
|
install -m 755 "${B}/target/${CARGO_TARGET_SUBDIR}/cargo" "${D}${bindir}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Disabled due to incompatibility with libgit2 0.28.x (https://github.com/rust-lang/git2-rs/issues/458, https://bugs.gentoo.org/707746#c1)
|
# Disabled due to incompatibility with libgit2 0.28.x (https://github.com/rust-lang/git2-rs/issues/458, https://bugs.gentoo.org/707746#c1)
|
||||||
|
|||||||
Reference in New Issue
Block a user