Skip to content

Commit f1d8b5e

Browse files
author
Staging script
committed
Staging PR 3018
1 parent 8bcc551 commit f1d8b5e

File tree

1 file changed

+14
-39
lines changed

1 file changed

+14
-39
lines changed

kernelci/kbuild.py

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@
4747
"https://gitlab.com/cip-project/cip-kernel/cip-kernel-config/-/raw/master/{branch}/{config}" # noqa
4848
CROS_CONFIG_URL = \
4949
"https://chromium.googlesource.com/chromiumos/third_party/kernel/+archive/refs/heads/{branch}/chromeos/config.tar.gz" # noqa
50-
LEGACY_CONFIG = [
51-
'config/core/build-configs.yaml',
52-
'/etc/kernelci/core/build-configs.yaml',
53-
]
5450
FW_GIT = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git" # noqa
5551

5652
# TODO: find a way to automatically fetch this information
@@ -153,7 +149,8 @@ class KBuild():
153149
if node, jobname and params are provided, create new build object
154150
if jsonobj is provided, load class from serialized json
155151
'''
156-
def __init__(self, node=None, jobname=None, params=None, jsonobj=None, apiconfig=None):
152+
def __init__(self, node=None, jobname=None, params=None, jsonobj=None, apiconfig=None,
153+
fragment_configs=None):
157154
# Retrieve and store API token for future use
158155
self._api_token = os.environ.get('KCI_API_TOKEN')
159156
if not self._api_token:
@@ -169,6 +166,7 @@ def __init__(self, node=None, jobname=None, params=None, jsonobj=None, apiconfig
169166
if isinstance(self._defconfig, str) and '+' in self._defconfig:
170167
self._defconfig = self._defconfig.split('+')
171168
self._fragments = params['fragments']
169+
self._fragment_configs = fragment_configs or {}
172170
if 'coverage' in self._fragments:
173171
self._coverage = True
174172
else:
@@ -221,6 +219,7 @@ def __init__(self, node=None, jobname=None, params=None, jsonobj=None, apiconfig
221219
self._compiler = jsonobj['compiler']
222220
self._defconfig = jsonobj['defconfig']
223221
self._fragments = jsonobj['fragments']
222+
self._fragment_configs = jsonobj.get('fragment_configs', {})
224223
self._cross_compile = jsonobj['cross_compile']
225224
self._cross_compile_compat = jsonobj['cross_compile_compat']
226225
self._steps = jsonobj['steps']
@@ -553,40 +552,16 @@ def extract_config(self, frag):
553552
txt += c + '\n'
554553
return txt
555554

556-
def add_legacy_fragment(self, fragname):
557-
""" Add legacy config fragment from build-configs.yaml """
558-
buffer = ''
559-
yml = None
560-
for cfg_path in LEGACY_CONFIG:
561-
if not os.path.exists(cfg_path):
562-
continue
563-
with open(cfg_path, 'r') as cfgfile:
564-
content = cfgfile.read()
565-
yml = yaml.safe_load(content)
566-
break
567-
568-
if not yml:
569-
print(f"No suitable config file found in {LEGACY_CONFIG}")
570-
self.submit_failure(f"No suitable config file found in {LEGACY_CONFIG}")
571-
sys.exit(1)
572-
573-
print(f"Searching for fragment {fragname} in {cfg_path}")
574-
if 'fragments' in yml:
575-
frag = yml['fragments']
576-
else:
577-
print("No fragments section in config file")
578-
self.submit_failure("No fragments section in config file")
579-
sys.exit(1)
580-
581-
if fragname in frag:
582-
txt = self.extract_config(frag[fragname])
583-
buffer += txt
584-
else:
585-
print(f"Fragment {fragname} not found")
586-
self.submit_failure(f"Fragment {fragname} not found")
555+
def add_fragment(self, fragname):
556+
""" Get config fragment from passed fragment_configs """
557+
if fragname not in self._fragment_configs:
558+
print(f"Fragment {fragname} not found in fragment_configs")
559+
self.submit_failure(f"Fragment {fragname} not found in fragment_configs")
587560
sys.exit(1)
588561

589-
return buffer
562+
frag = self._fragment_configs[fragname]
563+
print(f"Using fragment {fragname} from inline configs")
564+
return self.extract_config(frag)
590565

591566
def _parse_fragments(self, firmware=False):
592567
""" Parse fragments kbuild config and create config fragments """
@@ -600,8 +575,8 @@ def _parse_fragments(self, firmware=False):
600575
elif fragment.startswith("CONFIG_"):
601576
content = fragment + '\n'
602577
else:
603-
# TODO: implement 'path' option properly
604-
content = self.add_legacy_fragment(fragment)
578+
# Use fragment configs passed from scheduler
579+
content = self.add_fragment(fragment)
605580

606581
fragfile = os.path.join(self._fragments_dir, f"{num}.config")
607582
with open(fragfile, 'w') as f:

0 commit comments

Comments
 (0)