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
Changes from 1 commit
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
Next Next commit
rust-crate.eclass: Sync cargo config generation logic
This brings cargo invocation up to par with :gentoo's
cargo.eclass

See:
  gentoo/gentoo@84f8f7e
  gentoo/gentoo@f695ea5
  gentoo/gentoo@a176865
  gentoo/gentoo@8c6a43f
  • Loading branch information
kentfredric committed Mar 30, 2020
commit ae5ab8a3eb926807bcd7536a9cba1e7e64854571
37 changes: 32 additions & 5 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 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 @@ -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