component_information: switch from gzip to xz

Improves compression, e.g. current params file: 62KB to 51KB

There's also a PRESET_EXTREME option, which reduces by another 2KB.
We can revisit that once needed, as it increases mem usage as well.
This commit is contained in:
Beat Küng
2021-02-09 09:44:50 +01:00
parent cedfae9e46
commit 5a1c60b5a1
8 changed files with 22 additions and 22 deletions
+1 -1
View File
@@ -89,7 +89,7 @@ add_custom_command(OUTPUT ${generated_serial_params_file}
set(parameters_xml ${PX4_BINARY_DIR}/parameters.xml)
set(parameters_json ${PX4_BINARY_DIR}/params.json) # file name needs to be kept short to fit into url (metadata_uri)
file(GLOB_RECURSE param_src_files ${PX4_SOURCE_DIR}/src/*params.c)
add_custom_command(OUTPUT ${parameters_xml} ${parameters_json} ${parameters_json}.gz
add_custom_command(OUTPUT ${parameters_xml} ${parameters_json} ${parameters_json}.xz
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/px_process_params.py
--src-path ${module_list} ${generated_params_dir}
--xml ${parameters_xml}
+6 -6
View File
@@ -49,15 +49,15 @@ import os
import argparse
from px4params import srcscanner, srcparser, injectxmlparams, xmlout, markdownout, jsonout
import gzip #to create .gz file
import lzma #to create .xz file
import re
import json
import codecs
def SaveCompressed(filename):
#create gz compressed version
gz_filename=filename+'.gz'
with gzip.open(gz_filename, 'wt') as f:
def save_compressed(filename):
#create lzma compressed version
xz_filename=filename+'.xz'
with lzma.open(xz_filename, 'wt', preset=9) as f:
with open(filename, 'r') as content_file:
f.write(content_file.read())
@@ -185,7 +185,7 @@ def main():
for f in output_files:
if args.verbose:
print("Compressing file " + f)
SaveCompressed(f)
save_compressed(f)
if __name__ == "__main__":