From patchwork Fri Feb 17 12:37:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Langlois X-Patchwork-Id: 47033 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id BD3F616926; Fri, 17 Feb 2023 12:38:57 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4AEC7167D0 for ; Fri, 17 Feb 2023 12:38:56 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pT009-0003ns-CW; Fri, 17 Feb 2023 07:38:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pT003-0003ez-VE for guix-patches@gnu.org; Fri, 17 Feb 2023 07:38:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pT003-0000zl-Lm for guix-patches@gnu.org; Fri, 17 Feb 2023 07:38:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pT003-0001IT-Hp for guix-patches@gnu.org; Fri, 17 Feb 2023 07:38:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#49946] [PATCH v8 5/7] gnu: Add emacs-tree-sitter-core. Resent-From: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 17 Feb 2023 12:38:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49946 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49946@debbugs.gnu.org Cc: Pierre Langlois Received: via spool by 49946-submit@debbugs.gnu.org id=B49946.16766374604894 (code B ref 49946); Fri, 17 Feb 2023 12:38:03 +0000 Received: (at 49946) by debbugs.gnu.org; 17 Feb 2023 12:37:40 +0000 Received: from localhost ([127.0.0.1]:38705 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSzzg-0001Gm-1K for submit@debbugs.gnu.org; Fri, 17 Feb 2023 07:37:40 -0500 Received: from mout.gmx.net ([212.227.17.21]:46231) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSzzX-0001FI-GM for 49946@debbugs.gnu.org; Fri, 17 Feb 2023 07:37:33 -0500 Received: from localhost.localdomain ([82.69.64.142]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1N5mGB-1oUo0c2l5P-017Huj; Fri, 17 Feb 2023 13:37:25 +0100 From: Pierre Langlois Date: Fri, 17 Feb 2023 12:37:20 +0000 Message-Id: <20230217123722.15143-6-pierre.langlois@gmx.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230217123722.15143-1-pierre.langlois@gmx.com> References: <20221125012142.22579-1-pierre.langlois@gmx.com> <20230217123722.15143-1-pierre.langlois@gmx.com> MIME-Version: 1.0 X-Provags-ID: V03:K1:kqMHkrXCjaKeEDViNS/Ve88rziqhX1+bNq0uBm01oG4CHs+SEDF S1t6rZ/0Jig6rYLi88wGrEVWIqcBb25JHZnHitnOBuqcF0auBwxMLbCV9hqX0MUhMO/UVZc kt2wfalxRESxqJ+qdkCt+DjmlwfbJNwu+pcX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v7xK93vpFb6jwx9Y4tmakZgv/8s= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/tree-sitter.scm (tree-sitter-emacs-module): New local variable. (emacs-tree-sitter-core): New variable. --- gnu/packages/tree-sitter.scm | 85 ++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm index bb9972cb00..12f2d108d9 100644 --- a/gnu/packages/tree-sitter.scm +++ b/gnu/packages/tree-sitter.scm @@ -29,6 +29,7 @@ (define-module (gnu packages tree-sitter) #:use-module (gnu packages icu4c) #:use-module (gnu packages node) #:use-module (guix build-system cargo) + #:use-module (guix build-system emacs) #:use-module (guix build-system gnu) #:use-module (guix build-system tree-sitter) #:use-module (guix download) @@ -538,3 +539,87 @@ (define-public tree-sitter-racket (git-version "0.1.0" revision commit) #:repository-url "https://github.com/6cdh/tree-sitter-racket" #:commit commit))) + +;; Local package definition solely for building the native emacs module +;; written in Rust. +(define tree-sitter-emacs-module + (package + (name "tree-sitter-emacs-module") + (version "0.18.0") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/emacs-tree-sitter/elisp-tree-sitter") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1sdvz827v436qijs6xafakkfw2d16bvp8frymd818rppjc7a9dif")))) + (build-system cargo-build-system) + (inputs + (list tree-sitter)) + (arguments + (list + #:cargo-inputs + `(("rust-anyhow" ,rust-anyhow-1) + ("rust-emacs" ,rust-emacs-0.18) + ("rust-libloading" ,rust-libloading-0.7) + ("rust-once-cell" ,rust-once-cell-1) + ("rust-tree-sitter" ,rust-tree-sitter-for-emacs)) + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'chdir + (lambda _ (chdir "core"))) + (add-after 'chdir 'delete-cargo.lock + (lambda _ (delete-file "Cargo.lock"))) + (add-after 'delete-cargo.lock 'do-not-fetch-from-github + (lambda _ + (substitute* "Cargo.toml" + (("\\[patch.*") "") + (("git = .*") "")))) + (replace 'install + (lambda _ + (let ((lib (string-append #$output "/lib"))) + (mkdir-p lib) + (copy-file "target/release/libtsc_dyn.so" + (string-append lib "/tsc-dyn.so")))))))) + (home-page #f) + (synopsis #f) + (description #f) + (license license:expat))) + +(define-public emacs-tree-sitter-core + (package + (name "emacs-tree-sitter-core") + (version (package-version tree-sitter-emacs-module)) + (source (package-source tree-sitter-emacs-module)) + (build-system emacs-build-system) + (native-inputs + (list tree-sitter-emacs-module)) + (arguments + (list + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'chdir + (lambda _ (chdir "core"))) + (add-before 'install 'find-tsc-dyn + (lambda* (#:key inputs #:allow-other-keys) + (let ((module (search-input-file inputs "/lib/tsc-dyn.so"))) + ;; Install the tsc-dyn module in site-lisp and the current + ;; directory for test to pass. + (install-file module (elpa-directory #$output)) + (copy-file module "tsc-dyn.so") + ;; We replace the tsc-dyn-get.el file with an empty stub to + ;; prevent the code from downloading the module. + (call-with-output-file "tsc-dyn-get.el" + (lambda (port) + (for-each + (lambda (sexp) (write sexp port)) + '((defun tsc-dyn-get-ensure (requested) + nil) + (provide 'tsc-dyn-get))))))))))) + (home-page "https://emacs-tree-sitter.github.io") + (synopsis "Tree-sitter bindings for Emacs Lisp, core library") + (description "This package provides core APIs of the Emacs binding for +Tree-sitter, an incremental parsing system.") + (license license:expat)))