mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 20:41:14 +00:00
tools: allow alternative spellings of target name (ESP32-S2, ESP32S2)
by ignoring character case and hyphens in target name.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import click
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
@@ -314,3 +315,25 @@ def _guess_or_check_idf_target(args, prog_name, cache):
|
||||
"To keep the setting in sdkconfig ({t_conf}) and re-generate CMakeCache.txt, run '{prog} fullclean'. "
|
||||
"To re-generate sdkconfig for '{t_cache}' target, run '{prog} set-target {t_cache}'."
|
||||
.format(t_conf=idf_target_from_sdkconfig, t_cache=idf_target_from_cache, prog=prog_name))
|
||||
|
||||
|
||||
class TargetChoice(click.Choice):
|
||||
"""
|
||||
A version of click.Choice with two special features:
|
||||
- ignores hyphens
|
||||
- not case sensitive
|
||||
"""
|
||||
def __init__(self, choices):
|
||||
super(TargetChoice, self).__init__(choices, case_sensitive=False)
|
||||
|
||||
def convert(self, value, param, ctx):
|
||||
def normalize(str):
|
||||
return str.lower().replace("-", "")
|
||||
|
||||
saved_token_normalize_func = ctx.token_normalize_func
|
||||
ctx.token_normalize_func = normalize
|
||||
|
||||
try:
|
||||
return super(TargetChoice, self).convert(value, param, ctx)
|
||||
finally:
|
||||
ctx.token_normalize_func = saved_token_normalize_func
|
||||
|
Reference in New Issue
Block a user