Debian Codegraph @

examples/android/jni/ecl_boot.c

raw symbols SCIP
1 #include <stdlib.h>
2 #include <ecl/ecl.h>
3 #if ANDROID
4 #include <android/log.h>
5 #endif
6
7 #if ANDROID
8 #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native-activity", __VA_ARGS__))
9 #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "native-activity", __VA_ARGS__))
10 #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "native-activity", __VA_ARGS__))
11 #define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", __VA_ARGS__))
12 #else
13 #define LOGI(...)
14 #define LOGW(...)
15 #define LOGE(...)
16 #endif
17
18 #include "ecl_boot.h"
19
20 #ifdef __cplusplus
21 #define ECL_CPP_TAG "C"
22 #else
23 #define ECL_CPP_TAG
24 #endif
25
26 /* extern ECL_CPP_TAG void init_lib_ASDF(); */
27 /* extern ECL_CPP_TAG void init_lib_SOCKETS(); */
28 /* extern ECL_CPP_TAG void init_lib_SB_BSD_SOCKETS(); */
29 /* extern ECL_CPP_TAG void init_lib_SERVE_EVENT(); */
30 /* extern ECL_CPP_TAG void init_lib_ECL_CDB(); */
31 /* extern ECL_CPP_TAG void init_lib_ECL_HELP() */;
32
33 extern void loadLispFromAssets(char* fn);
34
35 int ecl_boot(const char *root_dir)
36 {
37 char *ecl = "ecl";
38 char tmp[2048];
39
40 LOGI("ECL boot beginning\n");
41
42 LOGI("Setting directories\n");
43 setenv("HOME", root_dir, 1);
44
45 sprintf(tmp, "%s/lib/", root_dir);
46 setenv("ECLDIR", tmp, 1);
47
48 sprintf(tmp, "%s/etc/", root_dir);
49 setenv("ETC", tmp, 1);
50
51 sprintf(tmp, "%s/home/", root_dir);
52 setenv("HOME", tmp, 1);
53
54 LOGI("Directories set\n");
55
56 /* ecl_set_option(ECL_OPT_TRAP_SIGFPE, 0); */
57 /* ecl_set_option(ECL_OPT_TRAP_SIGSEGV, 0); */
58 /* ecl_set_option(ECL_OPT_TRAP_SIGINT, 0); */
59 /* ecl_set_option(ECL_OPT_TRAP_SIGILL, 0); */
60 /* ecl_set_option(ECL_OPT_TRAP_SIGBUS, 0); */
61 /* ecl_set_option(ECL_OPT_TRAP_INTERRUPT_SIGNAL, 0); */
62 /* ecl_set_option(ECL_OPT_SIGNAL_HANDLING_THREAD, 0); */
63 /* ecl_set_option(ECL_OPT_INCREMENTAL_GC, 0); */
64
65 cl_boot(1, &ecl);
66
67 LOGI("installing bytecodes compiler\n");
68 si_safe_eval(3, c_string_to_object("(si:install-bytecodes-compiler)"), ECL_NIL, OBJNULL);
69
70 /* LOGI("initializing linked modules\n"); */
71 /* ecl_init_module(NULL, init_lib_ECL_HELP); */
72 /* ecl_init_module(NULL, init_lib_ASDF); */
73 /* ecl_init_module(NULL, init_lib_SOCKETS); */
74 /* ecl_init_module(NULL, init_lib_SERVE_EVENT); */
75
76 LOGI("writing some info to stdout\n");
77 si_safe_eval
78 (3, c_string_to_object
79 ("(format t \"ECL_BOOT, features = ~A ~%\" *features*)"),
80 Cnil, OBJNULL);
81 si_safe_eval
82 (3, c_string_to_object
83 ("(format t \"(truename SYS:): ~A)\" (truename \"SYS:\"))"),
84 Cnil, OBJNULL);
85
86 ecl_toplevel(root_dir);
87 return 0;
88 }
89
90 void ecl_toplevel(const char *home)
91 {
92 char tmp[2048];
93
94 LOGI("Executing the init scripts\n");
95
96 CL_CATCH_ALL_BEGIN(ecl_process_env())
97 {
98 sprintf(tmp, "(setq *default-pathname-defaults* #p\"%s/\")", home);
99 si_safe_eval(3, c_string_to_object(tmp), Cnil, OBJNULL);
100 si_select_package(ecl_make_simple_base_string("CL-USER", 7));
101 si_safe_eval(3, c_string_to_object("(load \"etc/init\")"), Cnil, OBJNULL);
102 } CL_CATCH_ALL_END;
103
104 LOGI("Toplevel initialization done\n");
105 }