Skip to content

Commit b4f94be

Browse files
committed
tools: add filter unwant arches feature in nsdk_cli tools
you can ignore arches which is passed via in ARCH_EXT of build_config eg. export SDK_IGNORED_EXTS=v_xxldsp it will ignore build config which ARCH_EXT contains only v extension or contains xxldsp extension This will help in the case when ARCH_EXT contains extensions which is not supported by hardware you can pass the unsupported extensions via SDK_IGNORED_EXTS Signed-off-by: Huaqi Fang <578567190@qq.com>
1 parent e8f766e commit b4f94be

3 files changed

Lines changed: 59 additions & 0 deletions

File tree

doc/source/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ V0.2.1
1212
- Add NMI exception support for evalsoc, exception code is ``0xFFF``
1313
- Support ``zcmt`` extension in evalsoc linker script file
1414

15+
* Tools
16+
17+
- Add filter configuration feature in nsdk_cli tools, you can filter certain arches which you dont want to run via ``SDK_IGNORED_EXTS`` environment variable
1518

1619
V0.2.0
1720
-------

tools/scripts/nsdk_cli/nsdk_builder.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,11 @@ def run_apps_with_config(self, config:dict, show_output=True, stoponfail=False):
989989
apps_config = copy.deepcopy(config)
990990
for appdir in apps_config:
991991
appconfig = apps_config[appdir]
992+
# Used to filter application with certain pattern not acceptable
993+
filtered, reason = filter_app_config(appconfig)
994+
if filtered:
995+
print("INFO: Ignore this app config %s for application %s" % (reason, appdir))
996+
continue
992997
applogs = appconfig.get("logs", dict())
993998
app_buildlogfile = applogs.get("build", None)
994999
app_runlogfile = applogs.get("run", None)
@@ -1023,6 +1028,11 @@ def run_apps_with_configs(self, config:dict, show_output=True, stoponfail=False)
10231028
app_allconfigs = appconfigs["configs"]
10241029
for cfgname in app_allconfigs:
10251030
appconfig = app_allconfigs[cfgname] # get configuration for each case for single app
1031+
# Used to filter application with certain pattern not acceptable
1032+
filtered, reason = filter_app_config(appconfig)
1033+
if filtered:
1034+
print("INFO: Ignore this app config %s for application %s" % (reason, appdir))
1035+
continue
10261036
applogs = appconfig.get("logs", dict())
10271037
app_buildlogfile = applogs.get("build", None)
10281038
app_runlogfile = applogs.get("run", None)

tools/scripts/nsdk_cli/nsdk_utils.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import serial.tools.list_ports
1818
import tempfile
1919
import collections
20+
from collections import OrderedDict
2021
from threading import Thread
2122
import subprocess
2223
import asyncio
@@ -176,6 +177,51 @@ def get_sdk_uploaderr_maxcnt():
176177

177178
return num
178179

180+
def filter_app_config(appconfig):
181+
if not isinstance(appconfig, dict):
182+
return False, ""
183+
184+
try:
185+
build_config = appconfig.get("build_config", None)
186+
if build_config is None or len(build_config) == 0:
187+
return False, ""
188+
archext = build_config.get("ARCH_EXT", None)
189+
if archext is None or archext.strip() == "":
190+
return False, ""
191+
192+
# example ignore pattern: export SDK_IGNORED_EXTS="v_zc_zv"
193+
ignored_exts = os.environ.get("SDK_IGNORED_EXTS")
194+
if ignored_exts is None:
195+
return False, ""
196+
unique_exts = list(
197+
OrderedDict.fromkeys(part.strip() for part in ignored_exts.split('_'))
198+
)
199+
if len(unique_exts) == 1 and unique_exts[0] == "":
200+
return False, ""
201+
first_part = None
202+
rest_part = None
203+
if archext.startswith("_") == False:
204+
if "_" in archext:
205+
first_part, rest_part = archext.split("_", 1)
206+
else:
207+
first_part = archext
208+
else:
209+
rest_part = archext
210+
for ext in unique_exts:
211+
if len(ext) == 0:
212+
continue
213+
if len(ext) == 1:
214+
# handle single letter
215+
if first_part and ext in first_part:
216+
return True, "Filtered by %s extension" %(ext)
217+
else:
218+
# handle multi letter
219+
if rest_part and ext in rest_part:
220+
return True, "Filtered by %s extension" % (ext)
221+
except:
222+
pass
223+
return False, ""
224+
179225
class NThread(Thread):
180226
def __init__(self, func, args):
181227
super(NThread, self).__init__()

0 commit comments

Comments
 (0)