mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/pyc_clean_v4.1' into 'release/v4.1'
tools/idf.py: Clean Python bytecode files (v4.1) See merge request espressif/esp-idf!9263
This commit is contained in:
commit
2a3ecaa926
@ -460,6 +460,17 @@ function run_tests()
|
||||
rm -r sdkconfig.defaults build
|
||||
done
|
||||
|
||||
print_status "Cleaning Python bytecode"
|
||||
idf.py clean > /dev/null
|
||||
idf.py fullclean > /dev/null
|
||||
if [ "$(find $IDF_PATH -name "*.py[co]" | wc -l)" -eq 0 ]; then
|
||||
failure "No Python bytecode in IDF!"
|
||||
fi
|
||||
idf.py python-clean
|
||||
if [ "$(find $IDF_PATH -name "*.py[co]" | wc -l)" -gt 0 ]; then
|
||||
failure "Python bytecode isn't working!"
|
||||
fi
|
||||
|
||||
print_status "Displays partition table when executing target partition_table"
|
||||
idf.py partition_table | grep -E "# Espressif .+ Partition Table"
|
||||
rm -r build
|
||||
|
@ -1,3 +1,4 @@
|
||||
import fnmatch
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
@ -128,6 +129,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):
|
||||
args.define_cache_entry.append("IDF_TARGET=" + idf_target)
|
||||
sdkconfig_path = os.path.join(args.project_dir, 'sdkconfig')
|
||||
@ -413,6 +428,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.")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user