view lisp/update-elc.el @ 938:0391335b65dc

[xemacs-hg @ 2002-07-31 07:14:49 by michaels] 2002-07-17 Marcus Crestani <crestani@informatik.uni-tuebingen.de> Markus Kaltenbach <makalten@informatik.uni-tuebingen.de> Mike Sperber <mike@xemacs.org> configure flag to turn these changes on: --use-kkcc First we added a dumpable flag to lrecord_implementation. It shows, if the object is dumpable and should be processed by the dumper. * lrecord.h (struct lrecord_implementation): added dumpable flag (MAKE_LRECORD_IMPLEMENTATION): fitted the different makro definitions to the new lrecord_implementation and their calls. Then we changed mark_object, that it no longer needs a mark method for those types that have pdump descritions. * alloc.c: (mark_object): If the object has a description, the new mark algorithm is called, and the object is marked according to its description. Otherwise it uses the mark method like before. These procedures mark objects according to their descriptions. They are modeled on the corresponding pdumper procedures. (mark_with_description): (get_indirect_count): (structure_size): (mark_struct_contents): These procedures still call mark_object, this is needed while there are Lisp_Objects without descriptions left. We added pdump descriptions for many Lisp_Objects: * extents.c: extent_auxiliary_description * database.c: database_description * gui.c: gui_item_description * scrollbar.c: scrollbar_instance_description * toolbar.c: toolbar_button_description * event-stream.c: command_builder_description * mule-charset.c: charset_description * device-msw.c: devmode_description * dialog-msw.c: mswindows_dialog_id_description * eldap.c: ldap_description * postgresql.c: pgconn_description pgresult_description * tooltalk.c: tooltalk_message_description tooltalk_pattern_description * ui-gtk.c: emacs_ffi_description emacs_gtk_object_description * events.c: * events.h: * event-stream.c: * event-Xt.c: * event-gtk.c: * event-tty.c: To write a pdump description for Lisp_Event, we converted every struct in the union event to a Lisp_Object. So we created nine new Lisp_Objects: Lisp_Key_Data, Lisp_Button_Data, Lisp_Motion_Data, Lisp_Process_Data, Lisp_Timeout_Data, Lisp_Eval_Data, Lisp_Misc_User_Data, Lisp_Magic_Data, Lisp_Magic_Eval_Data. We also wrote makro selectors and mutators for the fields of the new designed Lisp_Event and added everywhere these new abstractions. We implemented XD_UNION support in (mark_with_description), so we can describe exspecially console/device specific data with XD_UNION. To describe with XD_UNION, we added a field to these objects, which holds the variant type of the object. This field is initialized in the appendant constructor. The variant is an integer, it has also to be described in an description, if XD_UNION is used. XD_UNION is used in following descriptions: * console.c: console_description (get_console_variant): returns the variant (create_console): added variant initialization * console.h (console_variant): the different console types * console-impl.h (struct console): added enum console_variant contype * device.c: device_description (Fmake_device): added variant initialization * device-impl.h (struct device): added enum console_variant devtype * objects.c: image_instance_description font_instance_description (Fmake_color_instance): added variant initialization (Fmake_font_instance): added variant initialization * objects-impl.h (struct Lisp_Color_Instance): added color_instance_type * objects-impl.h (struct Lisp_Font_Instance): added font_instance_type * process.c: process_description (make_process_internal): added variant initialization * process.h (process_variant): the different process types
author michaels
date Wed, 31 Jul 2002 07:14:49 +0000
parents 11502791fc1c
children c08a6fa181d1
line wrap: on
line source

;;; update-elc.el --- Bytecompile out-of-date dumped files

;; Copyright (C) 1997 Free Software Foundation, Inc.
;; Copyright (C) 1996 Sun Microsystems, Inc.
;; Copyright (C) 2001 Ben Wing.

;; Author: Ben Wing <ben@xemacs.org>
;; Based On: Original by Steven L Baur <steve@xemacs.org>
;; Maintainer: XEmacs Development Team
;; Keywords: internal

;; This file is part of XEmacs.

;; XEmacs is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; XEmacs is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with XEmacs; see the file COPYING.  If not, write to the 
;; Free Software Foundation, 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Synched up with: Not in FSF.

;;; Commentary:

;; Byte compile the .EL files necessary to dump out xemacs.
;; Use this file like this:

;; temacs -batch -l ../lisp/update-elc.el $lisp

;; where $lisp comes from the Makefile.  .elc files listed in $lisp will
;; cause the corresponding .el file to be compiled.  .el files listed in
;; $lisp will be ignored.

;; (the idea here is that you can bootstrap if your .ELC files
;; are missing or badly out-of-date)

