Add :requires prop to def-bootstrap! & refactor+rewrite bootstrapping
This commit is contained in:
parent
71dbf605ae
commit
72698ca9e8
9 changed files with 84 additions and 55 deletions
|
@ -244,16 +244,36 @@ executed when called with `set!'. FORMS are not evaluated until `set!' calls it.
|
||||||
(defmacro def-bootstrap! (name &rest forms)
|
(defmacro def-bootstrap! (name &rest forms)
|
||||||
"TODO"
|
"TODO"
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
`(push (cons ',name
|
(let ((prereqs (plist-get forms :requires)))
|
||||||
(lambda ()
|
(while (keywordp (car forms))
|
||||||
(cl-flet ((sh (lambda (&rest args) (apply 'doom-sh args)))
|
(dotimes (i 2) (pop forms)))
|
||||||
(sudo (lambda (&rest args) (apply 'doom-sudo args)))
|
`(push (cons ',name
|
||||||
(fetch (lambda (&rest args) (apply 'doom-fetch args)))
|
(lambda ()
|
||||||
(message (lambda (&rest args)
|
(cl-flet ((sh (lambda (&rest args) (apply 'doom-sh args)))
|
||||||
(apply 'message (format "[%s] %s" ,(symbol-name name) (car args))
|
(sudo (lambda (&rest args) (apply 'doom-sudo args)))
|
||||||
(cdr args)))))
|
(fetch (lambda (&rest args) (apply 'doom-fetch args)))
|
||||||
,@forms)))
|
(message (lambda (&rest args)
|
||||||
doom-bootstraps))
|
(apply 'message (format "[%s] %s" ,(symbol-name name) (car args))
|
||||||
|
(cdr args)))))
|
||||||
|
(if (not ,(if (not prereqs)
|
||||||
|
't
|
||||||
|
(unless (listp prereqs)
|
||||||
|
(setq prereqs (list prereqs)))
|
||||||
|
`(and ,@(mapcar (lambda (sym) `(doom-bootstrap ',sym)) prereqs))))
|
||||||
|
(message "Aborting (prerequisites failed)")
|
||||||
|
(message "Bootstrapping")
|
||||||
|
,@forms
|
||||||
|
(message "Done")))))
|
||||||
|
doom-bootstraps)))
|
||||||
|
|
||||||
|
(defun doom-bootstrap (id)
|
||||||
|
(when-let (bootstrap (assq id doom-bootstraps))
|
||||||
|
(condition-case ex
|
||||||
|
(progn (funcall (cdr bootstrap)) t)
|
||||||
|
('error
|
||||||
|
(message "[%s] Aborted (ERROR: %s)"
|
||||||
|
id (if (eq (car ex) 'error) (cadr ex) ex))
|
||||||
|
nil))))
|
||||||
|
|
||||||
(defun doom/bootstrap (ids)
|
(defun doom/bootstrap (ids)
|
||||||
"Bootstraps a module, if it has a bootstrapper. Bootstraps are expected to be
|
"Bootstraps a module, if it has a bootstrapper. Bootstraps are expected to be
|
||||||
|
@ -275,12 +295,7 @@ using `doom-fetch'."
|
||||||
(and err-not-func
|
(and err-not-func
|
||||||
(message "ERROR: These bootstraps were invalid: %s" err-not-func)))
|
(message "ERROR: These bootstraps were invalid: %s" err-not-func)))
|
||||||
(error "There were errors. Aborting."))
|
(error "There were errors. Aborting."))
|
||||||
(dolist (id ids)
|
(mapc 'doom-bootstrap ids)))
|
||||||
(let ((bootstrap (assq id doom-bootstraps)))
|
|
||||||
(message "[%s] BOOTSTRAP START" id)
|
|
||||||
(with-demoted-errors (format "[%s] ERROR: %%s" id)
|
|
||||||
(message "[%s] %s"
|
|
||||||
id (if (funcall (cdr bootstrap)) "SKIPPED (nothing to do)" "DONE")))))))
|
|
||||||
|
|
||||||
(provide 'core-lib)
|
(provide 'core-lib)
|
||||||
;;; core-lib.el ends here
|
;;; core-lib.el ends here
|
||||||
|
|
|
@ -56,5 +56,4 @@
|
||||||
(when IS-MAC
|
(when IS-MAC
|
||||||
(sh (format "install_name_tool -change @rpath/libclang.dylib %s %s"
|
(sh (format "install_name_tool -change @rpath/libclang.dylib %s %s"
|
||||||
"/usr/local/opt/llvm/lib/libclang.dylib"
|
"/usr/local/opt/llvm/lib/libclang.dylib"
|
||||||
(expand-file-name "bin/irony-server" irony-server-install-prefix)))))
|
(expand-file-name "bin/irony-server" irony-server-install-prefix)))))))
|
||||||
t))
|
|
||||||
|
|
|
@ -32,5 +32,4 @@
|
||||||
'("github.com/nsf/gocode"
|
'("github.com/nsf/gocode"
|
||||||
"github.com/motemen/gore"
|
"github.com/motemen/gore"
|
||||||
"golang.org/x/tools/cmd/guru"
|
"golang.org/x/tools/cmd/guru"
|
||||||
"golang.org/x/tools/cmd/gorename"))
|
"golang.org/x/tools/cmd/gorename"))))
|
||||||
(or changed (not gobin))))
|
|
||||||
|
|
|
@ -17,25 +17,27 @@
|
||||||
(package! xref-js2))
|
(package! xref-js2))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
(def-bootstrap! nodejs
|
||||||
|
(pcase (doom-system-os)
|
||||||
|
('arch
|
||||||
|
(let (progs)
|
||||||
|
(unless (executable-find "node") (push "nodejs" progs))
|
||||||
|
(unless (executable-find "npm") (push "npm" progs))
|
||||||
|
(when progs
|
||||||
|
(sudo "pacman --noconfirm -S %s" progs))))
|
||||||
|
('debian) ;; TODO
|
||||||
|
('macos
|
||||||
|
(unless (executable-find "node")
|
||||||
|
(sh "brew install node"))))
|
||||||
|
;; return success
|
||||||
|
(unless (cl-every 'executable-find '("node" "npm"))
|
||||||
|
(error "Something went wrong installing NodeJS")))
|
||||||
|
|
||||||
(def-bootstrap! javascript
|
(def-bootstrap! javascript
|
||||||
(unless (cl-every 'executable-find '("node" "npm" "tern" "js-beautify" "eslint"))
|
:requires nodejs
|
||||||
(pcase (doom-system-os)
|
(unless (executable-find "tern")
|
||||||
('arch
|
(sh "npm -g install tern"))
|
||||||
(let (progs)
|
(unless (executable-find "js-beautify")
|
||||||
(unless (executable-find "node") (push "nodejs" progs))
|
(sh "npm -g install js-beautify"))
|
||||||
(unless (executable-find "npm") (push "npm" progs))
|
(unless (executable-find "eslint")
|
||||||
(when progs
|
(sh "npm -g install eslint eslint-plugin-react")))
|
||||||
(sudo "pacman --noconfirm -S %s" progs))))
|
|
||||||
('debian) ;; TODO
|
|
||||||
('macos
|
|
||||||
(unless (executable-find "node")
|
|
||||||
(sh "brew install node"))))
|
|
||||||
(unless (executable-find "node")
|
|
||||||
(error "Failed to install NodeJS"))
|
|
||||||
(unless (executable-find "tern")
|
|
||||||
(sh "npm -g install tern"))
|
|
||||||
(unless (executable-find "js-beautify")
|
|
||||||
(sh "npm -g install js-beautify"))
|
|
||||||
(unless (executable-find "eslint")
|
|
||||||
(sh "npm -g install eslint eslint-plugin-react"))
|
|
||||||
t))
|
|
||||||
|
|
|
@ -20,5 +20,4 @@
|
||||||
(when-let (pkgs (cl-remove-if
|
(when-let (pkgs (cl-remove-if
|
||||||
(lambda (pkg) (zerop (shell-command (format "pip show %s" pkg))))
|
(lambda (pkg) (zerop (shell-command (format "pip show %s" pkg))))
|
||||||
'("jedi" "setuptools")))
|
'("jedi" "setuptools")))
|
||||||
(sh "pip install %s" (s-join " " pkgs))
|
(sh "pip install jedi setuptools")))
|
||||||
t))
|
|
||||||
|
|
|
@ -8,3 +8,15 @@
|
||||||
|
|
||||||
(when (featurep! :completion company)
|
(when (featurep! :completion company)
|
||||||
(package! company-inf-ruby))
|
(package! company-inf-ruby))
|
||||||
|
|
||||||
|
;;
|
||||||
|
(def-bootstrap! ruby
|
||||||
|
;; Since there are so many possible setups for a ruby environment (rbenv, rvm,
|
||||||
|
;; etc), I'll leave it to you and only take care of installing gem
|
||||||
|
;; dependencies.
|
||||||
|
(unless (executable-find "ruby")
|
||||||
|
(error "ruby isn't installed"))
|
||||||
|
(unless (executable-find "gem")
|
||||||
|
(error "gem isn't installed"))
|
||||||
|
(when-let (pkgs (cl-remove-if 'executable-find) '("ruby-lint")))
|
||||||
|
(sh "gem install %s" (s-join " " pkgs)))
|
||||||
|
|
|
@ -23,19 +23,16 @@
|
||||||
('macos
|
('macos
|
||||||
(unless (executable-find "rustc")
|
(unless (executable-find "rustc")
|
||||||
(sh "brew install rust"))))
|
(sh "brew install rust"))))
|
||||||
|
|
||||||
(dolist (bin '("rustc" "cargo"))
|
(dolist (bin '("rustc" "cargo"))
|
||||||
(unless (executable-find bin)
|
(unless (executable-find bin)
|
||||||
(error "Failed to install %s" bin)))
|
(error "Failed to install %s" bin)))
|
||||||
|
|
||||||
(require! :lang rust t)
|
(require! :lang rust t)
|
||||||
(require 'racer)
|
(require 'racer)
|
||||||
(and (unless (file-directory-p racer-rust-src-path)
|
(unless (file-directory-p racer-rust-src-path)
|
||||||
(fetch :github "rust-lang/rust" (expand-file-name "rust" +rust-ext-dir))
|
(fetch :github "rust-lang/rust" (expand-file-name "rust" +rust-ext-dir)))
|
||||||
t)
|
(unless (file-executable-p racer-cmd)
|
||||||
(unless (file-executable-p racer-cmd)
|
(let ((racer-dir (expand-file-name "racer" +rust-ext-dir)))
|
||||||
(let ((racer-dir (expand-file-name "racer" +rust-ext-dir)))
|
(fetch :github "phildawes/racer" racer-dir)
|
||||||
(fetch :github "phildawes/racer" racer-dir)
|
(let ((default-directory racer-dir))
|
||||||
(let ((default-directory racer-dir))
|
(sh "cargo build --release")))))
|
||||||
(sh "cargo build --release"))
|
|
||||||
t))))
|
|
||||||
|
|
|
@ -14,5 +14,4 @@
|
||||||
('debian
|
('debian
|
||||||
(sudo "apt-get install -y %s" prog-str))
|
(sudo "apt-get install -y %s" prog-str))
|
||||||
('macos
|
('macos
|
||||||
(sh "brew install %s" prog-str))))
|
(sh "brew install %s" prog-str))))))
|
||||||
t))
|
|
||||||
|
|
|
@ -18,3 +18,10 @@
|
||||||
(package! sass-mode)
|
(package! sass-mode)
|
||||||
(package! stylus-mode)
|
(package! stylus-mode)
|
||||||
|
|
||||||
|
;;
|
||||||
|
(def-bootstrap! web
|
||||||
|
:requires nodejs
|
||||||
|
(unless (executable-find "js-beautify")
|
||||||
|
(sh "npm -g install js-beautify"))
|
||||||
|
(unless (executable-find "stylelint")
|
||||||
|
(sh "npm -g install stylelint stylelint-scss")))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue