Inspect: permit stabilization action appending via command line
This commit is contained in:
parent
3457071db1
commit
f12aa93376
|
@ -1069,6 +1069,7 @@ static const Ecore_Getopt optdesc = {
|
|||
ECORE_GETOPT_STORE_TRUE('l', "list", "List the actions of the given recording."),
|
||||
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_STR('o', "output", "Output."),
|
||||
ECORE_GETOPT_STORE_USHORT('s', "shot", "Select a specific shot (1 = 1st shot...)."),
|
||||
|
||||
|
@ -1084,14 +1085,13 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
const char *ext = NULL;
|
||||
const char *rec_file = NULL;
|
||||
char *output = NULL;
|
||||
Exactness_Unit *unit = NULL;
|
||||
int ret = 1, args = 0;
|
||||
unsigned short delay = 0, shot = 0;
|
||||
Eina_Bool write_file = EINA_FALSE;
|
||||
Eina_Bool want_quit, clean = EINA_FALSE, list_get = EINA_FALSE, compare_files = EINA_FALSE;
|
||||
Eina_Bool show_only_diffs = EINA_FALSE, gui_needed = EINA_TRUE;
|
||||
Eina_Bool stabilize = EINA_FALSE, show_only_diffs = EINA_FALSE, gui_needed = EINA_TRUE;
|
||||
|
||||
Ecore_Getopt_Value values[] = {
|
||||
ECORE_GETOPT_VALUE_USHORT(delay),
|
||||
|
@ -1099,6 +1099,7 @@ main(int argc, char *argv[])
|
|||
ECORE_GETOPT_VALUE_BOOL(list_get),
|
||||
ECORE_GETOPT_VALUE_BOOL(compare_files),
|
||||
ECORE_GETOPT_VALUE_BOOL(show_only_diffs),
|
||||
ECORE_GETOPT_VALUE_BOOL(stabilize),
|
||||
ECORE_GETOPT_VALUE_STR(output),
|
||||
ECORE_GETOPT_VALUE_USHORT(shot),
|
||||
|
||||
|
@ -1125,15 +1126,25 @@ main(int argc, char *argv[])
|
|||
{
|
||||
goto end;
|
||||
}
|
||||
if ((clean || delay || shot || list_get) && args == argc)
|
||||
if ((clean || delay || shot || list_get || stabilize) && args == argc)
|
||||
{
|
||||
fprintf(stderr, "Expected rec file as the last argument.\n");
|
||||
fprintf(stderr, "Expected scenario (.rec/.exu) as the last argument.\n");
|
||||
ecore_getopt_help(stderr, &optdesc);
|
||||
goto end;
|
||||
}
|
||||
if (shot && !delay)
|
||||
if (shot && (!delay && !stabilize))
|
||||
{
|
||||
fprintf(stderr, "shot option can only be used with delay option.\n");
|
||||
fprintf(stderr, "shot option can only be used with delay or stabilize option.\n");
|
||||
goto end;
|
||||
}
|
||||
if (delay && !shot)
|
||||
{
|
||||
fprintf(stderr, "delay option can only be used with shot option.\n");
|
||||
goto end;
|
||||
}
|
||||
if (stabilize && !shot)
|
||||
{
|
||||
fprintf(stderr, "stabilize option can only be used with shot option.\n");
|
||||
goto end;
|
||||
}
|
||||
if (compare_files && argc - args < 2)
|
||||
|
@ -1144,21 +1155,40 @@ main(int argc, char *argv[])
|
|||
}
|
||||
if (show_only_diffs && !compare_files)
|
||||
{
|
||||
fprintf(stderr, "--show-only-diffs is available with --compare only");
|
||||
fprintf(stderr, "--show-only-diffs is available with --compare only\n");
|
||||
goto end;
|
||||
}
|
||||
if (show_only_diffs && output)
|
||||
{
|
||||
fprintf(stderr, "--show-only-diffs works in GUI only");
|
||||
fprintf(stderr, "--show-only-diffs works in GUI only\n");
|
||||
goto end;
|
||||
}
|
||||
_show_only_diffs = show_only_diffs;
|
||||
|
||||
if (clean || delay || list_get)
|
||||
if (clean || delay || list_get || stabilize)
|
||||
{
|
||||
rec_file = argv[args];
|
||||
const char *src_file = NULL;
|
||||
src_file = argv[args];
|
||||
gui_needed = EINA_FALSE;
|
||||
unit = legacy_rec_file_read(rec_file);
|
||||
if (!ext) ext = strrchr(src_file, '.');
|
||||
if (!ext)
|
||||
{
|
||||
fprintf(stderr, "Extension required\n");
|
||||
goto end;
|
||||
}
|
||||
if (!strcmp(ext, ".exu"))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1214,27 +1244,34 @@ main(int argc, char *argv[])
|
|||
write_file = EINA_TRUE;
|
||||
}
|
||||
|
||||
if (delay)
|
||||
if (delay || stabilize)
|
||||
{
|
||||
if (shot)
|
||||
Exactness_Action *act;
|
||||
Eina_List *itr;
|
||||
unsigned int cur_shot = 0;
|
||||
EINA_LIST_FOREACH(unit->actions, itr, act)
|
||||
{
|
||||
Exactness_Action *act;
|
||||
Eina_List *itr;
|
||||
unsigned int cur_shot = 0;
|
||||
EINA_LIST_FOREACH(unit->actions, itr, act)
|
||||
if (act->type == EXACTNESS_ACTION_TAKE_SHOT)
|
||||
{
|
||||
if (act->type == EXACTNESS_ACTION_TAKE_SHOT)
|
||||
cur_shot++;
|
||||
if (cur_shot == shot)
|
||||
{
|
||||
cur_shot++;
|
||||
if (cur_shot == shot)
|
||||
if (delay) act->delay_ms = delay;
|
||||
if (stabilize)
|
||||
{
|
||||
act->delay_ms = delay;
|
||||
break;
|
||||
Exactness_Action *s_act = malloc(sizeof(*s_act));
|
||||
s_act->type = EXACTNESS_ACTION_STABILIZE;
|
||||
s_act->delay_ms = act->delay_ms;
|
||||
s_act->n_evas = act->n_evas;
|
||||
s_act->data = NULL;
|
||||
act->delay_ms = 0; /* Shot right after stabilization */
|
||||
unit->actions = eina_list_prepend_relative(unit->actions, s_act, act);
|
||||
}
|
||||
write_file = EINA_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
write_file = EINA_TRUE;
|
||||
}
|
||||
|
||||
if (list_get)
|
||||
|
@ -1261,7 +1298,7 @@ main(int argc, char *argv[])
|
|||
else if (!unit2) unit2 = unit;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Too much files to compare (only 2).");
|
||||
fprintf(stderr, "Too much files to compare (only 2).\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1289,7 +1326,24 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
ret = 0;
|
||||
if (output && write_file) exactness_unit_file_write(unit, output);
|
||||
if (write_file)
|
||||
{
|
||||
if (!output)
|
||||
{
|
||||
fprintf(stderr, "An output file is required to write the modifications.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *out_ext = strrchr(output, '.');
|
||||
if (!out_ext || strcmp(out_ext, ".exu"))
|
||||
{
|
||||
fprintf(stderr, "Only exu extension is supported as output.\n");
|
||||
goto end;
|
||||
}
|
||||
exactness_unit_file_write(unit, output);
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (gui_needed)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue