diff --git a/cmake/cfb.cmake b/cmake/cfb.cmake index e0263adae26..b7995823b66 100644 --- a/cmake/cfb.cmake +++ b/cmake/cfb.cmake @@ -15,6 +15,7 @@ function(generate_cfb_font ${ZEPHYR_BASE}/scripts/gen_cfb_font_header.py --input ${input_file} --output ${output_file} + --bindir ${CMAKE_BINARY_DIR} --width ${width} --height ${height} ${ARGN} # Extra arguments are passed to gen_cfb_font_header.py diff --git a/scripts/gen_cfb_font_header.py b/scripts/gen_cfb_font_header.py index d887d4e5c42..c19e7e0f9eb 100755 --- a/scripts/gen_cfb_font_header.py +++ b/scripts/gen_cfb_font_header.py @@ -5,6 +5,7 @@ # SPDX-License-Identifier: Apache-2.0 import argparse +import os import sys from PIL import ImageFont @@ -67,6 +68,21 @@ def generate_header(): guard = "__CFB_FONT_{:s}_{:d}{:d}_H__".format(args.name.upper(), args.width, args.height) + zephyr_base = os.environ.get('ZEPHYR_BASE', "") + + clean_cmd = [ ] + for arg in sys.argv: + if arg.startswith("--bindir"): + # Drop. Assumes --bindir= was passed with '=' sign. + continue + if arg.startswith(args.bindir): + # +1 to also strip '/' or '\' separator + striplen = min(len(args.bindir)+1, len(arg)) + clean_cmd.append(arg[striplen:]) + continue + + clean_cmd.append(arg.replace(zephyr_base, '"${ZEPHYR_BASE}"')) + args.output.write("""/* * This file was automatically generated using the following command: * {cmd} @@ -80,7 +96,7 @@ def generate_header(): #include const u8_t cfb_font_{name:s}_{width:d}{height:d}[{elem:d}][{b:.0f}] = {{\n""" - .format(cmd=" ".join(sys.argv), + .format(cmd=" ".join(clean_cmd), guard=guard, name=args.name, width=args.width, @@ -141,6 +157,9 @@ def parse_args(): group.add_argument( "-o", "--output", type=argparse.FileType('w'), default="-", metavar="FILE", help="CFB font header file (default: stdout)") + group.add_argument( + "--bindir", type=str, default="", + help="CMAKE_BINARY_DIR for pure logging purposes. No trailing slash.") group.add_argument( "-x", "--width", required=True, type=int, help="width of the CFB font elements in pixels")