android: arrange resources directory

Separate different directories for the resources.
 #P"SYS:" -> #P"lisp/lib" - ECLDIR with the modules
 $HOME -> lisp/home       - user provided files, quicklisp, 3rd party contribs
           lisp/etc       - init scripts and the configuration
This commit is contained in:
Daniel Kochmański 2015-10-22 14:40:54 +02:00
parent 58ee224fe3
commit b8edd5cda8
3 changed files with 47 additions and 24 deletions

View file

@ -7,22 +7,30 @@
(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*))
(ext:setenv "USER-CACHE"
(namestring (merge-pathnames #P"../cache/" *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)
;; swank probes sys:serve-event.fas (which doesn't exist)
;; (pushnew :SERVE-EVENT *features*)
(pushnew (namestring *default-pathname-defaults*)
asdf:*central-registry*)
(pushnew (namestring (merge-pathnames #P"home/slime-2.14/" *ecl-home*))
asdf:*central-registry*)
(format t "Preparing swank~%")
(handler-case (asdf:oos 'asdf:load-op :swank :verbose t)
(condition (c)
(format t "condition ~A happened~%" c)
(format t "filepath SYS:SLIME-2.14;SWANK.ASD.NEWEST: ~A~%"
(truename #P"SYS:SLIME-2.14;SWANK.ASD.NEWEST"))
(force-output)
(error c)))
(swank-loader:init :load-contribs t
:setup t
@ -30,17 +38,17 @@
: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."
;; "org.lisp.ecl"
nil)
(in-package :swank)
(defun repl-input-stream-read (connection stdin)
(loop
(let* ((socket (connection.socket-io connection))
(inputs (list socket #-(or) stdin))
(inputs (list socket #+(or) stdin))
(ready (wait-for-input inputs)))
(describe (list 'hobaa connection stdin socket inputs ready))
(cond ((eq ready :interrupt)
@ -58,6 +66,18 @@
(return (read-non-blocking stdin)))
(t (assert (null ready)))))))
;; (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)))
(when (probe-file #P"etc/user.lisp")
(load "etc/user"))
(format t "Starting swank~%")
(mp:process-run-function
"SLIME-listener"
@ -65,17 +85,10 @@
(let ((swank::*loopback-interface* "0.0.0.0"))
(swank:create-server :port 4005
:dont-close t
:style nil #|:spawn|#
;; :style nil #|:spawn|#
))
))
(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~%")
(force-output)
(sleep 3)

View file

@ -1,8 +1,9 @@
(in-package :cl-user)
(require 'bytecmp)
(setq *default-directory*
*default-pathname-defaults*)
(format t "user.lisp 1~%")
(defun sysinfo (&optional (out *standard-output*))
"Print the current environment to a stream."
(declare (stream out))

View file

@ -41,10 +41,19 @@ int ecl_boot(const char *root_dir)
LOGI("ECL boot beginning\n");
sprintf(tmp, "%s/", root_dir);
LOGI("Setting directories\n");
setenv("HOME", root_dir, 1);
sprintf(tmp, "%s/lib/", root_dir);
setenv("ECLDIR", tmp, 1);
LOGI("ECLDIR set\n");
sprintf(tmp, "%s/etc/", root_dir);
setenv("ETC", tmp, 1);
sprintf(tmp, "%s/home/", root_dir);
setenv("HOME", tmp, 1);
LOGI("Directories set\n");
// ecl_set_option(ECL_OPT_TRAP_SIGFPE, 0);
// ecl_set_option(ECL_OPT_TRAP_SIGSEGV, 0);
@ -85,7 +94,7 @@ 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);
si_safe_eval(3, c_string_to_object("(load \"etc/init\")"), Cnil, OBJNULL);
} CL_CATCH_ALL_END;
LOGI("EXIT TOP LEVEL\n");