From e0ba390411f01ee16adb2e5679e62bda1b3083ad Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Mon, 28 Mar 2022 12:17:31 +0300 Subject: [PATCH] Add cmdline file parsing --- kconfig_hardened_check/__init__.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/kconfig_hardened_check/__init__.py b/kconfig_hardened_check/__init__.py index 565503e..bf7977d 100644 --- a/kconfig_hardened_check/__init__.py +++ b/kconfig_hardened_check/__init__.py @@ -804,9 +804,20 @@ def parse_kconfig_file(parsed_options, fname): def parse_cmdline_file(parsed_options, fname): with open(fname, 'r') as f: - print('FIXME! cmdline file:') - for line in f.readlines(): - print(line) + line = f.readline() + opts = line.split() + + line = f.readline() + if line: + sys.exit('[!] ERROR: more than one line in "{}"'.format(fname)) + + for opt in opts: + if '=' in opt: + name, value = opt.split('=', 1) + else: + name = opt + value = '' # '' is not None + parsed_options[name] = value def main(): -- 2.31.1