;; See also update-elc-2.el

;;; Code:

(defvar processed nil)
(defvar update-elc-files-to-compile nil)
(defvar need-to-rebuild-autoloads nil)
(defvar need-to-rebuild-mule-autoloads nil)
(defvar need-to-recompile-autoloads nil)
(defvar need-to-recompile-mule-autoloads nil)

;(setq update-elc-files-to-compile
;      (delq nil
;	    (mapcar (function
;		     (lambda (x)
;		       (if (string-match "\.elc$" x)
;			   (let ((src (substring x 0 -1)))
;			     (if (file-newer-than-file-p src x)
;				 (progn
;				   (and (file-exists-p x)
;					(null (file-writable-p x))
;					(set-file-modes x (logior (file-modes x) 128)))
;				   src))))))
;		    ;; -batch gets filtered out.
;		    (nthcdr 3 command-line-args))))

(let ((build-root (expand-file-name ".." invocation-directory)))
  (setq load-path (list (expand-file-name "lisp" build-root))))

(load "very-early-lisp" nil t)

(load "find-paths.el")
(load "packages.el")
(load "setup-paths.el")
(load "dump-paths.el")

(defun update-elc-chop-extension (file)
  (if (string-match "\\.elc?$" file)
      (substring file 0 (match-beginning 0))
    file))

;; we used to call packages-list-autoloads here, but it's false generality.
;; we need to handle each autoload file differently and there are only
;; two of them.

(let (preloaded-file-list site-load-packages need-to-dump dumped-exe
			  files-to-process)
  
  (load (expand-file-name "../lisp/dumped-lisp.el"))

  (setq dumped-exe
	(cond ((file-exists-p "../src/xemacs.exe") "../src/xemacs.exe")
	      ((file-exists-p "../src/xemacs") "../src/xemacs")
	      (t nil)))

  ;; Path setup
  (let ((package-preloaded-file-list
	 (packages-collect-package-dumped-lisps late-package-load-path)))
 
    (setq preloaded-file-list
 	  (append package-preloaded-file-list
 		  preloaded-file-list
 		  packages-hardcoded-lisp)))

  (load (concat default-directory "../site-packages") t t)
  (setq preloaded-file-list
	(append packages-hardcoded-lisp
		preloaded-file-list
		site-load-packages))
  ;; bytecomp, byte-optimize, and autoload are mentioned in
  ;; packages-useful-lisp.
  (setq files-to-process (append packages-useful-lisp preloaded-file-list))
  (while files-to-process
    (let* ((arg (car files-to-process))
	   (arg-is-preloaded (member arg preloaded-file-list))
	   (arg-sans-extension (update-elc-chop-extension arg))
	   (full-arg (locate-library arg-sans-extension))
	   (full-arg-sans-extension
	    (if (null full-arg)
		(progn
		  (print (format "Error: Library file %s not found" arg))
		  ;; Uncomment in case of trouble
		  ;;(print (format "late-packages: %S" late-packages))
                  ;;(print (format "guessed-roots: %S"
                  ;;               (paths-find-emacs-roots
                  ;;                invocation-directory invocation-name)))
		  (kill-emacs))
	      (update-elc-chop-extension full-arg)))
	   (full-arg-el (concat full-arg-sans-extension ".el"))
	   (full-arg-elc (concat full-arg-sans-extension ".elc"))
	   (full-arg-dir (file-name-directory full-arg-el))
	   (autoload-file (expand-file-name "auto-autoloads.el" full-arg-dir))
	   (autoload-is-mule (string-match "[/\\]mule[/\\]$" full-arg-dir)))
	   
      ;; (print full-arg-el)

      ;; now check if .el or .elc is newer than the dumped exe.
      ;; if so, need to redump.
      (when (and dumped-exe arg-is-preloaded
		 (or (and (file-exists-p full-arg-el)
			  (file-newer-than-file-p full-arg-el dumped-exe))
		     (and (file-exists-p full-arg-elc)
			  (file-newer-than-file-p full-arg-elc dumped-exe))))
	(setq need-to-dump t))

      (when (or (not (file-exists-p autoload-file))
		(and (file-exists-p full-arg-el)
		     (file-newer-than-file-p full-arg-el autoload-file)))
	(if autoload-is-mule
	    (setq need-to-rebuild-mule-autoloads t)
	  (setq need-to-rebuild-autoloads t)))

      (if (and (not (member (file-name-nondirectory arg)
			    packages-unbytecompiled-lisp))
	       (not (member full-arg-el processed))
	       (file-exists-p full-arg-el)
	       (or (not (file-exists-p full-arg-elc))
		   (file-newer-than-file-p full-arg-el full-arg-elc)))
	  (setq processed (cons full-arg-el processed)))

      (setq files-to-process (cdr files-to-process))))

  (if need-to-dump
      (condition-case nil
	  (write-region-internal "foo" nil "../src/NEEDTODUMP")
	(file-error nil)))

  )

