mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
Merge branch 'fix/idf_size_help_v5.3' into 'release/v5.3'
fix: display correct help in the idf_size.py wrapper (v5.3) See merge request espressif/esp-idf!30661
This commit is contained in:
@ -1,22 +1,30 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
#
|
#
|
||||||
# SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
# Here the argparse is used only to "peek" into arguments if
|
||||||
|
# legacy version is requested or if old json format is specified.
|
||||||
|
# In these two cases the esp_idf_size legacy version is spawned.
|
||||||
|
parser = argparse.ArgumentParser(exit_on_error=False, add_help=False)
|
||||||
parser.add_argument('--format')
|
parser.add_argument('--format')
|
||||||
parser.add_argument('-l', '--legacy', action='store_true', default=os.environ.get('ESP_IDF_SIZE_LEGACY', '0') == '1')
|
parser.add_argument('-l', '--legacy', action='store_true', default=os.environ.get('ESP_IDF_SIZE_LEGACY', '0') == '1')
|
||||||
|
|
||||||
|
# The sys.argv is parsed with "exit_on_error", but the argparse.ArgumentError
|
||||||
|
# exception should never occur, because unknown args should be put into
|
||||||
|
# the rest variable, since the parse_known_args() method is used.
|
||||||
args, rest = parser.parse_known_args()
|
args, rest = parser.parse_known_args()
|
||||||
|
|
||||||
if not args.legacy and args.format != 'json':
|
if not args.legacy and args.format != 'json':
|
||||||
|
# By default start the refactored version, unless legacy version is explicitly requested with
|
||||||
|
# -l/--legacy option or if old json format is specified.
|
||||||
try:
|
try:
|
||||||
import esp_idf_size.ng # noqa: F401
|
import esp_idf_size.ng # noqa: F401
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -24,9 +32,9 @@ if __name__ == '__main__':
|
|||||||
args.legacy = True
|
args.legacy = True
|
||||||
else:
|
else:
|
||||||
os.environ['ESP_IDF_SIZE_NG'] = '1'
|
os.environ['ESP_IDF_SIZE_NG'] = '1'
|
||||||
|
if not rest or '-h' in rest or '--help' in rest:
|
||||||
if args.legacy and args.format in ['json2', 'raw', 'tree']:
|
print(('Note: legacy esp_idf_size version can be invoked by specifying the -l/--legacy '
|
||||||
sys.exit(f'Legacy esp-idf-size does not support {args.format} format')
|
'option or by setting the ESP_IDF_SIZE_LEGACY environment variable.'))
|
||||||
|
|
||||||
if args.format is not None:
|
if args.format is not None:
|
||||||
rest = ['--format', args.format] + rest
|
rest = ['--format', args.format] + rest
|
||||||
|
Reference in New Issue
Block a user