4 changed files with 125 additions and 5 deletions
-
55cmake/FindKicadCli.cmake
-
2tools/CMakeLists.txt
-
63tools/newstroke/CMakeLists.txt
-
10tools/newstroke/README.txt
@ -0,0 +1,55 @@ |
|||
# - Find kicad-cli |
|||
# Find the kicad-cli tool |
|||
# |
|||
# Used for managing KiCad files in the repo (e.g. test |
|||
# files, stroke font files, |
|||
|
|||
find_program(KICAD_CLI |
|||
NAMES kicad-cli |
|||
) |
|||
|
|||
if (KICAD_CLI) |
|||
message(STATUS "kicad-cli found: ${KICAD_CLI}") |
|||
else() |
|||
message(STATUS "kicad-cli not found") |
|||
endif() |
|||
|
|||
|
|||
# |
|||
# Helper function to upgrade a symbol library file |
|||
# using the installed kicad-cli tool |
|||
# |
|||
# Usage: |
|||
# KICAD_CLI_UPGRADE_SYMS(FILE TARGET [FORCE]) |
|||
# |
|||
# Arguments: |
|||
# FILE - The symbol library file to upgrade |
|||
# TARGET - The CMake target to add the upgrade command to |
|||
# FORCE - Optional argument to force the upgrade |
|||
# |
|||
function(KICAD_CLI_UPGRADE_SYMS FILE TARGET) |
|||
if (NOT KICAD_CLI) |
|||
message(FATAL_ERROR "Cannot run upgrade target (kicad-cli not found)") |
|||
endif() |
|||
|
|||
# Parse the optional FORCE argument |
|||
set(options FORCE) |
|||
set(oneValueArgs) |
|||
set(multiValueArgs) |
|||
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) |
|||
|
|||
# Check if FORCE was provided |
|||
if (ARGS_FORCE) |
|||
set(FORCE_ARG "--force") |
|||
else() |
|||
set(FORCE_ARG "") |
|||
endif() |
|||
|
|||
add_custom_command( |
|||
TARGET ${TARGET} |
|||
COMMAND ${KICAD_CLI} sym upgrade ${FORCE_ARG} ${FILE} |
|||
DEPENDS ${FILE} |
|||
COMMENT |
|||
"Upgrading symbol lib format: ${FILE}" |
|||
) |
|||
endfunction() |
|||
@ -0,0 +1,63 @@ |
|||
|
|||
find_package(KicadCli) |
|||
|
|||
# |
|||
# List of all newstroke symbol files that define the newstroke font |
|||
# glyphs. These files are used to generate the newstroke font data |
|||
# in newstroke_font.cpp. |
|||
# |
|||
set(NEWSTROKE_SOURCE_FILES |
|||
font.kicad_sym |
|||
symbol.kicad_sym |
|||
CJK_symbol.kicad_sym |
|||
CJK_wide_U+4E00.kicad_sym |
|||
CJK_wide_U+5AE6.kicad_sym |
|||
CJK_wide_U+66B9.kicad_sym |
|||
CJK_wide_U+7212.kicad_sym |
|||
CJK_wide_U+7D2A.kicad_sym |
|||
CJK_wide_U+8814.kicad_sym |
|||
CJK_wide_U+92B4.kicad_sym |
|||
CJK_wide_U+9C60.kicad_sym |
|||
half_full.kicad_sym |
|||
hiragana.kicad_sym |
|||
katakana.kicad_sym |
|||
) |
|||
|
|||
|
|||
add_custom_command( |
|||
OUTPUT |
|||
${CMAKE_BINARY_DIR}/common/newstroke_font.cpp |
|||
COMMAND |
|||
python3 fontconv.py |
|||
DEPENDS |
|||
${NEWSTROKE_SOURCE_FILES} |
|||
fontconv.py |
|||
WORKING_DIRECTORY |
|||
${CMAKE_CURRENT_SOURCE_DIR} |
|||
COMMENT |
|||
"Generating newstroke font data" |
|||
) |
|||
|
|||
|
|||
add_custom_target( |
|||
newstroke_generate_cpp |
|||
DEPENDS |
|||
${CMAKE_BINARY_DIR}/common/newstroke_font.cpp |
|||
) |
|||
|
|||
|
|||
if (NOT KICAD_CLI) |
|||
message(STATUS "Cannot create newstroke_upgrade_syms target (kicad-cli not found)") |
|||
else() |
|||
add_custom_target(newstroke_upgrade_syms |
|||
COMMENT "Running format update on all newstroke .kicad_sym files" |
|||
) |
|||
|
|||
foreach(NEWSTROKE_SOURCE_FILE ${NEWSTROKE_SOURCE_FILES}) |
|||
KICAD_CLI_UPGRADE_SYMS( |
|||
${CMAKE_CURRENT_SOURCE_DIR}/${NEWSTROKE_SOURCE_FILE} |
|||
newstroke_upgrade_syms |
|||
) |
|||
endforeach() |
|||
endif() |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue