Skip to content

Commit

Permalink
dev-libs/tree-sitter: support for building cli tool
Browse files Browse the repository at this point in the history
Signed-off-by: Vadim Misbakh-Soloviov <[email protected]>
  • Loading branch information
msva committed Dec 20, 2021
1 parent 15e061e commit 0b1d5c1
Show file tree
Hide file tree
Showing 12 changed files with 348 additions and 38 deletions.
106 changes: 106 additions & 0 deletions dev-libs/tree-sitter/Manifest

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions dev-libs/tree-sitter/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
<email>[email protected]</email>
<name>Nick Sarnie</name>
</maintainer>
<maintainer type="person">
<email>[email protected]</email>
<name>Vadim Misbakh-Soloviov</name>
</maintainer>
<use>
<flag name="ts-cli">Build Tree-sitter CLI tool (for developing, testing, and using Tree-sitter parsers)</flag>
</use>
<upstream>
<remote-id type="github">tree-sitter/tree-sitter</remote-id>
</upstream>
Expand Down
172 changes: 172 additions & 0 deletions dev-libs/tree-sitter/tree-sitter-0.20.1-r1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CARGO_OPTIONAL=1

CRATES="
aho-corasick-0.7.15
ansi_term-0.11.0
ansi_term-0.12.1
anyhow-1.0.40
arrayref-0.3.6
arrayvec-0.5.2
ascii-1.0.0
atty-0.2.14
autocfg-1.0.1
base64-0.13.0
bitflags-1.2.1
blake2b_simd-0.5.11
bumpalo-3.6.1
cc-1.0.67
cfg-if-1.0.0
chrono-0.4.19
chunked_transfer-1.4.0
clap-2.33.3
constant_time_eq-0.1.5
crossbeam-utils-0.8.3
ctor-0.1.20
diff-0.1.12
difference-2.0.0
dirs-3.0.1
dirs-sys-0.3.5
either-1.6.1
form_urlencoded-1.0.1
getrandom-0.1.16
getrandom-0.2.2
glob-0.3.0
hashbrown-0.9.1
hermit-abi-0.1.18
html-escape-0.2.6
idna-0.2.2
indexmap-1.6.1
itoa-0.4.7
js-sys-0.3.48
lazy_static-1.4.0
libc-0.2.86
libloading-0.7.0
log-0.4.14
matches-0.1.8
memchr-2.3.4
num-integer-0.1.44
num-traits-0.2.14
once_cell-1.7.0
output_vt100-0.1.2
percent-encoding-2.1.0
ppv-lite86-0.2.10
pretty_assertions-0.7.2
proc-macro2-1.0.24
quote-1.0.9
rand-0.8.3
rand_chacha-0.3.0
rand_core-0.6.2
rand_hc-0.3.0
redox_syscall-0.1.57
redox_syscall-0.2.5
redox_users-0.3.5
regex-1.4.3
regex-syntax-0.6.22
remove_dir_all-0.5.3
rust-argon2-0.8.3
rustc-hash-1.1.0
ryu-1.0.5
same-file-1.0.6
serde-1.0.130
serde_derive-1.0.130
serde_json-1.0.63
smallbitvec-2.5.1
spin-0.7.1
strsim-0.8.0
syn-1.0.67
tempfile-3.2.0
textwrap-0.11.0
thiserror-1.0.25
thiserror-impl-1.0.25
thread_local-1.1.3
time-0.1.43
tiny_http-0.8.0
tinyvec-1.1.1
tinyvec_macros-0.1.0
toml-0.5.8
unicode-bidi-0.3.4
unicode-normalization-0.1.17
unicode-width-0.1.8
unicode-xid-0.2.1
url-2.2.1
utf8-width-0.1.4
vec_map-0.8.2
walkdir-2.3.1
wasi-0.9.0+wasi-snapshot-preview1
wasi-0.10.2+wasi-snapshot-preview1
wasm-bindgen-0.2.71
wasm-bindgen-backend-0.2.71
wasm-bindgen-macro-0.2.71
wasm-bindgen-macro-support-0.2.71
wasm-bindgen-shared-0.2.71
web-sys-0.3.48
webbrowser-0.5.5
which-4.1.0
widestring-0.4.3
winapi-0.3.9
winapi-i686-pc-windows-gnu-0.4.0
winapi-util-0.1.5
winapi-x86_64-pc-windows-gnu-0.4.0
"

inherit toolchain-funcs cargo

DESCRIPTION="Tree-sitter is a parser generator tool and an incremental parsing library."
HOMEPAGE="https://github.com/tree-sitter/tree-sitter"

if [[ ${PV} == *9999* ]]; then
inherit git-r3
EGIT_REPO_URI="https://github.com/${PN}/${PN}"
else
SRC_URI="
https://github.com/${PN}/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz
ts-cli? ( $(cargo_crate_uris) )
"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
fi

LICENSE="MIT ts-cli? ( Apache-2.0 BSD-2 CC0-1.0 ISC MIT )"
SLOT="0"

IUSE="ts-cli"

BDEPEND="ts-cli? ( virtual/rust )"

PATCHES=(
"${FILESDIR}/${PN}-No-static-libs-gentoo.patch"
)

src_unpack() {
if [[ ${PV} == *9999* ]]; then
git-r3_src_unpack
use ts-cli && cargo_live_src_unpack
else
# behaves as default too, so it is ok to call it unconditonally
cargo_src_unpack
fi
}

src_prepare() {
default
tc-export CC
}

src_configure() {
default
use ts-cli && cargo_src_configure
}

src_compile() {
default
use ts-cli && cargo_src_compile
}

src_install() {
emake DESTDIR="${D}" PREFIX="${EPREFIX}/usr" LIBDIR="${EPREFIX}/usr/$(get_libdir)" install
use ts-cli && cargo_src_install --path "./cli"
}
33 changes: 0 additions & 33 deletions dev-libs/tree-sitter/tree-sitter-0.20.1.ebuild

This file was deleted.

40 changes: 35 additions & 5 deletions dev-libs/tree-sitter/tree-sitter-9999.ebuild
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7
EAPI=8

inherit toolchain-funcs
CARGO_OPTIONAL=1

inherit toolchain-funcs cargo

DESCRIPTION="Tree-sitter is a parser generator tool and an incremental parsing library."
HOMEPAGE="https://github.com/tree-sitter/tree-sitter"
Expand All @@ -12,22 +14,50 @@ if [[ ${PV} == *9999* ]]; then
inherit git-r3
EGIT_REPO_URI="https://github.com/${PN}/${PN}"
else
SRC_URI="https://github.com/${PN}/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
KEYWORDS="~amd64"
SRC_URI="
https://github.com/${PN}/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz
ts-cli? ( $(cargo_crate_uris) )
"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
fi

LICENSE="MIT"
LICENSE="MIT ts-cli? ( Apache-2.0 BSD-2 CC0-1.0 ISC MIT )"
SLOT="0"

IUSE="ts-cli"

BDEPEND="ts-cli? ( virtual/rust )"

PATCHES=(
"${FILESDIR}/${PN}-No-static-libs-gentoo.patch"
)

src_unpack() {
if [[ ${PV} == *9999* ]]; then
git-r3_src_unpack
use ts-cli && cargo_live_src_unpack
else
# behaves as default too, so it is ok to call it unconditonally
cargo_src_unpack
fi
}

src_prepare() {
default
tc-export CC
}

src_configure() {
default
use ts-cli && cargo_src_configure
}

src_compile() {
default
use ts-cli && cargo_src_compile
}

src_install() {
emake DESTDIR="${D}" PREFIX="${EPREFIX}/usr" LIBDIR="${EPREFIX}/usr/$(get_libdir)" install
use ts-cli && cargo_src_install --path "./cli"
}
4 changes: 4 additions & 0 deletions profiles/arch/alpha/package.use.mask
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Vadim Misbakh-Soloviov <[email protected]> (2021-12-09)
# ts-cli requires rust to be built, and rust is unavailable here ATM.
dev-libs/tree-sitter ts-cli

# Sam James <[email protected]> (2021-11-05)
# Avoid keywording unnecessary depenencies for now, bug #804115
dev-python/scipy pythran
Expand Down
4 changes: 4 additions & 0 deletions profiles/arch/arm/armv4/package.use.mask
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Vadim Misbakh-Soloviov <[email protected]> (2021-12-09)
# ts-cli requires rust to be built, and rust is unavailable here ATM.
dev-libs/tree-sitter ts-cli

# Matt Turner <[email protected]> (07-25-2021)
# gdm requires gnome-shell requires rustified librsvg.
x11-misc/xscreensaver gdm
4 changes: 4 additions & 0 deletions profiles/arch/arm/armv4t/package.use.mask
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Vadim Misbakh-Soloviov <[email protected]> (2021-12-09)
# ts-cli requires rust to be built, and rust is unavailable here ATM.
dev-libs/tree-sitter ts-cli

# Matt Turner <[email protected]> (07-25-2021)
# gdm requires gnome-shell requires rustified librsvg.
x11-misc/xscreensaver gdm
4 changes: 4 additions & 0 deletions profiles/arch/arm/armv5te/package.use.mask
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Vadim Misbakh-Soloviov <[email protected]> (2021-12-09)
# ts-cli requires rust to be built, and rust is unavailable here ATM.
dev-libs/tree-sitter ts-cli

# Matt Turner <[email protected]> (07-25-2021)
# gdm requires gnome-shell requires rustified librsvg.
x11-misc/xscreensaver gdm
4 changes: 4 additions & 0 deletions profiles/arch/hppa/package.use.mask
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# NOTE: When masking a USE flag due to missing keywords, please file a keyword
# request bug for the hppa arch.

# Vadim Misbakh-Soloviov <[email protected]> (2021-12-09)
# ts-cli requires rust to be built, and rust is unavailable here ATM.
dev-libs/tree-sitter ts-cli

# Sam James <[email protected]> (2021-11-19)
# Avoid dragging in doc/sphinx deps where we can help it
dev-python/anyio doc
Expand Down
4 changes: 4 additions & 0 deletions profiles/arch/ia64/package.use.mask
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Vadim Misbakh-Soloviov <[email protected]> (2021-12-09)
# ts-cli requires rust to be built, and rust is unavailable here ATM.
dev-libs/tree-sitter ts-cli

# Michał Górny <[email protected]> (2021-11-26)
# These package flags require dev-python/cryptography which -- due
# to the dependency on Rust -- is no longer portable to ia64.
Expand Down
4 changes: 4 additions & 0 deletions profiles/arch/sparc/package.use.mask
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Vadim Misbakh-Soloviov <[email protected]> (2021-12-09)
# ts-cli requires rust to be built, and rust is unavailable here ATM.
dev-libs/tree-sitter ts-cli

# Daniel Pielmeier <[email protected]> (2021-11-07)
# gnome-base/librsvg is not keyworded here, bug #807130
app-admin/conky lua-rsvg
Expand Down

0 comments on commit 0b1d5c1

Please sign in to comment.