镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/generate_build_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ def strip_prefix(filename, prefix = "src/"):

if args.bazel:
# 8562a4ec: Remove CommonGraphOptions from Utils target and warnings
graph_files += ["//utils:CommonGraphOptions.cpp"]
bazel_graph_files = graph_files + ["//utils:CommonGraphOptions.cpp"]

bazel_build_string = build_from_template_bazel(
graph_files, lib_files_sve, lib_files_sve_no_vectorize, lib_files_sve2, lib_files + lib_files_neon_fp16)
bazel_graph_files, lib_files_sve, lib_files_sve_no_vectorize, lib_files_sve2, lib_files + lib_files_neon_fp16)
with open("src/BUILD.bazel", "w") as fp:
fp.write(bazel_build_string)

Expand Down
54 changes: 54 additions & 0 deletions scripts/tests/test_generate_build_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# SPDX-FileCopyrightText: Copyright 2026 Yusuf Efe
#
# SPDX-License-Identifier: MIT

"""Run with: python -m unittest discover -s scripts/tests -p test_generate_build_files.py -v."""

from pathlib import Path
import shutil
import subprocess
import sys
import tempfile
import unittest

ROOT = Path(__file__).resolve().parents[2]
SCRIPT = ROOT / "scripts" / "generate_build_files.py"


class GenerateBuildFilesTest(unittest.TestCase):
def generate(self, *flags):
with tempfile.TemporaryDirectory(prefix="acl build ") as directory:
root = Path(directory)
shutil.copyfile(ROOT / "filelist.json", root / "filelist.json")
graph = root / "src" / "graph"
graph.mkdir(parents=True)
(graph / "Graph.cpp").touch()
result = subprocess.run(
[sys.executable, str(SCRIPT), *flags], cwd=root, capture_output=True, text=True
)
self.assertEqual(result.returncode, 0, result.stderr)
return {
name: (root / "src" / name).read_bytes()
for name in ("CMakeLists.txt", "BUILD.bazel")
if (root / "src" / name).exists()
}

def test_combined_generation_matches_separate_invocations(self):
cmake = self.generate("--cmake")
bazel = self.generate("--bazel")
self.assertEqual(set(cmake), {"CMakeLists.txt"})
self.assertEqual(set(bazel), {"BUILD.bazel"})
for flags in (("--bazel", "--cmake"), ("--cmake", "--bazel")):
with self.subTest(flags=flags):
self.assertEqual(self.generate(*flags), {**cmake, **bazel})

def test_bazel_utility_label_stays_out_of_cmake(self):
outputs = self.generate("--bazel", "--cmake")
self.assertIn(b"//utils:CommonGraphOptions.cpp", outputs["BUILD.bazel"])
self.assertNotIn(b"//utils:CommonGraphOptions.cpp", outputs["CMakeLists.txt"])
self.assertIn(b"Graph.cpp", outputs["BUILD.bazel"])
self.assertIn(b"Graph.cpp", outputs["CMakeLists.txt"])


if __name__ == "__main__":
unittest.main()