emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/native-comp c3bc348: * Fix failure when eln-cache is removed (in


From: Andrea Corallo
Subject: feature/native-comp c3bc348: * Fix failure when eln-cache is removed (introduced by 4a1bb46260)
Date: Thu, 8 Oct 2020 03:40:13 -0400 (EDT)

branch: feature/native-comp
commit c3bc348f5edefa4231d38b6d3967f0c8f0bb5e6d
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    * Fix failure when eln-cache is removed (introduced by 4a1bb46260)
    
        * src/comp.c (make_directory_wrapper, make_directory_wrapper_1):
        New functions.
        (Fcomp_el_to_eln_filename): If base_dir is not
        specified and we are searching across `comp-load-path' try to
        create a directory if does not exists.
---
 src/comp.c | 44 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 37 insertions(+), 7 deletions(-)

diff --git a/src/comp.c b/src/comp.c
index ba4089e..1b96bff 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -4013,6 +4013,19 @@ compile_function (Lisp_Object func)
 /* In use by Fcomp_el_to_eln_filename.  */
 static Lisp_Object loadsearch_re_list;
 
+static Lisp_Object
+make_directory_wrapper (Lisp_Object directory)
+{
+  CALL2I (make-directory, directory, Qt);
+  return Qnil;
+}
+
+static Lisp_Object
+make_directory_wrapper_1 (Lisp_Object ignore)
+{
+  return Qt;
+}
+
 DEFUN ("comp-el-to-eln-filename", Fcomp_el_to_eln_filename,
        Scomp_el_to_eln_filename, 1, 2, 0,
        doc: /* Given a source FILENAME return the corresponding .eln filename.
@@ -4087,14 +4100,31 @@ If BASE-DIR is nil use the first entry in 
`comp-eln-load-path'.  */)
     {
       Lisp_Object eln_load_paths = Vcomp_eln_load_path;
       FOR_EACH_TAIL (eln_load_paths)
-       if (!NILP (Ffile_writable_p (XCAR (eln_load_paths))))
-         {
-           base_dir = XCAR (eln_load_paths);
-           break;
-         }
-      /* If we can't find it return Nil.  */
+       {
+         Lisp_Object dir = XCAR (eln_load_paths);
+         if (!NILP (Ffile_exists_p (dir)))
+           {
+             if (!NILP (Ffile_writable_p (dir)))
+               {
+                 base_dir = dir;
+                 break;
+               }
+           }
+         else
+           {
+             /* Try to create the directory and if succeeds use it.  */
+             if (NILP (internal_condition_case_1 (make_directory_wrapper,
+                                                  dir, Qt,
+                                                  make_directory_wrapper_1)))
+               {
+                 base_dir = dir;
+                 break;
+               }
+           }
+       }
       if (NILP (base_dir))
-       return Qnil;
+       error ("Cannot find suitable directory for output in "
+              "`comp-native-laod-path'.");
     }
 
   if (!file_name_absolute_p (SSDATA (base_dir)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]