[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/android 84d27fe53b2 1/2: Save build timestamps in Android builds
From: |
Po Lu |
Subject: |
feature/android 84d27fe53b2 1/2: Save build timestamps in Android builds |
Date: |
Tue, 7 Mar 2023 07:18:38 -0500 (EST) |
branch: feature/android
commit 84d27fe53b2888b6668ba8510f377eb0eabeeb09
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Save build timestamps in Android builds
* java/Makefile.in (install_temp/assets/build_info): New
rule.:(emacs.apk-in): Depend on that file.
* lisp/version.el (android-read-build-system)
(android-read-build-time): New functions.
(emacs-build-system, emacs-build-time): Use those functions on
Android, as dumping is done after installation on Android.
* src/fileio.c (Finsert_file_contents):
* src/window.c (replace_buffer_in_windows): Don't call functions
if they are not defined, which can happen during loadup.
---
java/Makefile.in | 6 +++++-
lisp/version.el | 34 ++++++++++++++++++++++++++++++++--
src/fileio.c | 6 ++++--
src/window.c | 5 ++++-
4 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/java/Makefile.in b/java/Makefile.in
index c7fe6e07c77..1a7852487ef 100644
--- a/java/Makefile.in
+++ b/java/Makefile.in
@@ -222,8 +222,12 @@ install_temp/assets/version: install_temp
&& (git rev-parse --abbrev-ref HEAD \
|| echo "Unknown") } 2> /dev/null > $@
+install_temp/assets/build_info: install_temp
+ $(AM_V_GEN) { hostname; date +%s; } > $@
+
emacs.apk-in: install_temp install_temp/assets/directory-tree \
- install_temp/assets/version AndroidManifest.xml
+ install_temp/assets/version install_temp/assets/build_info \
+ AndroidManifest.xml
# Package everything. Specifying the assets on this command line is
# necessary for AAssetManager_getNextFileName to work on old versions
# of Android. Make sure not to generate R.java, as it's already been
diff --git a/lisp/version.el b/lisp/version.el
index 38a9f9c2be5..ca61f8cfeee 100644
--- a/lisp/version.el
+++ b/lisp/version.el
@@ -26,6 +26,31 @@
;;; Code:
+
+
+(defun android-read-build-system ()
+ "Obtain the host name of the system on which Emacs was built.
+Use the data stored in the special file `/assets/build_info'.
+Value is the string ``Unknown'' upon failure, else the hostname
+of the build system."
+ (with-temp-buffer
+ (insert-file-contents "/assets/build_info")
+ (let ((string (buffer-substring 1 (line-end-position))))
+ (and (not (equal string "Unknown")) string))))
+
+(defun android-read-build-time ()
+ "Obtain the time at which Emacs was built.
+Use the data stored in the special file `/assets/build_info'.
+Value is nil upon failure, else the time in the same format as
+returned by `current-time'."
+ (with-temp-buffer
+ (insert-file-contents "/assets/build_info")
+ (end-of-line)
+ (let ((number (read (current-buffer))))
+ (time-convert number 'list))))
+
+
+
(defconst emacs-major-version
(progn (string-match "^[0-9]+" emacs-version)
(string-to-number (match-string 0 emacs-version)))
@@ -36,10 +61,15 @@
(string-to-number (match-string 1 emacs-version)))
"Minor version number of this version of Emacs.")
-(defconst emacs-build-system (system-name)
+(defconst emacs-build-system (or (and (eq system-type 'android)
+ (android-read-build-system))
+ (system-name))
"Name of the system on which Emacs was built, or nil if not available.")
-(defconst emacs-build-time (if emacs-build-system (current-time))
+(defconst emacs-build-time (if emacs-build-system
+ (or (and (eq system-type 'android)
+ (android-read-build-time))
+ (current-time)))
"Time at which Emacs was dumped out, or nil if not available.")
(defconst emacs-build-number 1 ; loadup.el may increment this
diff --git a/src/fileio.c b/src/fileio.c
index ae244b8f85a..88582704d7e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4991,8 +4991,10 @@ by calling `format-decode', which see. */)
}
}
- /* Decode file format. */
- if (inserted > 0)
+ /* Decode file format. Don't do this if Qformat_decode is not
+ bound, which can happen when called early during loadup. */
+
+ if (inserted > 0 && !NILP (Fboundp (Qformat_decode)))
{
/* Don't run point motion or modification hooks when decoding. */
specpdl_ref count1 = SPECPDL_INDEX ();
diff --git a/src/window.c b/src/window.c
index f4e09f49eae..9a29ecb8807 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3514,7 +3514,10 @@ window-start value is reasonable when this function is
called. */)
void
replace_buffer_in_windows (Lisp_Object buffer)
{
- call1 (Qreplace_buffer_in_windows, buffer);
+ /* When kill-buffer is called early during loadup, this function is
+ undefined. */
+ if (!NILP (Fboundp (Qreplace_buffer_in_windows)))
+ call1 (Qreplace_buffer_in_windows, buffer);
}
/* If BUFFER is shown in a window, safely replace it with some other