diff --git a/examples/android/assets/lisp/init.lisp b/examples/android/assets/lisp/init.lisp index a96aaadc8..1874e5d62 100644 --- a/examples/android/assets/lisp/init.lisp +++ b/examples/android/assets/lisp/init.lisp @@ -3,32 +3,44 @@ (lisp-implementation-version) (ext:lisp-implementation-vcs-id)) -(require :SOCKETS) -(require :ASDF) +(format t "Setting environment variables~%") (setq *default-directory* *default-pathname-defaults*) (defvar *ecl-home* *default-directory*) (ext:setenv "HOME" (namestring *ecl-home*)) +(setf asdf:*user-cache* + (merge-pathnames #P"../cache/" *default-pathname-defaults*)) + +(format t "Loading the modules~%") +(require :ASDF) +(require :SOCKETS) +(require :SERVE-EVENT) + (pushnew (namestring *default-pathname-defaults*) asdf:*central-registry*) -(asdf:oos 'asdf:load-op :swank) + +(format t "Preparing swank~%") +(handler-case (asdf:oos 'asdf:load-op :swank :verbose t) + (condition (c) + (format t "condition ~A happened~%" c) + (error c))) (swank-loader:init :load-contribs t :setup t :delete t :quiet nil) ;; The following "patches" swank to work correctly on android/iOS -(in-package :swank/backend) -(defimplementation lisp-implementation-program () - "Return the argv[0] of the running Lisp process, or NIL." - ;; (lisp-implementation-type) - nil) +;; (in-package :swank/backend) +;; (defimplementation lisp-implementation-program () +;; "Return the argv[0] of the running Lisp process, or NIL." +;; ;; (lisp-implementation-type) +;; nil) (in-package :swank) (defun repl-input-stream-read (connection stdin) (loop (let* ((socket (connection.socket-io connection)) - (inputs (list socket #+nil stdin)) + (inputs (list socket #-(or) stdin)) (ready (wait-for-input inputs))) (describe (list 'hobaa connection stdin socket inputs ready)) (cond ((eq ready :interrupt) @@ -46,12 +58,24 @@ (return (read-non-blocking stdin))) (t (assert (null ready))))))) +(format t "Starting swank~%") (mp:process-run-function "SLIME-listener" (lambda () - (swank:create-server :port 4005 - :dont-close t))) + (let ((swank::*loopback-interface* "0.0.0.0")) + (swank:create-server :port 4005 + :dont-close t + :style nil #|:spawn|# + )) + )) -(cond ((probe-file #P"user.lisp") - (load "user"))) +(format t "Loading user.lisp~%") +(handler-case (cond ((probe-file #P"user.lisp") + (format t "user exists~%") + (load "user")) + (T (format t "user.lisp doesn't exist~%"))) + (condition (c) + (format t "condition ~A happened~%" c) + (error c))) +(format t "Initialization done~%") diff --git a/examples/android/jni/Android.mk b/examples/android/jni/Android.mk index 1784f06ec..8abb519db 100644 --- a/examples/android/jni/Android.mk +++ b/examples/android/jni/Android.mk @@ -16,13 +16,15 @@ BASE_PATH := $(call my-dir) include $(CLEAR_VARS) +# ecl_android shared object +include $(CLEAR_VARS) ifeq ($(TARGET_ARCH),x86) PLATFORM := androidx86 else PLATFORM := android endif -ECL_HOME := ../../android/install/$(PLATFORM) +ECL_HOME := ecl-android/ ECL_VER := $(shell basename $(ECL_HOME)/lib/ecl-* |cut -d "-" -f2) LOCAL_MODULE := ecl_android @@ -30,10 +32,14 @@ LOCAL_PATH := $(BASE_PATH) LOCAL_SRC_FILES := org_lisp_ecl_EmbeddedCommonLisp.c ecl_boot.c LOCAL_CFLAGS += -I$(ECL_HOME)/include LOCAL_CFLAGS += -g -Wall -DANDROID +# LOCAL_SHARED_LIBRARIES := ecl +# LOCAL_STATIC_LIBRARIES := asdf sockets ecl-help LOCAL_LDLIBS := -L$(ECL_HOME)/lib LOCAL_LDLIBS += -L$(ECL_HOME)/lib/ecl-$(ECL_VER) -LOCAL_LDLIBS += -lecl -lasdf -leclgmp -lsockets -llog -LOCAL_LDLIBS += -lsb-bsd-sockets -lserve-event -lecl-help -LOCAL_LDLIBS += -lecl-cdb -leclgc -leclatomic +LOCAL_LDLIBS += -llog +LOCAL_LDLIBS += -lecl -leclgc -leclatomic -leclgmp -leclffi +LOCAL_LDLIBS += -lasdf -lsockets -lsb-bsd-sockets -lecl-help -lecl-cdb -lserve-event + +# LOCAL_STATIC_LIBRARIES := ecl eclatomic eclffi eclgc eclgmp include $(BUILD_SHARED_LIBRARY) diff --git a/examples/android/jni/ecl_boot.c b/examples/android/jni/ecl_boot.c index 9a3ba5afa..293ac73d7 100644 --- a/examples/android/jni/ecl_boot.c +++ b/examples/android/jni/ecl_boot.c @@ -39,9 +39,13 @@ int ecl_boot(const char *root_dir) char *ecl = "ecl"; char tmp[2048]; + LOGI("ECL boot beginning\n"); + sprintf(tmp, "%s/", root_dir); setenv("ECLDIR", tmp, 1); + LOGI("ECLDIR set\n"); + // ecl_set_option(ECL_OPT_TRAP_SIGFPE, 0); // ecl_set_option(ECL_OPT_TRAP_SIGSEGV, 0); // ecl_set_option(ECL_OPT_TRAP_SIGINT, 0); @@ -53,17 +57,20 @@ int ecl_boot(const char *root_dir) cl_boot(1, &ecl); - init_lib_ECL_HELP(); - init_lib_ASDF(); - init_lib_SOCKETS(); + LOGI("installing bytecodes compiler\n"); + si_safe_eval(3, c_string_to_object("(si:install-bytecodes-compiler)"), ECL_NIL, OBJNULL); + LOGI("initializing linked modules\n"); + ecl_init_module(NULL, init_lib_ECL_HELP); + ecl_init_module(NULL, init_lib_ASDF); + ecl_init_module(NULL, init_lib_SOCKETS); + ecl_init_module(NULL, init_lib_SERVE_EVENT); + LOGI("writing some info to stdout\n"); si_safe_eval(3, c_string_to_object("(format t \"ECL_BOOT, features = ~A ~%\" *features*)"), Cnil, OBJNULL); si_safe_eval(3, c_string_to_object("(format t \"(truename SYS:): ~A)\" (truename \"SYS:\"))"), Cnil, OBJNULL); - LOGI("ALL LOADED\n"); ecl_toplevel(root_dir); - return 0; } @@ -77,11 +84,8 @@ void ecl_toplevel(const char *home) { sprintf(tmp, "(setq *default-pathname-defaults* #p\"%s/\")", home); si_safe_eval(3, c_string_to_object(tmp), Cnil, OBJNULL); - si_select_package(ecl_make_simple_base_string("CL-USER", 7)); - si_safe_eval(3, c_string_to_object("(load \"init\")"), Cnil, OBJNULL); - } CL_CATCH_ALL_END; LOGI("EXIT TOP LEVEL\n"); diff --git a/examples/android/jni/org_lisp_ecl_EmbeddedCommonLisp.c b/examples/android/jni/org_lisp_ecl_EmbeddedCommonLisp.c index 2e6f85cef..e407e8cea 100644 --- a/examples/android/jni/org_lisp_ecl_EmbeddedCommonLisp.c +++ b/examples/android/jni/org_lisp_ecl_EmbeddedCommonLisp.c @@ -36,7 +36,8 @@ Java_org_lisp_ecl_EmbeddedCommonLisp_start(JNIEnv *env, jobject this, jstring path) { const char *lisp_dir = (*env)->GetStringUTFChars(env, path, NULL); - LOGI("ECL starting: *default-pathname-defaults* to: %s\n", lisp_dir); + LOGI("XXX: ECL starting: *default-pathname-defaults* to: %s\n", lisp_dir); + LOGE("XXX: hey ho\n"); ecl_boot(lisp_dir); LOGI("ECL started."); }; diff --git a/examples/android/project.properties b/examples/android/project.properties index 4ab125693..b7c2081d5 100644 --- a/examples/android/project.properties +++ b/examples/android/project.properties @@ -11,4 +11,4 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-19 +target=android-10