Gentoo Archives: gentoo-dev

From: "Amadeusz Żołnowski" <aidecoe@g.o>
To: "Michał Górny" <mgorny@g.o>
Cc: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] rebar.eclass: Build Erlang/OTP projects using dev-util/rebar
Date: Fri, 20 May 2016 23:06:22
Message-Id: 87h9dswcrq.fsf@freja.aidecoe.name
In Reply to: Re: [gentoo-dev] [PATCH] rebar.eclass: Build Erlang/OTP projects using dev-util/rebar by "Michał Górny"
1 Michał Górny <mgorny@g.o> writes:
2 >> +export ERL_LIBS="${EPREFIX}$(get_erl_libs)"
3 >
4 > I think calling get_libdir in global scope is forbidden. You should
5 > really export this somewhere in phase function.
6
7 Fixed.
8
9
10 >> +# @FUNCTION: _find_dep_version
11 >
12 > Namespace it, please. Just in case.
13
14 Fixed.
15
16 >> +_find_dep_version() {
17 >> [...]
18 >> + pushd "${EPREFIX}$(get_erl_libs)" >/dev/null
19 >
20 > || die
21 >
22 > [...]
23 >
24 >> + popd >/dev/null
25 >
26 > || die
27
28 Fixed.
29
30
31 >> +eawk() {
32 >> + local f="$1"; shift
33 >> + local tmpf="$(emktemp)"
34 >
35 > Missing eutils inherit for EAPI 6.
36
37 Fixed.
38
39 >> +# @FUNCTION: erebar
40 >> +# @USAGE: <target>
41 >> +# @DESCRIPTION:
42 >> +# Run rebar with verbose flag. Die on failure.
43 >> +erebar() {
44 >> + debug-print-function ${FUNCNAME} "${@}"
45 >> +
46 >> + rebar -v skip_deps=true "$1" || die "rebar $1 failed"
47 >> +}
48 >
49 > Any reason it doesn't pass all the parameters? This inconsistency with
50 > emake etc. could be mildly confusing, esp. that you don't check for
51 > wrong argc.
52
53 Fixed.
54
55
56 >> +# @FUNCTION: rebar_fix_include_path
57 >> +# @USAGE: <project_name> [<rebar_config>]
58 >> +# @DESCRIPTION:
59 >> +# Fix path in rebar.config to 'include' directory of dependant project/package,
60 >> +# so it points to installation in system Erlang lib rather than relative 'deps'
61 >> +# directory.
62 >> +#
63 >> +# <rebar_config> is optional. Default is 'rebar.config'.
64 >
65 > Is it likely that you would be passing different values to it? Maybe it
66 > would be reasonable to make this an eclass variable.
67
68 Unlikely. But I'd better just remove these parameters rather than
69 defining as eclass variable.
70
71
72 >> + eawk "${rebar_config}" \
73 >> + -v erl_libs="${erl_libs}" -v pn="${pn}" -v pv="${pv}" \
74 >> + '/^{[[:space:]]*erl_opts[[:space:]]*,/, /}[[:space:]]*\.$/ {
75 >> + pattern = "\"(./)?deps/" pn "/include\"";
76 >> + if (match($0, "{i,[[:space:]]*" pattern "[[:space:]]*}")) {
77 >> + sub(pattern, "\"" erl_libs "/" pn "-" pv "/include\"");
78 >> + }
79 >> + print $0;
80 >> + next;
81 >> +}
82 >> +1
83 >> +' || die "failed to fix include paths in ${rebar_config}"
84 >
85 > I suggest you indent this a bit more since it feels like you start at
86 > two tabs and finish at zero.
87
88 How? Add space between "'" and "||" like follows?
89
90 + eawk "${rebar_config}" \
91 ...
92 + print $0;
93 + next;
94 +}
95 +1
96 +' || die "failed to fix include paths in ${rebar_config}"
97
98 It looks a bit weird as well...
99
100
101 >> +# @FUNCTION: rebar_src_prepare
102 >> +# @DESCRIPTION:
103 >> +# Prevent rebar from fetching in compiling dependencies. Set version in project
104 >> +# description file if it's not set.
105 >> +#
106 >> +# Existence of rebar.config is optional, but file description file must exist
107 >> +# at 'src/${PN}.app.src'.
108 >
109 > Wouldn't it be reasonable to make this configurable? Of course, it
110 > might be better to leave it for a possible future extension when
111 > it becomes necessary.
112
113 Which part you mean? 'src/${PN}.app.src'? Fixed: REBAR_APP_SRC eclass var.
114
115 >> +rebar_src_prepare() {
116 >> + debug-print-function ${FUNCNAME} "${@}"
117 >> +
118 >> + rebar_set_vsn
119 >> + [[ -f rebar.config ]] && rebar_remove_deps
120 >> +}
121 >
122 > You're missing obligatory default call for EAPI 6. You should really
123 > test stuff before submitting it.
124
125 Shame I have forgot to test it, sorry. I have completely forgotten about
126 EAPI 6. Fixed - I have made it working with EAPI 6 and dropped EAPI 5.
127
128
129 >> +# @FUNCTION: rebar_src_install
130 >> +# @DESCRIPTION:
131 >> +# Install BEAM files, include headers, executables and native libraries.
132 >> +# Install standard docs like README or defined in DOCS variable. Optionally
133 >
134 > Optionally what? It looks like an unfinished sentence.
135
136 Nothing. (-: Some leftover.
137
138
139 >> +rebar_src_install() {
140 >> + debug-print-function ${FUNCNAME} "${@}"
141 >> +
142 >> + local bin
143 >> + local dest="$(get_erl_libs)/${P}"
144 >> +
145 >> + insinto "${dest}"
146 >> + doins -r ebin
147 >> + [[ -d include ]] && doins -r include
148 >> + [[ -d bin ]] && for bin in bin/*; do dobin "$bin"; done
149 >
150 > Please don't do inlines like this.
151
152 Is there a particular problem with this?
153
154 >> + [[ -d priv ]] && cp -pR priv "${ED}${dest}/"
155 >
156 > This is about preserving executable bits, correct?
157
158 Yes.
159
160 Thanks for review.
161
162 --
163 Amadeusz Żołnowski

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies