From patchwork Tue Mar 29 19:42:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Langlois X-Patchwork-Id: 38181 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 28E5627BBEB; Tue, 29 Mar 2022 20:44:23 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,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 6FB1127BBEA for ; Tue, 29 Mar 2022 20:44:22 +0100 (BST) Received: from localhost ([::1]:34592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZHlN-0003RI-HT for patchwork@mira.cbaines.net; Tue, 29 Mar 2022 15:44:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZHl5-0003QY-CT for guix-patches@gnu.org; Tue, 29 Mar 2022 15:44:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39733) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nZHl5-0001Au-4T for guix-patches@gnu.org; Tue, 29 Mar 2022 15:44:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nZHl5-0004xn-1t for guix-patches@gnu.org; Tue, 29 Mar 2022 15:44:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49946] [PATCH v5 02/27] gnu: Add tree-sitter-cli. Resent-From: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 29 Mar 2022 19:44: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.164858303318896 (code B ref 49946); Tue, 29 Mar 2022 19:44:03 +0000 Received: (at 49946) by debbugs.gnu.org; 29 Mar 2022 19:43:53 +0000 Received: from localhost ([127.0.0.1]:33586 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZHku-0004ub-KJ for submit@debbugs.gnu.org; Tue, 29 Mar 2022 15:43:53 -0400 Received: from mout.gmx.net ([212.227.17.21]:43943) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZHkn-0004rp-4T for 49946@debbugs.gnu.org; Tue, 29 Mar 2022 15:43:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1648583019; bh=g6PGgOo/lsbJbHtqrKzLDpI0sQTjUr+6f5XVeUe6Ung=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=PsBi3gO4TZFSZrZVY0d/27ciHhO3jpn9RlxRDmTtnFbv3/fBw2lt/e6l2wns729Lt 9j69LvQVzvYm3GiwM5ztJbSyV0kZ0mGDDvKDljInS1zUQv/ec6WgHGLJc9m1jtEFKj W5+DSypstGUuQMwY4KgopsXGuKEHCJv7OylO7DXU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([82.69.64.142]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MgNct-1oFWj73h4J-00hyRP; Tue, 29 Mar 2022 21:43:39 +0200 From: Pierre Langlois Date: Tue, 29 Mar 2022 20:42:53 +0100 Message-Id: <20220329194318.6106-3-pierre.langlois@gmx.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220329194318.6106-1-pierre.langlois@gmx.com> References: <877d9s2qa9.fsf@gmx.com> <20220329194318.6106-1-pierre.langlois@gmx.com> MIME-Version: 1.0 X-Provags-ID: V03:K1:tJIWGRytHi6Abduv2CjOTeHxIzpMcmnSTevyQVQq+llHfelOzJU GzmG3CFdlxydW6p7gmwCG7sd2SIBYaIEjLzzXrRmzVu2to+/NuExUl8H/6EQ+5gLz9cC/KK uANPASQnaQFUJIS4Y64oTgGqTAbIIILKu/hGJlf6XkyHuCr4NtNGJEGooUDf1uJIMTepRuZ cqY9ou439QCpCuoaiLHTA== X-UI-Out-Filterresults: notjunk:1;V03:K0:gpqjNvk3NgM=:EqtB4akX/qPPxdz0Zha2gT quPLcK7XcSv3aMP89abmiOdXkj3AkjppR0IoyiDRftEeQ5Smc9YojgPSWtEW4QjCHEsKLgIEB YhEX7S1meylVqXwi+UUfQFfLf8+Kzjc0luXkytT+5bPvpgrHXsK2l54vNuyEkzs+OxBMJle+z i1k2WTomStvs2g8MRNCDabVr4kWakAyfAreNnacbtELq6fhKWn/b7K863gzSIE9Zk6Z0VqvBq rUj4ebBwCoAgjAufumvxluPBK/clwMbSHCFSf+6I75N3N4dxCI8Z8RWopBk3sOs8y4VRmtSCS tB6H2diyNkeXThg6lv+vXSBrRfzK375mrwr1uQtCh8hhgeIK1+SLXMmn8SlojG3cJHOnK/PvE NQDjPA7YoKQxY6G+R6gfFFLMywlh5RXekV6LkUtaB/FBsn43nayjYYRD+0V7WW501qYHBT97D al+XioUiW4yOyjFJiuPZzX44KwQE97WOdcf+wjaFLzcaJvZgLBZF6Q2WjBFyaeCVIriz3X15U RkzePW+HkAn/8spsDiQ1lk4evrlxBJ8amriN4AIXDxTxeAA4u9Sa/IHJu1s4ZtcllFpuo1SWk lbNs5vYXRBAF+UWQMBD9PqhX9yJ+xJAX2mr/4yWuLy0F2PTggrLOWLXqMOZokyI7Zj6MfgEm5 ifPOeOdR2NedczQTab4RXyeIkFP1KNSlEjIALspwcg2hG2vEa0a6M5XhY8rQzmp+Htpsw5hUV 24vDeelHVfSM8MpTDIFMXAnHqepAM/6fdJkr1k+gtQ77xqPrj/25POrRkzdhdqSEeqDMVXNPf 2e7ijKrLwrBAbyOrTjVXCrrvgCgQzcIWaVKt5QhBmkIYzCdQy++8GcouAzE5GSiGLlH9gjqMR zw73LWASW3C4AnIeXLm08ao3cQz5oEijp71WIH7YMYXFClvuNa9PaMwuAzsiONip9aDQRakTQ Vg2+N1S0y+efnEkjCiHbmjJJUzTbPC8EaWxs+KF4/ovXYejunja7wQlBjjItn78GtiD7UWV6d 3phUZ/pWjRnxZ+9rxyYHca6klTfAv7LXza9riK1LXrbldcDHO3M2DiDF9BJa1I2NzRarLS3qA 3pfcCSlLq/T10o= 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" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/tree-sitter.scm (tree-sitter-cli): New variable. --- gnu/packages/tree-sitter.scm | 79 ++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) -- 2.34.0 diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm index 7116a10ed7..18c9fe0844 100644 --- a/gnu/packages/tree-sitter.scm +++ b/gnu/packages/tree-sitter.scm @@ -20,10 +20,13 @@ (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 gnu) #:use-module (guix git-download) #:use-module (guix packages) #:use-module (guix utils) + #:use-module (gnu packages crates-graphics) + #:use-module (gnu packages crates-io) #:use-module (gnu packages icu4c)) (define-public tree-sitter @@ -76,3 +79,79 @@ (define-public tree-sitter This package includes the @code{libtree-sitter} runtime library. ") (license license:expat))) + +(define-public tree-sitter-cli + (package (inherit tree-sitter) + (name "tree-sitter-cli") + (source (origin + (inherit (package-source tree-sitter)) + (snippet + '(begin + ;; Remove the runtime library code and dynamically link to + ;; it instead. + (delete-file-recursively "lib/src") + (delete-file "lib/binding_rust/build.rs") + (with-output-to-file "lib/binding_rust/build.rs" + (lambda _ + (format #t "fn main() {~@ + println!(\"cargo:rustc-link-lib=tree-sitter\");~@ + }~%"))) + #t)))) + (build-system cargo-build-system) + (inputs (list tree-sitter)) + (arguments + `(;; Running test requires downloading fixtures, see the + ;; script/fetch-fixtures script. + #:tests? #f + ;; We're only packaging the CLI program so we do not need to install + ;; sources. + #:install-source? #f + #:cargo-inputs + (("rust-ansi-term" ,rust-ansi-term-0.12) + ("rust-anyhow" ,rust-anyhow-1) + ("rust-atty" ,rust-atty-0.2) + ("rust-clap" ,rust-clap-2) + ("rust-difference" ,rust-difference-2) + ("rust-html-escape" ,rust-html-escape-0.2) + ("rust-libloading" ,rust-libloading-0.7) + ("rust-rand" ,rust-rand-0.8) + ("rust-rustc-hash" ,rust-rustc-hash-1) + ("rust-semver" ,rust-semver-1) + ("rust-smallbitvec" ,rust-smallbitvec-2) + ("rust-thiserror" ,rust-thiserror-1) + ("rust-tiny-http" ,rust-tiny-http-0.8) + ("rust-toml" ,rust-toml-0.5) + ("rust-walkdir" ,rust-walkdir-2) + ("rust-webbrowser" ,rust-webbrowser-0.5) + ("rust-which" ,rust-which-4)) + #:cargo-development-inputs + (("rust-pretty-assertions" ,rust-pretty-assertions-0.7)) + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'delete-cargo.lock + (lambda _ (delete-file "Cargo.lock"))) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (bin (string-append out "/bin")) + (lib (string-append out "/lib"))) + (mkdir-p bin) + (install-file "target/release/tree-sitter" bin))))))) + (synopsis "Incremental parsing system for programming tools") + (description "Tree-sitter is a parser generator tool and an incremental +parsing library. It can build a concrete syntax tree for a source file and +efficiently update the syntax tree as the source file is edited. + +Tree-sitter aims to be: + +@enumerate +@item General enough to parse any programming language. +@item Fast enough to parse on every keystroke in a text editor. +@item Robust enough to provide useful results even in the presence of syntax +errors. +@item Dependency-free so that the runtime library (which is written in pure C) +can be embedded in any application. +@end enumerate + +This package includes the @command{tree-sitter} command-line tool.") + (license license:expat)))