diff --git a/ext/VARS b/ext/VARS index cc4696244..8ce6498c7 100644 --- a/ext/VARS +++ b/ext/VARS @@ -1,10 +1,15 @@ #!/usr/bin/env bash -CACHE_DIR="${HOME}/.emacs.d/private/cache/`hostname`/" -ELPA_DIR="${HOME}/.emacs.d/.cask/`emacs --version | grep -E -o '2[4-9]\.[0-9\.]+'`/elpa" +HOSTNAME=`emacs --batch --eval '(message "%s" (system-name))' 2>&1` -is-mac() { [ "$(uname)" == "Darwin" ]; } -is-linux() { [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; } +ROOT_DIR="$(cd $(dirname $0)/../ && pwd -P)" +CACHE_DIR="$ROOT_DIR/private/cache/$HOSTNAME" +ELPA_DIR="$ROOT_DIR/.cask/`emacs --version | grep -E -o '2[4-9]\.[0-9\.]+'`/elpa" +EXT_DIR="$ROOT_DIR/ext" + +# +is-arch() { [ -f "/etc/arch-release" ]; } +is-deb() { [ -f "/etc/debian_version" ]; } git-repo() { old=$(pwd) diff --git a/ext/setup-cc.sh b/ext/setup-cc.sh index 8e8a4fd27..04b3a8f2d 100755 --- a/ext/setup-cc.sh +++ b/ext/setup-cc.sh @@ -1,27 +1,48 @@ #!/usr/bin/env bash -cd ~/.emacs.d/ext -source ./VARS - -LLVMV="3.8.0" -LLVM="clang+llvm-${LLVMV}-x86_64-apple-darwin" +source VARS # echo "Setting up C/C++ (irony-mode)" -if is-mac; then - brew install cmake - brew install llvm --with-clang -fi +case "$OSTYPE" in + darwin*) + brew install cmake + brew install llvm --with-clang + ;; + linux*) + if is-arch; then + sudo pacman --noconfirm -S cmake clang + elif is-deb; then + echo "Not implemented" + exit 1 + fi + ;; +esac # Build irony-server git-repo "https://github.com/Sarcasm/irony-mode" "irony-mode" + +# Reset build directory cd irony-mode/server [ -d build ] && rm -rf build mkdir build && cd build -cmake -DCMAKE_INSTALL_RPATH_USE_LINK_PATH\=ON \ - -DCMAKE_INSTALL_PREFIX\=${CACHE_DIR}/irony/ ../ && \ - cmake --build . --use-stderr --config Release --target install -install_name_tool -change @rpath/libclang.dylib \ - /usr/local/opt/llvm/lib/libclang.dylib \ - ${CACHE_DIR}/irony/bin/irony-server + +DEST="$(pwd)/irony-mode/server/build/irony/" + +# Compile +if is-mac +then + cmake -DCMAKE_INSTALL_RPATH_USE_LINK_PATH\=ON \ + -DCMAKE_INSTALL_PREFIX\="$DEST" ../ +else + cmake -DCMAKE_INSTALL_PREFIX\="$DEST" ../ +fi +cmake --build . --use-stderr --config Release --target install + +if is-mac +then + install_name_tool -change @rpath/libclang.dylib \ + /usr/local/opt/llvm/lib/libclang.dylib \ + $DEST/bin/irony-server +fi diff --git a/ext/setup-js.sh b/ext/setup-js.sh index 110b6d5bd..c8d0c1d34 100755 --- a/ext/setup-js.sh +++ b/ext/setup-js.sh @@ -1,13 +1,22 @@ #!/usr/bin/env bash -cd ~/.emacs.d/ext -source ./VARS +source VARS # echo "Setting up JS (tern/trepanjs)" -if is-mac; then - brew install node -fi +case "$OSTYPE" in + darwin*) + brew install node + ;; + linux*) + if is-arch; then + sudo pacman --noconfirm -S nodejs npm + else + echo "..." + exit 1 + fi + ;; +esac npm -g install trepanjs tern diff --git a/modules/module-cc.el b/modules/module-cc.el index 50dce8144..42bfaf557 100644 --- a/modules/module-cc.el +++ b/modules/module-cc.el @@ -49,7 +49,7 @@ (use-package irony :after cc-mode :config - (setq irony-server-install-prefix (concat doom-temp-dir "/irony/")) + (setq irony-server-install-prefix (concat doom-ext-dir "/irony-mode/server/build/irony/")) (add-hook! c++-mode (make-local-variable 'irony-additional-clang-options) (push "-std=c++11" irony-additional-clang-options))