kconfig: convert Kconfig helper script into a shell script
PATCH v2 1/1 kconfig: convert Kconfig helper script into a shell script
Commit 51148790 added scripts/multiconfig.py written in Python 2 to adjust Kconfig for U-Boot.
It has been hard for Python 3 users because Python 2 and Python 3 are not compatible with each other.
We are not happy about adding a new host tool dependency (in this case, Python version dependency) for the core build process. After some discussion, we decided to use only basic tools.
The script may get a bit unreadable by shell scripting, but we believe it is worthwhile.
In addition, this commit revives "<board>_config" target that is equivalent to "<board>_defconfig" for backwards compatibility. It is annoying to adjust various projects which use U-Boot.
---
To apply this patch cleanly, the following is needed:
http://patchwork.ozlabs.org/patch/380316/
Changes in v2:
- Update git-description to mention the support for "<board>_config"
Makefile | 4 +- scripts/multiconfig.py | 405 ------------------------------------------------- scripts/multiconfig.sh | 251 ++++++++++++++++++++++++++++++ 3 files changed, 253 insertions(+), 407 deletions(-) delete mode 100755 scripts/multiconfig.py create mode 100644 scripts/multiconfig.sh
Makefile +2 -2
@@ -462,10 +462,10 @@ KBUILD_DEFCONFIG := sandbox_defconfig export KBUILD_DEFCONFIG KBUILD_KCONFIG config: scripts_basic outputmakefile FORCE - +$(Q)$(PYTHON) $(srctree)/scripts/multiconfig.py $@ + (Q)$(MAKE) $(build)=scripts/kconfig $@ %config: scripts_basic outputmakefile FORCE - +$(Q)$(PYTHON) $(srctree)/scripts/multiconfig.py $@ + +$(Q)$(CONFIG_SHELL) $(srctree)/scripts/multiconfig.sh $@ else # ===========================================================================
scripts/multiconfig.py deleted +0 -405
405 lines not on this page · raw message
scripts/multiconfig.sh new file +251 -0
251 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 1/1 kconfig: convert Kconfig helper script into a shell script
Quoted 17 lines · Masahiro Yamada
Commit 51148790 added
scripts/multiconfig.pywritten in Python 2 to adjustKconfigfor U-Boot.It has been hard for Python 3 users because Python 2 and Python 3 are not compatible with each other.
We are not happy about adding a new host tool dependency (in this case, Python version dependency) for the core build process. After some discussion, we decided to use only basic tools.
The script may get a bit unreadable by shell scripting, but we believe it is worthwhile.
In addition, this commit revives "<board>_config" target that is equivalent to "<board>_defconfig" for backwards compatibility. It is annoying to adjust various projects which use U-Boot.
Quoted 6 lines
Signed-off-by Masahiro Yamada <[email protected]>Suggested-by Igor Grinberg <[email protected]>Cc Tom Rini <[email protected]>Cc Jeroen Hofstee <[email protected]>Cc Simon Glass <[email protected]>Cc Stephen Warren <[email protected]>
Thanks Masahiro!
Signature · 2 lines
Regards, Igor.
PATCH v2 1/1 kconfig: convert Kconfig helper script into a shell script
In reply to Masahiro YamadaQuoted 10 lines · Masahiro Yamada
Commit 51148790 added
scripts/multiconfig.pywritten in Python 2 to adjustKconfigfor U-Boot.It has been hard for Python 3 users because Python 2 and Python 3 are not compatible with each other.
We are not happy about adding a new host tool dependency (in this case, Python version dependency) for the core build process. After some discussion, we decided to use only basic tools.
Quoted 6 lines
The script may get a bit unreadable by shell scripting, but we believe it is worthwhile.
In addition, this commit revives "<board>_config" target that is equivalent to "<board>_defconfig" for backwards compatibility. It is annoying to adjust various projects which use U-Boot.
Personally, I think this change isn't justified; I see no reason to replace the perfectly working existing script. Still, if that's what's desired...
PATCH v2 1/1 kconfig: convert Kconfig helper script into a shell script
Hi,
Quoted 15 lines · Stephen Warren
Quoted 13 lines · Masahiro Yamada
Commit 51148790 added
scripts/multiconfig.pywritten in Python 2 to adjustKconfigfor U-Boot.It has been hard for Python 3 users because Python 2 and Python 3 are not compatible with each other.
We are not happy about adding a new host tool dependency (in this case, Python version dependency) for the core build process. After some discussion, we decided to use only basic tools.
The script may get a bit unreadable by shell scripting, but we believe it is worthwhile.
Quoted 9 lines
Quoted 4 lines
In addition, this commit revives "<board>_config" target that is equivalent to "<board>_defconfig" for backwards compatibility. It is annoying to adjust various projects which use U-Boot.
Personally, I think this change isn't justified; I see no reason to replace the perfectly working existing script. Still, if that's what's desired...
Agreed, it seems unfortunate - long shell scripts are so much harder to work with IMO. Is it really not possible to make code compatible with both? Also we have lost the docs at the top of the file I think.
Regards,
Simon
PATCH v2 1/1 kconfig: convert Kconfig helper script into a shell script
Quoted 27 lines · Simon Glass
Hi,
On 18 August 2014 10:20, Stephen Warren <[email protected] <mailto:[email protected]>> wrote:
On 08/16/2014 10:56 PM, Masahiro Yamada wrote:
Commit 51148790 added
scripts/multiconfig.pywritten in Python 2 to adjustKconfigfor U-Boot.It has been hard for Python 3 users because Python 2 and Python 3 are not compatible with each other.
We are not happy about adding a new host tool dependency (in this case, Python version dependency) for the core build process.
After some discussion, we decided to use only basic tools.The script may get a bit unreadable by shell scripting, but we believe
it is worthwhile.In addition, this commit revives "<board>_config" target that is equivalent to "<board>_defconfig" for backwards compatibility. It is annoying to adjust various projects which use U-Boot.
Quoted 8 lines
Personally, I think this change isn't justified; I see no reason to replace the perfectly working existing script. Still, if that's what's desired...
Agreed, it seems unfortunate - long shell scripts are so much harder to work with IMO. Is it really not possible to make code compatible with both? Also we have lost the docs at the top of the file I think.
It might well be possible to be compatible with both Python 2 and 3, but the solution mentioned earlier in the thread was as simple as:
- #!/usr/bin/python
+ #!/usr/bin/python2
That would only fail on systems:
a) Without Python2 (which seems a little unlikely at the moment, and even if that's the case by default, there's enough Python2 code that surely a compat package would be available)
b) So old that there is no python2 symlink, just python. I don't know when python2 was added.
PATCH v2 1/1 kconfig: convert Kconfig helper script into a shell script
Hi Stephen,
Quoted 33 lines · On Mon, 18 Aug 2014 10:36:48 -0600 Stephen Warren <[email protected]> wrote:
Quoted 32 lines · Simon Glass
Hi,
On 18 August 2014 10:20, Stephen Warren <[email protected] <mailto:[email protected]>> wrote:
On 08/16/2014 10:56 PM, Masahiro Yamada wrote:
Commit 51148790 added
scripts/multiconfig.pywritten in Python 2 to adjustKconfigfor U-Boot.It has been hard for Python 3 users because Python 2 and Python 3 are not compatible with each other.
We are not happy about adding a new host tool dependency (in this case, Python version dependency) for the core build process.
After some discussion, we decided to use only basic tools.The script may get a bit unreadable by shell scripting, but we believe
it is worthwhile.In addition, this commit revives "<board>_config" target that is equivalent to "<board>_defconfig" for backwards compatibility. It is annoying to adjust various projects which use U-Boot.
Personally, I think this change isn't justified; I see no reason to replace the perfectly working existing script. Still, if that's what's desired...
Quoted 8 lines
Quoted 3 lines
Agreed, it seems unfortunate - long shell scripts are so much harder to work with IMO. Is it really not possible to make code compatible with both? Also we have lost the docs at the top of the file I think.
It might well be possible to be compatible with both Python 2 and 3, but the solution mentioned earlier in the thread was as simple as:
- #!/usr/bin/python
+ #!/usr/bin/python2
We can change the top Makefile as follows:
diff --git a/Makefile b/Makefile
index b5d5e01..e830d3d 100644
--- a/Makefile
+++ b/Makefile
@@ -338,7 +338,7 @@ OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
AWK = awk PERL = perl -PYTHON = python +PYTHON = python2 DTC = dtc CHECK = sparse
Quoted 5 lines
That would only fail on systems:
a) Without Python2 (which seems a little unlikely at the moment, and even if that's the case by default, there's enough Python2 code that surely a compat package would be available)
b) So old that there is no python2 symlink, just python. I don't know when python2 was added.
To be more supportive for b), we can also do
PYTHON = $(if $(shell which python2 2>/dev/null), python2, python)
I don't know exactly when 'python2' was added but I think it existed at least from python 2.4. We can not (need not) support older versions than it. The switch above might not be necessary.
Best Regards
Masahiro Yamada
PATCH v2 1/1 kconfig: convert Kconfig helper script into a shell script
In reply to Simon GlassHi.
Quoted 28 lines · On Mon, 18 Aug 2014 10:27:29 -0600 Simon Glass <[email protected]> wrote:
Hi,
Quoted 24 lines · Stephen Warren
Quoted 10 lines · Masahiro Yamada
Commit 51148790 added
scripts/multiconfig.pywritten in Python 2 to adjustKconfigfor U-Boot.It has been hard for Python 3 users because Python 2 and Python 3 are not compatible with each other.
We are not happy about adding a new host tool dependency (in this case, Python version dependency) for the core build process. After some discussion, we decided to use only basic tools.
Quoted 7 lines
The script may get a bit unreadable by shell scripting, but we believe it is worthwhile.
In addition, this commit revives "<board>_config" target that is equivalent to "<board>_defconfig" for backwards compatibility. It is annoying to adjust various projects which use U-Boot.
Personally, I think this change isn't justified; I see no reason to replace the perfectly working existing script. Still, if that's what's desired...
In that case, I wanted you to stop me earlier. I wrote this patch during my summer vacation. :-(
Quoted 2 lines
Agreed, it seems unfortunate - long shell scripts are so much harder to work with IMO. Is it really not possible to make code compatible with both?
Actually, it is easy to have scripts/multiconfig.py work on python2.6, python 2.7 and python3.x.
Apply this
http://patchwork.ozlabs.org/patch/380316/
and then fix a print statement as follows:
--- a/scripts/multiconfig.py
+++ b/scripts/multiconfig.py
@@ -336,7 +336,7 @@ def do_defconfig(cmd):
cmd: should always be a string 'defconfig'
"""
KBUILD_DEFCONFIG = os.environ['KBUILD_DEFCONFIG']
- print "*** Default configuration is based on '%s'" % KBUILD_DEFCONFIG
+ print("*** Default configuration is based on '%s'" % KBUILD_DEFCONFIG)
do_board_defconfig(KBUILD_DEFCONFIG)
def do_savedefconfig(cmd):
Pretty easy, isn't it?
But the problem I see here is that the "except foo, bar " statement was replaced with "except foo as bar" and Python 3.x dropped the backwards compatibility.
[1] Python 2.5 or older only understands "except foo, bar"
[2] Python 2.6 thru 2.7 accepts both "except foo, bar" and "except foo as bar"
[3] Python 3.x only accepts "excpet foo as bar"
If we take [3], we have to cut [1].
We need to choose either [1]+[2] (python 2.4 or later, but not python 3.x)
or [2]+[3] (python 2.6 or later).
(Python 2.5 is still used in some long-term support distributions, isn't it? Tom?)
Quoted 1 line
Also we have lost the docs at the top of the file I think.
The docs at the top of file is duplication of doc/README.kconfig
http://patchwork.ozlabs.org/patch/380310/
That is why I just wrote a pointer, "See doc/README.kconfig".
It is true docstrings in each function provide much nicer documentation.
Best Regards
Masahiro Yamada
PATCH v2 1/1 kconfig: convert Kconfig helper script into a shell script
Quoted 31 lines · Masahiro Yamada
Hi.
Quoted 24 lines · On Mon, 18 Aug 2014 10:27:29 -0600 Simon Glass <[email protected]> wrote:
Hi,
Quoted 20 lines · Stephen Warren
Quoted 17 lines · Masahiro Yamada
Commit 51148790 added
scripts/multiconfig.pywritten in Python 2 to adjustKconfigfor U-Boot.It has been hard for Python 3 users because Python 2 and Python 3 are not compatible with each other.
We are not happy about adding a new host tool dependency (in this case, Python version dependency) for the core build process. After some discussion, we decided to use only basic tools.
The script may get a bit unreadable by shell scripting, but we believe it is worthwhile.
In addition, this commit revives "<board>_config" target that is equivalent to "<board>_defconfig" for backwards compatibility. It is annoying to adjust various projects which use U-Boot.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Personally, I think this change isn't justified; I see no reason to replace the perfectly working existing script. Still, if that's what's desired...
In that case, I wanted you to stop me earlier. I wrote this patch during my summer vacation. :-(
Thank you for doing it on your vacation! Yes, I'm _not_ comfortable making python a requirement for _everyone_ to build U-Boot. I'm willing to consider replacing MAKEALL with buildman since that's a more U-Boot developer tool. But for the average user we're making things more complicated than we must just so they can use our software.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140819/9683f6d7/attachment.pgp>