From 517c61a4ec2f2506a18de7aa4e4c0bce221dcba5 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 10 Jun 2019 23:29:18 +0800 Subject: [PATCH] docs: fix generation of toolchain links Closes https://github.com/espressif/esp-idf/issues/3609 --- docs/gen-toolchain-links.py | 41 ++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/docs/gen-toolchain-links.py b/docs/gen-toolchain-links.py index ea90f47c7..885817438 100644 --- a/docs/gen-toolchain-links.py +++ b/docs/gen-toolchain-links.py @@ -9,6 +9,15 @@ from __future__ import print_function import sys import os +from collections import namedtuple + +PlatformInfo = namedtuple("PlatformInfo", [ + "platform_name", + "platform_archive_suffix", + "extension", + "unpack_cmd", + "unpack_code" +]) def main(): @@ -44,35 +53,33 @@ def main(): scratch_build_code_linux_macos = """ :: - git clone -b xtensa-1.22.x https://github.com/espressif/crosstool-NG.git + git clone https://github.com/espressif/crosstool-NG.git cd crosstool-NG + git checkout {} ./bootstrap && ./configure --enable-local && make install """ - platform_info = [["linux64", "tar.gz", "z", unpack_code_linux_macos], - ["linux32", "tar.gz", "z", unpack_code_linux_macos], - ["osx", "tar.gz", "z", unpack_code_linux_macos], - ["win32", "zip", None, None]] + platform_info = [ + PlatformInfo("linux64", "linux-amd64", "tar.gz", "z", unpack_code_linux_macos), + PlatformInfo("linux32", "linux-i686","tar.gz", "z", unpack_code_linux_macos), + PlatformInfo("osx", "macos", "tar.gz", "z", unpack_code_linux_macos), + PlatformInfo("win32", "win32", "zip", None, None) + ] with open(os.path.join(out_dir, 'download-links.inc'), "w") as links_file: for p in platform_info: - platform_name = p[0] - extension = p[1] - unpack_cmd = p[2] - unpack_code = p[3] - - archive_name = 'xtensa-esp32-elf-{}-{}-{}.{}'.format( - platform_name, toolchain_desc, gcc_version, extension) + archive_name = 'xtensa-esp32-elf-gcc{}-{}-{}.{}'.format( + gcc_version.replace('.', '_'), toolchain_desc, p.platform_archive_suffix, p.extension) print('.. |download_link_{}| replace:: {}{}'.format( - platform_name, base_url, archive_name), file=links_file) + p.platform_name, base_url, archive_name), file=links_file) - if unpack_code is not None: - with open(os.path.join(out_dir, 'unpack-code-%s.inc' % platform_name), "w") as f: - print(unpack_code.format(unpack_cmd, archive_name), file=f) + if p.unpack_code is not None: + with open(os.path.join(out_dir, 'unpack-code-%s.inc' % p.platform_name), "w") as f: + print(p.unpack_code.format(p.unpack_cmd, archive_name), file=f) with open(os.path.join(out_dir, 'scratch-build-code.inc'), "w") as code_file: - print(scratch_build_code_linux_macos, file=code_file) + print(scratch_build_code_linux_macos.format(toolchain_desc), file=code_file) if __name__ == "__main__":