Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: build_tools/generate_port_list.py

Issue 1411283004: Update generate_port_list.py to generate Markdown (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | docs/port_list.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Native Client Authors. All rights reserved. 2 # Copyright (c) 2013 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 """Tool for generating list of ports in code.google.com wiki format. 5 """Tool for re-generating port list in markdown format
6 """ 6 """
7 7
8 from __future__ import print_function 8 from __future__ import print_function
9 9
10 import argparse 10 import argparse
11 import os 11 import os
12 import sys 12 import sys
13 13
14 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 14 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
15 NACLPORTS_ROOT = os.path.dirname(SCRIPT_DIR) 15 NACLPORTS_ROOT = os.path.dirname(SCRIPT_DIR)
16 OUTPUT_FILE = os.path.join(NACLPORTS_ROOT, 'docs', 'port_list.md')
16 17
17 sys.path.append(os.path.join(NACLPORTS_ROOT, 'lib')) 18 sys.path.append(os.path.join(NACLPORTS_ROOT, 'lib'))
18 19
19 import naclports 20 import naclports
20 import naclports.source_package 21 import naclports.source_package
21 22
22 SRC_URL = 'https://chromium.googlesource.com/external/naclports/+/master' 23 SRC_URL = 'https://chromium.googlesource.com/external/naclports/+/master'
23 24
24 header = '''\ 25 header = '''\
25 #summary List of ports available in naclports. 26 # List of available NaCl ports
26 = List of available !NaCl ports =
27 27
28 Port are listed in alphabetical order, with links to the upstream 28 Port are listed in alphabetical order, with links to the upstream
29 source archive and the patch used when building for !NaCl. 29 source archive and the patch used when building for NaCl.
30 This listing is auto-generated by the 30 This listing is auto-generated by the
31 [%s/build_tools/generate_port_list.py generate_port_list.py] 31 [generate\_port\_list.py]
32 (%s/build_tools/generate_port_list.py generate_port_list.py)
32 script. 33 script.
33 34
34 || *Name* || *Version* || *Upstream Archive* || *!NaCl Patch* || *Libc* \ 35 | **Name** | **Version** | **Upstream Archive** | **NaCl Patch** | **Libc** \
35 || *Arch* || *Builds on* ||''' % SRC_URL 36 | **Arch** | **Builds on** |
37 | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
38 ''' % SRC_URL
36 39
37 40
38 def OutputTableRow(package): 41 def MakeTableRow(package):
39 if not package.URL:
40 return
41 patch = os.path.join(package.root, 'nacl.patch') 42 patch = os.path.join(package.root, 'nacl.patch')
42 if os.path.exists(patch): 43 if os.path.exists(patch):
43 relative_path = os.path.relpath(patch, NACLPORTS_ROOT)
44 size = os.path.getsize(patch) 44 size = os.path.getsize(patch)
45 if size < 1024: 45 if size < 1024:
46 patch = '[%s/%s %d B]' % (SRC_URL, relative_path, size) 46 patch = '[%d B][%s]' % (size, package.NAME + '_patch')
47 else: 47 else:
48 patch = '[%s/%s %d KiB]' % (SRC_URL, relative_path, size / 1024) 48 patch = '[%d KiB][%s]' % (size / 1024, package.NAME + '_patch')
49 else: 49 else:
50 patch = '' 50 patch = ''
51 url = '[%s %s]' % (package.URL, package.GetArchiveFilename()) 51 url = '[%s][%s]' % (package.GetArchiveFilename(), package.NAME + '_upstream')
52 package_url = '[%s/%s %s]' % (SRC_URL, 52 package_url = '[%s]' % package.NAME
53 os.path.relpath(package.root, NACLPORTS_ROOT),
54 package.NAME)
55 53
56 libc = package.LIBC 54 libc = package.LIBC
57 if libc: 55 if libc:
58 libc = libc + '-only' 56 libc = libc + '-only'
59 else: 57 else:
60 disabled_libc = getattr(package, 'DISABLED_LIBC') 58 disabled_libc = getattr(package, 'DISABLED_LIBC')
61 if disabled_libc: 59 if disabled_libc:
62 libc = 'not ' + ' or '.join(disabled_libc) 60 libc = 'not ' + ' or '.join(disabled_libc)
63 else: 61 else:
64 libc = '' 62 libc = ''
65 63
66 disabled_arch = getattr(package, 'DISABLED_ARCH') 64 disabled_arch = getattr(package, 'DISABLED_ARCH')
67 if disabled_arch: 65 if disabled_arch:
68 arch = 'not ' + ' or '.join(disabled_arch) 66 arch = 'not ' + ' or '.join(disabled_arch)
69 else: 67 else:
70 arch = '' 68 arch = ''
71 69
72 host = package.BUILD_OS 70 host = package.BUILD_OS
73 if host: 71 if host:
74 host = host + '-only' 72 host = host + '-only'
75 else: 73 else:
76 host = '' 74 host = ''
77 cols = (package_url, package.VERSION, url, patch, libc, arch, host) 75 cols = (package_url, package.VERSION, url, patch, libc, arch, host)
78 print('|| %-70s || %-10s || %-50s || %s || %s || %s || %s ||' % cols) 76 return '| %-25s | %-15s | %-45s | %-20s | %s | %s | %s |\n' % cols
77
78
79 def MakePage():
80 page = header
81
82 total = 0
83 for package in sorted(naclports.source_package.SourcePackageIterator()):
84 if package.URL:
85 page += MakeTableRow(package)
86 total += 1
87
88 page += '\n_Total = %d_\n\n' % total
89
90 page += '# Local Ports (not based on upstream sources) =\n\n'
91 total = 0
92 for package in naclports.source_package.SourcePackageIterator():
93 if package.URL:
94 continue
95 page += '- [%s][%s]\n' % (package.NAME, package.NAME)
96 total += 1
97 page += '\n_Total = %d_\n\n' % total
98
99 # Generate up to tree links for each package at the base of the page
100 for package in naclports.source_package.SourcePackageIterator():
101 relative_path = os.path.relpath(package.root, NACLPORTS_ROOT)
102 page += '[%s]: %s/%s\n' % (package.NAME, SRC_URL, relative_path)
103
104 patch = os.path.join(package.root, 'nacl.patch')
105 if os.path.exists(patch):
106 relative_path = os.path.relpath(patch, NACLPORTS_ROOT)
107 page += '[%s_patch]: %s/%s\n' % (package.NAME, SRC_URL, relative_path)
108
109 if package.URL:
110 page += '[%s_upstream]: %s\n' % (package.NAME, package.URL)
111
112
113 return page
79 114
80 115
81 def main(args): 116 def main(args):
82 parser = argparse.ArgumentParser(description=__doc__) 117 parser = argparse.ArgumentParser(description=__doc__)
83 parser.add_argument('-v', '--verbose', action='store_true', 118 parser.add_argument('-v', '--verbose', action='store_true',
84 help='Output extra information.') 119 help='Output extra information.')
85 parser.parse_args(args) 120 parser.parse_args(args)
86 rtn = 0 121 with open(OUTPUT_FILE, 'w') as f:
87 122 f.write(MakePage())
88 print(header) 123 return 0
89
90 total = 0
91 for package in sorted(naclports.source_package.SourcePackageIterator()):
92 OutputTableRow(package)
93 total += 1
94
95 print('\n_Total = %d_\n' % total)
96
97 print('= Local Ports (not based on upstream sources) =\n')
98 total = 0
99 for package in naclports.source_package.SourcePackageIterator():
100 if package.URL:
101 continue
102 package_url = '[%s/%s %s]' % (SRC_URL,
103 os.path.relpath(package.root, NACLPORTS_ROOT),
104 package.NAME)
105 print('|| %-70s ||' % package_url)
106 total += 1
107 print('\n_Total = %d_\n' % total)
108
109 return rtn
110 124
111 125
112 if __name__ == '__main__': 126 if __name__ == '__main__':
113 sys.exit(main(sys.argv[1:])) 127 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | docs/port_list.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698