;; Determine which build number to use
;; based on the executables that now exist.
-(if (and (equal (last command-line-args) '("dump"))
- (fboundp 'dump-emacs)
+(if (and (or
+ (and (equal (last command-line-args) '("dump"))
+ (fboundp 'dump-emacs))
+ (and (equal (last command-line-args) '("pdump"))
+ (fboundp 'dump-emacs-portable)))
(not (eq system-type 'ms-dos)))
(let* ((base (concat "emacs-" emacs-version "."))
(exelen (if (eq system-type 'windows-nt) -4))
(substring name (length base) exelen))))
files)))
(setq emacs-repository-version (condition-case nil (emacs-repository-get-version)
- (error nil)))
+ (error nil)))
;; A constant, so we shouldn't change it with `setq'.
(defconst emacs-build-number
(if versions (1+ (apply 'max versions)) 1))))
(message "Finding pointers to doc strings...")
-(if (and (fboundp 'dump-emacs)
- (equal (last command-line-args) '("dump")))
+(if (and (or (and (fboundp 'dump-emacs)
+ (equal (last command-line-args) '("dump")))
+ (and (fboundp 'dump-emacs-portable)
+ (equal (last command-line-args) '("pdump")))))
(Snarf-documentation "DOC")
(condition-case nil
(Snarf-documentation "DOC")
(if (member dump-mode '("pdump" "pbootstrap"))
(dump-emacs-portable (expand-file-name output invocation-directory))
(dump-emacs output "temacs")
- (message "%d pure bytes used" pure-bytes-used)
- ;; Recompute NAME now, so that it isn't set when we dump.
- (if (not (or (eq system-type 'ms-dos)
- ;; Don't bother adding another name if we're just
- ;; building bootstrap-emacs.
- (equal dump-mode "bootstrap")))
- (let ((name (concat "emacs-" emacs-version))
- (exe (if (eq system-type 'windows-nt) ".exe" "")))
- (while (string-match "[^-+_.a-zA-Z0-9]+" name)
- (setq name (concat (downcase (substring name 0 (match-beginning 0)))
- "-"
- (substring name (match-end 0)))))
- (setq name (concat name exe))
- (message "Adding name %s" name)
- ;; When this runs on Windows, invocation-directory is not
- ;; necessarily the current directory.
- (add-name-to-file (expand-file-name (concat "emacs" exe)
+ (message "%d pure bytes used" pure-bytes-used))
+ ;; Recompute NAME now, so that it isn't set when we dump.
+ (if (not (or (eq system-type 'ms-dos)
+ ;; Don't bother adding another name if we're just
+ ;; building bootstrap-emacs.
+ (member dump-mode '("pbootstrap" "bootstrap"))))
+ (let ((name (format "emacs-%s.%d" emacs-version emacs-build-number))
+ (exe (if (eq system-type 'windows-nt) ".exe" "")))
+ (while (string-match "[^-+_.a-zA-Z0-9]+" name)
+ (setq name (concat (downcase (substring name 0 (match-beginning 0)))
+ "-"
+ (substring name (match-end 0)))))
+ (message "Adding name %s" (concat name exe))
+ ;; When this runs on Windows, invocation-directory is not
+ ;; necessarily the current directory.
+ (add-name-to-file (expand-file-name (concat "emacs" exe)
+ invocation-directory)
+ (expand-file-name (concat name exe)
+ invocation-directory)
+ t)
+ (when (equal dump-mode "pdump")
+ (message "Adding name %s" (concat name ".pdmp"))
+ (add-name-to-file (expand-file-name "emacs.pdmp"
+ invocation-directory)
+ (expand-file-name (concat name ".pdmp")
invocation-directory)
- (expand-file-name name invocation-directory)
t))))
(kill-emacs)))
/* Finally, look for "emacs.pdmp" in PATH_EXEC. We hardcode
"emacs" in "emacs.pdmp" so that the Emacs binary still works
- if the user copies and renames it. */
+ if the user copies and renames it.
+
+ FIXME: this doesn't work with emacs-XX.YY.ZZ.pdmp versioned files. */
argv0_base = "emacs";
- /* FIXME: On MS-Windows, PATH_EXEC starts with a literal
+ const char *path_exec = PATH_EXEC;
+#ifdef WINDOWSNT
+ /* On MS-Windows, PATH_EXEC normally starts with a literal
"%emacs_dir%", so it will never work without some tweaking. */
- dump_file = alloca (strlen (PATH_EXEC)
+ path_exec = w32_relocate (path_exec);
+#endif
+ dump_file = alloca (strlen (path_exec)
+ 1
+ strlen (argv0_base)
+ strlen (suffix)
+ 1);
sprintf (dump_file, "%s%c%s%s",
- PATH_EXEC, DIRECTORY_SEP, argv0_base, suffix);
+ path_exec, DIRECTORY_SEP, argv0_base, suffix);
result = pdumper_load (dump_file);
if (result != PDUMPER_LOAD_SUCCESS)
dump_file = NULL;
double tdif =
1000.0 * (end.tv_sec - start.tv_sec)
+ (end.tv_usec - start.tv_usec) / 1.0e3;
- fprintf (stderr, "load_dump completed in %g milliseconds\n", tdif);
+ fprintf (stderr, "load_dump %s %g milliseconds\n",
+ loaded_dump ? "completed in" : "failed after", tdif);
#endif
}
}
}
+/* Relocate a directory specified by epaths.h, using the location of
+ our binary as an anchor. Note: this runs early during startup, so
+ we cannot rely on the usual file-related facilities, and in
+ particular the argument is assumed to be a unibyte string in system
+ codepage encoding. */
+const char *
+w32_relocate (const char *epath_dir)
+{
+ if (strncmp (epath_dir, "%emacs_dir%/", 12) == 0)
+ {
+ static char relocated_dir[MAX_PATH];
+
+ /* Replace "%emacs_dir%" with the parent of the directory where
+ our binary lives. Note that init_environment was not yet
+ called, so we cannot rely on emacs_dir being set in the
+ environment. */
+ if (GetModuleFileNameA (NULL, relocated_dir, MAX_PATH))
+ {
+ char *p = _mbsrchr (relocated_dir, '\\');
+
+ if (p)
+ {
+ *p = '\0';
+ if ((p = _mbsrchr (relocated_dir, '\\')) != NULL)
+ {
+ strcpy (p, epath_dir + 11);
+ epath_dir = relocated_dir;
+ }
+ }
+ }
+ }
+ return epath_dir;
+}
+
/*
globals_of_w32 is used to initialize those global variables that
must always be initialized on startup even when the global variable