Skip to content

Commit 0dfd191

Browse files
de-nordiccarlescufi
authored andcommitted
scripts: west_commands: Remove no longer needed load_dot_config(path)
The functionality of the function is now covered by BuildConfiguration class. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 09980d6 commit 0dfd191

File tree

1 file changed

+0
-63
lines changed

1 file changed

+0
-63
lines changed

scripts/west_commands/zephyr_ext_common.py

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import os
1212
from pathlib import Path
13-
import re
1413

1514
from west import log
1615
from west.commands import WestCommand
@@ -46,65 +45,3 @@ def check_force(self, cond, msg):
4645
if not (cond or self.args.force):
4746
log.err(msg)
4847
log.die('refusing to proceed without --force due to above error')
49-
50-
51-
def load_dot_config(path):
52-
'''Load a Kconfig .config output file in 'path' and return a dict
53-
from symbols set in that file to their values.
54-
55-
This parser:
56-
57-
- respects the usual "# CONFIG_FOO is not set" --> CONFIG_FOO=n
58-
semantics
59-
- converts decimal or hexadecimal integer literals to ints
60-
- strips quotes around strings
61-
'''
62-
63-
# You might think it would be easier to create a new
64-
# kconfiglib.Kconfig object and use its load_config() method to
65-
# parse the file instead.
66-
#
67-
# Beware, traveler: that way lies madness.
68-
#
69-
# Zephyr's Kconfig files rely heavily on environment variables to
70-
# manage user-configurable directory locations, and recreating
71-
# that state turns out to be a surprisingly fragile process. It's
72-
# not just 'srctree'; there are various others and they change
73-
# randomly as features get merged.
74-
#
75-
# Nor will pickling the Kconfig object come to your aid. It's a
76-
# deeply recursive data structure which requires a very high
77-
# system recursion limit (100K frames seems to do it) and contains
78-
# references to un-pickle-able values in its attributes.
79-
#
80-
# It's easier and in fact more robust to rely on the fact that the
81-
# .config file contents are just a strictly formatted Makefile
82-
# fragment with some extra "is not set" semantics.
83-
84-
opt_value = re.compile('^(?P<option>CONFIG_[A-Za-z0-9_]+)=(?P<value>.*)$')
85-
not_set = re.compile('^# (?P<option>CONFIG_[A-Za-z0-9_]+) is not set$')
86-
87-
with open(path, 'r') as f:
88-
lines = f.readlines()
89-
90-
ret = {}
91-
for line in lines:
92-
match = opt_value.match(line)
93-
if match:
94-
value = match.group('value')
95-
if value.startswith('"') and value.endswith('"'):
96-
value = value[1:-1]
97-
else:
98-
try:
99-
base = 16 if value.startswith('0x') else 10
100-
value = int(value, base=base)
101-
except ValueError:
102-
pass
103-
104-
ret[match.group('option')] = value
105-
106-
match = not_set.match(line)
107-
if match:
108-
ret[match.group('option')] = 'n'
109-
110-
return ret

0 commit comments

Comments
 (0)