mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
94 lines
2.2 KiB
Python
Executable File
94 lines
2.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import glob as py_glob
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
from typing import Optional
|
|
|
|
LIBS = {}
|
|
|
|
|
|
def load(bzl: str, *syms: str) -> None:
|
|
pass
|
|
|
|
|
|
def exports_files(srcs: list[str],
|
|
visibility: Optional[list[str]] = None) -> None:
|
|
pass
|
|
|
|
|
|
def cc_library(name: str, **kwargs: list[str]) -> None:
|
|
LIBS[name] = kwargs
|
|
|
|
|
|
def cc_test(name: str, **kwargs: list[str]) -> None:
|
|
pass
|
|
|
|
|
|
def cc_fuzz_test(name: str, **kwargs: list[str]) -> None:
|
|
pass
|
|
|
|
|
|
def select(selector: dict[str, list[str]]) -> list[str]:
|
|
return selector["//tools/config:linux"]
|
|
|
|
|
|
def glob(include: list[str]) -> list[str]:
|
|
return [
|
|
f[len("toxcore/"):] for p in include
|
|
for f in py_glob.glob(os.path.join("toxcore", p))
|
|
]
|
|
|
|
|
|
def alias(name: str, actual: str, visibility: list[str]) -> None:
|
|
pass
|
|
|
|
|
|
def sh_library(name: str, **kwargs: list[str]) -> None:
|
|
pass
|
|
|
|
|
|
def main() -> None:
|
|
with open("toxcore/BUILD.bazel", "r") as fh:
|
|
exec(fh.read())
|
|
|
|
with open("module.modulemap", "w") as fh:
|
|
for name, lib in LIBS.items():
|
|
fh.write("module " + name + " {\n")
|
|
for hdr in lib["hdrs"]:
|
|
fh.write(f' header "toxcore/{hdr}"\n')
|
|
for dep in lib.get("deps", []):
|
|
if dep[0] == ":":
|
|
fh.write(f" use {dep[1:]}\n")
|
|
fh.write("}\n")
|
|
|
|
srcs = sorted(
|
|
set(
|
|
os.path.join("toxcore", src) for lib in LIBS.values()
|
|
for src in lib.get("srcs", [])))
|
|
for src in srcs:
|
|
print(f"Validating {src}", file=sys.stderr)
|
|
subprocess.run(
|
|
[
|
|
"clang",
|
|
"-xc++",
|
|
"-fsyntax-only",
|
|
"-Wall",
|
|
"-Werror",
|
|
"-Wno-missing-braces",
|
|
"-std=c++23",
|
|
"-fdiagnostics-color=always",
|
|
"-fmodules",
|
|
# TODO(iphydf): Fix all the other errors.
|
|
# "-fmodules-strict-decluse",
|
|
"-fmodules-decluse",
|
|
"-fmodule-map-file=module.modulemap",
|
|
src,
|
|
],
|
|
check=True,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|