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
+3 -3
View File
@@ -40,7 +40,7 @@ if (${index} EQUAL -1)
endif()
set(component_version_json ${PX4_BINARY_DIR}/component_version.json)
add_custom_command(OUTPUT ${component_version_json} ${component_version_json}.gz
add_custom_command(OUTPUT ${component_version_json} ${component_version_json}.xz
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_component_version.py
${component_version_json}
--compress
@@ -55,13 +55,13 @@ add_custom_target(component_version_json DEPENDS ${component_version_json})
set(component_information_header ${CMAKE_CURRENT_BINARY_DIR}/hashes.h)
add_custom_command(OUTPUT ${component_information_header}
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_hashes.py
${PX4_BINARY_DIR}/params.json.gz
${PX4_BINARY_DIR}/params.json.xz
${component_version_json}
--output ${component_information_header}
DEPENDS
generate_hashes.py
parameters_xml
${PX4_BINARY_DIR}/params.json.gz
${PX4_BINARY_DIR}/params.json.xz
${component_version_json}
COMMENT "Generating component_information/hashes.h"
)
@@ -2,7 +2,7 @@
import argparse
import json
import gzip
import lzma #to create .xz file
parser = argparse.ArgumentParser(description="""Generate the COMPONENT_VERSION json file""")
parser.add_argument('filename', metavar='component_version.json', help='JSON output file')
@@ -14,9 +14,9 @@ filename = args.filename
compress = args.compress
def save_compressed(filename):
#create gz compressed version
gz_filename=filename+'.gz'
with gzip.open(gz_filename, 'wt') as f:
#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())