[U-Boot] [PATCH v5 07/15] Do not apply: tools: add gen_maintainers.py
Masahiro Yamada
yamada.m at jp.panasonic.com
Thu Jul 24 06:00:14 CEST 2014
========================================
Do not apply this patch to the main line
========================================
This tool generates MAINTAINERS files based on boards.cfg file.
Because it is used only once, it should not be applied.
Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
---
Changes in v5: None
Changes in v4:
- Newly added
Changes in v3: None
Changes in v2: None
tools/gen_maintainers.py | 117 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 117 insertions(+)
create mode 100755 tools/gen_maintainers.py
diff --git a/tools/gen_maintainers.py b/tools/gen_maintainers.py
new file mode 100755
index 0000000..c448402
--- /dev/null
+++ b/tools/gen_maintainers.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import subprocess
+
+INPUT_FILE = 'boards.cfg'
+
+def get_board_name(board, target):
+ board = board.upper()
+ target = target.upper()
+ if board == '<none>':
+ return target
+ elif board == target[:len(board)]:
+ return board
+ else:
+ print "other cases:", board, ':', target
+ return target
+
+def get_status(status):
+ if status == 'Active':
+ return 'Maintained'
+ elif status == 'Orphan':
+ return 'Orphan (since %s)' % orphaned_date
+ else:
+ print 'Error: %s: unknown status' % status
+ sys.exit(1)
+
+class Board:
+ def __init__(self, name, status, files, maintainers):
+ self.name = name
+ self.status = status
+ self.files = files
+ self.maintainers = maintainers
+ def append(self, files):
+ self.files += files
+
+# remove old MAINTAINERS files
+subprocess.call("find board -name MAINTAINERS | xargs -r rm", shell=True)
+
+# store all the boards in this dictionary
+all_boards = {}
+
+for line in open(INPUT_FILE):
+ if line[0] == '#' or line == '\n':
+ if line == '# The following were moved to "Orphan" in June, 2014\n':
+ orphaned_date = '2014-06'
+ elif line == '# The following were moved to "Orphan" in April, 2014\n':
+ orphaned_date = '2014-04'
+ elif line == '# The following were moved to "Orphan" in March, 2014\n':
+ orphaned_date = '2014-03'
+ elif line == '# The following were move to "Orphan" in September, 2013\n':
+ orphaned_date = '2013-09'
+ continue
+ (status, arch, cpu, soc, vendor, board, target, options, maintainers) = \
+ line.rstrip().split(None, 8)
+ status = get_status(status)
+ if options == '-':
+ config = target
+ else:
+ config = options.split(':')[0]
+ # path of MAINTAINERS file: board/<path>/MAINTAINERS
+ if board == '-':
+ path = vendor
+ elif vendor == '-':
+ path = board
+ else:
+ path = os.path.join(vendor, board)
+ #name = get_board_name(board, target)
+ if board == '-':
+ files = []
+ elif vendor == '-':
+ files = [ 'board/' + board + '/' ]
+ else:
+ files = [ 'board/' + vendor + '/' + board + '/' ]
+ files.append('include/configs/' + config + '.h')
+ files.append('configs/' + target + '_defconfig')
+ # On the first occurance of this MAINTAINERS path, add an empty list
+ if not path in all_boards:
+ all_boards[path] = []
+ # boards_list is the list of boards that share the same MAINTAINERS file
+ boards_list = all_boards[path]
+ for b in boards_list:
+ remove_list = []
+ for f in files:
+ if f in b.files:
+ remove_list.append(f)
+ for f in remove_list:
+ files.remove(f)
+ i = 0
+ for b in boards_list:
+ if status == b.status and maintainers == b.maintainers:
+ b.append(files)
+ break
+ i += 1
+ else:
+ if i == 0:
+ name = board.upper()
+ else:
+ name = target.upper()
+ boards_list.append(Board(name, status, files, maintainers))
+
+for path, boards_list in all_boards.items():
+ path = os.path.join('board', path, 'MAINTAINERS')
+ wfile = open(path, 'w')
+ first_loop = True
+ for b in boards_list:
+ if first_loop:
+ first_loop = False
+ else:
+ wfile.write('\n')
+ wfile.write(b.name.upper() + ' BOARD\n')
+ for maintainer in b.maintainers.split(':'):
+ wfile.write('M:\t%s\n' % maintainer)
+ wfile.write('S:\t%s\n' % b.status)
+ for file in b.files:
+ wfile.write('F:\t%s\n' % file)
--
1.9.1
More information about the U-Boot
mailing list