mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feat(tools): Option in tools.json to rename toolchanis being downloaded
- Implemented condition that version 1 of tools.json must not contain new rename_dist keyword in any of #/definitions/versionInfo properties.
This commit is contained in:
parent
562bb6783a
commit
56e3e8ce56
@ -83,7 +83,7 @@ TOOLS_FILE = 'tools/tools.json'
|
||||
TOOLS_SCHEMA_FILE = 'tools/tools_schema.json'
|
||||
TOOLS_FILE_NEW = 'tools/tools.new.json'
|
||||
IDF_ENV_FILE = 'idf-env.json'
|
||||
TOOLS_FILE_VERSION = 1
|
||||
TOOLS_FILE_VERSION = 2
|
||||
IDF_TOOLS_PATH_DEFAULT = os.path.join('~', '.espressif')
|
||||
UNKNOWN_VERSION = 'unknown'
|
||||
SUBST_TOOL_PATH_REGEX = re.compile(r'\${TOOL_PATH}')
|
||||
@ -555,12 +555,12 @@ class ToolExecError(RuntimeError):
|
||||
|
||||
|
||||
class IDFToolDownload(object):
|
||||
def __init__(self, platform_name, url, size, sha256): # type: (str, str, int, str) -> None
|
||||
def __init__(self, platform_name, url, size, sha256, rename_dist): # type: (str, str, int, str, str) -> None
|
||||
self.platform_name = platform_name
|
||||
self.url = url
|
||||
self.size = size
|
||||
self.sha256 = sha256
|
||||
self.platform_name = platform_name
|
||||
self.rename_dist = rename_dist
|
||||
|
||||
|
||||
@functools.total_ordering
|
||||
@ -590,8 +590,8 @@ class IDFToolVersion(object):
|
||||
return NotImplemented
|
||||
return self.status == other.status and self.version == other.version
|
||||
|
||||
def add_download(self, platform_name, url, size, sha256): # type: (str, str, int, str) -> None
|
||||
self.downloads[platform_name] = IDFToolDownload(platform_name, url, size, sha256)
|
||||
def add_download(self, platform_name, url, size, sha256, rename_dist=''): # type: (str, str, int, str, str) -> None
|
||||
self.downloads[platform_name] = IDFToolDownload(platform_name, url, size, sha256, rename_dist)
|
||||
|
||||
def get_download_for_platform(self, platform_name): # type: (Optional[str]) -> Optional[IDFToolDownload]
|
||||
platform_name = Platforms.get(platform_name)
|
||||
@ -855,7 +855,7 @@ class IDFTool(object):
|
||||
raise SystemExit(1)
|
||||
|
||||
url = download_obj.url
|
||||
archive_name = os.path.basename(url)
|
||||
archive_name = download_obj.rename_dist if download_obj.rename_dist else os.path.basename(url)
|
||||
local_path = os.path.join(global_idf_tools_path or '', 'dist', archive_name)
|
||||
mkdir_p(os.path.dirname(local_path))
|
||||
|
||||
@ -889,7 +889,7 @@ class IDFTool(object):
|
||||
assert version in self.versions
|
||||
download_obj = self.versions[version].get_download_for_platform(self._platform)
|
||||
assert download_obj is not None
|
||||
archive_name = os.path.basename(download_obj.url)
|
||||
archive_name = download_obj.rename_dist if download_obj.rename_dist else os.path.basename(download_obj.url)
|
||||
archive_path = os.path.join(global_idf_tools_path or '', 'dist', archive_name)
|
||||
assert os.path.isfile(archive_path)
|
||||
dest_dir = self.get_path_for_version(version)
|
||||
@ -1041,7 +1041,8 @@ class IDFTool(object):
|
||||
(platform_id, tool_name, version))
|
||||
|
||||
version_obj.add_download(platform_id,
|
||||
platform_dict['url'], platform_dict['size'], platform_dict['sha256'])
|
||||
platform_dict['url'], platform_dict['size'],
|
||||
platform_dict['sha256'], platform_dict.get('rename_dist', ''))
|
||||
|
||||
if version_status == IDFToolVersion.STATUS_RECOMMENDED:
|
||||
if platform_id not in recommended_versions:
|
||||
@ -1068,6 +1069,14 @@ class IDFTool(object):
|
||||
'status': version_obj.status
|
||||
}
|
||||
for platform_id, download in version_obj.downloads.items():
|
||||
if download.rename_dist:
|
||||
version_json[platform_id] = {
|
||||
'url': download.url,
|
||||
'size': download.size,
|
||||
'sha256': download.sha256,
|
||||
'rename_dist': download.rename_dist
|
||||
}
|
||||
else:
|
||||
version_json[platform_id] = {
|
||||
'url': download.url,
|
||||
'size': download.size,
|
||||
@ -1339,9 +1348,6 @@ def parse_tools_info_json(tools_info): # type: ignore
|
||||
Parse and validate the dictionary obtained by loading the tools.json file.
|
||||
Returns a dictionary of tools (key: tool name, value: IDFTool object).
|
||||
"""
|
||||
if tools_info['version'] != TOOLS_FILE_VERSION:
|
||||
raise RuntimeError('Invalid version')
|
||||
|
||||
tools_dict = OrderedDict()
|
||||
|
||||
tools_array = tools_info.get('tools')
|
||||
@ -2321,7 +2327,8 @@ def action_add_version(args): # type: ignore
|
||||
if not tool_obj:
|
||||
info('Creating new tool entry for {}'.format(tool_name))
|
||||
tool_obj = IDFTool(tool_name, TODO_MESSAGE, IDFTool.INSTALL_ALWAYS,
|
||||
TODO_MESSAGE, TODO_MESSAGE, [TODO_MESSAGE], TODO_MESSAGE)
|
||||
TODO_MESSAGE, TODO_MESSAGE, [TODO_MESSAGE], TODO_MESSAGE,
|
||||
[TODO_MESSAGE])
|
||||
tools_info[tool_name] = tool_obj
|
||||
version = args.version
|
||||
version_status = IDFToolVersion.STATUS_SUPPORTED
|
||||
|
@ -674,16 +674,19 @@
|
||||
"versions": [
|
||||
{
|
||||
"linux-amd64": {
|
||||
"rename_dist": "ninja-linux-v1.11.1.zip",
|
||||
"sha256": "b901ba96e486dce377f9a070ed4ef3f79deb45f4ffe2938f8e7ddc69cfb3df77",
|
||||
"size": 119463,
|
||||
"url": "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip"
|
||||
},
|
||||
"macos": {
|
||||
"rename_dist": "ninja-mac-v1.11.1.zip",
|
||||
"sha256": "482ecb23c59ae3d4f158029112de172dd96bb0e97549c4b1ca32d8fad11f873e",
|
||||
"size": 277306,
|
||||
"url": "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-mac.zip"
|
||||
},
|
||||
"macos-arm64": {
|
||||
"rename_dist": "ninja-mac-v1.11.1.zip",
|
||||
"sha256": "482ecb23c59ae3d4f158029112de172dd96bb0e97549c4b1ca32d8fad11f873e",
|
||||
"size": 277306,
|
||||
"url": "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-mac.zip"
|
||||
@ -691,6 +694,7 @@
|
||||
"name": "1.11.1",
|
||||
"status": "recommended",
|
||||
"win64": {
|
||||
"rename_dist": "ninja-win-v1.11.1.zip",
|
||||
"sha256": "524b344a1a9a55005eaf868d991e090ab8ce07fa109f1820d40e74642e289abc",
|
||||
"size": 285922,
|
||||
"url": "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip"
|
||||
@ -928,5 +932,5 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": 1
|
||||
"version": 2
|
||||
}
|
||||
|
@ -182,6 +182,10 @@
|
||||
"url": {
|
||||
"type": "string",
|
||||
"description": "Download URL"
|
||||
},
|
||||
"rename_dist": {
|
||||
"type": "string",
|
||||
"description": "Filename under which the archive should be downloaded"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@ -242,5 +246,35 @@
|
||||
},
|
||||
"required": ["platforms"]
|
||||
}
|
||||
},
|
||||
"$comment": "Condition verifying that version 1 of tools.json must not contain 'rename_dist' keyword in any of #/definitions/versionInfo properties.",
|
||||
"if": {
|
||||
"properties": {
|
||||
"version": {
|
||||
"const": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"tools": {
|
||||
"items": {
|
||||
"properties": {
|
||||
"versions": {
|
||||
"items": {
|
||||
"additionalProperties": {
|
||||
"not": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"rename_dist"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user