diff options
author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2020-03-27 21:21:37 -0400 |
---|---|---|
committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2020-05-27 13:46:49 -0400 |
commit | 9ea9e97b9c6d886151f4fd4394c315fda8efa9cb (patch) | |
tree | c37408a46aa26b1c66e9c9fdf4a7131cbfa86e95 | |
parent | c08f235b12900e8079677fe90d075f03867e0be2 (diff) |
gnu: Add emacs-libgit.
* gnu/packages/emacs-xyz.scm (emacs-libgit): New variable.
* gnu/packages/patches/emacs-libgit-use-system-libgit2.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register patch.
-rw-r--r-- | gnu/local.mk | 3 | ||||
-rw-r--r-- | gnu/packages/emacs-xyz.scm | 78 | ||||
-rw-r--r-- | gnu/packages/patches/emacs-libgit-use-system-libgit2.patch | 88 |
3 files changed, 167 insertions, 2 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index 3d5653b0b1..6be47b9a9a 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -19,7 +19,7 @@ # Copyright © 2018 Amirouche Boubekki <amirouche@hypermove.net> # Copyright © 2018, 2019, 2020 Oleg Pykhalov <go.wigust@gmail.com> # Copyright © 2018 Stefan Stefanović <stefanx2ovic@gmail.com> -# Copyright © 2018 Maxim Cournoyer <maxim.cournoyer@gmail.com> +# Copyright © 2018, 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com> # Copyright © 2019 Guillaume Le Vaillant <glv@posteo.net> # Copyright © 2019, 2020 John Soo <jsoo1@asu.edu> # Copyright © 2019 Jonathan Brielmaier <jonathan.brielmaier@web.de> @@ -886,6 +886,7 @@ dist_patch_DATA = \ %D%/packages/patches/emacs-fix-scheme-indent-function.patch \ %D%/packages/patches/emacs-json-reformat-fix-tests.patch \ %D%/packages/patches/emacs-highlight-stages-add-gexp.patch \ + %D%/packages/patches/emacs-libgit-use-system-libgit2.patch \ %D%/packages/patches/emacs-magit-log-format-author-margin.patch \ %D%/packages/patches/emacs-scheme-complete-scheme-r5rs-info.patch \ %D%/packages/patches/emacs-source-date-epoch.patch \ diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm index 45a10f4689..e6cbd44453 100644 --- a/gnu/packages/emacs-xyz.scm +++ b/gnu/packages/emacs-xyz.scm @@ -31,7 +31,7 @@ ;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com> ;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2017 Mike Gerwitz <mtg@gnu.org> -;;; Copyright © 2017, 2018, 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com> +;;; Copyright © 2017, 2018, 2019, 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; Copyright © 2018 Sohom Bhattacharjee <soham.bhattacharjee15@gmail.com> ;;; Copyright © 2018, 2019 Mathieu Lirzin <mthl@gnu.org> ;;; Copyright © 2018, 2019, 2020 Pierre Neidhardt <mail@ambrevar.xyz> @@ -318,6 +318,82 @@ For remote processes a substitute is provided, which communicates with Emacs on stdout instead of using a socket as the Emacsclient does.") (license license:gpl3+))) +(define-public emacs-libgit + (let ((commit "0ef8b13aef011a98b7da756e4f1ce3bb18e4d55a") + (revision "1")) + (package + (name "emacs-libgit") + (version (git-version "20200515" revision commit)) + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/magit/libegit2.git") + (commit commit))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0pnjr3bg6y6354dfjjxfj0g51swzgl1fncpprah75x4k94rd369f")) + (patches (search-patches + ;; Submitted for inclusion upstream (see: + ;; https://github.com/magit/libegit2/pull/96). + "emacs-libgit-use-system-libgit2.patch")))) + ;; Use the cmake-build-system as it provides support for cross builds. + (build-system cmake-build-system) + (arguments + `(#:configure-flags '("-DUSE_SYSTEM_LIBGIT2=x") + ;; Add the emacs-build-system byte compilation and install phases. + #:imported-modules (,@%cmake-build-system-modules + (guix build emacs-build-system) + (guix build emacs-utils)) + #:modules ((guix build cmake-build-system) + ((guix build emacs-build-system) #:prefix emacs:) + (guix build emacs-utils) + (guix build utils)) + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'set-libgit--module-file + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (make-file-writable "libgit.el") + (emacs-substitute-variables "libgit.el" + ("libgit--module-file" + (string-append out "/share/emacs/site-lisp/libegit2.so"))) + #t))) + (add-before 'install 'prepare-for-install + (lambda _ + (let ((s (string-append "../" ,name "-" ,version "-checkout"))) + (copy-file "libegit2.so" (string-append s "/libegit2.so")) + (chdir s) + #t))) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let ((install (assoc-ref emacs:%standard-phases 'install))) + (install #:outputs outputs + #:include (cons "\\.so$" + emacs:%default-include))))) + (add-after 'install 'make-autoloads + (assoc-ref emacs:%standard-phases 'make-autoloads)) + (add-after 'make-autoloads 'enable-autoloads-compilation + (assoc-ref emacs:%standard-phases 'enable-autoloads-compilation)) + (add-after 'enable-autoloads-compilation 'patch-el-files + (assoc-ref emacs:%standard-phases 'patch-el-files)) + (add-after 'patch-el-files 'emacs-build + (assoc-ref emacs:%standard-phases 'build)) + (add-after 'emacs-build 'validate-compiled-autoloads + (assoc-ref emacs:%standard-phases 'validate-compiled-autoloads))))) + (native-inputs + `(("pkg-config" ,pkg-config) + ("emacs" ,emacs-no-x) + ("git" ,git-minimal))) + (inputs + `(("libgit2" ,libgit2))) + (home-page "https://github.com/magit/libegit2") + (synopsis "Emacs bindings for libgit2") + (description "This is an experimental module written in C providing +libgit2 bindings for Emacs, intended to boost the performance of Magit.") + ;; The LICENSE file says GPL v2+, but libgit.el says GPL v3+. + (license license:gpl3+)))) + (define-public emacs-magit ;; `magit-setup-buffer' macro introduced in c761d28d and required in ;; `emacs-forge'. diff --git a/gnu/packages/patches/emacs-libgit-use-system-libgit2.patch b/gnu/packages/patches/emacs-libgit-use-system-libgit2.patch new file mode 100644 index 0000000000..4a5546b06b --- /dev/null +++ b/gnu/packages/patches/emacs-libgit-use-system-libgit2.patch @@ -0,0 +1,88 @@ +From de3c48d72ec7064e7f0522877fe759c729df0c50 Mon Sep 17 00:00:00 2001 +From: Maxim Cournoyer <maxim.cournoyer@gmail.com> +Date: Wed, 25 Mar 2020 11:32:18 -0400 +Subject: [PATCH] Allow using a system provided libgit2 library + +Setting the USE_SYSTEM_LIBGIT2 Make or CMake variable (through the +BUILD_OPTIONS variable) to any value enables using the system library. +The default behavior of using a bundled copy of libgit2 is unchanged. +--- + CMakeLists.txt | 9 +++++++-- + Makefile | 11 +++++++++++ + src/CMakeLists.txt | 9 +++++++-- + 3 files changed, 25 insertions(+), 4 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a393d7c..75d6ca6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -7,9 +7,14 @@ set(BUILD_SHARED_LIBS OFF CACHE BOOL "shared" FORCE) + set(BUILD_CLAR OFF CACHE BOOL "clar" FORCE) + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DEGIT_DEBUG") + +-add_subdirectory(libgit2) ++if(USE_SYSTEM_LIBGIT2) ++ find_package(PkgConfig REQUIRED) ++ pkg_check_modules(git2 REQUIRED IMPORTED_TARGET libgit2) ++else() ++ add_subdirectory(libgit2) ++ find_library(git2 libgit2.a) ++endif() + +-find_library(git2 libgit2.a) + add_subdirectory(src) + + enable_testing() +diff --git a/Makefile b/Makefile +index 8199532..6a6a4e1 100644 +--- a/Makefile ++++ b/Makefile +@@ -13,6 +13,13 @@ ifeq ($(UNAME),MSYS) + BUILD_OPTIONS+= -G "MSYS Makefiles" + endif + ++# If the variable USE_SYSTEM_LIBGIT2 is set to *any* value, use the ++# system provided libgit2 library. ++USE_SYSTEM_LIBGIT2? := \ ++ $(if $(or $(USE_SYSTEM_LIBGIT2),\ ++ $(findstring USE_SYSTEM_LIBGIT2,$(BUILD_OPTIONS))),\ ++ true) ++ + ifeq "$(TRAVIS)" "true" + ## Makefile for Travis ################################################### + # +@@ -87,7 +94,11 @@ submodule-update: + @git submodule update + + libgit2: ++ifeq ($(USE_SYSTEM_LIBGIT2?),) + @git submodule update --init ++else ++ @echo "Using the system provided libgit2 library" ++endif + + CLEAN = $(ELCS) $(PKG)-autoloads.el build + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index cfb5777..0dbad8a 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -13,8 +13,13 @@ if(WIN32) + set_target_properties(egit2 PROPERTIES PREFIX lib) + endif(WIN32) + +-target_link_libraries(egit2 git2) +-target_include_directories(egit2 SYSTEM PRIVATE "${libgit2_SOURCE_DIR}/include") ++if(USE_SYSTEM_LIBGIT2) ++ target_link_libraries(egit2 PRIVATE PkgConfig::git2) ++else() ++ target_link_libraries(egit2 git2) ++ target_include_directories( ++ egit2 SYSTEM PRIVATE "${libgit2_SOURCE_DIR}/include") ++endif() + + if(CMAKE_COMPILER_IS_GNUCC) + target_compile_options(egit2 PRIVATE -Wall -Wextra) +-- +2.26.2 + |