Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
panekj committed Jun 21, 2024
1 parent 79eebb5 commit c990ed4
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
ci = os.getenv("GITHUB_ACTIONS")

logger = logging.getLogger(__name__)
logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(asctime)s %(message)s')
logging.basicConfig(
stream=sys.stdout, level=logging.INFO, format="%(asctime)s %(message)s"
)

cwd = Path.cwd().resolve()
logger.info("cwd: %s", cwd)
Expand Down Expand Up @@ -40,10 +42,21 @@ def lib_suffix():
return ""


def build(grammar):
def build(grammar, grammar_name, output):
"""Build tree-sitter grammar"""
# pylint: disable-next=exec-used
make = run(['tree-sitter', 'build', '.'], capture_output=True, check=False, cwd=grammar)
make = run(
[
"tree-sitter",
"build",
"--output",
output.joinpath(f"lib{grammar_name}.{lib_suffix()}"),
".",
],
capture_output=True,
check=False,
cwd=grammar,
)
for line in make.stdout.splitlines():
logging.info(line.decode())
for line in make.stderr.splitlines():
Expand All @@ -53,6 +66,7 @@ def build(grammar):
return False
return True


def main():
"""Main program"""
output = cwd.joinpath("output")
Expand Down Expand Up @@ -87,36 +101,31 @@ def main():
case "tree-sitter-php": # multi-grammar
grammar = grammar.joinpath("php")
case "tree-sitter-vue":
continue # C++ grammar
continue # C++ grammar
case "tree-sitter-sql":
continue # C++ grammar
continue # C++ grammar

match grammar_name:
case "tree-sitter-markdown":
for subdir in ["tree-sitter-markdown", "tree-sitter-markdown-inline"]:
if build(grammar.joinpath(subdir)) is False:
if build(grammar.joinpath(subdir), grammar_name, output) is False:
continue
case "tree-sitter-ocaml":
for subdir in ["grammars/ocaml", "grammars/interface", "grammars/type"]:
if build(grammar.joinpath(subdir)) is False:
if build(grammar.joinpath(subdir), grammar_name, output) is False:
continue
case "tree-sitter-typescript":
for subdir in ["tsx", "typescript"]:
if build(grammar.joinpath(subdir)) is False:
if build(grammar.joinpath(subdir), grammar_name, output) is False:
continue
case "tree-sitter-wasm":
for subdir in ["wast", "wat"]:
if build(grammar.joinpath(subdir)) is False:
if build(grammar.joinpath(subdir), grammar_name, output) is False:
continue
case _:
if build(grammar) is False:
if build(grammar, grammar_name, output) is False:
continue

for lib in grammar.glob(f"**/libtree-sitter-*.{lib_suffix()}"):
lib_path = grammar.joinpath(lib)
logging.info("copying '%s' to output", lib_path)
copy(lib_path, output)

def copy_lic(src_lic_path, dst_lic_path):
logging.info("copying '%s' to '%s'", src_lic_path, dst_lic_path)
copy(src_lic_path, dst_lic_path)
Expand Down Expand Up @@ -150,7 +159,7 @@ def copy_lic(src_lic_path, dst_lic_path):
# Get first one
lic = next(copg, next(licg, ""))

if lic != '' and lic.exists() is True:
if lic != "" and lic.exists() is True:
suffix = "LICENSE"
if lic.name.startswith("COPYING"):
suffix = "COPYING"
Expand Down

0 comments on commit c990ed4

Please sign in to comment.