Add a verbosity level command line option to the chackwps tool. This should make life easier for the themes.rockbox.org people.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13958 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c897c241d9
commit
3213d4a0f5
3 changed files with 87 additions and 53 deletions
|
@ -34,6 +34,7 @@
|
|||
|
||||
#if defined(SIMULATOR) || defined(__PCTOOL__)
|
||||
extern bool debug_wps;
|
||||
extern int wps_verbose_level;
|
||||
#endif
|
||||
|
||||
static char *next_str(bool next) {
|
||||
|
@ -49,11 +50,6 @@ static void dump_wps_tokens(struct wps_data *data)
|
|||
bool next;
|
||||
int num_string_tokens = 0;
|
||||
|
||||
if (data->num_tokens > WPS_MAX_TOKENS) {
|
||||
DEBUGF("Number of tokens is too high (%d)!!!\n", data->num_tokens);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Dump parsed WPS */
|
||||
for (i = 0, token = data->tokens; i < data->num_tokens; i++, token++) {
|
||||
next = token->next;
|
||||
|
@ -383,16 +379,22 @@ static void dump_wps_tokens(struct wps_data *data)
|
|||
break;
|
||||
}
|
||||
|
||||
for(j = 0; j < indent; j++) {
|
||||
DEBUGF("\t");
|
||||
if (wps_verbose_level > 2)
|
||||
{
|
||||
for(j = 0; j < indent; j++) {
|
||||
DEBUGF("\t");
|
||||
}
|
||||
|
||||
DEBUGF("[%3d] = (%2d) %s\n", i, token->type, buf);
|
||||
}
|
||||
|
||||
DEBUGF("[%3d] = (%2d) %s\n", i, token->type, buf);
|
||||
}
|
||||
DEBUGF("\n");
|
||||
|
||||
DEBUGF("Number of string tokens: %d\n", num_string_tokens);
|
||||
DEBUGF("\n");
|
||||
if (wps_verbose_level > 0)
|
||||
{
|
||||
DEBUGF("\n");
|
||||
DEBUGF("Number of string tokens: %d\n", num_string_tokens);
|
||||
DEBUGF("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void print_line_info(struct wps_data *data)
|
||||
|
@ -401,56 +403,67 @@ static void print_line_info(struct wps_data *data)
|
|||
struct wps_line *line;
|
||||
struct wps_subline *subline;
|
||||
|
||||
DEBUGF("Number of lines : %d\n", data->num_lines);
|
||||
DEBUGF("Number of sublines: %d\n", data->num_sublines);
|
||||
DEBUGF("Number of tokens : %d\n", data->num_tokens);
|
||||
DEBUGF("\n");
|
||||
|
||||
for (i = 0, line = data->lines; i < data->num_lines; i++,line++)
|
||||
if (wps_verbose_level > 0)
|
||||
{
|
||||
DEBUGF("Line %2d (num_sublines=%d, first_subline=%d)\n",
|
||||
i, line->num_sublines, line->first_subline_idx);
|
||||
|
||||
for (j = 0, subline = data->sublines + line->first_subline_idx;
|
||||
j < line->num_sublines; j++, subline++)
|
||||
{
|
||||
DEBUGF(" Subline %d: first_token=%3d, last_token=%3d",
|
||||
j, subline->first_token_idx,
|
||||
wps_last_token_index(data, i, j));
|
||||
|
||||
if (subline->line_type & WPS_REFRESH_SCROLL)
|
||||
DEBUGF(", scrolled");
|
||||
else if (subline->line_type & WPS_REFRESH_PLAYER_PROGRESS)
|
||||
DEBUGF(", progressbar");
|
||||
else if (subline->line_type & WPS_REFRESH_PEAK_METER)
|
||||
DEBUGF(", peakmeter");
|
||||
|
||||
DEBUGF("\n");
|
||||
}
|
||||
DEBUGF("Number of lines : %d\n", data->num_lines);
|
||||
DEBUGF("Number of sublines: %d\n", data->num_sublines);
|
||||
DEBUGF("Number of tokens : %d\n", data->num_tokens);
|
||||
DEBUGF("\n");
|
||||
}
|
||||
|
||||
DEBUGF("\n");
|
||||
if (wps_verbose_level > 1)
|
||||
{
|
||||
for (i = 0, line = data->lines; i < data->num_lines; i++,line++)
|
||||
{
|
||||
DEBUGF("Line %2d (num_sublines=%d, first_subline=%d)\n",
|
||||
i, line->num_sublines, line->first_subline_idx);
|
||||
|
||||
for (j = 0, subline = data->sublines + line->first_subline_idx;
|
||||
j < line->num_sublines; j++, subline++)
|
||||
{
|
||||
DEBUGF(" Subline %d: first_token=%3d, last_token=%3d",
|
||||
j, subline->first_token_idx,
|
||||
wps_last_token_index(data, i, j));
|
||||
|
||||
if (subline->line_type & WPS_REFRESH_SCROLL)
|
||||
DEBUGF(", scrolled");
|
||||
else if (subline->line_type & WPS_REFRESH_PLAYER_PROGRESS)
|
||||
DEBUGF(", progressbar");
|
||||
else if (subline->line_type & WPS_REFRESH_PEAK_METER)
|
||||
DEBUGF(", peakmeter");
|
||||
|
||||
DEBUGF("\n");
|
||||
}
|
||||
}
|
||||
|
||||
DEBUGF("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void print_wps_strings(struct wps_data *data)
|
||||
{
|
||||
int i, len, total_len = 0, buf_used = 0;
|
||||
|
||||
DEBUGF("Strings:\n");
|
||||
if (wps_verbose_level > 1) DEBUGF("Strings:\n");
|
||||
for (i = 0; i < data->num_strings; i++)
|
||||
{
|
||||
len = strlen(data->strings[i]);
|
||||
total_len += len;
|
||||
buf_used += len + 1;
|
||||
DEBUGF("%2d: (%2d) '%s'\n", i, len, data->strings[i]);
|
||||
if (wps_verbose_level > 1)
|
||||
DEBUGF("%2d: (%2d) '%s'\n", i, len, data->strings[i]);
|
||||
}
|
||||
if (wps_verbose_level > 1) DEBUGF("\n");
|
||||
|
||||
if (wps_verbose_level > 0)
|
||||
{
|
||||
DEBUGF("Number of unique strings: %d (max: %d)\n",
|
||||
data->num_strings, WPS_MAX_STRINGS);
|
||||
DEBUGF("Total string length: %d\n", total_len);
|
||||
DEBUGF("String buffer used: %d out of %d bytes\n",
|
||||
buf_used, STRING_BUFFER_SIZE);
|
||||
DEBUGF("\n");
|
||||
}
|
||||
DEBUGF("\n");
|
||||
DEBUGF("Number of strings: %d out of an allowed %d\n",
|
||||
data->num_strings, WPS_MAX_STRINGS);
|
||||
DEBUGF("Total string length: %d\n", total_len);
|
||||
DEBUGF("String buffer used: %d out of %d bytes\n",
|
||||
buf_used, STRING_BUFFER_SIZE);
|
||||
DEBUGF("\n");
|
||||
}
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
|
@ -470,17 +483,22 @@ static void print_img_cond_indexes(struct wps_data *data)
|
|||
void print_debug_info(struct wps_data *data, int fail, int line)
|
||||
{
|
||||
#if defined(SIMULATOR) || defined(__PCTOOL__)
|
||||
if (debug_wps)
|
||||
if (debug_wps && wps_verbose_level)
|
||||
{
|
||||
dump_wps_tokens(data);
|
||||
print_wps_strings(data);
|
||||
print_line_info(data);
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
print_img_cond_indexes(data);
|
||||
if (wps_verbose_level > 2) print_img_cond_indexes(data);
|
||||
#endif
|
||||
}
|
||||
#endif /* SIMULATOR */
|
||||
|
||||
if (data->num_tokens >= WPS_MAX_TOKENS - 1) {
|
||||
DEBUGF("Warning: Max number of tokens was reached (%d)\n",
|
||||
WPS_MAX_TOKENS - 1);
|
||||
}
|
||||
|
||||
if (fail)
|
||||
{
|
||||
DEBUGF("Failed parsing on line %d : ", line);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#define MIN(x,y) ((x) > (y) ? (y) : (x))
|
||||
|
||||
bool debug_wps = true;
|
||||
int wps_verbose_level = 0;
|
||||
|
||||
int read_bmp_file(char* filename,
|
||||
struct bitmap *bm,
|
||||
|
@ -63,22 +64,36 @@ int main(int argc, char **argv)
|
|||
{
|
||||
int res;
|
||||
int fd;
|
||||
int filearg = 1;
|
||||
|
||||
struct wps_data wps;
|
||||
|
||||
if (argc != 2) {
|
||||
printf("Usage: checkwps filename.wps\n");
|
||||
if (argc < 2) {
|
||||
printf("Usage: checkwps [OPTIONS] filename.wps\n");
|
||||
printf("\nOPTIONS:\n");
|
||||
printf("\t-v\tverbose\n");
|
||||
printf("\t-vv\tmore verbose\n");
|
||||
printf("\t-vvv\tvery verbose\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fd = open(argv[1], O_RDONLY);
|
||||
if (argv[1][0] == '-') {
|
||||
filearg++;
|
||||
int i = 1;
|
||||
while (argv[1][i] && argv[1][i] == 'v') {
|
||||
i++;
|
||||
wps_verbose_level++;
|
||||
}
|
||||
}
|
||||
|
||||
fd = open(argv[filearg], O_RDONLY);
|
||||
if (fd < 0) {
|
||||
printf("Failed to open %s\n",argv[1]);
|
||||
return 2;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
res = wps_data_load(&wps, argv[1], true);
|
||||
res = wps_data_load(&wps, argv[filearg], true);
|
||||
|
||||
if (!res) {
|
||||
printf("WPS parsing failure\n");
|
||||
|
|
|
@ -56,6 +56,7 @@ char having_new_lcd = true; /* Used for player simulator */
|
|||
bool debug_audio = false;
|
||||
|
||||
bool debug_wps = false;
|
||||
int wps_verbose_level = 3;
|
||||
|
||||
long start_tick;
|
||||
|
||||
|
|
Loading…
Reference in a new issue