Anas Nashif | 3ae5262 | 2019-04-06 09:08:09 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | |
Henrik Brix Andersen | 9e8c9ca | 2018-11-08 20:47:39 +0100 | [diff] [blame] | 3 | # These functions can be used to generate a CFB font include file from |
| 4 | # a TrueType/OpenType font file or an image file. |
| 5 | function(generate_cfb_font |
| 6 | input_file # The TrueType/OpenType font file or the image file |
| 7 | output_file # The generated header file |
| 8 | width # Width of the CFB font elements in pixels |
| 9 | height # Height of the CFB font elements in pixels |
| 10 | ) |
| 11 | add_custom_command( |
| 12 | OUTPUT ${output_file} |
| 13 | COMMAND |
| 14 | ${PYTHON_EXECUTABLE} |
| 15 | ${ZEPHYR_BASE}/scripts/gen_cfb_font_header.py |
Torsten Rasmussen | d7862cf | 2020-02-12 15:42:09 +0100 | [diff] [blame] | 16 | --zephyr-base ${ZEPHYR_BASE} |
Henrik Brix Andersen | 9e8c9ca | 2018-11-08 20:47:39 +0100 | [diff] [blame] | 17 | --input ${input_file} |
| 18 | --output ${output_file} |
Marc Herbert | 6f98db6 | 2019-06-11 15:50:04 -0700 | [diff] [blame] | 19 | --bindir ${CMAKE_BINARY_DIR} |
Henrik Brix Andersen | 9e8c9ca | 2018-11-08 20:47:39 +0100 | [diff] [blame] | 20 | --width ${width} |
| 21 | --height ${height} |
| 22 | ${ARGN} # Extra arguments are passed to gen_cfb_font_header.py |
| 23 | DEPENDS ${source_file} |
| 24 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 25 | ) |
| 26 | endfunction() |
| 27 | |
| 28 | function(generate_cfb_font_for_gen_target |
| 29 | target # The cmake target that depends on the generated file |
| 30 | input_file # The TrueType/OpenType font file or the image file |
| 31 | output_file # The generated header file |
| 32 | width # Width of the CFB font elements in pixels |
| 33 | height # Height of the CFB font elements in pixels |
| 34 | gen_target # The generated file target we depend on |
| 35 | # Any additional arguments are passed on to |
| 36 | # gen_cfb_font_header.py |
| 37 | ) |
| 38 | generate_cfb_font(${input_file} ${output_file} ${width} ${height} ${ARGN}) |
| 39 | |
| 40 | # Ensure 'output_file' is generated before 'target' by creating a |
| 41 | # dependency between the two targets |
| 42 | |
| 43 | add_dependencies(${target} ${gen_target}) |
| 44 | endfunction() |
| 45 | |
| 46 | function(generate_cfb_font_for_target |
| 47 | target # The cmake target that depends on the generated file |
| 48 | input_file # The TrueType/OpenType font file or image file |
| 49 | output_file # The generated header file |
| 50 | width # Width of the CFB font elements in pixels |
| 51 | height # Height of the CFB font elements in pixels |
| 52 | # Any additional arguments are passed on to |
| 53 | # gen_cfb_font_header.py |
| 54 | ) |
| 55 | # Ensure 'output_file' is generated before 'target' by creating a |
| 56 | # 'custom_target' for it and setting up a dependency between the two |
| 57 | # targets |
| 58 | |
| 59 | # But first create a unique name for the custom target |
| 60 | generate_unique_target_name_from_filename(${output_file} generated_target_name) |
| 61 | |
| 62 | add_custom_target(${generated_target_name} DEPENDS ${output_file}) |
| 63 | generate_cfb_font_for_gen_target(${target} ${input_file} ${output_file} |
| 64 | ${width} ${height} ${generated_target_name} ${ARGN}) |
| 65 | endfunction() |