summaryrefslogtreecommitdiff
path: root/menuconfig.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-05-27 04:43:00 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2018-05-27 04:46:11 +0200
commit1c81db1a573b930f80df176ef3012b6159e0598a (patch)
treebe456d6bc438b833c871ef59c272625649c4849a /menuconfig.py
parent37fe695e1745165bae6672e638e986bb885574c5 (diff)
menuconfig: Prepare for packaging
setuptools' 'entry_points' gives nice behavior on Windows. It requires that the module has an entry point function. Create one and move the command line argument handling to it.
Diffstat (limited to 'menuconfig.py')
-rwxr-xr-xmenuconfig.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/menuconfig.py b/menuconfig.py
index 5332b08..15a8539 100755
--- a/menuconfig.py
+++ b/menuconfig.py
@@ -278,6 +278,16 @@ _expr_str_orig = kconfiglib.expr_str
kconfiglib.expr_str = _expr_str_val
_expr_str = _expr_str_val
+# Entry point when run as an executable, split out so that setuptools'
+# 'entry_points' can be used. It produces a handy menuconfig.exe launcher on
+# Windows.
+def _main():
+ if len(sys.argv) > 2:
+ print("usage: {} [Kconfig]".format(sys.argv[0]), file=sys.stderr)
+ sys.exit(1)
+
+ menuconfig(Kconfig("Kconfig" if len(sys.argv) < 2 else sys.argv[1]))
+
def menuconfig(kconf):
"""
Launches the configuration interface, returning after the user exits.
@@ -2414,8 +2424,4 @@ def _convert_c_lc_ctype_to_utf8():
_IS_WINDOWS = (platform.system() == "Windows")
if __name__ == "__main__":
- if len(sys.argv) > 2:
- print("usage: {} [Kconfig]".format(sys.argv[0]), file=sys.stderr)
- sys.exit(1)
-
- menuconfig(Kconfig("Kconfig" if len(sys.argv) < 2 else sys.argv[1]))
+ _main()