From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id AEaOF28ZgGNO5AAAbAwnHQ (envelope-from ) for ; Fri, 25 Nov 2022 02:25:03 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id aB2LF28ZgGPdggAAauVa8A (envelope-from ) for ; Fri, 25 Nov 2022 02:25:03 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2975327596 for ; Fri, 25 Nov 2022 02:25:03 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oyNRp-0006Vr-Gz; Thu, 24 Nov 2022 20:24: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 1oyNRi-0006Pr-2l for guix-patches@gnu.org; Thu, 24 Nov 2022 20:24: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 1oyNRh-0004ra-P0 for guix-patches@gnu.org; Thu, 24 Nov 2022 20:24:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oyNRh-0000T7-Ky for guix-patches@gnu.org; Thu, 24 Nov 2022 20:24:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#49946] [PATCH v7 30/32] gnu: Add emacs-tree-sitter-core. Resent-From: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 25 Nov 2022 01:24:01 +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.16693394001709 (code B ref 49946); Fri, 25 Nov 2022 01:24:01 +0000 Received: (at 49946) by debbugs.gnu.org; 25 Nov 2022 01:23:20 +0000 Received: from localhost ([127.0.0.1]:60843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyNQn-0000Og-HC for submit@debbugs.gnu.org; Thu, 24 Nov 2022 20:23:19 -0500 Received: from mout.gmx.net ([212.227.17.21]:36519) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyNQC-0000J8-Mj for 49946@debbugs.gnu.org; Thu, 24 Nov 2022 20:22:29 -0500 Received: from localhost.localdomain ([82.69.64.142]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MgvrB-1oXGnz3sab-00hKvL; Fri, 25 Nov 2022 02:22:23 +0100 From: Pierre Langlois Date: Fri, 25 Nov 2022 01:21:40 +0000 Message-Id: <20221125012142.22579-31-pierre.langlois@gmx.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221125012142.22579-1-pierre.langlois@gmx.com> References: <87mtfi63ut.fsf@gmx.com> <20221125012142.22579-1-pierre.langlois@gmx.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:x8pVT2+hWSLK/mhBNyh7pRAHPPLydmVXoppjZNZz9mi6102CPGt UqMyP8Ab2uSY3MyGYYR2lcLfPuhWA5uatiQ8PFnpfmcpjspjLSblVtjeKH0LGMXoS2WKUgI i/nO51ukAMnDJjj7wLCvFtaTC9MwsSCvZb38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r8ImAzQM5JE9 HydI/Zf/jYBPZHOrLvGpAlb0IUE= 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+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1669339503; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=sGUSvxvaqkF3wlMSDB9L9zNK5mkAl1mHnSQdVMIQ990=; b=OG2H2SVL/vl+rmlLuOwFWMZ/7cBBX09bokYJ1agDETNE4w/kyUWazv0H+hL1vTFv33jeb1 A3DqPt9zjw4VdT92whk0Rp3F8aeVIjI7QTGxcrXFTPXrHDCZko0LvAOQy0P55twYAvkLkO 7bpGv7yGcZFGxecDsiOlKioPJEHx5XqQycNspvYlhBhubieErhI8VC0V5UZLig5wRmE3W/ ELW+TgMONRkLOOqEffhWFtviyMp8DQBu5PVuDCNvY49dw0hxr68/sVztHuOazSMnzWE1pq RhVVeA077xAMGJQVoSwlolXncAyBnu+3e3EBwjO193+I5gchSa9UR2vETy5KtA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1669339503; a=rsa-sha256; cv=none; b=e7DgRy4Y4GH1MDrleNQ4sPFgMWu9nWqS7g8xYmN0VjTGsyEpNvFlFye96f/9H+B9CxIPF8 Yz2GWwoaM0RujKe4GvfmpWLS1vT1ZsG9YzDqOUSN4FVEe9trJQI/9FfvxNUx72jWNM09b0 v0dTUzaYXUfV0rWO7tV59ajDP9yv8LB03QNL9H1UVT7+3+znznG00+lS5AEnwuzNhLfUiG 5Y30eiyB2kipSE3duG2Z26DjVa8XhahArkaeDrnwXy0Mw7tTZSzJ+759utNbOZrMZmvNS+ y9nUKVdeKpuF/4U2cPsj1lDeZM2FGKIa01h+Eg4bprqq5kWS/5K1Bb1Jc3iQHw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmx.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 3.42 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmx.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 2975327596 X-Spam-Score: 3.42 X-Migadu-Scanner: scn1.migadu.com X-TUID: u/GsrXcwh8Fn * gnu/packages/tree-sitter.scm (tree-sitter-emacs-module): New local variable. (emacs-tree-sitter-core): New variable. --- gnu/packages/tree-sitter.scm | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm index d0214f3a12..d23fa2fbd8 100644 --- a/gnu/packages/tree-sitter.scm +++ b/gnu/packages/tree-sitter.scm @@ -21,6 +21,7 @@ (define-module (gnu packages tree-sitter) #:use-module (guix gexp) #:use-module ((guix licenses) #:prefix license:) #: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) @@ -738,3 +739,86 @@ (define-public tree-sitter-typescript "This package provides Typescript and TSX grammars for the Tree-sitter library.") (license license:expat))) + +;; 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 + `(#: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* (#:key outputs #:allow-other-keys) + (let ((lib (string-append (assoc-ref outputs "out") "/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 + `(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'chdir + (lambda _ (chdir "core"))) + (add-before 'install 'find-tsc-dyn + (lambda* (#:key inputs outputs #:allow-other-keys) + (let ((elpa (elpa-directory (assoc-ref outputs "out"))) + (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) + (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://github.com/emacs-tree-sitter/elisp-tree-sitter") + (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))) -- 2.38.1