From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jean-Jacques Hiblot Date: Wed, 3 Oct 2018 15:53:50 +0200 Subject: [U-Boot] [RFC PATCH v2 1/3] tools: moveconfig: Add an option to build a fuller database of options In-Reply-To: <1538574832-21910-1-git-send-email-jjhiblot@ti.com> References: <1538574832-21910-1-git-send-email-jjhiblot@ti.com> Message-ID: <1538574832-21910-2-git-send-email-jjhiblot@ti.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de "moveconfig -b" will build a database of config options based on the content of include/config/auto.conf that reflects the .config Add a new option '-B' that does essentially the same, except that it uses the content of u-boot.cfg, spl/u-boot.cfg and tpl/u-boot.cfg. This allows to get the options from .config AND the headers for all the possible binary types (u-boot, SPL and TPL) Signed-off-by: Jean-Jacques Hiblot --- Changes in v2: None tools/moveconfig.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/tools/moveconfig.py b/tools/moveconfig.py index caa81ac..85c2b8b 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -1151,9 +1151,17 @@ class Slot: self.ps.stderr.read()) self.finish(False) + def remove_cfg_files(self): + for base in ['.', 'spl', 'tpl']: + try: + os.remove(os.path.join(self.build_dir, base, "u-boot.cfg")) + except: + pass + def do_defconfig(self): """Run 'make _defconfig' to create the .config file.""" - + # first remove old cfg files that may have been produced earlier + self.remove_cfg_files() cmd = list(self.make_cmd) cmd.append(self.defconfig) self.ps = subprocess.Popen(cmd, stdout=self.devnull, @@ -1182,15 +1190,43 @@ class Slot: cwd=self.current_src_dir) self.state = STATE_AUTOCONF + def do_build_db(self): """Add the board to the database""" - configs = {} - with open(os.path.join(self.build_dir, AUTO_CONF_PATH)) as fd: - for line in fd.readlines(): + def conf_to_dic(filename): + configs = {} + if not os.path.isfile(filename): + return None + + try: + if filename.endswith("u-boot.cfg"): + with tempfile.NamedTemporaryFile(delete = True) as fd: + lines = subprocess.check_call("sed -n -f tools/scripts/define2mk.sed {}".format(filename).split(), stdout = fd) + fd.seek(0) + lines = fd.readlines() + else: + with open(filename, "r") as fd: + lines = fd.readlines() + except: + return None + + for line in lines: if line.startswith('CONFIG'): config, value = line.split('=', 1) configs[config] = value.rstrip() - self.db_queue.put([self.defconfig, configs]) + return configs + + list_of_conf = [] + if self.options.build_full_db: + list_of_conf.append((self.defconfig,"u-boot.cfg")) + list_of_conf.append(("{} SPL".format(self.defconfig),"spl/u-boot.cfg")) + list_of_conf.append(("{} TPL".format(self.defconfig),"tpl/u-boot.cfg")) + else: + list_of_conf.append((self.defconfig,AUTO_CONF_PATH)) + for name,conf_file in list_of_conf: + configs = conf_to_dic(os.path.join(self.build_dir, conf_file)) + if configs: + self.db_queue.put([name, configs]) self.finish(True) def do_savedefconfig(self): @@ -1770,7 +1806,9 @@ def main(): help="don't show options which are already marked as " 'implying others') parser.add_option('-b', '--build-db', action='store_true', default=False, - help='build a CONFIG database') + help='build a CONFIG database based only on auto.conf') + parser.add_option('-B', '--build-full-db', action='store_true', default=False, + help='build a CONFIG database based only on u-boot.cfg (and also for SPL and TPL)') parser.add_option('-c', '--color', action='store_true', default=False, help='display the log in color') parser.add_option('-C', '--commit', action='store_true', default=False, @@ -1807,6 +1845,9 @@ def main(): (options, configs) = parser.parse_args() + if options.build_full_db: + options.build_db = True + if len(configs) == 0 and not any((options.force_sync, options.build_db, options.imply)): parser.print_usage() @@ -1875,7 +1916,8 @@ def main(): if options.build_db: with open(CONFIG_DATABASE, 'w') as fd: - for defconfig, configs in config_db.iteritems(): + for defconfig in sorted(config_db.keys()): + configs = config_db[defconfig] fd.write('%s\n' % defconfig) for config in sorted(configs.keys()): fd.write(' %s=%s\n' % (config, configs[config])) -- 2.7.4