summaryrefslogtreecommitdiff
path: root/src/bin/exactness
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-27 09:14:45 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2020-03-31 14:56:23 +0200
commit7891e8582bc9bfffa77e21e595306629a1c65d30 (patch)
treeb2a6931c299ca3d47ccd353028d047f9432554ef /src/bin/exactness
parent4ecc94f84afdb0d627c9f1809786d33300f23c85 (diff)
downloadefl-7891e8582bc9bfffa77e21e595306629a1c65d30.tar.gz
exactness_recorder: move to preload
this is now not a binary anymore, that dlopen's a binary, it is now a library, that can be loaded using LD_PRELOAD. EXACTNESS_DEST is used for the path of the .exu file. EXACTNESS_FONTS_DIR is used to get the fonts directory Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org> Differential Revision: https://phab.enlightenment.org/D11610
Diffstat (limited to 'src/bin/exactness')
-rw-r--r--src/bin/exactness/meson.build2
-rw-r--r--src/bin/exactness/recorder.c206
2 files changed, 82 insertions, 126 deletions
diff --git a/src/bin/exactness/meson.build b/src/bin/exactness/meson.build
index 4dbfc73d1f..405cb240de 100644
--- a/src/bin/exactness/meson.build
+++ b/src/bin/exactness/meson.build
@@ -37,7 +37,7 @@ exactness_play_bin = executable('exactness_play',
install: true,
)
-exactness_record_bin = executable('exactness_record',
+exactness_record_bin = library('exactness_record',
[ 'recorder.c', 'common.c', 'common.h' ],
dependencies: [ elementary ],
c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"',
diff --git a/src/bin/exactness/recorder.c b/src/bin/exactness/recorder.c
index 67b7becd57..6c881f950f 100644
--- a/src/bin/exactness/recorder.c
+++ b/src/bin/exactness/recorder.c
@@ -7,6 +7,10 @@
#include <getopt.h>
#include <unistd.h>
+#ifdef HAVE_DLSYM
+# include <dlfcn.h>
+#endif
+
#include <sys/types.h>
#ifdef HAVE_SYS_SYSINFO_H
# include <sys/sysinfo.h>
@@ -224,8 +228,7 @@ static Evas *
_my_evas_new(int w EINA_UNUSED, int h EINA_UNUSED)
{
Evas *e;
- if (!_evas_new) return NULL;
- e = _evas_new();
+ e = evas_new();
if (e)
{
INF("New Evas\n");
@@ -290,147 +293,100 @@ _setup_ee_creation(void)
_last_timestamp = ecore_time_get() * 1000;
}
+#ifdef HAVE_DLSYM
+# define ORIGINAL_CALL_T(t, name, ...) \
+ t (*_original_init_cb)(); \
+ _original_init_cb = dlsym(RTLD_NEXT, name); \
+ original_return = _original_init_cb(__VA_ARGS__);
+#else
+# define ORIGINAL_CALL_T(t, name, ...) \
+ printf("THIS IS NOT SUPPORTED ON WINDOWS\n"); \
+ abort();
+#endif
-static const Ecore_Getopt optdesc = {
- "exactness_record",
- "%prog [options] <-v|-t|-h> command",
- PACKAGE_VERSION,
- "(C) 2017 Enlightenment",
- "BSD",
- "A scenario recorder for EFL based applications.\n"
- "\tF1 - Request stabilization\n"
- "\tF2 - Request shot\n"
- "\tF3 - Request to save the scenario\n",
- 1,
- {
- ECORE_GETOPT_STORE_STR('t', "test", "Name of the filename where to store the test."),
- ECORE_GETOPT_STORE_STR('f', "fonts-dir", "Specify a directory of the fonts that should be used."),
-
- ECORE_GETOPT_LICENSE('L', "license"),
- ECORE_GETOPT_COPYRIGHT('C', "copyright"),
- ECORE_GETOPT_VERSION('V', "version"),
- ECORE_GETOPT_HELP('h', "help"),
- ECORE_GETOPT_SENTINEL
- }
-};
-
-int main(int argc, char **argv)
+#define ORIGINAL_CALL(name, ...) \
+ ORIGINAL_CALL_T(int, name, __VA_ARGS__)
+
+EAPI int
+eina_init(void)
{
- char *dest = NULL, *eq;
- char *fonts_dir = NULL;
- int pret = 1, opt_args = 0;
- Eina_Bool want_quit = EINA_FALSE;
- _evas_new = NULL;
-
- Ecore_Getopt_Value values[] = {
- ECORE_GETOPT_VALUE_STR(dest),
- ECORE_GETOPT_VALUE_STR(fonts_dir),
-
- ECORE_GETOPT_VALUE_BOOL(want_quit),
- ECORE_GETOPT_VALUE_BOOL(want_quit),
- ECORE_GETOPT_VALUE_BOOL(want_quit),
- ECORE_GETOPT_VALUE_BOOL(want_quit),
- ECORE_GETOPT_VALUE_NONE
- };
-
- _log_domain = eina_log_domain_register("exactness_recorder", NULL);
-
- if (!ecore_evas_init())
- return EXIT_FAILURE;
-
- opt_args = ecore_getopt_parse(&optdesc, values, argc, argv);
- if (opt_args < 0)
- {
- fprintf(stderr, "Failed parsing arguments.\n");
- goto end;
- }
- if (want_quit) goto end;
+ int original_return;
- /* Check for a sentinel */
- if (argv[opt_args] && !strcmp(argv[opt_args], "--")) opt_args++;
+ ORIGINAL_CALL("eina_init");
- /* Check for env variables */
- do
+ if (original_return == 1)
{
- eq = argv[opt_args] ? strchr(argv[opt_args], '=') : NULL;
- if (eq)
- {
- char *var = malloc(eq - argv[opt_args] + 1);
- memcpy(var, argv[opt_args], eq - argv[opt_args]);
- var[eq - argv[opt_args]] = '\0';
- setenv(var, eq + 1, 1);
- opt_args++;
- }
- } while (eq);
- _out_filename = eina_stringshare_add(dest);
+ _log_domain = eina_log_domain_register("exactness_recorder", NULL);
- if (!_out_filename)
- {
- fprintf(stderr, "no test file specified\n");
- goto end;
- }
- else
- {
- const char *_test_name;
- char *slash = strrchr(_out_filename, '/');
- if (slash) _test_name = strdup(slash + 1);
- else _test_name = strdup(_out_filename);
- char *dot = strrchr(_test_name, '.');
- if (dot) *dot = '\0';
- if (slash)
- {
- *slash = '\0';
- if (!ecore_file_mkpath(_out_filename))
- {
- fprintf(stderr, "Can't create %s\n", _out_filename);
- goto end;
- }
- *slash = '/';
- }
- }
- if (strcmp(_out_filename + strlen(_out_filename) - 4,".exu"))
- {
- fprintf(stderr, "A file with a exu extension is required - %s invalid\n", _out_filename);
- goto end;
- }
+ _out_filename = getenv("EXACTNESS_DEST");
+ _setup_unit();
+ if (!_setup_fonts_dir(getenv("EXACTNESS_FONTS_DIR")))
+ return -1;
- if (!argv[opt_args])
- {
- fprintf(stderr, "no program specified\nUse -h for more information\n");
- goto end;
+ _setup_shot_key();
}
- _setup_unit();
- if (!_setup_fonts_dir(fonts_dir))
- goto end;
+ return original_return;
+}
- /* Replace the current command line to hide the Exactness part */
- char **new_argv;
+EAPI int
+ecore_evas_init(void)
+{
+ int original_return;
- new_argv = calloc(argc - opt_args + 1, sizeof(char*));
+ ORIGINAL_CALL("ecore_evas_init")
- for (int i = 0; i < argc - opt_args + 1; ++i)
+ if (original_return == 1)
{
- if (i < argc - opt_args)
- new_argv[i] = argv[opt_args + i];
- else
- new_argv[i] = NULL;
+ _setup_ee_creation();
+
}
- _setup_shot_key();
- _setup_ee_creation();
+ return original_return;
+}
- pret = ex_prg_invoke(ex_prg_full_path_guess(argv[opt_args]), argc - opt_args, new_argv, EINA_FALSE);
+//hook, to hook in our theme
+EAPI int
+elm_init(int argc, char **argv)
+{
+ int original_return;
+ ORIGINAL_CALL("elm_init", argc, argv)
+
+ if (original_return == 1)
+ ex_prepare_elm_overloay();
+
+ return original_return;
+}
+EAPI void
+ecore_main_loop_begin(void)
+{
+ int original_return;
+ ORIGINAL_CALL("ecore_main_loop_begin")
_output_write();
- //free_events(_events_list, EINA_TRUE);
- //_events_list = NULL;
+ (void)original_return;
+}
+
+EAPI Eina_Value*
+efl_loop_begin(Eo *obj)
+{
+ Eina_Value *original_return;
+ ORIGINAL_CALL_T(Eina_Value*, "efl_loop_begin", obj);
+ _output_write();
+ return original_return;
+}
- pret = 0;
+EAPI int
+eina_shutdown(void)
+{
+ int original_return;
+ static Eina_Bool output_written = EINA_FALSE;
+ ORIGINAL_CALL("eina_shutdown")
+ if (original_return == 1 && !output_written)
+ {
+ output_written = EINA_TRUE;
+ _output_write();
+ }
-end:
- ecore_evas_shutdown();
- eina_log_domain_unregister(_log_domain);
- _log_domain = -1;
- return pret;
+ return original_return;
}