diff options
| author | Andrea Corallo | 2020-10-07 23:38:00 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2020-10-07 23:38:00 +0200 |
| commit | c3bc348f5edefa4231d38b6d3967f0c8f0bb5e6d (patch) | |
| tree | 9a757a9ebbf08f165ff811d022a49985fe0fb57d | |
| parent | 7041c32ec2cd985f1c324c75ecea8038f998a792 (diff) | |
| download | emacs-c3bc348f5edefa4231d38b6d3967f0c8f0bb5e6d.tar.gz emacs-c3bc348f5edefa4231d38b6d3967f0c8f0bb5e6d.zip | |
* 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.
| -rw-r--r-- | src/comp.c | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/src/comp.c b/src/comp.c index ba4089e5aeb..1b96bffeb87 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -4013,6 +4013,19 @@ compile_function (Lisp_Object func) | |||
| 4013 | /* In use by Fcomp_el_to_eln_filename. */ | 4013 | /* In use by Fcomp_el_to_eln_filename. */ |
| 4014 | static Lisp_Object loadsearch_re_list; | 4014 | static Lisp_Object loadsearch_re_list; |
| 4015 | 4015 | ||
| 4016 | static Lisp_Object | ||
| 4017 | make_directory_wrapper (Lisp_Object directory) | ||
| 4018 | { | ||
| 4019 | CALL2I (make-directory, directory, Qt); | ||
| 4020 | return Qnil; | ||
| 4021 | } | ||
| 4022 | |||
| 4023 | static Lisp_Object | ||
| 4024 | make_directory_wrapper_1 (Lisp_Object ignore) | ||
| 4025 | { | ||
| 4026 | return Qt; | ||
| 4027 | } | ||
| 4028 | |||
| 4016 | DEFUN ("comp-el-to-eln-filename", Fcomp_el_to_eln_filename, | 4029 | DEFUN ("comp-el-to-eln-filename", Fcomp_el_to_eln_filename, |
| 4017 | Scomp_el_to_eln_filename, 1, 2, 0, | 4030 | Scomp_el_to_eln_filename, 1, 2, 0, |
| 4018 | doc: /* Given a source FILENAME return the corresponding .eln filename. | 4031 | 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'. */) | |||
| 4087 | { | 4100 | { |
| 4088 | Lisp_Object eln_load_paths = Vcomp_eln_load_path; | 4101 | Lisp_Object eln_load_paths = Vcomp_eln_load_path; |
| 4089 | FOR_EACH_TAIL (eln_load_paths) | 4102 | FOR_EACH_TAIL (eln_load_paths) |
| 4090 | if (!NILP (Ffile_writable_p (XCAR (eln_load_paths)))) | 4103 | { |
| 4091 | { | 4104 | Lisp_Object dir = XCAR (eln_load_paths); |
| 4092 | base_dir = XCAR (eln_load_paths); | 4105 | if (!NILP (Ffile_exists_p (dir))) |
| 4093 | break; | 4106 | { |
| 4094 | } | 4107 | if (!NILP (Ffile_writable_p (dir))) |
| 4095 | /* If we can't find it return Nil. */ | 4108 | { |
| 4109 | base_dir = dir; | ||
| 4110 | break; | ||
| 4111 | } | ||
| 4112 | } | ||
| 4113 | else | ||
| 4114 | { | ||
| 4115 | /* Try to create the directory and if succeeds use it. */ | ||
| 4116 | if (NILP (internal_condition_case_1 (make_directory_wrapper, | ||
| 4117 | dir, Qt, | ||
| 4118 | make_directory_wrapper_1))) | ||
| 4119 | { | ||
| 4120 | base_dir = dir; | ||
| 4121 | break; | ||
| 4122 | } | ||
| 4123 | } | ||
| 4124 | } | ||
| 4096 | if (NILP (base_dir)) | 4125 | if (NILP (base_dir)) |
| 4097 | return Qnil; | 4126 | error ("Cannot find suitable directory for output in " |
| 4127 | "`comp-native-laod-path'."); | ||
| 4098 | } | 4128 | } |
| 4099 | 4129 | ||
| 4100 | if (!file_name_absolute_p (SSDATA (base_dir))) | 4130 | if (!file_name_absolute_p (SSDATA (base_dir))) |