* [gentoo-dev] [PATCH 1/2] cargo.eclass: allow passing additional arguments to cargo
@ 2019-01-07 4:01 Georgy Yakovlev
2019-01-07 4:01 ` [gentoo-dev] [PATCH 2/2] cargo.eclass: add standard src_test Georgy Yakovlev
2019-01-07 7:27 ` [gentoo-dev] [PATCH 1/2] cargo.eclass: allow passing additional arguments to cargo Ulrich Mueller
0 siblings, 2 replies; 5+ messages in thread
From: Georgy Yakovlev @ 2019-01-07 4:01 UTC (permalink / raw
To: gentoo-dev; +Cc: Georgy Yakovlev
for example:
src_compile() {
cargo_src_compile $(usex pcre "--features pcre2" "")"
}
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
---
Some packages just copy cargo_src_install and add custom arguments.
This change will allow just passing arguments to cargo_src_* instead.
eclass/cargo.eclass | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index 50f7830c51b..ee17f2af9d9 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -1,142 +1,142 @@
-# Copyright 1999-2018 Gentoo Authors
+# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: cargo.eclass
# @MAINTAINER:
# rust@gentoo.org
# @AUTHOR:
# Doug Goldstein <cardoe@gentoo.org>
# @SUPPORTED_EAPIS: 6 7
# @BLURB: common functions and variables for cargo builds
if [[ -z ${_CARGO_ECLASS} ]]; then
_CARGO_ECLASS=1
CARGO_DEPEND=""
[[ ${CATEGORY}/${PN} != dev-util/cargo ]] && CARGO_DEPEND="virtual/cargo"
case ${EAPI} in
6) DEPEND="${CARGO_DEPEND}";;
7) BDEPEND="${CARGO_DEPEND}";;
*) die "EAPI=${EAPI:-0} is not supported" ;;
esac
inherit multiprocessing
EXPORT_FUNCTIONS src_unpack src_compile src_install
IUSE="${IUSE} debug"
ECARGO_HOME="${WORKDIR}/cargo_home"
ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
# @FUNCTION: cargo_crate_uris
# @DESCRIPTION:
# Generates the URIs to put in SRC_URI to help fetch dependencies.
cargo_crate_uris() {
local crate
for crate in "$@"; do
local name version url pretag
name="${crate%-*}"
version="${crate##*-}"
pretag="^[a-zA-Z]+"
if [[ $version =~ $pretag ]]; then
version="${name##*-}-${version}"
name="${name%-*}"
fi
url="https://crates.io/api/v1/crates/${name}/${version}/download -> ${crate}.crate"
echo "${url}"
done
}
# @FUNCTION: cargo_src_unpack
# @DESCRIPTION:
# Unpacks the package and the cargo registry
cargo_src_unpack() {
debug-print-function ${FUNCNAME} "$@"
mkdir -p "${ECARGO_VENDOR}" || die
mkdir -p "${S}" || die
local archive shasum pkg
for archive in ${A}; do
case "${archive}" in
*.crate)
ebegin "Loading ${archive} into Cargo registry"
tar -xf "${DISTDIR}"/${archive} -C "${ECARGO_VENDOR}/" || die
# generate sha256sum of the crate itself as cargo needs this
shasum=$(sha256sum "${DISTDIR}"/${archive} | cut -d ' ' -f 1)
pkg=$(basename ${archive} .crate)
cat <<- EOF > ${ECARGO_VENDOR}/${pkg}/.cargo-checksum.json
{
"package": "${shasum}",
"files": {}
}
EOF
# if this is our target package we need it in ${WORKDIR} too
# to make ${S} (and handle any revisions too)
if [[ ${P} == ${pkg}* ]]; then
tar -xf "${DISTDIR}"/${archive} -C "${WORKDIR}" || die
fi
eend $?
;;
cargo-snapshot*)
ebegin "Unpacking ${archive}"
mkdir -p "${S}"/target/snapshot
tar -xzf "${DISTDIR}"/${archive} -C "${S}"/target/snapshot --strip-components 2 || die
# cargo's makefile needs this otherwise it will try to
# download it
touch "${S}"/target/snapshot/bin/cargo || die
eend $?
;;
*)
unpack ${archive}
;;
esac
done
cargo_gen_config
}
# @FUNCTION: cargo_gen_config
# @DESCRIPTION:
# Generate the $CARGO_HOME/config necessary to use our local registry
cargo_gen_config() {
debug-print-function ${FUNCNAME} "$@"
cat <<- EOF > "${ECARGO_HOME}/config"
[source.gentoo]
directory = "${ECARGO_VENDOR}"
[source.crates-io]
replace-with = "gentoo"
local-registry = "/nonexistant"
EOF
}
# @FUNCTION: cargo_src_compile
# @DESCRIPTION:
# Build the package using cargo build
cargo_src_compile() {
debug-print-function ${FUNCNAME} "$@"
export CARGO_HOME="${ECARGO_HOME}"
- cargo build -j $(makeopts_jobs) $(usex debug "" --release) \
+ cargo build -j $(makeopts_jobs) $(usex debug "" --release) "${@}" \
|| die "cargo build failed"
}
# @FUNCTION: cargo_src_install
# @DESCRIPTION:
# Installs the binaries generated by cargo
cargo_src_install() {
debug-print-function ${FUNCNAME} "$@"
- cargo install -j $(makeopts_jobs) --root="${D}/usr" $(usex debug --debug "") \
+ cargo install -j $(makeopts_jobs) --root="${D}/usr" $(usex debug --debug "") "${@}" \
|| die "cargo install failed"
rm -f "${D}/usr/.crates.toml"
[ -d "${S}/man" ] && doman "${S}/man" || return 0
}
fi
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-dev] [PATCH 2/2] cargo.eclass: add standard src_test
2019-01-07 4:01 [gentoo-dev] [PATCH 1/2] cargo.eclass: allow passing additional arguments to cargo Georgy Yakovlev
@ 2019-01-07 4:01 ` Georgy Yakovlev
2019-01-07 7:27 ` [gentoo-dev] [PATCH 1/2] cargo.eclass: allow passing additional arguments to cargo Ulrich Mueller
1 sibling, 0 replies; 5+ messages in thread
From: Georgy Yakovlev @ 2019-01-07 4:01 UTC (permalink / raw
To: gentoo-dev; +Cc: Georgy Yakovlev
But not set IUSE=test by default
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
This is pretty straightforward change, just adds standard src_test for
cargo
---
eclass/cargo.eclass | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index ee17f2af9d9..c576c8e8066 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -1,142 +1,152 @@
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: cargo.eclass
# @MAINTAINER:
# rust@gentoo.org
# @AUTHOR:
# Doug Goldstein <cardoe@gentoo.org>
# @SUPPORTED_EAPIS: 6 7
# @BLURB: common functions and variables for cargo builds
if [[ -z ${_CARGO_ECLASS} ]]; then
_CARGO_ECLASS=1
CARGO_DEPEND=""
[[ ${CATEGORY}/${PN} != dev-util/cargo ]] && CARGO_DEPEND="virtual/cargo"
case ${EAPI} in
6) DEPEND="${CARGO_DEPEND}";;
7) BDEPEND="${CARGO_DEPEND}";;
*) die "EAPI=${EAPI:-0} is not supported" ;;
esac
inherit multiprocessing
-EXPORT_FUNCTIONS src_unpack src_compile src_install
+EXPORT_FUNCTIONS src_unpack src_compile src_install src_test
IUSE="${IUSE} debug"
ECARGO_HOME="${WORKDIR}/cargo_home"
ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
# @FUNCTION: cargo_crate_uris
# @DESCRIPTION:
# Generates the URIs to put in SRC_URI to help fetch dependencies.
cargo_crate_uris() {
local crate
for crate in "$@"; do
local name version url pretag
name="${crate%-*}"
version="${crate##*-}"
pretag="^[a-zA-Z]+"
if [[ $version =~ $pretag ]]; then
version="${name##*-}-${version}"
name="${name%-*}"
fi
url="https://crates.io/api/v1/crates/${name}/${version}/download -> ${crate}.crate"
echo "${url}"
done
}
# @FUNCTION: cargo_src_unpack
# @DESCRIPTION:
# Unpacks the package and the cargo registry
cargo_src_unpack() {
debug-print-function ${FUNCNAME} "$@"
mkdir -p "${ECARGO_VENDOR}" || die
mkdir -p "${S}" || die
local archive shasum pkg
for archive in ${A}; do
case "${archive}" in
*.crate)
ebegin "Loading ${archive} into Cargo registry"
tar -xf "${DISTDIR}"/${archive} -C "${ECARGO_VENDOR}/" || die
# generate sha256sum of the crate itself as cargo needs this
shasum=$(sha256sum "${DISTDIR}"/${archive} | cut -d ' ' -f 1)
pkg=$(basename ${archive} .crate)
cat <<- EOF > ${ECARGO_VENDOR}/${pkg}/.cargo-checksum.json
{
"package": "${shasum}",
"files": {}
}
EOF
# if this is our target package we need it in ${WORKDIR} too
# to make ${S} (and handle any revisions too)
if [[ ${P} == ${pkg}* ]]; then
tar -xf "${DISTDIR}"/${archive} -C "${WORKDIR}" || die
fi
eend $?
;;
cargo-snapshot*)
ebegin "Unpacking ${archive}"
mkdir -p "${S}"/target/snapshot
tar -xzf "${DISTDIR}"/${archive} -C "${S}"/target/snapshot --strip-components 2 || die
# cargo's makefile needs this otherwise it will try to
# download it
touch "${S}"/target/snapshot/bin/cargo || die
eend $?
;;
*)
unpack ${archive}
;;
esac
done
cargo_gen_config
}
# @FUNCTION: cargo_gen_config
# @DESCRIPTION:
# Generate the $CARGO_HOME/config necessary to use our local registry
cargo_gen_config() {
debug-print-function ${FUNCNAME} "$@"
cat <<- EOF > "${ECARGO_HOME}/config"
[source.gentoo]
directory = "${ECARGO_VENDOR}"
[source.crates-io]
replace-with = "gentoo"
local-registry = "/nonexistant"
EOF
}
# @FUNCTION: cargo_src_compile
# @DESCRIPTION:
# Build the package using cargo build
cargo_src_compile() {
debug-print-function ${FUNCNAME} "$@"
export CARGO_HOME="${ECARGO_HOME}"
cargo build -j $(makeopts_jobs) $(usex debug "" --release) "${@}" \
|| die "cargo build failed"
}
# @FUNCTION: cargo_src_install
# @DESCRIPTION:
# Installs the binaries generated by cargo
cargo_src_install() {
debug-print-function ${FUNCNAME} "$@"
cargo install -j $(makeopts_jobs) --root="${D}/usr" $(usex debug --debug "") "${@}" \
|| die "cargo install failed"
rm -f "${D}/usr/.crates.toml"
[ -d "${S}/man" ] && doman "${S}/man" || return 0
}
+# @FUNCTION: cargo_src_test
+# @DESCRIPTION:
+# Test the package using cargo test
+cargo_src_test() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ cargo test -j $(makeopts_jobs) $(usex debug "" --release) "${@}" \
+ || die "cargo test failed"
+}
+
fi
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [gentoo-dev] [PATCH 1/2] cargo.eclass: allow passing additional arguments to cargo
2019-01-07 4:01 [gentoo-dev] [PATCH 1/2] cargo.eclass: allow passing additional arguments to cargo Georgy Yakovlev
2019-01-07 4:01 ` [gentoo-dev] [PATCH 2/2] cargo.eclass: add standard src_test Georgy Yakovlev
@ 2019-01-07 7:27 ` Ulrich Mueller
2019-01-07 20:33 ` Georgy Yakovlev
1 sibling, 1 reply; 5+ messages in thread
From: Ulrich Mueller @ 2019-01-07 7:27 UTC (permalink / raw
To: Georgy Yakovlev; +Cc: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 643 bytes --]
>>>>> On Mon, 07 Jan 2019, Georgy Yakovlev wrote:
> cargo_src_compile() {
> debug-print-function ${FUNCNAME} "$@"
>
> export CARGO_HOME="${ECARGO_HOME}"
>
> - cargo build -j $(makeopts_jobs) $(usex debug "" --release) \
> + cargo build -j $(makeopts_jobs) $(usex debug "" --release) "${@}" \
Keep constistent style, "$@" is without braces just above.
> cargo_src_install() {
> debug-print-function ${FUNCNAME} "$@"
>
> - cargo install -j $(makeopts_jobs) --root="${D}/usr" $(usex debug --debug "") \
> + cargo install -j $(makeopts_jobs) --root="${D}/usr" $(usex debug --debug "") "${@}" \
Ditto.
Ulrich
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [gentoo-dev] [PATCH 1/2] cargo.eclass: allow passing additional arguments to cargo
2019-01-07 7:27 ` [gentoo-dev] [PATCH 1/2] cargo.eclass: allow passing additional arguments to cargo Ulrich Mueller
@ 2019-01-07 20:33 ` Georgy Yakovlev
2019-01-07 20:33 ` [gentoo-dev] [PATCH 2/2] cargo.eclass: add standard src_test Georgy Yakovlev
0 siblings, 1 reply; 5+ messages in thread
From: Georgy Yakovlev @ 2019-01-07 20:33 UTC (permalink / raw
To: gentoo-dev; +Cc: Georgy Yakovlev
for example:
src_compile() {
cargo_src_compile $(usex pcre "--features pcre2" "")"
}
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
---
eclass/cargo.eclass | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index 50f7830c51b..06c85ce9de8 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2018 Gentoo Authors
+# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: cargo.eclass
@@ -122,7 +122,7 @@ cargo_src_compile() {
export CARGO_HOME="${ECARGO_HOME}"
- cargo build -j $(makeopts_jobs) $(usex debug "" --release) \
+ cargo build -j $(makeopts_jobs) $(usex debug "" --release) "$@" \
|| die "cargo build failed"
}
@@ -132,7 +132,7 @@ cargo_src_compile() {
cargo_src_install() {
debug-print-function ${FUNCNAME} "$@"
- cargo install -j $(makeopts_jobs) --root="${D}/usr" $(usex debug --debug "") \
+ cargo install -j $(makeopts_jobs) --root="${D}/usr" $(usex debug --debug "") "$@" \
|| die "cargo install failed"
rm -f "${D}/usr/.crates.toml"
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-dev] [PATCH 2/2] cargo.eclass: add standard src_test
2019-01-07 20:33 ` Georgy Yakovlev
@ 2019-01-07 20:33 ` Georgy Yakovlev
0 siblings, 0 replies; 5+ messages in thread
From: Georgy Yakovlev @ 2019-01-07 20:33 UTC (permalink / raw
To: gentoo-dev; +Cc: Georgy Yakovlev
But not set IUSE=test by default
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
---
eclass/cargo.eclass | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index 06c85ce9de8..051d5c499a6 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -23,7 +23,7 @@ esac
inherit multiprocessing
-EXPORT_FUNCTIONS src_unpack src_compile src_install
+EXPORT_FUNCTIONS src_unpack src_compile src_install src_test
IUSE="${IUSE} debug"
@@ -139,4 +139,14 @@ cargo_src_install() {
[ -d "${S}/man" ] && doman "${S}/man" || return 0
}
+# @FUNCTION: cargo_src_test
+# @DESCRIPTION:
+# Test the package using cargo test
+cargo_src_test() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ cargo test -j $(makeopts_jobs) $(usex debug "" --release) "$@" \
+ || die "cargo test failed"
+}
+
fi
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-07 20:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-07 4:01 [gentoo-dev] [PATCH 1/2] cargo.eclass: allow passing additional arguments to cargo Georgy Yakovlev
2019-01-07 4:01 ` [gentoo-dev] [PATCH 2/2] cargo.eclass: add standard src_test Georgy Yakovlev
2019-01-07 7:27 ` [gentoo-dev] [PATCH 1/2] cargo.eclass: allow passing additional arguments to cargo Ulrich Mueller
2019-01-07 20:33 ` Georgy Yakovlev
2019-01-07 20:33 ` [gentoo-dev] [PATCH 2/2] cargo.eclass: add standard src_test Georgy Yakovlev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox