diff --git a/ebox-native-reflow.el b/ebox-native-reflow.el index 0dcb1cf..34a0e9a 100644 --- a/ebox-native-reflow.el +++ b/ebox-native-reflow.el @@ -948,8 +948,7 @@ next Emacs start." (plist-get issue :message)))))) (display-buffer buffer))) -;;;###autoload -(defun ebox-native-build (&optional clean) +(defun ebox-native-reflow--build (&optional clean) "Compile and install the bundled native module asynchronously. The command always runs the shared environment checks first and requires a Rust/Cargo toolchain native to the current Emacs architecture. With prefix @@ -1018,15 +1017,15 @@ Build output and exact errors appear in `*Ebox Native Build*'." (error-message-string err))))))) (defun ebox-native-reflow--clean-build () - "Run `ebox-native-build' after clearing Ebox's private Cargo cache." + "Run a native build after clearing Ebox's private Cargo cache." (interactive) - (ebox-native-build t)) + (ebox-native-reflow--build t)) (defvar ebox-native-status-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map special-mode-map) - (define-key map (kbd "g") #'ebox-native-status) - (define-key map (kbd "b") #'ebox-native-build) + (define-key map (kbd "g") #'ebox-native-reflow--status) + (define-key map (kbd "b") #'ebox-native-reflow--build) (define-key map (kbd "B") #'ebox-native-reflow--clean-build) map) "Keymap for `ebox-native-status-mode'.") @@ -1142,8 +1141,7 @@ Build output and exact errors appear in `*Ebox Native Build*'." (insert (concat "Keys: g refresh status, b build/rebuild, " "B clean rebuild, q quit.\n")))) -;;;###autoload -(defun ebox-native-status () +(defun ebox-native-reflow--status () "Display native toolchain, installation, and runtime loading status." (interactive) (unless ebox-native-reflow--load-attempted-p diff --git a/ebox.el b/ebox.el index ce4fbe4..2950d25 100644 --- a/ebox.el +++ b/ebox.el @@ -65,11 +65,10 @@ "ebox-incremental" (buffer report)) (declare-function ebox--scroll-rendered-content-lines "ebox-layout" (box lines region-id &optional start-index)) +(declare-function ebox-native-reflow--build + "ebox-native-reflow" (&optional clean)) +(declare-function ebox-native-reflow--status "ebox-native-reflow" ()) -(unless (fboundp 'ebox-native-build) - (autoload 'ebox-native-build "ebox-native-reflow" nil t)) -(unless (fboundp 'ebox-native-status) - (autoload 'ebox-native-status "ebox-native-reflow" nil t)) (defalias 'ebox-select-all #'ebox-selector-query-buffer) (defalias 'ebox-update-selector #'ebox-selector-update-buffer) @@ -78,6 +77,21 @@ :group 'applications :prefix "ebox-") +;;;###autoload +(defun ebox-native-build (&optional clean) + "Build and install Ebox's optional native module asynchronously. +With prefix argument CLEAN, clear only Ebox's private Cargo build cache first." + (interactive "P") + (require 'ebox-native-reflow) + (ebox-native-reflow--build clean)) + +;;;###autoload +(defun ebox-native-status () + "Display Ebox native toolchain, installation, and runtime status." + (interactive) + (require 'ebox-native-reflow) + (ebox-native-reflow--status)) + ;;;###autoload (defun ebox-byte-compile () "Recompile every active Ebox Lisp source into a neighboring `.elc' file. diff --git a/tests/ebox-package-tests.el b/tests/ebox-package-tests.el index 61a01ec..fce1cbe 100644 --- a/tests/ebox-package-tests.el +++ b/tests/ebox-package-tests.el @@ -19,8 +19,7 @@ "ebox-grid.el" "ebox-canonical.el" "ebox-buffer-backend.el" - "ebox-selector.el" - "ebox-native-reflow.el") + "ebox-selector.el") "Source files that currently own public autoload entry points.") (defun ebox-test--source-text () @@ -81,13 +80,42 @@ "(unless (ebox-text-node-p (ebox-text-create :value \"A\")) " " (error \"Typed Text autoload failed\")))"))))))) -(ert-deftest ebox-facade-exposes-native-workflow-without-loading-it () - "The two native commands should be available without native load work." +(ert-deftest ebox-facade-defines-native-workflow-without-loading-it () + "The facade should define native commands without loading the subsystem." (require 'ebox) - (should (autoloadp (symbol-function 'ebox-native-build))) - (should (autoloadp (symbol-function 'ebox-native-status))) + (should (commandp 'ebox-native-build)) + (should (commandp 'ebox-native-status)) + (should-not (autoloadp (symbol-function 'ebox-native-build))) + (should-not (autoloadp (symbol-function 'ebox-native-status))) (should-not (featurep 'ebox-native-reflow))) +(ert-deftest ebox-native-command-autoloads-may-target-the-facade () + "Startup registries may safely autoload native commands from `ebox'." + (let* ((emacs (expand-file-name invocation-name invocation-directory)) + (parent (file-name-directory (directory-file-name ebox-test--root))) + (ecss (expand-file-name "ecss" parent)) + (tp (expand-file-name "tp" parent))) + (with-temp-buffer + (should + (zerop + (process-file + emacs nil (current-buffer) nil + "-Q" "--batch" + "-L" ebox-test--root "-L" ecss "-L" tp + "--eval" "(setq load-prefer-newer t)" + "--eval" + (concat + "(progn " + "(autoload 'ebox-native-status \"ebox\" nil t) " + "(autoload 'ebox-native-build \"ebox\" nil t) " + "(autoload-do-load (symbol-function 'ebox-native-status) " + " 'ebox-native-status) " + "(unless (and (commandp 'ebox-native-status) " + " (commandp 'ebox-native-build)) " + " (error \"Facade did not define native commands\")) " + "(when (featurep 'ebox-native-reflow) " + " (error \"Facade autoload eagerly loaded native subsystem\")))"))))))) + (ert-deftest ebox-byte-compile-is-an-interactive-public-command () "Users should be able to rebuild all active Ebox bytecode from Emacs." (should (commandp 'ebox-byte-compile))