1 |
for example: |
2 |
|
3 |
src_compile() { |
4 |
cargo_src_compile $(usex pcre "--features pcre2" "")" |
5 |
} |
6 |
|
7 |
Signed-off-by: Georgy Yakovlev <gyakovlev@g.o> |
8 |
--- |
9 |
Some packages just copy cargo_src_install and add custom arguments. |
10 |
This change will allow just passing arguments to cargo_src_* instead. |
11 |
|
12 |
eclass/cargo.eclass | 6 +++--- |
13 |
1 file changed, 3 insertions(+), 3 deletions(-) |
14 |
|
15 |
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass |
16 |
index 50f7830c51b..ee17f2af9d9 100644 |
17 |
--- a/eclass/cargo.eclass |
18 |
+++ b/eclass/cargo.eclass |
19 |
@@ -1,142 +1,142 @@ |
20 |
-# Copyright 1999-2018 Gentoo Authors |
21 |
+# Copyright 1999-2019 Gentoo Authors |
22 |
# Distributed under the terms of the GNU General Public License v2 |
23 |
|
24 |
# @ECLASS: cargo.eclass |
25 |
# @MAINTAINER: |
26 |
# rust@g.o |
27 |
# @AUTHOR: |
28 |
# Doug Goldstein <cardoe@g.o> |
29 |
# @SUPPORTED_EAPIS: 6 7 |
30 |
# @BLURB: common functions and variables for cargo builds |
31 |
|
32 |
if [[ -z ${_CARGO_ECLASS} ]]; then |
33 |
_CARGO_ECLASS=1 |
34 |
|
35 |
CARGO_DEPEND="" |
36 |
[[ ${CATEGORY}/${PN} != dev-util/cargo ]] && CARGO_DEPEND="virtual/cargo" |
37 |
|
38 |
case ${EAPI} in |
39 |
6) DEPEND="${CARGO_DEPEND}";; |
40 |
7) BDEPEND="${CARGO_DEPEND}";; |
41 |
*) die "EAPI=${EAPI:-0} is not supported" ;; |
42 |
esac |
43 |
|
44 |
inherit multiprocessing |
45 |
|
46 |
EXPORT_FUNCTIONS src_unpack src_compile src_install |
47 |
|
48 |
IUSE="${IUSE} debug" |
49 |
|
50 |
ECARGO_HOME="${WORKDIR}/cargo_home" |
51 |
ECARGO_VENDOR="${ECARGO_HOME}/gentoo" |
52 |
|
53 |
# @FUNCTION: cargo_crate_uris |
54 |
# @DESCRIPTION: |
55 |
# Generates the URIs to put in SRC_URI to help fetch dependencies. |
56 |
cargo_crate_uris() { |
57 |
local crate |
58 |
for crate in "$@"; do |
59 |
local name version url pretag |
60 |
name="${crate%-*}" |
61 |
version="${crate##*-}" |
62 |
pretag="^[a-zA-Z]+" |
63 |
if [[ $version =~ $pretag ]]; then |
64 |
version="${name##*-}-${version}" |
65 |
name="${name%-*}" |
66 |
fi |
67 |
url="https://crates.io/api/v1/crates/${name}/${version}/download -> ${crate}.crate" |
68 |
echo "${url}" |
69 |
done |
70 |
} |
71 |
|
72 |
# @FUNCTION: cargo_src_unpack |
73 |
# @DESCRIPTION: |
74 |
# Unpacks the package and the cargo registry |
75 |
cargo_src_unpack() { |
76 |
debug-print-function ${FUNCNAME} "$@" |
77 |
|
78 |
mkdir -p "${ECARGO_VENDOR}" || die |
79 |
mkdir -p "${S}" || die |
80 |
|
81 |
local archive shasum pkg |
82 |
for archive in ${A}; do |
83 |
case "${archive}" in |
84 |
*.crate) |
85 |
ebegin "Loading ${archive} into Cargo registry" |
86 |
tar -xf "${DISTDIR}"/${archive} -C "${ECARGO_VENDOR}/" || die |
87 |
# generate sha256sum of the crate itself as cargo needs this |
88 |
shasum=$(sha256sum "${DISTDIR}"/${archive} | cut -d ' ' -f 1) |
89 |
pkg=$(basename ${archive} .crate) |
90 |
cat <<- EOF > ${ECARGO_VENDOR}/${pkg}/.cargo-checksum.json |
91 |
{ |
92 |
"package": "${shasum}", |
93 |
"files": {} |
94 |
} |
95 |
EOF |
96 |
# if this is our target package we need it in ${WORKDIR} too |
97 |
# to make ${S} (and handle any revisions too) |
98 |
if [[ ${P} == ${pkg}* ]]; then |
99 |
tar -xf "${DISTDIR}"/${archive} -C "${WORKDIR}" || die |
100 |
fi |
101 |
eend $? |
102 |
;; |
103 |
cargo-snapshot*) |
104 |
ebegin "Unpacking ${archive}" |
105 |
mkdir -p "${S}"/target/snapshot |
106 |
tar -xzf "${DISTDIR}"/${archive} -C "${S}"/target/snapshot --strip-components 2 || die |
107 |
# cargo's makefile needs this otherwise it will try to |
108 |
# download it |
109 |
touch "${S}"/target/snapshot/bin/cargo || die |
110 |
eend $? |
111 |
;; |
112 |
*) |
113 |
unpack ${archive} |
114 |
;; |
115 |
esac |
116 |
done |
117 |
|
118 |
cargo_gen_config |
119 |
} |
120 |
|
121 |
# @FUNCTION: cargo_gen_config |
122 |
# @DESCRIPTION: |
123 |
# Generate the $CARGO_HOME/config necessary to use our local registry |
124 |
cargo_gen_config() { |
125 |
debug-print-function ${FUNCNAME} "$@" |
126 |
|
127 |
cat <<- EOF > "${ECARGO_HOME}/config" |
128 |
[source.gentoo] |
129 |
directory = "${ECARGO_VENDOR}" |
130 |
|
131 |
[source.crates-io] |
132 |
replace-with = "gentoo" |
133 |
local-registry = "/nonexistant" |
134 |
EOF |
135 |
} |
136 |
|
137 |
# @FUNCTION: cargo_src_compile |
138 |
# @DESCRIPTION: |
139 |
# Build the package using cargo build |
140 |
cargo_src_compile() { |
141 |
debug-print-function ${FUNCNAME} "$@" |
142 |
|
143 |
export CARGO_HOME="${ECARGO_HOME}" |
144 |
|
145 |
- cargo build -j $(makeopts_jobs) $(usex debug "" --release) \ |
146 |
+ cargo build -j $(makeopts_jobs) $(usex debug "" --release) "${@}" \ |
147 |
|| die "cargo build failed" |
148 |
} |
149 |
|
150 |
# @FUNCTION: cargo_src_install |
151 |
# @DESCRIPTION: |
152 |
# Installs the binaries generated by cargo |
153 |
cargo_src_install() { |
154 |
debug-print-function ${FUNCNAME} "$@" |
155 |
|
156 |
- cargo install -j $(makeopts_jobs) --root="${D}/usr" $(usex debug --debug "") \ |
157 |
+ cargo install -j $(makeopts_jobs) --root="${D}/usr" $(usex debug --debug "") "${@}" \ |
158 |
|| die "cargo install failed" |
159 |
rm -f "${D}/usr/.crates.toml" |
160 |
|
161 |
[ -d "${S}/man" ] && doman "${S}/man" || return 0 |
162 |
} |
163 |
|
164 |
fi |
165 |
-- |
166 |
2.20.1 |