Re: [U-Boot] [PATCH v8 07/13] tools: add genboardscfg.py
On Thu, Jul 31, 2014 at 11:22:05AM +0900, Masahiro Yamada wrote: Hi Tom, On Wed, 30 Jul 2014 10:07:19 -0400 Tom Rini tr...@ti.com wrote: On Wed, Jul 30, 2014 at 02:08:19PM +0900, Masahiro Yamada wrote: Now the primary data for each board is in Kconfig, defconfig and MAINTAINERS. It is true boards.cfg is needed for MAKEALL and buildman and might be useful to brouse all the supported boards in a single database. But it would be painful to maintain the boards.cfg in sync. So, this is the solution. Add a tool to generate the equivalent boards.cfg file based on the latest Kconfig, defconfig and MAINTAINERS. We can keep all the functions of MAKEALL and buildman with it. The best thing would be to change MAKEALL and buildman for not depending on boards.cfg in the future, but it would take some time. [snip] +def get_make_cmd(): +Get the command name of GNU Make. +try: +make_cmd = subprocess.check_output([SHOW_GNU_MAKE]) +except subprocess.CalledProcessError: +print sys.stderr, 'GNU Make not found' +sys.exit(1) +return make_cmd.rstrip() So subprocess.check_output comes from Python 2.7 and Ubuntu 10.04 ships with 2.6. This isn't a deal-breaker as I'm working on updating the two calls here now (and we'll set aside mailmapper, that's not going to be commonly used I think). BTW, Ubuntu 10.04 is now being supported only for Server. Yeah. IT counts build servers as Server not Desktop so I've got access to some beefy build resources that're on that (and staying there for some time to come). :) -- Tom signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v8 07/13] tools: add genboardscfg.py
On Wed, Jul 30, 2014 at 02:08:19PM +0900, Masahiro Yamada wrote: Now the primary data for each board is in Kconfig, defconfig and MAINTAINERS. It is true boards.cfg is needed for MAKEALL and buildman and might be useful to brouse all the supported boards in a single database. But it would be painful to maintain the boards.cfg in sync. So, this is the solution. Add a tool to generate the equivalent boards.cfg file based on the latest Kconfig, defconfig and MAINTAINERS. We can keep all the functions of MAKEALL and buildman with it. The best thing would be to change MAKEALL and buildman for not depending on boards.cfg in the future, but it would take some time. [snip] +def get_make_cmd(): +Get the command name of GNU Make. +try: +make_cmd = subprocess.check_output([SHOW_GNU_MAKE]) +except subprocess.CalledProcessError: +print sys.stderr, 'GNU Make not found' +sys.exit(1) +return make_cmd.rstrip() So subprocess.check_output comes from Python 2.7 and Ubuntu 10.04 ships with 2.6. This isn't a deal-breaker as I'm working on updating the two calls here now (and we'll set aside mailmapper, that's not going to be commonly used I think). -- Tom signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v8 07/13] tools: add genboardscfg.py
Hi Tom, On 30 July 2014 15:07, Tom Rini tr...@ti.com wrote: On Wed, Jul 30, 2014 at 02:08:19PM +0900, Masahiro Yamada wrote: Now the primary data for each board is in Kconfig, defconfig and MAINTAINERS. It is true boards.cfg is needed for MAKEALL and buildman and might be useful to brouse all the supported boards in a single database. But it would be painful to maintain the boards.cfg in sync. So, this is the solution. Add a tool to generate the equivalent boards.cfg file based on the latest Kconfig, defconfig and MAINTAINERS. We can keep all the functions of MAKEALL and buildman with it. The best thing would be to change MAKEALL and buildman for not depending on boards.cfg in the future, but it would take some time. [snip] +def get_make_cmd(): +Get the command name of GNU Make. +try: +make_cmd = subprocess.check_output([SHOW_GNU_MAKE]) +except subprocess.CalledProcessError: +print sys.stderr, 'GNU Make not found' +sys.exit(1) +return make_cmd.rstrip() So subprocess.check_output comes from Python 2.7 and Ubuntu 10.04 ships with 2.6. This isn't a deal-breaker as I'm working on updating the two calls here now (and we'll set aside mailmapper, that's not going to be commonly used I think). We could use tools/patman/command.py's OutputOneLine(). Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v8 07/13] tools: add genboardscfg.py
On Wed, Jul 30, 2014 at 04:12:09PM +0100, Simon Glass wrote: Hi Tom, On 30 July 2014 15:07, Tom Rini tr...@ti.com wrote: On Wed, Jul 30, 2014 at 02:08:19PM +0900, Masahiro Yamada wrote: Now the primary data for each board is in Kconfig, defconfig and MAINTAINERS. It is true boards.cfg is needed for MAKEALL and buildman and might be useful to brouse all the supported boards in a single database. But it would be painful to maintain the boards.cfg in sync. So, this is the solution. Add a tool to generate the equivalent boards.cfg file based on the latest Kconfig, defconfig and MAINTAINERS. We can keep all the functions of MAKEALL and buildman with it. The best thing would be to change MAKEALL and buildman for not depending on boards.cfg in the future, but it would take some time. [snip] +def get_make_cmd(): +Get the command name of GNU Make. +try: +make_cmd = subprocess.check_output([SHOW_GNU_MAKE]) +except subprocess.CalledProcessError: +print sys.stderr, 'GNU Make not found' +sys.exit(1) +return make_cmd.rstrip() So subprocess.check_output comes from Python 2.7 and Ubuntu 10.04 ships with 2.6. This isn't a deal-breaker as I'm working on updating the two calls here now (and we'll set aside mailmapper, that's not going to be commonly used I think). We could use tools/patman/command.py's OutputOneLine(). That feels like a lot of code to borrow, or should we be able to just import and use it? And would you mind reviewing the patch I posted that switches over to subprocess.Popen() ? Thanks! -- Tom signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v8 07/13] tools: add genboardscfg.py
Hi Tom, On 30 July 2014 16:22, Tom Rini tr...@ti.com wrote: On Wed, Jul 30, 2014 at 04:12:09PM +0100, Simon Glass wrote: Hi Tom, On 30 July 2014 15:07, Tom Rini tr...@ti.com wrote: On Wed, Jul 30, 2014 at 02:08:19PM +0900, Masahiro Yamada wrote: Now the primary data for each board is in Kconfig, defconfig and MAINTAINERS. It is true boards.cfg is needed for MAKEALL and buildman and might be useful to brouse all the supported boards in a single database. But it would be painful to maintain the boards.cfg in sync. So, this is the solution. Add a tool to generate the equivalent boards.cfg file based on the latest Kconfig, defconfig and MAINTAINERS. We can keep all the functions of MAKEALL and buildman with it. The best thing would be to change MAKEALL and buildman for not depending on boards.cfg in the future, but it would take some time. [snip] +def get_make_cmd(): +Get the command name of GNU Make. +try: +make_cmd = subprocess.check_output([SHOW_GNU_MAKE]) +except subprocess.CalledProcessError: +print sys.stderr, 'GNU Make not found' +sys.exit(1) +return make_cmd.rstrip() So subprocess.check_output comes from Python 2.7 and Ubuntu 10.04 ships with 2.6. This isn't a deal-breaker as I'm working on updating the two calls here now (and we'll set aside mailmapper, that's not going to be commonly used I think). We could use tools/patman/command.py's OutputOneLine(). That feels like a lot of code to borrow, or should we be able to just import and use it? And would you mind reviewing the patch I posted that switches over to subprocess.Popen() ? Thanks! Yes it is a lot of code. You can just import and borrow it so long as it is available on the python path. See tools/buildman/buildman.py for the code: # Bring in the patman libraries our_path = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(our_path, '../patman')) I didn't see that patch you mention, will take a look. Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v8 07/13] tools: add genboardscfg.py
On Wed, Jul 30, 2014 at 02:08:19PM +0900, Masahiro Yamada wrote: Now the primary data for each board is in Kconfig, defconfig and MAINTAINERS. It is true boards.cfg is needed for MAKEALL and buildman and might be useful to brouse all the supported boards in a single database. But it would be painful to maintain the boards.cfg in sync. So, this is the solution. Add a tool to generate the equivalent boards.cfg file based on the latest Kconfig, defconfig and MAINTAINERS. We can keep all the functions of MAKEALL and buildman with it. The best thing would be to change MAKEALL and buildman for not depending on boards.cfg in the future, but it would take some time. Signed-off-by: Masahiro Yamada yamad...@jp.panasonic.com Acked-by: Simon Glass s...@chromium.org With the re-work that we talked about ont he ML for Python 2.6, Applied to u-boot/master, thanks! -- Tom signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v8 07/13] tools: add genboardscfg.py
Hi Tom, On Wed, 30 Jul 2014 10:07:19 -0400 Tom Rini tr...@ti.com wrote: On Wed, Jul 30, 2014 at 02:08:19PM +0900, Masahiro Yamada wrote: Now the primary data for each board is in Kconfig, defconfig and MAINTAINERS. It is true boards.cfg is needed for MAKEALL and buildman and might be useful to brouse all the supported boards in a single database. But it would be painful to maintain the boards.cfg in sync. So, this is the solution. Add a tool to generate the equivalent boards.cfg file based on the latest Kconfig, defconfig and MAINTAINERS. We can keep all the functions of MAKEALL and buildman with it. The best thing would be to change MAKEALL and buildman for not depending on boards.cfg in the future, but it would take some time. [snip] +def get_make_cmd(): +Get the command name of GNU Make. +try: +make_cmd = subprocess.check_output([SHOW_GNU_MAKE]) +except subprocess.CalledProcessError: +print sys.stderr, 'GNU Make not found' +sys.exit(1) +return make_cmd.rstrip() So subprocess.check_output comes from Python 2.7 and Ubuntu 10.04 ships with 2.6. This isn't a deal-breaker as I'm working on updating the two calls here now (and we'll set aside mailmapper, that's not going to be commonly used I think). BTW, Ubuntu 10.04 is now being supported only for Server. Desktop support ended in April, 2013. Ubuntu 12.04 is shipped with Python 2.7. Best Regards Masahiro Yamada ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v8 07/13] tools: add genboardscfg.py
Now the primary data for each board is in Kconfig, defconfig and MAINTAINERS. It is true boards.cfg is needed for MAKEALL and buildman and might be useful to brouse all the supported boards in a single database. But it would be painful to maintain the boards.cfg in sync. So, this is the solution. Add a tool to generate the equivalent boards.cfg file based on the latest Kconfig, defconfig and MAINTAINERS. We can keep all the functions of MAKEALL and buildman with it. The best thing would be to change MAKEALL and buildman for not depending on boards.cfg in the future, but it would take some time. Signed-off-by: Masahiro Yamada yamad...@jp.panasonic.com Acked-by: Simon Glass s...@chromium.org --- Changes in v8: None Changes in v7: - Delete the incomplete boards.cfg file when the script is terminated by user with keyboard interrupt. - Follow PEP8 codiyg style: Use blah blah rather than '''blah blah''' for docstring. Fix some indents Add a period of the end of the first line of docstring - Do not hard-code 'make' command name. Use scripts/show-gnu-make - Add specific exception class - Add a blank line to some places for readability Changes in v6: - Fix comment format of arguments foo: blah blah rather than foo - blah blah - Use tag, rest instead of line[:2], line[2:] for clarification - Sort imports alphabetically - Insert a blank before each function - Fix some comments - Use tempfile.mkdtemp() to create working directories Changes in v5: - Support wildcard pattern like 'F: configs/foo_*_defconfig' - Rename genboardscfg to genboardscfg.py - Use assert statement for sanity check - Do not run if imported from another script if __name__ == '__main__': main() - Check if we are at the top of source directory Changes in v4: - Newly added Changes in v3: None Changes in v2: None tools/genboardscfg.py | 504 ++ 1 file changed, 504 insertions(+) create mode 100755 tools/genboardscfg.py diff --git a/tools/genboardscfg.py b/tools/genboardscfg.py new file mode 100755 index 000..805e4eb --- /dev/null +++ b/tools/genboardscfg.py @@ -0,0 +1,504 @@ +#!/usr/bin/env python +# +# Author: Masahiro Yamada yamad...@jp.panasonic.com +# +# SPDX-License-Identifier: GPL-2.0+ +# + + +Converter from Kconfig and MAINTAINERS to boards.cfg + +Run 'tools/genboardscfg.py' to create boards.cfg file. + +Run 'tools/genboardscfg.py -h' for available options. + + +import errno +import fnmatch +import glob +import optparse +import os +import re +import shutil +import subprocess +import sys +import tempfile +import time + +BOARD_FILE = 'boards.cfg' +CONFIG_DIR = 'configs' +REFORMAT_CMD = [os.path.join('tools', 'reformat.py'), +'-i', '-d', '-', '-s', '8'] +SHOW_GNU_MAKE = 'scripts/show-gnu-make' +SLEEP_TIME=0.03 + +COMMENT_BLOCK = '''# +# List of boards +# Automatically generated by %s: don't edit +# +# Status, Arch, CPU(:SPLCPU), SoC, Vendor, Board, Target, Options, Maintainers + +''' % __file__ + +### helper functions ### +def get_terminal_columns(): +Get the width of the terminal. + +Returns: + The width of the terminal, or zero if the stdout is not + associated with tty. + +try: +return shutil.get_terminal_size().columns # Python 3.3~ +except AttributeError: +import fcntl +import termios +import struct +arg = struct.pack('', 0, 0, 0, 0) +try: +ret = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, arg) +except IOError as exception: +if exception.errno != errno.ENOTTY: +raise +# If 'Inappropriate ioctl for device' error occurs, +# stdout is probably redirected. Return 0. +return 0 +return struct.unpack('', ret)[1] + +def get_devnull(): +Get the file object of '/dev/null' device. +try: +devnull = subprocess.DEVNULL # py3k +except AttributeError: +devnull = open(os.devnull, 'wb') +return devnull + +def check_top_directory(): +Exit if we are not at the top of source directory. +for f in ('README', 'Licenses'): +if not os.path.exists(f): +print sys.stderr, 'Please run at the top of source directory.' +sys.exit(1) + +def get_make_cmd(): +Get the command name of GNU Make. +try: +make_cmd = subprocess.check_output([SHOW_GNU_MAKE]) +except subprocess.CalledProcessError: +print sys.stderr, 'GNU Make not found' +sys.exit(1) +return make_cmd.rstrip() + +### classes ### +class MaintainersDatabase: + +The database of board status and maintainers. + +def __init__(self): +Create an empty database. +self.database = {} + +def get_status(self, target): +Return the status of the given board. + +Returns: + Either 'Active' or 'Orphan' + +