From patchwork Wed Oct 23 06:33:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rolf Eike Beer X-Patchwork-Id: 13846538 Received: from mx1.emlix.com (mx1.emlix.com [178.63.209.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6AEA149011; Wed, 23 Oct 2024 06:33:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.63.209.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729665211; cv=none; b=MTGarDQ5+lk3bOE5UIjsIoJc5cOvbgyfILoLiGI9KCxEewgl6oNGZwZDaSE89Wp25or+jKxQd3qS6h7+bvQ+Y/Ud8tNkg0IdMumQfBFIZeMkwPIskZsYgDMcbXsGttKEser9tRxV9EvzR33pIRt8d4GMlGLZUlzRgICx8aSzax0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729665211; c=relaxed/simple; bh=tL9WB59hfAXSN94hpAXwy9dgVG30yl1q1MSVzRi6vjk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sZ+LAIAxkPO2Ti/kwS35VS1lohCnU0eD2U+OyN8RmjdXNp/2xihfQi/oYh/HtSlc4rwKuAsG0+Vcx48OOFLBmigmjUw/6l+n0VHt5kVXe1gEBCEecWPgdY9MXvg5kmx0t390rRxprxZwQCrVE24U+nvyMqNP0hSMRbCQSdqJY2s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=emlix.com; spf=pass smtp.mailfrom=emlix.com; arc=none smtp.client-ip=178.63.209.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=emlix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=emlix.com Received: from mailer.emlix.com (p5098be52.dip0.t-ipconnect.de [80.152.190.82]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.emlix.com (Postfix) with ESMTPS id EE8375F976; Wed, 23 Oct 2024 08:33:26 +0200 (CEST) From: Rolf Eike Beer To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] kconfig: qconf: use QCommandLineParser Date: Wed, 23 Oct 2024 08:33:26 +0200 Message-ID: <8441512.T7Z3S40VBb@devpool47.emlix.com> Organization: emlix GmbH In-Reply-To: <4960180.31r3eYUQgx@devpool47.emlix.com> References: <4960180.31r3eYUQgx@devpool47.emlix.com> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This has a much nicer output without manual processing. It also adds window management options from Qt for free. Signed-off-by: Rolf Eike Beer --- scripts/kconfig/qconf.cc | 44 ++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 6a653ebe9df3..313a51941825 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1844,41 +1845,30 @@ void fixup_rootmenu(struct menu *menu) } } -static const char *progname; - -static void usage(void) -{ - printf("%s [-s] \n", progname); - exit(0); -} - int main(int ac, char** av) { ConfigMainWindow* v; - const char *name; + configApp = new QApplication(ac, av); + QCommandLineParser cmdline; + QCommandLineOption silent("s", "silent"); - progname = av[0]; - if (ac > 1 && av[1][0] == '-') { - switch (av[1][1]) { - case 's': - conf_set_message_callback(NULL); - break; - case 'h': - case '?': - usage(); - } - name = av[2]; - } else - name = av[1]; - if (!name) - usage(); + cmdline.addOption(silent); + cmdline.addHelpOption(); + cmdline.addPositionalArgument("file", "config file to open", "Kconfig"); + + cmdline.process(*configApp); + + if (cmdline.isSet(silent)) + conf_set_message_callback(NULL); - conf_parse(name); + QStringList args = cmdline.positionalArguments(); + if (args.isEmpty()) + cmdline.showHelp(1); + + conf_parse(args.first().toLocal8Bit().constData()); fixup_rootmenu(&rootmenu); //zconfdump(stdout); - configApp = new QApplication(ac, av); - configSettings = new ConfigSettings(); configSettings->beginGroup("/kconfig/qconf"); v = new ConfigMainWindow();