Browse Source

Fixes grep and ctags commands on bsd systems

pipelines/143601543
eidheim 6 years ago
parent
commit
22b62fdde2
  1. 5
      CMakeLists.txt
  2. 1
      src/CMakeLists.txt
  3. 11
      src/files.h
  4. 9
      src/grep.cc
  5. 4
      tests/ctags_grep_test.cc

5
CMakeLists.txt

@ -98,6 +98,11 @@ else()
message("liblldb not found. Building juCi++ without debugging support") message("liblldb not found. Building juCi++ without debugging support")
endif() endif()
if(CMAKE_SYSTEM_NAME MATCHES .*BSD|DragonFly)
add_definitions(-DJUCI_USE_UCTAGS) # See https://svnweb.freebsd.org/ports?view=revision&revision=452957
add_definitions(-DJUCI_USE_GREP_EXCLUDE) # --exclude-dir is not an argument in bsd grep
endif()
# For both src and tests targets # For both src and tests targets
include_directories( include_directories(
${Boost_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}

1
src/CMakeLists.txt

@ -65,7 +65,6 @@ if(APPLE)
target_link_libraries(juci "-framework Foundation -framework AppKit") target_link_libraries(juci "-framework Foundation -framework AppKit")
endif() endif()
install(TARGETS juci RUNTIME DESTINATION bin) install(TARGETS juci RUNTIME DESTINATION bin)
if(${CMAKE_SYSTEM_NAME} MATCHES Linux|.*BSD|DragonFly) if(${CMAKE_SYSTEM_NAME} MATCHES Linux|.*BSD|DragonFly)
install(FILES "${CMAKE_SOURCE_DIR}/share/juci.desktop" install(FILES "${CMAKE_SOURCE_DIR}/share/juci.desktop"

11
src/files.h

@ -191,8 +191,15 @@ const std::string default_config_file = R"RAW({
"default_build_management_system_comment": "Select which build management system to use when creating a new C or C++ project, for instance \"cmake\" or \"meson\"", "default_build_management_system_comment": "Select which build management system to use when creating a new C or C++ project, for instance \"cmake\" or \"meson\"",
"default_build_management_system": "cmake", "default_build_management_system": "cmake",
"save_on_compile_or_run": true, "save_on_compile_or_run": true,
"clear_terminal_on_compile": true, "clear_terminal_on_compile": true,)RAW"
"ctags_command": "ctags", #ifdef JUCI_USE_UCTAGS
R"RAW(
"ctags_command": "uctags",)RAW"
#else
R"RAW(
"ctags_command": "ctags",)RAW"
#endif
R"RAW(
"grep_command": "grep", "grep_command": "grep",
"python_command": "PYTHONUNBUFFERED=1 python", "python_command": "PYTHONUNBUFFERED=1 python",
"markdown_command": "grip -b" "markdown_command": "grip -b"

9
src/grep.cc

@ -6,11 +6,20 @@
Grep::Grep(const boost::filesystem::path &path, const std::string &pattern, bool case_sensitive, bool extended_regex) { Grep::Grep(const boost::filesystem::path &path, const std::string &pattern, bool case_sensitive, bool extended_regex) {
auto build = Project::Build::create(path); auto build = Project::Build::create(path);
#ifdef JUCI_USE_GREP_EXCLUDE
std::string exclude = "--exclude=node_modules/*";
#else
std::string exclude = "--exclude-dir=node_modules"; std::string exclude = "--exclude-dir=node_modules";
#endif
if(!build->project_path.empty()) { if(!build->project_path.empty()) {
project_path = build->project_path; project_path = build->project_path;
#ifdef JUCI_USE_GREP_EXCLUDE
exclude += " --exclude=" + filesystem::escape_argument(filesystem::get_relative_path(build->get_default_path(), build->project_path).string()) + "/*";
exclude += " --exclude=" + filesystem::escape_argument(filesystem::get_relative_path(build->get_debug_path(), build->project_path).string()) + "/*";
#else
exclude += " --exclude-dir=" + filesystem::escape_argument(filesystem::get_relative_path(build->get_default_path(), build->project_path).string()); exclude += " --exclude-dir=" + filesystem::escape_argument(filesystem::get_relative_path(build->get_default_path(), build->project_path).string());
exclude += " --exclude-dir=" + filesystem::escape_argument(filesystem::get_relative_path(build->get_debug_path(), build->project_path).string()); exclude += " --exclude-dir=" + filesystem::escape_argument(filesystem::get_relative_path(build->get_debug_path(), build->project_path).string());
#endif
} }
else else
project_path = path; project_path = path;

4
tests/ctags_grep_test.cc

@ -14,7 +14,11 @@ class Test {
int main() { int main() {
auto app = Gtk::Application::create(); auto app = Gtk::Application::create();
#ifdef JUCI_USE_UCTAGS
Config::get().project.ctags_command = "uctags";
#else
Config::get().project.ctags_command = "ctags"; Config::get().project.ctags_command = "ctags";
#endif
Config::get().project.grep_command = "grep"; Config::get().project.grep_command = "grep";
Config::get().project.debug_build_path = "build"; Config::get().project.debug_build_path = "build";

Loading…
Cancel
Save