lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # Copyright lowRISC contributors. |
| 3 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | # |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 6 | # Usage: |
| 7 | # run './build_docs.py' to generate the documentation and keep it updated |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 8 | # open 'http://localhost:1313/' to check live update (this opens the top |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 9 | # level index page). you can also directly access a specific document by |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 10 | # accessing 'http://localhost:1313/path/to/doc', |
| 11 | # e.g. http://localhost:1313/hw/ip/uart/doc |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 12 | |
| 13 | import argparse |
| 14 | import logging |
| 15 | import os |
Philipp Wagner | cd57f86 | 2019-10-31 14:20:39 +0000 | [diff] [blame] | 16 | import platform |
Silvestrs Timofejevs | ecaf87c | 2019-11-12 21:52:57 +0000 | [diff] [blame] | 17 | import re |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 18 | import subprocess |
Tobias Wölfel | 19a86e2 | 2020-05-14 14:31:00 +0200 | [diff] [blame] | 19 | import sys |
Sam Elliott | 692078c | 2020-02-07 17:23:21 +0000 | [diff] [blame] | 20 | import textwrap |
Martin Lueker-Boden | dcd6c68 | 2021-05-16 21:20:10 -0700 | [diff] [blame] | 21 | import socket |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 22 | from pathlib import Path |
| 23 | |
Philipp Wagner | 2e217a9 | 2020-10-09 12:19:08 +0200 | [diff] [blame] | 24 | import check_tool_requirements |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 25 | import dashboard.gen_dashboard_entry as gen_dashboard_entry |
Sam Elliott | b6745d3 | 2020-04-08 21:46:28 +0100 | [diff] [blame] | 26 | import difgen.gen_dif_listing as gen_dif_listing |
Srikrishna Iyer | 86169d0 | 2021-05-10 09:35:52 -0700 | [diff] [blame] | 27 | import dvsim.Testplan as Testplan |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 28 | import reggen.gen_cfg_html as gen_cfg_html |
| 29 | import reggen.gen_html as gen_html |
Eunchan Kim | 9790e3e | 2019-11-01 15:17:32 -0700 | [diff] [blame] | 30 | import reggen.gen_selfdoc as reggen_selfdoc |
Eunchan Kim | 9790e3e | 2019-11-01 15:17:32 -0700 | [diff] [blame] | 31 | import tlgen |
Rupert Swarbrick | 269bb3d | 2021-02-23 15:41:56 +0000 | [diff] [blame] | 32 | from reggen.ip_block import IpBlock |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 33 | |
| 34 | USAGE = """ |
| 35 | build_docs [options] |
| 36 | """ |
| 37 | |
Philipp Wagner | cd57f86 | 2019-10-31 14:20:39 +0000 | [diff] [blame] | 38 | # Version of hugo extended to be used to build the docs |
Philipp Wagner | 2e217a9 | 2020-10-09 12:19:08 +0200 | [diff] [blame] | 39 | try: |
Rupert Swarbrick | 9ab407e | 2021-01-25 11:40:17 +0000 | [diff] [blame] | 40 | TOOL_REQUIREMENTS = check_tool_requirements.read_tool_requirements() |
| 41 | HUGO_EXTENDED_VERSION = TOOL_REQUIREMENTS['hugo_extended'].min_version |
Philipp Wagner | 2e217a9 | 2020-10-09 12:19:08 +0200 | [diff] [blame] | 42 | except Exception as e: |
| 43 | print("Unable to get required hugo version: %s" % str(e), file=sys.stderr) |
| 44 | sys.exit(1) |
Philipp Wagner | cd57f86 | 2019-10-31 14:20:39 +0000 | [diff] [blame] | 45 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 46 | # Configurations |
Tobias Wölfel | 7840d7b | 2019-10-07 12:29:33 +0200 | [diff] [blame] | 47 | # TODO: Move to config.yaml |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 48 | SRCTREE_TOP = Path(__file__).parent.joinpath('..').resolve() |
| 49 | config = { |
| 50 | # Toplevel source directory |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 51 | "topdir": |
| 52 | SRCTREE_TOP, |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 53 | |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 54 | # Pre-generate register and hwcfg fragments from these files. |
| 55 | "hardware_definitions": [ |
| 56 | "hw/ip/aes/data/aes.hjson", |
Tom Roberts | 7f173f2 | 2020-12-01 14:29:31 +0000 | [diff] [blame] | 57 | "hw/ip/aon_timer/data/aon_timer.hjson", |
Sam Elliott | d834c70 | 2020-02-12 11:18:47 +0000 | [diff] [blame] | 58 | "hw/top_earlgrey/ip/alert_handler/data/autogen/alert_handler.hjson", |
Mark Branstad | 4efd35e | 2019-12-19 15:44:45 +0000 | [diff] [blame] | 59 | "hw/ip/entropy_src/data/entropy_src.hjson", |
Martin Lueker-Boden | c76cbc7 | 2020-07-21 21:13:35 +0000 | [diff] [blame] | 60 | "hw/ip/csrng/data/csrng.hjson", |
Eric Shiu | 5f1d304 | 2021-03-17 17:24:11 -0700 | [diff] [blame] | 61 | "hw/ip/adc_ctrl/data/adc_ctrl.hjson", |
Martin Lueker-Boden | 94bfa22 | 2020-09-25 12:27:31 -0700 | [diff] [blame] | 62 | "hw/ip/edn/data/edn.hjson", |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 63 | "hw/ip/flash_ctrl/data/flash_ctrl.hjson", |
| 64 | "hw/ip/gpio/data/gpio.hjson", |
| 65 | "hw/ip/hmac/data/hmac.hjson", |
| 66 | "hw/ip/i2c/data/i2c.hjson", |
Timothy Chen | c2e3f05 | 2020-09-10 18:47:25 -0700 | [diff] [blame] | 67 | "hw/ip/keymgr/data/keymgr.hjson", |
Eunchan Kim | 4096f7d | 2020-10-20 17:55:47 -0700 | [diff] [blame] | 68 | "hw/ip/kmac/data/kmac.hjson", |
Michael Schaffner | e81ab75 | 2020-09-30 18:57:29 -0700 | [diff] [blame] | 69 | "hw/ip/lc_ctrl/data/lc_ctrl.hjson", |
Philipp Wagner | 05a5f14 | 2020-06-03 23:42:20 +0100 | [diff] [blame] | 70 | "hw/ip/otbn/data/otbn.hjson", |
Michael Schaffner | 41319c2 | 2020-04-12 15:40:24 -0700 | [diff] [blame] | 71 | "hw/ip/otp_ctrl/data/otp_ctrl.hjson", |
Martin Lueker-Boden | 4d4acea | 2020-08-22 15:23:43 -0700 | [diff] [blame] | 72 | "hw/ip/pattgen/data/pattgen.hjson", |
Martin Lueker-Boden | 5dd1bfb | 2020-11-15 21:18:59 -0800 | [diff] [blame] | 73 | "hw/ip/pwm/data/pwm.hjson", |
Rupert Swarbrick | cd5d00e | 2020-12-02 08:41:35 +0000 | [diff] [blame] | 74 | "hw/ip/rom_ctrl/data/rom_ctrl.hjson", |
Sam Elliott | d834c70 | 2020-02-12 11:18:47 +0000 | [diff] [blame] | 75 | "hw/top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson", |
Timothy Chen | 375be34 | 2020-11-02 12:55:09 -0800 | [diff] [blame] | 76 | "hw/top_earlgrey/ip/clkmgr/data/autogen/clkmgr.hjson", |
Timothy Chen | d7d6e0f | 2020-08-11 18:59:50 -0700 | [diff] [blame] | 77 | "hw/top_earlgrey/ip/pwrmgr/data/autogen/pwrmgr.hjson", |
Timothy Chen | 1e68dd8 | 2020-09-22 16:20:17 -0700 | [diff] [blame] | 78 | "hw/top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson", |
Timothy Chen | 244a8dd | 2021-04-23 16:11:25 -0700 | [diff] [blame] | 79 | "hw/top_earlgrey/ip/sensor_ctrl/data/sensor_ctrl.hjson", |
Timothy Chen | 1e68dd8 | 2020-09-22 16:20:17 -0700 | [diff] [blame] | 80 | "hw/top_earlgrey/ip/rv_plic/data/autogen/rv_plic.hjson", |
Timothy Chen | 576cc08 | 2021-07-21 17:42:48 -0700 | [diff] [blame] | 81 | "hw/ip/rv_core_ibex/data/rv_core_ibex.hjson", |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 82 | "hw/ip/rv_timer/data/rv_timer.hjson", |
Martin Lueker-Boden | eb9498c | 2021-02-02 08:33:29 -0800 | [diff] [blame] | 83 | "hw/ip/spi_host/data/spi_host.hjson", |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 84 | "hw/ip/spi_device/data/spi_device.hjson", |
Michael Schaffner | 86c0e32 | 2020-10-07 19:56:32 -0700 | [diff] [blame] | 85 | "hw/ip/sram_ctrl/data/sram_ctrl.hjson", |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 86 | "hw/ip/sysrst_ctrl/data/sysrst_ctrl.hjson", |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 87 | "hw/ip/uart/data/uart.hjson", |
| 88 | "hw/ip/usbdev/data/usbdev.hjson", |
| 89 | "hw/ip/usbuart/data/usbuart.hjson", |
| 90 | ], |
| 91 | |
| 92 | # Pre-generate dashboard fragments from these directories. |
Philipp Wagner | 8171ede | 2021-03-15 21:47:01 +0000 | [diff] [blame] | 93 | "dashboard_definitions": { |
| 94 | "comportable": [ |
| 95 | "hw/ip", |
Timothy Chen | 244a8dd | 2021-04-23 16:11:25 -0700 | [diff] [blame] | 96 | "hw/top_earlgrey/ip/sensor_ctrl" |
Philipp Wagner | 8171ede | 2021-03-15 21:47:01 +0000 | [diff] [blame] | 97 | ], |
| 98 | }, |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 99 | |
| 100 | # Pre-generate testplan fragments from these files. |
| 101 | "testplan_definitions": [ |
Rasmus Madsen | 206784b | 2019-11-13 14:55:04 -0800 | [diff] [blame] | 102 | "hw/ip/aes/data/aes_testplan.hjson", |
Cindy Chen | 70f9ca5 | 2019-12-02 16:32:58 -0800 | [diff] [blame] | 103 | "hw/ip/alert_handler/data/alert_handler_testplan.hjson", |
Srikrishna Iyer | 1abc7b9 | 2021-03-08 21:46:49 -0800 | [diff] [blame] | 104 | "hw/ip/aon_timer/data/aon_timer_testplan.hjson", |
Guillermo Maturana | d2c7fe6 | 2021-03-31 19:19:18 -0700 | [diff] [blame] | 105 | "hw/ip/clkmgr/data/clkmgr_testplan.hjson", |
Steve Nelson | d677d78 | 2020-04-30 12:35:44 -0700 | [diff] [blame] | 106 | "hw/ip/entropy_src/data/entropy_src_testplan.hjson", |
Steve Nelson | 8cc9fc6 | 2020-12-08 08:00:45 -0800 | [diff] [blame] | 107 | "hw/ip/csrng/data/csrng_testplan.hjson", |
Eric Shiu | 5f1d304 | 2021-03-17 17:24:11 -0700 | [diff] [blame] | 108 | "hw/ip/adc_ctrl/data/adc_ctrl_testplan.hjson", |
Steve Nelson | 8adade0 | 2020-12-17 13:40:35 -0800 | [diff] [blame] | 109 | "hw/ip/edn/data/edn_testplan.hjson", |
Srikrishna Iyer | fb03739 | 2020-07-20 17:11:08 -0700 | [diff] [blame] | 110 | "hw/ip/flash_ctrl/data/flash_ctrl_testplan.hjson", |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 111 | "hw/ip/gpio/data/gpio_testplan.hjson", |
| 112 | "hw/ip/hmac/data/hmac_testplan.hjson", |
| 113 | "hw/ip/i2c/data/i2c_testplan.hjson", |
Timothy Chen | c2e3f05 | 2020-09-10 18:47:25 -0700 | [diff] [blame] | 114 | "hw/ip/keymgr/data/keymgr_testplan.hjson", |
Cindy Chen | b30114e | 2020-11-25 14:41:12 -0800 | [diff] [blame] | 115 | "hw/ip/lc_ctrl/data/lc_ctrl_testplan.hjson", |
Rupert Swarbrick | 7b24766 | 2021-03-19 13:15:28 +0000 | [diff] [blame] | 116 | "hw/ip/otbn/data/otbn_testplan.hjson", |
Cindy Chen | da49359 | 2020-11-25 10:42:37 -0800 | [diff] [blame] | 117 | "hw/ip/otp_ctrl/data/otp_ctrl_testplan.hjson", |
Martin Lueker-Boden | 4d4acea | 2020-08-22 15:23:43 -0700 | [diff] [blame] | 118 | "hw/ip/pattgen/data/pattgen_testplan.hjson", |
Cindy Chen | df135f0 | 2020-04-03 17:20:15 -0700 | [diff] [blame] | 119 | "hw/ip/pinmux/data/pinmux_fpv_testplan.hjson", |
Guillermo Maturana | 966df62 | 2021-05-13 09:28:52 -0700 | [diff] [blame] | 120 | "hw/ip/pwm/data/pwm_testplan.hjson", |
| 121 | "hw/ip/pwrmgr/data/pwrmgr_testplan.hjson", |
Tom Roberts | e856fb7 | 2021-05-12 15:19:31 +0100 | [diff] [blame] | 122 | "hw/ip/rom_ctrl/data/rom_ctrl_testplan.hjson", |
Guillermo Maturana | 0fd914d | 2021-07-01 15:02:17 -0700 | [diff] [blame] | 123 | "hw/ip/rstmgr/data/rstmgr_testplan.hjson", |
Cindy Chen | 9be86fe | 2019-11-02 11:42:18 -0700 | [diff] [blame] | 124 | "hw/ip/rv_plic/data/rv_plic_fpv_testplan.hjson", |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 125 | "hw/ip/rv_timer/data/rv_timer_testplan.hjson", |
Weicai Yang | dda5948 | 2019-11-12 16:42:18 -0800 | [diff] [blame] | 126 | "hw/ip/spi_device/data/spi_device_testplan.hjson", |
Guillermo Maturana | 966df62 | 2021-05-13 09:28:52 -0700 | [diff] [blame] | 127 | "hw/ip/spi_host/data/spi_host_testplan.hjson", |
Srikrishna Iyer | e09bafc | 2021-03-08 21:56:25 -0800 | [diff] [blame] | 128 | "hw/ip/sram_ctrl/data/sram_ctrl_base_testplan.hjson", |
Guillermo Maturana | 966df62 | 2021-05-13 09:28:52 -0700 | [diff] [blame] | 129 | "hw/ip/tlul/data/tlul_testplan.hjson", |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 130 | "hw/ip/uart/data/uart_testplan.hjson", |
Srikrishna Iyer | 627f782 | 2020-01-15 21:39:29 -0800 | [diff] [blame] | 131 | "hw/ip/usbdev/data/usbdev_testplan.hjson", |
Srikrishna Iyer | 5cddaf8 | 2020-04-24 14:19:49 -0700 | [diff] [blame] | 132 | "hw/top_earlgrey/data/chip_testplan.hjson", |
Timothy Chen | f2d7726 | 2019-11-01 17:17:20 -0700 | [diff] [blame] | 133 | "hw/top_earlgrey/data/standalone_sw_testplan.hjson", |
Srikrishna Iyer | 86169d0 | 2021-05-10 09:35:52 -0700 | [diff] [blame] | 134 | "util/dvsim/examples/testplanner/foo_testplan.hjson", |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 135 | ], |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 136 | |
Eunchan Kim | 9790e3e | 2019-11-01 15:17:32 -0700 | [diff] [blame] | 137 | # Pre-generated utility selfdoc |
| 138 | "selfdoc_tools": ["tlgen", "reggen"], |
| 139 | |
Sam Elliott | b6745d3 | 2020-04-08 21:46:28 +0100 | [diff] [blame] | 140 | # DIF Docs |
| 141 | "difs-directory": "sw/device/lib/dif", |
| 142 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 143 | # Output directory for documents |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 144 | "outdir": |
| 145 | SRCTREE_TOP.joinpath('build', 'docs'), |
| 146 | "outdir-generated": |
| 147 | SRCTREE_TOP.joinpath('build', 'docs-generated'), |
| 148 | "verbose": |
| 149 | False, |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 153 | def generate_dashboards(): |
Philipp Wagner | 8171ede | 2021-03-15 21:47:01 +0000 | [diff] [blame] | 154 | for dashboard_name, dirs in config["dashboard_definitions"].items(): |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 155 | hjson_paths = [] |
Philipp Wagner | 8171ede | 2021-03-15 21:47:01 +0000 | [diff] [blame] | 156 | for d in dirs: |
| 157 | hjson_paths += SRCTREE_TOP.joinpath(d).rglob('*.prj.hjson') |
| 158 | |
| 159 | hjson_paths.sort(key=lambda f: f.name) |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 160 | |
| 161 | dashboard_path = config["outdir-generated"].joinpath( |
Philipp Wagner | 8171ede | 2021-03-15 21:47:01 +0000 | [diff] [blame] | 162 | dashboard_name, 'dashboard') |
| 163 | dashboard_path.parent.mkdir(exist_ok=True, parents=True) |
Philipp Wagner | 57df62c | 2019-11-04 14:49:24 +0000 | [diff] [blame] | 164 | dashboard_html = open(str(dashboard_path), mode='w') |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 165 | for hjson_path in hjson_paths: |
| 166 | gen_dashboard_entry.gen_dashboard_html(hjson_path, dashboard_html) |
| 167 | dashboard_html.close() |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 168 | |
| 169 | |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 170 | def generate_hardware_blocks(): |
| 171 | for hardware in config["hardware_definitions"]: |
Rupert Swarbrick | 269bb3d | 2021-02-23 15:41:56 +0000 | [diff] [blame] | 172 | regs = IpBlock.from_path(str(SRCTREE_TOP.joinpath(hardware)), []) |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 173 | |
Rupert Swarbrick | 269bb3d | 2021-02-23 15:41:56 +0000 | [diff] [blame] | 174 | hw_path = config["outdir-generated"].joinpath(hardware) |
| 175 | dst_path = hw_path.parent |
| 176 | dst_path.mkdir(parents=True, exist_ok=True) |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 177 | |
Rupert Swarbrick | 269bb3d | 2021-02-23 15:41:56 +0000 | [diff] [blame] | 178 | regs_path = dst_path.joinpath(hw_path.name + '.registers') |
| 179 | with open(regs_path, 'w') as regs_file: |
| 180 | gen_html.gen_html(regs, regs_file) |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 181 | |
Rupert Swarbrick | 269bb3d | 2021-02-23 15:41:56 +0000 | [diff] [blame] | 182 | hwcfg_path = dst_path.joinpath(hw_path.name + '.hwcfg') |
| 183 | with open(hwcfg_path, 'w') as hwcfg_file: |
| 184 | gen_cfg_html.gen_cfg_html(regs, hwcfg_file) |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 185 | |
| 186 | |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 187 | def generate_testplans(): |
| 188 | for testplan in config["testplan_definitions"]: |
Srikrishna Iyer | 86169d0 | 2021-05-10 09:35:52 -0700 | [diff] [blame] | 189 | plan = Testplan.Testplan(SRCTREE_TOP.joinpath(testplan), |
| 190 | repo_top=SRCTREE_TOP) |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 191 | plan_path = config["outdir-generated"].joinpath(testplan + '.testplan') |
| 192 | plan_path.parent.mkdir(parents=True, exist_ok=True) |
| 193 | |
Philipp Wagner | 57df62c | 2019-11-04 14:49:24 +0000 | [diff] [blame] | 194 | testplan_html = open(str(plan_path), mode='w') |
Srikrishna Iyer | 86169d0 | 2021-05-10 09:35:52 -0700 | [diff] [blame] | 195 | testplan_html.write(plan.get_testplan_table("html")) |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 196 | testplan_html.close() |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 197 | |
| 198 | |
Eunchan Kim | 9790e3e | 2019-11-01 15:17:32 -0700 | [diff] [blame] | 199 | def generate_selfdocs(): |
| 200 | """Generate documents for the tools in `util/` if `--doc` option exists. |
| 201 | |
| 202 | Each tool creates selfdoc differently. Manually invoked. |
| 203 | """ |
| 204 | for tool in config["selfdoc_tools"]: |
| 205 | selfdoc_path = config["outdir-generated"].joinpath(tool + '.selfdoc') |
| 206 | selfdoc_path.parent.mkdir(parents=True, exist_ok=True) |
Philipp Wagner | 57df62c | 2019-11-04 14:49:24 +0000 | [diff] [blame] | 207 | with open(str(selfdoc_path), mode='w') as fout: |
Eunchan Kim | 9790e3e | 2019-11-01 15:17:32 -0700 | [diff] [blame] | 208 | if tool == "reggen": |
| 209 | reggen_selfdoc.document(fout) |
| 210 | elif tool == "tlgen": |
| 211 | fout.write(tlgen.selfdoc(heading=3, cmd='tlgen.py --doc')) |
| 212 | |
Tobias Wölfel | ff54334 | 2020-05-14 16:14:56 +0200 | [diff] [blame] | 213 | |
Pirmin Vogel | 3ff52be | 2021-01-20 18:20:25 +0100 | [diff] [blame] | 214 | def generate_pkg_reqs(): |
| 215 | """Generate an apt/yum command line invocation from |
| 216 | apt/yum-requirements.txt |
Sam Elliott | 692078c | 2020-02-07 17:23:21 +0000 | [diff] [blame] | 217 | |
Pirmin Vogel | 3ff52be | 2021-01-20 18:20:25 +0100 | [diff] [blame] | 218 | This will be saved in outdir-generated/apt_cmd.txt and |
| 219 | outdir-generated/yum_cmd.txt, respectively. |
Sam Elliott | 692078c | 2020-02-07 17:23:21 +0000 | [diff] [blame] | 220 | """ |
Sam Elliott | 692078c | 2020-02-07 17:23:21 +0000 | [diff] [blame] | 221 | |
Pirmin Vogel | 3ff52be | 2021-01-20 18:20:25 +0100 | [diff] [blame] | 222 | for pkgmgr in ["apt", "yum"]: |
| 223 | # Read the apt/yum-requirements.txt |
| 224 | requirements = [] |
| 225 | requirements_file = open(str(SRCTREE_TOP.joinpath(pkgmgr + "-requirements.txt"))) |
| 226 | for package_line in requirements_file.readlines(): |
| 227 | # Ignore everything after `#` on each line, and strip whitespace |
| 228 | package = package_line.split('#', 1)[0].strip() |
| 229 | if package: |
| 230 | # only add non-empty lines to packages |
| 231 | requirements.append(package) |
| 232 | |
| 233 | cmd = "$ sudo " + pkgmgr + " install " + " ".join(requirements) |
| 234 | cmd_lines = textwrap.wrap(cmd, |
Sam Elliott | 692078c | 2020-02-07 17:23:21 +0000 | [diff] [blame] | 235 | width=78, |
| 236 | replace_whitespace=True, |
| 237 | subsequent_indent=' ') |
Pirmin Vogel | 3ff52be | 2021-01-20 18:20:25 +0100 | [diff] [blame] | 238 | # Newlines need to be escaped |
| 239 | cmd = " \\\n".join(cmd_lines) |
Sam Elliott | 692078c | 2020-02-07 17:23:21 +0000 | [diff] [blame] | 240 | |
Pirmin Vogel | 3ff52be | 2021-01-20 18:20:25 +0100 | [diff] [blame] | 241 | # And then to write the generated string directly to the file. |
| 242 | cmd_path = config["outdir-generated"].joinpath(pkgmgr + '_cmd.txt') |
| 243 | cmd_path.parent.mkdir(parents=True, exist_ok=True) |
| 244 | with open(str(cmd_path), mode='w') as fout: |
| 245 | fout.write(cmd) |
Sam Elliott | 692078c | 2020-02-07 17:23:21 +0000 | [diff] [blame] | 246 | |
Tobias Wölfel | ff54334 | 2020-05-14 16:14:56 +0200 | [diff] [blame] | 247 | |
Pirmin Vogel | 0761f1c | 2020-03-09 17:47:45 +0100 | [diff] [blame] | 248 | def generate_tool_versions(): |
| 249 | """Generate an tool version number requirement from tool_requirements.py |
| 250 | |
| 251 | The version number per tool will be saved in outdir-generated/version_$TOOL_NAME.txt |
| 252 | """ |
| 253 | |
Pirmin Vogel | 0761f1c | 2020-03-09 17:47:45 +0100 | [diff] [blame] | 254 | # And then write a version file for every tool. |
Rupert Swarbrick | 9ab407e | 2021-01-25 11:40:17 +0000 | [diff] [blame] | 255 | for tool, req in TOOL_REQUIREMENTS.items(): |
Pirmin Vogel | 0761f1c | 2020-03-09 17:47:45 +0100 | [diff] [blame] | 256 | version_path = config["outdir-generated"].joinpath('version_' + tool + '.txt') |
| 257 | version_path.parent.mkdir(parents=True, exist_ok=True) |
| 258 | with open(str(version_path), mode='w') as fout: |
Rupert Swarbrick | 9ab407e | 2021-01-25 11:40:17 +0000 | [diff] [blame] | 259 | fout.write(req.min_version) |
Pirmin Vogel | 0761f1c | 2020-03-09 17:47:45 +0100 | [diff] [blame] | 260 | |
Eunchan Kim | 4096f7d | 2020-10-20 17:55:47 -0700 | [diff] [blame] | 261 | |
Sam Elliott | b6745d3 | 2020-04-08 21:46:28 +0100 | [diff] [blame] | 262 | def generate_dif_docs(): |
| 263 | """Generate doxygen documentation and DIF listings from DIF source comments. |
| 264 | |
| 265 | This invokes Doxygen, and a few other things. Be careful of changing any |
| 266 | paths here, some correspond to paths in other configuration files. |
| 267 | """ |
| 268 | |
| 269 | logging.info("Generating Software API Documentation (Doxygen)...") |
| 270 | |
| 271 | doxygen_out_path = config["outdir-generated"].joinpath("sw") |
| 272 | |
| 273 | # The next two paths correspond to relative paths specified in the Doxyfile |
| 274 | doxygen_xml_path = doxygen_out_path.joinpath("api-xml") |
| 275 | |
| 276 | # We need to prepare this path because doxygen won't `mkdir -p` |
| 277 | doxygen_sw_path = doxygen_out_path.joinpath("public-api/sw/apis") |
| 278 | doxygen_sw_path.mkdir(parents=True, exist_ok=True) |
| 279 | |
Sam Elliott | c8fa558 | 2020-04-08 21:02:05 +0100 | [diff] [blame] | 280 | # This is where warnings will be generated |
| 281 | doxygen_warnings_path = doxygen_out_path.joinpath("doxygen_warnings.log") |
| 282 | if doxygen_warnings_path.exists(): |
| 283 | doxygen_warnings_path.unlink() |
| 284 | |
Sam Elliott | b6745d3 | 2020-04-08 21:46:28 +0100 | [diff] [blame] | 285 | doxygen_args = [ |
| 286 | "doxygen", |
| 287 | str(SRCTREE_TOP.joinpath("util/doxygen/Doxyfile")), |
| 288 | ] |
| 289 | |
Eunchan Kim | 4096f7d | 2020-10-20 17:55:47 -0700 | [diff] [blame] | 290 | doxygen_results = subprocess.run( # noqa: F841 |
| 291 | doxygen_args, check=True, |
Sam Elliott | b6745d3 | 2020-04-08 21:46:28 +0100 | [diff] [blame] | 292 | cwd=str(SRCTREE_TOP), stdout=subprocess.PIPE, |
Eunchan Kim | 4096f7d | 2020-10-20 17:55:47 -0700 | [diff] [blame] | 293 | env=dict( |
| 294 | os.environ, |
Sam Elliott | b6745d3 | 2020-04-08 21:46:28 +0100 | [diff] [blame] | 295 | SRCTREE_TOP=str(SRCTREE_TOP), |
| 296 | DOXYGEN_OUT=str(doxygen_out_path), |
| 297 | )) |
| 298 | |
| 299 | logging.info("Generated Software API Documentation (Doxygen)") |
| 300 | |
Sam Elliott | c8fa558 | 2020-04-08 21:02:05 +0100 | [diff] [blame] | 301 | if doxygen_warnings_path.exists(): |
Eunchan Kim | 4096f7d | 2020-10-20 17:55:47 -0700 | [diff] [blame] | 302 | logging.warning("Doxygen Generated Warnings " |
| 303 | "(saved in {})".format(str(doxygen_warnings_path))) |
Sam Elliott | c8fa558 | 2020-04-08 21:02:05 +0100 | [diff] [blame] | 304 | |
Sam Elliott | b6745d3 | 2020-04-08 21:46:28 +0100 | [diff] [blame] | 305 | combined_xml = gen_dif_listing.get_combined_xml(doxygen_xml_path) |
| 306 | |
| 307 | dif_paths = [] |
| 308 | dif_paths.extend(sorted(SRCTREE_TOP.joinpath(config["difs-directory"]).glob("dif_*.h"))) |
| 309 | |
| 310 | dif_listings_root_path = config["outdir-generated"].joinpath("sw/difs_listings") |
| 311 | difrefs_root_path = config["outdir-generated"].joinpath("sw/difref") |
| 312 | |
| 313 | for dif_header_path in dif_paths: |
| 314 | dif_header = str(dif_header_path.relative_to(SRCTREE_TOP)) |
| 315 | |
| 316 | dif_listings_filename = dif_listings_root_path.joinpath(dif_header + ".html") |
| 317 | dif_listings_filename.parent.mkdir(parents=True, exist_ok=True) |
| 318 | |
Sam Elliott | 24398ab | 2020-07-17 17:02:05 +0100 | [diff] [blame] | 319 | with open(str(dif_listings_filename), mode='w') as dif_listings_html: |
| 320 | gen_dif_listing.gen_listing_html(combined_xml, dif_header, |
| 321 | dif_listings_html) |
Sam Elliott | b6745d3 | 2020-04-08 21:46:28 +0100 | [diff] [blame] | 322 | |
| 323 | difref_functions = gen_dif_listing.get_difref_info(combined_xml, dif_header) |
| 324 | for function in difref_functions: |
| 325 | difref_filename = difrefs_root_path.joinpath(function["name"] + '.html') |
| 326 | difref_filename.parent.mkdir(parents=True, exist_ok=True) |
| 327 | |
Sam Elliott | 24398ab | 2020-07-17 17:02:05 +0100 | [diff] [blame] | 328 | with open(str(difref_filename), mode='w') as difref_html: |
| 329 | gen_dif_listing.gen_difref_html(function, difref_html) |
Sam Elliott | b6745d3 | 2020-04-08 21:46:28 +0100 | [diff] [blame] | 330 | |
| 331 | logging.info("Generated DIF Listing for {}".format(dif_header)) |
| 332 | |
Eunchan Kim | 9790e3e | 2019-11-01 15:17:32 -0700 | [diff] [blame] | 333 | |
Rupert Swarbrick | 63da48e | 2020-07-08 10:16:57 +0100 | [diff] [blame] | 334 | def generate_otbn_isa(): |
| 335 | '''Generate the OTBN ISA documentation fragment |
| 336 | |
| 337 | The result is in Markdown format and is written to |
| 338 | outdir-generated/otbn-isa.md |
| 339 | |
| 340 | ''' |
| 341 | otbn_dir = SRCTREE_TOP / 'hw/ip/otbn' |
| 342 | script = otbn_dir / 'util/yaml_to_doc.py' |
| 343 | yaml_file = otbn_dir / 'data/insns.yml' |
Rupert Swarbrick | 4077bec | 2020-10-05 11:50:11 +0100 | [diff] [blame] | 344 | impl_file = otbn_dir / 'dv/otbnsim/sim/insn.py' |
Rupert Swarbrick | 63da48e | 2020-07-08 10:16:57 +0100 | [diff] [blame] | 345 | |
Rupert Swarbrick | d3de4bb | 2020-09-01 17:50:19 +0100 | [diff] [blame] | 346 | out_dir = config['outdir-generated'].joinpath('otbn-isa') |
Rupert Swarbrick | 4077bec | 2020-10-05 11:50:11 +0100 | [diff] [blame] | 347 | subprocess.run([str(script), str(yaml_file), str(impl_file), str(out_dir)], |
| 348 | check=True) |
Rupert Swarbrick | 63da48e | 2020-07-08 10:16:57 +0100 | [diff] [blame] | 349 | |
| 350 | |
Tobias Wölfel | 19a86e2 | 2020-05-14 14:31:00 +0200 | [diff] [blame] | 351 | def hugo_match_version(hugo_bin_path, version): |
| 352 | logging.info("Hugo binary path: %s", hugo_bin_path) |
| 353 | args = [str(hugo_bin_path), "version"] |
Silvestrs Timofejevs | ecaf87c | 2019-11-12 21:52:57 +0000 | [diff] [blame] | 354 | process = subprocess.run(args, |
| 355 | universal_newlines=True, |
| 356 | stdout=subprocess.PIPE, |
| 357 | check=True, |
| 358 | cwd=str(SRCTREE_TOP)) |
| 359 | |
Tobias Wölfel | 19a86e2 | 2020-05-14 14:31:00 +0200 | [diff] [blame] | 360 | logging.info("Checking for correct Hugo version: %s", version) |
Silvestrs Timofejevs | ecaf87c | 2019-11-12 21:52:57 +0000 | [diff] [blame] | 361 | # Hugo version string example: |
Tobias Wölfel | ff54334 | 2020-05-14 16:14:56 +0200 | [diff] [blame] | 362 | # "Hugo Static Site Generator v0.59.0-1DD0C69C/extended linux/amd64 BuildDate: 2019-10-21T09:45:38Z" # noqa: E501 |
Rupert Swarbrick | 4dcb074 | 2021-04-28 14:54:17 +0100 | [diff] [blame] | 363 | return bool(re.search("v" + version + ".*[/+]extended", process.stdout)) |
Silvestrs Timofejevs | ecaf87c | 2019-11-12 21:52:57 +0000 | [diff] [blame] | 364 | |
| 365 | |
Philipp Wagner | cd57f86 | 2019-10-31 14:20:39 +0000 | [diff] [blame] | 366 | def install_hugo(install_dir): |
| 367 | """Download and "install" hugo into |install_dir| |
| 368 | |
| 369 | install_dir is created if it doesn't exist yet. |
| 370 | |
| 371 | Limitations: |
Sam Elliott | 1087d27 | 2020-11-17 18:56:19 +0000 | [diff] [blame] | 372 | Currently only 64-bit x86 Linux and macOS is supported.""" |
Philipp Wagner | cd57f86 | 2019-10-31 14:20:39 +0000 | [diff] [blame] | 373 | |
| 374 | # TODO: Support more configurations |
Sam Elliott | 1087d27 | 2020-11-17 18:56:19 +0000 | [diff] [blame] | 375 | if platform.system() == 'Linux' and platform.machine() == 'x86_64': |
| 376 | download_url = ('https://github.com/gohugoio/hugo/releases/download/v{version}' |
Timothy Chen | 7df1434 | 2021-03-23 17:05:38 -0700 | [diff] [blame] | 377 | '/hugo_extended_{version}_Linux-64bit.tar.gz').format( |
| 378 | version=HUGO_EXTENDED_VERSION) |
Philipp Wagner | cd57f86 | 2019-10-31 14:20:39 +0000 | [diff] [blame] | 379 | |
Sam Elliott | 1087d27 | 2020-11-17 18:56:19 +0000 | [diff] [blame] | 380 | elif platform.system() == 'Darwin' and platform.machine() == 'x86_64': |
Timothy Chen | 7df1434 | 2021-03-23 17:05:38 -0700 | [diff] [blame] | 381 | download_url = ('https://github.com/gohugoio/hugo/releases/download/v{version}' |
| 382 | '/hugo_extended_{version}_macOS-64bit.tar.gz').format( |
| 383 | version=HUGO_EXTENDED_VERSION) |
Sam Elliott | 1087d27 | 2020-11-17 18:56:19 +0000 | [diff] [blame] | 384 | |
| 385 | else: |
| 386 | logging.fatal( |
| 387 | "Auto-install of hugo only supported for 64-bit x86 Linux and " |
| 388 | "macOS. Manually install hugo and re-run this script with --force-global.") |
| 389 | return False |
| 390 | |
Philipp Wagner | cd57f86 | 2019-10-31 14:20:39 +0000 | [diff] [blame] | 391 | install_dir.mkdir(exist_ok=True, parents=True) |
| 392 | hugo_bin_path = install_dir / 'hugo' |
| 393 | |
Tobias Wölfel | 19a86e2 | 2020-05-14 14:31:00 +0200 | [diff] [blame] | 394 | try: |
| 395 | if hugo_match_version(hugo_bin_path, HUGO_EXTENDED_VERSION): |
| 396 | return hugo_bin_path |
Tobias Wölfel | ff54334 | 2020-05-14 16:14:56 +0200 | [diff] [blame] | 397 | except PermissionError: |
Tobias Wölfel | 19a86e2 | 2020-05-14 14:31:00 +0200 | [diff] [blame] | 398 | # If there is an error checking the version just continue to download |
Tobias Wölfel | ff54334 | 2020-05-14 16:14:56 +0200 | [diff] [blame] | 399 | logging.info("Hugo version could not be verified. Continue to download.") |
| 400 | except FileNotFoundError: |
Tobias Wölfel | 19a86e2 | 2020-05-14 14:31:00 +0200 | [diff] [blame] | 401 | pass |
| 402 | |
Philipp Wagner | cd57f86 | 2019-10-31 14:20:39 +0000 | [diff] [blame] | 403 | # TODO: Investigate the use of Python builtins for downloading. Extracting |
| 404 | # the archive will probably will be a call to tar. |
Sam Elliott | 1087d27 | 2020-11-17 18:56:19 +0000 | [diff] [blame] | 405 | cmd = 'curl -sL {download_url} | tar -xzO hugo > {hugo_bin_file}'.format( |
Philipp Wagner | cd57f86 | 2019-10-31 14:20:39 +0000 | [diff] [blame] | 406 | hugo_bin_file=str(hugo_bin_path), download_url=download_url) |
| 407 | logging.info("Calling %s to download hugo.", cmd) |
Philipp Wagner | 57df62c | 2019-11-04 14:49:24 +0000 | [diff] [blame] | 408 | subprocess.run(cmd, shell=True, check=True, cwd=str(SRCTREE_TOP)) |
Philipp Wagner | cd57f86 | 2019-10-31 14:20:39 +0000 | [diff] [blame] | 409 | hugo_bin_path.chmod(0o755) |
Tobias Wölfel | 19a86e2 | 2020-05-14 14:31:00 +0200 | [diff] [blame] | 410 | return hugo_bin_path |
Philipp Wagner | cd57f86 | 2019-10-31 14:20:39 +0000 | [diff] [blame] | 411 | |
| 412 | |
Martin Lueker-Boden | dcd6c68 | 2021-05-16 21:20:10 -0700 | [diff] [blame] | 413 | def invoke_hugo(preview, bind_wan, hugo_opts, hugo_bin_path): |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 414 | site_docs = SRCTREE_TOP.joinpath('site', 'docs') |
| 415 | config_file = str(site_docs.joinpath('config.toml')) |
| 416 | layout_dir = str(site_docs.joinpath('layouts')) |
| 417 | args = [ |
Tobias Wölfel | 19a86e2 | 2020-05-14 14:31:00 +0200 | [diff] [blame] | 418 | str(hugo_bin_path), |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 419 | "--config", |
| 420 | config_file, |
| 421 | "--destination", |
| 422 | str(config["outdir"]), |
| 423 | "--contentDir", |
| 424 | str(SRCTREE_TOP), |
| 425 | "--layoutDir", |
| 426 | layout_dir, |
| 427 | ] |
| 428 | if preview: |
| 429 | args += ["server"] |
Martin Lueker-Boden | dcd6c68 | 2021-05-16 21:20:10 -0700 | [diff] [blame] | 430 | # --bind-wan only applies when previewing. |
| 431 | if bind_wan: |
Guillermo Maturana | 0fd914d | 2021-07-01 15:02:17 -0700 | [diff] [blame] | 432 | args += ["--bind", "0.0.0.0", "--baseURL", |
| 433 | "http://" + socket.getfqdn()] |
| 434 | if hugo_opts is not None: |
Martin Lueker-Boden | dcd6c68 | 2021-05-16 21:20:10 -0700 | [diff] [blame] | 435 | args += hugo_opts |
| 436 | |
Philipp Wagner | 57df62c | 2019-11-04 14:49:24 +0000 | [diff] [blame] | 437 | subprocess.run(args, check=True, cwd=str(SRCTREE_TOP)) |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 438 | |
| 439 | |
| 440 | def main(): |
| 441 | logging.basicConfig(level=logging.INFO, |
| 442 | format="%(asctime)s - %(message)s", |
| 443 | datefmt="%Y-%m-%d %H:%M") |
| 444 | |
| 445 | parser = argparse.ArgumentParser( |
| 446 | prog="build_docs", |
| 447 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 448 | usage=USAGE) |
| 449 | parser.add_argument( |
| 450 | '--preview', |
| 451 | action='store_true', |
Tobias Wölfel | ff54334 | 2020-05-14 16:14:56 +0200 | [diff] [blame] | 452 | help="""Starts a local server with live reload (updates triggered upon |
| 453 | changes in the documentation files). This feature is intended |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 454 | to preview the documentation locally.""") |
Tobias Wölfel | 19a86e2 | 2020-05-14 14:31:00 +0200 | [diff] [blame] | 455 | parser.add_argument( |
Martin Lueker-Boden | dcd6c68 | 2021-05-16 21:20:10 -0700 | [diff] [blame] | 456 | '--bind-wan', |
| 457 | action='store_true', |
| 458 | help="""When previewing, bind to all interfaces (instead of just |
| 459 | localhost). This makes the documentation preview visible from |
| 460 | other hosts.""") |
| 461 | parser.add_argument( |
Tobias Wölfel | 19a86e2 | 2020-05-14 14:31:00 +0200 | [diff] [blame] | 462 | '--force-global', |
| 463 | action='store_true', |
| 464 | help="""Use a global installation of Hugo. This skips the version |
| 465 | check and relies on Hugo to be available from the environment.""") |
Martin Lueker-Boden | dcd6c68 | 2021-05-16 21:20:10 -0700 | [diff] [blame] | 466 | parser.add_argument( |
| 467 | '--hugo-opts', |
| 468 | nargs=argparse.REMAINDER, |
| 469 | help="""Indicates that all following arguments should be passed as |
| 470 | additional options to hugo. This may be useful for controlling |
| 471 | server bindings and so forth.""") |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 472 | parser.add_argument('--hugo', help="""TODO""") |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 473 | |
| 474 | args = parser.parse_args() |
| 475 | |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 476 | generate_hardware_blocks() |
| 477 | generate_dashboards() |
| 478 | generate_testplans() |
Eunchan Kim | 9790e3e | 2019-11-01 15:17:32 -0700 | [diff] [blame] | 479 | generate_selfdocs() |
Pirmin Vogel | 3ff52be | 2021-01-20 18:20:25 +0100 | [diff] [blame] | 480 | generate_pkg_reqs() |
Pirmin Vogel | 0761f1c | 2020-03-09 17:47:45 +0100 | [diff] [blame] | 481 | generate_tool_versions() |
Sam Elliott | b6745d3 | 2020-04-08 21:46:28 +0100 | [diff] [blame] | 482 | generate_dif_docs() |
Rupert Swarbrick | 63da48e | 2020-07-08 10:16:57 +0100 | [diff] [blame] | 483 | generate_otbn_isa() |
Philipp Wagner | cd57f86 | 2019-10-31 14:20:39 +0000 | [diff] [blame] | 484 | |
| 485 | hugo_localinstall_dir = SRCTREE_TOP / 'build' / 'docs-hugo' |
| 486 | os.environ["PATH"] += os.pathsep + str(hugo_localinstall_dir) |
| 487 | |
Tobias Wölfel | 19a86e2 | 2020-05-14 14:31:00 +0200 | [diff] [blame] | 488 | hugo_bin_path = "hugo" |
| 489 | if not args.force_global: |
| 490 | try: |
| 491 | hugo_bin_path = install_hugo(hugo_localinstall_dir) |
| 492 | except KeyboardInterrupt: |
| 493 | pass |
Silvestrs Timofejevs | ecaf87c | 2019-11-12 21:52:57 +0000 | [diff] [blame] | 494 | |
Tobias Wölfel | 19a86e2 | 2020-05-14 14:31:00 +0200 | [diff] [blame] | 495 | try: |
Martin Lueker-Boden | dcd6c68 | 2021-05-16 21:20:10 -0700 | [diff] [blame] | 496 | invoke_hugo(args.preview, args.bind_wan, args.hugo_opts, hugo_bin_path) |
Tobias Wölfel | 19a86e2 | 2020-05-14 14:31:00 +0200 | [diff] [blame] | 497 | except subprocess.CalledProcessError: |
| 498 | sys.exit("Error building site") |
| 499 | except PermissionError: |
| 500 | sys.exit("Error running Hugo") |
Philipp Wagner | e08be11 | 2019-10-31 14:43:52 +0000 | [diff] [blame] | 501 | except KeyboardInterrupt: |
| 502 | pass |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 503 | |
| 504 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 505 | if __name__ == "__main__": |
| 506 | main() |