Skip to content

Commit aeaee3b

Browse files
authored
tree-sitter: add 0.26.4:0.26.9 and clean up the dependencies and install logic (#5115)
1 parent 20b5152 commit aeaee3b

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

  • repos/spack_repo/builtin/packages/tree_sitter

repos/spack_repo/builtin/packages/tree_sitter/package.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,18 @@ class TreeSitter(MakefilePackage):
1515

1616
homepage = "https://tree-sitter.github.io/tree-sitter/"
1717
url = "https://github.com/tree-sitter/tree-sitter/archive/refs/tags/v0.20.1.tar.gz"
18+
supplier = "Organization: tree-sitter"
1819

1920
maintainers("albestro")
2021

21-
license("MIT")
22+
license("MIT", checked_by="mcmehrtens", when="@0.14:")
2223

24+
version("0.26.9", sha256="8e14780500933f43d86662fcaa1b0ce99ebe9c220f4680bc929dce09a0e0cfc6")
25+
version("0.26.8", sha256="e6826b7533ec3a885aba598377a6d20b5a6321ff3db76968e960c2352d3a5077")
26+
version("0.26.7", sha256="4343107ad1097a35e106092b79e5dd87027142c6fba5e4486b1d1d44d5499f84")
27+
version("0.26.6", sha256="b4218185a48a791d4022ab3969709e271a70a0253e94792abbcf18d7fcf4291c")
28+
version("0.26.5", sha256="8e012493b2103e0471d3aba8048b73bc1a3138132974e2fd8bfb89a63e62f478")
29+
version("0.26.4", sha256="08932434d4cf8472a63579253937c302dd97765c65febd59631860905fd3cbf7")
2330
version("0.26.3", sha256="7f4a7cf0a2cd217444063fe2a4d800bc9d21ed609badc2ac20c0841d67166550")
2431
version("0.26.2", sha256="3cda4166a049fc736326941d6f20783b698518b0f80d8735c7754a6b2d173d9a")
2532
version("0.25.3", sha256="862fac52653bc7bc9d2cd0630483e6bdf3d02bcd23da956ca32663c4798a93e3")
@@ -54,7 +61,14 @@ class TreeSitter(MakefilePackage):
5461
depends_on("c", type="build")
5562

5663
with when("+cli"):
57-
depends_on("rust", type="build", when="+cli")
64+
depends_on("rust", type="build")
65+
66+
# minimum rust versions from `rust-version` in the upstream Cargo.toml
67+
depends_on("rust@1.84:", type="build", when="@0.26:")
68+
depends_on("rust@1.82:", type="build", when="@0.25")
69+
depends_on("rust@1.74.1:", type="build", when="@0.22:0.24")
70+
depends_on("rust@1.70:", type="build", when="@0.21")
71+
depends_on("rust@1.65:", type="build", when="@0.20.8:0.20")
5872

5973
# tree-sitter-cli needs a c compiler and a javascript runtime
6074
# https://tree-sitter.github.io/tree-sitter/creating-parsers/1-getting-started.html#dependencies
@@ -71,22 +85,17 @@ class TreeSitter(MakefilePackage):
7185
when="@0.26:0.26.3",
7286
)
7387

74-
def setup_build_environment(self, env):
75-
env.set("PREFIX", self.prefix)
76-
88+
def flag_handler(self, name, flags):
7789
# Starting from 0.25 endianness is taken into account using system headers
7890
# https://github.com/tree-sitter/tree-sitter/pull/3740
7991
# but GLIBC provides them according to some defines that changed over time.
8092
# https://www.sourceware.org/glibc/wiki/Release/2.20#Deprecation_of__BSD_SOURCE_and__SVID_SOURCE_feature_macros
81-
if self.spec.satisfies("@0.25 ^glibc@:2.19"):
82-
env.append_flags("CFLAGS", "-D_BSD_SOURCE")
83-
84-
def build(self, spec, prefix):
85-
super().build(spec, prefix)
93+
if name == "cflags" and self.spec.satisfies("@0.25 ^glibc@:2.19"):
94+
flags.append("-D_BSD_SOURCE")
95+
return (flags, None, None)
8696

87-
if spec.satisfies("+cli"):
88-
cargo = Executable("cargo")
89-
cargo("build")
97+
def setup_build_environment(self, env):
98+
env.set("PREFIX", self.prefix)
9099

91100
def install(self, spec, prefix):
92101
super().install(spec, prefix)
@@ -98,4 +107,4 @@ def install(self, spec, prefix):
98107
else:
99108
crate_cli_path = "cli"
100109

101-
cargo("install", "--root", prefix, "--path", crate_cli_path)
110+
cargo("install", "--locked", "--root", prefix, "--path", crate_cli_path)

0 commit comments

Comments
 (0)