[U-Boot] [PATCH v2] kconfig: convert Kconfig helper script into a shell script

Masahiro Yamada yamada.m at jp.panasonic.com
Tue Aug 19 05:11:08 CEST 2014


Hi Stephen,


On Mon, 18 Aug 2014 10:36:48 -0600
Stephen Warren <swarren at wwwdotorg.org> wrote:

> On 08/18/2014 10:27 AM, Simon Glass wrote:
> > Hi,
> >
> > On 18 August 2014 10:20, Stephen Warren <swarren at wwwdotorg.org
> > <mailto:swarren at wwwdotorg.org>> wrote:
> >
> >     On 08/16/2014 10:56 PM, Masahiro Yamada wrote:
> >
> >         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.
> >
> >
> >     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



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
 



> 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



More information about the U-Boot mailing list