Inspect: permit packing given scenario and images into a exu file

This commit is contained in:
Daniel Zaoui 2018-10-30 15:19:46 +02:00
parent 6f74e380a4
commit 89a207bd34
1 changed files with 57 additions and 19 deletions

View File

@ -1147,6 +1147,7 @@ static const Ecore_Getopt optdesc = {
ECORE_GETOPT_STORE_TRUE('C', "compare", "Compare given files (images files or objects eet files)."), ECORE_GETOPT_STORE_TRUE('C', "compare", "Compare given files (images files or objects eet files)."),
ECORE_GETOPT_STORE_TRUE(0, "show-only-diffs", "Show only differences during comparison."), ECORE_GETOPT_STORE_TRUE(0, "show-only-diffs", "Show only differences during comparison."),
ECORE_GETOPT_STORE_TRUE(0, "stabilize", "Stabilize after the given shot number in --shot."), ECORE_GETOPT_STORE_TRUE(0, "stabilize", "Stabilize after the given shot number in --shot."),
ECORE_GETOPT_STORE_TRUE(0, "pack", "Pack the given input files (scenario and images) into the given output."),
ECORE_GETOPT_STORE_STR('o', "output", "Output."), ECORE_GETOPT_STORE_STR('o', "output", "Output."),
ECORE_GETOPT_STORE_USHORT('s', "shot", "Select a specific shot (1 = 1st shot...)."), ECORE_GETOPT_STORE_USHORT('s', "shot", "Select a specific shot (1 = 1st shot...)."),
@ -1170,6 +1171,7 @@ main(int argc, char *argv[])
Eina_Bool write_file = EINA_FALSE; Eina_Bool write_file = EINA_FALSE;
Eina_Bool want_quit, clean = EINA_FALSE, list_get = EINA_FALSE, compare_files = EINA_FALSE; Eina_Bool want_quit, clean = EINA_FALSE, list_get = EINA_FALSE, compare_files = EINA_FALSE;
Eina_Bool stabilize = EINA_FALSE, show_only_diffs = EINA_FALSE, gui_needed = EINA_TRUE; Eina_Bool stabilize = EINA_FALSE, show_only_diffs = EINA_FALSE, gui_needed = EINA_TRUE;
Eina_Bool pack = EINA_FALSE;
Ecore_Getopt_Value values[] = { Ecore_Getopt_Value values[] = {
ECORE_GETOPT_VALUE_USHORT(delay), ECORE_GETOPT_VALUE_USHORT(delay),
@ -1178,6 +1180,7 @@ main(int argc, char *argv[])
ECORE_GETOPT_VALUE_BOOL(compare_files), ECORE_GETOPT_VALUE_BOOL(compare_files),
ECORE_GETOPT_VALUE_BOOL(show_only_diffs), ECORE_GETOPT_VALUE_BOOL(show_only_diffs),
ECORE_GETOPT_VALUE_BOOL(stabilize), ECORE_GETOPT_VALUE_BOOL(stabilize),
ECORE_GETOPT_VALUE_BOOL(pack),
ECORE_GETOPT_VALUE_STR(output), ECORE_GETOPT_VALUE_STR(output),
ECORE_GETOPT_VALUE_USHORT(shot), ECORE_GETOPT_VALUE_USHORT(shot),
@ -1204,7 +1207,7 @@ main(int argc, char *argv[])
{ {
goto end; goto end;
} }
if ((clean || delay || shot || list_get || stabilize) && args == argc) if ((clean || delay || shot || list_get || stabilize || pack) && args == argc)
{ {
fprintf(stderr, "Expected scenario (.rec/.exu) as the last argument.\n"); fprintf(stderr, "Expected scenario (.rec/.exu) as the last argument.\n");
ecore_getopt_help(stderr, &optdesc); ecore_getopt_help(stderr, &optdesc);
@ -1243,29 +1246,62 @@ main(int argc, char *argv[])
} }
_show_only_diffs = show_only_diffs; _show_only_diffs = show_only_diffs;
if (clean || delay || list_get || stabilize) if (clean || delay || list_get || stabilize || pack)
{ {
const char *src_file = NULL; int arg;
src_file = argv[args]; Eina_List *images = NULL;
gui_needed = EINA_FALSE; gui_needed = EINA_FALSE;
if (!ext) ext = strrchr(src_file, '.'); for (arg = args; arg < argc; arg++)
if (!ext)
{ {
fprintf(stderr, "Extension required\n"); const char *src_file = argv[arg];
goto end; ext = strrchr(src_file, '.');
if (!ext)
{
fprintf(stderr, "Extension required\n");
goto end;
}
if (!strcmp(ext, ".exu"))
{
if (!unit) unit = exactness_unit_file_read(src_file);
else
{
fprintf(stderr, "%s - scenario already provided\n", src_file);
goto end;
}
}
else if (!strcmp(ext, ".rec"))
{
if (!unit) unit = legacy_rec_file_read(src_file);
else
{
fprintf(stderr, "%s - scenario already provided\n", src_file);
goto end;
}
}
else if (!strcmp(ext, ".png"))
{
Exactness_Image *ex_img = _image_read(src_file);
if (!ex_img)
{
fprintf(stderr, "Issue while reading %s\n", src_file);
goto end;
}
images = eina_list_append(images, ex_img);
}
else
{
fprintf(stderr, "Correct extension (.exu/.rec/.png) required\n");
goto end;
}
} }
if (!strcmp(ext, ".exu")) if (unit)
{ {
unit = exactness_unit_file_read(src_file); Exactness_Image *ex_img;
} EINA_LIST_FREE(images, ex_img)
else if (!strcmp(ext, ".rec")) {
{ unit->imgs = eina_list_append(unit->imgs, ex_img);
unit = legacy_rec_file_read(src_file); unit->nb_shots++;
} }
else
{
fprintf(stderr, "Correct extension (.exu/.rec) required\n");
goto end;
} }
} }
else else
@ -1353,6 +1389,8 @@ main(int argc, char *argv[])
} }
} }
if (pack) write_file = EINA_TRUE;
if (list_get) if (list_get)
{ {
Exactness_Action *act; Exactness_Action *act;