Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package tree-sitter for openSUSE:Factory checked in at 2026-09-16 17:40:56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/tree-sitter (Old) and /work/SRC/openSUSE:Factory/.tree-sitter.new.383539 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "tree-sitter" Wed Sep 16 17:40:56 2026 rev:30 rq:1378101 version:0.26.8 Changes: -------- --- /work/SRC/openSUSE:Factory/tree-sitter/tree-sitter.changes 2026-08-31 15:56:10.632880864 +0200 +++ /work/SRC/openSUSE:Factory/.tree-sitter.new.383539/tree-sitter.changes 2026-09-16 17:41:31.985020273 +0200 @@ -1,0 +2,24 @@ +Tue Sep 15 06:20:21 UTC 2026 - Martin Pluskal <[email protected]> + +- Add the %treesitter_queries_install, %treesitter_queries_files + and %treesitter_queries_package macros: ship the queries a + grammar carries (highlights.scm and friends) in a noarch -queries + subpackage under %_datadir/tree-sitter/queries/<grammar>, keyed + like the -wasm modules, for consumers highlighting with the + grammar's own queries +- Own %_datadir/tree-sitter/queries +- tree-sitter-target.py: match a nested grammar source directory + (grammars/<name>) as a path prefix, not only a top-level one + +------------------------------------------------------------------- +Mon Sep 14 18:07:18 UTC 2026 - Martin Pluskal <[email protected]> + +- Add the %treesitter_wasm_build, %treesitter_wasm_install, + %treesitter_wasm_files and %treesitter_wasm_package macros: build + every grammar of a package to a WebAssembly module with the + distribution's clang, lld and wasi-libc (the tree-sitter CLI's + own wasi-sdk invocation) into a noarch -wasm subpackage under + %_datadir/tree-sitter/wasm, for consumers running web-tree-sitter +- Own %_datadir/tree-sitter/wasm + +------------------------------------------------------------------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ tree-sitter.spec ++++++ --- /var/tmp/diff_new_pack.sVujdI/_old 2026-09-16 17:41:33.668090598 +0200 +++ /var/tmp/diff_new_pack.sVujdI/_new 2026-09-16 17:41:33.671090723 +0200 @@ -125,6 +125,8 @@ # stupid workaround for "integrating" the grammars into neovim install -d %{buildroot}%{_treesitter_grammardir} install -d %{buildroot}%{_treesitter_grammar_develdir} +install -d %{buildroot}%{_treesitter_wasmdir} +install -d %{buildroot}%{_treesitter_queriesdir} #fix pkgconfig file for i in lib include; do @@ -157,6 +159,9 @@ %dir %{_includedir}/%{_treesitter_base_name} %dir %{_treesitter_grammar_develdir} %dir %{_treesitter_grammardir} +%dir %{_datadir}/%{_treesitter_base_name} +%dir %{_treesitter_wasmdir} +%dir %{_treesitter_queriesdir} %files -n lib%{name}%{somajor} %license LICENSE ++++++ _scmsync.obsinfo ++++++ --- /var/tmp/diff_new_pack.sVujdI/_old 2026-09-16 17:41:33.735093398 +0200 +++ /var/tmp/diff_new_pack.sVujdI/_new 2026-09-16 17:41:33.740093606 +0200 @@ -1,6 +1,6 @@ -mtime: 1788024932 -commit: 7ecf0183cee1608252624071018bc684caa3aa71ee20252231186290fec0ba3e +mtime: 1789461954 +commit: 117630e3738b993e101c04153b7198ddbf46d0ee17fac42d085d8ad478f9ab6c url: https://src.opensuse.org/tree-sitter/tree-sitter -revision: 7ecf0183cee1608252624071018bc684caa3aa71ee20252231186290fec0ba3e +revision: 117630e3738b993e101c04153b7198ddbf46d0ee17fac42d085d8ad478f9ab6c projectscmsync: https://src.opensuse.org/tree-sitter/_ObsPrj ++++++ build.specials.obscpio ++++++ ++++++ build.specials.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.gitignore new/.gitignore --- old/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/.gitignore 2026-09-15 10:45:54.000000000 +0200 @@ -0,0 +1,5 @@ +*.obscpio +*.osc +_build.* +.pbuild +tree-sitter-*-build/ ++++++ functions.lua ++++++ --- /var/tmp/diff_new_pack.sVujdI/_old 2026-09-16 17:41:34.135110112 +0200 +++ /var/tmp/diff_new_pack.sVujdI/_new 2026-09-16 17:41:34.141110362 +0200 @@ -121,3 +121,16 @@ print("\n") end +function treesitter_wasm_module(name) + -- The CLI names a WebAssembly module after the grammar's own name from + -- grammar.json, which is an identifier: a dash in the rpm-side grammar + -- name (markdown-inline) is an underscore there. + return "tree-sitter-" .. name:gsub("-", "_") .. ".wasm" +end + +function treesitter_queries_key(name) + -- Queries are keyed like the WebAssembly modules: by the grammar's own + -- name, an identifier, so a dash in the rpm-side name is an underscore. + return (name:gsub("-", "_")) +end + ++++++ macros.in ++++++ --- /var/tmp/diff_new_pack.sVujdI/_old 2026-09-16 17:41:34.178111909 +0200 +++ /var/tmp/diff_new_pack.sVujdI/_new 2026-09-16 17:41:34.189112368 +0200 @@ -5,9 +5,105 @@ %_treesitter_grammardir %{_libdir}/tree-sitter %_treesitter_grammar_develdir %{_includedir}/%{_treesitter_base_name}/grammars %_treesitter_grammar_base_libname lib%{_treesitter_base_name} +%_treesitter_wasmdir %{_datadir}/%{_treesitter_base_name}/wasm +%_treesitter_queriesdir %{_datadir}/%{_treesitter_base_name}/queries %treesitter_target() %{_rpmconfigdir}/tree-sitter-target.py %treesitter_set_flags export NODE_PATH="${NODE_PATH:+${NODE_PATH}:}%{_treesitter_grammar_develdir}:$PWD"; mkdir -p node_modules; for grammar in %{_treesitter_grammar_develdir}/tree-sitter-*; do [ -d "$grammar" ] || continue; ln -sfn "$grammar" "node_modules/$(basename "$grammar")"; done +# --[[ +# Optional -wasm subpackage: every grammar of the package compiled to a +# WebAssembly module, for consumers that run tree-sitter in a WebAssembly +# runtime (web-tree-sitter; opencode's highlighter is the first). The +# tree-sitter CLI builds it exactly as it would with wasi-sdk -- one clang +# call, no libc -- and %%treesitter_wasm_set_sdk points it at the +# distribution's clang, lld and wasi-libc through a two-line shim, because +# without TREE_SITTER_WASI_SDK_PATH the CLI downloads wasi-sdk. The module +# is arch-independent bytecode, so the subpackage is noarch (-DNDEBUG keeps +# a scanner's assert() text, the only host-specific input, out of it; the +# CLI compiles relative paths from the grammar's src/, so nothing else could +# leak). Files land in +# %%{_treesitter_wasmdir} as tree-sitter-<grammar>.wasm, named after the +# grammar's own name (grammar.json), which is what the CLI and consumers +# expect (markdown-inline yields tree-sitter-markdown_inline.wasm). +# +# Usage -- the three BuildRequires must be literal: the OBS scheduler +# resolves BuildRequires before macros.treesitter is installed, so a +# macro from this file cannot carry them. +# +# BuildRequires: clang +# BuildRequires: lld +# BuildRequires: wasi-libc +# +# %%build +# %%treesitter_wasm_build +# +# %%install +# %%treesitter_wasm_install +# +# %%treesitter_wasm_package +# +# A grammar whose directory is not what %%treesitter_grammars names as its +# source (that source is a binding.gyp path prefix for %%treesitter_build, +# which can differ) gets the directory as an argument, grammar=dir: +# tree-sitter-hcl declares terraform=dialects and builds its module with +# %%treesitter_wasm_build terraform=dialects/terraform +# --]] +%treesitter_wasm_set_sdk mkdir -p .wasi-sdk/bin; { echo '#!/bin/sh'; echo "exec %{_bindir}/clang --sysroot=%{_datadir}/wasi-sysroot -isystem %{_datadir}/wasi-sysroot/include/wasm32-wasip1 -DNDEBUG "'"$@"'; } > .wasi-sdk/bin/clang; chmod 0755 .wasi-sdk/bin/clang; export TREE_SITTER_WASI_SDK_PATH="$PWD/.wasi-sdk" + +%__treesitter_wasm_package_name() %name-wasm +%treesitter_wasm_package \ +%package -n %{__treesitter_wasm_package_name} \ +Summary: WebAssembly modules of the %{name} grammars \ +BuildArch: noarch \ +%{treesitter_wasm_provides} \ +%description -n %{__treesitter_wasm_package_name} \ +The grammars of %{name} compiled to WebAssembly, for consumers that run \ +tree-sitter in a WebAssembly runtime such as web-tree-sitter. The modules \ +live in %{_treesitter_wasmdir}. \ +%files -n %{__treesitter_wasm_package_name} \ +%{treesitter_wasm_files} + +# --[[ +# Optional -queries subpackage: the queries upstream ships with the +# grammar (highlights.scm and friends) installed to +# %%{_treesitter_queriesdir}/<grammar>/, keyed like the -wasm modules +# (grammar.json name, so markdown-inline -> queries/markdown_inline/). +# Consumers: opencode's highlighter with the -wasm modules, or any editor +# pointed at that directory. Every *.scm in the grammar's query directory +# goes in; the directory must hold a highlights.scm or the build fails. +# +# The query directory is found at build time: queries/ next to the +# grammar's src/ (single-grammar packages), else <source>/queries (a +# multi-grammar package whose grammars keep their own), else the shared +# top-level queries/ (typescript's tsx, php). Layouts the search cannot +# guess take grammar=dir arguments, and grammar= (empty) skips a grammar +# that has none: +# +# %%install +# %%treesitter_queries_install +# %%treesitter_queries_install xml=queries/xml dtd=queries/dtd +# %%treesitter_queries_install terraform= +# +# %%treesitter_queries_package +# +# %%treesitter_queries_package must come after %%treesitter_queries_install +# in the spec (as %%treesitter_devel_package does): the install macro records +# which grammars got queries and the package template reads that. +# --]] +%__treesitter_queries_package_name() %name-queries +%treesitter_queries_package \ +%package -n %{__treesitter_queries_package_name} \ +Summary: Tree-sitter queries of the %{name} grammars \ +BuildArch: noarch \ +%{treesitter_queries_provides} \ +%description -n %{__treesitter_queries_package_name} \ +The queries upstream ships for the grammars of %{name} (highlights.scm and \ +whatever else the grammar carries), in %{_treesitter_queriesdir}/<grammar>/, \ +for consumers that highlight with the grammar's own queries: opencode with \ +the -wasm modules, or an editor pointed at that directory. \ +%files -n %{__treesitter_queries_package_name} \ +%{treesitter_queries_files} + %__treesitter_devel_package_name() %name-devel %treesitter_devel_package \ %package -n %{__treesitter_devel_package_name} \ ++++++ macros.lua ++++++ --- /var/tmp/diff_new_pack.sVujdI/_old 2026-09-16 17:41:34.223113789 +0200 +++ /var/tmp/diff_new_pack.sVujdI/_new 2026-09-16 17:41:34.227113956 +0200 @@ -173,6 +173,166 @@ end --[[ + Optional -wasm package: each grammar compiled to a WebAssembly module + (see the usage block in macros.in). + + %%build + %%treesitter_wasm_build + + %%install + %%treesitter_wasm_install + + %%treesitter_wasm_package +--]] + +function treesitter_wasm_build() + --[[ + Build every grammar to a WebAssembly module with the tree-sitter CLI, + pointed at the distribution's wasm toolchain. Arguments of the form + grammar=dir override the directory the CLI is given for that grammar. + The CLI already refuses a scanner that imports symbols web-tree-sitter + cannot provide; the grep proves the module exports the grammar's entry + point (anchored so markdown does not pass on markdown_inline). + --]] + rpm.expand("%_treesitter_macro_init") + local grammar_names = rpm.expand("%{treesitter_grammar_names}"):split() + local grammar_sources = rpm.expand("%{treesitter_grammar_sources}"):split() + local dirs = {} + for _, spec in ipairs(arg_compat(arg)) do + local name, dir = spec:match("^([^=]+)=(.+)$") + if name then + dirs[name] = dir + end + end + + print(rpm.expand("%treesitter_wasm_set_sdk")) + print("\n") + for i, name in ipairs(grammar_names) do + local source = dirs[name] or grammar_sources[i] or "src" + if source == "src" then + source = "." + end + local module = treesitter_wasm_module(name) + local symbol = "tree_sitter_" .. name:gsub("-", "_") + print("tree-sitter build --wasm -o " .. module .. " " .. source) + print("\n") + print("LC_ALL=C grep -qP '" .. symbol .. "(?![A-Za-z0-9_])' " .. module) + print("\n") + end +end + +function treesitter_wasm_provides() + --[[ + One Provides line per grammar, printed rather than stored in a macro: + a macro body defined from Lua keeps only its first line, so a + multi-grammar package would otherwise advertise only its first grammar. + --]] + rpm.expand("%_treesitter_macro_init") + local base_name = rpm.expand("%_treesitter_base_name") + for _, name in ipairs(rpm.expand("%{treesitter_grammar_names}"):split()) do + print("Provides: treesitter_grammar_wasm(" .. base_name .. "-" .. name .. ")\n") + end +end + +function treesitter_wasm_install() + rpm.expand("%_treesitter_macro_init") + local grammar_names = rpm.expand("%{treesitter_grammar_names}"):split() + local install_path = rpm.expand("%{buildroot}%{_treesitter_wasmdir}") + for _, name in ipairs(grammar_names) do + local module = treesitter_wasm_module(name) + print("install -Dm644 " .. module .. " " .. install_path .. "/" .. module) + print("\n") + end +end + +function treesitter_wasm_files() + rpm.expand("%_treesitter_macro_init") + local grammar_names = rpm.expand("%{treesitter_grammar_names}"):split() + local wasmdir = rpm.expand("%{_treesitter_wasmdir}") + + print(rpm.expand("%dir " .. wasmdir:dirname() .. "\n")) + print(rpm.expand("%dir " .. wasmdir .. "\n")) + for _, name in ipairs(grammar_names) do + print(rpm.expand(wasmdir .. "/" .. treesitter_wasm_module(name) .. "\n")) + end +end + +--[[ + Optional -queries package: the grammar's own queries, next to the -wasm + modules (see the usage block in macros.in). + + %%install + %%treesitter_queries_install [grammar=dir ...] [grammar= ...] + + %%treesitter_queries_package +--]] + +function treesitter_queries_install() + --[[ + Install every *.scm of each grammar's query directory to + %%{_treesitter_queriesdir}/<grammar.json name>/. grammar=dir names + the directory, grammar= skips the grammar. Records the grammars that + got queries in %%_treesitter_queries_grammars for the files and + provides macros. + --]] + rpm.expand("%_treesitter_macro_init") + local grammar_names = rpm.expand("%{treesitter_grammar_names}"):split() + local grammar_sources = rpm.expand("%{treesitter_grammar_sources}"):split() + local dirs = {} + local skip = {} + for _, spec in ipairs(arg_compat(arg)) do + local name, dir = spec:match("^([^=]+)=(.*)$") + if name then + if dir == "" then + skip[name] = true + else + dirs[name] = dir + end + end + end + local install_root = rpm.expand("%{buildroot}%{_treesitter_queriesdir}") + local installed = {} + for i, name in ipairs(grammar_names) do + if not skip[name] then + local source = grammar_sources[i] or "src" + local candidates + if dirs[name] then + candidates = { dirs[name] } + elseif source == "src" then + candidates = { "queries" } + else + candidates = { source .. "/queries", "queries" } + end + local dest = install_root .. "/" .. treesitter_queries_key(name) + print("tsq_dir=''; for tsq_d in " .. table.concat(candidates, " ") .. "; do test -f \"$tsq_d/highlights.scm\" && { tsq_dir=$tsq_d; break; }; done\n") + print("test -n \"$tsq_dir\" || { echo 'error: no highlights.scm for grammar " .. name .. " (looked in " .. table.concat(candidates, ", ") .. "); pass " .. name .. "=<dir> or " .. name .. "= to treesitter_queries_install' >&2; exit 1; }\n") + print("install -d " .. dest .. "\n") + print("install -m 0644 \"$tsq_dir\"/*.scm " .. dest .. "/\n") + table.insert(installed, name) + end + end + rpm.define("_treesitter_queries_grammars " .. table.concat(installed, " ")) +end + +function treesitter_queries_provides() + rpm.expand("%_treesitter_macro_init") + local base_name = rpm.expand("%_treesitter_base_name") + for _, name in ipairs(rpm.expand("%{?_treesitter_queries_grammars}%{!?_treesitter_queries_grammars:%{treesitter_grammar_names}}"):split()) do + print("Provides: treesitter_grammar_queries(" .. base_name .. "-" .. name .. ")\n") + end +end + +function treesitter_queries_files() + rpm.expand("%_treesitter_macro_init") + local queriesdir = rpm.expand("%{_treesitter_queriesdir}") + print(rpm.expand("%dir " .. queriesdir:dirname() .. "\n")) + print(rpm.expand("%dir " .. queriesdir .. "\n")) + for _, name in ipairs(rpm.expand("%{?_treesitter_queries_grammars}%{!?_treesitter_queries_grammars:%{treesitter_grammar_names}}"):split()) do + print(rpm.expand(queriesdir .. "/" .. treesitter_queries_key(name) .. "\n")) + end +end + +--[[ Optional -devel package for grammars that are needed for other grammars to be built. If the -devel package is needed it should look like this: ++++++ tree-sitter-target.py ++++++ --- /var/tmp/diff_new_pack.sVujdI/_old 2026-09-16 17:41:34.299116965 +0200 +++ /var/tmp/diff_new_pack.sVujdI/_new 2026-09-16 17:41:34.307117299 +0200 @@ -118,8 +118,11 @@ if str(source) in seen_sources: continue - # Only include if it belongs to the grammar (or default 'src') - if _grammar == "src" or source.parts[0] == _grammar: + # Only include if it belongs to the grammar (or default 'src'). + # The grammar is a path prefix, possibly nested (grammars/ocaml), + # so compare as many leading components as it has. + grammar_parts = Path(_grammar).parts + if _grammar == "src" or (grammar_parts and source.parts[:len(grammar_parts)] == grammar_parts): if any(source.name.endswith(s) for s in suffixes_cc): command += ['-xc++', str(source)] seen_sources.add(str(source))
