feat: idf_tools.py export support env var "IDF_SKIP_TOOLS_CHECK"

This commit is contained in:
Fu Hanxi 2024-11-04 11:05:56 +01:00
parent 5a3f53a2b5
commit 3e2b56d114
No known key found for this signature in database
GPG Key ID: 19399699CF3C4B16
2 changed files with 19 additions and 2 deletions

View File

@ -2122,8 +2122,12 @@ def process_tool(
if not tool.versions_installed:
if tool.get_install_type() == IDFTool.INSTALL_ALWAYS:
handle_missing_versions(tool, tool_name, install_cmd, prefer_system_hint)
tool_found = False
if os.getenv('IDF_SKIP_TOOLS_CHECK', '0') == '1':
warn(f'Tool {tool_name} is not installed and IDF_SKIP_TOOLS_CHECK is set. '
'This may cause build failures.')
else:
handle_missing_versions(tool, tool_name, install_cmd, prefer_system_hint)
tool_found = False
# If a tool found, but it is optional and does not have versions installed, use whatever is in PATH.
return tool_export_paths, tool_export_vars, tool_found

View File

@ -312,6 +312,19 @@ class TestUsage(TestUsageBase):
self.assertNotIn(tool_to_test, output)
def test_export_with_required_tools_check_skipped(self):
self.run_idf_tools_with_error(['export'], assertError=True)
new_os_environ = os.environ.copy()
new_os_environ['IDF_SKIP_TOOLS_CHECK'] = '1'
with patch('os.environ', new_os_environ):
self.run_idf_tools_with_action(['export'])
self.run_idf_tools_with_action(['install', OPENOCD])
output = self.run_idf_tools_with_action(['export'])
self.assertIn('%s/tools/openocd-esp32/%s/openocd-esp32/bin' %
(self.temp_tools_dir, OPENOCD_VERSION), output)
# TestUsageUnix tests installed tools on UNIX platforms
@unittest.skipIf(sys.platform == 'win32', reason='Tools for UNIX differ')