From 89a207bd34257f92c4ddbbb30573a4a221c1c4ab Mon Sep 17 00:00:00 2001 From: Daniel Zaoui Date: Tue, 30 Oct 2018 15:19:46 +0200 Subject: [PATCH] Inspect: permit packing given scenario and images into a exu file --- src/bin/inspect.c | 76 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 19 deletions(-) diff --git a/src/bin/inspect.c b/src/bin/inspect.c index a4d2323..c796c4d 100644 --- a/src/bin/inspect.c +++ b/src/bin/inspect.c @@ -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(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, "pack", "Pack the given input files (scenario and images) into the given output."), ECORE_GETOPT_STORE_STR('o', "output", "Output."), 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 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 pack = EINA_FALSE; Ecore_Getopt_Value values[] = { ECORE_GETOPT_VALUE_USHORT(delay), @@ -1178,6 +1180,7 @@ main(int argc, char *argv[]) ECORE_GETOPT_VALUE_BOOL(compare_files), ECORE_GETOPT_VALUE_BOOL(show_only_diffs), ECORE_GETOPT_VALUE_BOOL(stabilize), + ECORE_GETOPT_VALUE_BOOL(pack), ECORE_GETOPT_VALUE_STR(output), ECORE_GETOPT_VALUE_USHORT(shot), @@ -1204,7 +1207,7 @@ main(int argc, char *argv[]) { 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"); ecore_getopt_help(stderr, &optdesc); @@ -1243,29 +1246,62 @@ main(int argc, char *argv[]) } _show_only_diffs = show_only_diffs; - if (clean || delay || list_get || stabilize) + if (clean || delay || list_get || stabilize || pack) { - const char *src_file = NULL; - src_file = argv[args]; + int arg; + Eina_List *images = NULL; gui_needed = EINA_FALSE; - if (!ext) ext = strrchr(src_file, '.'); - if (!ext) + for (arg = args; arg < argc; arg++) { - fprintf(stderr, "Extension required\n"); - goto end; + const char *src_file = argv[arg]; + 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); - } - else if (!strcmp(ext, ".rec")) - { - unit = legacy_rec_file_read(src_file); - } - else - { - fprintf(stderr, "Correct extension (.exu/.rec) required\n"); - goto end; + Exactness_Image *ex_img; + EINA_LIST_FREE(images, ex_img) + { + unit->imgs = eina_list_append(unit->imgs, ex_img); + unit->nb_shots++; + } } } else @@ -1353,6 +1389,8 @@ main(int argc, char *argv[]) } } + if (pack) write_file = EINA_TRUE; + if (list_get) { Exactness_Action *act;