Merge pull request #3686 from wavexx/lang_checks
Add targets for language checking
This commit is contained in:
commit
990f585312
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -xe
|
||||||
|
rm -rf build
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake .. \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE="../cmake/AvrGcc.cmake" \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-G Ninja
|
||||||
|
|
||||||
|
# ignore all failures in order to show as much output as possible
|
||||||
|
ninja -k0 check_lang || true
|
||||||
|
|
@ -37,7 +37,12 @@ jobs:
|
||||||
- stage: tests
|
- stage: tests
|
||||||
script: ./.github/travis/cmake-test.sh
|
script: ./.github/travis/cmake-test.sh
|
||||||
|
|
||||||
|
# language checks
|
||||||
|
- stage: lang
|
||||||
|
script: ./.github/travis/cmake-lang.sh
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- cmake
|
- cmake
|
||||||
|
- lang
|
||||||
- legacy
|
- legacy
|
||||||
- tests
|
- tests
|
||||||
|
|
|
||||||
|
|
@ -294,8 +294,7 @@ function(add_base_binary variant_name)
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
${variant_name}
|
${variant_name}
|
||||||
PRIVATE ${PRUSA_BOARDS_DIR}/cores/prusa_einsy_rambo/
|
PRIVATE ${PRUSA_BOARDS_DIR}/cores/prusa_einsy_rambo/
|
||||||
${PRUSA_BOARDS_DIR}/variants/prusa_einsy_rambo/
|
${PRUSA_BOARDS_DIR}/variants/prusa_einsy_rambo/ ${CMAKE_SOURCE_DIR}/Firmware
|
||||||
${CMAKE_SOURCE_DIR}/Firmware
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${variant_name} avr_core)
|
target_link_libraries(${variant_name} avr_core)
|
||||||
|
|
@ -373,20 +372,34 @@ function(fw_add_variant variant_name)
|
||||||
COMMENT "Generating ${variant_name} language map"
|
COMMENT "Generating ${variant_name} language map"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Base targets for language checks
|
||||||
|
add_custom_target(check_lang_${variant_name})
|
||||||
|
add_dependencies(check_lang check_lang_${variant_name})
|
||||||
|
|
||||||
# Build language catalogs
|
# Build language catalogs
|
||||||
set(LANG_BINS "")
|
set(LANG_BINS "")
|
||||||
foreach(LANG IN LISTS SELECTED_LANGUAGES)
|
foreach(LANG IN LISTS SELECTED_LANGUAGES)
|
||||||
set(LANG_BIN ${LANG_TMP_DIR}/${variant_name}_${LANG}.bin)
|
set(LANG_BIN ${LANG_TMP_DIR}/${variant_name}_${LANG}.bin)
|
||||||
set(PO_FILE "${CMAKE_SOURCE_DIR}/lang/po/Firmware_${LANG}.po")
|
set(PO_FILE "${CMAKE_SOURCE_DIR}/lang/po/Firmware_${LANG}.po")
|
||||||
|
|
||||||
|
# Full language checks
|
||||||
|
add_custom_target(
|
||||||
|
check_lang_${variant_name}_${LANG}
|
||||||
|
COMMENT "Checking ${variant_name} language ${LANG}"
|
||||||
|
COMMAND ${CMAKE_SOURCE_DIR}/lang/lang-check.py --map ${LANG_MAP} ${PO_FILE}
|
||||||
|
DEPENDS ${LANG_MAP} ${PO_FILE}
|
||||||
|
USES_TERMINAL
|
||||||
|
)
|
||||||
|
add_dependencies(check_lang_${variant_name} check_lang_${variant_name}_${LANG})
|
||||||
|
add_dependencies(check_lang_${LANG} check_lang_${variant_name}_${LANG})
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${LANG_BIN}
|
OUTPUT ${LANG_BIN}
|
||||||
#[[
|
# Check po file for errors _only_
|
||||||
# Check po file:
|
COMMAND ${CMAKE_SOURCE_DIR}/lang/lang-check.py --errors-only --map ${LANG_MAP} ${PO_FILE}
|
||||||
#COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lang/lang-check.py --no-warning --map ${LANG_MAP} ${PO_FILE}
|
# Build the catalog
|
||||||
#]]
|
|
||||||
COMMAND ${CMAKE_SOURCE_DIR}/lang/lang-build.py ${LANG_MAP} ${PO_FILE} ${LANG_BIN}
|
COMMAND ${CMAKE_SOURCE_DIR}/lang/lang-build.py ${LANG_MAP} ${PO_FILE} ${LANG_BIN}
|
||||||
# Check bin size:
|
# Check bin size
|
||||||
COMMAND ${CMAKE_COMMAND} -DLANG_MAX_SIZE=${LANG_MAX_SIZE} -DLANG_FILE=${LANG_BIN} -P
|
COMMAND ${CMAKE_COMMAND} -DLANG_MAX_SIZE=${LANG_MAX_SIZE} -DLANG_FILE=${LANG_BIN} -P
|
||||||
${PROJECT_CMAKE_DIR}/Check_lang_size.cmake
|
${PROJECT_CMAKE_DIR}/Check_lang_size.cmake
|
||||||
DEPENDS ${LANG_MAP} ${PO_FILE}
|
DEPENDS ${LANG_MAP} ${PO_FILE}
|
||||||
|
|
@ -471,6 +484,13 @@ endfunction()
|
||||||
|
|
||||||
if(CMAKE_CROSSCOMPILING)
|
if(CMAKE_CROSSCOMPILING)
|
||||||
|
|
||||||
|
# Main target for language checks
|
||||||
|
add_custom_target(check_lang)
|
||||||
|
foreach(LANG IN LISTS SELECTED_LANGUAGES)
|
||||||
|
add_custom_target(check_lang_${LANG})
|
||||||
|
add_dependencies(check_lang check_lang_${LANG})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
# build a list of all supported variants
|
# build a list of all supported variants
|
||||||
file(
|
file(
|
||||||
GLOB ALL_VARIANTS
|
GLOB ALL_VARIANTS
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ def check_translation(entry, msgids, is_pot, no_warning, no_suggest, warn_empty,
|
||||||
return (errors == 0)
|
return (errors == 0)
|
||||||
|
|
||||||
# Missing translation
|
# Missing translation
|
||||||
if len(translation) == 0 and (known_msgid or warn_empty):
|
if len(translation) == 0 and (warn_empty or (not no_warning and known_msgid)):
|
||||||
errors += 1
|
errors += 1
|
||||||
if rows == 1:
|
if rows == 1:
|
||||||
print(yellow("[W]: Empty translation for \"%s\" on line %d" % (source, line)))
|
print(yellow("[W]: Empty translation for \"%s\" on line %d" % (source, line)))
|
||||||
|
|
@ -307,6 +307,9 @@ def main():
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--no-suggest", action="store_true",
|
"--no-suggest", action="store_true",
|
||||||
help="Disable suggestions")
|
help="Disable suggestions")
|
||||||
|
parser.add_argument(
|
||||||
|
"--errors-only", action="store_true",
|
||||||
|
help="Only check errors")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--pot", action="store_true",
|
"--pot", action="store_true",
|
||||||
help="Do not check translations")
|
help="Do not check translations")
|
||||||
|
|
@ -331,6 +334,10 @@ def main():
|
||||||
print("{}: file does not exist or is not a regular file".format(args.po), file=stderr)
|
print("{}: file does not exist or is not a regular file".format(args.po), file=stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
if args.errors_only:
|
||||||
|
args.no_warning = True
|
||||||
|
args.no_suggest = True
|
||||||
|
|
||||||
# load the symbol map to supress empty (but unused) translation warnings
|
# load the symbol map to supress empty (but unused) translation warnings
|
||||||
msgids = None
|
msgids = None
|
||||||
if args.map:
|
if args.map:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue