Skip to content
Permalink
Browse files

generated/cfb_font_dice.h: don't leak absolute paths in comment

The start of generated/cfb_font_dice.h looked like this:

/*
 * This file was automatically generated using the following command:
 * /home/john/zephyrproject/zephyr/scripts/gen_cfb_font_header.py
 * --input fonts/dice.png --output
 * /home/john/tmp/build/zephyr/include/generated//cfb_font_dice.h
 * --width 32 --height 32 --first 49 --last 54
 */

For build reproduction and "privacy" reasons, change it to this:

/*
 * This file was automatically generated using the following command:
 * ${ZEPHYR_BASE}/scripts/gen_cfb_font_header.py
 * --input fonts/dice.png --output
 * zephyr/include/generated//cfb_font_dice.h
 * --width 32 --height 32 --first 49 --last 54
 */

Test with:
  sanitycheck  -p reel_board \
  -T $ZEPHYR_BASE/samples/display/cfb_custom_font/

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
  • Loading branch information...
marc-hb authored and nashif committed Jun 11, 2019
1 parent d385db0 commit 6f98db61f16fc944a2fe361979aeef518295aeb8
Showing with 21 additions and 1 deletion.
  1. +1 −0 cmake/cfb.cmake
  2. +20 −1 scripts/gen_cfb_font_header.py
@@ -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
@@ -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 <display/cfb.h>
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")

0 comments on commit 6f98db6

Please sign in to comment.
You can’t perform that action at this time.