Added recently introduced optimizations - generation in string literal form
and faster generation for hexadecimal initializer list form - to gzip path
as well.
Signed-off-by: Irfan Ahmad <irfan.ahmad@siemens.com>
Currently, file2hex.py supports conversion of binary data into hexadecimal
character list format only. The generated list can then be used to embed
the binary data by using the list to initialize an array. However, this
approach is highly inefficient for large binary files.
A close but considerably more efficient alternative is to use string
literals composed of hex characters (in escaped form) to initialize the
array, instead of an initializer list. Benchmarking (with GCC and clang)
indicates that compile time and host memory usage by the compiler can be
more than an order of magnitude less with string literal approach compared
to the initializer list form.
The only caveat is that string literals contain the null character as
terminator so where accurate length is required, the correct length must
be specified explicitly while defining the array.
Signed-off-by: Irfan Ahmad <irfan.ahmad@siemens.com>
Read and convert binary data in chunks of 1024 bytes, instead of 8 bytes.
This significantly reduces the conversion time. The improvement increases
with increasing file sizes but saturates to around 60-61% as file size
approaches 64MiB, and beyond.
The existing generated output format of eight byte-values per line is still
preserved.
Signed-off-by: Irfan Ahmad <irfan.ahmad@siemens.com>
Disables allowing the python argparse library from automatically
shortening command line arguments, this prevents issues whereby
a new command is added and code that wrongly uses the shortened
command of an existing argument which is the same as the new
command being added will silently change script behaviour.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Convert the description comment at the top of the file to a
documentation string. That string then maybe viewed with the --help
argument. Also, rework a bit the documentation string.
Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
This makes the output of file2hex.py deterministic by default while also
letting the user set the mtime in the gzip header manually if desired.
Use the option without any argument to restore the previous behavior
that sets the current (and obviously changing) "now" timestamp.
To test: ./sanitycheck --tag gen_inc_file
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Zero functional change, this is pure refactoring and preparation for
using the mtime= parameter which the gzip.compress() shortcut does not
make available.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This commit is useful if there is a need to generate a file
that can be included into the application at build time.
The file can also be compressed automatically when embedding it.
Files to be generated are listed in
generate_inc_file
generate_inc_gz_file
variables.
How to use this commit in your application:
1. Add this to your application Makefile
SRC = $(ZEPHYR_BASE)/<your-app-dir>/src
include $(ZEPHYR_BASE)/scripts/Makefile.gen
2. Add needed binary/other embedded files into src/Makefile
to "generate_inc_file" or "generate_inc_gz_file" variables:
# List of files that are used to generate a file that can be
# included into .c file.
generate_inc_file += \
echo-apps-cert.der \
echo-apps-key.der \
file.bin
generate_inc_gz_file += \
index.html
include $(ZEPHYR_BASE)/scripts/Makefile.gen
3. In the application, do something with the embedded file
static const unsigned char inc_file[] = {
#include "file.bin.inc"
};
static const unsigned char gz_inc_file[] = {
#include "index.html.gz.inc"
};
The generated files in ${SRC}/*.inc are automatically removed
when you do "make pristine"
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>