Accepting request 1162836 from editors
OBS-URL: https://build.opensuse.org/request/show/1162836 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/tree-sitter?expand=0&rev=11
This commit is contained in:
commit
ccd887b51f
@ -43,3 +43,18 @@ function string.split(str, sep)
|
|||||||
string.gsub(str, '[^'..sep..']+', func)
|
string.gsub(str, '[^'..sep..']+', func)
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function arg_compat()
|
||||||
|
--[[
|
||||||
|
Compat macro as workaround for older rpm not having function
|
||||||
|
arguments available as table arg(uments)
|
||||||
|
--]]
|
||||||
|
local arg_count = rpm.expand("%#")
|
||||||
|
local arg = {}
|
||||||
|
|
||||||
|
for arg_num = 1,arg_count do
|
||||||
|
arg[arg_num] = rpm.expand(("%" .. arg_num))
|
||||||
|
end
|
||||||
|
|
||||||
|
return arg
|
||||||
|
end
|
||||||
|
18
macros.lua
18
macros.lua
@ -32,6 +32,12 @@ function treesitter_grammars()
|
|||||||
local treesitter_grammar_names = ""
|
local treesitter_grammar_names = ""
|
||||||
local treesitter_grammar_libnames = ""
|
local treesitter_grammar_libnames = ""
|
||||||
|
|
||||||
|
local arg = arg
|
||||||
|
local suse_version = tonumber(rpm.expand("%suse_version"))
|
||||||
|
if suse_version < 1600 then
|
||||||
|
arg = arg_compat()
|
||||||
|
end
|
||||||
|
|
||||||
for arg_num = 1,#arg do
|
for arg_num = 1,#arg do
|
||||||
treesitter_grammar_libnames=treesitter_grammar_libnames .. base_libname .. "-" .. arg[arg_num] .. ".so "
|
treesitter_grammar_libnames=treesitter_grammar_libnames .. base_libname .. "-" .. arg[arg_num] .. ".so "
|
||||||
end
|
end
|
||||||
@ -42,7 +48,6 @@ function treesitter_grammars()
|
|||||||
print("Provides: treesitter_grammar(" .. base_name .. "-" .. arg[arg_num] .. ")\n")
|
print("Provides: treesitter_grammar(" .. base_name .. "-" .. arg[arg_num] .. ")\n")
|
||||||
end
|
end
|
||||||
rpm.define("treesitter_grammar_names " .. treesitter_grammar_names)
|
rpm.define("treesitter_grammar_names " .. treesitter_grammar_names)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -76,6 +81,11 @@ function treesitter_build()
|
|||||||
rpm.expand("%_treesitter_macro_init")
|
rpm.expand("%_treesitter_macro_init")
|
||||||
local basename = rpm.expand("%{_treesitter_grammar_base_libname}")
|
local basename = rpm.expand("%{_treesitter_grammar_base_libname}")
|
||||||
local grammar_names = rpm.expand("%treesitter_grammar_names")
|
local grammar_names = rpm.expand("%treesitter_grammar_names")
|
||||||
|
local arg = arg
|
||||||
|
local suse_version = tonumber(rpm.expand("%suse_version"))
|
||||||
|
if suse_version < 1600 then
|
||||||
|
arg = arg_compat()
|
||||||
|
end
|
||||||
local left_over_args = arg[1]
|
local left_over_args = arg[1]
|
||||||
local grammar_arg_binding = ""
|
local grammar_arg_binding = ""
|
||||||
|
|
||||||
@ -170,6 +180,12 @@ function treesitter_devel_install()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local arg = arg
|
||||||
|
local suse_version = tonumber(rpm.expand("%suse_version"))
|
||||||
|
if suse_version < 1600 then
|
||||||
|
arg = arg_compat()
|
||||||
|
end
|
||||||
|
|
||||||
if #arg > 0 then
|
if #arg > 0 then
|
||||||
--[[ FIXME: This maybe not be the best solution if packages can have a single grammar
|
--[[ FIXME: This maybe not be the best solution if packages can have a single grammar
|
||||||
but also addon files
|
but also addon files
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Mar 25 21:58:38 UTC 2024 - Björn Bidar <bjorn.bidar@thaodan.de>
|
||||||
|
|
||||||
|
- Add workaround to packaging macros for RPM being to old on current Leap
|
||||||
|
- Add workaround for Python below 3.9 on Leap
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri Mar 22 19:35:31 UTC 2024 - Björn Bidar <bjorn.bidar@thaodan.de>
|
Fri Mar 22 19:35:31 UTC 2024 - Björn Bidar <bjorn.bidar@thaodan.de>
|
||||||
|
|
||||||
|
@ -7,12 +7,23 @@
|
|||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
|
|
||||||
|
|
||||||
|
import platform
|
||||||
import fileinput
|
import fileinput
|
||||||
import re
|
import re
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
if platform.sys.version_info.minor < 9:
|
||||||
|
def remove_prefix(text, prefix):
|
||||||
|
if text.startswith(prefix):
|
||||||
|
return text[len(prefix):]
|
||||||
|
return text
|
||||||
|
def remove_suffix(text, suffix):
|
||||||
|
if text.endswith(suffix):
|
||||||
|
return text[:-len(suffix):]
|
||||||
|
return text
|
||||||
|
|
||||||
treeSitterGrammarSrcPath = "/usr/include/tree_sitter"
|
treeSitterGrammarSrcPath = "/usr/include/tree_sitter"
|
||||||
treeSitterGrammarSymbolToken = "treesitter_grammar_src"
|
treeSitterGrammarSymbolToken = "treesitter_grammar_src"
|
||||||
grammarPaths = []
|
grammarPaths = []
|
||||||
@ -57,10 +68,17 @@ def dummyRequire(requiredFile_fd: str, maxDepth: Optional[int] = 5 ) -> str:
|
|||||||
requiredLvl2 = re.match(require_re, r_line)
|
requiredLvl2 = re.match(require_re, r_line)
|
||||||
#print(r_line)
|
#print(r_line)
|
||||||
if requiredLvl2 is not None:
|
if requiredLvl2 is not None:
|
||||||
requiredLvl2_grp_cleaned = \
|
if platform.sys.version_info.minor < 9:
|
||||||
requiredLvl2.group(1).removeprefix("'").removesuffix("'")
|
requiredLvl2_grp_cleaned = \
|
||||||
requiredLvl2_grp_cleaned = \
|
remove_suffix(remove_prefix(requiredLvl2.group(1), "'"), "'")
|
||||||
requiredLvl2_grp_cleaned.removeprefix("\"").removesuffix("\"")
|
requiredLvl2_grp_cleaned = \
|
||||||
|
remove_suffix(remove_prefix(requiredLvl2_grp_cleaned, "\""),
|
||||||
|
"\"")
|
||||||
|
else:
|
||||||
|
requiredLvl2_grp_cleaned = \
|
||||||
|
requiredLvl2.group(1).removeprefix("'").removesuffix("'")
|
||||||
|
requiredLvl2_grp_cleaned = \
|
||||||
|
requiredLvl2_grp_cleaned.removeprefix("\"").removesuffix("\"")
|
||||||
if not requiredLvl2_grp_cleaned.split('/')[0] == "..":
|
if not requiredLvl2_grp_cleaned.split('/')[0] == "..":
|
||||||
# Don't emit dependencies which are local
|
# Don't emit dependencies which are local
|
||||||
pass
|
pass
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:8158ba3e18b25a81d41e6937d120597630a57181996355154197e6988d632030
|
oid sha256:636609804ef5535c53a60e42ff1fac0a35d29aac4df98bd308fe2e7b25492b60
|
||||||
size 30391447
|
size 30401756
|
||||||
|
Loading…
x
Reference in New Issue
Block a user