Repository navigation
Expand file tree
/
Copy pathKconfig.conf
More file actions
77 lines (68 loc) · 3.63 KB
/
Copy pathKconfig.conf
File metadata and controls
77 lines (68 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#
# hpc configuration options: how much of <hpc/conf.h> a build pays for.
#
# In a file of its own for the reason the memory options are (Kconfig.mem): a
# tree that embeds this package sources the same definitions instead of keeping
# a copy of them in step by hand. hpc's own Kconfig sources it where the block
# used to be, so nothing about a standalone hpc build changes.
#
#
# Configuration options. <hpc/conf.h> lets a program declare its knobs once, as
# attributes grouped into sections, and generates the getopt_long() tables, the
# --help text and the sec.attr namespace from that one declaration. The symbol
# below decides how much of it a build pays for.
#
config SECTION
bool "Configuration sections and attribute descriptions"
default y
help
Keep the section names and the attribute descriptions that
<hpc/conf.h> declarations carry, and the code that uses them:
a --help text grouped by section, the <section>.<attribute>
namespace behind -S and conf_set(), the configuration file reader
behind -C, and --dumpconfig.
Say N and none of that is in the binary. The gate is in the
declaration macros themselves, not around the code that reads them:
the section name, the section headline and every attribute's metavar
and description stop being fields of the structures, so the string
literals are never named and never linked. What is left of an
attribute is its long name, its short letter, its target and its
type - exactly what getopt_long() and the value parser need - and
-S, -C and --dumpconfig disappear from the command line with the
machinery behind them.
What does not change is the program: option spellings are declared
verbatim and a section is a namespace, never a prefix, so the command
line is identical either way, and source that compiled with this on
compiles with it off. conf_set(), conf_load() and conf_dump() become
inline stubs and --help prints the option list without descriptions.
Say N for a small statically linked tool that only needs its options
parsed. If unsure, say Y.
#
# The environment as a source of configuration. A knob a program reads out of
# the environment is a knob whoever starts the program sets, which is exactly
# what a build meant for a fixed deployment - an appliance, a setuid tool, a
# binary run by a service manager it does not control - may want none of.
#
config ENVIRONMENT
bool "Configuration from the environment"
default y
help
Let a program take configuration from environment variables:
conf_getenv() and the typed conf_env_*() readers over it are the
one door <hpc/conf.h> opens onto getenv(), and the code in this
package and in the programs built on it goes through it.
Say N and that door is closed. conf_getenv() becomes an inline
stub returning NULL, every conf_env_*() returns the default it was
given, and the module that parses the values is not compiled at
all - so a variable set in the environment changes nothing, and
the defaults compiled into the program are what runs. The variable
names themselves stop being named by the code that looked them up,
the way section names stop being named without CONFIG_SECTION.
What does not change is the program: every knob remains reachable
from the command line, from -S and from a configuration file, and
source that compiled with this on compiles with it off - a caller
passes the default it wants and gets it back.
Say N for a program whose environment is not to be trusted with its
configuration: a setuid or otherwise privileged tool, or a build
whose behaviour must be a property of the binary and not of whoever
started it. If unsure, say Y.