From 4d0e4a4e43e962e91dca076bcd2cd9c0d987f6b0 Mon Sep 17 00:00:00 2001 From: Geir Morten Larsen Date: Mon, 13 Jul 2015 19:02:28 +0200 Subject: [PATCH 01/15] CHANGE: updated libraries needed to run cmake . --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index cf441e9..0699904 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,9 @@ Please install these dependencies on your system. * libclang * [libclangmm](http://github.com/cppit/libclangmm/) +* boost +* gtkmm +* gtksourceview * cmake * make * clang or gcc (compiler) From fd49094e4896fdfd18189191e1d386ca6a6394ca Mon Sep 17 00:00:00 2001 From: Geir Morten Larsen Date: Tue, 14 Jul 2015 21:46:30 +0200 Subject: [PATCH 02/15] Change: added libraries and installation guide Added libraries that after comment on last commmit, and added an installation guide for linux. Did also change compile guide. --- README.md | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0699904..75603e2 100644 --- a/README.md +++ b/README.md @@ -26,18 +26,40 @@ Configuration description will arrive shortly after source code is added. ## Dependencies ## Please install these dependencies on your system. -* libclang +* libboost-python-dev +* libboost-filesystem-dev +* libboost-log-dev +* libboost-test-dev +* libboost-thread-dev +* libboost-system-dev +* libgtkmm-3.0-dev +* libgtksourceview2.0-dev +* libgtksourceviewmm-3.0-dev +* libpython-dev +* libclang-dev * [libclangmm](http://github.com/cppit/libclangmm/) -* boost -* gtkmm -* gtksourceview * cmake * make * clang or gcc (compiler) ## Installation ## +**Linux** +```sh +# Libraries (missing libclangmm, see http://github.com/cppit/libclangmm/ for installation) +$ sudo apt-get install libboost-python-dev libboost-filesystem-dev libboost-log-dev libboost-test-dev +libboost-thread-dev libboost-system-dev libgtkmm-3.0-dev libgtksourceview2.0-dev libgtksourceviewmm-3.0-dev +libpython-dev libclang-dev +# Programs +$sudo apt-get install make cmake gcc +``` +Compile ```sh +# When git clone +$ cd path-to-cloned-from-folder/jucipp/juci +# When download zipped file, extraxt it to a folder of your choice +$ cd path-to-folder-extraxted-into/jucipp-master/juci +# In both cases above you can choose remove the jucipp folder, but remeber to apply changes to cd command as well. $ cmake . $ make ``` From 2a521d4a873aae7843dc44bf37382360d5a428e5 Mon Sep 17 00:00:00 2001 From: Geir Morten Larsen Date: Wed, 15 Jul 2015 19:37:15 +0200 Subject: [PATCH 03/15] Added docs/install.md --- README.md | 24 +----------------------- docs/install.md | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 docs/install.md diff --git a/README.md b/README.md index 75603e2..9f82537 100644 --- a/README.md +++ b/README.md @@ -43,28 +43,6 @@ Please install these dependencies on your system. * clang or gcc (compiler) ## Installation ## -**Linux** -```sh -# Libraries (missing libclangmm, see http://github.com/cppit/libclangmm/ for installation) -$ sudo apt-get install libboost-python-dev libboost-filesystem-dev libboost-log-dev libboost-test-dev -libboost-thread-dev libboost-system-dev libgtkmm-3.0-dev libgtksourceview2.0-dev libgtksourceviewmm-3.0-dev -libpython-dev libclang-dev -# Programs -$sudo apt-get install make cmake gcc +See installation guide [docs/install.md](http://github.com/cppit/jucipp/blob/master/docs/install.md). -``` -Compile -```sh -# When git clone -$ cd path-to-cloned-from-folder/jucipp/juci -# When download zipped file, extraxt it to a folder of your choice -$ cd path-to-folder-extraxted-into/jucipp-master/juci -# In both cases above you can choose remove the jucipp folder, but remeber to apply changes to cd command as well. -$ cmake . -$ make -``` -## Run -```sh -$ ./bin/juci -``` diff --git a/docs/install.md b/docs/install.md new file mode 100644 index 0000000..9af5fa0 --- /dev/null +++ b/docs/install.md @@ -0,0 +1,27 @@ +# juCi++ +## Installation guide ## +## Linux +```sh +# Libraries (missing libclangmm, see http://github.com/cppit/libclangmm/ for installation) +$ sudo apt-get install libboost-python-dev libboost-filesystem-dev libboost-log-dev libboost-test-dev +libboost-thread-dev libboost-system-dev libgtkmm-3.0-dev libgtksourceview2.0-dev libgtksourceviewmm-3.0-dev +libpython-dev libclang-dev +# Programs +$sudo apt-get install make cmake gcc + +``` +Compile +```sh +# When git clone +$ cd path-to-cloned-from-folder/jucipp/juci +# When download zipped file, extraxt it to a folder of your choice +$ cd path-to-folder-extraxted-into/jucipp-master/juci +# In both cases above you can choose remove the jucipp folder, but remeber to apply changes to cd command as well. +$ cmake . +$ make +``` + +## Run +```sh +$ ./bin/juci +``` From 4626bc910fade126eeb957e8e9decc15d95c5e03 Mon Sep 17 00:00:00 2001 From: Geir Morten Larsen Date: Wed, 22 Jul 2015 17:39:42 +0200 Subject: [PATCH 04/15] changing link names to installtion guides --- README.md | 2 +- docs/install.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9f82537..362e9c8 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,6 @@ Please install these dependencies on your system. * clang or gcc (compiler) ## Installation ## -See installation guide [docs/install.md](http://github.com/cppit/jucipp/blob/master/docs/install.md). +See [installation guide](http://github.com/cppit/jucipp/blob/master/docs/install.md). diff --git a/docs/install.md b/docs/install.md index 9af5fa0..2713a3f 100644 --- a/docs/install.md +++ b/docs/install.md @@ -2,7 +2,7 @@ ## Installation guide ## ## Linux ```sh -# Libraries (missing libclangmm, see http://github.com/cppit/libclangmm/ for installation) +# Libraries (missing libclangmm, see [installation guide](http://github.com/cppit/libclangmm/blob/master/docs/install.md) for installation) $ sudo apt-get install libboost-python-dev libboost-filesystem-dev libboost-log-dev libboost-test-dev libboost-thread-dev libboost-system-dev libgtkmm-3.0-dev libgtksourceview2.0-dev libgtksourceviewmm-3.0-dev libpython-dev libclang-dev From 1ea83932ffb7b9b6678993441462d2d056e2d304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 29 Jul 2015 14:42:59 +0200 Subject: [PATCH 05/15] #14 Rearrange directory structure --- {juci => config}/config.json | 0 {juci => config}/menu.xml | 0 {juci => config}/plugins.py | 0 {juci/plugins => plugins}/snippet.py | 0 {juci => src}/CMakeLists.txt | 0 {juci => src}/api.cc | 0 {juci => src}/api.h | 0 {juci => src}/api_ext.cc | 0 {juci => src}/cmake/Modules/FindLibClang.cmake | 0 {juci => src}/cmake/Modules/FindLibClangmm.cmake | 0 {juci => src}/config.cc | 0 {juci => src}/config.h | 0 {juci => src}/directories.cc | 0 {juci => src}/directories.h | 0 {juci => src}/entrybox.cc | 0 {juci => src}/entrybox.h | 0 {juci => src}/juci.cc | 0 {juci => src}/juci.h | 0 {juci => src}/logging.h | 0 {juci => src}/menu.cc | 0 {juci => src}/menu.h | 0 {juci => src}/notebook.cc | 0 {juci => src}/notebook.h | 0 {juci => src}/selectiondialog.cc | 0 {juci => src}/selectiondialog.h | 0 {juci => src}/singletons.cc | 0 {juci => src}/singletons.h | 0 {juci => src}/source.cc | 0 {juci => src}/source.h | 0 {juci => src}/sourcefile.cc | 0 {juci => src}/sourcefile.h | 0 {juci => src}/terminal.cc | 0 {juci => src}/terminal.h | 0 {juci => src}/tooltips.cc | 0 {juci => src}/tooltips.h | 0 {juci => src}/window.cc | 0 {juci => src}/window.h | 0 37 files changed, 0 insertions(+), 0 deletions(-) rename {juci => config}/config.json (100%) rename {juci => config}/menu.xml (100%) rename {juci => config}/plugins.py (100%) rename {juci/plugins => plugins}/snippet.py (100%) rename {juci => src}/CMakeLists.txt (100%) rename {juci => src}/api.cc (100%) rename {juci => src}/api.h (100%) rename {juci => src}/api_ext.cc (100%) rename {juci => src}/cmake/Modules/FindLibClang.cmake (100%) rename {juci => src}/cmake/Modules/FindLibClangmm.cmake (100%) rename {juci => src}/config.cc (100%) rename {juci => src}/config.h (100%) rename {juci => src}/directories.cc (100%) rename {juci => src}/directories.h (100%) rename {juci => src}/entrybox.cc (100%) rename {juci => src}/entrybox.h (100%) rename {juci => src}/juci.cc (100%) rename {juci => src}/juci.h (100%) rename {juci => src}/logging.h (100%) rename {juci => src}/menu.cc (100%) rename {juci => src}/menu.h (100%) rename {juci => src}/notebook.cc (100%) rename {juci => src}/notebook.h (100%) rename {juci => src}/selectiondialog.cc (100%) rename {juci => src}/selectiondialog.h (100%) rename {juci => src}/singletons.cc (100%) rename {juci => src}/singletons.h (100%) rename {juci => src}/source.cc (100%) rename {juci => src}/source.h (100%) rename {juci => src}/sourcefile.cc (100%) rename {juci => src}/sourcefile.h (100%) rename {juci => src}/terminal.cc (100%) rename {juci => src}/terminal.h (100%) rename {juci => src}/tooltips.cc (100%) rename {juci => src}/tooltips.h (100%) rename {juci => src}/window.cc (100%) rename {juci => src}/window.h (100%) diff --git a/juci/config.json b/config/config.json similarity index 100% rename from juci/config.json rename to config/config.json diff --git a/juci/menu.xml b/config/menu.xml similarity index 100% rename from juci/menu.xml rename to config/menu.xml diff --git a/juci/plugins.py b/config/plugins.py similarity index 100% rename from juci/plugins.py rename to config/plugins.py diff --git a/juci/plugins/snippet.py b/plugins/snippet.py similarity index 100% rename from juci/plugins/snippet.py rename to plugins/snippet.py diff --git a/juci/CMakeLists.txt b/src/CMakeLists.txt similarity index 100% rename from juci/CMakeLists.txt rename to src/CMakeLists.txt diff --git a/juci/api.cc b/src/api.cc similarity index 100% rename from juci/api.cc rename to src/api.cc diff --git a/juci/api.h b/src/api.h similarity index 100% rename from juci/api.h rename to src/api.h diff --git a/juci/api_ext.cc b/src/api_ext.cc similarity index 100% rename from juci/api_ext.cc rename to src/api_ext.cc diff --git a/juci/cmake/Modules/FindLibClang.cmake b/src/cmake/Modules/FindLibClang.cmake similarity index 100% rename from juci/cmake/Modules/FindLibClang.cmake rename to src/cmake/Modules/FindLibClang.cmake diff --git a/juci/cmake/Modules/FindLibClangmm.cmake b/src/cmake/Modules/FindLibClangmm.cmake similarity index 100% rename from juci/cmake/Modules/FindLibClangmm.cmake rename to src/cmake/Modules/FindLibClangmm.cmake diff --git a/juci/config.cc b/src/config.cc similarity index 100% rename from juci/config.cc rename to src/config.cc diff --git a/juci/config.h b/src/config.h similarity index 100% rename from juci/config.h rename to src/config.h diff --git a/juci/directories.cc b/src/directories.cc similarity index 100% rename from juci/directories.cc rename to src/directories.cc diff --git a/juci/directories.h b/src/directories.h similarity index 100% rename from juci/directories.h rename to src/directories.h diff --git a/juci/entrybox.cc b/src/entrybox.cc similarity index 100% rename from juci/entrybox.cc rename to src/entrybox.cc diff --git a/juci/entrybox.h b/src/entrybox.h similarity index 100% rename from juci/entrybox.h rename to src/entrybox.h diff --git a/juci/juci.cc b/src/juci.cc similarity index 100% rename from juci/juci.cc rename to src/juci.cc diff --git a/juci/juci.h b/src/juci.h similarity index 100% rename from juci/juci.h rename to src/juci.h diff --git a/juci/logging.h b/src/logging.h similarity index 100% rename from juci/logging.h rename to src/logging.h diff --git a/juci/menu.cc b/src/menu.cc similarity index 100% rename from juci/menu.cc rename to src/menu.cc diff --git a/juci/menu.h b/src/menu.h similarity index 100% rename from juci/menu.h rename to src/menu.h diff --git a/juci/notebook.cc b/src/notebook.cc similarity index 100% rename from juci/notebook.cc rename to src/notebook.cc diff --git a/juci/notebook.h b/src/notebook.h similarity index 100% rename from juci/notebook.h rename to src/notebook.h diff --git a/juci/selectiondialog.cc b/src/selectiondialog.cc similarity index 100% rename from juci/selectiondialog.cc rename to src/selectiondialog.cc diff --git a/juci/selectiondialog.h b/src/selectiondialog.h similarity index 100% rename from juci/selectiondialog.h rename to src/selectiondialog.h diff --git a/juci/singletons.cc b/src/singletons.cc similarity index 100% rename from juci/singletons.cc rename to src/singletons.cc diff --git a/juci/singletons.h b/src/singletons.h similarity index 100% rename from juci/singletons.h rename to src/singletons.h diff --git a/juci/source.cc b/src/source.cc similarity index 100% rename from juci/source.cc rename to src/source.cc diff --git a/juci/source.h b/src/source.h similarity index 100% rename from juci/source.h rename to src/source.h diff --git a/juci/sourcefile.cc b/src/sourcefile.cc similarity index 100% rename from juci/sourcefile.cc rename to src/sourcefile.cc diff --git a/juci/sourcefile.h b/src/sourcefile.h similarity index 100% rename from juci/sourcefile.h rename to src/sourcefile.h diff --git a/juci/terminal.cc b/src/terminal.cc similarity index 100% rename from juci/terminal.cc rename to src/terminal.cc diff --git a/juci/terminal.h b/src/terminal.h similarity index 100% rename from juci/terminal.h rename to src/terminal.h diff --git a/juci/tooltips.cc b/src/tooltips.cc similarity index 100% rename from juci/tooltips.cc rename to src/tooltips.cc diff --git a/juci/tooltips.h b/src/tooltips.h similarity index 100% rename from juci/tooltips.h rename to src/tooltips.h diff --git a/juci/window.cc b/src/window.cc similarity index 100% rename from juci/window.cc rename to src/window.cc diff --git a/juci/window.h b/src/window.h similarity index 100% rename from juci/window.h rename to src/window.h From 9f60e210b7ff836bda3e132c1edb8820ac78f0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 29 Jul 2015 16:54:55 +0200 Subject: [PATCH 06/15] Cleanup cmakelists --- CMakeLists.txt | 19 ++ src/CMakeLists.txt | 246 +++++++++++-------------- src/cmake/Modules/FindLibClangmm.cmake | 9 +- 3 files changed, 124 insertions(+), 150 deletions(-) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..3b69577 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required (VERSION 2.8.4) + +set(project_name juci) +set(module juci_to_python_api) + +#### TODO WINDOWS SUPPORT #### +set(juci_config_folder "$ENV{HOME}/.juci") +set(bin_install_path "/usr/local/bin") +set(lib_install_path "/usr/local/lib/python2.7/dist-packages/") +##### + +project (${project_name}) + +add_subdirectory("src") + +install( + DIRECTORY "config" "plugins" + DESTINATION ${juci_config_folder} + USE_SOURCE_PERMISSIONS) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 694961c..79323c8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,164 +1,124 @@ -cmake_minimum_required (VERSION 2.8.4) -set(project_name juci) -set(module juci_to_python_api) -project (${project_name}) add_definitions(-DBOOST_LOG_DYN_LINK) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11 -pthread -Wall -Wno-reorder") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/") -#You are of course using Homebrew: if(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L/usr/local/opt/gettext/lib -I/usr/local/opt/gettext/include -undefined dynamic_lookup") #TODO: fix this + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L/usr/local/opt/gettext/lib -I/usr/local/opt/gettext/include -undefined dynamic_lookup") #T set(CMAKE_MACOSX_RPATH 1) set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig") endif() INCLUDE(FindPkgConfig) -message("Searcing for libclang") -#LIBCLANG_FOUND System has libclang. -#LIBCLANG_INCLUDE_DIRS The libclang include directories. -#LIBCLANG_LIBRARIES The libraries needed to use libclang. -#LIBCLANG_LIBRARY_DIR The path to the directory containing libclang. -#LIBCLANG_KNOWN_LLVM_VERSIONS Known LLVM release numbers. -find_package(LibClangmm) -find_package(LibClang) +set(validation true) + +function(install_help APPLE UNIX WINDOWS) + message("Install package with:") + if(UNIX) + if(APPLE) + message("brew install ${APPLE}") + else() + message("sudo apt-get install ${UNIX}") + endif(APPLE) + endif(UNIX) + if(WINDOWS) + message("choco install ${WINDOWS}") + endif(WINDOWS) +endfunction(install_help) + +function(validate FOUND APPLE UNIX WINDOWS) + if(!${FOUND}) + set(validation false) + install_help(${APPLE} ${UNIX} ${WINDOWS}) + endif() +endfunction(validate) -if(${LCL_FOUND}) - message("libclangmm libraries found. Continuing") - message("${LCL_INCLUDE_DIRS}") -else() - message(FATAL_ERROR "The libclangmm libraries are required. Quitting.") -endif() +find_package(LibClangmm) +validate(${LCL_FOUND} "clangmm" "clangmm" "clangmm") -if(${LIBCLANG_FOUND}) - message("libclangmm libraries found. Continuing") - message("${LIBCLANG_INCLUDE_DIRS}") -else() - message(FATAL_ERROR "The libclangmm libraries are required. Quitting.") -endif() +find_package(LibClang) +validate(${LIBCLANG_FOUND} "clang" "libclang-dev" "llvm") -#### Finding boost, the variables below is set ##### -#PYTHONLIBS_FOUND - True if headers and requested libraries were found -#PYTHON_INCLUDE_DIRS - Boost include directories -#PYTHON_LIBRARIES - Boost component libraries to be linked find_package(PythonLibs 2.7) +validate(${PYTHONLIBS_FOUND} "python" "libpython-dev" "python") -#If python is found -if(${PYTHONLIBS_FOUND}) - message("Python libraries found. Continuing") -else() - message("Please install python libraries. The libraries where not found.") - message("Python include dirs: ${PYTHON_INCLUDE_DIRS}") - message("Python link dirs ${PYTHON_LIBRARIES}") - message(FATAL_ERROR "The python libraries are required. Quitting.") -endif() - -#### Finding boost, the variables below is set ##### -#Boost_FOUND - True if headers and requested libraries were found -#Boost_INCLUDE_DIRS - Boost include directories -#Boost_LIBRARY_DIRS - Link directories for Boost libraries -#Boost_LIBRARIES - Boost component libraries to be linked find_package(Boost 1.55 COMPONENTS python thread log system filesystem REQUIRED) +validate(${Boost_FOUND} "boost" "libboost-all-dev" "boost") -#If boost is not found -if(${Boost_FOUND}) - message("Boost libraries found. Continuing") -else() - message("Please install boost libraries. The libraries where not found.") - message("Boost library dirs: ${Boost_LIBRARY_DIRS}") - message("Boost include dirs: ${Boost_INCLUDE_DIRS}") - message("Boost link dirs ${Boost_LIBRARIES}") - message(FATAL_ERROR "The boost libraries are required. Quitting.") -endif() - -#### Finding gtkmm, the variables below is set ##### -#GTKMM_FOUND - True if headers and requested libraries were found -#GTKMM_INCLUDE_DIRS - GTKMM include directories -#GTKMM_LIBRARY_DIRS - Link directories for GTKMM libraries -#GTKMM_LIBRARIES - GTKMM libraries to be linked pkg_check_modules(GTKMM gtkmm-3.0) # The name GTKMM is set here for the variables abouve - -#If gtkmm is not found -if(${GTKMM_FOUND}) - message("Gtkmm libraries found. Continuing") -else() - message("Please install gtkmm libraries. The libraries where not found.") - message("Gtkmm library dirs ${GTKMM_LIBRARY_DIRS}") - message("Gtkmm include dirs ${GTKMM_INCLUDE_DIRS}") - message("Gtkmm link dirs ${GTKMM_LIBRARIES}") - message(FATAL_ERROR "The gtkmm libraries are required. Quitting.") -endif() +validate(${GTKMM_FOUND} "gtkmm" "libgtkmm-dev" "gtkmm") pkg_check_modules(GTKSVMM gtksourceviewmm-3.0) -if(${GTKSVMM_FOUND}) - message("Gtksourceviewmm libraries found. Continuing") -else() - message(FATAL_ERROR "The gtksourceviewmm libraries are required. Quitting.") -endif() - -# name of the executable on Windows will be example.exe -add_executable(${project_name} - #list of every needed file to create the executable - juci.h - juci.cc - menu.h - menu.cc - source.h - source.cc - selectiondialog.h - selectiondialog.cc - config.h - config.cc - sourcefile.h - sourcefile.cc - window.cc - window.h - api.h - api.cc - notebook.cc - notebook.h - entrybox.h - entrybox.cc - directories.h - directories.cc - terminal.h - terminal.cc - tooltips.h - tooltips.cc - singletons.h - singletons.cc - ) - -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) - - -add_library(${module} SHARED - api - api_ext - ) -# dependencies - -include_directories( - ${Boost_INCLUDE_DIRS} - ${PYTHON_INCLUDE_DIRS} - ${GTKMM_INCLUDE_DIRS} - ${GTKSVMM_INCLUDE_DIRS} - ${LCL_INCLUDE_DIRS} - ${LIBCLANG_INCLUDE_DIRS} - ) -link_directories( - ${GTKMM_LIBRARY_DIRS} - ${GTKSVMM_LIBRARY_DIRS} - ${Boost_LIBRARY_DIRS} - ${PYTHON_INCLUDE_DIRS} - ${LCL_LIBRARY_DIRS} - ${LIBCLANG_LIBRARY_DIRS} - ) -#module: -set_target_properties(${module} PROPERTIES PREFIX "" -LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib/") -target_link_libraries(${module} ${PYTHON_LIBRARIES} ${Boost_LIBRARIES}) -#executable: -target_link_libraries(${project_name} ${LIVCLANG_LIBRARIES} ${LCL_LIBRARIES} ${GTKMM_LIBRARIES} ${GTKSVMM_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) - +validate(${GTKSVMM_FOUND} "gtksvmm" "libgtksvmm-dev" "gtkmmsv") + +if(${validation}) + add_executable(${project_name} + juci.h + juci.cc + menu.h + menu.cc + source.h + source.cc + selectiondialog.h + selectiondialog.cc + config.h + config.cc + sourcefile.h + sourcefile.cc + window.cc + window.h + api.h + api.cc + notebook.cc + notebook.h + entrybox.h + entrybox.cc + directories.h + directories.cc + terminal.h + terminal.cc + tooltips.h + tooltips.cc + singletons.h + singletons.cc) + + add_library(${module} SHARED + api + api_ext) + + include_directories( + ${Boost_INCLUDE_DIRS} + ${PYTHON_INCLUDE_DIRS} + ${GTKMM_INCLUDE_DIRS} + ${GTKSVMM_INCLUDE_DIRS} + ${LCL_INCLUDE_DIRS} + ${LIBCLANG_INCLUDE_DIRS}) + + link_directories( + ${GTKMM_LIBRARY_DIRS} + ${GTKSVMM_LIBRARY_DIRS} + ${Boost_LIBRARY_DIRS} + ${PYTHON_INCLUDE_DIRS} + ${LCL_LIBRARY_DIRS} + ${LIBCLANG_LIBRARY_DIRS}) + + set_target_properties(${module} + PROPERTIES PREFIX "" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib/") + + target_link_libraries(${module} ${PYTHON_LIBRARIES} ${Boost_LIBRARIES}) + + target_link_libraries(${project_name} + ${LIBCLANG_LIBRARIES} + ${LCL_LIBRARIES} + ${GTKMM_LIBRARIES} + ${GTKSVMM_LIBRARIES} + ${Boost_LIBRARIES} + ${PYTHON_LIBRARIES}) + + install(TARGETS ${project_name} ${module} + RUNTIME DESTINATION ${bin_install_path} + LIBRARY DESTINATION ${lib_install_path} + ) + +endif(${validation}) diff --git a/src/cmake/Modules/FindLibClangmm.cmake b/src/cmake/Modules/FindLibClangmm.cmake index 0cb9fc5..49f950b 100644 --- a/src/cmake/Modules/FindLibClangmm.cmake +++ b/src/cmake/Modules/FindLibClangmm.cmake @@ -1,20 +1,15 @@ -# - Try to find LCL - - -# Once done this will define # LCL_FOUND - Libclangmm is available # LCL_INCLUDE_DIRS - The libclangmm include directories # LCL_LIBRARIES - -# LCL_DEFINITIONS - Compiler switches required for using libclangmm find_package(PkgConfig) find_path(LCL_INCLUDE_DIR clangmm.h - HINTS "/usr/local/lib/libclangmm/include/" + HINTS "/usr/local/include/libclangmm/" ) find_library(LCL_LIBRARY NAMES clangmm - HINTS "/usr/local/lib/libclangmm/" + HINTS "/usr/local/lib/" ) set(LCL_LIBRARIES ${LCL_LIBRARY} ) From d87312de94019cd20e1fce717476e9eb9a14d173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 29 Jul 2015 17:15:20 +0200 Subject: [PATCH 07/15] Update config path --- src/config.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config.cc b/src/config.cc index a4fc63a..f0d942b 100644 --- a/src/config.cc +++ b/src/config.cc @@ -6,7 +6,8 @@ MainConfig::MainConfig() { INFO("Reading config file"); - boost::property_tree::json_parser::read_json("config.json", cfg_); + std::string path(getenv("HOME")); // TODO WINDOWS + boost::property_tree::json_parser::read_json(path + "/.juci/config/config.json", cfg_); INFO("Config file read"); GenerateSource(); GenerateKeybindings(); From f5b689d83c8927b970d2bed042ffc8b9c872ed8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 29 Jul 2015 17:39:30 +0200 Subject: [PATCH 08/15] Update plugins to new paths --- config/plugins.py | 11 ++++------- src/api.cc | 9 ++------- src/api.h | 1 - 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/config/plugins.py b/config/plugins.py index ef50bb7..e19fff9 100644 --- a/config/plugins.py +++ b/config/plugins.py @@ -1,13 +1,10 @@ #!/usr/bin/python -#plugin handler -import sys, os, glob -cwd = os.getcwd() -sys.path.append(cwd+"/lib") - import juci_to_python_api as juci +import glob + def loadplugins(): - plugin_files = glob.glob(cwd+"/plugins/*.py") + plugin_files = glob.glob("../plugins/*.py") for current_file in plugin_files: juci.initPlugin(current_file) - loadplugins() + diff --git a/src/api.cc b/src/api.cc index 4cf9242..6d6b9e2 100644 --- a/src/api.cc +++ b/src/api.cc @@ -18,12 +18,6 @@ PluginApi::PluginApi(Notebook* notebook) { DEBUG("Plugins initiated.."); } -std::string PluginApi::ProjectPath() { - int MAXPATHLEN = 50; - char temp[MAXPATHLEN]; - return ( getcwd(temp, MAXPATHLEN) ? std::string( temp ) : std::string("") ); -} - void PluginApi::ReplaceWord(std::string word) { Glib::RefPtr buffer = libjuci::BufferFromNotebook(); Gtk::TextIter word_start = libjuci::IterFromNotebook(); @@ -57,7 +51,8 @@ std::string PluginApi::GetWord() { } void PluginApi::InitPlugins() { - libjuci::LoadPlugin(ProjectPath()+"/plugins.py"); + std::string path(getenv("HOME")); + libjuci::LoadPlugin(path + "/.juci/config/plugins.py"); } void PluginApi::AddMenuElement(std::string plugin_name) { diff --git a/src/api.h b/src/api.h index 6292c07..4468631 100644 --- a/src/api.h +++ b/src/api.h @@ -16,7 +16,6 @@ public: static Menu* menu_; static Notebook* notebook; static void InitPlugins(); - static std::string ProjectPath(); // for Python module: static std::string GetWord(); // menu management From cb8f8e72663cf62ca668c59ef386ea14a2637451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 29 Jul 2015 17:48:03 +0200 Subject: [PATCH 09/15] Add some logging --- src/menu.cc | 2 ++ src/menu.h | 1 + src/singletons.cc | 2 +- src/window.cc | 4 +++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/menu.cc b/src/menu.cc index 71703ba..6a08595 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -2,6 +2,7 @@ #include Menu::Menu() : box(Gtk::ORIENTATION_VERTICAL) { + INFO("Creating menu"); action_group = Gtk::ActionGroup::create(); ui_manager = Gtk::UIManager::create(); @@ -16,6 +17,7 @@ Menu::Menu() : box(Gtk::ORIENTATION_VERTICAL) { action_group->add(Gtk::Action::create("HelpMenu", "Help")); action_group->add(Gtk::Action::create("HelpAbout", "About"), [this]() { }); + INFO("Menu created"); } Gtk::Widget& Menu::get_widget() { diff --git a/src/menu.h b/src/menu.h index 40e3cb3..af5aa92 100644 --- a/src/menu.h +++ b/src/menu.h @@ -4,6 +4,7 @@ #include #include #include +#include "logging.h" class Menu { public: diff --git a/src/singletons.cc b/src/singletons.cc index b9c19bd..d517cd6 100644 --- a/src/singletons.cc +++ b/src/singletons.cc @@ -15,4 +15,4 @@ Menu *Singleton::menu() { if(!menu_) menu_=std::unique_ptr(new Menu()); return menu_.get(); -} \ No newline at end of file +} diff --git a/src/window.cc b/src/window.cc index 72194c1..3065fcb 100644 --- a/src/window.cc +++ b/src/window.cc @@ -15,6 +15,7 @@ Window::Window() : notebook(), plugin_api(¬ebook), box(Gtk::ORIENTATION_VERTI //TODO: see TODO Window::on_directory_navigation directories.m_TreeView.signal_row_activated().connect(sigc::mem_fun(*this, &Window::on_directory_navigation)); auto menu=Singleton::menu(); + INFO("Adding actions to menu"); menu->action_group->add(Gtk::Action::create("FileQuit", "Quit juCi++"), Gtk::AccelKey(menu->key_map["quit"]), [this]() { hide(); }); @@ -145,9 +146,10 @@ Window::Window() : notebook(), plugin_api(¬ebook), box(Gtk::ORIENTATION_VERTI execute.detach(); } }); - + INFO("Done adding actions to menu, building menu:") add_accel_group(menu->ui_manager->get_accel_group()); menu->build(); + INFO("Menu build") box.pack_start(menu->get_widget(), Gtk::PACK_SHRINK); box.pack_start(entry_box, Gtk::PACK_SHRINK); From c5c9f59653038751c8a55aefd043612116377e5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 29 Jul 2015 19:48:41 +0200 Subject: [PATCH 10/15] Make install working --- src/config.cc | 21 +++++++++++++-------- src/juci.cc | 2 +- src/menu.cc | 1 + src/menu.h | 1 - src/singletons.h | 4 +++- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/config.cc b/src/config.cc index f0d942b..b71cbf5 100644 --- a/src/config.cc +++ b/src/config.cc @@ -3,11 +3,12 @@ #include "logging.h" #include #include +#include + MainConfig::MainConfig() { INFO("Reading config file"); - std::string path(getenv("HOME")); // TODO WINDOWS - boost::property_tree::json_parser::read_json(path + "/.juci/config/config.json", cfg_); + boost::property_tree::json_parser::read_json(Singleton::config_dir() + "config.json", cfg_); INFO("Config file read"); GenerateSource(); GenerateKeybindings(); @@ -74,13 +75,17 @@ void MainConfig::GenerateTerminalCommands() { } void MainConfig::GenerateKeybindings() { - auto menu=Singleton::menu(); - DEBUG("Fetching keybindings"); + auto menu = Singleton::menu(); + boost::filesystem::path path(Singleton::config_dir() + "menu.xml"); + if (!boost::filesystem::is_regular_file(path)) { + std::cerr << "menu.xml not found" << std::endl; + throw; + } + std::ifstream input(path.string()); std::string line; - std::ifstream menu_xml("menu.xml"); - if (menu_xml.is_open()) { - while (getline(menu_xml, line)) - menu->ui+=line; + if (input.is_open()) { + while (getline(input, line)) + menu->ui += line; } boost::property_tree::ptree keys_json = cfg_.get_child("keybindings"); for (auto &i : keys_json) { diff --git a/src/juci.cc b/src/juci.cc index bd38c4b..a6326dc 100644 --- a/src/juci.cc +++ b/src/juci.cc @@ -3,7 +3,7 @@ void init_logging() { add_common_attributes(); - add_file_log(keywords::file_name = "juci.log", + add_file_log(keywords::file_name = Singleton::log_dir() + "juci.log", keywords::auto_flush = true); INFO("Logging initalized"); } diff --git a/src/menu.cc b/src/menu.cc index 6a08595..d20b74d 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -1,4 +1,5 @@ #include "menu.h" +#include "logging.h" #include Menu::Menu() : box(Gtk::ORIENTATION_VERTICAL) { diff --git a/src/menu.h b/src/menu.h index af5aa92..40e3cb3 100644 --- a/src/menu.h +++ b/src/menu.h @@ -4,7 +4,6 @@ #include #include #include -#include "logging.h" class Menu { public: diff --git a/src/singletons.h b/src/singletons.h index be8240a..15bc60d 100644 --- a/src/singletons.h +++ b/src/singletons.h @@ -6,6 +6,7 @@ #include "terminal.h" #include "notebook.h" #include "menu.h" +#include class Singleton { public: @@ -19,7 +20,8 @@ public: static std::unique_ptr terminal_; static std::unique_ptr directories_; }; - + static std::string config_dir() { return std::string(getenv("HOME")) + "/.juci/config/"; } + static std::string log_dir() { return std::string(getenv("HOME")) + "/.juci/log/"; } static Terminal::Controller *terminal(); static Menu *menu(); private: From b88702f94a3dba6e18e70cf932818ed45fda8fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 29 Jul 2015 19:48:41 +0200 Subject: [PATCH 11/15] Make install working --- CMakeLists.txt | 3 ++- src/config.cc | 21 +++++++++++++-------- src/juci.cc | 2 +- src/menu.cc | 1 + src/menu.h | 1 - src/singletons.h | 4 +++- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b69577..6229322 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,4 +16,5 @@ add_subdirectory("src") install( DIRECTORY "config" "plugins" DESTINATION ${juci_config_folder} - USE_SOURCE_PERMISSIONS) \ No newline at end of file + USE_SOURCE_PERMISSIONS) +install(CODE "FILE(MAKE_DIRECTORY ${juci_config_filder}/log)") diff --git a/src/config.cc b/src/config.cc index f0d942b..b71cbf5 100644 --- a/src/config.cc +++ b/src/config.cc @@ -3,11 +3,12 @@ #include "logging.h" #include #include +#include + MainConfig::MainConfig() { INFO("Reading config file"); - std::string path(getenv("HOME")); // TODO WINDOWS - boost::property_tree::json_parser::read_json(path + "/.juci/config/config.json", cfg_); + boost::property_tree::json_parser::read_json(Singleton::config_dir() + "config.json", cfg_); INFO("Config file read"); GenerateSource(); GenerateKeybindings(); @@ -74,13 +75,17 @@ void MainConfig::GenerateTerminalCommands() { } void MainConfig::GenerateKeybindings() { - auto menu=Singleton::menu(); - DEBUG("Fetching keybindings"); + auto menu = Singleton::menu(); + boost::filesystem::path path(Singleton::config_dir() + "menu.xml"); + if (!boost::filesystem::is_regular_file(path)) { + std::cerr << "menu.xml not found" << std::endl; + throw; + } + std::ifstream input(path.string()); std::string line; - std::ifstream menu_xml("menu.xml"); - if (menu_xml.is_open()) { - while (getline(menu_xml, line)) - menu->ui+=line; + if (input.is_open()) { + while (getline(input, line)) + menu->ui += line; } boost::property_tree::ptree keys_json = cfg_.get_child("keybindings"); for (auto &i : keys_json) { diff --git a/src/juci.cc b/src/juci.cc index bd38c4b..a6326dc 100644 --- a/src/juci.cc +++ b/src/juci.cc @@ -3,7 +3,7 @@ void init_logging() { add_common_attributes(); - add_file_log(keywords::file_name = "juci.log", + add_file_log(keywords::file_name = Singleton::log_dir() + "juci.log", keywords::auto_flush = true); INFO("Logging initalized"); } diff --git a/src/menu.cc b/src/menu.cc index 6a08595..d20b74d 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -1,4 +1,5 @@ #include "menu.h" +#include "logging.h" #include Menu::Menu() : box(Gtk::ORIENTATION_VERTICAL) { diff --git a/src/menu.h b/src/menu.h index af5aa92..40e3cb3 100644 --- a/src/menu.h +++ b/src/menu.h @@ -4,7 +4,6 @@ #include #include #include -#include "logging.h" class Menu { public: diff --git a/src/singletons.h b/src/singletons.h index be8240a..15bc60d 100644 --- a/src/singletons.h +++ b/src/singletons.h @@ -6,6 +6,7 @@ #include "terminal.h" #include "notebook.h" #include "menu.h" +#include class Singleton { public: @@ -19,7 +20,8 @@ public: static std::unique_ptr terminal_; static std::unique_ptr directories_; }; - + static std::string config_dir() { return std::string(getenv("HOME")) + "/.juci/config/"; } + static std::string log_dir() { return std::string(getenv("HOME")) + "/.juci/log/"; } static Terminal::Controller *terminal(); static Menu *menu(); private: From 4222608c4cad7510298c9740ab76e6c1f8612529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 29 Jul 2015 21:25:14 +0200 Subject: [PATCH 12/15] Make install complete --- CMakeLists.txt | 9 +-- config/config.json | 101 ----------------------------- config/menu.xml | 40 ------------ config/plugins.py | 10 --- src/CMakeLists.txt | 1 - src/config.cc | 32 ++++++--- src/config.h | 5 +- src/files.h | 157 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 185 insertions(+), 170 deletions(-) delete mode 100644 config/config.json delete mode 100644 config/menu.xml delete mode 100644 config/plugins.py create mode 100644 src/files.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6229322..da710eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,17 +4,10 @@ set(project_name juci) set(module juci_to_python_api) #### TODO WINDOWS SUPPORT #### -set(juci_config_folder "$ENV{HOME}/.juci") set(bin_install_path "/usr/local/bin") set(lib_install_path "/usr/local/lib/python2.7/dist-packages/") ##### project (${project_name}) -add_subdirectory("src") - -install( - DIRECTORY "config" "plugins" - DESTINATION ${juci_config_folder} - USE_SOURCE_PERMISSIONS) -install(CODE "FILE(MAKE_DIRECTORY ${juci_config_filder}/log)") +add_subdirectory("src") \ No newline at end of file diff --git a/config/config.json b/config/config.json deleted file mode 100644 index 0c85f6d..0000000 --- a/config/config.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "source": { - "colors": { - "text_color": "black", - "string": "#CC0000", - "namespace_ref": "#990099", - "type": "#0066FF", - "keyword": "blue", - "comment": "grey", - "own": "pink", - "diagnostic_warning": "orange", - "diagnostic_error": "red" - }, - "syntax": { - "43": "type", - "46": "namespace_ref", - "109": "string", - "702": "keyword", - "703": "own", - "705": "comment" - }, - "extensions": [ - "c", - "cc", - "cpp", - "cxx", - "c++", - "h", - "hh", - "hpp", - "hxx", - "h++" - ], - "visual": { - "background": "white", - "background_selected": "blue", - "background_tooltips": "yellow", - "font": "Monospace", - "show_line_numbers": 1, - "highlight_current_line": 1 - }, - "tab_size": 2, - "tab_char": "" - }, - "keybindings": { - "new_file": "n", - "open_folder": "o", - "open_file": "o", - "save": "s", - "save_as": "s", - "quit": "q", - "split_window": "s", - "close_tab": "w", - "edit_copy": "c", - "edit_cut": "x", - "edit_paste": "v", - "edit_undo": "z", - "edit_redo": "z", - "edit_find": "f", - "source_goto_declaration": "d", - "source_goto_method": "m", - "source_rename": "r", - "compile_and_run": "Return", - "compile": "Return" - }, - "directoryfilter": { - "ignore": [ - "cmake", - "#", - "~", - ".idea", - ".so", - "in-lowercase.pls" - ], - "exceptions": [ - "cmakelists.txt", - "in-lowercase.pls" - ] - }, - "project": { - "run_commands": [ - "./.build/" - ], - "compile_commands": [ - "rm -rf ./.build", - "mkdir ./.build", - "cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -B./.build -H.", - "cd ./.build/; make", - "cp ./.build/compile_commands.json compile_commands.json" - ] - }, - "example": { - "key": "value", - "key2": [ - "val1", - "val2", - 3 - ], - "key3": "value" - } -} diff --git a/config/menu.xml b/config/menu.xml deleted file mode 100644 index d93305f..0000000 --- a/config/menu.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/plugins.py b/config/plugins.py deleted file mode 100644 index e19fff9..0000000 --- a/config/plugins.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/python -import juci_to_python_api as juci -import glob - -def loadplugins(): - plugin_files = glob.glob("../plugins/*.py") - for current_file in plugin_files: - juci.initPlugin(current_file) -loadplugins() - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 79323c8..54c9549 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -119,6 +119,5 @@ if(${validation}) RUNTIME DESTINATION ${bin_install_path} LIBRARY DESTINATION ${lib_install_path} ) - endif(${validation}) diff --git a/src/config.cc b/src/config.cc index b71cbf5..8671110 100644 --- a/src/config.cc +++ b/src/config.cc @@ -3,24 +3,40 @@ #include "logging.h" #include #include +#include #include - +#include "files.h" MainConfig::MainConfig() { - INFO("Reading config file"); - boost::property_tree::json_parser::read_json(Singleton::config_dir() + "config.json", cfg_); - INFO("Config file read"); + find_or_create_config_files(); + boost::property_tree::json_parser::read_json(Singleton::config_dir() + "config.json", cfg); GenerateSource(); GenerateKeybindings(); GenerateDirectoryFilter(); GenerateTerminalCommands(); } +void MainConfig::find_or_create_config_files() { + std::vector files = {"config.json", "menu.xml", "plugins.py"}; + boost::filesystem::create_directories(boost::filesystem::path(Singleton::config_dir())); + for (auto &file : files) { + auto path = boost::filesystem::path(Singleton::config_dir() + file); + if (!boost::filesystem::is_regular_file(path)) { + std::ofstream output; + output.open(path.string()); + if (file == "config.json") output << configjson; + if (file == "plugins.py") output << pluginspy; + if (file == "menu.xml") output << menuxml; + output.close(); + } + } +} + void MainConfig::GenerateSource() { auto source_cfg=Singleton::Config::source(); DEBUG("Fetching source cfg"); // boost::property_tree::ptree - auto source_json = cfg_.get_child("source"); + auto source_json = cfg.get_child("source"); auto syntax_json = source_json.get_child("syntax"); auto colors_json = source_json.get_child("colors"); auto extensions_json = source_json.get_child("extensions"); @@ -63,7 +79,7 @@ void MainConfig::GenerateSource() { void MainConfig::GenerateTerminalCommands() { auto terminal_cfg=Singleton::Config::terminal(); - boost::property_tree::ptree source_json = cfg_.get_child("project"); + boost::property_tree::ptree source_json = cfg.get_child("project"); boost::property_tree::ptree compile_commands_json = source_json.get_child("compile_commands"); boost::property_tree::ptree run_commands_json = source_json.get_child("run_commands"); for (auto &i : compile_commands_json) { @@ -87,7 +103,7 @@ void MainConfig::GenerateKeybindings() { while (getline(input, line)) menu->ui += line; } - boost::property_tree::ptree keys_json = cfg_.get_child("keybindings"); + boost::property_tree::ptree keys_json = cfg.get_child("keybindings"); for (auto &i : keys_json) { auto key=i.second.get_value(); menu->key_map[i.first] = key; @@ -98,7 +114,7 @@ void MainConfig::GenerateKeybindings() { void MainConfig::GenerateDirectoryFilter() { auto dir_cfg=Singleton::Config::directories(); DEBUG("Fetching directory filter"); - boost::property_tree::ptree dir_json = cfg_.get_child("directoryfilter"); + boost::property_tree::ptree dir_json = cfg.get_child("directoryfilter"); boost::property_tree::ptree ignore_json = dir_json.get_child("ignore"); boost::property_tree::ptree except_json = dir_json.get_child("exceptions"); for ( auto &i : except_json ) diff --git a/src/config.h b/src/config.h index 9729467..9f97a90 100644 --- a/src/config.h +++ b/src/config.h @@ -6,13 +6,14 @@ class MainConfig { public: MainConfig(); + void find_or_create_config_files(); void PrintMenu(); void GenerateSource(); void GenerateKeybindings(); void GenerateDirectoryFilter(); void GenerateTerminalCommands(); private: - boost::property_tree::ptree cfg_; - boost::property_tree::ptree key_tree_; + boost::property_tree::ptree cfg; + boost::property_tree::ptree key_tree; }; #endif diff --git a/src/files.h b/src/files.h new file mode 100644 index 0000000..dde0b17 --- /dev/null +++ b/src/files.h @@ -0,0 +1,157 @@ +#include +const std::string configjson = +"{\n" +" \"source\": {\n" +" \"colors\": {\n" +" \"text_color\": \"black\",\n" +" \"string\": \"#CC0000\",\n" +" \"namespace_ref\": \"#990099\",\n" +" \"type\": \"#0066FF\",\n" +" \"keyword\": \"blue\",\n" +" \"comment\": \"grey\",\n" +" \"own\": \"pink\",\n" +" \"diagnostic_warning\": \"orange\",\n" +" \"diagnostic_error\": \"red\"\n" +" },\n" +" \"syntax\": {\n" +" \"43\": \"type\",\n" +" \"46\": \"namespace_ref\",\n" +" \"109\": \"string\",\n" +" \"702\": \"keyword\",\n" +" \"703\": \"own\",\n" +" \"705\": \"comment\"\n" +" },\n" +" \"extensions\": [\n" +" \"c\",\n" +" \"cc\",\n" +" \"cpp\",\n" +" \"cxx\",\n" +" \"c++\",\n" +" \"h\",\n" +" \"hh\",\n" +" \"hpp\",\n" +" \"hxx\",\n" +" \"h++\"\n" +" ],\n" +" \"visual\": {\n" +" \"background\": \"white\",\n" +" \"background_selected\": \"blue\",\n" +" \"background_tooltips\": \"yellow\",\n" +" \"font\": \"Monospace\",\n" +" \"show_line_numbers\": 1,\n" +" \"highlight_current_line\": 1\n" +" },\n" +" \"tab_size\": 2,\n" +" \"tab_char\": \"\"\n" +" },\n" +" \"keybindings\": {\n" +" \"new_file\": \"n\",\n" +" \"open_folder\": \"o\",\n" +" \"open_file\": \"o\",\n" +" \"save\": \"s\",\n" +" \"save_as\": \"s\",\n" +" \"quit\": \"q\",\n" +" \"split_window\": \"s\",\n" +" \"close_tab\": \"w\",\n" +" \"edit_copy\": \"c\",\n" +" \"edit_cut\": \"x\",\n" +" \"edit_paste\": \"v\",\n" +" \"edit_undo\": \"z\",\n" +" \"edit_redo\": \"z\",\n" +" \"edit_find\": \"f\",\n" +" \"source_goto_declaration\": \"d\",\n" +" \"source_goto_method\": \"m\",\n" +" \"source_rename\": \"r\",\n" +" \"compile_and_run\": \"Return\",\n" +" \"compile\": \"Return\"\n" +" },\n" +" \"directoryfilter\": {\n" +" \"ignore\": [\n" +" \"cmake\",\n" +" \"#\",\n" +" \"~\",\n" +" \".idea\",\n" +" \".so\",\n" +" \"in-lowercase.pls\"\n" +" ],\n" +" \"exceptions\": [\n" +" \"cmakelists.txt\",\n" +" \"in-lowercase.pls\"\n" +" ]\n" +" },\n" +" \"project\": {\n" +" \"run_commands\": [\n" +" \"./.build/\"\n" +" ],\n" +" \"compile_commands\": [\n" +" \"rm -rf ./.build\",\n" +" \"mkdir ./.build\",\n" +" \"cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -B./.build -H.\",\n" +" \"cd ./.build/; make\",\n" +" \"cp ./.build/compile_commands.json compile_commands.json\"\n" +" ]\n" +" },\n" +" \"example\": {\n" +" \"key\": \"value\",\n" +" \"key2\": [\n" +" \"val1\",\n" +" \"val2\",\n" +" 3\n" +" ],\n" +" \"key3\": \"value\"\n" +" }\n" +"}\n"; + +const std::string menuxml = +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n"; + +const std::string pluginspy = +"#!/usr/bin/python \n" +"import juci_to_python_api as juci \n" +"import glob \n" +"\n" +"def loadplugins(): \n" +" plugin_files = glob.glob(\"../plugins/*.py\") \n" +" for current_file in plugin_files: \n" +" juci.initPlugin(current_file) \n" +"loadplugins() \n"; + From 9b7d338b6b2cfe07acd799d44dce2f9eb3e45a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 29 Jul 2015 21:25:14 +0200 Subject: [PATCH 13/15] Make install complete --- CMakeLists.txt | 9 +-- config/config.json | 101 ----------------------------- config/menu.xml | 40 ------------ config/plugins.py | 10 --- src/CMakeLists.txt | 1 - src/config.cc | 32 ++++++--- src/config.h | 5 +- src/files.h | 157 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 185 insertions(+), 170 deletions(-) delete mode 100644 config/config.json delete mode 100644 config/menu.xml delete mode 100644 config/plugins.py create mode 100644 src/files.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6229322..da710eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,17 +4,10 @@ set(project_name juci) set(module juci_to_python_api) #### TODO WINDOWS SUPPORT #### -set(juci_config_folder "$ENV{HOME}/.juci") set(bin_install_path "/usr/local/bin") set(lib_install_path "/usr/local/lib/python2.7/dist-packages/") ##### project (${project_name}) -add_subdirectory("src") - -install( - DIRECTORY "config" "plugins" - DESTINATION ${juci_config_folder} - USE_SOURCE_PERMISSIONS) -install(CODE "FILE(MAKE_DIRECTORY ${juci_config_filder}/log)") +add_subdirectory("src") \ No newline at end of file diff --git a/config/config.json b/config/config.json deleted file mode 100644 index 0c85f6d..0000000 --- a/config/config.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "source": { - "colors": { - "text_color": "black", - "string": "#CC0000", - "namespace_ref": "#990099", - "type": "#0066FF", - "keyword": "blue", - "comment": "grey", - "own": "pink", - "diagnostic_warning": "orange", - "diagnostic_error": "red" - }, - "syntax": { - "43": "type", - "46": "namespace_ref", - "109": "string", - "702": "keyword", - "703": "own", - "705": "comment" - }, - "extensions": [ - "c", - "cc", - "cpp", - "cxx", - "c++", - "h", - "hh", - "hpp", - "hxx", - "h++" - ], - "visual": { - "background": "white", - "background_selected": "blue", - "background_tooltips": "yellow", - "font": "Monospace", - "show_line_numbers": 1, - "highlight_current_line": 1 - }, - "tab_size": 2, - "tab_char": "" - }, - "keybindings": { - "new_file": "n", - "open_folder": "o", - "open_file": "o", - "save": "s", - "save_as": "s", - "quit": "q", - "split_window": "s", - "close_tab": "w", - "edit_copy": "c", - "edit_cut": "x", - "edit_paste": "v", - "edit_undo": "z", - "edit_redo": "z", - "edit_find": "f", - "source_goto_declaration": "d", - "source_goto_method": "m", - "source_rename": "r", - "compile_and_run": "Return", - "compile": "Return" - }, - "directoryfilter": { - "ignore": [ - "cmake", - "#", - "~", - ".idea", - ".so", - "in-lowercase.pls" - ], - "exceptions": [ - "cmakelists.txt", - "in-lowercase.pls" - ] - }, - "project": { - "run_commands": [ - "./.build/" - ], - "compile_commands": [ - "rm -rf ./.build", - "mkdir ./.build", - "cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -B./.build -H.", - "cd ./.build/; make", - "cp ./.build/compile_commands.json compile_commands.json" - ] - }, - "example": { - "key": "value", - "key2": [ - "val1", - "val2", - 3 - ], - "key3": "value" - } -} diff --git a/config/menu.xml b/config/menu.xml deleted file mode 100644 index d93305f..0000000 --- a/config/menu.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/plugins.py b/config/plugins.py deleted file mode 100644 index e19fff9..0000000 --- a/config/plugins.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/python -import juci_to_python_api as juci -import glob - -def loadplugins(): - plugin_files = glob.glob("../plugins/*.py") - for current_file in plugin_files: - juci.initPlugin(current_file) -loadplugins() - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 79323c8..54c9549 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -119,6 +119,5 @@ if(${validation}) RUNTIME DESTINATION ${bin_install_path} LIBRARY DESTINATION ${lib_install_path} ) - endif(${validation}) diff --git a/src/config.cc b/src/config.cc index b71cbf5..8671110 100644 --- a/src/config.cc +++ b/src/config.cc @@ -3,24 +3,40 @@ #include "logging.h" #include #include +#include #include - +#include "files.h" MainConfig::MainConfig() { - INFO("Reading config file"); - boost::property_tree::json_parser::read_json(Singleton::config_dir() + "config.json", cfg_); - INFO("Config file read"); + find_or_create_config_files(); + boost::property_tree::json_parser::read_json(Singleton::config_dir() + "config.json", cfg); GenerateSource(); GenerateKeybindings(); GenerateDirectoryFilter(); GenerateTerminalCommands(); } +void MainConfig::find_or_create_config_files() { + std::vector files = {"config.json", "menu.xml", "plugins.py"}; + boost::filesystem::create_directories(boost::filesystem::path(Singleton::config_dir())); + for (auto &file : files) { + auto path = boost::filesystem::path(Singleton::config_dir() + file); + if (!boost::filesystem::is_regular_file(path)) { + std::ofstream output; + output.open(path.string()); + if (file == "config.json") output << configjson; + if (file == "plugins.py") output << pluginspy; + if (file == "menu.xml") output << menuxml; + output.close(); + } + } +} + void MainConfig::GenerateSource() { auto source_cfg=Singleton::Config::source(); DEBUG("Fetching source cfg"); // boost::property_tree::ptree - auto source_json = cfg_.get_child("source"); + auto source_json = cfg.get_child("source"); auto syntax_json = source_json.get_child("syntax"); auto colors_json = source_json.get_child("colors"); auto extensions_json = source_json.get_child("extensions"); @@ -63,7 +79,7 @@ void MainConfig::GenerateSource() { void MainConfig::GenerateTerminalCommands() { auto terminal_cfg=Singleton::Config::terminal(); - boost::property_tree::ptree source_json = cfg_.get_child("project"); + boost::property_tree::ptree source_json = cfg.get_child("project"); boost::property_tree::ptree compile_commands_json = source_json.get_child("compile_commands"); boost::property_tree::ptree run_commands_json = source_json.get_child("run_commands"); for (auto &i : compile_commands_json) { @@ -87,7 +103,7 @@ void MainConfig::GenerateKeybindings() { while (getline(input, line)) menu->ui += line; } - boost::property_tree::ptree keys_json = cfg_.get_child("keybindings"); + boost::property_tree::ptree keys_json = cfg.get_child("keybindings"); for (auto &i : keys_json) { auto key=i.second.get_value(); menu->key_map[i.first] = key; @@ -98,7 +114,7 @@ void MainConfig::GenerateKeybindings() { void MainConfig::GenerateDirectoryFilter() { auto dir_cfg=Singleton::Config::directories(); DEBUG("Fetching directory filter"); - boost::property_tree::ptree dir_json = cfg_.get_child("directoryfilter"); + boost::property_tree::ptree dir_json = cfg.get_child("directoryfilter"); boost::property_tree::ptree ignore_json = dir_json.get_child("ignore"); boost::property_tree::ptree except_json = dir_json.get_child("exceptions"); for ( auto &i : except_json ) diff --git a/src/config.h b/src/config.h index 9729467..9f97a90 100644 --- a/src/config.h +++ b/src/config.h @@ -6,13 +6,14 @@ class MainConfig { public: MainConfig(); + void find_or_create_config_files(); void PrintMenu(); void GenerateSource(); void GenerateKeybindings(); void GenerateDirectoryFilter(); void GenerateTerminalCommands(); private: - boost::property_tree::ptree cfg_; - boost::property_tree::ptree key_tree_; + boost::property_tree::ptree cfg; + boost::property_tree::ptree key_tree; }; #endif diff --git a/src/files.h b/src/files.h new file mode 100644 index 0000000..dde0b17 --- /dev/null +++ b/src/files.h @@ -0,0 +1,157 @@ +#include +const std::string configjson = +"{\n" +" \"source\": {\n" +" \"colors\": {\n" +" \"text_color\": \"black\",\n" +" \"string\": \"#CC0000\",\n" +" \"namespace_ref\": \"#990099\",\n" +" \"type\": \"#0066FF\",\n" +" \"keyword\": \"blue\",\n" +" \"comment\": \"grey\",\n" +" \"own\": \"pink\",\n" +" \"diagnostic_warning\": \"orange\",\n" +" \"diagnostic_error\": \"red\"\n" +" },\n" +" \"syntax\": {\n" +" \"43\": \"type\",\n" +" \"46\": \"namespace_ref\",\n" +" \"109\": \"string\",\n" +" \"702\": \"keyword\",\n" +" \"703\": \"own\",\n" +" \"705\": \"comment\"\n" +" },\n" +" \"extensions\": [\n" +" \"c\",\n" +" \"cc\",\n" +" \"cpp\",\n" +" \"cxx\",\n" +" \"c++\",\n" +" \"h\",\n" +" \"hh\",\n" +" \"hpp\",\n" +" \"hxx\",\n" +" \"h++\"\n" +" ],\n" +" \"visual\": {\n" +" \"background\": \"white\",\n" +" \"background_selected\": \"blue\",\n" +" \"background_tooltips\": \"yellow\",\n" +" \"font\": \"Monospace\",\n" +" \"show_line_numbers\": 1,\n" +" \"highlight_current_line\": 1\n" +" },\n" +" \"tab_size\": 2,\n" +" \"tab_char\": \"\"\n" +" },\n" +" \"keybindings\": {\n" +" \"new_file\": \"n\",\n" +" \"open_folder\": \"o\",\n" +" \"open_file\": \"o\",\n" +" \"save\": \"s\",\n" +" \"save_as\": \"s\",\n" +" \"quit\": \"q\",\n" +" \"split_window\": \"s\",\n" +" \"close_tab\": \"w\",\n" +" \"edit_copy\": \"c\",\n" +" \"edit_cut\": \"x\",\n" +" \"edit_paste\": \"v\",\n" +" \"edit_undo\": \"z\",\n" +" \"edit_redo\": \"z\",\n" +" \"edit_find\": \"f\",\n" +" \"source_goto_declaration\": \"d\",\n" +" \"source_goto_method\": \"m\",\n" +" \"source_rename\": \"r\",\n" +" \"compile_and_run\": \"Return\",\n" +" \"compile\": \"Return\"\n" +" },\n" +" \"directoryfilter\": {\n" +" \"ignore\": [\n" +" \"cmake\",\n" +" \"#\",\n" +" \"~\",\n" +" \".idea\",\n" +" \".so\",\n" +" \"in-lowercase.pls\"\n" +" ],\n" +" \"exceptions\": [\n" +" \"cmakelists.txt\",\n" +" \"in-lowercase.pls\"\n" +" ]\n" +" },\n" +" \"project\": {\n" +" \"run_commands\": [\n" +" \"./.build/\"\n" +" ],\n" +" \"compile_commands\": [\n" +" \"rm -rf ./.build\",\n" +" \"mkdir ./.build\",\n" +" \"cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -B./.build -H.\",\n" +" \"cd ./.build/; make\",\n" +" \"cp ./.build/compile_commands.json compile_commands.json\"\n" +" ]\n" +" },\n" +" \"example\": {\n" +" \"key\": \"value\",\n" +" \"key2\": [\n" +" \"val1\",\n" +" \"val2\",\n" +" 3\n" +" ],\n" +" \"key3\": \"value\"\n" +" }\n" +"}\n"; + +const std::string menuxml = +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n"; + +const std::string pluginspy = +"#!/usr/bin/python \n" +"import juci_to_python_api as juci \n" +"import glob \n" +"\n" +"def loadplugins(): \n" +" plugin_files = glob.glob(\"../plugins/*.py\") \n" +" for current_file in plugin_files: \n" +" juci.initPlugin(current_file) \n" +"loadplugins() \n"; + From b78b077f5487dfa728644d8179d98f272b493c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 29 Jul 2015 21:40:02 +0200 Subject: [PATCH 14/15] Use singleton path instead --- src/api.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/api.cc b/src/api.cc index 6d6b9e2..b1ac39b 100644 --- a/src/api.cc +++ b/src/api.cc @@ -51,8 +51,7 @@ std::string PluginApi::GetWord() { } void PluginApi::InitPlugins() { - std::string path(getenv("HOME")); - libjuci::LoadPlugin(path + "/.juci/config/plugins.py"); + libjuci::LoadPlugin(Singleton::config_dir() + "plugins.py"); } void PluginApi::AddMenuElement(std::string plugin_name) { From 4a64d09c51e06482ff53e8ddbf70d62e4838a1ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 29 Jul 2015 22:01:18 +0200 Subject: [PATCH 15/15] Update readme to fit new features --- README.md | 42 ++++++++++++++++++------------------------ docs/install.md | 23 +++++++++-------------- 2 files changed, 27 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 362e9c8..3823f43 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,20 @@ # juCi++ ###### a lightweight C++-IDE with support for C++11 and C++14. ## About -juCi++ is a lightweight C++-IDE written in C++. You can write plugins -in Python and configure the IDE from the config.json file. - - -## Autocompletion -The IDE supports autocompletion on accessor specifiers such as dot and arrow. The autocompletion has excellent support for C++11/14. - -## Syntax Highlighting -The IDE also supports syntax highligthing even in C++11 and C++14. - -## To get C++11 and C++14 support -If you want support for external libraries and C++11 and C++14 you need to make sure you add a parameter to the cmake command. This will make compile_commands.json wich tells juCi++ all the paramters for the compiler. There is a bug where juCi++ sometimes puts the compile_commands.json file in the incorrect folder. Please make sure this file exists and that the contents of it covers all your files. -```sh -$ cmake . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -``` - -## Plugins -There are expansion oppertunities with usage of python plugins. - -## Configuration -Configuration description will arrive shortly after source code is added. +A lot of IDEs struggle with good C++11/14 support. Therefore we +created juCi++. juCi++ is based of the compiler and will *always* +support new versions of C++. + +## Features +* Syntax highlighing (even C++11/14) +* Superfast autocomletion (even external libraries) +* Accurate refactoring across files +* Basic editor functionallity +* Highlighting of similar types +* write your own plugins in python (limited atm) ## Dependencies ## Please install these dependencies on your system. - * libboost-python-dev * libboost-filesystem-dev * libboost-log-dev @@ -43,6 +32,11 @@ Please install these dependencies on your system. * clang or gcc (compiler) ## Installation ## -See [installation guide](http://github.com/cppit/jucipp/blob/master/docs/install.md). - +Quickstart: +```sh +$ cmake . +$ make +$ sudo make install +``` +See [installation guide](http://github.com/cppit/jucipp/blob/master/docs/install.md) for more details. diff --git a/docs/install.md b/docs/install.md index 2713a3f..3e06b5e 100644 --- a/docs/install.md +++ b/docs/install.md @@ -1,27 +1,22 @@ # juCi++ ## Installation guide ## -## Linux +Before installation, please install libclangmm see [installation guide](http://github.com/cppit/libclangmm/blob/master/docs/install.md) for installation. +## Debian +First dependencies: ```sh -# Libraries (missing libclangmm, see [installation guide](http://github.com/cppit/libclangmm/blob/master/docs/install.md) for installation) $ sudo apt-get install libboost-python-dev libboost-filesystem-dev libboost-log-dev libboost-test-dev libboost-thread-dev libboost-system-dev libgtkmm-3.0-dev libgtksourceview2.0-dev libgtksourceviewmm-3.0-dev -libpython-dev libclang-dev -# Programs -$sudo apt-get install make cmake gcc - +libpython-dev libclang-dev make cmake gcc ``` -Compile +Install the project: ```sh -# When git clone -$ cd path-to-cloned-from-folder/jucipp/juci -# When download zipped file, extraxt it to a folder of your choice -$ cd path-to-folder-extraxted-into/jucipp-master/juci -# In both cases above you can choose remove the jucipp folder, but remeber to apply changes to cd command as well. +$ git clone http://github.com/cppit/jucipp.git juci +$ cd juci $ cmake . $ make +$ sudo make install ``` - ## Run ```sh -$ ./bin/juci +$ juci ```