Skip to content

Commit 90a3902

Browse files
committed
Bazel build and test all works
1 parent e2f5e5b commit 90a3902

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

MODULE.bazel

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module(
1111
repo_name = "mlir_tutorial",
1212
)
1313

14-
# Core Bazel dependencies that are available in BCR
14+
# Dependencies available in BCR
1515
bazel_dep(name = "bazel_skylib", version = "1.7.1")
1616
bazel_dep(name = "rules_python", version = "1.2.0")
1717
bazel_dep(name = "platforms", version = "0.0.11")
@@ -20,8 +20,6 @@ bazel_dep(name = "rules_java", version = "8.12.0")
2020
bazel_dep(name = "protobuf", version = "30.1")
2121
bazel_dep(name = "rules_proto", version = "7.1.0")
2222
bazel_dep(name = "rules_pkg", version = "1.1.0")
23-
24-
# External dependencies available in BCR
2523
bazel_dep(name = "re2", version = "2024-07-02.bcr.1")
2624
bazel_dep(name = "abseil-cpp", version = "20250512.1")
2725
bazel_dep(name = "or-tools", version = "9.12")
@@ -58,13 +56,13 @@ llvm_configure(name = "llvm-project")
5856

5957
# Configure Python dependencies
6058
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
61-
python.toolchain(python_version = "3.10")
62-
use_repo(python, "python_3_10")
59+
python.toolchain(python_version = "3.13")
60+
use_repo(python, "python_3_13")
6361

6462
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
6563
pip.parse(
6664
hub_name = "mlir_tutorial_pip_deps",
67-
python_version = "3.10",
65+
python_version = "3.13",
6866
requirements_lock = "//:requirements.txt",
6967
)
7068
use_repo(pip, "mlir_tutorial_pip_deps")

bazel/lit.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ def lit_test(name = None, src = None, size = "small", tags = None):
5151
# -v ensures lit outputs useful info during test failures
5252
args = ["-v", paths.join(native.package_name(), src)],
5353
data = ["@mlir_tutorial//tests:test_utilities", filegroup_name],
54+
deps = ["@mlir_tutorial_pip_deps//lit"],
5455
srcs = ["@llvm-project//llvm:lit"],
5556
main = "lit.py",
57+
python_version = "PY3",
5658
tags = tags,
5759
)
5860

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lit==16.0.6
1+
lit==18.1.8

tests/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ filegroup(
1616
"@llvm-project//mlir:mlir-runner",
1717
"@llvm-project//mlir:mlir-opt",
1818
"@llvm-project//mlir:mlir-translate",
19-
"@mlir_tutorial_pip_deps_lit//:pkg",
19+
"@mlir_tutorial_pip_deps//lit",
2020
],
2121
)
2222

tests/lit.cfg.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# lit executes relative to the directory
1414
#
15-
# bazel-bin/tests/<test_target_name>.runfiles/mlir_tutorial/
15+
# bazel-bin/tests/<test_target_name>.runfiles/_main/
1616
#
1717
# which contains all the binary targets included in via the `data` attribute in
1818
# the lit.bzl macro, which in turn gets them from the filegroup //tests:test_utilities.
@@ -25,14 +25,16 @@
2525
# print(subprocess.run(["ls", "-l", os.environ["RUNFILES_DIR"]]).stdout)
2626
# print(subprocess.run([ "env", ]).stdout)
2727
#
28-
# Bazel defines RUNFILES_DIR which includes mlir_tutorial/ and third party
28+
# Bazel defines RUNFILES_DIR which includes _main/ and third party
2929
# dependencies as their own directory. Generally, it seems that $PWD ==
30-
# $RUNFILES_DIR/mlir_tutorial/
30+
# $RUNFILES_DIR/_main/
3131
runfiles_dir = Path(os.environ["RUNFILES_DIR"])
32+
33+
# Fix tool paths to use _main instead of mlir_tutorial
3234
tool_relpaths = [
33-
"llvm-project/mlir",
34-
"llvm-project/llvm",
35-
"mlir_tutorial/tools",
35+
"+_repo_rules+llvm-project/mlir",
36+
"+_repo_rules+llvm-project/llvm",
37+
"_main/tools",
3638
]
3739

3840
config.environment["PATH"] = (
@@ -42,6 +44,6 @@
4244
)
4345

4446
substitutions = {
45-
"%project_source_dir": str(runfiles_dir.joinpath(Path('mlir_tutorial'))),
47+
"%project_source_dir": str(runfiles_dir.joinpath(Path('_main'))),
4648
}
4749
config.substitutions.extend(substitutions.items())

0 commit comments

Comments
 (0)