Index: build_tools/generate_port_list.py |
diff --git a/build_tools/generate_port_list.py b/build_tools/generate_port_list.py |
index f44a90f0e4745a83a2dbbb82c98e91a0f23d51d7..35c7bfeb4dec8681b67b28d569714a9405357bc4 100755 |
--- a/build_tools/generate_port_list.py |
+++ b/build_tools/generate_port_list.py |
@@ -2,7 +2,7 @@ |
# Copyright (c) 2013 The Native Client Authors. All rights reserved. |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
-"""Tool for generating list of ports in code.google.com wiki format. |
+"""Tool for re-generating port list in markdown format |
""" |
from __future__ import print_function |
@@ -13,6 +13,7 @@ import sys |
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
NACLPORTS_ROOT = os.path.dirname(SCRIPT_DIR) |
+OUTPUT_FILE = os.path.join(NACLPORTS_ROOT, 'docs', 'port_list.md') |
sys.path.append(os.path.join(NACLPORTS_ROOT, 'lib')) |
@@ -22,36 +23,33 @@ import naclports.source_package |
SRC_URL = 'https://chromium.googlesource.com/external/naclports/+/master' |
header = '''\ |
-#summary List of ports available in naclports. |
-= List of available !NaCl ports = |
+# List of available NaCl ports |
Port are listed in alphabetical order, with links to the upstream |
-source archive and the patch used when building for !NaCl. |
+source archive and the patch used when building for NaCl. |
This listing is auto-generated by the |
-[%s/build_tools/generate_port_list.py generate_port_list.py] |
+[generate\_port\_list.py] |
+(%s/build_tools/generate_port_list.py generate_port_list.py) |
script. |
-|| *Name* || *Version* || *Upstream Archive* || *!NaCl Patch* || *Libc* \ |
-|| *Arch* || *Builds on* ||''' % SRC_URL |
+| **Name** | **Version** | **Upstream Archive** | **NaCl Patch** | **Libc** \ |
+| **Arch** | **Builds on** | |
+| :--- | :--- | :--- | :--- | :--- | :--- | :--- | |
+''' % SRC_URL |
-def OutputTableRow(package): |
- if not package.URL: |
- return |
+def MakeTableRow(package): |
patch = os.path.join(package.root, 'nacl.patch') |
if os.path.exists(patch): |
- relative_path = os.path.relpath(patch, NACLPORTS_ROOT) |
size = os.path.getsize(patch) |
if size < 1024: |
- patch = '[%s/%s %d B]' % (SRC_URL, relative_path, size) |
+ patch = '[%d B][%s]' % (size, package.NAME + '_patch') |
else: |
- patch = '[%s/%s %d KiB]' % (SRC_URL, relative_path, size / 1024) |
+ patch = '[%d KiB][%s]' % (size / 1024, package.NAME + '_patch') |
else: |
patch = '' |
- url = '[%s %s]' % (package.URL, package.GetArchiveFilename()) |
- package_url = '[%s/%s %s]' % (SRC_URL, |
- os.path.relpath(package.root, NACLPORTS_ROOT), |
- package.NAME) |
+ url = '[%s][%s]' % (package.GetArchiveFilename(), package.NAME + '_upstream') |
+ package_url = '[%s]' % package.NAME |
libc = package.LIBC |
if libc: |
@@ -75,38 +73,54 @@ def OutputTableRow(package): |
else: |
host = '' |
cols = (package_url, package.VERSION, url, patch, libc, arch, host) |
- print('|| %-70s || %-10s || %-50s || %s || %s || %s || %s ||' % cols) |
+ return '| %-25s | %-15s | %-45s | %-20s | %s | %s | %s |\n' % cols |
-def main(args): |
- parser = argparse.ArgumentParser(description=__doc__) |
- parser.add_argument('-v', '--verbose', action='store_true', |
- help='Output extra information.') |
- parser.parse_args(args) |
- rtn = 0 |
- |
- print(header) |
+def MakePage(): |
+ page = header |
total = 0 |
for package in sorted(naclports.source_package.SourcePackageIterator()): |
- OutputTableRow(package) |
+ if package.URL: |
+ page += MakeTableRow(package) |
total += 1 |
- print('\n_Total = %d_\n' % total) |
+ page += '\n_Total = %d_\n\n' % total |
- print('= Local Ports (not based on upstream sources) =\n') |
+ page += '# Local Ports (not based on upstream sources) =\n\n' |
total = 0 |
for package in naclports.source_package.SourcePackageIterator(): |
if package.URL: |
continue |
- package_url = '[%s/%s %s]' % (SRC_URL, |
- os.path.relpath(package.root, NACLPORTS_ROOT), |
- package.NAME) |
- print('|| %-70s ||' % package_url) |
+ page += '- [%s][%s]\n' % (package.NAME, package.NAME) |
total += 1 |
- print('\n_Total = %d_\n' % total) |
+ page += '\n_Total = %d_\n\n' % total |
+ |
+ # Generate up to tree links for each package at the base of the page |
+ for package in naclports.source_package.SourcePackageIterator(): |
+ relative_path = os.path.relpath(package.root, NACLPORTS_ROOT) |
+ page += '[%s]: %s/%s\n' % (package.NAME, SRC_URL, relative_path) |
+ |
+ patch = os.path.join(package.root, 'nacl.patch') |
+ if os.path.exists(patch): |
+ relative_path = os.path.relpath(patch, NACLPORTS_ROOT) |
+ page += '[%s_patch]: %s/%s\n' % (package.NAME, SRC_URL, relative_path) |
- return rtn |
+ if package.URL: |
+ page += '[%s_upstream]: %s\n' % (package.NAME, package.URL) |
+ |
+ |
+ return page |
+ |
+ |
+def main(args): |
+ parser = argparse.ArgumentParser(description=__doc__) |
+ parser.add_argument('-v', '--verbose', action='store_true', |
+ help='Output extra information.') |
+ parser.parse_args(args) |
+ with open(OUTPUT_FILE, 'w') as f: |
+ f.write(MakePage()) |
+ return 0 |
if __name__ == '__main__': |