checkwps: Validate translated strings (%Sx)

In verbose mode it will log valid the strings found, otherwise it will
only complain when we encounter a missing string.

Unfortunately a missing string is not inherently a problem, due to
conditional expressions.  So all we can do is complain in checkwps
or if wps debugging is turned on.

Meanwhile, this is the first step in actually enumerating the translated
strings used by themes.

Change-Id: Ia93b333085e825d5b085c4d372ad8e13aa3e3ba1
This commit is contained in:
Solomon Peachy 2024-05-23 21:36:54 -04:00
parent ac20f8a73c
commit 8b8c0c7c2a
9 changed files with 72 additions and 24 deletions

View file

@ -2,6 +2,7 @@
../../apps/gui/skin_engine/skin_parser.c
../../apps/gui/skin_engine/skin_backdrops.c
../../apps/gui/viewport.c
../../apps/language.c
../../apps/misc.c
../../firmware/common/strmemccpy.c
../../firmware/common/strlcpy.c

View file

@ -35,7 +35,7 @@
#include "file.h"
#include "font.h"
bool debug_wps = true;
bool debug_wps = false;
int wps_verbose_level = 0;
char *skin_buffer;
@ -167,9 +167,9 @@ int remote_getwidth(void) { return LCD_REMOTE_WIDTH; }
int remote_getheight(void) { return LCD_REMOTE_HEIGHT; }
#endif
static inline bool backdrop_load(const char *filename, char* backdrop_buffer)
{
(void)filename; (void)backdrop_buffer; return true;
static inline bool backdrop_load(const char *filename, char* backdrop_buffer)
{
(void)filename; (void)backdrop_buffer; return true;
}
struct screen screens[NB_SCREENS] =
@ -282,6 +282,7 @@ int main(int argc, char **argv)
while (argv[1][i] && argv[1][i] == 'v') {
i++;
wps_verbose_level++;
debug_wps = true;
}
}
skin_buffer = malloc(SKIN_BUFFER_SIZE);

View file

@ -4,14 +4,14 @@
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
# \/ \/ \/ \/ \/
# $Id$
#
ENGLISH := english
# Use global GCCOPTS
GCCOPTS += -D__PCTOOL__ -DCHECKWPS
CHECKWPS_SRC = $(call preprocess, $(TOOLSDIR)/checkwps/SOURCES)
CHECKWPS_OBJ = $(call c2obj,$(CHECKWPS_SRC))
CHECKWPS_OBJ = $(call c2obj,$(CHECKWPS_SRC)) $(BUILDDIR)/lang/lang_core.o
OTHER_SRC += $(CHECKWPS_SRC)
@ -29,7 +29,9 @@ INCLUDES = -I$(ROOTDIR)/apps/gui \
-I$(ROOTDIR)/lib/rbcodec/metadata \
-I$(ROOTDIR)/lib/rbcodec/dsp \
-I$(APPSDIR) \
-I$(BUILDDIR)
-I$(BUILDDIR) \
-I$(BUILDDIR)/lang \
$(TARGET_INC)
.SECONDEXPANSION: # $$(OBJ) is not populated until after this
@ -37,3 +39,32 @@ $(BUILDDIR)/$(BINARY): $$(CHECKWPS_OBJ) $$(CORE_LIBS)
@echo LD $(BINARY)
$(SILENT)$(HOSTCC) -o $@ $+ $(INCLUDE) $(GCCOPTS) \
-L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS))
#### Everything below is hacked in from apps.make and lang.make
$(BUILDDIR)/apps/features: $(ROOTDIR)/apps/features.txt
$(SILENT)mkdir -p $(BUILDDIR)/apps
$(SILENT)mkdir -p $(BUILDDIR)/lang
$(call PRINTS,PP $(<F))
$(SILENT)$(CC) $(PPCFLAGS) \
-E -P -imacros "config.h" -imacros "button.h" -x c $< | \
grep -v "^#" | grep -v "^ *$$" > $(BUILDDIR)/apps/features; \
$(BUILDDIR)/apps/genlang-features: $(BUILDDIR)/apps/features
$(call PRINTS,GEN $(subst $(BUILDDIR)/,,$@))tr \\n : < $< > $@
$(BUILDDIR)/lang_enum.h: $(BUILDDIR)/lang/lang.h $(TOOLSDIR)/genlang
$(BUILDDIR)/lang/lang.h: $(ROOTDIR)/apps/lang/$(ENGLISH).lang $(BUILDDIR)/apps/features $(TOOLSDIR)/genlang
$(call PRINTS,GEN lang.h)
$(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
perl -s $(TOOLSDIR)/genlang -p=$(BUILDDIR)/lang -t=$(MODELNAME)$$feat $<
$(BUILDDIR)/lang/lang_core.c: $(BUILDDIR)/lang/lang.h $(TOOLSDIR)/genlang
$(BUILDDIR)/lang/lang_core.o: $(BUILDDIR)/lang/lang.h $(BUILDDIR)/lang/lang_core.c
$(call PRINTS,CC lang_core.c)$(CC) $(CFLAGS) -c $(BUILDDIR)/lang/lang_core.c -o $@
$(BUILDDIR)/lang/max_language_size.h: $(BUILDDIR)/lang/lang.h
$(call PRINTS,GEN $(subst $(BUILDDIR)/,,$@))
$(SILENT)echo "#define MAX_LANGUAGE_SIZE 131072" > $@