Skip to content

Commit

Permalink
[util] Allow optional tools in check_tool_requirements
Browse files Browse the repository at this point in the history
tool_requirements.py lists minimum versions for tools, but the
distinction between "tools that absolutely need to be installed" and
"the minimum version of a tool if you want to run it" was baked in to
check_tool_requirements.py

This patch moves that distinction to the (more user-editable)
tool_requirements.py. Tools that are marked as_needed aren't checked
unless they are passed on the command line to
check_tool_requirements.py.

Signed-off-by: Rupert Swarbrick <[email protected]>
  • Loading branch information
rswarbrick committed Jan 28, 2021
1 parent 282e009 commit 9ab407e
Show file tree
Hide file tree
Showing 4 changed files with 387 additions and 143 deletions.
2 changes: 1 addition & 1 deletion doc/ug/install_instructions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ For packages listed below without a version number we have not determined a mini
GCC 5 or Clang 3.5 should meet this requirement.
* clang-format.
The use of clang-format 6.0 is recommended to match the formatting enforced when submitting a pull request.
* [ninja](https://ninja-build.org/) {{< tool_version "ninja-build" >}}
* [ninja](https://ninja-build.org/) {{< tool_version "ninja" >}}
* Bash
* curl
* xz tools
Expand Down
28 changes: 25 additions & 3 deletions tool_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,32 @@

# Version requirements for various tools. Checked by tooling (e.g. fusesoc),
# and inserted into the documentation.
#
# Entries are keyed by tool name. The value is either a string giving the
# minimum version number or is a dictionary. If a dictionary, the following
# keys are recognised:
#
# min_version: Required string. Minimum version number.
#
# as_needed: Optional bool. Defaults to False. If set, this tool is not
# automatically required. If it is asked for, the rest of the
# entry gives the required version.
#
__TOOL_REQUIREMENTS__ = {
'edalize': '0.2.0',
'hugo_extended': '0.71.0',
'ninja-build': '1.8.2',
'verible': 'v0.0-808-g1e17daa',
'ninja': '1.8.2',
'verilator': '4.104',

'hugo_extended': {
'min_version': '0.71.0',
'as_needed': True
},
'verible': {
'min_version': 'v0.0-808-g1e17daa',
'as_needed': True
},
'vcs': {
'min_version': '2020.03-SP2',
'as_needed': True
}
}
12 changes: 4 additions & 8 deletions util/build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

# Version of hugo extended to be used to build the docs
try:
tool_requirements = check_tool_requirements.read_tool_requirements()
HUGO_EXTENDED_VERSION = tool_requirements['hugo_extended']
TOOL_REQUIREMENTS = check_tool_requirements.read_tool_requirements()
HUGO_EXTENDED_VERSION = TOOL_REQUIREMENTS['hugo_extended'].min_version
except Exception as e:
print("Unable to get required hugo version: %s" % str(e), file=sys.stderr)
sys.exit(1)
Expand Down Expand Up @@ -241,16 +241,12 @@ def generate_tool_versions():
The version number per tool will be saved in outdir-generated/version_$TOOL_NAME.txt
"""

# Populate __TOOL_REQUIREMENTS__
requirements_file = str(SRCTREE_TOP.joinpath("tool_requirements.py"))
exec(open(requirements_file).read(), globals())

# And then write a version file for every tool.
for tool in __TOOL_REQUIREMENTS__: # noqa: F821
for tool, req in TOOL_REQUIREMENTS.items():
version_path = config["outdir-generated"].joinpath('version_' + tool + '.txt')
version_path.parent.mkdir(parents=True, exist_ok=True)
with open(str(version_path), mode='w') as fout:
fout.write(__TOOL_REQUIREMENTS__[tool]) # noqa: F821
fout.write(req.min_version)


def generate_dif_docs():
Expand Down
Loading

0 comments on commit 9ab407e

Please sign in to comment.