(when (or need-to-rebuild-autoloads
	  (not (file-exists-p "../lisp/auto-autoloads.el"))
	  (not (file-exists-p "../lisp/auto-autoloads.elc"))
	  (file-newer-than-file-p "../lisp/auto-autoloads.el"
				  "../lisp/auto-autoloads.elc"))
  (setq need-to-recompile-autoloads t))

(when (or need-to-rebuild-mule-autoloads
	  (not (file-exists-p "../lisp/mule/auto-autoloads.el"))
	  (not (file-exists-p "../lisp/mule/auto-autoloads.elc"))
	  (file-newer-than-file-p "../lisp/mule/auto-autoloads.el"
				  "../lisp/mule/auto-autoloads.elc"))
  (setq need-to-recompile-mule-autoloads t))

(when (not (featurep 'mule))
  ;; sorry charlie.
  (setq need-to-rebuild-mule-autoloads nil
	need-to-recompile-mule-autoloads nil))

(setq update-elc-files-to-compile (append update-elc-files-to-compile
					  (nreverse processed)))

;; (print update-elc-files-to-compile)

(if (and (not update-elc-files-to-compile)
	 (not need-to-rebuild-autoloads)
	 (not need-to-rebuild-mule-autoloads)
	 (not need-to-recompile-autoloads)
	 (not need-to-recompile-mule-autoloads))
    (condition-case nil
	(delete-file "../src/NOBYTECOMPILE")
      (file-error nil))
  (let* (
	 (bytecomp-arg (concat (update-elc-chop-extension
				(locate-library "bytecomp")) ".el"))
	 (byte-opt-arg (concat (update-elc-chop-extension
				(locate-library "byte-optimize")) ".el"))
	 (autoload-arg (concat (update-elc-chop-extension
				(locate-library "autoload")) ".el"))
	 )
    (setq inhibit-autoloads t)
    (setq command-line-args
	  (append
	   '("-l" "loadup-el.el" "run-temacs" "-batch" "-q" "-no-site-file")
	   ;; if bytecomp or byte-optimize need recompiling, then load
	   ;; the .el version of them first, recompile them, and reload
	   ;; the .elc versions to recompile everything else (so we won't
	   ;; be waiting until the cows come home).  we need to set
	   ;; load-ignore-elc-files because byte-optimize gets autoloaded
	   ;; from bytecomp.
	   (if (or (member bytecomp-arg update-elc-files-to-compile)
		   (member byte-opt-arg update-elc-files-to-compile))
	       (append
		'("-eval" "(setq load-ignore-elc-files t)" "-l" "bytecomp")
		(if (member bytecomp-arg update-elc-files-to-compile)
		    (append '("-f" "batch-byte-compile-one-file")
			    (list bytecomp-arg)))
		(if (member byte-opt-arg update-elc-files-to-compile)
		    (append '("-f" "batch-byte-compile-one-file")
			    (list byte-opt-arg)))
		'("-eval" "(setq load-ignore-elc-files nil)")))
	   '("-l" "bytecomp")
	   ;; likewise, recompile autoload.el if out-of-date.
	   (if (member autoload-arg update-elc-files-to-compile)
	       (append '("-f" "batch-byte-compile-one-file")
		       (list autoload-arg)))
	   ;; then generate autoloads for lisp and maybe lisp/mule.
	   (if (or need-to-rebuild-autoloads
		   need-to-rebuild-mule-autoloads)
	       '("-l" "autoload"))
	   (if need-to-rebuild-autoloads
	       '("-f" "batch-force-update-one-directory" "../lisp"))
	   (if need-to-rebuild-mule-autoloads
	       '("-f" "batch-force-update-one-directory" "../lisp/mule"))
	   (if need-to-recompile-autoloads
	       '("-f" "batch-byte-compile-one-file"
		 "../lisp/auto-autoloads.el"))
	   (if need-to-recompile-mule-autoloads
	       '("-f" "batch-byte-compile-one-file"
		 "../lisp/mule/auto-autoloads.el"))
	   ;; now load the autoloads and compile alles anderes.
	   '("-eval" "(setq inhibit-autoloads nil)"
	     "-f" "startup-load-autoloads"
	     "-f" "batch-byte-compile")
	   (delete autoload-arg
		   (delete byte-opt-arg
			   (delete bytecomp-arg
				   update-elc-files-to-compile))))))
  (load "loadup-el.el"))

(kill-emacs)

;;; update-elc.el ends here