eaf 的安装除了仓库本身,还需要安装各种依赖,每个 app 需要的依赖都在仓库的 dependencies.json
里面写好了
striaght 支持 :post-build
,在 build 之后运行任意 elisp 或者 shell 命令,所以我们可以在 :post-build
里面安装依赖。
下面是我的配置代码,代码只针对我自己的配置,只能参考,不能够拷贝过去就用
(defun my-eaf-install-deps(app-dir)
"Install deps from dependencies.json."
(let* ((deps-dict (with-temp-buffer
(insert-file-contents (expand-file-name "dependencies.json" app-dir))
(json-parse-string (buffer-string))))
(pip-deps (gethash "win32" (or (gethash "pip" deps-dict) (make-hash-table))))
(vue-install (gethash "vue_install" deps-dict))
(npm-install (gethash "npm_install" deps-dict))
(npm-rebuild (gethash "npm_rebuild" deps-dict))
(npm-cmd (if (memq system-type '(cygwin windows-nt ms-dos)) "npm.cmd" "npm")))
(when pip-deps
(dolist (pkg (append pip-deps nil))
(message "%s" (shell-command-to-string (format "pip install %s" pkg)))))
(when vue-install
(let ((default-directory app-dir))
(message "%s" (shell-command-to-string (format "%s install" npm-cmd)))
(message "%s" (shell-command-to-string (format "%s run build" npm-cmd)))))
(when npm-install
(let ((default-directory app-dir))
(message "%s" (shell-command-to-string (format "%s install" npm-cmd)))))
(when npm-rebuild
(let ((default-directory app-dir))
(message "%s" (shell-command-to-string (format "%s rebuild" npm-cmd)))))))
(use-package eaf
:straight (eaf :type git :host github :repo "emacs-eaf/emacs-application-framework"
:files ("*")
:post-build ("python" "install-eaf.py" "--install-core-deps"))
:config
(when IS-WINDOWS
(setq eaf-python-command "D:\\Applications\\Scoop\\apps\\python\\current\\python.exe")
(setq eaf-wm-name "windows")))
(use-package eaf-demo
:after (eaf)
:straight (eaf-demo :type git :host github :repo "emacs-eaf/eaf-demo" :files ("*")))
(use-package eaf-browser
:after (eaf)
:straight (eaf-browser :type git :host github :repo "emacs-eaf/eaf-browser" :files ("*")
:post-build (my-eaf-install-deps (straight--build-dir "eaf-browser"))))
(use-package eaf-pdf-viewer
:after (eaf)
:straight (eaf-pdf-viewer :type git :host github :repo "emacs-eaf/eaf-pdf-viewer" :files ("*")
:post-build (my-eaf-install-deps (straight--build-dir "eaf-pdf-viewer"))))
(use-package eaf-markdown-previewer
:after (eaf)
:straight (eaf-markdown-previewer :type git :host github :repo "emacs-eaf/eaf-markdown-previewer" :files ("*")
:post-build (my-eaf-install-deps (straight--build-dir "eaf-markdown-previewer"))))