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