From 43ce12404393f3af2a331f1163e715f9d4a4ea5d Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 20 Mar 2017 03:47:12 -0400 Subject: [PATCH] lang/cc: add irony install bootstrap --- modules/lang/cc/packages.el | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/modules/lang/cc/packages.el b/modules/lang/cc/packages.el index 259e5e847..a4e2f571a 100644 --- a/modules/lang/cc/packages.el +++ b/modules/lang/cc/packages.el @@ -17,3 +17,44 @@ (when (featurep! :completion company) (package! company-irony) (package! company-irony-c-headers)) + +;; +(def-bootstrap! cc + ;; NOTE Untested + (require! :lang cc) + (require 'irony) + (unless (expand-file-name "bin/irony-server" irony-server-install-prefix) + (pcase (doom-system-os) + ('arch + (let (pkgs) + (unless (executable-find "cmake") + (push "cmake" pkgs)) + (unless (file-exists-p "/usr/lib/libclang.so") + (push "clang" pkgs)) + (when pkgs + (sudo "pacman --noconfirm -S %s" pkgs)))) + ('debian) ;; TODO + ('macos + (unless (executable-find "cmake") + (sh "brew install cmake")) + (unless (file-exists-p "/usr/loacl/opt/llvm/lib/libclang.dylib") + ;; Since installing llvm is a _huge_ undertaking for homebrew, we force + ;; you to install it manually. + (error "libclang.so not found. Run `brew install llvm` first, then retry")))) + (let ((default-directory (concat (file-name-as-directory temporary-file-directory) + (file-name-as-directory (format "build-irony-server-%s" (irony-version)))))) + (irony-install-server + (format (concat "%s " + (when IS-MAC "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON ") + "-DCMAKE_INSTALL_PREFIX='%s' " + "%s && %s --build . " + "--use-stderr --config Release --target install") + (shell-quote-argument irony-cmake-executable) + (shell-quote-argument (expand-file-name irony-server-install-prefix)) + (shell-quote-argument irony-server-source-dir) + (shell-quote-argument irony-cmake-executable))) + (when IS-MAC + (sh (format "install_name_tool -change @rpath/libclang.dylib %s %s" + "/usr/local/opt/llvm/lib/libclang.dylib" + (expand-file-name "bin/irony-server" irony-server-install-prefix))))) + t))