1# Generate toolchain download links from toolchain info makefile
2from __future__ import print_function
3
4import os.path
5
6from .util import call_with_python, copy_if_modified
7
8
9def setup(app):
10    # we don't actually need idf-info, just a convenient event to trigger this on
11    app.connect('idf-info', generate_idf_tools_links)
12
13    return {'parallel_read_safe': True, 'parallel_write_safe': True, 'version': '0.1'}
14
15
16def generate_idf_tools_links(app, project_description):
17    print('Generating IDF Tools list')
18    os.environ['IDF_MAINTAINER'] = '1'
19    tools_rst = os.path.join(app.config.build_dir, 'inc', 'idf-tools-inc.rst')
20    tools_rst_tmp = os.path.join(app.config.build_dir, 'idf-tools-inc.rst')
21    call_with_python('{}/tools/idf_tools.py gen-doc --output {}'.format(app.config.idf_path, tools_rst_tmp))
22    copy_if_modified(tools_rst_tmp, tools_rst)
23