|
|
@@ -1,3 +1,4 @@
|
|
|
+import fnmatch
|
|
|
import os
|
|
|
import shutil
|
|
|
import subprocess
|
|
|
@@ -121,6 +122,20 @@ def action_extensions(base_actions, project_path):
|
|
|
else:
|
|
|
os.remove(f)
|
|
|
|
|
|
+ def python_clean(action, ctx, args):
|
|
|
+ for root, dirnames, filenames in os.walk(os.environ["IDF_PATH"]):
|
|
|
+ for d in dirnames:
|
|
|
+ if d == "__pycache__":
|
|
|
+ dir_to_delete = os.path.join(root, d)
|
|
|
+ if args.verbose:
|
|
|
+ print("Removing: %s" % dir_to_delete)
|
|
|
+ shutil.rmtree(dir_to_delete)
|
|
|
+ for filename in fnmatch.filter(filenames, '*.py[co]'):
|
|
|
+ file_to_delete = os.path.join(root, filename)
|
|
|
+ if args.verbose:
|
|
|
+ print("Removing: %s" % file_to_delete)
|
|
|
+ os.remove(file_to_delete)
|
|
|
+
|
|
|
def set_target(action, ctx, args, idf_target):
|
|
|
if(not args["preview"] and idf_target in PREVIEW_TARGETS):
|
|
|
raise FatalError("%s is still in preview. You have to append '--preview' option after idf.py to use any preview feature." % idf_target)
|
|
|
@@ -418,6 +433,14 @@ def action_extensions(base_actions, project_path):
|
|
|
"in the build directory, so use with care."
|
|
|
"Project configuration is not deleted.")
|
|
|
},
|
|
|
+ "python-clean": {
|
|
|
+ "callback": python_clean,
|
|
|
+ "short_help": "Delete generated Python byte code from the IDF directory",
|
|
|
+ "help": (
|
|
|
+ "Delete generated Python byte code from the IDF directory "
|
|
|
+ "which may cause issues when switching between IDF and Python versions. "
|
|
|
+ "It is advised to run this target after switching versions.")
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
|