Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncing cargo glue to ::gentoo circa 2020-01-24 #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions dev-rust/autocfg/autocfg-0.1.6.ebuild
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 Gentoo Authors
# Copyright 2019-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7
Expand All @@ -13,13 +13,14 @@ LICENSE="|| ( MIT Apache-2.0 )"
KEYWORDS="~amd64 ~x86"
IUSE=""

src_prepare() {
rm -vrf examples/ || die
default
}
src_test() {
# Default tests broken by invalid TARGET
# https://github.com/gyakovlev/rust-dev-overlay/issues/3
# # Tests write to ./target and fail if ./target doesn't exist
# mkdir -p target
# rust-crate_src_test

# Alternative to tests given tests fail
ecargo build --all-targets
mkdir -p target
rust-crate_src_test
}
7 changes: 2 additions & 5 deletions dev-rust/autocfg/autocfg-0.1.7.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ src_test() {
# Default tests broken by invalid TARGET
# https://github.com/gyakovlev/rust-dev-overlay/issues/3
# # Tests write to ./target and fail if ./target doesn't exist
# mkdir -p target
# rust-crate_src_test

# Alternative to tests given tests fail
ecargo build --all-targets
mkdir -p target
rust-crate_src_test
}
7 changes: 2 additions & 5 deletions dev-rust/autocfg/autocfg-1.0.0.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ src_test() {
# Default tests broken by invalid TARGET
# https://github.com/gyakovlev/rust-dev-overlay/issues/3
# # Tests write to ./target and fail if ./target doesn't exist
# mkdir -p target
# rust-crate_src_test

# Alternative to tests given tests fail
ecargo build --all-targets
mkdir -p target
rust-crate_src_test
}
39 changes: 33 additions & 6 deletions eclass/rust-crate.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ esac
# dev-dependencies or crates like winapi.
: ${RUST_CRATE_EMPTY:=}

inherit toolchain-funcs
inherit rust-toolchain multiprocessing toolchain-funcs

EXPORT_FUNCTIONS src_unpack src_compile src_configure src_install src_test

Expand Down Expand Up @@ -54,7 +54,7 @@ ecargo() {
addwrite Cargo.lock
rm -f Cargo.lock

cargo -v "${@}" || die
cargo "${@}" || die

# Now remove any Cargo.lock files that cargo pointlessly created.
rm -f Cargo.lock
Expand Down Expand Up @@ -127,7 +127,7 @@ rust-crate_src_configure() {
export CARGO_HOME="${ECARGO_HOME}"
export HOST="${CBUILD}"
export HOST_CC="$(tc-getBUILD_CC)"
export TARGET="${CHOST}"
export TARGET="$(rust_abi)"
export TARGET_CC="$(tc-getCC)"
# https://github.com/rust-lang/pkg-config-rs/issues/41
tc-is-cross-compiler && export PKG_CONFIG_ALLOW_CROSS=1
Expand All @@ -136,7 +136,6 @@ rust-crate_src_configure() {
local rustflags=(
-Cdebuginfo=2
-Copt-level=3
-v
)

use test || rustflags+=( -Cpanic=abort )
Expand Down Expand Up @@ -203,14 +202,42 @@ rust-crate_src_unpack() {
fi
# Set up the cargo config.
mkdir -p "${ECARGO_HOME}"
cargo_gen_config
}

fi

# @FUNCTION: cargo_gen_config
# @DESCRIPTION:
# Generate the $CARGO_HOME/config necessary to use our local registry and settings.
# Cargo can also be configured through environment variables in addition to the TOML syntax below.
# For each configuration key below of the form foo.bar the environment variable CARGO_FOO_BAR
# can also be used to define the value.
# Environment variables will take precedent over TOML configuration,
# and currently only integer, boolean, and string keys are supported.
# For example the build.jobs key can also be defined by CARGO_BUILD_JOBS.
# Or setting CARGO_TERM_VERBOSE=false in make.conf will make build quieter.
cargo_gen_config() {
debug-print-function ${FUNCNAME} "$@"

cat <<- EOF > "${ECARGO_HOME}/config"
[source.gentoo]
directory = "${SYSROOT}${RUST_CRATE_REGISTRY_DIR}"

[source.crates-io]
replace-with = "gentoo"
local-registry = "/nonexistent"
local-registry = "/nonexistant"

[net]
offline = true

[build]
jobs = $(makeopts_jobs)

[term]
verbose = true
EOF
# honor NOCOLOR setting
[[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && echo "color = 'never'" >> "${ECARGO_HOME}/config"
}

fi