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

Masahiro Yamada yamada.m at jp.panasonic.com
Tue Aug 19 04:34:38 CEST 2014


Hi.



On Mon, 18 Aug 2014 10:27:29 -0600
Simon Glass <sjg at chromium.org> wrote:

> Hi,
> 
> On 18 August 2014 10:20, Stephen Warren <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...
> >

In that case, I wanted you to stop me earlier.
I wrote this patch during my summer vacation.  :-(



> 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?)



> 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



More information about the U-Boot mailing list