diff options
author | Ada Stevenson <adanskana@gmail.com> | 2025-07-15 15:19:03 +0800 |
---|---|---|
committer | Sharlatan Hellseher <sharlatanus@gmail.com> | 2025-07-27 10:08:15 +0100 |
commit | 63cd2324ddb26c13246c1575fc141d10e9c36145 (patch) | |
tree | e6c2621ea54bb064dd1b9d6ecac96cbb97d24ee3 | |
parent | 9b912bb666de116d3a807176a7239b73ecb39790 (diff) |
gnu: Add sourcetrail.
* gnu/packages/code.scm: Add sourcetrail. Update imports.
* gnu/packages/patches/sourcetrail-fix-cmakelists-and-paths.patch: Add patch.
* gnu/local.mk: Register it.
Change-Id: Ib074d392452a527552074e5329e8153a858979c9
Reviewed-by: Noé Lopez <noelopez@free.fr>
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
-rw-r--r-- | gnu/local.mk | 1 | ||||
-rw-r--r-- | gnu/packages/code.scm | 101 | ||||
-rw-r--r-- | gnu/packages/patches/sourcetrail-fix-cmakelists-and-paths.patch | 101 |
3 files changed, 202 insertions, 1 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index d57f03ffaa..4672492c92 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -2322,6 +2322,7 @@ dist_patch_DATA = \ %D%/packages/patches/snappy-add-O2-flag-in-CmakeLists.txt.patch \ %D%/packages/patches/snappy-add-inline-for-GCC.patch \ %D%/packages/patches/source-highlight-gcc-compat.patch \ + %D%/packages/patches/sourcetrail-fix-cmakelists-and-paths.patch \ %D%/packages/patches/softhsm-fix-openssl3-tests.patch \ %D%/packages/patches/spectre-meltdown-checker-externalize-fwdb.patch \ %D%/packages/patches/sphinxbase-fix-doxygen.patch \ diff --git a/gnu/packages/code.scm b/gnu/packages/code.scm index c4c423c846..ebd50309d5 100644 --- a/gnu/packages/code.scm +++ b/gnu/packages/code.scm @@ -23,6 +23,7 @@ ;;; Copyright © 2024 Artyom V. Poptsov <poptsov.artyom@gmail.com> ;;; Copyright © 2024 Jordan Moore <lockbox@struct.foo> ;;; Copyright © 2025 Nicolas Graves <ngraves@ngraves.fr> +;;; Copyright © 2025 Ada Stevenson <adanskana@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -88,7 +89,15 @@ #:use-module (gnu packages texinfo) #:use-module (gnu packages tls) #:use-module (gnu packages web) - #:use-module (gnu packages xml)) + #:use-module (gnu packages xml) + #:use-module (gnu packages boost) + #:use-module (gnu packages pretty-print) + #:use-module (gnu packages qt) + #:use-module (gnu packages regex) + #:use-module (gnu packages logging) + #:use-module (gnu packages check) + #:use-module (gnu packages cpp) + #:use-module (srfi srfi-1)) ;;; Tools to deal with source code: metrics, cross-references, etc. @@ -1079,6 +1088,96 @@ also be used for C++ code. Using cscope, you can easily search for where symbols are used and defined.") (license license:bsd-3))) +(define-public sourcetrail + (package + (name "sourcetrail") + (version "2.0.0") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/OpenSourceSourceTrail/Sourcetrail") + (commit version) + (recursive? #t))) + (patches (search-patches "sourcetrail-fix-cmakelists-and-paths.patch")) + (file-name (git-file-name name version)) + (sha256 + "06rp9ba9lkzwm8m7agzajg550h632kqb57bs9srvbgv411bkvgdd") + (modules '((guix build utils))) + (snippet #~(begin + (for-each delete-file-recursively + '(".conan" ".devcontainer" + ".github" + "conanfile.txt" + "scripts" + "bin/app/data/install" + "bin/app/user/log")))))) + (build-system cmake-build-system) + (arguments + (let* ((split-version (string-split version + (lambda (c) + (or (eqv? c #\.) + (eqv? c #\-))))) + (major-version (first split-version)) + (minor-version (second split-version)) + (version-patch (third split-version))) + (list #:configure-flags #~(list "-DENABLE_UNIT_TEST=true" + "-DENABLE_GUI_TEST=true" + "-DENABLE_INTERGRATION_TEST=true" + (string-append "-DVERSION_MAJOR=" + #$major-version) + (string-append "-DVERSION_MINOR=" + #$minor-version) + (string-append "-DVERSION_PATCH=" + #$version-patch) + "-DLLVM_ENABLE_PROJECTS:STRING=clang" + "-DLLVM_ENABLE_RTTI:BOOL=ON" + "-DCLANG_LINK_CLANG_DYLIB:BOOL=ON" + "-DLLVM_LINK_LLVM_DYLIB:BOOL=ON" + "-DLLVM_TARGETS_TO_BUILD=host" + "-DBUILD_CXX_LANGUAGE_PACKAGE=ON" + (string-append "-DClang_DIR=" + #$clang-19 + "/lib/cmake/clang")) + #:phases #~(modify-phases %standard-phases + (add-after 'unpack 'fix-paths + (lambda* (#:key inputs #:allow-other-keys) + (substitute* "src/lib_gui/tests/utilityAppTestSuite.cpp" + (("/usr/bin/bash") + (search-input-file inputs "/bin/bash"))) + (substitute* "CMakeLists.txt" + (("@OUTPUT_DIR@") + #$output)))) + (add-after 'install 'install-projects + (lambda _ + (let ((src (string-append #$output + "/share/sourcetrail/user/projects")) + (dst (string-append #$output:projects + "/share/sourcetrail/user/projects"))) + (copy-recursively src dst) + (delete-file-recursively src)))))))) + (inputs (list boost + clang-19 + expected-lite + qt5compat + qtbase + qtnetworkauth + qtsvg + qtwayland + range-v3 + spdlog-1.13 + sqlite + tinyxml)) + (native-inputs (list googletest)) + (home-page "https://github.com/OpenSourceSourceTrail/Sourcetrail") + (synopsis "Graphical cross-platform source code browser for C/C++") + (description + "Sourcetrail is a free and open-source cross-platform source explorer +that helps you get productive on unfamiliar source code. It includes support +for C/C++, providing a graphical means for discovering symbols and their place +in a project.") + (license license:gpl3))) + (define-public xenon (package (name "xenon") diff --git a/gnu/packages/patches/sourcetrail-fix-cmakelists-and-paths.patch b/gnu/packages/patches/sourcetrail-fix-cmakelists-and-paths.patch new file mode 100644 index 0000000000..15c813b81a --- /dev/null +++ b/gnu/packages/patches/sourcetrail-fix-cmakelists-and-paths.patch @@ -0,0 +1,101 @@ +Get rid of `clang-tidy.cmake` as it is not present in cmake installation. +Change SQLite3's `find_package` to `REQUIRED` as the `sqlite3` package does not provide a .cmake file, so we fall back to cmake's included definition. +We change the install directory to the store output rather than /usr. `@OUTPUT_DIR@` is substituted to the store path in an added phase. +For the /data and /user directories, we move them to /share/sourcetrail rather than leaving them in the /bin directory. + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b8b91d9c..d5dbdfa2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -69,7 +69,6 @@ include(cmake/create_symlink.cmake) + include(cmake/add_sourcetrail_library.cmake) + include(cmake/add_sourcetrail_interface.cmake) + include(cmake/add_sourcetrail_test.cmake) +-include(cmake/clang-tidy.cmake) + include(cmake/cppcheck.cmake) + include(cmake/coverage.cmake) + #--------------------------------------------------------------------------------------------------------------------------------- +@@ -142,12 +141,9 @@ find_package(expected-lite REQUIRED) + find_package(fmt CONFIG REQUIRED) + find_package(range-v3 CONFIG REQUIRED) + find_package(spdlog CONFIG REQUIRED) +-find_package(SQLite3 CONFIG REQUIRED) ++find_package(SQLite3 REQUIRED) + # Boost -------------------------------------------------------------------------------------------------------------------------- + set(Boost_USE_MULTITHREAD ON) +-set(Boost_USE_STATIC_LIBS +- ON +- CACHE BOOL "Set to ON to force the use of the static libraries.") + set(Boost_USE_STATIC_RUNTIME OFF) + find_package( + Boost 1.83 +@@ -384,14 +380,14 @@ execute_process(COMMAND "${CMAKE_COMMAND}" "-E" "make_directory" "${CMAKE_BINARY + create_symlink("${CMAKE_SOURCE_DIR}/bin/app/data" "${CMAKE_BINARY_DIR}/app/data") + create_symlink("${CMAKE_SOURCE_DIR}/bin/app/user" "${CMAKE_BINARY_DIR}/app/user") + # Install Executables ------------------------------------------------------------------------------------------------------------ +-set(APPIMAGE_ROOT "usr") ++set(APPIMAGE_ROOT "@OUTPUT_DIR@") + set(INSTALL_RUNTIME_DIR "${APPIMAGE_ROOT}/bin") + + install(TARGETS Sourcetrail Sourcetrail_indexer RUNTIME DESTINATION ${INSTALL_RUNTIME_DIR}) + +-install(DIRECTORY ${CMAKE_SOURCE_DIR}/bin/app/data/ DESTINATION ${INSTALL_RUNTIME_DIR}/data/) ++install(DIRECTORY ${CMAKE_SOURCE_DIR}/bin/app/data/ DESTINATION ${APPIMAGE_ROOT}/share/sourcetrail/data/) + +-install(DIRECTORY ${CMAKE_SOURCE_DIR}/bin/app/user/ DESTINATION ${INSTALL_RUNTIME_DIR}/user/) ++install(DIRECTORY ${CMAKE_SOURCE_DIR}/bin/app/user/ DESTINATION ${APPIMAGE_ROOT}/share/sourcetrail/user/) + + # Install desktop file for application + install(FILES "${CMAKE_SOURCE_DIR}/cmake/Sourcetrail.desktop" DESTINATION "${APPIMAGE_ROOT}/share/applications") + +We remove the sample projects from the default `ApplicationSettings.xml` as they do not function properly, requiring their installed directory to be mutable, +which is not possible in the store. They are installed in the `projects` package output. + +Submodule bin contains modified content +diff --git a/bin/app/data/fallback/ApplicationSettings.xml b/bin/app/data/fallback/ApplicationSettings.xml +index c1d3a78..33cf7d4 100644 +--- a/bin/app/data/fallback/ApplicationSettings.xml ++++ b/bin/app/data/fallback/ApplicationSettings.xml +@@ -9,10 +9,6 @@ + </indexing> + <user> + <recent_projects> +- <recent_project>./projects/tutorial/tutorial.srctrlprj</recent_project> +- <recent_project>./projects/tictactoe_cpp/tictactoe_cpp.srctrlprj</recent_project> +- <recent_project>./projects/tictactoe_py/tictactoe_py.srctrlprj</recent_project> +- <recent_project>./projects/javaparser/javaparser.srctrlprj</recent_project> + </recent_projects> + </user> + <version>8</version> +diff --git a/bin/app/user/ApplicationSettings.xml b/bin/app/user/ApplicationSettings.xml +index 7081ab0..755281f 100755 +--- a/bin/app/user/ApplicationSettings.xml ++++ b/bin/app/user/ApplicationSettings.xml +@@ -22,10 +22,6 @@ + </indexing>
+ <user>
+ <recent_projects>
+- <recent_project>C:/Hard/SourceCode/Sourcetrail/build/x64-Debug/Debug/app/user/./projects/tutorial/tutorial.srctrlprj</recent_project>
+- <recent_project>C:/Hard/SourceCode/Sourcetrail/build/x64-Debug/Debug/app/user/./projects/tictactoe_cpp/tictactoe_cpp.srctrlprj</recent_project>
+- <recent_project>C:/Hard/SourceCode/Sourcetrail/build/x64-Debug/Debug/app/user/./projects/tictactoe_py/tictactoe_py.srctrlprj</recent_project>
+- <recent_project>C:/Hard/SourceCode/Sourcetrail/build/x64-Debug/Debug/app/user/./projects/javaparser/javaparser.srctrlprj</recent_project>
+ </recent_projects>
+ </user>
+ <version>8</version>
+ +Set paths to /share/sourcetrail. + +diff --git a/src/lib_gui/platform_includes/includesLinux.h b/src/lib_gui/platform_includes/includesLinux.h +index 79e8be7f..5dadcca5 100644 +--- a/src/lib_gui/platform_includes/includesLinux.h ++++ b/src/lib_gui/platform_includes/includesLinux.h +@@ -43,6 +43,6 @@ inline void setupApp([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) { + AppPath::setCxxIndexerDirectoryPath(appPath); + + // Check if bundled as Linux AppImage +- if(appPath.getConcatenated(L"/../share/data").exists()) { +- AppPath::setSharedDataDirectoryPath(appPath.getConcatenated(L"/../share").getAbsolute()); ++ if(appPath.getConcatenated(L"/../share/sourcetrail/data").exists()) { ++ AppPath::setSharedDataDirectoryPath(appPath.getConcatenated(L"/../share/sourcetrail").getAbsolute()); + } + |