1 |
On Mon, 2018-10-15 at 21:41 +0200, Dirkjan Ochtman wrote: |
2 |
> Signed-off-by: Dirkjan Ochtman <djc@g.o> |
3 |
> --- |
4 |
> eclass/rust-toolchain.eclass | 120 +++++++++++++++++++++++++++++++++++ |
5 |
> 1 file changed, 120 insertions(+) |
6 |
> create mode 100644 eclass/rust-toolchain.eclass |
7 |
|
8 |
I'm sorry that I haven't managed to find time to review this in 3 days. |
9 |
|
10 |
> |
11 |
> diff --git a/eclass/rust-toolchain.eclass b/eclass/rust-toolchain.eclass |
12 |
> new file mode 100644 |
13 |
> index 00000000000..d09db264fc3 |
14 |
> --- /dev/null |
15 |
> +++ b/eclass/rust-toolchain.eclass |
16 |
> @@ -0,0 +1,120 @@ |
17 |
> +# Copyright 1999-2018 Gentoo Foundation |
18 |
> +# Distributed under the terms of the GNU General Public License v2 |
19 |
> + |
20 |
> +# @ECLASS: rust-toolchain.eclass |
21 |
> +# @MAINTAINER: |
22 |
> +# Rust Project <rust@g.o> |
23 |
> +# @SUPPORTED_EAPIS: 6 |
24 |
|
25 |
This doesn't match the conditional below... |
26 |
|
27 |
> +# @BLURB: helps map gentoo arches to rust ABIs |
28 |
> +# @DESCRIPTION: |
29 |
> +# This eclass contains a src_unpack default phase function, and |
30 |
> +# helper functions, to aid in proper rust-ABI handling for various |
31 |
> +# gentoo arches. |
32 |
> + |
33 |
> +case ${EAPI} in |
34 |
> + 6) : ;; |
35 |
> + 7) : ;; |
36 |
|
37 |
...which permits 6 and 7. |
38 |
|
39 |
> + *) die "EAPI=${EAPI:-0} is not supported" ;; |
40 |
> +esac |
41 |
> + |
42 |
> +inherit multilib-build |
43 |
> + |
44 |
> +# @ECLASS-VARIABLE: RUST_TOOLCHAIN_BASEURL |
45 |
> +# @DESCRIPTION: |
46 |
> +# This variable specifies the base URL used by the |
47 |
> +# rust_arch_uri and rust_all_arch_uris functions when |
48 |
> +# generating the URI output list. |
49 |
> +: ${RUST_TOOLCHAIN_BASEURL:=https://static.rust-lang.org/dist/} |
50 |
> + |
51 |
> +# @FUNCTION: rust_abi |
52 |
> +# @USAGE: [CHOST-value] |
53 |
> +# @DESCRIPTION: |
54 |
> +# Outputs the Rust ABI name from a CHOST value, uses CHOST in the |
55 |
> +# environment if none is specified. |
56 |
> + |
57 |
> +rust_abi() { |
58 |
> + local CTARGET=${1:-${CHOST}} |
59 |
|
60 |
You're mixing tab and space indent. |
61 |
|
62 |
> + case ${CTARGET%%*-} in |
63 |
> + aarch64*) echo aarch64-unknown-linux-gnu;; |
64 |
> + mips64*) echo mips64-unknown-linux-gnuabi64;; |
65 |
> + powerpc64le*) echo powerpc64le-unknown-linux-gnu;; |
66 |
> + powerpc64*) echo powerpc64-unknown-linux-gnu;; |
67 |
> + x86_64*) echo x86_64-unknown-linux-gnu;; |
68 |
> + armv6j*s*) echo arm-unknown-linux-gnueabi;; |
69 |
|
70 |
Substring match for a single letter is a horrible idea. It even fails |
71 |
with one of standard CHOSTs we have: armv6j-unknown-linux-musleabihf. |
72 |
|
73 |
> + armv6j*h*) echo arm-unknown-linux-gnueabihf;; |
74 |
> + armv7a*h*) echo armv7-unknown-linux-gnueabihf;; |
75 |
> + i?86*) echo i686-unknown-linux-gnu;; |
76 |
> + mipsel*) echo mipsel-unknown-linux-gnu;; |
77 |
> + mips*) echo mips-unknown-linux-gnu;; |
78 |
> + powerpc*) echo powerpc-unknown-linux-gnu;; |
79 |
> + s390x*) echo s390x-unknown-linux-gnu;; |
80 |
> + *) echo ${CTARGET};; |
81 |
> + esac |
82 |
> +} |
83 |
> + |
84 |
> +# @FUNCTION: rust_all_abis |
85 |
> +# @DESCRIPTION: |
86 |
> +# Outputs a list of all the enabled Rust ABIs |
87 |
> +rust_all_abis() { |
88 |
> + if use multilib; then |
89 |
|
90 |
USE=multilib is deprecated. Any new packages should be using ABI_* |
91 |
flags directly. |
92 |
|
93 |
> + local abi |
94 |
> + local ALL_ABIS=() |
95 |
> + for abi in $(multilib_get_enabled_abis); do |
96 |
|
97 |
In fact, to what purpose are you inheriting multilib-build if you |
98 |
completely ignore the new API and instead use obsolete multilib.eclass |
99 |
functions directly? |
100 |
|
101 |
> + ALL_ABIS+=( $(rust_abi $(get_abi_CHOST ${abi})) ) |
102 |
> + done |
103 |
> + local abi_list |
104 |
> + IFS=, eval 'abi_list=${ALL_ABIS[*]}' |
105 |
|
106 |
The 'eval' here is absolutely unnecessary: |
107 |
|
108 |
local IFS=, |
109 |
echo "${ALL_ABIS[*]}" |
110 |
|
111 |
> + echo ${abi_list} |
112 |
> + else |
113 |
> + rust_abi |
114 |
> + fi |
115 |
> +} |
116 |
> + |
117 |
> +# @FUNCTION: rust_arch_uri |
118 |
> +# @USAGE: <rust-ABI> <base-uri> [alt-distfile-basename] |
119 |
> +# @DESCRIPTION: |
120 |
> +# Output the URI for use in SRC_URI, combining $RUST_TOOLCHAIN_BASEURL |
121 |
> +# and the URI suffix provided in ARG2 with the rust ABI in ARG1, and |
122 |
> +# optionally renaming to the distfile basename specified in ARG3. |
123 |
|
124 |
Why are you using ARGn when you explicitly named the parameters above? |
125 |
|
126 |
> +# |
127 |
> +# @EXAMPLE: |
128 |
> +# SRC_URI="amd64? ( |
129 |
> +# $(rust_arch_uri x86_64-unknown-linux-gnu rustc-${STAGE0_VERSION}) |
130 |
> +# )" |
131 |
> +# |
132 |
> +rust_arch_uri() { |
133 |
> + if [ -n "$3" ]; then |
134 |
|
135 |
Always use [[ ... ]] in bash. |
136 |
|
137 |
> + echo "${RUST_TOOLCHAIN_BASEURL}${2}-${1}.tar.gz -> ${3}-${1}.tar.gz" |
138 |
> + else |
139 |
> + echo "${RUST_TOOLCHAIN_BASEURL}${2}-${1}.tar.gz" |
140 |
|
141 |
Why not make this common, and just append "-> ..." when [[ -n ${3} ]]? |
142 |
|
143 |
> + fi |
144 |
> +} |
145 |
> + |
146 |
> +# @FUNCTION: rust_all_arch_uris |
147 |
> +# @USAGE <base-uri> [alt-distfile-basename] |
148 |
> +# @DESCRIPTION: |
149 |
> +# Outputs the URIs for SRC_URI to help fetch dependencies, using a base URI |
150 |
> +# provided as an argument. Optionally allows for distfile renaming via a specified |
151 |
> +# basename. |
152 |
> +# |
153 |
> +# @EXAMPLE: |
154 |
> +# SRC_URI="$(rust_all_arch_uris rustc-${STAGE0_VERSION})" |
155 |
> +# |
156 |
> +rust_all_arch_uris() |
157 |
> +{ |
158 |
> + local uris="" |
159 |
> + uris+="amd64? ( $(rust_arch_uri x86_64-unknown-linux-gnu "$@") ) " |
160 |
> + uris+="arm? ( $(rust_arch_uri arm-unknown-linux-gnueabi "$@") |
161 |
> + $(rust_arch_uri arm-unknown-linux-gnueabihf "$@") |
162 |
> + $(rust_arch_uri armv7-unknown-linux-gnueabihf "$@") ) " |
163 |
> + uris+="arm64? ( $(rust_arch_uri aarch64-unknown-linux-gnu "$@") ) " |
164 |
> + uris+="mips? ( $(rust_arch_uri mips-unknown-linux-gnu "$@") |
165 |
> + $(rust_arch_uri mipsel-unknown-linux-gnu "$@") |
166 |
> + $(rust_arch_uri mips64-unknown-linux-gnuabi64 "$@") ) " |
167 |
> + uris+="ppc? ( $(rust_arch_uri powerpc-unknown-linux-gnu "$@") ) " |
168 |
> + uris+="ppc64? ( $(rust_arch_uri powerpc64-unknown-linux-gnu "$@") |
169 |
> + $(rust_arch_uri powerpc64le-unknown-linux-gnu "$@") ) " |
170 |
> + uris+="s390? ( $(rust_arch_uri s390x-unknown-linux-gnu "$@") ) " |
171 |
> + uris+="x86? ( $(rust_arch_uri i686-unknown-linux-gnu "$@") ) " |
172 |
> + echo "${uris}" |
173 |
> +} |
174 |
|
175 |
How are you going to deal with future versions having more/less |
176 |
variants? |
177 |
|
178 |
-- |
179 |
Best regards, |
180 |
Michał Górny |