Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: vapier@g.o, tools-portage@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 1/2] app-portage/eclass-manpages: Introduce additional variable classes
Date: Fri, 28 Apr 2017 14:59:50
Message-Id: 20170428145931.26090-1-mgorny@gentoo.org
1 Add a few additional variable classes to better emphasize the specifics
2 of different kinds of variables set for eclasses, and by eclasses.
3
4 The change applied, each eclass variable can belong to one of
5 the following five eclasses:
6
7 1. (default) - variable set by ebuild, influences eclass behavior.
8
9 2. @PRE-INHERIT - likewise but must be set above the inherit line,
10 and not modified afterwards.
11
12 3. @USER-VARIABLE - variable to be set by user (make.conf), and not
13 by ebuilds. This mostly involves MAKEOPTS-style variables.
14
15 4. @OUTPUT-VARIABLE - variable that is generated and defined by eclass,
16 and ebuilds can *read* it.
17
18 5. @INTERNAL - (existing) internal use variable.
19 ---
20 .../eclass-manpages/files/eclass-to-manpage.awk | 32 ++++++++++++++++++++--
21 1 file changed, 29 insertions(+), 3 deletions(-)
22
23 diff --git a/app-portage/eclass-manpages/files/eclass-to-manpage.awk b/app-portage/eclass-manpages/files/eclass-to-manpage.awk
24 index 681a567af043..56847930ff35 100644
25 --- a/app-portage/eclass-manpages/files/eclass-to-manpage.awk
26 +++ b/app-portage/eclass-manpages/files/eclass-to-manpage.awk
27 @@ -37,8 +37,9 @@
28
29 # The format of function-specific variables:
30 # @VARIABLE: foo
31 +# [@USER-VARIABLE] (set in make.conf, not ebuilds)
32 +# [@INTERNAL] (internal eclass use variable)
33 # [@DEFAULT-UNSET]
34 -# [@INTERNAL]
35 # [@REQUIRED]
36 # @DESCRIPTION:
37 # <required; blurb about this variable>
38 @@ -46,8 +47,11 @@
39
40 # The format of eclass variables:
41 # @ECLASS-VARIABLE: foo
42 +# [@PRE-INHERIT] (the variable must be set before inheriting the eclass)
43 +# [@USER-VARIABLE] (set in make.conf, not ebuilds)
44 +# [@OUTPUT-VARIABLE] (set by eclass, to be read in ebuilds)
45 +# [@INTERNAL] (internal eclass use variable)
46 # [@DEFAULT-UNSET]
47 -# [@INTERNAL]
48 # [@REQUIRED]
49 # @DESCRIPTION:
50 # <required; blurb about this variable>
51 @@ -279,6 +283,11 @@ function _handle_variable() {
52 internal = 0
53 required = 0
54
55 + # additional variable classes
56 + pre_inherit = 0
57 + user_variable = 0
58 + output_variable = 0
59 +
60 # make sure people haven't specified this before (copy & paste error)
61 if (all_vars[var_name])
62 fail(eclass ": duplicate definition found for variable: " var_name)
63 @@ -297,6 +306,12 @@ function _handle_variable() {
64 internal = 1
65 else if ($2 == "@REQUIRED")
66 required = 1
67 + else if ($2 == "@PRE-INHERIT")
68 + pre_inherit = 1
69 + else if ($2 == "@USER-VARIABLE")
70 + user_variable = 1
71 + else if ($2 == "@OUTPUT-VARIABLE")
72 + output_variable = 1
73 else
74 opts = 0
75 }
76 @@ -314,7 +329,7 @@ function _handle_variable() {
77 regex = "^[[:space:]]*:[[:space:]]*[$]{" var_name ":?=(.*)}"
78 val = gensub(regex, "\\1", 1, $0)
79 if (val == $0) {
80 - if (default_unset + required + internal == 0)
81 + if (default_unset + required + internal + output_variable == 0)
82 warn(var_name ": unable to extract default variable content: " $0)
83 val = ""
84 } else if (val !~ /^["']/ && val ~ / /) {
85 @@ -327,6 +342,17 @@ function _handle_variable() {
86 val = " " op " \\fI" val "\\fR"
87 if (required == 1)
88 val = val " (REQUIRED)"
89 + # TODO: group variables using those classes
90 + if (pre_inherit == 1)
91 + val = val " (SET BEFORE INHERIT)"
92 + if (user_variable == 1)
93 + val = val " (USER VARIABLE)"
94 + if (output_variable == 1)
95 + val = val " (GENERATED BY ECLASS)"
96 +
97 + # check for invalid combos
98 + if (internal + pre_inherit + user_variable + output_variable > 1)
99 + fail(var_name ": multiple variable classes specified")
100
101 if (internal == 1)
102 return ""
103 --
104 2.13.0.rc1

Replies