in memory_statistics/memory_statistics.py [0:0]
def main():
args = parse_arguments()
if not shutil.which("arm-none-eabi-gcc"):
print("ARM GCC not found. Please add the ARM GCC toolchain to your path.")
sys.exit(1)
if not args['json_report']:
# Generate HTML file for a library. The config parameter is the library config path.
# See test/memory_statistics_config.json for an example.
lib_data = generate_library_estimates(args['config'])
doc = generate_table_from_object(lib_data)
else:
# Generate a JSON report for the given libraries. The config parameter is the path to the report paths config.
# See paths.json for a paths config for the FreeRTOS repository.
with open(args['config']) as paths_file:
libs = json.load(paths_file)
doc = {}
cwd = os.getcwd()
# Generate memory data for each library in paths config.
for lib in libs:
lib_path = libs[lib]['path']
# If the library entry in the paths config has a config key, use that as the libary config path.
# If not, use .github/memory_statistics_config.json in the library directory as a default.
config_path = os.path.abspath(libs[lib].get('config',
os.path.join(lib_path, ".github/memory_statistics_config.json")))
os.chdir(lib_path)
doc[lib] = generate_library_estimates(config_path)
os.chdir(cwd)
doc = json.dumps(doc, sort_keys=False, indent=4)
print(doc)
if args['output']:
with open(args['output'], 'w') as output:
output.write(doc)