blob: 8847b52625535d3981555d08bf78d2997aeee661 [file] [log] [blame]
Chris Frantz340e6232021-08-25 15:56:28 -07001# Copyright lowRISC contributors.
2# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3# SPDX-License-Identifier: Apache-2.0
4
Drew Macraed3029c72021-09-24 19:24:09 +00005load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
Drew Macrae0b93de02022-04-04 17:36:34 -04006load("//rules:quality.bzl", "clang_format_check", "html_coverage_report")
Chris Frantzb3a10932022-06-03 14:52:06 -07007load("//rules:cargo.bzl", "cargo_raze")
Drew Macrae0b93de02022-04-04 17:36:34 -04008load("@lowrisc_lint//rules:rules.bzl", "licence_check")
Chris Frantzb0b81e62022-06-01 14:07:33 -07009load("@rules_rust//rust:defs.bzl", "rust_analyzer")
Drew Macraed3029c72021-09-24 19:24:09 +000010
Chris Frantze7454162021-08-25 14:43:05 -070011package(default_visibility = ["//visibility:public"])
Drew Macraed3029c72021-09-24 19:24:09 +000012
Chris Frantzb0b81e62022-06-01 14:07:33 -070013exports_files(["python-requirements.txt"])
14
Drew Macrae2c235ba2022-04-04 17:01:44 -040015unbuildify = [
Miguel Young de la Sota98cfa222022-04-06 15:31:06 -040016 "./WORKSPACE", # Prevent Buildifier from inserting unnecessary newlines.
Drew Macrae2c235ba2022-04-04 17:01:44 -040017 "./**/vendor/**",
18 "./util/lowrisc_misc-linters/**",
Drew Macraee3b85492022-04-18 17:23:06 -040019 "./build/**",
Drew Macrae2c235ba2022-04-04 17:01:44 -040020]
21
Drew Macraed3029c72021-09-24 19:24:09 +000022buildifier(
Chris Frantz6fb3f4e2021-11-12 10:56:10 -080023 name = "buildifier_fix",
Drew Macrae2c235ba2022-04-04 17:01:44 -040024 exclude_patterns = unbuildify,
Drew Macraed3029c72021-09-24 19:24:09 +000025)
Chris Frantz3f87fe02021-11-12 09:59:04 -080026
Chris Frantz6fb3f4e2021-11-12 10:56:10 -080027buildifier(
28 name = "buildifier_check",
29 diff_command = "diff -u",
Drew Macrae2c235ba2022-04-04 17:01:44 -040030 exclude_patterns = unbuildify,
Chris Frantz6fb3f4e2021-11-12 10:56:10 -080031 mode = "diff",
32)
33
Drew Macrae0b93de02022-04-04 17:36:34 -040034licence_check(
Chris Frantz3f87fe02021-11-12 09:59:04 -080035 name = "license_check",
Drew Macrae0b93de02022-04-04 17:36:34 -040036 exclude_patterns = [".style.yapf"],
37 licence = """
38 Copyright lowRISC contributors.
39 Licensed under the Apache License, Version 2.0, see LICENSE for details.
40 SPDX-License-Identifier: Apache-2.0
41 """,
Chris Frantz3f87fe02021-11-12 09:59:04 -080042)
Chris Frantz6fb3f4e2021-11-12 10:56:10 -080043
44clang_format_check(
45 name = "clang_format_check",
46 exclude_patterns = [
47 # Vendored source code dirs
48 "./**/vendor/**",
49 # Rust cargo build dirs
50 "./**/target/**",
Timothy Trippel5d96baf2022-06-06 22:44:06 -070051 # (Old) Meson build dirs that Bazel artifacts are still copied into.
Chris Frantz6fb3f4e2021-11-12 10:56:10 -080052 "./build-out/**",
53 "./build-bin/**",
54 # fusesoc build dir
55 "./build/**",
56 ],
57 mode = "diff",
58)
59
60clang_format_check(
61 name = "clang_format_fix",
62 exclude_patterns = [
63 # Vendored source code dirs
64 "./**/vendor/**",
65 # Rust cargo build dirs
66 "./**/target/**",
Timothy Trippel5d96baf2022-06-06 22:44:06 -070067 # (Old) Meson build dirs that Bazel artifacts are still copied into.
Chris Frantz6fb3f4e2021-11-12 10:56:10 -080068 "./build-out/**",
69 "./build-bin/**",
70 # fusesoc build dir
71 "./build/**",
72 ],
73 mode = "fix",
74)
Chris Frantz6da32ea2021-11-22 13:12:08 -080075
Chris Frantzb231f112021-12-02 15:42:10 -080076html_coverage_report(
77 name = "html_coverage_report",
78)
79
Chris Frantz6da32ea2021-11-22 13:12:08 -080080filegroup(
81 name = "cores",
82 srcs = [
83 "check_tool_requirements.core",
84 "topgen.core",
85 "topgen-reg-only.core",
86 ],
87)
Timothy Trippelb54abfa2022-04-12 18:04:10 -070088
Chris Frantzb0b81e62022-06-01 14:07:33 -070089alias(
90 name = "gen_rust_project",
91 actual = "@rules_rust//tools/rust_analyzer:gen_rust_project",
92)
93
94# Do not use directly, run `:gen_rust_project` instead.
95rust_analyzer(
96 name = "rust_analyzer",
97 targets = [
98 "//sw/host/opentitanlib:opentitanlib",
99 "//sw/host/opentitansession:opentitansession",
100 "//sw/host/opentitantool:opentitantool",
101 "//sw/host/rom_ext_image_tools/signer:rom_ext_signer",
102 "//sw/host/rom_ext_image_tools/signer/image:rom_ext_image",
103 ],
104)
Chris Frantzb3a10932022-06-03 14:52:06 -0700105
106cargo_raze(
107 name = "cargo_raze",
108 cargo = [
109 "third_party/rust/crates/Cargo.toml",
110 ],
111)