Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ob-glsl.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
;;; ob-glsl.el --- description pending -*- lexical-binding: t; -*-

(defcustom ob-glsl-make-command "cmake -G \"Ninja\" . && ninja"
"build command used when compiling ob-glsl"
:type 'string
:group 'ob-glsl)

(require 'ob)

;; setup
(defun ob-glsl-compile ()
(let ((default-directory (file-name-directory load-file-name)))
(shell-command ob-glsl-make-command)
(load-file
(concat default-directory
(car (directory-files default-directory nil "^ob-glsl-module\\.\\(so\\|dll\\|dylib\\)$"))))
))
(when (not (featurep 'ob-glsl-module))
(ob-glsl-compile))
Comment on lines +18 to +19
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: does this mean this code will always attempt to compile if the module is not yet loaded, even when it's already compiled and available?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in order to minimize the loading latency, we would only want to run the compilation when the dynamic module is not available (or better, check if it is out of date).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points here. Are there any well established references for automatically compiling modules? Vterm detects when its module is out of date (I haven't looked into the implementation), but doesn't do so automatically.

If lazy loading is done properly, then this may be enough. It'd help with debugging problems in compilation (eg a dependency isn't installed).

I don't know of any emacs packages with modules that automatically compile on install/load, but I haven't exactly looked too much.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: does this mean this code will always attempt to compile if the module is not yet loaded, even when it's already compiled and available?

Yes.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just perform a quick check of the existence of the dynamic module, or just attempt to load it, and only run the compilation when the file does not already exist or failed to load?


(require 'ob-glsl-module)

(defvar org-babel-default-header-args:glsl
Expand Down Expand Up @@ -37,3 +56,4 @@ This function is called by `org-babel-execute-src-block'."
(error "glsl does not support sessions"))

(provide 'ob-glsl)
;;; ob-glsl.el ends here