Use source codes stored in the unit as application
This can be useful if the application is not in an official repository like elementary_test. This feature allows compiling the source code and using it to run the scenario on. The command (e.g gcc...) must be stored in the unit as well. $SRC and $DEST can be used to specify the source and destination files in the command.
This commit is contained in:
parent
5ffc8ec640
commit
9831560caf
|
@ -249,8 +249,11 @@ ok:
|
||||||
if (_mode == RUN_INIT)
|
if (_mode == RUN_INIT)
|
||||||
eina_strbuf_append_printf(sbuf, "-o '%s/%s' ", _dest_dir, ORIG_SUBDIR);
|
eina_strbuf_append_printf(sbuf, "-o '%s/%s' ", _dest_dir, ORIG_SUBDIR);
|
||||||
}
|
}
|
||||||
eina_strbuf_append(sbuf, "-- ");
|
if (ent->command)
|
||||||
eina_strbuf_append(sbuf, ent->command);
|
{
|
||||||
|
eina_strbuf_append(sbuf, "-- ");
|
||||||
|
eina_strbuf_append(sbuf, ent->command);
|
||||||
|
}
|
||||||
strncpy(buf, eina_strbuf_string_get(sbuf), SCHEDULER_CMD_SIZE-1);
|
strncpy(buf, eina_strbuf_string_get(sbuf), SCHEDULER_CMD_SIZE-1);
|
||||||
eina_strbuf_free(sbuf);
|
eina_strbuf_free(sbuf);
|
||||||
_printf(1, "Command: %s\n", buf);
|
_printf(1, "Command: %s\n", buf);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef HAVE_SYS_SYSINFO_H
|
#ifdef HAVE_SYS_SYSINFO_H
|
||||||
# include <sys/sysinfo.h>
|
# include <sys/sysinfo.h>
|
||||||
|
@ -1100,12 +1101,6 @@ int main(int argc, char **argv)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!argv[opt_args])
|
|
||||||
{
|
|
||||||
fprintf(stderr, "no program specified\nUse -h for more information\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dest_type == FTYPE_EXU) _dest_unit = calloc(1, sizeof(*_dest_unit));
|
if (_dest_type == FTYPE_EXU) _dest_unit = calloc(1, sizeof(*_dest_unit));
|
||||||
|
|
||||||
if (!_src_open())
|
if (!_src_open())
|
||||||
|
@ -1158,21 +1153,59 @@ int main(int argc, char **argv)
|
||||||
efl_object_init();
|
efl_object_init();
|
||||||
evas_init();
|
evas_init();
|
||||||
|
|
||||||
/* Replace the current command line to hide the Exactness part */
|
if (argv[opt_args])
|
||||||
int len = argv[argc - 1] + strlen(argv[argc - 1]) - argv[opt_args];
|
|
||||||
memcpy(argv[0], argv[opt_args], len);
|
|
||||||
memset(argv[0] + len, 0, _POSIX_PATH_MAX - len);
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = opt_args; i < argc; i++)
|
|
||||||
{
|
{
|
||||||
if (i != opt_args)
|
/* Replace the current command line to hide the Exactness part */
|
||||||
|
int len = argv[argc - 1] + strlen(argv[argc - 1]) - argv[opt_args];
|
||||||
|
memcpy(argv[0], argv[opt_args], len);
|
||||||
|
memset(argv[0] + len, 0, _POSIX_PATH_MAX - len);
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = opt_args; i < argc; i++)
|
||||||
{
|
{
|
||||||
argv[i - opt_args] = argv[0] + (argv[i] - argv[opt_args]);
|
if (i != opt_args)
|
||||||
|
{
|
||||||
|
argv[i - opt_args] = argv[0] + (argv[i] - argv[opt_args]);
|
||||||
|
}
|
||||||
|
_printf(1, "%s ", argv[i - opt_args]);
|
||||||
}
|
}
|
||||||
_printf(1, "%s ", argv[i - opt_args]);
|
_printf(1, "\n");
|
||||||
}
|
}
|
||||||
_printf(1, "\n");
|
else
|
||||||
|
{
|
||||||
|
Eina_List *itr;
|
||||||
|
Exactness_Source_Code *code;
|
||||||
|
Eina_Tmpstr *f_output = NULL;
|
||||||
|
EINA_LIST_FOREACH(_src_unit->codes, itr, code)
|
||||||
|
{
|
||||||
|
if (!strcmp(code->language, "C") && code->command)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
Ecore_Exe *exe;
|
||||||
|
Eina_Tmpstr *f_code;
|
||||||
|
Eina_Strbuf *sbuf;
|
||||||
|
int fd_code = eina_file_mkstemp("exactness_XXXXXX.c", &f_code);
|
||||||
|
int fd_output = eina_file_mkstemp("exactness_XXXXXX.output", &f_output);
|
||||||
|
close(fd_output);
|
||||||
|
write(fd_code, code->content, strlen(code->content));
|
||||||
|
close(fd_code);
|
||||||
|
|
||||||
|
sbuf = eina_strbuf_new();
|
||||||
|
eina_strbuf_append(sbuf, code->command);
|
||||||
|
eina_strbuf_replace_all(sbuf, "$SRC", f_code);
|
||||||
|
eina_strbuf_replace_all(sbuf, "$DEST", f_output);
|
||||||
|
exe = ecore_exe_pipe_run(eina_strbuf_string_get(sbuf), ECORE_EXE_NONE, NULL);
|
||||||
|
waitpid(ecore_exe_pid_get(exe), &status, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!f_output)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "no program specified\nUse -h for more information\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
argv[0] = strdup(f_output);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ecore_evas_callback_new_set(_my_evas_new);
|
ecore_evas_callback_new_set(_my_evas_new);
|
||||||
if (_src_type != FTYPE_REMOTE)
|
if (_src_type != FTYPE_REMOTE)
|
||||||
|
|
|
@ -186,12 +186,20 @@ typedef struct
|
||||||
void *pixels; /**< Pixels of the image */
|
void *pixels; /**< Pixels of the image */
|
||||||
} Exactness_Image;
|
} Exactness_Image;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char *language; /**< String describing the language of the content e.g "C"...*/
|
||||||
|
char *content; /**< Content used as source */
|
||||||
|
char *command; /**< Command needed to generate the application from the content */
|
||||||
|
} Exactness_Source_Code;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
Eina_List *actions; /**< List of Exactness_Action */
|
Eina_List *actions; /**< List of Exactness_Action */
|
||||||
/* imgs not in EET */
|
/* imgs not in EET */
|
||||||
Eina_List *imgs; /**< List of Exactness_Image */
|
Eina_List *imgs; /**< List of Exactness_Image */
|
||||||
Eina_List *objs; /**< List of Exactness_Objects */
|
Eina_List *objs; /**< List of Exactness_Objects */
|
||||||
|
Eina_List *codes; /**< List of Exactness_Source_Code */
|
||||||
const char *fonts_path; /**< Path to the fonts to use, relative to the fonts dir given in parameter to the player/recorder */
|
const char *fonts_path; /**< Path to the fonts to use, relative to the fonts dir given in parameter to the player/recorder */
|
||||||
int nb_shots; /**< The number of shots present in the unit */
|
int nb_shots; /**< The number of shots present in the unit */
|
||||||
} Exactness_Unit;
|
} Exactness_Unit;
|
||||||
|
|
|
@ -203,6 +203,13 @@ _unit_desc_make(void)
|
||||||
}
|
}
|
||||||
if (!unit_d)
|
if (!unit_d)
|
||||||
{
|
{
|
||||||
|
Eet_Data_Descriptor *code_d = NULL;
|
||||||
|
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Source_Code);
|
||||||
|
code_d = eet_data_descriptor_stream_new(&eddc);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "language", language, EET_T_STRING);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "content", content, EET_T_STRING);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "command", command, EET_T_STRING);
|
||||||
|
|
||||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action);
|
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action);
|
||||||
action_d = eet_data_descriptor_stream_new(&eddc);
|
action_d = eet_data_descriptor_stream_new(&eddc);
|
||||||
|
|
||||||
|
@ -243,6 +250,7 @@ _unit_desc_make(void)
|
||||||
unit_d = eet_data_descriptor_stream_new(&eddc);
|
unit_d = eet_data_descriptor_stream_new(&eddc);
|
||||||
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "actions", actions, action_d);
|
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "actions", actions, action_d);
|
||||||
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "objs", objs, objs_d);
|
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "objs", objs, objs_d);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "codes", codes, code_d);
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "fonts_path", fonts_path, EET_T_STRING);
|
EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "fonts_path", fonts_path, EET_T_STRING);
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "nb_shots", nb_shots, EET_T_UINT);
|
EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "nb_shots", nb_shots, EET_T_UINT);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue