summaryrefslogtreecommitdiff
blob: 9a86046be9929764860d7e38967fcddd78b8a366 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
--- a/lisp/update-elc-2.el.orig	2022-06-16 21:58:48.748641021 +0200
+++ b/lisp/update-elc-2.el	2022-06-16 21:58:48.748641021 +0200
@@ -137,37 +137,10 @@
   (let ((dir (car command-line-args-left)))
     ;; don't depend on being able to autoload `update-autoload-files'!
     (load "autoload")
-    (autoload 'cl-compile-time-init "cl-macs")
     (load "bytecomp")
     (load "byte-optimize")
-    ;; #### the API used here is deprecated, convert to one with explicit
-    ;; arguments when it is available
-    ;; update-elc.el signals us to rebuild the autoloads when necessary.
-    ;; in some cases it will rebuild the autoloads itself, but doing it this
-    ;; way is slow, so we avoid it when possible.
-    (when (file-exists-p (expand-file-name "REBUILD_AUTOLOADS"
-					   invocation-directory))
-      ;; if we were instructed to rebuild the autoloads, force the file
-      ;; to be touched even w/o changes; otherwise, we won't ever stop
-      ;; being told to rebuild them.
-      (update-autoload-files dir "auto" nil t)
-      (byte-recompile-file (expand-file-name "auto-autoloads.el" dir) 0)
-      (when (featurep 'mule)
-	(let ((muledir (expand-file-name "../lisp/mule" (file-truename dir))))
-	  ;; force here just like above.
-	  (update-autoload-files muledir "mule" nil t)
-	  (byte-recompile-file (expand-file-name "auto-autoloads.el" dir) 0))))
-    (when (featurep 'modules)
-      (let* ((moddir (expand-file-name "../modules" (file-truename dir)))
-	     (autofile (expand-file-name "auto-autoloads.el" moddir)))
-	(update-autoload-files 
-	 (delete (concat (file-name-as-directory moddir) ".")
-		 (delete (concat (file-name-as-directory moddir) "..")
-			 (directory-files moddir t nil nil 0)))
-	 "modules" autofile)
-	(byte-recompile-file autofile 0)))
-    ;; now load the (perhaps newly rebuilt) autoloads; we were called with
-    ;; -no-autoloads so they're not already loaded.
+    ;; now load the autoloads; we were called with -no-autoloads so they're not
+    ;; already loaded.
     (load (expand-file-name "auto-autoloads" lisp-directory))
     (when (featurep 'mule)
       (load (expand-file-name "mule/auto-autoloads" lisp-directory)))
@@ -175,6 +148,8 @@
     ;; there may be dependencies between one .el and another (even across
     ;; directories), and we don't want to load an out-of-date .elc while
     ;; byte-compiling a file.
+    (when (featurep 'modules)
+      (load (expand-file-name "auto-autoloads" module-directory)))
     (message "Removing old or spurious .elcs in directory tree `%s'..." dir)
     (do-update-elc-2 dir nil nil)
     (message "Removing old or spurious .elcs in directory tree `%s'...done"
--- a/lisp/update-elc.el.orig	2022-06-16 21:58:48.748641021 +0200
+++ b/lisp/update-elc.el	2022-06-16 21:58:48.748641021 +0200
@@ -54,8 +54,11 @@
 (defvar update-elc-files-to-compile nil)
 (defvar need-to-rebuild-autoloads nil)
 (defvar need-to-rebuild-mule-autoloads nil)
+(defvar need-to-rebuild-module-autoloads nil)
 (defvar need-to-recompile-autoloads nil)
 (defvar need-to-recompile-mule-autoloads nil)
+(defvar need-to-recompile-module-autoloads nil)
+
 (defvar exe-target nil)
 (defvar dump-target nil)
 (defvar dump-target-out-of-date-wrt-dump-files nil)
@@ -84,10 +87,14 @@
 
 (defvar source-lisp-mule (expand-file-name "mule" source-lisp))
 (defvar source-directory (expand-file-name ".." source-lisp))
+(defconst module-directory (expand-file-name "modules" source-directory))
+
 (defvar aa-lisp (expand-file-name "auto-autoloads.el" source-lisp))
 (defvar aac-lisp (expand-file-name "auto-autoloads.elc" source-lisp))
 (defvar aa-lisp-mule (expand-file-name "auto-autoloads.el" source-lisp-mule))
 (defvar aac-lisp-mule (expand-file-name "auto-autoloads.elc" source-lisp-mule))
+(defvar aa-modules (expand-file-name "auto-autoloads.el" module-directory))
+(defvar aac-modules (expand-file-name "auto-autoloads.elc" module-directory))
 
 (setq load-path (list source-lisp))
 
@@ -130,7 +137,8 @@
 
 (defvar lisp-files-ignored-when-checking-for-autoload-updating
   '("custom-load.el"
-    "auto-autoloads.el")
+    "auto-autoloads.el"
+    "finder-inf.el")
   "Lisp files that should not trigger auto-autoloads rebuilding.")
 
 (defun update-elc-chop-extension (file)
@@ -270,6 +278,18 @@
 	  (setq all-files-in-dir (cdr all-files-in-dir))))
       (setq dirs-to-check (cdr dirs-to-check))))
 
+  ;; Check for the module autoloads separately, given the need to run
+  ;; directory-files on subdirectories.
+  (let ((autoload-file
+        (expand-file-name "auto-autoloads.el" module-directory)))
+    (mapc
+     #'(lambda (full-dir)
+        (mapc #'(lambda (full-arg)
+                  (when (file-newer-than-file-p full-arg autoload-file)
+                    (setq need-to-rebuild-module-autoloads t)))
+              (directory-files full-dir t "\\.c$" nil t)))
+     (directory-files module-directory t nil t 'subdirs)))
+
   (if dump-target-out-of-date-wrt-dump-files
       (condition-case nil
 	  (write-region-internal
@@ -297,6 +317,14 @@
 	  (file-newer-than-file-p aa-lisp-mule aac-lisp-mule))
   (setq need-to-recompile-mule-autoloads t))
 
+(when (or need-to-rebuild-module-autoloads
+         ;; not necessary but ...  see comment above.
+         (eq (file-exists-p aa-modules) nil)
+         ;; no need to check for file-exists of .elc due to definition
+         ;; of file-newer-than-file-p
+         (file-newer-than-file-p aa-modules aac-modules))
+  (setq need-to-recompile-module-autoloads t))
+
 (when (not (featurep 'mule))
   ;; sorry charlie.
   (setq need-to-rebuild-mule-autoloads nil
@@ -318,15 +346,18 @@
 	(if need-to-rebuild-mule-autoloads
 	    (list "-f" "batch-update-directory-autoloads"
 		  "mule" source-lisp-mule))
+        (if need-to-rebuild-module-autoloads
+            (list "-f" "batch-update-directory-autoloads"
+                  "auto" module-directory))
 	(if need-to-recompile-autoloads
 	    (list "-f" "batch-byte-compile-one-file"
 		  aa-lisp))
 	(if need-to-recompile-mule-autoloads
 	    (list "-f" "batch-byte-compile-one-file"
-		  aa-lisp-mule)))))
-  (condition-case nil
-      (delete-file (expand-file-name "src/REBUILD_AUTOLOADS" build-directory))
-    (file-error nil))
+                  aa-lisp-mule))
+        (if need-to-recompile-module-autoloads
+            (list "-f" "batch-byte-compile-one-file"
+                  aa-modules)))))
   (cond ((and (not update-elc-files-to-compile)
 	      (not need-to-rebuild-autoloads)
 	      (not need-to-rebuild-mule-autoloads)
@@ -335,17 +366,25 @@
 	 ;; (1) Nothing to do at all.
 	 )
 	((not update-elc-files-to-compile)
-	 ;; (2) We have no files to byte-compile, but we do need to
-	 ;;     regenerate and compile the auto-autoloads file, so signal
-	 ;;     update-elc-2 to do it.  This is much faster than loading
-	 ;;     all the .el's and doing it here. (We only need to rebuild
-	 ;;     the autoloads here when we have files to compile, since
-	 ;;     they may depend on the updated autoloads.)
-	 (condition-case nil
-	     (write-region-internal
-	      "foo" nil (expand-file-name "src/REBUILD_AUTOLOADS" build-directory))
-	   (file-error nil))
-	 )
+         ;; (2) We have no files to byte-compile, but we do need to regenerate
+         ;;     and compile the auto-autoloads file. Don't pass this on to
+         ;;     update-elc-2.el to do, since that gives dependency problems
+         ;;     with parallel builds (make -j and friends). Completely fine to
+         ;;     use the compiled Lisp infrastructure for this, though, since we
+         ;;     know it's up to date.
+         (setq command-line-args
+               (append
+                '("-l" "loadup-el.el" "run-temacs"
+                  "-batch" "-no-packages" "-no-autoloads"
+                  "-eval" "(setq stack-trace-on-error t)"
+                  "-eval" "(setq load-always-display-messages t)"
+                  "-l" "bytecomp.elc" "-l" "autoload.elc")
+                do-autoload-commands))
+         (write-sequence "\nNeed to regenerate auto-autoload files... "
+                         'external-debugging-output)
+         (let ((load-ignore-elc-files nil)
+               (purify-flag nil))
+           (load "loadup.el")))
 	(t
 	 (let ((bc-bootstrap
 		(mapcar #'(lambda (arg)