From 0cb2c6cf2f5ba8756f648c50a93045815668b355 Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 12 Nov 2015 10:38:38 +0100 Subject: [PATCH] Simplified installation and integration of clang-format. --- docs/install.md | 15 ++------------- src/config.cc | 14 +++++++++++++- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/docs/install.md b/docs/install.md index 9693755..fe1bdc4 100644 --- a/docs/install.md +++ b/docs/install.md @@ -4,6 +4,7 @@ Install dependencies: ```sh sudo apt-get install git cmake make g++ libclang-dev pkg-config libboost-system-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libgtkmm-3.0-dev libgtksourceviewmm-3.0-dev aspell-en libaspell-dev +sudo apt-get install clang-format-3.6 || sudo apt-get install clang-format-3.5 ``` Get juCi++ source, compile and install: @@ -15,12 +16,6 @@ make sudo make install ``` -To use clang-format for auto-indentation of C++ files (replace \[version\] with an available clang-format version): -```sh -sudo apt-get install clang-format-[version] -sudo ln -s /usr/bin/clang-format-[version] /usr/local/bin/clang-format -``` - ## Ubuntu 14/Linux Mint 17 Install dependencies: ```sh @@ -28,7 +23,7 @@ sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install g++-4.9 sudo apt-get remove g++-4.8 -sudo apt-get install git cmake make g++ libclang-3.6-dev pkg-config libboost-system1.55-dev libboost-thread1.55-dev libboost-filesystem1.55-dev libboost-log1.55-dev libgtkmm-3.0-dev libgtksourceviewmm-3.0-dev aspell-en libaspell-dev +sudo apt-get install git cmake make g++ libclang-3.6-dev clang-format-3.6 pkg-config libboost-system1.55-dev libboost-thread1.55-dev libboost-filesystem1.55-dev libboost-log1.55-dev libgtkmm-3.0-dev libgtksourceviewmm-3.0-dev aspell-en libaspell-dev ``` Get juCi++ source, compile and install: @@ -40,12 +35,6 @@ make sudo make install ``` -To use clang-format for auto-indentation of C++ files (replace \[version\] with an available clang-format version): -```sh -sudo apt-get install clang-format-[version] -sudo ln -s /usr/bin/clang-format-[version] /usr/local/bin/clang-format -``` - ## OS X with Homebrew (http://brew.sh/) Install dependencies (installing llvm may take some time): ```sh diff --git a/src/config.cc b/src/config.cc index 4883f23..094d57e 100644 --- a/src/config.cc +++ b/src/config.cc @@ -89,8 +89,20 @@ void Config::retrieve_config() { window.default_size = {cfg.get("default_window_size.width"), cfg.get("default_window_size.height")}; terminal.make_command=cfg.get("project.make_command"); terminal.cmake_command=cfg.get("project.cmake_command"); - terminal.clang_format_command=cfg.get("project.clang_format_command", "clang-format"); terminal.history_size=cfg.get("terminal_history_size"); + + terminal.clang_format_command=cfg.get("project.clang_format_command", "clang-format"); +#ifdef __linux + if(terminal.clang_format_command=="clang-format" && + !boost::filesystem::exists("/usr/bin/clang-format") && !boost::filesystem::exists("/usr/local/bin/clang-format")) { + if(boost::filesystem::exists("/usr/bin/clang-format-3.7")) + terminal.clang_format_command="/usr/bin/clang-format-3.7"; + else if(boost::filesystem::exists("/usr/bin/clang-format-3.6")) + terminal.clang_format_command="/usr/bin/clang-format-3.6"; + else if(boost::filesystem::exists("/usr/bin/clang-format-3.5")) + terminal.clang_format_command="/usr/bin/clang-format-3.5"; + } +#endif } bool Config::check_config_file(const boost::property_tree::ptree &default_cfg, std::string parent_path) {