Gentoo Archives: gentoo-soc

From: "André Erdmann" <dywi@×××××××.de>
To: Nicolas Sebrecht <nicolas.s-dev@×××××××.net>
Cc: rafaelmartins@g.o, Denis Dupeyron <calchan@g.o>, gentoo-soc <gentoo-soc@l.g.o>
Subject: [gentoo-soc] Re: [GSoC] The macros in your proposal
Date: Fri, 01 Apr 2016 16:48:32
Message-Id: CAGrucu17s1B4ibw1hVQvayVqFQYeB3qXCegBcFSn-iVzGNzekw@mail.gmail.com
In Reply to: [gentoo-soc] [GSoC] The macros in your proposal by Nicolas Sebrecht
1 Hi Nicolas,
2
3 2016-03-31 0:13 GMT+02:00 Nicolas Sebrecht <nicolas.s-dev@×××××××.net>:
4 > Hi André,
5 >
6 > I'm mentor in the Gentoo org and I'd like to know more on your proposal.
7 >
8 > You intend to introduce a macro system in the soft and make it quite
9 > central. Did you consider using a (mini-) DSL (based on Python) instead?
10 >
11 > What would be the pros and cons for both?
12 >
13
14 The term 'macro', as I've used it in my proposal, might be a bit misleading.
15 It just means "statement that expands to something (that is usually bigger)".
16
17 An external DSL is exactly what I have planned.
18
19 Basic instructions would be very simple in this language::
20
21 <statement> # <effective decision(s)>
22
23 enable A [A'...] # CONFIG_A={y}[, CONFIG_A'={y} ...]
24 module B # CONFIG_B={m}
25 disable C # CONFIG_C={n} ("# CONFIG_C is not set")
26
27 enable-or-module D # CONFIG_D={y,m}
28 include <name|file> # expands to statements from <name|file>
29 exclude <name|file> # expands to statements from <name|file>, negated
30
31 The first group of instructions exists already in the original project [0],
32 and I assume tristate-type kconfig symbols in this and the following examples.
33
34 The left side ("<statemtent>") is what users write(*),
35 and the right side reflects the "immediate" decisions made by the program.
36 Immediate insofar as user decisions need to be propagated,
37 if B={m} and B depends on P, then P must be y or m.
38 And if P depends on C and C={n} due to user decision,
39 then no kernel configuration can be created because of a conflict
40 (C = C_user & C_P = {y,m} & {n} = {}, no decision can be made).
41 But that's a different subject I'm going to address during the first weeks
42 (probably with an AC-3-inspired algorithm).
43
44 (*) usually in the "[options]" section of the settings ini file,
45 which will then become an ini-alike file, because the
46 "<statements>" don't need to adhere to the ini format
47
48
49 However, I plan to add conditional statements,
50 which is where the language gets a bit more complex::
51
52 <statement> [<postfix condition>]
53
54 # A={y} if the kconfig symbol A is defined,
55 # and B={y} otherwise (in which case the kconfig symbol B has to be known)
56 enable A if exists
57 enable B if not ^above
58
59 # C={y}, depending on kernel release version and architecture
60 enable C if kver >= 3 and arch == x86_64
61
62 # D={y} if any modalias identifier matches, else leave D unmodified
63 enable D if modalias-match pci:... pci:...
64
65 # E={y} if compound condition matches, else leave E unmodified
66 enable E if $some_parameter == "value" [and (...) or (...)]
67
68 which is why I would implement a parser with ply or pyparsing.
69
70 The main use case of the conditional statements are files that get included
71 via the "include"/"exclude" instructions in the settings file.
72 These files - I called them "macro files" or "feature set" files
73 in the proposal - originate from various sources:
74
75 * kernelconfig itself, in the form of:
76
77 * hardware detection, a generated "enable _ if modalias-match _"
78 feature set file
79
80 * commonly used config option blocks,
81 e.g. an "I/O scheduler" feature set that prefers BFQ if that exists,
82 and falls back to CFQ otherwise
83
84 * package management,
85 either generated from CONFIG_CHECK,
86 or written by package maintainers/contributors
87 ("better", because it'd be more accurate)
88
89 None of these sources involve end users directly, so it would be possible
90 to use a different language here (say, XML or even Python) and restrict
91 the settings file to basic instructions only, but I like the idea of having
92 a uniform method, which would also make user contributions easier.
93
94 I hope that answers your questions and provides a better insight into the
95 project ;-)
96
97
98 Regards,
99 André Erdmann
100
101 [0] https://github.com/Calchan/kernelconfig